diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 913dc87d333..0bcd0040c6f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -15,7 +15,7 @@ * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023-2024 Benjamin Falière - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2025 Lenin Rivas * * This program is free software; you can redistribute it and/or modify @@ -608,7 +608,7 @@ if (empty($reshook)) { } elseif ($action == 'setabsolutediscount' && $usercancreate) { if (GETPOST('remise_id')) { if ($object->id > 0) { - $object->insert_discount(GETPOST('remise_id')); + $object->insert_discount(GETPOSTINT('remise_id')); } else { dol_print_error($db, $object->error); } @@ -640,12 +640,12 @@ if (empty($reshook)) { // Multicurrency rate $result = $object->setMulticurrencyRate(GETPOSTFLOAT('multicurrency_tx'), GETPOSTINT('calculation_mode')); } elseif ($action == 'setavailability' && $usercancreate) { - $result = $object->availability(GETPOST('availability_id')); + $result = $object->availability(GETPOSTINT('availability_id')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setdemandreason' && $usercancreate) { - $result = $object->demand_reason(GETPOST('demand_reason_id')); + $result = $object->demand_reason(GETPOSTINT('demand_reason_id')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -719,7 +719,7 @@ if (empty($reshook)) { $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); foreach ($object->lines as $line) { - $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, (float) $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { // Define remise_percent @@ -730,7 +730,7 @@ if (empty($reshook)) { if (!empty($line->vat_src_code)) { $tvatx .= ' ('.$line->vat_src_code.')'; } - $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $tvatx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, (float) $remise_percent, $tvatx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } } elseif ($action == 'addline' && !GETPOST('submitforalllines', 'alpha') && $usercancreate) { // Add a new line $langs->load('errors'); @@ -870,7 +870,7 @@ if (empty($reshook)) { $prodcustprice = new ProductCustomerPrice($db); - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); + $filter = array('t.fk_product' => (string) $prod->id, 't.fk_soc' => (string) $object->thirdparty->id); // If a price per customer exist $pricebycustomerexist = false; @@ -939,7 +939,7 @@ if (empty($reshook)) { $prodcustprice = new ProductCustomerPrice($db); - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); + $filter = array('t.fk_product' => (string) $prod->id, 't.fk_soc' => (string) $object->thirdparty->id); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); if ($result >= 0) { @@ -1136,7 +1136,7 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOSTINT('fournprice'.$predef) : ''); $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value // Prepare a price equivalent for minimum price check @@ -1182,7 +1182,7 @@ if (empty($reshook)) { if (!$error) { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), $fournprice, (float) $buyingprice, $label, $array_options, $fk_unit, '', 0, (float) $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -1395,7 +1395,7 @@ if (empty($reshook)) { $price_base_type = 'TTC'; } - $result = $object->updateline(GETPOSTINT('lineid'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); + $result = $object->updateline(GETPOSTINT('lineid'), $description, (float) $pu, (float) $qty, $remise_percent, (float) $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOSTINT('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOSTINT('units'), (float) $pu_ht_devise); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { @@ -1625,7 +1625,7 @@ if (empty($reshook)) { } if ($action == 'update_extras' && $usercancreate) { - $object->oldcopy = dol_clone($object, 2); + $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form @@ -1743,7 +1743,7 @@ if (empty($reshook)) { if (!$error && getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && $usercancreate) { if ($action == 'addcontact' && $usercancreate) { if ($object->id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } @@ -2070,13 +2070,13 @@ if ($action == 'create' && $usercancreate) { // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); - print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); + print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', (float) $deposit_percent); print ''; // Payment mode print ''.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - print $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_types_paiements((string) $mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); print ''; // Bank Account @@ -2125,7 +2125,7 @@ if ($action == 'create' && $usercancreate) { // Incoterms if (isModEnabled('incoterm')) { print ''; - print ''; + print ''; print ''; $incoterm_id = GETPOST('incoterm_id'); $location_incoterms = GETPOST('location_incoterms'); @@ -2176,7 +2176,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET('multicurrency_code') && !GETPOST('changecompany')) ? GETPOST('multicurrency_code') : $currency_code), 'multicurrency_code', 0, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET('multicurrency_code') && !GETPOST('changecompany')) ? GETPOST('multicurrency_code') : $currency_code), 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -2194,7 +2194,7 @@ if ($action == 'create' && $usercancreate) { print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', (string) $note_public, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print ''; @@ -2205,7 +2205,7 @@ if ($action == 'create' && $usercancreate) { print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', (string) $note_private, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print ''; @@ -2603,8 +2603,8 @@ if ($action == 'create' && $usercancreate) { $morehtmlref = '
'; // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, (int) $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, (int) $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$soc->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { @@ -2619,7 +2619,7 @@ if ($action == 'create' && $usercancreate) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2689,7 +2689,7 @@ if ($action == 'create' && $usercancreate) { // Date print ''; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; - print $form->editfieldkey("Date", 'date', '', $object, $editenable); + print $form->editfieldkey("Date", 'date', '', $object, (int) $editenable); print ''; if ($action == 'editdate') { print '
'; @@ -2711,7 +2711,7 @@ if ($action == 'create' && $usercancreate) { // Delivery date planned print ''; $editenable = $usercancreate; - print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); + print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, (int) $editenable); print ''; if ($action == 'editdate_livraison') { print ''; @@ -2733,12 +2733,12 @@ if ($action == 'create' && $usercancreate) { // Delivery delay print ''; $editenable = $usercancreate; - print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); + print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, (int) $editenable); print ''; if ($action == 'editavailability') { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->availability_id, 'availability_id', 1); } else { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->availability_id, 'none', 1); } print ''; @@ -2746,12 +2746,12 @@ if ($action == 'create' && $usercancreate) { if (isModEnabled('shipping')) { print ''; $editenable = $usercancreate; - print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); + print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, (int) $editenable); print ''; if ($action == 'editshippingmethod') { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->shipping_method_id, 'shipping_method_id', 1); } else { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->shipping_method_id, 'none'); } print ''; print ''; @@ -2764,7 +2764,7 @@ if ($action == 'create' && $usercancreate) { $formproduct = new FormProduct($db); print ''; $editenable = $usercancreate; - print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); + print $form->editfieldkey("Warehouse", 'warehouse', '', $object, (int) $editenable); print ''; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); @@ -2778,24 +2778,24 @@ if ($action == 'create' && $usercancreate) { // Source reason (why we have an order) print ''; $editenable = $usercancreate; - print $form->editfieldkey("Source", 'demandreason', '', $object, $editenable); + print $form->editfieldkey("Source", 'demandreason', '', $object, (int) $editenable); print ''; if ($action == 'editdemandreason') { - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->demand_reason_id, 'none'); } print ''; // Terms of payment print ''; $editenable = $usercancreate; - print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); + print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, (int) $editenable); print ''; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1, '', 1, $object->deposit_percent); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->cond_reglement_id, 'none', 1, '', 1, $object->deposit_percent); } print ''; @@ -2804,12 +2804,12 @@ if ($action == 'create' && $usercancreate) { // Mode of payment print ''; $editenable = $usercancreate; - print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); + print $form->editfieldkey("PaymentMode", 'mode', '', $object, (int) $editenable); print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->mode_reglement_id, 'none'); } print ''; @@ -2849,7 +2849,7 @@ if ($action == 'create' && $usercancreate) { if (isModEnabled('incoterm')) { print ''; $editenable = $usercancreate; - print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); + print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, (int) $editenable); print ''; print ''; if ($action != 'editincoterm') { @@ -2864,12 +2864,12 @@ if ($action == 'create' && $usercancreate) { if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled("bank")) { print ''; $editenable = $usercancreate; - print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); + print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, (int) $editenable); print ''; if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'fk_account', 1); } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'none'); } print ''; print ''; @@ -2896,7 +2896,7 @@ if ($action == 'create' && $usercancreate) { print ''; $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ORDER); - $arrayselected=[]; + $arrayselected = []; foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -3101,9 +3101,9 @@ if ($action == 'create' && $usercancreate) { // Valid if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || getDolGlobalString('ORDER_ENABLE_NEGATIVE')) && $usercanvalidate) { if ($numlines > 0) { - print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, $object->id, 1); + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, (string) $object->id, 1); } else { - print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, $object->id, 0); + print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, (string) $object->id, 0); } } // Edit @@ -3213,9 +3213,9 @@ if ($action == 'create' && $usercancreate) { ]; if ($numlines > 0) { - print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayforbutaction, $object->id, 1, $actionButtonsParameters); + print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayforbutaction, (string) $object->id, 1, $actionButtonsParameters); } else { - print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans("Create"), 'default', $arrayforbutaction, $object->id, 0, $actionButtonsParameters); + print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans("Create"), 'default', $arrayforbutaction, (string) $object->id, 0, $actionButtonsParameters); } // Set to shipped @@ -3273,7 +3273,7 @@ if ($action == 'create' && $usercancreate) { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); + print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, (int) $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); // Show links to link elements diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 05c18321cf7..6d079d30445 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1535,19 +1535,19 @@ class Commande extends CommonOrder * @param float $pu_ttc Prix unitaire TTC * @param int|string $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param int|string $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int<0,1> $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Parent line * @param int $fk_fournprice Id supplier price - * @param int $pa_ht Buying price (without tax) + * @param float $pa_ht Buying price (without tax) * @param string $label Label - * @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) + * @param array $array_options Extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * @param ?int $fk_unit Code of the unit to use. Null to use the default one * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param float $pu_ht_devise Unit price in currency - * @param string $ref_ext line external reference + * @param string $ref_ext Line external reference * @param int $noupdateafterinsertline No update after insert of line * @return int >0 if OK, <0 if KO * diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1ff63131a71..c1caa3d4ef3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2536,10 +2536,10 @@ class Facture extends CommonInvoice if (isset($this->retained_warranty)) { $this->retained_warranty = (float) $this->retained_warranty; } - if (!isset($this->user_creation_id) && isset($this->fk_user_author) ) { + if (!isset($this->user_creation_id) && isset($this->fk_user_author)) { $this->user_creation_id = $this->fk_user_author; } - if (!isset($this->user_validation_id) && isset($this->fk_user_valid) ) { + if (!isset($this->user_validation_id) && isset($this->fk_user_valid)) { $this->user_validation_id = $this->fk_user_valid; } @@ -4173,7 +4173,7 @@ class Facture extends CommonInvoice * @param string $label Label of the line (deprecated, do not use) * @param int $special_code Special code (also used by externals modules!) * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage + * @param float $situation_percent Situation advance percentage * @param ?int $fk_unit Code of the unit to use. Null to use the default one * @param float $pu_ht_devise Unit price in currency * @param int<0,1> $notrigger disable line update trigger diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 354062cdd59..81f282a76d7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2906,6 +2906,7 @@ abstract class CommonObject $line->product_type, $line->array_options, $line->ref_fourn, + (int) $line->fk_unit, $line->multicurrency_subprice ); break; @@ -3013,7 +3014,7 @@ abstract class CommonObject $sql = 'UPDATE '.$this->db->prefix().$this->table_element; $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); if (in_array($this->table_element, array('propal', 'commande', 'societe'))) { - $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'"); + $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'".$this->db->escape((string) $deposit_percent)."'"); } $sql .= ' WHERE rowid='.((int) $this->id); @@ -5344,7 +5345,7 @@ abstract class CommonObject $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } - if (empty($reshook)) { + if (empty($reshook) && $buyer !== null) { $this->printObjectLine($action, $line, '', $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir); } @@ -5394,6 +5395,7 @@ abstract class CommonObject // Define output language and label if (getDolGlobalInt('MAIN_MULTILANGS')) { + // @phan-suppress-next-line PhanUndeclaredProperty if (property_exists($this, 'socid') && !empty($this->socid) && !is_object($this->thirdparty)) { dol_print_error(null, 'Error: Method printObjectLine was called on an object and object->fetch_thirdparty was not done before'); return; @@ -5719,10 +5721,10 @@ abstract class CommonObject $sql .= ") VALUES ("; $sql .= ((int) $resource_id); $sql .= ", '".$this->db->escape($resource_type)."'"; - $sql .= ", '".$this->db->escape($this->id)."'"; + $sql .= ", '".$this->db->escape((string) $this->id)."'"; $sql .= ", '".$this->db->escape($this->element)."'"; - $sql .= ", '".$this->db->escape($busy)."'"; - $sql .= ", '".$this->db->escape($mandatory)."'"; + $sql .= ", '".$this->db->escape((string) $busy)."'"; + $sql .= ", '".$this->db->escape((string) $mandatory)."'"; $sql .= ")"; dol_syslog(get_class($this)."::add_element_resource", LOG_DEBUG); @@ -5959,10 +5961,23 @@ abstract class CommonObject $this->model_pdf = $saved_model; if ($obj instanceof ModelePDFMember) { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards'); + if ($this instanceof Adherent) { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards'); + } else { + $resultwritefile = -1; + dol_syslog("Error generating document - Provided ".get_class($this)." to ".get_class($obj)."::write_file()", LOG_ERR); + } + } elseif ($obj instanceof ModeleDon) { + // Only 3 arguments + if ($this instanceof Don) { + $resultwritefile = $obj->write_file($this, $outputlangs /*, $currency */); + } else { + $resultwritefile = -1; + dol_syslog("Error generating document - Provided ".get_class($this)." to Don::write_file()", LOG_ERR); + } } else { // TODO: Try to set type above again - '@phan-var-force ModeleBarCode|ModeleDon|ModeleExports|ModeleImports|ModelePDFAsset|ModelePDFContract|ModelePDFDeliveryOrder|ModelePDFEvaluation|ModelePDFFactures|ModelePDFFicheinter|ModelePDFMo|ModelePDFMovement|ModelePDFProduct|ModelePDFProjects|ModelePDFPropales|ModelePDFRecruitmentJobPosition|ModelePDFStock|ModelePDFStockTransfer|ModelePDFSupplierProposal|ModelePDFSuppliersInvoices|ModelePDFSuppliersOrders|ModelePDFSuppliersPayments|ModelePDFTask|ModelePDFTicket|ModelePDFUser|ModelePDFUserGroup|ModelePdfExpedition|ModelePdfReception|ModeleThirdPartyDoc $obj'; + '@phan-var-force ModeleBarCode|ModeleExports|ModeleImports|ModelePDFAsset|ModelePDFContract|ModelePDFDeliveryOrder|ModelePDFEvaluation|ModelePDFFactures|ModelePDFFicheinter|ModelePDFMo|ModelePDFMovement|ModelePDFProduct|ModelePDFProjects|ModelePDFPropales|ModelePDFRecruitmentJobPosition|ModelePDFStock|ModelePDFStockTransfer|ModelePDFSupplierProposal|ModelePDFSuppliersInvoices|ModelePDFSuppliersOrders|ModelePDFSuppliersPayments|ModelePDFTask|ModelePDFTicket|ModelePDFUser|ModelePDFUserGroup|ModelePdfExpedition|ModelePdfReception|ModeleThirdPartyDoc $obj'; $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); } // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. @@ -8304,7 +8319,8 @@ abstract class CommonObject //$objectfield = $valparent; $objectfield = $val; // Is better than using old method $valparent - $out = $form->selectForForms($param_list_array[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, (empty($val['disabled']) ? 0 : 1), '', $objectfield); + // @phan-suppress-next-line PhanTypeMismatchArgumentNullable + $out = $form->selectForForms($param_list_array[0], $keyprefix.$key.$keysuffix, (int) $value, $showempty, '', '', $morecss, $moreparam, 0, (empty($val['disabled']) ? 0 : 1), '', $objectfield); if (!empty($param_list_array[2])) { // If the entry into $fields is set, we must add a create button if ((!GETPOSTISSET('backtopage') || strpos(GETPOST('backtopage'), $_SERVER['PHP_SELF']) === 0) // // To avoid to open several times the 'Plus' button (we accept only one level) @@ -8544,15 +8560,15 @@ abstract class CommonObject $value = yn($value ? 1 : 0); } } elseif ($type == 'mail' || $type == 'email') { - $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); + $value = dol_print_email((string) $value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'url') { - $value = dol_print_url($value, '_blank', 32, 1); + $value = dol_print_url((string) $value, '_blank', 32, 1); } elseif ($type == 'phone') { - $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); + $value = dol_print_phone((string) $value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'ip') { - $value = dol_print_ip($value, 0); + $value = dol_print_ip((string) $value, 0); } elseif ($type == 'stars') { - $value = ''; + $value = ''; $value .= '
'; $i = 1; while ($i <= $size) { @@ -8653,7 +8669,7 @@ abstract class CommonObject } elseif ($selectkey == 'rowid') { $sql .= " WHERE ".$selectkey." = ".((int) $value); } else { - $sql .= " WHERE ".$selectkey." = '".$this->db->escape($value)."'"; + $sql .= " WHERE ".$selectkey." = '".$this->db->escape((string) $value)."'"; } //$sql.= ' AND entity = '.$conf->entity; @@ -8858,7 +8874,7 @@ abstract class CommonObject '@phan-var-force CommonObject $object'; if ($object->element === 'product') { // Special case for product because default valut of fetch are wrong '@phan-var-force Product $object'; - $result = $object->fetch($value, '', '', '', 0, 1, 1); + $result = $object->fetch((int) $value, '', '', '', 0, 1, 1); } else { $result = $object->fetch($value); } @@ -8911,7 +8927,7 @@ abstract class CommonObject if (!empty($value) && preg_match('/^text/', (string) $type) && !preg_match('/search_/', $keyprefix) && !empty($param['options'])) { $value = str_replace(',', "\n", $value); } - $value = dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr((string) $value); } //print $type.'-'.$size.'-'.$value; @@ -9009,7 +9025,7 @@ abstract class CommonObject // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) { $type = 'varchar'; // convert varchar(xx) int varchar - $maxSize = $reg[1]; + $maxSize = (int) $reg[1]; } elseif (preg_match('/varchar/', $type)) { $type = 'varchar'; // convert varchar(xx) int varchar } @@ -9156,11 +9172,11 @@ abstract class CommonObject $InfoFieldList = explode(":", $param_list[0]); $classname = $InfoFieldList[0]; $classpath = $InfoFieldList[1]; - if (!$validate->isFetchable($fieldValue, $classname, $classpath)) { + if (!$validate->isFetchable((int) $fieldValue, $classname, $classpath)) { $lastIsFetchableError = $validate->error; // from V19 of Dolibarr, In some cases link use element instead of class, example project_task - if ($validate->isFetchableElement($fieldValue, $classname)) { + if ($validate->isFetchableElement((int) $fieldValue, $classname)) { return true; } @@ -9481,7 +9497,7 @@ abstract class CommonObject $out .= getPictoForType($extrafields->attributes[$this->table_element]['type'][$key], ($extrafields->attributes[$this->table_element]['type'][$key] == 'text' ? 'tdtop' : '')); } //$out .= ''; - $out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this, $this->table_element); + $out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', '', $this, $this->table_element); break; case "edit": $listoftypestoshowpicto = explode(',', getDolGlobalString('MAIN_TYPES_TO_SHOW_PICTO', 'email,phone,ip,password')); @@ -10721,6 +10737,7 @@ abstract class CommonObject if (array_key_exists('user_modification_id', $fieldvalues) && !($fieldvalues['user_modification_id'] > 0)) { $fieldvalues['user_modification_id'] = $user->id; } + // @phan-suppress-next-line PhanUndeclaredProperty if (array_key_exists('pass_crypted', $fieldvalues) && property_exists($this, 'pass') && !empty($this->pass)) { // @phan-suppress-next-line PhanUndeclaredProperty $tmparray = dol_hash($this->pass, '0', 0, 1); diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index b0c986797a5..7854b3ee672 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ class Validate public $db; /** - * @var Translate $outputLang + * @var Translate */ public $outputLang; @@ -247,8 +247,8 @@ class Validate /** * Check for boolean validity * - * @param boolean $bool Boolean to validate - * @return boolean Validity is ok or not + * @param mixed $bool Value to validate, may not be bool + * @return bool Validity is ok or not */ public function isBool($bool) { @@ -342,9 +342,9 @@ class Validate * Check for all values in db for an element * @see self::isFetchable() * - * @param integer $id of element - * @param string $element_type the element type - * @return boolean Validity is ok or not + * @param int $id Element Id + * @param string $element_type The element type + * @return bool Validity is ok or not * @throws Exception */ public function isFetchableElement($id, $element_type) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 2b0f65ecfb7..da189c3dbc0 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -435,7 +435,7 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Buying price without tax * @param string $label ??? * @param array $array_options extrafields array - * @param string $ref_supplier Supplier price reference + * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. * @param string $origin 'order', 'supplier_proposal', ... * @param int $origin_id Id of origin line