From 4f3d4950e1ba0439fc73a6e59f000753d82ca56d Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Tue, 12 Nov 2019 13:01:16 +0100 Subject: [PATCH 01/18] Check if draft exists in TakePOS customer list Check if draft invoice already exists, if not create it --- htdocs/societe/list.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index afd4c89aab5..bbe9f6a9424 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -231,7 +231,25 @@ if ($action == "change") // Change customer for TakePOS $idcustomer = GETPOST('idcustomer', 'int'); $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant - // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically + // Check if draft invoice already exists, if not create it + $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'facture + where ref=\'(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')\' + AND entity IN ('.getEntity('invoice').')'; + $result = $db->query($sql); + $num_lines = $db->num_rows($result); + if ($num_lines==0) + { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = $_SESSION["takeposterminal"]; + $placeid =$invoice->create($user); + $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; + $db->query($sql); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> From 34b832507959882da8c70467aea8d6fd551e95e5 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Tue, 12 Nov 2019 14:21:49 +0100 Subject: [PATCH 02/18] Update list.php --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index bbe9f6a9424..a62dde1d79d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -249,7 +249,7 @@ if ($action == "change") // Change customer for TakePOS $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; $db->query($sql); } - + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> From 480ac1a926286c29c4518f8a23502b150a077353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 12 Nov 2019 18:08:09 +0100 Subject: [PATCH 03/18] API New link/unlink products with categories Need it for V11 please :) --- .../categories/class/api_categories.class.php | 240 ++++++++++++++++++ 1 file changed, 240 insertions(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d289874d1ee..f7a2addef3d 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,6 +264,246 @@ class Categories extends DolibarrApi ) ); } + + /** + * Link an object to a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/{object_id} + */ + public function link_object_by_id($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } + + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + $result = $this->category->fetch($id); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch($object_id); + if ($result > 0) { + $result=$this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Link an object to a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/ref/{object_ref} + */ + public function link_object_by_ref($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } + + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + $result = $this->category->fetch($id); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch('', $object_ref); + if ($result > 0) { + $result=$this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Unlink an object from a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/{object_id} + */ + public function unlink_object_by_id($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } + + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + $result = $this->category->fetch($id); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch((int) $object_id); + if ($result > 0) { + $result=$this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Unlink an object from a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/ref/{object_ref} + */ + public function unlink_object_by_ref($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } + + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + $result = $this->category->fetch($id); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch('', (string) $object_ref); + if ($result > 0) { + $result=$this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } + + throw new RestException(401); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From fcb50841ccf35a298fb9c145f4be21445381e4e0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 12 Nov 2019 17:10:20 +0000 Subject: [PATCH 04/18] Fixing style errors. --- .../categories/class/api_categories.class.php | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index f7a2addef3d..36b3e10174a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,17 +264,17 @@ class Categories extends DolibarrApi ) ); } - + /** * Link an object to a category by id * * @param int $id ID of category * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param int $object_id ID of object - * + * * @return array * @throws RestException - * + * * @url POST {id}/objects/{type}/{object_id} */ public function link_object_by_id($id, $type, $object_id) @@ -282,17 +282,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_id)) { throw new RestException(401); } - + if(! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - + $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -301,7 +301,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch($object_id); if ($result > 0) { @@ -314,7 +314,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -322,10 +322,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Link an object to a category by ref * @@ -343,17 +343,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_ref)) { throw new RestException(401); } - + if(! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - + $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -362,7 +362,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch('', $object_ref); if ($result > 0) { @@ -375,7 +375,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -383,10 +383,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Unlink an object from a category by id * @@ -404,17 +404,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_id)) { throw new RestException(401); } - + if(! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - + $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -423,7 +423,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch((int) $object_id); if ($result > 0) { @@ -434,7 +434,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -442,10 +442,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Unlink an object from a category by ref * @@ -463,17 +463,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_ref)) { throw new RestException(401); } - + if(! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - + $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -482,7 +482,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch('', (string) $object_ref); if ($result > 0) { @@ -493,7 +493,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -501,7 +501,7 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } From e33d969178ed5885548c7e590dafc3af4aad6654 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 12 Nov 2019 18:38:23 +0100 Subject: [PATCH 05/18] Fix php error on stripe account display convert non object in full array in order to avoid php error message. --- htdocs/societe/paymentmodes.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5636f09b3a4..11a5955a3ff 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1317,11 +1317,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + $currencybalance[$cpt->currency]['available']=$cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->available=$cpt->amount; + $currencybalance[$cpt->currency]['available']=$cpt->amount; } - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $currencybalance[$cpt->currency]['currency']=$cpt->currency; } } @@ -1331,9 +1331,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + $currencybalance[$cpt->currency]['pending']=$currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $currencybalance[$cpt->currency]['pending']=$currencybalance[$cpt->currency]['available']+$cpt->amount; } } } @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''; + print ''.$langs->trans("Currency".strtoupper($cpt['pending'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; } } From 24bac213aaa7d0f141ef32036d939b610c7ad879 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 12 Nov 2019 18:39:39 +0100 Subject: [PATCH 06/18] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 11a5955a3ff..e44feb047ab 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['pending'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; } } From 422d893eccac641b482188741ce90c050f5dd44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2019 21:33:42 +0100 Subject: [PATCH 07/18] Update llx_c_action_trigger.sql --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index b7cad86d6bb..85360478500 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -125,7 +125,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); -- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) From 4f90fe0fd23e02387882d04964ba549df2dc3e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2019 21:34:45 +0100 Subject: [PATCH 08/18] Update 10.0.0-11.0.0.sql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 9c52044291d..6a31fa3e745 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -493,7 +493,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); From 7ce297c6cc54b463b210ddc285555552a41cf083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2019 21:53:17 +0100 Subject: [PATCH 09/18] doxygen --- htdocs/core/lib/ticket.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 41e783b7597..609dbd9926d 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France * * 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 @@ -180,10 +181,10 @@ function showDirectPublicLink($object) } /** - * Generate a random id + * Generate a random id * - * @param string $car Char to generate key - * @return void + * @param int $car Length of string to generate key + * @return string */ function generate_random_id($car = 16) { From 9efcdc78f90d2892a3869da7b98197e9676a4270 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 12 Nov 2019 21:56:05 +0100 Subject: [PATCH 10/18] Cleanup interface_90_modSociete_ContactRoles --- .../interface_90_modSociete_ContactRoles.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index b806e70c71d..b50008dba2e 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php + * \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php * \ingroup agenda - * \brief Trigger file for agenda module + * \brief Trigger file for company - contactroles */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; class InterfaceContactRoles extends DolibarrTriggers { public $family = 'agenda'; - public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + public $description = "Triggers of this module auto link contact to company."; /** * Version of the trigger @@ -73,7 +73,6 @@ class InterfaceContactRoles extends DolibarrTriggers $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc); if (! empty($socid) && $socid > 0) { - global $db, $langs; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); $contactdefault->socid=$socid; @@ -83,7 +82,7 @@ class InterfaceContactRoles extends DolibarrTriggers if ($object->id > 0) { $class = get_class($object); - $cloneFrom = new $class($db); + $cloneFrom = new $class($this->db); $r = $cloneFrom->fetch($object->id); if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal')); From e7d51d4ec753451c600d5bbb50cf1a613f3f3674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2019 22:01:53 +0100 Subject: [PATCH 11/18] do not trim int --- htdocs/ticket/class/ticket.class.php | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5784fc22a3e..2b673ad8899 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France * * 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 @@ -250,11 +251,11 @@ class Ticket extends CommonObject } if (isset($this->fk_soc)) { - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = (int) $this->fk_soc; } if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + $this->fk_project = (int) $this->fk_project; } if (isset($this->origin_email)) { @@ -262,11 +263,11 @@ class Ticket extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->fk_user_assign)) { - $this->fk_user_assign = trim($this->fk_user_assign); + $this->fk_user_assign = (int) $this->fk_user_assign; } if (isset($this->subject)) { @@ -278,7 +279,7 @@ class Ticket extends CommonObject } if (isset($this->fk_statut)) { - $this->fk_statut = trim($this->fk_statut); + $this->fk_statut = (int) $this->fk_statut; } if (isset($this->resolution)) { @@ -746,11 +747,11 @@ class Ticket extends CommonObject } if (isset($this->fk_soc)) { - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = (int) $this->fk_soc; } if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + $this->fk_project = (int) $this->fk_project; } if (isset($this->origin_email)) { @@ -758,11 +759,11 @@ class Ticket extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->fk_user_assign)) { - $this->fk_user_assign = trim($this->fk_user_assign); + $this->fk_user_assign = (int) $this->fk_user_assign; } if (isset($this->subject)) { @@ -774,7 +775,7 @@ class Ticket extends CommonObject } if (isset($this->fk_statut)) { - $this->fk_statut = trim($this->fk_statut); + $this->fk_statut = (int) $this->fk_statut; } if (isset($this->resolution)) { @@ -1002,12 +1003,12 @@ class Ticket extends CommonObject $this->ref = 'TI0501-001'; $this->track_id = 'XXXXaaaa'; $this->origin_email = 'email@email.com'; - $this->fk_project = '1'; - $this->fk_user_create = '1'; - $this->fk_user_assign = '1'; + $this->fk_project = 1; + $this->fk_user_create = 1; + $this->fk_user_assign = 1; $this->subject = 'Subject of ticket'; $this->message = 'Message of ticket'; - $this->fk_statut = '0'; + $this->fk_statut = 0; $this->resolution = '1'; $this->progress = '10'; $this->timing = '30'; From bb4fd0d5c02518f7464edc2ad34e25f4df213739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2019 22:06:22 +0100 Subject: [PATCH 12/18] timing is varchar in db --- htdocs/ticket/class/ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2b673ad8899..1d6b1d591c4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -121,7 +121,7 @@ class Ticket extends CommonObject public $progress; /** - * @var int Duration for ticket + * @var string Duration for ticket */ public $timing; From c4c463fb96eb9a207db5a3ac684cafc99b0f807d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Wed, 13 Nov 2019 11:36:42 +0100 Subject: [PATCH 13/18] camelCaps --- htdocs/categories/class/api_categories.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 36b3e10174a..0f2a425fe87 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -277,7 +277,7 @@ class Categories extends DolibarrApi * * @url POST {id}/objects/{type}/{object_id} */ - public function link_object_by_id($id, $type, $object_id) + public function linkObjectById($id, $type, $object_id) { if (empty($type) || empty($object_id)) { throw new RestException(401); @@ -338,7 +338,7 @@ class Categories extends DolibarrApi * * @url POST {id}/objects/{type}/ref/{object_ref} */ - public function link_object_by_ref($id, $type, $object_ref) + public function linkObjectByRef($id, $type, $object_ref) { if (empty($type) || empty($object_ref)) { throw new RestException(401); @@ -399,7 +399,7 @@ class Categories extends DolibarrApi * * @url DELETE {id}/objects/{type}/{object_id} */ - public function unlink_object_by_id($id, $type, $object_id) + public function unlinkObjectById($id, $type, $object_id) { if (empty($type) || empty($object_id)) { throw new RestException(401); @@ -458,7 +458,7 @@ class Categories extends DolibarrApi * * @url DELETE {id}/objects/{type}/ref/{object_ref} */ - public function unlink_object_by_ref($id, $type, $object_ref) + public function unlinkObjectByRef($id, $type, $object_ref) { if (empty($type) || empty($object_ref)) { throw new RestException(401); From 5d42ef323e6419d0135d12697f1c3fd6a4522b2b Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 13 Nov 2019 15:13:56 +0100 Subject: [PATCH 14/18] Fix Printsheet product selector --- htdocs/barcode/printsheet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 1ed7c449868..7c055855ffc 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -380,7 +380,7 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; print '
'; print '
'; - $form->select_produits(GETPOST('productid'), 'productid', ''); + $form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); print '   '; print '
'; } From c66bce7ec6a241b39a5369e7b0e17e879e5de3eb Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 17:31:18 +0000 Subject: [PATCH 15/18] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../sociales/class/chargesociales.class.php | 170 +++++++++--------- htdocs/core/modules/modBom.class.php | 54 +++--- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2bc82fc8b78..fecc5a96aa1 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -35,14 +35,14 @@ class ChargeSociales extends CommonObject /** * @var string ID to identify managed object */ - public $element='chargesociales'; + public $element = 'chargesociales'; - public $table='chargesociales'; + public $table = 'chargesociales'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='chargesociales'; + public $table_element = 'chargesociales'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -175,7 +175,7 @@ class ChargeSociales extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -187,10 +187,10 @@ class ChargeSociales extends CommonObject */ public function check() { - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); // Validation parametres - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) { return false; } @@ -208,55 +208,55 @@ class ChargeSociales extends CommonObject public function create($user) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Nettoyage parametres - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); if (!$this->check()) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -2; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; - $sql.= " VALUES (".$this->type; - $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); - $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); - $sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", '".$this->db->idate($this->date_ech)."'"; - $sql.= ", '".$this->db->idate($this->periode)."'"; - $sql.= ", '".price2num($newamount)."'"; - $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL'); - $sql.= ", ".$conf->entity; - $sql.= ", ".$user->id; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ")"; + $sql .= " VALUES (".$this->type; + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", '".$this->db->idate($this->date_ech)."'"; + $sql .= ", '".$this->db->idate($this->periode)."'"; + $sql .= ", '".price2num($newamount)."'"; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); + $sql .= ", ".$conf->entity; + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); - $result=$this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); + $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); if ($result < 0) $error++; - if(empty($error)) { + if (empty($error)) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -271,23 +271,23 @@ class ChargeSociales extends CommonObject */ public function delete($user) { - $error=0; + $error = 0; $this->db->begin(); // Get bank transaction lines for this social contributions include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account=new Account($this->db); - $lines_url=$account->get_url('', $this->id, 'sc'); + $account = new Account($this->db); + $lines_url = $account->get_url('', $this->id, 'sc'); // Delete bank urls foreach ($lines_url as $line_url) { - if (! $error) + if (!$error) { - $accountline=new AccountLine($this->db); + $accountline = new AccountLine($this->db); $accountline->fetch($line_url['fk_bank']); - $result=$accountline->delete_urls($user); + $result = $accountline->delete_urls($user); if ($result < 0) { $error++; @@ -296,31 +296,31 @@ class ChargeSociales extends CommonObject } // Delete payments - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -342,31 +342,31 @@ class ChargeSociales extends CommonObject */ public function update($user, $notrigger = 0) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; - $sql.= ", periode='".$this->db->idate($this->periode)."'"; - $sql.= ", amount='".price2num($this->amount, 'MT')."'"; - $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL"); - $sql.= ", fk_user_modif=".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; + $sql .= ", periode='".$this->db->idate($this->periode)."'"; + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); + $sql .= ", fk_user_modif=".$user->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SOCIALCHARGES_MODIFY', $user); + $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -375,13 +375,13 @@ class ChargeSociales extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -401,9 +401,9 @@ class ChargeSociales extends CommonObject global $conf; $sql = "SELECT SUM(f.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND paye = 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND paye = 0"; if ($year) { $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; @@ -441,8 +441,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 1"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -459,8 +459,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 0"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -549,9 +549,9 @@ class ChargeSociales extends CommonObject { global $langs, $conf, $user, $form; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; @@ -607,20 +607,20 @@ class ChargeSociales extends CommonObject */ public function getSommePaiement() { - $table='paiementcharge'; - $field='fk_charge'; + $table = 'paiementcharge'; + $field = 'fk_charge'; $sql = 'SELECT sum(amount) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; - $sql.= ' WHERE '.$field.' = '.$this->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $amount=0; + $amount = 0; $obj = $this->db->fetch_object($resql); - if ($obj) $amount=$obj->amount?$obj->amount:0; + if ($obj) $amount = $obj->amount ? $obj->amount : 0; $this->db->free($resql); return $amount; @@ -640,12 +640,12 @@ class ChargeSociales extends CommonObject public function info($id) { $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; - $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; - $sql.= " WHERE e.rowid = ".$id; + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; + $sql .= " WHERE e.rowid = ".$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -696,14 +696,14 @@ class ChargeSociales extends CommonObject public function initAsSpecimen() { // Initialize parameters - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->paye = 0; $this->date = dol_now(); - $this->date_ech=$this->date+3600*24*30; - $this->periode=$this->date+3600*24*30; - $this->amount=100; + $this->date_ech = $this->date + 3600 * 24 * 30; + $this->periode = $this->date + 3600 * 24 * 30; + $this->amount = 100; $this->label = 'Social contribution label'; $this->type = 1; $this->type_label = 'Type of social contribution'; diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 714e15f0ee9..362e0c445ee 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -25,7 +25,7 @@ * \ingroup bom * \brief Description and activation file for module Bom */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -75,7 +75,7 @@ class modBom extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='bom'; + $this->picto = 'bom'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( @@ -103,15 +103,15 @@ class modBom extends DolibarrModules $this->config_page_url = array("bom.php"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->hidden = false; // A condition to hide module + $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->need_dolibarr_version = array(9, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'BomWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -132,10 +132,10 @@ class modBom extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (! isset($conf->bom) || ! isset($conf->bom->enabled)) + if (!isset($conf->bom) || !isset($conf->bom->enabled)) { - $conf->bom=new stdClass(); - $conf->bom->enabled=0; + $conf->bom = new stdClass(); + $conf->bom->enabled = 0; } @@ -281,28 +281,28 @@ class modBom extends DolibarrModules // Exports - $r=1; + $r = 1; /* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */ $langs->load("mrp"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='bom'; - $keyforclass = 'BOM'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bom'; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r] = 'bom'; + $keyforclass = 'BOM'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforclass = 'BOMLine'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bomline'; $keyforalias='tl'; + $keyforclass = 'BOMLine'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bomline'; $keyforalias = 'tl'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; unset($this->export_fields_array[$r]['tl.fk_bom']); - $keyforselect ='bom_bom'; $keyforaliasextra='extra'; $keyforelement='bom'; + $keyforselect = 'bom_bom'; $keyforaliasextra = 'extra'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect ='bom_bomline'; $keyforaliasextra='extraline'; $keyforelement='bomline'; + $keyforselect = 'bom_bomline'; $keyforaliasextra = 'extraline'; $keyforelement = 'bomline'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_dependencies_array[$r]=array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')'; + $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; + $this->export_sql_end[$r] .= ' WHERE 1 = 1'; + $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ } @@ -319,7 +319,7 @@ class modBom extends DolibarrModules { global $conf, $langs; - $result=$this->_load_tables('/bom/sql/'); + $result = $this->_load_tables('/bom/sql/'); if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') // Create extrafields From d10be4f1699ba8f3aa8978ed5c53160e5aacd9da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:40:24 +0100 Subject: [PATCH 16/18] FIX #12409 FIX #12408 --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index fa7efdfa2a5..54736ebc40f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -390,7 +390,7 @@ if ($action == 'confirm_generateinvoice') // Define qty per hour $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent']); + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known if (empty($pu_ht)) From cc70ffd1b36dc8b25398d7bfd9361570d1cb4ac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:47:35 +0100 Subject: [PATCH 17/18] Update list.php --- htdocs/societe/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a62dde1d79d..da5d4c268fd 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -232,9 +232,7 @@ if ($action == "change") // Change customer for TakePOS $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant // Check if draft invoice already exists, if not create it - $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'facture - where ref=\'(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')\' - AND entity IN ('.getEntity('invoice').')'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; $result = $db->query($sql); $num_lines = $db->num_rows($result); if ($num_lines==0) From a14042e4b21b04566dedde76830d26f2c1ac6d9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:48:39 +0100 Subject: [PATCH 18/18] Update list.php --- htdocs/societe/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index da5d4c268fd..504ccb37a25 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -239,7 +239,8 @@ if ($action == "change") // Change customer for TakePOS { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $invoice = new Facture($db); - $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $invoice->socid = $conf->global->$constforthirdpartyid; $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"];