Fix : php 8.1 warnings

This commit is contained in:
lmarcouiller 2022-09-27 11:22:20 +02:00
parent 5e6e6e1c98
commit 91d0eefd92
8 changed files with 48 additions and 22 deletions

View File

@ -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'])) {

View File

@ -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;

View File

@ -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 '</td>';
// 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 '<td class="right">';
print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $selectedvat), $mysoc, '', 0, 0, '', false, 1);
print '</td>';
// Unit price
print '<td class="right">';
print '<input type="text" min="0" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag(price2num($line->value_unit_ht)).'"'.$taxlessUnitPriceDisabled.' />';
print '<input type="text" min="0" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag(price2num((!empty($line->value_unit_ht) ? $line->value_unit_ht : ""))).'"'.$taxlessUnitPriceDisabled.' />';
print '</td>';
// Unit price with tax
@ -2521,19 +2524,19 @@ if ($action == 'create') {
// Select date
print '<td class="center inputdate">';
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 '</td>';
// Select project
if (isModEnabled('project')) {
print '<td class="inputproject">';
$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 '</td>';
}
// Select type
print '<td class="center inputtype">';
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 '</td>';
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
@ -2545,7 +2548,7 @@ if ($action == 'create') {
// Add comments
print '<td class="inputcomment">';
print '<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.'">'.dol_escape_htmltag($comments, 0, 1).'</textarea>';
print '<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.'">'.dol_escape_htmltag(!empty($comments) ? $comments : "", 0, 1).'</textarea>';
print '</td>';
// 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 '</td>';
// Unit price net
print '<td class="right inputpricenet">';
print '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag($value_unit_ht).'"'.$taxlessUnitPriceDisabled.' />';
print '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag((!empty($value_unit_ht) ? $value_unit_ht : 0)).'"'.$taxlessUnitPriceDisabled.' />';
print '</td>';
// Unit price with tax
print '<td class="right inputtax">';
print '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag($value_unit).'">';
print '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : 0)).'">';
print '</td>';
// Quantity
print '<td class="right inputqty">';
print '<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($qty ? $qty : 1).'">'; // We must be able to enter decimal qty
print '<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).'">'; // We must be able to enter decimal qty
print '</td>';
// Picture

View File

@ -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";

View File

@ -836,7 +836,7 @@ class CommandeFournisseur extends CommonOrder
$label = '';
if ($user->rights->fournisseur->commande->lire) {
if ($user->hasRight("fournisseur", "commande", "read")) {
$label = '<u class="paddingrightonly">'.$langs->trans("SupplierOrder").'</u>';
if (isset($this->statut)) {
$label .= ' '.$this->getLibStatut(5);

View File

@ -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,";

View File

@ -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 "</div>\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);

View File

@ -1016,7 +1016,7 @@ if ($resql) {
// Type ent
if (!empty($arrayfields['typent.code']['checked'])) {
print '<td class="center">';
if (count($typenArray) == 0) {
if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
$typenArray = $formcompany->typent_array(1);
}
print $typenArray[$obj->typent_code];