From 1d6cbe1fdaaa4137bb74243d63dd2f26a513c24a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Feb 2024 23:46:12 +0100 Subject: [PATCH] Fix GETPOST use should be avoid in classes --- htdocs/bom/class/api_boms.class.php | 2 +- htdocs/comm/propal/card.php | 2 +- .../comm/propal/class/api_proposals.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- .../facture/class/api_invoices.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/api_contracts.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/core/actions_addupdatedelete.inc.php | 14 +++- htdocs/delivery/class/delivery.class.php | 2 +- .../expedition/class/api_shipments.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/expensereport/card.php | 2 +- .../class/api_expensereports.class.php | 2 +- .../class/expensereport.class.php | 2 +- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- .../class/api_supplier_invoices.class.php | 2 +- .../class/fournisseur.commande.class.php | 14 ++-- .../fourn/class/fournisseur.facture.class.php | 6 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/mrp/class/mo.class.php | 15 ++-- htdocs/mrp/mo_movements.php | 69 ++++++++++++++----- htdocs/mrp/mo_production.php | 4 +- .../class/stocktransfer.class.php | 4 -- .../class/stocktransferline.class.php | 4 +- .../reception/class/api_receptions.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/takepos/invoice.php | 6 +- htdocs/webportal/class/context.class.php | 2 +- test/phpunit/CodingPhpTest.php | 20 ++++-- 39 files changed, 135 insertions(+), 83 deletions(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index f9b1a7257de..a80f295e755 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -471,7 +471,7 @@ class Boms extends DolibarrApi throw new RestException(500, 'Line to delete (rowid: '.$lineid.') is not a line of BOM (id: '.$this->bom->id.')'); } - $updateRes = $this->bom->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->bom->deleteLine(DolibarrApiAccess::$user, $lineid); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a0a2a5a4c5f..408d13837ab 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -258,7 +258,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { // Remove line - $result = $object->deleteline($lineid); + $result = $object->deleteLine($lineid); // reorder lines if ($result > 0) { $object->line_order(true); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index f280a7657a3..762027e1475 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -567,7 +567,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $updateRes = $this->propal->deleteline($lineid, $id); + $updateRes = $this->propal->deleteLine($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a433e6b85e6..a016555e3a4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1016,7 +1016,7 @@ class Propal extends CommonObject * @param int $id Id of object (for a check) * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid, $id = 0) + public function deleteLine($lineid, $id = 0) { global $user; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index cae96460a93..f3881a10aff 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -233,7 +233,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { // Remove a product line - $result = $object->deleteline($user, $lineid); + $result = $object->deleteLine($user, $lineid); if ($result > 0) { // reorder lines $object->line_order(true); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 8fd80322c00..2e6ed740f7c 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -485,7 +485,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid, $id); + $updateRes = $this->commande->deleteLine(DolibarrApiAccess::$user, $lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f8226634cf0..dc4df918c7b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2392,7 +2392,7 @@ class Commande extends CommonOrder * @param int $id Id of object (for a check) * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - public function deleteline($user = null, $lineid = 0, $id = 0) + public function deleteLine($user = null, $lineid = 0, $id = 0) { if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 55f4876fee2..bdd079d5163 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -276,7 +276,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fetch_thirdparty(); - $result = $object->deleteline(GETPOST('lineid', 'int')); + $result = $object->deleteLine(GETPOST('lineid', 'int')); if ($result > 0) { // reorder lines $object->line_order(true); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 602ea69f691..d118bdfcbb1 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -623,7 +623,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - $updateRes = $this->invoice->deleteline($lineid, $id); + $updateRes = $this->invoice->deleteLine($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ad43e7e250a..058b4441967 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -539,7 +539,7 @@ class Facture extends CommonInvoice } $this->entity = $_facrec->entity; // Invoice created in same entity than template - // Fields coming from GUI (priority on template). + // Fields coming from GUI. // @TODO Value of template should be used as default value on the form on the GUI, and we should here always use the value from GUI // set by posted page wth $object->xxx = ... and this section should be removed. $this->fk_project = GETPOST('projectid', 'int') > 0 ? GETPOSTINT('projectid') : $_facrec->fk_project; @@ -4353,7 +4353,7 @@ class Facture extends CommonInvoice * @param int $id Id of object (for a check) * @return int Return integer <0 if KO, >0 if OK */ - public function deleteline($rowid, $id = 0) + public function deleteLine($rowid, $id = 0) { global $user; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 065a2bcf45f..b5440c221b5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -822,7 +822,7 @@ if (empty($reshook)) { $db->rollback(); } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { - $result = $object->deleteline(GETPOST('lineid', 'int'), $user); + $result = $object->deleteLine(GETPOST('lineid', 'int'), $user); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 64989ffb8a0..7fac4926b1a 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -469,7 +469,7 @@ class Contracts extends DolibarrApi // TODO Check the lineid $lineid is a line of object - $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user); + $updateRes = $this->contract->deleteLine($lineid, DolibarrApiAccess::$user); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e5a54c9b119..6c59e720d64 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1886,10 +1886,8 @@ class Contrat extends CommonObject * @param User $user User that delete * @return int >0 if OK, <0 if KO */ - public function deleteline($idline, User $user) + public function deleteLine($idline, User $user) { - global $conf, $langs; - $error = 0; if ($this->statut >= 0) { diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ccfe263026a..91e1b34dc5d 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -56,6 +56,7 @@ if ($cancel) { // Action to add record if ($action == 'add' && !empty($permissiontoadd)) { foreach ($object->fields as $key => $val) { + // Ignore special cases if ($object->fields[$key]['type'] == 'duration') { if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') { continue; // The field was not submitted to be saved @@ -65,6 +66,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { continue; // The field was not submitted to be saved } } + // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) { continue; @@ -149,6 +151,12 @@ if ($action == 'add' && !empty($permissiontoadd)) { } } + // Special field + $model_pdf = GETPOST('model'); + if (!empty($model_pdf) && property_exists($this, 'model_pdf')) { + $object->model_pdf = $model_pdf; + } + // Fill array 'array_options' with data from add form if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1); @@ -422,11 +430,13 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) { // Remove a line if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { - if (method_exists($object, 'deleteline')) { - $result = $object->deleteline($user, $lineid); // For backward compatibility + if (!empty($object->element) && $object->element == 'mo') { + $fk_movement = GETPOSTINT('fk_movement'); + $result = $object->deleteLine($user, $lineid, 0, $fk_movement); } else { $result = $object->deleteLine($user, $lineid); } + if ($result > 0) { // Define output language $outputlangs = $langs; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 37c5f3a0a17..edc90dfda22 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -657,7 +657,7 @@ class Delivery extends CommonObject * @param int $lineid Line id * @return integer Return integer <0 if KO, 0 if nothing done, >0 if OK */ - public function deleteline($lineid) + public function deleteLine($lineid) { if ($this->statut == 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index e5cf55742c1..fe3c778153f 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -408,7 +408,7 @@ class Shipments extends DolibarrApi // TODO Check the lineid $lineid is a line of object - $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->shipment->deleteLine(DolibarrApiAccess::$user, $lineid); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 105cccb1af8..cb627539943 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1769,7 +1769,7 @@ class Expedition extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - public function deleteline($user, $lineid) + public function deleteLine($user, $lineid) { global $user; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 8ed2b44f37d..86a661d59c2 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1247,7 +1247,7 @@ if (empty($reshook)) { $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result = $object->deleteline(GETPOST("rowid", 'int'), $user); + $result = $object->deleteLine(GETPOST("rowid", 'int'), $user); if ($result >= 0) { if ($result > 0) { // Define output language diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 3fb000275bb..27f7601e9ef 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -386,7 +386,7 @@ class ExpenseReports extends DolibarrApi // TODO Check the lineid $lineid is a line of object - $updateRes = $this->expensereport->deleteline($lineid); + $updateRes = $this->expensereport->deleteLine($lineid); if ($updateRes == 1) { return $this->get($id); } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index da62de7ecfc..020e888aab6 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2291,7 +2291,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger 1=No trigger * @return int Return integer <0 if KO, >0 if OK */ - public function deleteline($rowid, $fuser = '', $notrigger = 0) + public function deleteLine($rowid, $fuser = '', $notrigger = 0) { $error=0; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 2843ad4a794..971eea5a1eb 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -663,7 +663,7 @@ if (empty($reshook)) { dol_print_error($db); exit; } - $result = $objectline->deleteline($user); + $result = $objectline->deleteLine($user); if ($object->fetch($objectline->fk_fichinter) <= 0) { dol_print_error($db); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6f335747756..e5c60461bae 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1907,7 +1907,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int >0 if ok, <0 if ko */ - public function deleteline($user, $notrigger = 0) + public function deleteLine($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 2c6251a1249..d205275b238 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -702,7 +702,7 @@ class SupplierInvoices extends DolibarrApi // TODO Check the lineid $lineid is a line of object - $updateRes = $this->invoice->deleteline($lineid); + $updateRes = $this->invoice->deleteLine($lineid); if ($updateRes > 0) { return $this->get($id); } else { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4f4a06dc512..14bd62e50f6 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2315,7 +2315,7 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Disable call to triggers * @return int Return integer <0 if KO, >0 if OK */ - public function deleteline($idline, $notrigger = 0) + public function deleteLine($idline, $notrigger = 0) { if ($this->statut == 0) { $line = new CommandeFournisseurLigne($this->db); @@ -3568,7 +3568,7 @@ class CommandeFournisseur extends CommonOrder if (count($diff_array) == 0 && count($keysinwishednotindelivered) == 0 && count($keysindeliverednotinwished) == 0) { //No diff => mean everything is received if ($closeopenorder) { //$ret=$this->setStatus($user,5); - $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } @@ -3576,7 +3576,7 @@ class CommandeFournisseur extends CommonOrder } else { //Diff => received partially //$ret=$this->setStatus($user,4); - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } @@ -3603,14 +3603,14 @@ class CommandeFournisseur extends CommonOrder if ($close == count($diff_array)) { //all the products are received equal or more than the wished quantity if ($closeopenorder) { - $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } return 5; } else { //Diff => received partially - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } @@ -3618,7 +3618,7 @@ class CommandeFournisseur extends CommonOrder } } else { //all the products are not received - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } @@ -3626,7 +3626,7 @@ class CommandeFournisseur extends CommonOrder } } else { //Diff => received partially - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can' if ($ret < 0) { return -1; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3f8e6d61705..4bbf1d5c79c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -429,7 +429,9 @@ class FactureFournisseur extends CommonInvoice $this->entity = $_facrec->entity; // Invoice created in same entity than template - // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI + // Fields coming from GUI + // @TODO Value of template should be used as default value on the form on the GUI, and we should here always use the value from GUI + // set by posted page wth $object->xxx = ... and this section should be removed. $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; $this->note_public = GETPOST('note_public', 'restricthtml') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public; $this->note_private = GETPOST('note_private', 'restricthtml') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private; @@ -2489,7 +2491,7 @@ class FactureFournisseur extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Return integer <0 if KO, >0 if OK */ - public function deleteline($rowid, $notrigger = 0) + public function deleteLine($rowid, $notrigger = 0) { if (!$rowid) { $rowid = $this->id; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 5bd59060ce8..1134d10caaf 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -888,7 +888,7 @@ if (empty($reshook)) { if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $db->begin(); - $result = $object->deleteline($lineid); + $result = $object->deleteLine($lineid); if ($result > 0) { // reorder lines $object->line_order(true); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 01ddb66dc6e..cb360b2749b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -309,7 +309,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { // Remove a product line - $result = $object->deleteline($lineid); + $result = $object->deleteLine($lineid); if ($result > 0) { // reorder lines $object->line_order(true); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a950f4f9f57..fe178496f87 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -18,7 +18,7 @@ */ /** - * \file class/mo.class.php + * \file mrp/class/mo.class.php * \ingroup mrp * \brief This file is a CRUD class file for Mo (Create/Read/Update/Delete) */ @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; + /** * Class for Mo */ @@ -877,12 +878,13 @@ class Mo extends CommonObject /** * Delete a line of object in database * - * @param User $user User that delete - * @param int $idline Id of line to delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int >0 if OK, <0 if KO + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param int $fk_movement Movement + * @return int Return >0 if OK, <0 if KO */ - public function deleteLine(User $user, $idline, $notrigger = 0) + public function deleteLine(User $user, $idline, $notrigger = 0, $fk_movement = 0) { global $langs; $langs->loadLangs(array('stocks', 'mrp')); @@ -892,7 +894,6 @@ class Mo extends CommonObject return -2; } $productstatic = new Product($this->db); - $fk_movement = GETPOST('fk_movement', 'int'); $arrayoflines = $this->fetchLinesLinked('consumed', $idline); if (!empty($arrayoflines)) { diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 9cbea212d8e..fdb3a0a8366 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -599,13 +599,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; // Fields title search print ''; + // Actions + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } // Actions - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print "\n"; $totalarray = array(); $totalarray['nbfield'] = 0; print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; + } if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; @@ -824,8 +839,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); $totalarray['nbfield']++; } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - $totalarray['nbfield']++; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; + } print "\n"; $i = 0; @@ -884,6 +902,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Id movement if (!empty($arrayfields['m.rowid']['checked'])) { // This is primary not movement id @@ -992,17 +1025,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } // Action column - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; } print "\n"; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 23b996fcca0..a0730b6078e 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -117,7 +117,7 @@ if ($reshook < 0) { if (empty($reshook)) { $error = 0; - $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/mrp/mo_list.php'; if (empty($backtopage) || ($cancel && empty($id))) { //var_dump($backurlforlist);exit; @@ -133,7 +133,7 @@ if (empty($reshook)) { $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); if ($result > 0) { - header("Location: " . dol_buildpath('/mrp/mo_card.php?id=' . $object->id, 1)); + header("Location: " . DOL_URL_ROOT.'/mrp/mo_card.php?id=' . $object->id); exit; } else { $action = ''; diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index 08d1213c47b..b81bf014192 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -233,10 +233,6 @@ class StockTransfer extends CommonObject */ public function create(User $user, $notrigger = 0) { - $model_pdf = GETPOST('model'); - if (!empty($model_pdf)) { - $this->model_pdf = $model_pdf; - } $this->status = (int) $this->status; if ($this->fk_warehouse_source <= 0) { $this->fk_warehouse_source = 0; diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index a17df806b8f..af6a215dca5 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -449,7 +449,7 @@ class StockTransferLine extends CommonObjectLine $direction, // 1=décrémentation $label, empty($direction) ? $this->pmp : 0, - GETPOST('inventorycode', 'alphanohtml'), + $code_inv, 'stocktransfer', $this->fk_stocktransfer );*/ @@ -492,7 +492,7 @@ class StockTransferLine extends CommonObjectLine $dlc, $dluo, $this->batch, - GETPOST("codemove") + $code_inv );*/ $result = $movementstock->_create( diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index c587e97fd40..69e5b77d616 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -403,7 +403,7 @@ class Receptions extends DolibarrApi // TODO Check the lineid $lineid is a line of object - $updateRes = $this->reception->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->reception->deleteLine(DolibarrApiAccess::$user, $lineid); if ($updateRes < 0) { throw new RestException(405, $this->reception->error); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bfc979b77b6..cfe55c80e12 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4897,7 +4897,7 @@ class Societe extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example. + * @param string $modele Generator to use. Caller must set it to obj->model_pdf. * @param Translate $outputlangs object lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 0deee6c6a41..4567e6b823f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -197,7 +197,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { // Remove line - $result = $object->deleteline($lineid); + $result = $object->deleteLine($lineid); // reorder lines if ($result > 0) { $object->line_order(true); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 7018339149d..52786d894de 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -843,7 +843,7 @@ class SupplierProposal extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid) + public function deleteLine($lineid) { global $user; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 87057bc05b5..35f8737168a 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -747,14 +747,14 @@ if (empty($reshook)) { }*/ if ($idline > 0 && $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); + $invoice->deleteLine($idline); $invoice->fetch($placeid); } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; $resql = $db->query($sql); $row = $db->fetch_array($resql); $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); + $invoice->deleteLine($deletelineid); $invoice->fetch($placeid); } @@ -781,7 +781,7 @@ if (empty($reshook)) { // We delete the lines $resdeletelines = 1; foreach ($invoice->lines as $line) { - $tmpres = $invoice->deleteline($line->id); + $tmpres = $invoice->deleteLine($line->id); if ($tmpres < 0) { $resdeletelines = 0; break; diff --git a/htdocs/webportal/class/context.class.php b/htdocs/webportal/class/context.class.php index 58645ac5892..10fb12e5641 100644 --- a/htdocs/webportal/class/context.class.php +++ b/htdocs/webportal/class/context.class.php @@ -132,7 +132,7 @@ class Context $this->controller = 'default'; } - $this->appliName = !empty($conf->global->WEBPORTAL_TITLE) ? $conf->global->WEBPORTAL_TITLE : $conf->global->MAIN_INFO_SOCIETE_NOM; + $this->appliName = getDolGlobalString('WEBPORTAL_TITLE', getDolGlobalString('MAIN_INFO_SOCIETE_NOM')); //$this->generateNewToken(); diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 1480203b604..fcf9b659efa 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -242,22 +242,32 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'core/class/html.formsms.class.php', 'core/class/html.formticket.class.php', 'core/class/utils.class.php', + 'fourn/class/fournisseur.facture.class.php', + 'societe/canvas/actions_card_common.class.php', + 'societe/canvas/individual/actions_card_individual.class.php', + 'ticket/class/actions_ticket.class.php', + 'ticket/class/ticket.class.php', + 'webportal/class/context.class.php', + 'webportal/class/html.formcardwebportal.class.php', + 'webportal/class/html.formlistwebportal.class.php', + 'webportal/controllers/document.controller.class.php', + 'workstation/class/workstation.class.php', ))) { // Must not find GETPOST - $ok=true; - $matches=array(); + $ok = true; + $matches = array(); // Check string GETPOSTFLOAT a class.php file (should not be found into classes) preg_match_all('/GETPOST\(["\'](....)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { - if (in_array($val[1], array('lang', 'forc'))) { + if (in_array($val[1], array('lang', 'forc', 'mass', 'conf'))) { continue; } //var_dump($val); - $ok=false; + $ok = false; break; } //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; - //$this->assertTrue($ok, 'Found string GETPOST into a .class.php file in '.$file['relativename'].'.'); + $this->assertTrue($ok, 'Found string GETPOST into a .class.php file in '.$file['relativename'].'.'); } } else { // Check into Include files
'; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print ''; @@ -733,16 +741,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($objp->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($objp->rowid, $arrayofselected)) { - $selected = 1; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($objp->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '