From c8e1b80ec3f2cc64dbf5be693fc18752674b235a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 21 Feb 2025 09:49:14 +0100 Subject: [PATCH] clean code --- htdocs/fourn/commande/card.php | 70 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e48220fd9c2..bae82735e73 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -149,13 +149,13 @@ if ($id > 0 || !empty($ref)) { } // Security check -$isdraft = (isset($object->statut) && ($object->statut == $object::STATUS_DRAFT) ? 1 : 0); +$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft); // Common permissions $usercanread = ($user->hasRight("fournisseur", "commande", "lire") || $user->hasRight("supplier_order", "lire")); $usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$usercandelete = (($user->hasRight("fournisseur", "commande", "supprimer") || $user->hasRight("supplier_order", "supprimer")) || ($usercancreate && isset($object->statut) && $object->statut == $object::STATUS_DRAFT)); +$usercandelete = (($user->hasRight("fournisseur", "commande", "supprimer") || $user->hasRight("supplier_order", "supprimer")) || ($usercancreate && isset($object->status) && $object->status == $object::STATUS_DRAFT)); // Advanced permissions $usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "supplier_order_advance", "validate"))); @@ -179,7 +179,7 @@ $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatede // Project permission $caneditproject = false; if (isModEnabled('project')) { - $caneditproject = !getDolGlobalString('SUPPLIER_ORDER_FORBID_EDIT_PROJECT') || ($object->statut == CommandeFournisseur::STATUS_DRAFT && preg_match('/^[\(]?PROV/i', $object->ref)); + $caneditproject = !getDolGlobalString('SUPPLIER_ORDER_FORBID_EDIT_PROJECT') || ($object->status == CommandeFournisseur::STATUS_DRAFT && preg_match('/^[\(]?PROV/i', $object->ref)); } $error = 0; @@ -287,7 +287,7 @@ if (empty($reshook)) { } // Edit Thirdparty - if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $action == 'set_thirdparty' && $usercancreate && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $action == 'set_thirdparty' && $usercancreate && $object->status == CommandeFournisseur::STATUS_DRAFT) { $new_socid = GETPOSTINT('new_socid'); if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { $db->begin(); @@ -355,32 +355,32 @@ if (empty($reshook)) { } if ($action == 'reopen' && $permissiontoadd) { // no test on permission here, permission to use will depends on status - if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) { - if ($object->statut == 1) { + if (in_array($object->status, array(1, 2, 3, 4, 5, 6, 7, 9))) { + if ($object->status == 1) { $newstatus = 0; // Validated->Draft - } elseif ($object->statut == 2) { + } elseif ($object->status == 2) { $newstatus = 0; // Approved->Draft - } elseif ($object->statut == 3) { + } elseif ($object->status == 3) { $newstatus = 2; // Ordered->Approved - } elseif ($object->statut == 4) { + } elseif ($object->status == 4) { $newstatus = 3; - } elseif ($object->statut == 5) { + } elseif ($object->status == 5) { //$newstatus=2; // Ordered // TODO Can we set it to submitted ? //$newstatus=3; // Submitted // TODO If there is at least one reception, we can set to Received->Received partially $newstatus = 4; // Received partially - } elseif ($object->statut == 6) { + } elseif ($object->status == 6) { $newstatus = 2; // Canceled->Approved - } elseif ($object->statut == 7) { + } elseif ($object->status == 7) { $newstatus = 3; // Canceled->Process running - } elseif ($object->statut == 9) { + } elseif ($object->status == 9) { $newstatus = 1; // Refused->Validated } else { $newstatus = 2; } - //print "old status = ".$object->statut.' new status = '.$newstatus; + //print "old status = ".$object->status.' new status = '.$newstatus; $db->begin(); $result = $object->setStatus($user, $newstatus); @@ -2166,7 +2166,7 @@ if ($action == 'create') { $morehtmlref .= ''; } if (!getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') || $action != 'edit_thirdparty') { - if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $object->status == CommandeFournisseur::STATUS_DRAFT) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; } $morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier'); @@ -2348,7 +2348,7 @@ if ($action == 'create') { $usehourmin = 'dayhour'; } print $object->delivery_date ? dol_print_date($object->delivery_date, $usehourmin) : ' '; - if ($object->hasDelay() && !empty($object->delivery_date) && ($object->statut == $object::STATUS_ORDERSENT || $object->statut == $object::STATUS_RECEIVED_PARTIALLY)) { + if ($object->hasDelay() && !empty($object->delivery_date) && ($object->status == $object::STATUS_ORDERSENT || $object->status == $object::STATUS_RECEIVED_PARTIALLY)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2485,7 +2485,7 @@ if ($action == 'create') { '; - if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -2510,7 +2510,7 @@ if ($action == 'create') { $num = count($object->lines); // Form to add new line - if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $usercancreate) { + if ($object->status == CommandeFournisseur::STATUS_DRAFT && $usercancreate) { if ($action != 'editline') { // Add free products/services @@ -2546,7 +2546,7 @@ if ($action == 'create') { $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. // Validate - if ($object->statut == 0 && $num > 0) { + if ($object->status == 0 && $num > 0) { if ($usercanvalidate) { $tmpbuttonlabel = $langs->trans('Validate'); if ($usercanapprove && !getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE')) { @@ -2565,14 +2565,14 @@ if ($action == 'create') { }*/ // Modify - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($object->status == CommandeFournisseur::STATUS_VALIDATED) { if ($usercanorder) { print ''.$langs->trans("Modify").''; } } // Approve - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($object->status == CommandeFournisseur::STATUS_VALIDATED) { if ($usercanapprove) { if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED') && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { print ''.$langs->trans("ApproveOrder").''; @@ -2586,7 +2586,7 @@ if ($action == 'create') { // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED') && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($object->status == CommandeFournisseur::STATUS_VALIDATED) { if ($usercanapprovesecond) { if (!empty($object->user_approve_id2)) { print ''.$langs->trans("Approve2Order").''; @@ -2600,7 +2600,7 @@ if ($action == 'create') { } // Refuse - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($object->status == CommandeFournisseur::STATUS_VALIDATED) { if ($usercanapprove || $usercanapprovesecond) { print ''.$langs->trans("RefuseOrder").''; } else { @@ -2610,7 +2610,7 @@ if ($action == 'create') { // Send if (empty($user->socid)) { - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || getDolGlobalString('SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS')) { + if (in_array($object->status, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || getDolGlobalString('SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS')) { if ($usercanorder) { print ''.$langs->trans('SendMail').''; } @@ -2618,7 +2618,7 @@ if ($action == 'create') { } // Reopen - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { + if (in_array($object->status, array(CommandeFournisseur::STATUS_ACCEPTED))) { $buttonshown = 0; if (!$buttonshown && $usercanapprove) { if (!getDolGlobalString('SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY') @@ -2634,7 +2634,7 @@ if ($action == 'create') { } } } - if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) { + if (in_array($object->status, array(3, 4, 5, 6, 7, 9))) { if ($usercanorder) { print ''.$langs->trans("ReOpen").''; } @@ -2668,7 +2668,7 @@ if ($action == 'create') { } } - if (in_array($object->statut, array(3, 4, 5))) { + if (in_array($object->status, array(3, 4, 5))) { if (isModEnabled("supplier_order") && $usercanreceive) { print '
'.$labelofbutton.'
'; } else { @@ -2677,7 +2677,7 @@ if ($action == 'create') { } } - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { + if ($object->status == CommandeFournisseur::STATUS_ACCEPTED) { if ($usercanorder) { print '
'.$langs->trans("MakeOrder").'
'; } else { @@ -2686,7 +2686,7 @@ if ($action == 'create') { } // Classify received (this does not record reception) - if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { + if ($object->status == CommandeFournisseur::STATUS_ORDERSENT || $object->status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { if ($usercanreceive) { print '
'.$langs->trans("ClassifyReception").'
'; } @@ -2695,7 +2695,7 @@ if ($action == 'create') { // Create bill //if (isModEnabled('facture')) //{ - if (isModEnabled("supplier_invoice") && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled + if (isModEnabled("supplier_invoice") && ($object->status >= 2 && $object->status != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) { print ''.$langs->trans("SupplierOrderCreateBill").''; } @@ -2703,7 +2703,7 @@ if ($action == 'create') { //} // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) - if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) { // statut 2 means approved + if ($usercancreate && $object->status >= 2 && $object->status != 7 && $object->billed != 1) { // statut 2 means approved if (!isModEnabled('invoice')) { print ''.$langs->trans("ClassifyBilled").''; } else { @@ -2718,7 +2718,7 @@ if ($action == 'create') { } // Classify unbilled manually - if ($usercancreate && $object->billed > 0 && $object->statut > $object::STATUS_DRAFT) { + if ($usercancreate && $object->billed > 0 && $object->status > $object::STATUS_DRAFT) { print ''.$langs->trans("ClassifyUnbilled").''; } @@ -2728,7 +2728,7 @@ if ($action == 'create') { } // Cancel - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { + if ($object->status == CommandeFournisseur::STATUS_ACCEPTED) { if ($usercanorder) { print ''.$langs->trans("CancelOrder").''; } @@ -2747,7 +2747,7 @@ if ($action == 'create') { print ""; } - if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'createorder') { + if ($usercanorder && $object->status == CommandeFournisseur::STATUS_ACCEPTED && $action == 'createorder') { // Set status to ordered (action=commande) print ''."\n"; print '
'; @@ -2812,7 +2812,7 @@ if ($action == 'create') { print '
'; if ($action == 'classifyreception') { - if ($usercanreceive && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { + if ($usercanreceive && ($object->status == CommandeFournisseur::STATUS_ORDERSENT || $object->status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print ''."\n"; print '';