diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 5b678a0f7ac..b95d1e5253f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1900,7 +1900,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; } - $totalarray['val']['p.total_ht'] += $obj->total_ht; + if (empty($totalarray['val']['p.total_ht'])) { + $totalarray['val']['p.total_ht'] = $obj->total_ht; + } else { + $totalarray['val']['p.total_ht'] += $obj->total_ht; + } } // Amount VAT if (!empty($arrayfields['p.total_tva']['checked'])) { @@ -1911,7 +1915,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; } - $totalarray['val']['p.total_tva'] += $obj->total_tva; + if (empty($totalarray['val']['p.total_tva'])) { + $totalarray['val']['p.total_tva'] = $obj->total_tva; + } else { + $totalarray['val']['p.total_tva'] += $obj->total_tva; + } } // Amount TTC if (!empty($arrayfields['p.total_ttc']['checked'])) { @@ -1922,7 +1930,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; } - $totalarray['val']['p.total_ttc'] += $obj->total_ttc; + if (empty($totalarray['val']['p.total_ttc'])) { + $totalarray['val']['p.total_ttc'] = $obj->total_ttc; + } else { + $totalarray['val']['p.total_ttc'] += $obj->total_ttc; + } } // Amount invoiced HT if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { @@ -1933,7 +1945,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; } - $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; + if (empty($totalarray['val']['p.total_ht_invoiced'])) { + $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; + } else { + $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; + } } // Amount invoiced TTC if (!empty($arrayfields['p.total_invoiced']['checked'])) { @@ -1944,7 +1960,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; } - $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; + if (empty($totalarray['val']['p.total_invoiced'])) { + $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; + } else { + $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; + } } // Currency if (!empty($arrayfields['p.multicurrency_code']['checked'])) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index da6a6c5e1f8..6a9f49ce997 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -62,7 +62,7 @@ function product_prepare_head($object) if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase if ((((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->lire) - || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) + || (!empty($conf->margin->enabled) && $user->hasRight("margin", "liretous")) ) { if ($usercancreadprice) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c325aae4854..bb4f41861ec 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -155,6 +155,9 @@ $permissiontoadd = $user->rights->expensereport->creer; // Used by the include o /* * Actions */ +$value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); +$value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); +$qty = price2num(GETPOST('qty', 'alpha')); $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -2370,14 +2373,14 @@ if ($action == 'create') { print ''; // VAT - $selectedvat = price2num($line->vatrate).($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); + $selectedvat = price2num($line->vatrate).(!empty($line->vat_src_code) ? ' ('.$line->vat_src_code.')' : ''); print ''; print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $selectedvat), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price print ''; - print ''; + print ''; print ''; // Unit price with tax @@ -2521,19 +2524,19 @@ if ($action == 'create') { // Select date print ''; - print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); + print $form->selectDate(!empty($date) ? $date : -1, 'date', 0, 0, 0, '', 1, 1); print ''; // Select project if (isModEnabled('project')) { print ''; - $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, !empty($fk_project) ? $fk_project : 0, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } // Select type print ''; - print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1); + print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees : "", 'fk_c_type_fees', 1); print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { @@ -2545,7 +2548,7 @@ if ($action == 'create') { // Add comments print ''; - print ''; + print ''; print ''; // Select VAT @@ -2554,22 +2557,22 @@ if ($action == 'create') { if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; } - print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); + print $form->load_tva('vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price net print ''; - print ''; + print ''; print ''; // Unit price with tax print ''; - print ''; + print ''; print ''; // Quantity print ''; - print ''; // We must be able to enter decimal qty + print ''; // We must be able to enter decimal qty print ''; // Picture diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e0799a46f73..a1afcef74a2 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -771,6 +771,7 @@ class ExpenseReport extends CommonObject $sql .= " f.date_valid as datev,"; $sql .= " f.date_approve as datea,"; $sql .= " f.fk_user_creat as fk_user_creation,"; + $sql .= " f.fk_user_author as fk_user_author,"; $sql .= " f.fk_user_modif as fk_user_modification,"; $sql .= " f.fk_user_valid,"; $sql .= " f.fk_user_approve"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 38a9f051288..770276e96b8 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -836,7 +836,7 @@ class CommandeFournisseur extends CommonOrder $label = ''; - if ($user->rights->fournisseur->commande->lire) { + if ($user->hasRight("fournisseur", "commande", "read")) { $label = ''.$langs->trans("SupplierOrder").''; if (isset($this->statut)) { $label .= ' '.$this->getLibStatut(5); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 2a4b1072e87..107189e5181 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -74,7 +74,9 @@ if (empty($user->rights->margins->liretous)) { $invoicestatic = new Facture($db); $form = new Form($db); - +$totalMargin = 0; +$marginRate = 0; +$markRate = 0; if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); @@ -136,7 +138,7 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); - if ($user->rights->facture->lire) { + if ($user->hasRight("facture", "read")) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 53414a0a608..034fa97f86f 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -76,7 +76,7 @@ if ($user->socid) { $socid = $user->socid; } -if (empty($user->rights->fournisseur->lire)) { +if (empty($user->rights->fournisseur->lire) && (empty($conf->margin->enabled) && !$user->hasRight("margin", "liretous"))) { accessforbidden(); } @@ -919,7 +919,7 @@ END; print "\n"; - if ($user->rights->fournisseur->lire) { // Duplicate ? this check is already in the head of this file + if ($user->hasRight("fournisseur", "read")) { // Duplicate ? this check is already in the head of this file $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a0299ef3fec..5cb7cf69ef8 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -1016,7 +1016,7 @@ if ($resql) { // Type ent if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (count($typenArray) == 0) { + if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { $typenArray = $formcompany->typent_array(1); } print $typenArray[$obj->typent_code];