From 2a7b3c7d7d327128f4b33acf4287185af501daa3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 14 Jan 2019 10:48:34 +0100 Subject: [PATCH 001/187] FIX : Check for old picture name if the new one was not found --- htdocs/theme/eldy/style.css.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0097eb4715c..14dad44a89d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1783,6 +1783,12 @@ foreach($mainmenuusedarray as $val) $found=1; break; } + else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); + $found=1; + break; + } } // Img file not found if (! $found) From 1cf786acff1dc3c31c0006e47238c349e5179fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 22 Jan 2019 00:09:36 +0100 Subject: [PATCH 002/187] Fix #10278 Fix #10278 --- htdocs/core/class/commonobject.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 676e76fe16a..d8d27a0378a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4932,8 +4932,6 @@ abstract class CommonObject $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $new_array_options[$key] = $this->db->idate($this->array_options[$key]); - break; case 'datetime': // If data is a string instead of a timestamp, we convert it if (! is_int($this->array_options[$key])) { From aa08e3276140499836516baf59feb7ac172cef5b Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Mon, 28 Jan 2019 04:48:59 +0100 Subject: [PATCH 003/187] Add links and related documents for a stock movement @eldy you can clone in movement_card.php if you prefer this structure --- htdocs/product/stock/movement_list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 68ad4d96789..ce77f120db4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -403,12 +403,12 @@ if ($action == "transfert_stock" && ! $cancel) /* * Build document */ -/* The builddoc action for object of a movement must be on the movement card +// The builddoc action for object of a movement must be on the movement card // Actions to build doc -$upload_dir = $conf->stock->dir_output; +$upload_dir = $conf->stock->dir_output . "movement/"; $permissioncreate = $user->rights->stock->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; -*/ + if (empty($reshook) && $action != 'remove_file') { @@ -416,7 +416,7 @@ if (empty($reshook) && $action != 'remove_file') $objectlabel='Movements'; $permtoread = $user->rights->stock->lire; $permtodelete = $user->rights->stock->supprimer; - $uploaddir = $conf->stock->dir_output; + $uploaddir = $conf->stock->dir_output . "/movement/"; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -1145,8 +1145,8 @@ else /* * Documents generes */ -/* Area for doc and last events of warehouse are stored on the main card of warehouse -$modulepart='mouvement'; +//Area for doc and last events of warehouse are stored on the main card of warehouse +$modulepart='movement'; if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) { @@ -1183,11 +1183,11 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print ''; } -*/ + // End of page llxFooter(); From 49ccdb96027960ad4f583ddf10cc403c35ba9b13 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Mon, 28 Jan 2019 05:06:02 +0100 Subject: [PATCH 004/187] Update movement_list.php For it to work you have to create this script htdocs\core\modules\stock\doc\pdf_stdmouvement.modules.php instead htdocs\core\modules\stock\doc\pdf_stdmovement.modules.php this mixture of fr/en confused me and I'm sure you better control the structure to make it work properly it tested & works but with htdocs\core\modules\stock\doc\pdf_stdmouvement.modules.php thx --- htdocs/product/stock/movement_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ce77f120db4..4435ea98f42 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1160,14 +1160,14 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; if($search_type_mouvement) $objectref.="_".$search_type_mouvement; $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/movement/' . $objectref; + $filedir = $conf->stock->dir_output . '/' . $modulepart .'/' . $objectref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; $genallowed=$usercanread; $delallowed=$usercancreate; - $genallowed=$user->rights->stock->mouvement->lire; - $delallowed=$user->rights->stock->mouvement->creer; + $genallowed=$user->rights->stock->lire; + $delallowed=$user->rights->stock->creer; print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; @@ -1183,7 +1183,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, $modulepart, 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print ''; } From 8546c801a568b73021fa182baf5536b62151845e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Mon, 28 Jan 2019 05:17:09 +0100 Subject: [PATCH 005/187] to make it work with movement_card.php --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 4435ea98f42..b790226cc61 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1031,7 +1031,7 @@ if ($resql) { // Inventory code print ''.'stock->dir_output . "movement/"; -$permissioncreate = $user->rights->stock->creer; -include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - - -if (empty($reshook) && $action != 'remove_file') -{ - $objectclass='MouvementStock'; - $objectlabel='Movements'; - $permtoread = $user->rights->stock->lire; - $permtodelete = $user->rights->stock->supprimer; - $uploaddir = $conf->stock->dir_output . "/movement/"; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; -} - - - /* * View */ @@ -1141,54 +1119,6 @@ else } - -/* - * Documents generes - */ -//Area for doc and last events of warehouse are stored on the main card of warehouse -$modulepart='movement'; - -if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) -{ - print '
'; - print '
'; - print ''; // ancre - - // Documents - $objectref = dol_sanitizeFileName($object->ref); - // Add inventorycode & type_mouvement to filename of the pdf - if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; - if($search_type_mouvement) $objectref.="_".$search_type_mouvement; - $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/' . $modulepart .'/' . $objectref; - - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; - $genallowed=$usercanread; - $delallowed=$usercancreate; - - $genallowed=$user->rights->stock->lire; - $delallowed=$user->rights->stock->creer; - - print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; - - print '
'; - - $MAXEVENT = 10; - - $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $modulepart, 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product - - print '
'; -} - - // End of page llxFooter(); $db->close(); From d31aadf5dab74fd1cba6f8b5fb53d34db57b01a6 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 05:20:33 +0100 Subject: [PATCH 007/187] Add Default Warehouse to user --- htdocs/user/class/user.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a6bc202d17f..451a5abda80 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -173,6 +173,8 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; + + public $fk_warehouse; public $fields = array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), @@ -248,6 +250,7 @@ class User extends CommonObject $sql.= " u.weeklyhours,"; $sql.= " u.color,"; $sql.= " u.dateemployment, u.dateemploymentend,"; + $sql.= " u.fk_warehouse,"; $sql.= " u.ref_int, u.ref_ext,"; $sql.= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode $sql.= " c.code as country_code, c.label as country,"; @@ -368,6 +371,7 @@ class User extends CommonObject $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; + $this->fk_warehouse = $obj->fk_warehouse; // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. @@ -1482,6 +1486,7 @@ class User extends CommonObject $this->color = empty($this->color)?'':$this->color; $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; $this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend; + $this->fk_warehouse = trim(empty($this->fk_warehouse)?'':$this->fk_warehouse); // Check parameters if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -1539,6 +1544,7 @@ class User extends CommonObject $sql.= ", entity = '".$this->db->escape($this->entity)."'"; $sql.= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null'); $sql.= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); + $sql.= ", fk_warehouse = ".($this->fk_warehouse?"'".$this->db->escape($this->fk_warehouse)."'":"null"); $sql.= " WHERE rowid = ".$this->id; @@ -1977,7 +1983,7 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } -$mailfile = new CMailFile( + $mailfile = new CMailFile( $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, From 4dc4a25bb500fb0683f61e9484b2fc0a3af454d6 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 05:24:25 +0100 Subject: [PATCH 008/187] Add Default Warehouse to user card --- htdocs/user/card.php | 46 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 63a2a598d41..f4482a9e872 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -48,6 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); @@ -91,7 +92,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id <> $id && ! $canreaduser) accessforbidden(); // Load translation files required by page -$langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm')); +$langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks')); $object = new User($db); $extrafields = new ExtraFields($db); @@ -237,6 +238,8 @@ if (empty($reshook)) { $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth'), GETPOST('dateemploymentendday'), GETPOST('dateemploymentendyear')); $object->dateemploymentend = $dateemploymentend; + $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { @@ -383,6 +386,8 @@ if (empty($reshook)) { $object->dateemployment = $dateemployment; $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $object->dateemploymentend = $dateemploymentend; + + $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); if (! empty($conf->multicompany->enabled)) { @@ -639,6 +644,7 @@ $form = new Form($db); $formother=new FormOther($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans("UserCard")); @@ -1104,7 +1110,8 @@ if ($action == 'create' || $action == 'adduserldap') { print '' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); - print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); + print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, + null, '90%' ); print ""; } @@ -1165,6 +1172,10 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print ''; + // Default warehouse + print ''.$langs->trans("DefaultWarehouse").''; + print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); + print ''; if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) @@ -1517,6 +1528,14 @@ else print ''.$langs->trans("PostOrFunction").''; print ''.$object->job.''; print ''."\n"; + + // Default warehouse + require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; + $warehousestatic=new Entrepot($db); + $warehousestatic->fetch($object->fk_warehouse); + print ''.$langs->trans("DefaultWarehouse").''; + print $warehousestatic->getNomUrl(); + print ''; //$childids = $user->getAllChildIds(1); @@ -1611,9 +1630,9 @@ else // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print '' . $langs->trans("Categories") . ''; + print '' . $langs->trans( "Categories" ) . ''; print ''; - print $form->showCategories($object->id, 'user', 1); + print $form->showCategories( $object->id, 'user', 1 ); print ''; } @@ -2378,21 +2397,21 @@ else print ''; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print '' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; print ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); - $c = new Categorie($db); + $cate_arbo = $form->select_all_categories( Categorie::TYPE_USER, null, null, null, null, 1 ); + $c = new Categorie( $db ); $cats = $c->containing($object->id, Categorie::TYPE_USER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } if ($caneditfield) { - print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print $form->multiselectarray( 'usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); }else{ - print $form->showCategories($object->id, 'user', 1); + print $form->showCategories( $object->id, 'user', 1 ); } print ""; } @@ -2518,6 +2537,15 @@ else print $object->job; } print ''; + + // Default warehouse + if (! empty($conf->stock->enabled)) + { + print ''.$langs->trans("DefaultWarehouse").''; + print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); + print ' '.$langs->trans("AddWarehouse").''; + print ''; + } if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) From fd4f82b1b72828d06ba3b13c77ec21edc513cb5c Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 05:32:01 +0100 Subject: [PATCH 009/187] Fix conflict --- htdocs/user/card.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f4482a9e872..fc6d7793330 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1110,8 +1110,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); - print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, - null, '90%' ); + print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); print ""; } @@ -1630,9 +1629,9 @@ else // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print '' . $langs->trans( "Categories" ) . ''; + print '' . $langs->trans("Categories") . ''; print ''; - print $form->showCategories( $object->id, 'user', 1 ); + print $form->showCategories($object->id, 'user', 1); print ''; } @@ -2397,21 +2396,21 @@ else print ''; // Categories - if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; print ''; - $cate_arbo = $form->select_all_categories( Categorie::TYPE_USER, null, null, null, null, 1 ); - $c = new Categorie( $db ); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); + $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_USER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } if ($caneditfield) { - print $form->multiselectarray( 'usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); + print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); }else{ - print $form->showCategories( $object->id, 'user', 1 ); + print $form->showCategories($object->id, 'user', 1); } print ""; } From 03c5e040c59691fc532eaa36957e5c7b786fe56d Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 05:48:56 +0100 Subject: [PATCH 010/187] Fix backtopage url --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fc6d7793330..ff4253df646 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2542,7 +2542,7 @@ else { print ''.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); - print ' '.$langs->trans("AddWarehouse").''; + print ' '.$langs->trans("AddWarehouse").''; print ''; } From 63ffb7a87341a1024fa6b888fe78e044e0f8aae8 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 06:04:58 +0100 Subject: [PATCH 011/187] Fix backtopage url --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ff4253df646..84d83acf483 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2542,7 +2542,7 @@ else { print ''.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); - print ' '.$langs->trans("AddWarehouse").''; + print ' '.$langs->trans("AddWarehouse").''; print ''; } From 8390ed346bd6d2909e18dafb660f1b0439bc25b4 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 15 Feb 2019 17:12:39 +0100 Subject: [PATCH 012/187] Hidden for users not using the stock module --- htdocs/user/card.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 84d83acf483..048ee72e688 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -48,7 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); @@ -644,7 +644,7 @@ $form = new Form($db); $formother=new FormOther($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); -$formproduct = new FormProduct($db); +if (! empty($conf->stock->enabled)) $formproduct = new FormProduct($db); llxHeader('', $langs->trans("UserCard")); @@ -1172,9 +1172,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; // Default warehouse - print ''.$langs->trans("DefaultWarehouse").''; - print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); - print ''; + if (! empty($conf->stock->enabled)) + { + print ''.$langs->trans("DefaultWarehouse").''; + print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); + print ''; + } if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) @@ -1529,12 +1532,15 @@ else print ''."\n"; // Default warehouse - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; - $warehousestatic=new Entrepot($db); - $warehousestatic->fetch($object->fk_warehouse); - print ''.$langs->trans("DefaultWarehouse").''; - print $warehousestatic->getNomUrl(); - print ''; + if (! empty($conf->stock->enabled)) + { + require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; + $warehousestatic=new Entrepot($db); + $warehousestatic->fetch($object->fk_warehouse); + print ''.$langs->trans("DefaultWarehouse").''; + print $warehousestatic->getNomUrl(); + print ''; + } //$childids = $user->getAllChildIds(1); @@ -2543,7 +2549,7 @@ else print ''.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); print ' '.$langs->trans("AddWarehouse").''; - print ''; + print ''; } if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) From b017213131e278ab1603d0e1a78402bed704e100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 17 Feb 2019 20:59:39 +0100 Subject: [PATCH 013/187] selectMulticurrency avoid malformed empty value --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 58df0ad4e22..c451a83a4fb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4517,7 +4517,7 @@ class Form $out=''; $out.= ''; +print ''; + +// Define main accounts for closure +print ''; + +foreach ($list_account_main as $key) { + + print ''; + // Param + $label = $langs->trans($key); + $keydesc=$key.'_Desc'; + + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; +} + +// Journal +print ''; +print ''; +print ''; + +print "
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force align=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
' . $langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL") . ''; +$defaultjournal=$conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL; +print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0); +print '
\n"; + +print '
'; + +print ''; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index fc5f5980df5..5b39a38657f 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -53,8 +53,6 @@ $list_account_main = array ( ); $list_account = array ( - 'ACCOUNTING_RESULT_PROFIT', - 'ACCOUNTING_RESULT_LOSS', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 028e6569378..a5b0a574c35 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -89,7 +89,7 @@ class FormAccounting extends Form $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; $sql.= " WHERE active = 1"; $sql.= " AND entity = ".$conf->entity; - //if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; + if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; $sql.= " ORDER BY code"; dol_syslog(get_class($this) . "::select_journal", LOG_DEBUG); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index f49c4cb6027..50d1862f39f 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -249,7 +249,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 54, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 55, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2465__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_closure', 2451__+MAX_llx_menu__, '/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuClosureAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); -- Accounting period insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7a43aa43d60..ab2599728d8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1058,6 +1058,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55); $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60); + $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 70); // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 1) { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 1a153d1f80d..014cc9827f9 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -96,6 +96,7 @@ MenuTaxAccounts=Tax accounts MenuExpenseReportAccounts=Expense report accounts MenuLoanAccounts=Loan accounts MenuProductsAccounts=Product accounts +MenuClosureAccounts=Closure accounts ProductsBinding=Products accounts Ventilation=Binding to accounts CustomersVentilation=Customer invoice binding @@ -149,8 +150,9 @@ ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal -ACCOUNTING_RESULT_PROFIT=Accounting account of profit result -ACCOUNTING_RESULT_LOSS=Accounting account of loss result +ACCOUNTING_RESULT_PROFIT=Result accounting account (Profit) +ACCOUNTING_RESULT_LOSS=Result accounting account (Loss) +ACCOUNTING_CLOSURE_DEFAULT_JOURNAL=Journal of closure ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait @@ -289,6 +291,7 @@ ChartofaccountsId=Chart of accounts Id InitAccountancy=Init accountancy InitAccountancyDesc=This page can be used to initialize an accounting account on products and services that does not have accounting account defined for sales and purchases. DefaultBindingDesc=This page can be used to set a default account to use to link transactions record about payment salaries, donation, taxes and vat when no specific accounting account were already set. +DefaultClosureDesc=This page can be used to set accounts to use to enclose a balance sheet. Options=Options OptionModeProductSell=Mode sales OptionModeProductBuy=Mode purchases From f5b5859089958d21c8019958aeb4ce669c41105d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 18 Feb 2019 07:16:00 +0100 Subject: [PATCH 016/187] Language --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 014cc9827f9..86c510dfe00 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -291,7 +291,7 @@ ChartofaccountsId=Chart of accounts Id InitAccountancy=Init accountancy InitAccountancyDesc=This page can be used to initialize an accounting account on products and services that does not have accounting account defined for sales and purchases. DefaultBindingDesc=This page can be used to set a default account to use to link transactions record about payment salaries, donation, taxes and vat when no specific accounting account were already set. -DefaultClosureDesc=This page can be used to set accounts to use to enclose a balance sheet. +DefaultClosureDesc=This page can be used to set parameters to use to enclose a balance sheet. Options=Options OptionModeProductSell=Mode sales OptionModeProductBuy=Mode purchases From c22be202d9d16022efa87c4752170a2fda3e3f09 Mon Sep 17 00:00:00 2001 From: bomuux Date: Mon, 18 Feb 2019 23:17:03 +0100 Subject: [PATCH 017/187] SQL error in box_project.php Corrected a bug : for an internal user with no rights to see all projects, the project box on home cause an error in log. Finally a lot of simplification because Project::getProjectsAuthorizedForUser do most of the filtering. --- htdocs/core/boxes/box_project.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 7ab97832637..a969d2126e6 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -89,21 +89,14 @@ class box_project extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); - $socid=$user->societe_id; - - // Get list of project id allowed to user (in a string list separated by coma) + // Get list of project id allowed to user (in a string list separated by coma) $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; //$sql.= $db->plimit($max, 0); From d3627c143808a01ba73979876ec05686e0b77216 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 15:49:54 +0100 Subject: [PATCH 018/187] NEW options for alternative method payment request api (ex apple pay) and sepa direct debit --- htdocs/stripe/admin/stripe.php | 56 ++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 100a85f6c30..056c993bcec 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov - * Copyright (C) 2018 ptibogxiv + * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -78,9 +78,6 @@ if ($action == 'setvalue' && $user->admin) $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; - $result = dolibarr_set_const($db, "STRIPE_MINIMAL_3DSECURE", GETPOST('STRIPE_MINIMAL_3DSECURE', 'int'), 'chaine', 0, '', $conf->entity); - if (! $result > 0) - $error ++; $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; @@ -166,17 +163,11 @@ print "\n"; print ''; print ''; print $langs->trans("StripeLiveEnabled").''; -if (!empty($conf->global->STRIPE_LIVE)) -{ - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_LIVE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); } print ''; @@ -272,16 +263,36 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? print ''; } -// Minimal amount for force 3Dsecure if it's optionnal +// Activate Payment Request API +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code +{ + print ''; + print $langs->trans("STRIPE_PAYMENT_REQUEST_API").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); +} + print ''; +} + +// Activate SEPA DIRECT_DEBIT if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { print ''; - print $langs->trans("STRIPE_MINIMAL_3DSECURE").''; - print ''.$langs->getCurrencySymbol($conf->currency).''; + print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); +} + print ''; } // Warehouse for automatic decrement -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment { print ''; print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; @@ -329,7 +340,12 @@ print ''; print ''; print $langs->trans("SecurityTokenIsUnique").''; -print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN)?0:$conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE); +} print ''; print ''; From 97620e91c948c65808ea01cd490a0d3eaa0fccc5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 16:31:39 +0100 Subject: [PATCH 019/187] add link to webhook --- htdocs/stripe/admin/stripe.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 056c993bcec..dc63efbd99b 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov - * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2018 ptibogxiv * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -186,9 +186,14 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").'
'; + $url = dol_buildpath('/public/stripe/ipn.php?test', 2); + $out.= ''; + $out.= ajax_autoselect("onlinetestwebhookurl", 0); + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -216,9 +221,14 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").'
'; + $url = dol_buildpath('/public/stripe/ipn.php', 2); + $out.= ''; + $out.= ajax_autoselect("onlinelivewebhookurl", 0); + print '
'.$out; print ''; } else From 8e55802e92e55aa321dabc971dc8dc4050fc70e2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 19:40:47 +0100 Subject: [PATCH 020/187] Update stripe.php --- htdocs/stripe/admin/stripe.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index dc63efbd99b..ac86a893903 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -165,7 +165,7 @@ print ''; print $langs->trans("StripeLiveEnabled").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_LIVE'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); } @@ -193,7 +193,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php?test', 2); $out.= ''; $out.= ajax_autoselect("onlinetestwebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -228,7 +228,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php', 2); $out.= ''; $out.= ajax_autoselect("onlinelivewebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else @@ -280,7 +280,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print $langs->trans("STRIPE_PAYMENT_REQUEST_API").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); } @@ -294,7 +294,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); } From ea6e397d18a9bffc78d5e943e739151a9441295a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 22:28:26 +0100 Subject: [PATCH 021/187] Update stripe.php --- htdocs/stripe/admin/stripe.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index ac86a893903..4a3b189a71e 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -168,7 +168,7 @@ print $langs->trans("StripeLiveEnabled").''; } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); -} + } print ''; if (empty($conf->stripeconnect->enabled)) @@ -282,8 +282,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); -} + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API): + } print ''; } @@ -297,7 +297,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); -} + } print ''; } From 0a3e0bc2682592987b24c2f083a000f1f8d64b03 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 22:56:07 +0100 Subject: [PATCH 022/187] Update stripe.php --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 4a3b189a71e..46c12801c51 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -282,7 +282,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API): + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); } print ''; } From 0af6426f8c7ec6fb924e35eafafd6612c02b46dc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 23:36:59 +0100 Subject: [PATCH 023/187] Update stripe.php --- htdocs/stripe/admin/stripe.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 46c12801c51..172e1897417 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -193,7 +193,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php?test', 2); $out.= ''; $out.= ajax_autoselect("onlinetestwebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -228,7 +228,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php', 2); $out.= ''; $out.= ajax_autoselect("onlinelivewebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else From 0428e026c9a53c8a5ab0e04ecf7d78b2520b60be Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 21 Feb 2019 15:08:19 +0100 Subject: [PATCH 024/187] Update stripe.php --- htdocs/stripe/admin/stripe.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 172e1897417..0c6e195910d 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -187,7 +187,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; - print ''; + print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").'
'; $url = dol_buildpath('/public/stripe/ipn.php?test', 2); @@ -222,7 +222,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; - print ''; + print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").'
'; $url = dol_buildpath('/public/stripe/ipn.php', 2); From 6ba5708814627d346a3cf1d8d0a7c7d2e500c368 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 23 Feb 2019 19:26:52 +0100 Subject: [PATCH 025/187] disable online payment warehouse --- htdocs/stripe/admin/stripe.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 0c6e195910d..5e2c27dd392 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -94,9 +94,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; // Stock decrement - $result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - if (! $result > 0) - $error ++; + //$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); + //if (! $result > 0) + // $error ++; // Payment token for URL $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -302,13 +302,13 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code } // Warehouse for automatic decrement -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment -{ - print ''; - print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; - print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled); - print ''; -} +//if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment +//{ +// print ''; +// print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; +// print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled); +// print ''; +//} print ''; print $langs->trans("CSSUrlForPaymentForm").''; From 0ea7bf3b0b6ee6c7419d3a1fe306987ac78628a7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 24 Feb 2019 08:21:56 +0100 Subject: [PATCH 026/187] FIX could not create several superadmin in transversal mode --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6db383ed515..adcf094e7a4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -855,7 +855,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print $form->selectyesno('admin',GETPOST('admin'),1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if (! empty($conf->use_javascript_ajax)) { @@ -1992,7 +1992,7 @@ else { print $form->selectyesno('admin',$object->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if ($conf->use_javascript_ajax) { From 435b416f939b7d906abb246c711acca8a8d25914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 11:50:06 +0100 Subject: [PATCH 027/187] fix #10656 --- htdocs/fourn/facture/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 98a6956a809..4d2c81dbbfa 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -387,6 +387,7 @@ if (! $search_all) $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql.= " f.localtax1, f.localtax2,"; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= ' p.title,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; From ca2eba866c641d799f378a834ef99ccd652f9179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 11:56:17 +0100 Subject: [PATCH 028/187] Update list.php --- htdocs/fourn/facture/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4d2c81dbbfa..4b208a99af7 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -387,11 +387,10 @@ if (! $search_all) $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql.= " f.localtax1, f.localtax2,"; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql .= ' p.title,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref"; + $sql.= " p.rowid, p.ref, p.title"; foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by { From 2ad91213b2dd5c2bcd136b51f8a281f688df6378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 12:09:57 +0100 Subject: [PATCH 029/187] Update combinations.php --- htdocs/variants/combinations.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 04f53e55d21..8c8f669c0e0 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Laurent Destailleur + * 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 @@ -30,9 +31,9 @@ $langs->load("other"); $var = false; $id = GETPOST('id', 'int'); $valueid = GETPOST('valueid', 'int'); -$ref = GETPOST('ref'); -$weight_impact = (float) GETPOST('weight_impact'); -$price_impact = (float) GETPOST('price_impact'); +$ref = GETPOST('ref', 'alpha'); +$weight_impact = GETPOST('weight_impact', 'alpha'); +$price_impact = GETPOST('price_impact', 'alpha'); $price_impact_percent = (bool) GETPOST('price_impact_percent'); $form = new Form($db); From 46a6bbe62cf7049672d318461a22a8cbc5d553a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 14:16:29 +0100 Subject: [PATCH 030/187] phpcs fix in 9.0 --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fd050297fe5..cab95ff7a97 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1324,7 +1324,7 @@ class Facture extends CommonInvoice $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; - $sql.= ', f.module_source, f.pos_source'; + $sql.= ', f.module_source, f.pos_source'; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; @@ -1402,7 +1402,7 @@ class Facture extends CommonInvoice $this->libelle_incoterms = $obj->libelle_incoterms; $this->module_source = $obj->module_source; - $this->pos_source = $obj->pos_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; From 47f5ff3303393a0a025a791ddf7d695de764463b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 24 Feb 2019 16:11:52 +0100 Subject: [PATCH 031/187] Fix declare functions2.lib.php for donations API --- htdocs/core/lib/functions2.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index aae70adfb62..faa149305a2 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2260,6 +2260,9 @@ function getModuleDirForApiClass($module) elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { $moduledirforclass = 'adherents'; } + elseif ($module == 'don' || $module == 'donations') { + $moduledirforclass = 'don'; + } elseif ($module == 'banque' || $module == 'bankaccounts') { $moduledirforclass = 'compta/bank'; } From c781eeb17d46cfb74b723c81fda1d99e50edf618 Mon Sep 17 00:00:00 2001 From: Cristian Torres Date: Wed, 20 Feb 2019 11:45:07 -0600 Subject: [PATCH 032/187] [FIX] ORDER BY before custom filters for where When filtering data "and cac.libelle" would be appended after ORDER BY --- htdocs/core/modules/modAgenda.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 2324bfad616..86157eb98f6 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -418,6 +418,6 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_end[$r] .=' ORDER BY ac.datep'; + $this->export_sql_order[$r] .=' ORDER BY ac.datep'; } } From 57ee8b7991be9fec477cf497ec9d8b5ccfceecd7 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 24 Feb 2019 21:15:11 +0100 Subject: [PATCH 033/187] Fix no JPG images in TakePOS and other image improvements. --- htdocs/takepos/css/pos.css | 12 +++++ htdocs/takepos/genimg/add.jpg | Bin 5419 -> 0 bytes htdocs/takepos/genimg/empty.jpg | Bin 2239 -> 0 bytes htdocs/takepos/genimg/empty.png | Bin 0 -> 156 bytes htdocs/takepos/genimg/index.php | 87 +++++++++----------------------- htdocs/takepos/takepos.php | 34 ++++++++----- 6 files changed, 57 insertions(+), 76 deletions(-) delete mode 100644 htdocs/takepos/genimg/add.jpg delete mode 100644 htdocs/takepos/genimg/empty.jpg create mode 100644 htdocs/takepos/genimg/empty.png diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index 87c74c8952d..cac9a23a8d9 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -110,6 +110,18 @@ div.description{ text-align:center; } +div.catwatermark{ + position:absolute; + top:3%; + left:3%; + width:20%; + background-color:black; + color:white; + text-align:center; + font-size: 20px; + display: none; +} + @media only screen and (max-aspect-ratio: 6/4) { div.description{ min-height:20%; diff --git a/htdocs/takepos/genimg/add.jpg b/htdocs/takepos/genimg/add.jpg deleted file mode 100644 index 976fd10697d47e06cc9d74f7efed36ab17d95ed7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5419 zcmeHL4OA0X7QRCW2>}g3z`xd@Kt-T>s!)GR01XNrgn$bE)KnDtJ1(^qLB$N>A7U*< zMYri9KPrf#DL*bA*117Cuv;;C3&)y~- zL^jWL(}#!$=JbnJ2Udw}f7VU?0Na`eP@0MEz;rOfFw^~GV=x(}W?^p5V6rS&ER(P; ztt{DW4x7c|4B&9Atm($G9LODDJ_g=$=LwOYrCD+u1`ioJ%;mk&u4CLhy*`{cY4VimGlc## zX9Wa?&7C(tJYvDZWy_;hM90L&eZD$zO;YmOb(=PC*}5%#d&aKad$RZL`|H=zf&&K+ z6&4*XK2la*apLcl-~Hp{`Ksy*7cYH(x#q^ry82rUw;P*U+wR?O|KUN$!%lV26U|d? zuTI}*!i53jIjk4Reuaxi<1(Yyz?@~mg_$MM!r+-RM}A;o>nma{T{URb_>F8kzpVVy zbCymMLRI#WpUF86&YrCl%>|>|Rss`|}-< zK7~>UT6PmXJH|B@QJ2HFAkfI;efT~ip&k4r;c6BFW+Z|=h13m&c3z4ILDBjnl)_!N ziC(x;ye15fO)$8faYb> zsR&%lNGYz&P8K5wa;U&GOgoX!3&Cx0)%%5k!Sw;P)k+ly&vI_2*lE{_gk` z%afEs1Qr>Rt3*YSQmoq6_TfM8C4A{1Rb(3N4%C3`KMForEdS+7d>FsATm%1X*2qd+9-LxA5{Q|M9E`)Xe4YnNKnWTKG z3Y$$zDJ+@adTq<9!yk9-2Nk((t47~_*ZHKh`C8M|+Zd@Aij88ke}6nWwXD$HGIdFugAK~%GNwc{9@V{b`wg$ zx^!A@U8gIfhxH0CWcJ4hq@*BK;E2D<3v`D2HPy%(-e|+_dO2As;l$$Q;;wx4`WK#8 zA1`k`?Y+J?U~FM!`59^R=d?HBhWe3 zBhW{Szxp3A-k|x|z)Oj*$76$U6Rq6pm1`8i6}OBVT8<5`mTq?7oqACMAHVi!$l4*U z(UCATa;@Ne4&GlF=W+91F5#c;c)aB?(KK5dPgZ!3OPO4IYLLpidxna;Gck9-!zYT4 zzJvS17Bwn@5(d>=K3w3r#VPcH$k(~mrv(?*_ZPmY-V~kr>WR37J{vq5fsxlqKgthK zPV>oPqQjTWMWC8_6hY55!Z9X~+t97sxky_`7uqZ>PVa^hG6Ywq2->_7n!cen^BYae zYrc*^;PI%(A_GXt8*klMO6E(vI_XN_lH#2d|Av(sLr}t{W=BH(UOsbk!n-9C2k#rd zI55k-{N%+E{+yw=Q!OI)2lIbh!Tz>5e|y+@d)WCy4v)o(@&@C(4Tb>8RUA%nRS*1B z!DkJp2c7lif2(TF{fNpu5|HS1I;UcddRmDz!)aEim&ZIi+c|avS?xRRus*UsR+-rk zSxJ24K75&?KgwGDDp@t$AMghmPt-3n_!*y(N9LJHx}C@GJk-)Bl2gwMV0QD=h`)>* ZyZpQCQQ^@qmB0JF|GfWsej+2(_-~uMLm2=7 diff --git a/htdocs/takepos/genimg/empty.jpg b/htdocs/takepos/genimg/empty.jpg deleted file mode 100644 index 8883f7c9957bf151875278b6ded394d9594c8b25..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2239 zcmex=}T+5Ri6|E+FFJVCMj-APxLK zz#z!MsL5!;%&5e`B*@4t$oT&VgFMistiX@}1qKu_GBLBTvH_jM#SK)jRRHLGW@aX! zV_8{%-es%>$}_MCvI;30I#U-U>$dGXcJ4ZK_{h;?$4{I*b?NeztJkjIxOwa0 zqsLF4K70P+<*SdMK7aZ8?fZ|Pzd-(CWMGDP3+^*Ce+dHp#RQB47Iu)o7@5j}m|2j8 zRnd@5$T5&Tu~1masF6d&Y2w0-2RW6EgFc8R6KQ!#m{`Vr(cu+NC|SQA-3gL@3& ruUiZ}z=X*p$SlZU&+zxpqAm@FQ9K$3qiJ9?4UDFNVV?$=|K9`vEy2T8 diff --git a/htdocs/takepos/genimg/empty.png b/htdocs/takepos/genimg/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..63163e9f86953a5a1b1ef0a16f5e8189e63b8f1e GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|!aQ9ZLn>~) qJ!r@Xfetch($id); + $upload_dir = $conf->categorie->multidir_output[$object->entity]; $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; $dir = $upload_dir.'/'.$pdir; + foreach ($object->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - - // The file - $filename = $dir.$filename; - if (!file_exists($filename)) $filename="empty.jpg"; - - // Dimensions - list($width, $height) = getimagesize($filename); - $new_width = $w; - $new_height = $h; - - // Resample - $image_p = imagecreatetruecolor($new_width, $new_height); - $image = imagecreatefromjpeg($filename); - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - - // Add icon - $icon = imagecreatefromjpeg('add.jpg'); - list($width, $height) = getimagesize('add.jpg'); - $new_width = $w*0.3; - $new_height = $h*0.3; - $icon_p = imagecreatetruecolor($new_width, $new_height); - imagecopyresampled($icon_p, $icon, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - imagecopymerge($image_p, $icon_p, 0, 0, 0, 0, $new_width, $new_height, 100); - - // Output - imagejpeg($image_p, null, 100); + { + if ($obj['photo_vignette']) + { + $filename=$obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + $viewfilename=$obj['photo']; + $file=DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename); + header('Location: '.$file); + exit; + } + header('Location: ../../public/theme/common/nophoto.png'); } elseif ($query=="pro") { @@ -89,39 +76,13 @@ elseif ($query=="pro") $objProd = new Product($db); $objProd->fetch($id); - - $dir .= get_exdir(0, 0, 0, 0, $objProd, 'product').$objProd->ref.'/'; - $pdir .= get_exdir(0, 0, 0, 0, $objProd, 'product').$objProd->ref.'/'; - - foreach ($objProd->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - $filename = $dir.$filename; - - if (!file_exists($filename)){ - $dir = $conf->product->multidir_output[$objProd->entity].'/'.$pdir; - foreach ($objProd->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - $filename = $dir.$filename; - } - - if (!file_exists($filename)) $filename="empty.jpg"; - - // Dimensions - list($width, $height) = getimagesize($filename); - $new_width = $w; - $new_height = $h; - - // Resample - $image_p = imagecreatetruecolor($new_width, $new_height); - $image = imagecreatefromjpeg($filename); - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - - // Output - imagejpeg($image_p, null, 100); + $image=$objProd->show_photos('product', $conf->product->multidir_output[$entity], 'small', 1); + + preg_match( '@src="([^"]+)"@' , $image, $match ); + $file = array_pop($match); + if ($file=="") header('Location: ../../public/theme/common/nophoto.png'); + else header('Location: '.$file); + } else { diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 4edab6c9bee..4b36bbbdd81 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -93,8 +93,9 @@ function PrintCategories(first){ for (i = 0; i < 14; i++) { if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break; $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); - $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[parseInt(i)+parseInt(first)]['rowid']); + $("#catimg"+i).attr("src","genimg/?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); + $("#catwatermark"+i).show(); } } @@ -117,12 +118,14 @@ function MoreCategories(moreorless){ for (i = 0; i < 14; i++) { if (typeof (categories[i+(14*pagecategories)]) == "undefined"){ $("#catdesc"+i).text(""); - $("#catimg"+i).attr("src",""); + $("#catimg"+i).attr("src","genimg/empty.png"); + $("#catwatermark"+i).hide(); continue; } $("#catdesc"+i).text(categories[i+(14*pagecategories)]['label']); - $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[i+(14*pagecategories)]['rowid']); + $("#catimg"+i).attr("src","genimg/?query=cat&id="+categories[i+(14*pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+(14*pagecategories)]['rowid']); + $("#catwatermark"+i).show(); } } @@ -131,16 +134,17 @@ function LoadProducts(position, issubcat=false){ $('#catimg'+position).animate({opacity: '1'}, 100); if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); else currentcat=$('#catdiv'+position).data('rowid'); - if (currentcat=="") return; + if (currentcat==undefined) return; pageproducts=0; ishow=0; //product to show counter jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent){ $("#prodesc"+ishow).text(val.label); - $("#proimg"+ishow).attr("src","genimg/?query=cat&w=55&h=50&id="+val.rowid); + $("#proimg"+ishow).attr("src","genimg/?query=cat&id="+val.rowid); $("#prodiv"+ishow).data("rowid",val.rowid); $("#prodiv"+ishow).data("iscat",1); + $("#prowatermark"+ishow).show(); ishow++; } }); @@ -150,18 +154,19 @@ function LoadProducts(position, issubcat=false){ while (idata < 30 && ishow < 30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); - $("#proimg"+ishow).attr("src",""); + $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); ishow++; //Next product to show after print data product } else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); - $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); $("#prodiv"+ishow).data("iscat",0); ishow++; //Next product to show after print data product } + $("#prowatermark"+ishow).hide(); idata++; //Next data everytime } }); @@ -189,18 +194,19 @@ function MoreProducts(moreorless){ while (idata < (30*pageproducts)+30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); - $("#proimg"+ishow).attr("src",""); + $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); ishow++; //Next product to show after print data product } else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); - $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); $("#prodiv"+ishow).data("iscat",0); ishow++; //Next product to show after print data product } + $("#prowatermark"+ishow).hide(); idata++; //Next data everytime } }); @@ -261,12 +267,12 @@ function Search2(){ for (i = 0; i < 30; i++) { if (typeof (data[i]) == "undefined"){ $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src",""); + $("#proimg"+i).attr("src","genimg/empty.png"); $("#prodiv"+i).data("rowid",""); continue; } $("#prodesc"+i).text(data[parseInt(i)]['label']); - $("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i]['rowid']); + $("#proimg"+i).attr("src","genimg/?query=pro&id="+data[i]['rowid']); $("#prodiv"+i).data("rowid",data[i]['rowid']); $("#prodiv"+i).data("iscat",0); } @@ -491,10 +497,11 @@ foreach($menus as $menu) { { ?>
id='catdiv'> - width="98%" id='catimg'/> + width="100%" height="85%" id='catimg'/>
+
+
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > - width="95%" id='proimg'/> + width="100%" height="85%" id='proimg'/>
+
+
Date: Sun, 24 Feb 2019 23:32:09 +0100 Subject: [PATCH 034/187] wip --- dev/setup/codesniffer/ruleset.xml | 2 +- .../categories/class/api_categories.class.php | 16 +- htdocs/categories/class/categorie.class.php | 135 +++--- .../expedition/class/api_shipments.class.php | 35 +- htdocs/expedition/class/expedition.class.php | 97 ++-- .../class/expeditionbatch.class.php | 26 +- .../class/expeditionstats.class.php | 26 +- htdocs/product/class/api_products.class.php | 42 +- .../product/class/html.formproduct.class.php | 12 +- htdocs/product/class/product.class.php | 437 ++++++++++-------- htdocs/product/class/productbatch.class.php | 41 +- .../class/productcustomerprice.class.php | 40 +- .../class/propalmergepdfproduct.class.php | 52 +-- .../stock/class/api_stockmovements.class.php | 16 +- .../stock/class/api_warehouses.class.php | 16 +- htdocs/product/stock/class/entrepot.class.php | 30 +- .../stock/class/mouvementstock.class.php | 32 +- .../product/stock/class/productlot.class.php | 6 +- .../class/productstockentrepot.class.php | 16 +- htdocs/projet/class/api_projects.class.php | 26 +- htdocs/projet/class/api_tasks.class.php | 34 +- htdocs/projet/class/project.class.php | 128 ++--- htdocs/projet/class/projectstats.class.php | 38 +- htdocs/projet/class/task.class.php | 88 ++-- htdocs/projet/class/taskstats.class.php | 8 +- 25 files changed, 723 insertions(+), 676 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 6098a0e0139..0b39529ff66 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -201,7 +201,7 @@ 0 - + diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index f5b13437ba9..4605b9f200e 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -53,7 +53,7 @@ class Categories extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -70,7 +70,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -103,7 +103,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') { global $db, $conf; @@ -173,7 +173,7 @@ class Categories extends DolibarrApi * @param array $request_data Request data * @return int ID of category */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -198,7 +198,7 @@ class Categories extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -234,7 +234,7 @@ class Categories extends DolibarrApi * @param int $id Category ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { throw new RestException(401); @@ -267,7 +267,7 @@ class Categories extends DolibarrApi * @param Categorie $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -324,7 +324,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $category = array(); foreach (Categories::$FIELDS as $field) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 20d9a862f33..f162bc68bba 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-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 @@ -107,7 +107,7 @@ class Categorie extends CommonObject 'account' => 'account', // old for bank_account 'bank_account' => 'account', 'project' => 'project', - ); + ); /** * @var array Category tables mapping from type string @@ -221,7 +221,7 @@ class Categorie extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -234,7 +234,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', '...') or (0, 1, ...) * @return int <0 if KO, >0 if OK */ - function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null) { global $conf; @@ -297,15 +297,15 @@ class Categorie extends CommonObject } /** - * Add category into database + * Add category into database * - * @param User $user Object user - * @return int -1 : SQL error + * @param User $user Object user + * @return int -1 : SQL error * -2 : new ID unknown * -3 : Invalid category * -4 : category already exists */ - function create($user) + public function create($user) { global $conf,$langs,$hookmanager; $langs->load('categories'); @@ -426,7 +426,7 @@ class Categorie extends CommonObject * -1 : SQL error * -2 : invalid category */ - function update(User $user) + public function update(User $user) { global $conf, $langs,$hookmanager; @@ -501,7 +501,7 @@ class Categorie extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 KO >0 OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; @@ -588,7 +588,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', ...) * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ - function add_type($obj, $type) + public function add_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -682,7 +682,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete object from category * @@ -691,7 +691,7 @@ class Categorie extends CommonObject * * @return int 1 if OK, -1 if KO */ - function del_type($obj, $type) + public function del_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -749,7 +749,7 @@ class Categorie extends CommonObject * @return array|int -1 if KO, array of instance of object if OK * @see containsObject */ - function getObjectsInCateg($type, $onlyids = 0) + public function getObjectsInCateg($type, $onlyids = 0) { $objs = array(); @@ -796,7 +796,7 @@ class Categorie extends CommonObject * @return int Number of occurrences * @see getObjectsInCateg */ - function containsObject($type, $object_id) + public function containsObject($type, $object_id) { $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id; @@ -821,7 +821,7 @@ class Categorie extends CommonObject * @param int $page Page number * @return array|int Array of categories, 0 if no cat, -1 on error */ - function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $conf; @@ -913,7 +913,7 @@ class Categorie extends CommonObject * * @return array|int <0 KO, array ok */ - function get_filles() + public function get_filles() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; @@ -974,7 +974,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Rebuilding the category tree as an array * Return an array of table('id','id_mere',...) trie selon arbre et avec: @@ -990,7 +990,7 @@ class Categorie extends CommonObject * * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ - function get_full_arbo($type, $markafterid = 0) + public function get_full_arbo($type, $markafterid = 0) { // phpcs:enable global $conf, $langs; @@ -1068,7 +1068,7 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel * @@ -1076,8 +1076,8 @@ class Categorie extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 1000) - { + public function build_path_from_id_categ($id_categ, $protection = 1000) + { // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); @@ -1112,13 +1112,13 @@ class Categorie extends CommonObject return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display content of $this->cats * * @return void */ - function debug_cats() + public function debug_cats() { // phpcs:enable // Display $this->cats @@ -1135,7 +1135,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns all categories * @@ -1143,7 +1143,7 @@ class Categorie extends CommonObject * @param boolean $parent Just parent categories if true * @return array|int Table of Object Category, -1 on error */ - function get_all_categories($type = null, $parent = false) + public function get_all_categories($type = null, $parent = false) { // phpcs:enable if (! is_numeric($type)) $type = $this->MAP_ID[$type]; @@ -1174,13 +1174,13 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * * @return integer 1 if already exist, 0 otherwise, -1 if error */ - function already_exists() + public function already_exists() { // phpcs:enable $type=$this->type; @@ -1225,20 +1225,20 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the top level categories (which are not girls) * * @param int $type Type of category (0, 1, ...) * @return array */ - function get_main_categories($type = null) + public function get_main_categories($type = null) { // phpcs:enable return $this->get_all_categories($type, true); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) @@ -1248,7 +1248,7 @@ class Categorie extends CommonObject * @param int $nocolor 0 * @return array */ - function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) + public function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) { // phpcs:enable $ways = array(); @@ -1297,13 +1297,13 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the list of parent categories * * @return int|array <0 KO, array OK */ - function get_meres() + public function get_meres() { // phpcs:enable $parents = array(); @@ -1333,14 +1333,14 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns in a table all possible paths to get to the category * starting with the major categories represented by Tables of categories * * @return array */ - function get_all_ways() + public function get_all_ways() { // phpcs:enable $ways = array(); @@ -1376,7 +1376,7 @@ class Categorie extends CommonObject * labels, 'id'= Get array of category IDs * @return array|int Array of category objects or < 0 if KO */ - function containing($id, $type, $mode = 'object') + public function containing($id, $type, $mode = 'object') { $cats = array(); @@ -1458,7 +1458,7 @@ class Categorie extends CommonObject * @param boolean $case Case sensitive (true/false) * @return array|int Array of category id, -1 if error */ - function rechercher($id, $nom, $type, $exact = false, $case = false) + public function rechercher($id, $nom, $type, $exact = false, $case = false) { // Deprecation warning if (is_numeric($type)) { @@ -1468,13 +1468,12 @@ class Categorie extends CommonObject $cats = array(); // For backward compatibility - if (is_numeric($type)) { + if (is_numeric($type)) { // We want to reverse lookup $map_type = array_flip($this->MAP_ID); $type = $map_type[$type]; -dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", - LOG_WARNING ); - } + dol_syslog(get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); + } // Generation requete recherche $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; @@ -1522,7 +1521,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * @param int $maxlength Max length of text * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) { global $langs; @@ -1557,7 +1556,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * @param string $file Nom du fichier uploade * @return void */ - function add_photo($sdir, $file) + public function add_photo($sdir, $file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1608,7 +1607,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * @param int $nbmax Nombre maximum de photos (0=pas de max) * @return array Tableau de photos */ - function liste_photos($dir, $nbmax = 0) + public function liste_photos($dir, $nbmax = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; @@ -1657,14 +1656,14 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo de la categorie et sa vignette * * @param string $file Path to file * @return void */ - function delete_photo($file) + public function delete_photo($file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1687,14 +1686,14 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * * @param string $file Path to file * @return void */ - function get_image_size($file) + public function get_image_size($file) { // phpcs:enable $infoImg = getimagesize($file); // Recuperation des infos de l'image @@ -1709,7 +1708,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * * @return int <0 if KO, >0 if OK */ - function setMultiLangs($user) + public function setMultiLangs($user) { global $langs; @@ -1790,7 +1789,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * * @return int <0 if KO, >0 if OK */ - function getMultiLangs() + public function getMultiLangs() { global $langs; @@ -1829,7 +1828,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } @@ -1842,7 +1841,7 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1856,20 +1855,20 @@ dol_syslog( get_class($this) . "::rechercher(): numeric types are deprecated, pl $this->type = self::TYPE_PRODUCT; } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_societe' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_societe' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); + } } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 3352927f7c9..4f8d1ac0301 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -46,7 +46,7 @@ class Shipments extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -60,10 +60,10 @@ class Shipments extends DolibarrApi * * @param int $id ID of shipment * @return array|mixed data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->expedition->lire) { throw new RestException(401); @@ -99,7 +99,7 @@ class Shipments extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -182,7 +182,7 @@ class Shipments extends DolibarrApi * @param array $request_data Request data * @return int ID of shipment */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expedition->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -315,7 +315,7 @@ class Shipments extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -376,7 +376,7 @@ class Shipments extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -412,7 +412,7 @@ class Shipments extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -448,7 +448,7 @@ class Shipments extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->shipment->supprimer) { throw new RestException(401); @@ -493,7 +493,7 @@ class Shipments extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -542,7 +542,8 @@ class Shipments extends DolibarrApi * @throws 404 * @throws 405 */ -/* function setinvoiced($id) + /* + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { @@ -562,7 +563,7 @@ class Shipments extends DolibarrApi } return $result; } -*/ + */ /** @@ -579,7 +580,7 @@ class Shipments extends DolibarrApi * @throws 405 */ /* - function createShipmentFromOrder($orderid) + public function createShipmentFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; @@ -615,7 +616,7 @@ class Shipments extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -654,7 +655,7 @@ class Shipments extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $shipment = array(); foreach (Shipments::$FIELDS as $field) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9c908d32a95..169511fe160 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -171,7 +171,7 @@ class Expedition extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -207,7 +207,7 @@ class Expedition extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("sendings"); @@ -264,7 +264,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si erreur, id expedition creee si ok */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $hookmanager; @@ -434,7 +434,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a expedition line * @@ -444,7 +444,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, line_id if OK */ - function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) + public function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) { //phpcs:enable $expeditionline = new ExpeditionLigne($this->db); @@ -462,7 +462,7 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create the detail (eat-by date) of the expedition line * @@ -470,7 +470,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function create_line_batch($line_ext, $array_options = 0) + public function create_line_batch($line_ext, $array_options = 0) { // phpcs:enable $error = 0; @@ -520,7 +520,7 @@ class Expedition extends CommonObject * @param string $ref_int Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; @@ -646,7 +646,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if OK, >0 if KO */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf, $langs; @@ -862,14 +862,14 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a delivery receipt from a shipment * * @param User $user User * @return int <0 if KO, >=0 if OK */ - function create_delivery($user) + public function create_delivery($user) { // phpcs:enable global $conf; @@ -908,7 +908,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline($entrepot_id, $id, $qty, $array_options = 0) + public function addline($entrepot_id, $id, $qty, $array_options = 0) { global $conf, $langs; @@ -971,7 +971,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a shipment line with batch record * @@ -979,7 +979,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline_batch($dbatch, $array_options = 0) + public function addline_batch($dbatch, $array_options = 0) { // phpcs:enable global $conf,$langs; @@ -1048,7 +1048,7 @@ class Expedition extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf; $error=0; @@ -1152,7 +1152,7 @@ class Expedition extends CommonObject * * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - function delete() + public function delete() { global $conf, $langs, $user; @@ -1360,13 +1360,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return int >0 if OK, Otherwise if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable global $conf, $mysoc; @@ -1548,7 +1548,7 @@ class Expedition extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($user, $lineid) + public function deleteline($user, $lineid) { global $user; @@ -1593,7 +1593,7 @@ class Expedition extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $langs; @@ -1643,12 +1643,12 @@ class Expedition extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1656,7 +1656,7 @@ class Expedition extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1700,7 +1700,7 @@ class Expedition extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -1772,7 +1772,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -1780,7 +1780,7 @@ class Expedition extends CommonObject * @param timestamp $date_livraison Date de livraison * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if ($user->rights->expedition->creer) @@ -1808,13 +1808,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * * @return void */ - function fetch_delivery_methods() + public function fetch_delivery_methods() { // phpcs:enable global $langs; @@ -1836,14 +1836,14 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch all deliveries method and return an array. Load array this->listmeths. * * @param id $id only this carrier, all if none * @return void */ - function list_delivery_methods($id = '') + public function list_delivery_methods($id = '') { // phpcs:enable global $langs; @@ -1872,7 +1872,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update/create delivery method. * @@ -1880,7 +1880,7 @@ class Expedition extends CommonObject * * @return void */ - function update_delivery_method($id = '') + public function update_delivery_method($id = '') { // phpcs:enable if ($id=='') @@ -1902,7 +1902,7 @@ class Expedition extends CommonObject if ($resql < 0) dol_print_error($this->db, ''); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate delivery method. * @@ -1910,7 +1910,7 @@ class Expedition extends CommonObject * * @return void */ - function activ_delivery_method($id) + public function activ_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; @@ -1919,7 +1919,7 @@ class Expedition extends CommonObject $resql = $this->db->query($sql); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * DesActivate delivery method. * @@ -1927,7 +1927,7 @@ class Expedition extends CommonObject * * @return void */ - function disable_delivery_method($id) + public function disable_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; @@ -1943,7 +1943,7 @@ class Expedition extends CommonObject * @param string $value Value * @return void */ - function getUrlTrackingStatus($value = '') + public function getUrlTrackingStatus($value = '') { if (! empty($this->shipping_method_id)) { @@ -1977,7 +1977,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, >0 if OK */ - function setClosed() + public function setClosed() { global $conf,$langs,$user; @@ -2123,13 +2123,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * * @return int <0 if ko, >0 if ok */ - function set_billed() + public function set_billed() { // phpcs:enable global $user; @@ -2174,7 +2174,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, 0 if already open, >0 if OK */ - function reOpen() + public function reOpen() { global $conf,$langs,$user; @@ -2273,14 +2273,13 @@ class Expedition extends CommonObject } } - if (! $error) - { + if (! $error) { // Call trigger $result=$this->call_trigger('SHIPPING_REOPEN', $user); if ($result < 0) { $error++; } - } + } } else { $error++; $this->errors[]=$this->db->lasterror(); @@ -2510,7 +2509,7 @@ class ExpeditionLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -2521,7 +2520,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; @@ -2556,7 +2555,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, line id >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -2638,7 +2637,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int >0 if OK, <0 if KO */ - function delete($user = null, $notrigger = 0) + public function delete($user = null, $notrigger = 0) { global $conf; @@ -2715,7 +2714,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 1 = disable triggers * @return int < 0 if KO, > 0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf; diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index e15e766c439..1cc0f277af6 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -35,21 +35,21 @@ class ExpeditionLineBatch extends CommonObject private static $_table_element='expeditiondet_batch'; //!< Name of table without prefix where object is stored - var $sellby; - var $eatby; - var $batch; - var $qty; - var $dluo_qty; // deprecated, use qty - var $entrepot_id; - var $fk_origin_stock; - var $fk_expeditiondet; + public $sellby; + public $eatby; + public $batch; + public $qty; + public $dluo_qty; // deprecated, use qty + public $entrepot_id; + public $fk_origin_stock; + public $fk_expeditiondet; /** * Constructor * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -60,7 +60,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_stockdluo Rowid in product_batch table * @return int -1 if KO, 1 if OK */ - function fetchFromStock($id_stockdluo) + public function fetchFromStock($id_stockdluo) { $sql = "SELECT"; $sql.= " pb.batch,"; @@ -104,7 +104,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_line_expdet rowid of expedtiondet record * @return int <0 if KO, Id of record (>0) if OK */ - function create($id_line_expdet) + public function create($id_line_expdet) { $error = 0; @@ -155,7 +155,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ - static function deletefromexp($db, $id_expedition) + public static function deletefromexp($db, $id_expedition) { $id_expedition = (int) $id_expedition; @@ -181,7 +181,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $fk_product If provided, load also detailed information of lot * @return int|array -1 if KO, array of ExpeditionLineBatch if OK */ - static function fetchAll($db, $id_line_expdet, $fk_product = 0) + public static function fetchAll($db, $id_line_expdet, $fk_product = 0) { $sql="SELECT"; $sql.= " eb.rowid,"; diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index e1bb3c0b219..d6ac5e2242a 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class ExpeditionStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class ExpeditionStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -88,7 +88,7 @@ class ExpeditionStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -110,7 +110,7 @@ class ExpeditionStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -129,7 +129,7 @@ class ExpeditionStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c0e0b485d71..c95bcdcb8f4 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -44,7 +44,7 @@ class Products extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -68,14 +68,14 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) + public function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) { if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) { throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } $id = (empty($id)?0:$id); - + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } @@ -84,7 +84,7 @@ class Products extends DolibarrApi if(! $result ) { throw new RestException(404, 'Product not found'); } - + if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -110,7 +110,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects */ - function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') { global $db, $conf; @@ -185,7 +185,7 @@ class Products extends DolibarrApi * @param array $request_data Request data * @return int ID of product */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -215,7 +215,7 @@ class Products extends DolibarrApi * @throws 401 * @throws 404 */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { global $conf; @@ -300,7 +300,7 @@ class Products extends DolibarrApi * @param int $id Product ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); @@ -335,7 +335,7 @@ class Products extends DolibarrApi * * @url GET {id}/categories */ - function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -365,7 +365,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_segment */ - function getCustomerPricesPerSegment($id) + public function getCustomerPricesPerSegment($id) { global $conf; @@ -387,13 +387,13 @@ class Products extends DolibarrApi } return array( - 'multiprices'=>$this->product->multiprices, - 'multiprices_inc_tax'=>$this->product->multiprices_ttc, - 'multiprices_min'=>$this->product->multiprices_min, - 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, - 'multiprices_vat'=>$this->product->multiprices_tva_tx, - 'multiprices_base_type'=>$this->product->multiprices_base_type, - //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code + 'multiprices'=>$this->product->multiprices, + 'multiprices_inc_tax'=>$this->product->multiprices_ttc, + 'multiprices_min'=>$this->product->multiprices_min, + 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, + 'multiprices_vat'=>$this->product->multiprices_tva_tx, + 'multiprices_base_type'=>$this->product->multiprices_base_type, + //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code ); } @@ -406,7 +406,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_customer */ - function getCustomerPricesPerCustomer($id) + public function getCustomerPricesPerCustomer($id) { global $conf; @@ -440,7 +440,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_quantity */ - function getCustomerPricesPerQuantity($id) + public function getCustomerPricesPerQuantity($id) { global $conf; @@ -474,7 +474,7 @@ class Products extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -502,7 +502,7 @@ class Products extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $product = array(); foreach (Products::$FIELDS as $field) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 93d239cc207..b19ec65e43f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -69,7 +69,7 @@ class FormProduct * @param array $exclude warehouses ids to exclude * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') + public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') { global $conf, $langs; @@ -210,7 +210,7 @@ class FormProduct * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @return string HTML select */ - function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) { global $conf,$langs,$user; @@ -255,7 +255,7 @@ class FormProduct * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) + public function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -291,7 +291,7 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return void */ - function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); @@ -308,7 +308,7 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return string */ - function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable global $langs, $conf, $mysoc, $db; @@ -365,7 +365,7 @@ class FormProduct * * @return string HTML select */ - function selectLotStock($selected = '', $htmlname = 'batch_id', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $empty_label = '', $forcecombo = 0, $events = array(), $morecss = 'minwidth200') + public function selectLotStock($selected = '', $htmlname = 'batch_id', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $empty_label = '', $forcecombo = 0, $events = array(), $morecss = 'minwidth200') { global $langs; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3a10377e8a3..9ef3ba450cf 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -344,20 +344,29 @@ class Product extends CommonObject public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), - //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), - //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + 'rowid' => array( + 'type'=>'integer', + 'label'=>'TechnicalID', + 'enabled'=>1, + 'visible'=>-2, + 'notnull'=>1, + 'index'=>1, + 'position'=>1, + 'comment'=>'Id', + ), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); /** @@ -383,7 +392,7 @@ class Product extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->canvas = ''; @@ -394,7 +403,7 @@ class Product extends CommonObject * * @return int >1 if OK, <=0 if KO */ - function check() + public function check() { $this->ref = dol_sanitizeFileName(stripslashes($this->ref)); @@ -423,7 +432,7 @@ class Product extends CommonObject * @param int $notrigger Disable triggers * @return int Id of product/service if OK, < 0 if KO */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -436,32 +445,41 @@ class Product extends CommonObject $this->price=price2num($this->price); $this->price_min_ttc=price2num($this->price_min_ttc); $this->price_min=price2num($this->price_min); - if (empty($this->tva_tx)) { $this->tva_tx = 0; + if (empty($this->tva_tx)) { + $this->tva_tx = 0; } - if (empty($this->tva_npr)) { $this->tva_npr = 0; + if (empty($this->tva_npr)) { + $this->tva_npr = 0; } //Local taxes - if (empty($this->localtax1_tx)) { $this->localtax1_tx = 0; + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; } - if (empty($this->localtax2_tx)) { $this->localtax2_tx = 0; + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; } - if (empty($this->localtax1_type)) { $this->localtax1_type = '0'; + if (empty($this->localtax1_type)) { + $this->localtax1_type = '0'; } - if (empty($this->localtax2_type)) { $this->localtax2_type = '0'; + if (empty($this->localtax2_type)) { + $this->localtax2_type = '0'; } - - if (empty($this->price)) { $this->price = 0; + if (empty($this->price)) { + $this->price = 0; } - if (empty($this->price_min)) { $this->price_min = 0; + if (empty($this->price_min)) { + $this->price_min = 0; } - // Price by quantity - if (empty($this->price_by_qty)) { $this->price_by_qty = 0; + if (empty($this->price_by_qty)) { + $this->price_by_qty = 0; } - if (empty($this->status)) { $this->status = 0; + if (empty($this->status)) { + $this->status = 0; } - if (empty($this->status_buy)) { $this->status_buy = 0; + if (empty($this->status_buy)) { + $this->status_buy = 0; } $price_ht=0; @@ -608,7 +626,7 @@ class Product extends CommonObject $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product"); if ($id > 0) { - $this->id = $id; + $this->id = $id; $this->price = $price_ht; $this->price_ttc = $price_ttc; $this->price_min = $price_min_ht; @@ -622,8 +640,8 @@ class Product extends CommonObject } else { - $error++; - $this->error=$this->db->lasterror(); + $error++; + $this->error=$this->db->lasterror(); } } else @@ -685,7 +703,7 @@ class Product extends CommonObject * * @return int 0 if OK, <0 if KO */ - function verify() + public function verify() { $this->errors=array(); @@ -716,7 +734,7 @@ class Product extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check barcode * @@ -727,7 +745,7 @@ class Product extends CommonObject * -2 ErrorBarCodeRequired * -3 ErrorBarCodeAlreadyUsed */ - function check_barcode($valuetotest, $typefortest) + public function check_barcode($valuetotest, $typefortest) { // phpcs:enable global $conf; @@ -764,7 +782,7 @@ class Product extends CommonObject * @param string $action Current action for hookmanager ('add' or 'update') * @return int 1 if OK, -1 if ref already exists, -2 if other error */ - function update($id, $user, $notrigger = false, $action = 'update') + public function update($id, $user, $notrigger = false, $action = 'update') { global $langs, $conf, $hookmanager; @@ -806,24 +824,33 @@ class Product extends CommonObject $this->surface_units = trim($this->surface_units); $this->volume = price2num($this->volume); $this->volume_units = trim($this->volume_units); - if (empty($this->tva_tx)) { $this->tva_tx = 0; + if (empty($this->tva_tx)) { + $this->tva_tx = 0; } - if (empty($this->tva_npr)) { $this->tva_npr = 0; + if (empty($this->tva_npr)) { + $this->tva_npr = 0; } - if (empty($this->localtax1_tx)) { $this->localtax1_tx = 0; + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; } - if (empty($this->localtax2_tx)) { $this->localtax2_tx = 0; + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; } - if (empty($this->localtax1_type)) { $this->localtax1_type = '0'; + if (empty($this->localtax1_type)) { + $this->localtax1_type = '0'; } - if (empty($this->localtax2_type)) { $this->localtax2_type = '0'; + if (empty($this->localtax2_type)) { + $this->localtax2_type = '0'; } - if (empty($this->status)) { $this->status = 0; + if (empty($this->status)) { + $this->status = 0; } - if (empty($this->status_buy)) { $this->status_buy = 0; + if (empty($this->status_buy)) { + $this->status_buy = 0; } - if (empty($this->country_id)) { $this->country_id = 0; + if (empty($this->country_id)) { + $this->country_id = 0; } // Barcode value @@ -1056,7 +1083,7 @@ class Product extends CommonObject * @param int $notrigger Do not execute trigger * @return int < 0 if KO, 0 = Not possible, > 0 if OK */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { // Deprecation warning if ($id > 0) { @@ -1224,7 +1251,7 @@ class Product extends CommonObject * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - function setMultiLangs($user) + public function setMultiLangs($user) { global $conf, $langs; @@ -1333,7 +1360,7 @@ class Product extends CommonObject * * @return int <0 if KO, >0 if OK */ - function delMultiLangs($langtodelete, $user) + public function delMultiLangs($langtodelete, $user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; $sql.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; @@ -1422,7 +1449,7 @@ class Product extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getMultiLangs() + public function getMultiLangs() { global $langs; @@ -1458,7 +1485,7 @@ class Product extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert a track that we changed a customer price * @@ -1466,7 +1493,7 @@ class Product extends CommonObject * @param int $level price level to change * @return int <0 if KO, >0 if OK */ - function _log_price($user, $level = 0) + private function _log_price($user, $level = 0) { // phpcs:enable global $conf; @@ -1498,7 +1525,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a price line * @@ -1506,7 +1533,7 @@ class Product extends CommonObject * @param int $rowid Line id to delete * @return int <0 if KO, >0 if OK */ - function log_price_delete($user, $rowid) + public function log_price_delete($user, $rowid) { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; @@ -1536,7 +1563,7 @@ class Product extends CommonObject * @return array Array of price information * @see get_buyprice() */ - function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) + public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) { global $conf, $db; @@ -1634,7 +1661,7 @@ class Product extends CommonObject return array('pu_ht'=>$pu_ht, 'pu_ttc'=>$pu_ttc, 'price_min'=>$price_min, 'price_base_type'=>$price_base_type, 'tva_tx'=>$tva_tx, 'tva_npr'=>$tva_npr); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read price used by a provider. * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. @@ -1648,7 +1675,7 @@ class Product extends CommonObject * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) * @see getSellPrice() */ - function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0) + public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0) { // phpcs:enable global $conf; @@ -1798,7 +1825,7 @@ class Product extends CommonObject * @param string $newdefaultvatcode Default vat code * @return int <0 if KO, >0 if OK */ - function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '') + public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '') { global $conf,$langs; @@ -1961,7 +1988,7 @@ class Product extends CommonObject * @return int <0 if KO, >0 if OK * @deprecated Use Product::update instead */ - function setPriceExpression($expression_id) + public function setPriceExpression($expression_id) { global $user; @@ -1980,7 +2007,7 @@ class Product extends CommonObject * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0) + public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -2004,13 +2031,16 @@ class Product extends CommonObject $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; $sql.= " fk_price_expression, price_autogen"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - if ($id) { $sql.= " WHERE rowid = ".$this->db->escape($id); - } else - { + if ($id) { + $sql.= " WHERE rowid = ".$this->db->escape($id); + } else { $sql.= " WHERE entity IN (".getEntity($this->element).")"; - if ($ref) { $sql.= " AND ref = '".$this->db->escape($ref)."'"; - } elseif ($ref_ext) { $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; - } elseif ($barcode) { $sql.= " AND barcode = '".$this->db->escape($barcode)."'"; + if ($ref) { + $sql.= " AND ref = '".$this->db->escape($ref)."'"; + } elseif ($ref_ext) { + $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; + } elseif ($barcode) { + $sql.= " AND barcode = '".$this->db->escape($barcode)."'"; } } @@ -2019,7 +2049,7 @@ class Product extends CommonObject if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; $this->label = $obj->label; @@ -2202,7 +2232,7 @@ class Product extends CommonObject $resultat=array(); $resql = $this->db->query($sql); if ($resql) { - $ii=0; + $ii=0; while ($result= $this->db->fetch_array($resql)) { $resultat[$ii]=array(); $resultat[$ii]["rowid"]=$result["rowid"]; @@ -2214,7 +2244,7 @@ class Product extends CommonObject $resultat[$ii]["price_base_type"]= $result["price_base_type"]; $ii++; } - $this->prices_by_qty_list[0]=$resultat; + $this->prices_by_qty_list[0]=$resultat; } else { @@ -2259,24 +2289,24 @@ class Product extends CommonObject $this->prices_by_qty_id[$i]=$result["rowid"]; // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[$i] == 1) { - $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; - $sql.= " ORDER BY quantity ASC"; - $resultat=array(); - $resql = $this->db->query($sql); + $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; + $sql.= " ORDER BY quantity ASC"; + $resultat=array(); + $resql = $this->db->query($sql); if ($resql) { $ii=0; while ($result= $this->db->fetch_array($resql)) { - $resultat[$ii]=array(); - $resultat[$ii]["rowid"]=$result["rowid"]; - $resultat[$ii]["price"]= $result["price"]; - $resultat[$ii]["unitprice"]= $result["unitprice"]; - $resultat[$ii]["quantity"]= $result["quantity"]; - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; - $resultat[$ii]["remise"]= $result["remise"]; // deprecated - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; - $ii++; + $resultat[$ii]=array(); + $resultat[$ii]["rowid"]=$result["rowid"]; + $resultat[$ii]["price"]= $result["price"]; + $resultat[$ii]["unitprice"]= $result["unitprice"]; + $resultat[$ii]["quantity"]= $result["quantity"]; + $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $resultat[$ii]["remise"]= $result["remise"]; // deprecated + $resultat[$ii]["price_base_type"]= $result["price_base_type"]; + $ii++; } $this->prices_by_qty_list[$i]=$resultat; } @@ -2326,14 +2356,14 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats propale pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - function load_stats_propale($socid = 0) + public function load_stats_propale($socid = 0) { // phpcs:enable global $conf; @@ -2373,14 +2403,14 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats propale pour le produit/service * * @param int $socid Id thirdparty * @return array Tableau des stats */ - function load_stats_proposal_supplier($socid = 0) + public function load_stats_proposal_supplier($socid = 0) { // phpcs:enable global $conf; @@ -2420,7 +2450,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats commande client pour le produit/service * @@ -2429,7 +2459,7 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Array of stats (nb=nb of order, qty=qty ordered) */ - function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable global $conf,$user; @@ -2515,7 +2545,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats commande fournisseur pour le produit/service * @@ -2524,7 +2554,7 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable global $conf,$user; @@ -2563,7 +2593,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats expedition client pour le produit/service * @@ -2572,7 +2602,7 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable global $conf,$user; @@ -2615,7 +2645,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats réception fournisseur pour le produit/service * @@ -2624,7 +2654,7 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable global $conf,$user; @@ -2663,14 +2693,14 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats contrat pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - function load_stats_contrat($socid = 0) + public function load_stats_contrat($socid = 0) { // phpcs:enable global $conf; @@ -2709,14 +2739,14 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats facture pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - function load_stats_facture($socid = 0) + public function load_stats_facture($socid = 0) { // phpcs:enable global $conf; @@ -2755,14 +2785,14 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats facture pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - function load_stats_facture_fournisseur($socid = 0) + public function load_stats_facture_fournisseur($socid = 0) { // phpcs:enable global $conf; @@ -2801,7 +2831,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return an array formated for showing graphs * @@ -2810,7 +2840,7 @@ class Product extends CommonObject * @param int $year Year (0=current year) * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function _get_stats($sql, $mode, $year = 0) + private function _get_stats($sql, $mode, $year = 0) { // phpcs:enable $resql = $this->db->query($sql); @@ -2865,7 +2895,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or customers invoices in which product is included * @@ -2876,7 +2906,7 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf; @@ -2910,7 +2940,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or supplier invoices in which product is included * @@ -2921,7 +2951,7 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf; @@ -2954,7 +2984,7 @@ class Product extends CommonObject return $this->_get_stats($sql, $mode, $year); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or proposals in which product is included * @@ -2965,7 +2995,7 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf; @@ -2998,7 +3028,7 @@ class Product extends CommonObject return $this->_get_stats($sql, $mode, $year); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or proposals in which product is included * @@ -3009,7 +3039,7 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf; @@ -3042,7 +3072,7 @@ class Product extends CommonObject return $this->_get_stats($sql, $mode, $year); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or orders in which product is included * @@ -3053,7 +3083,7 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf, $user; @@ -3085,7 +3115,7 @@ class Product extends CommonObject return $this->_get_stats($sql, $mode, $year); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of units or orders in which product is included * @@ -3096,13 +3126,14 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') + public function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; - if ($mode == 'bynumber') { $sql.= ", count(DISTINCT c.rowid)"; + if ($mode == 'bynumber') { + $sql.= ", count(DISTINCT c.rowid)"; } $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { $sql.=", ".MAIN_DB_PREFIX."product as p"; @@ -3128,7 +3159,7 @@ class Product extends CommonObject return $this->_get_stats($sql, $mode, $year); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link a product/service to a parent product/service * @@ -3138,7 +3169,7 @@ class Product extends CommonObject * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int < 0 if KO, > 0 if OK */ - function add_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) + public function add_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) { // phpcs:enable // Clean parameters @@ -3186,7 +3217,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Modify composed product * @@ -3196,7 +3227,7 @@ class Product extends CommonObject * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int < 0 if KO, > 0 if OK */ - function update_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) + public function update_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) { // phpcs:enable // Clean parameters @@ -3224,7 +3255,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retire le lien entre un sousproduit et un produit/service * @@ -3232,7 +3263,7 @@ class Product extends CommonObject * @param int $fk_child Id du produit a ne plus lie * @return int < 0 if KO, > 0 if OK */ - function del_sousproduit($fk_parent, $fk_child) + public function del_sousproduit($fk_parent, $fk_child) { // phpcs:enable if (! is_numeric($fk_parent)) { $fk_parent=0; @@ -3253,7 +3284,7 @@ class Product extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Verifie si c'est un sous-produit * @@ -3261,7 +3292,7 @@ class Product extends CommonObject * @param int $fk_child Id du produit lie * @return int < 0 si erreur, > 0 si ok */ - function is_sousproduit($fk_parent, $fk_child) + public function is_sousproduit($fk_parent, $fk_child) { // phpcs:enable $sql = "SELECT fk_product_pere, qty, incdec"; @@ -3293,7 +3324,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a supplier price for the product. * Note: Duplicate ref is accepted for different quantity only, or for different companies. @@ -3304,7 +3335,7 @@ class Product extends CommonObject * @param float $quantity Quantity minimum for price * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK */ - function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) + public function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { // phpcs:enable global $conf; @@ -3394,13 +3425,13 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des fournisseurs du produit/service * * @return array Tableau des id de fournisseur */ - function list_suppliers() + public function list_suppliers() { // phpcs:enable global $conf; @@ -3427,7 +3458,7 @@ class Product extends CommonObject return $list; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recopie les prix d'un produit/service sur un autre * @@ -3435,7 +3466,7 @@ class Product extends CommonObject * @param int $toId Id product target * @return int < 0 if KO, > 0 if OK */ - function clone_price($fromId, $toId) + public function clone_price($fromId, $toId) { // phpcs:enable $this->db->begin(); @@ -3456,7 +3487,7 @@ class Product extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clone links between products * @@ -3464,7 +3495,7 @@ class Product extends CommonObject * @param int $toId Product id * @return int <0 if KO, >0 if OK */ - function clone_associations($fromId, $toId) + public function clone_associations($fromId, $toId) { // phpcs:enable $this->db->begin(); @@ -3483,7 +3514,7 @@ class Product extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre * @@ -3491,7 +3522,7 @@ class Product extends CommonObject * @param int $toId Id produit cible * @return int < 0 si erreur, > 0 si ok */ - function clone_fournisseurs($fromId, $toId) + public function clone_fournisseurs($fromId, $toId) { // phpcs:enable $this->db->begin(); @@ -3531,7 +3562,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits * Define value of this->res @@ -3543,7 +3574,7 @@ class Product extends CommonObject * @param int $id_parent Id parent * @return void */ - function fetch_prod_arbo($prod, $compl_path = "", $multiply = 1, $level = 1, $id_parent = 0) + public function fetch_prod_arbo($prod, $compl_path = "", $multiply = 1, $level = 1, $id_parent = 0) { // phpcs:enable global $conf,$langs; @@ -3592,7 +3623,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the tree of subproducts into an array * this->sousprods is loaded by this->get_sousproduits_arbo() @@ -3600,7 +3631,7 @@ class Product extends CommonObject * @param int $multiply Because each sublevel must be multiplicated by parent nb * @return array $this->res */ - function get_arbo_each_prod($multiply = 1) + public function get_arbo_each_prod($multiply = 1) { // phpcs:enable $this->res = array(); @@ -3791,14 +3822,14 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tree of all subproducts for product. Tree contains id, name and quantity. * Set this->sousprods * * @return void */ - function get_sousproduits_arbo() + public function get_sousproduits_arbo() { // phpcs:enable $parent=array(); @@ -4010,7 +4041,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a given status * @@ -4019,7 +4050,7 @@ class Product extends CommonObject * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" * @return string Label of status */ - function LibStatut($status, $mode = 0, $type = 0) + public function LibStatut($status, $mode = 0, $type = 0) { // phpcs:enable global $conf, $langs; @@ -4051,38 +4082,52 @@ class Product extends CommonObject } } if ($mode == 0) { - if ($status == 0) { return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - } elseif ($status == 1) { return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + if ($status == 0) { + return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); + } elseif ($status == 1) { + return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } } elseif ($mode == 1) { - if ($status == 0) { return ($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - } elseif ($status == 1) { return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); + if ($status == 0) { + return ($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); + } elseif ($status == 1) { + return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); } } elseif ($mode == 2) { - if ($status == 0) { return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - } elseif ($status == 1) { return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + if ($status == 0) { + return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); + } elseif ($status == 1) { + return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } } elseif ($mode == 3) { - if ($status == 0) { return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); + if ($status == 0) { + return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); + } elseif ($status == 1) { + return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); } } elseif ($mode == 4) { - if ($status == 0) { return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - } elseif ($status == 1) { return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); + if ($status == 0) { + return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); + } elseif ($status == 1) { + return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); } } elseif ($mode == 5) { - if ($status == 0) { return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); + if ($status == 0) { + return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); + } elseif ($status == 1) { + return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); } } elseif ($mode == 6) { - if ($status == 0) { return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); + if ($status == 0) { + return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); + } elseif ($status == 1) { + return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); } } return $langs->trans('Unknown'); @@ -4094,7 +4139,7 @@ class Product extends CommonObject * * @return string Libelle */ - function getLibFinished() + public function getLibFinished() { global $langs; $langs->load('products'); @@ -4107,7 +4152,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adjust stock in a warehouse for product * @@ -4122,7 +4167,7 @@ class Product extends CommonObject * @param int $origin_id Origin id of element * @return int <0 if KO, >0 if OK */ - function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null) + public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null) { // phpcs:enable if ($id_entrepot) { @@ -4152,7 +4197,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adjust stock in a warehouse for product with batch number * @@ -4170,7 +4215,7 @@ class Product extends CommonObject * @param int $origin_id Origin id of element * @return int <0 if KO, >0 if OK */ - function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null) + public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null) { // phpcs:enable if ($id_entrepot) { @@ -4200,7 +4245,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) * This function need a lot of load. If you use it on list, use a cache to execute it once for each product id. @@ -4210,7 +4255,7 @@ class Product extends CommonObject * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock(), loadBatchInfo() */ - function load_stock($option = '') + public function load_stock($option = '') { // phpcs:enable global $conf; @@ -4274,7 +4319,7 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load value ->stock_theorique of a product. Property this->id must be defined. * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. @@ -4282,7 +4327,7 @@ class Product extends CommonObject * @return int < 0 if KO, > 0 if OK * @see load_stock(), loadBatchInfo() */ - function load_virtual_stock() + public function load_virtual_stock() { // phpcs:enable global $conf, $hookmanager, $action; @@ -4360,7 +4405,7 @@ class Product extends CommonObject * @return array Array with record into product_batch * @see load_stock(), load_virtual_stock() */ - function loadBatchInfo($batch) + public function loadBatchInfo($batch) { $result=array(); @@ -4388,7 +4433,7 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Move an uploaded file described into $file array into target directory $sdir. * @@ -4396,7 +4441,7 @@ class Product extends CommonObject * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) * @return int <0 if KO, >0 if OK */ - function add_photo($sdir, $file) + public function add_photo($sdir, $file) { // phpcs:enable global $conf; @@ -4406,8 +4451,10 @@ class Product extends CommonObject $result = 0; $dir = $sdir; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= '/'. get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id ."/photos"; - } else { $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref); + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + $dir .= '/'. get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id ."/photos"; + } else { + $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref); } dol_mkdir($dir); @@ -4426,19 +4473,21 @@ class Product extends CommonObject } } - if (is_numeric($result) && $result > 0) { return 1; - } else { return -1; + if (is_numeric($result) && $result > 0) { + return 1; + } else { + return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if at least one photo is available * * @param string $sdir Directory to scan * @return boolean True if at least one photo is available, False if not */ - function is_photo_available($sdir) + public function is_photo_available($sdir) { // phpcs:enable include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; @@ -4469,7 +4518,7 @@ class Product extends CommonObject return false; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne tableau de toutes les photos du produit * @@ -4477,7 +4526,7 @@ class Product extends CommonObject * @param int $nbmax Nombre maximum de photos (0=pas de max) * @return array Tableau de photos */ - function liste_photos($dir, $nbmax = 0) + public function liste_photos($dir, $nbmax = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -4526,14 +4575,14 @@ class Product extends CommonObject return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo du produit et sa vignette * * @param string $file Chemin de l'image * @return void */ - function delete_photo($file) + public function delete_photo($file) { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -4560,14 +4609,14 @@ class Product extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * * @param string $file Path to file * @return void */ - function get_image_size($file) + public function get_image_size($file) { // phpcs:enable $file_osencoded=dol_osencode($file); @@ -4576,13 +4625,13 @@ class Product extends CommonObject $this->imgHeight = $infoImg[1]; // Hauteur de l'image } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for the dashboard * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user, $hookmanager; @@ -4624,7 +4673,7 @@ class Product extends CommonObject * * @return boolean True if it's a product */ - function isProduct() + public function isProduct() { return ($this->type == Product::TYPE_PRODUCT ? true : false); } @@ -4634,12 +4683,12 @@ class Product extends CommonObject * * @return boolean True if it's a service */ - function isService() + public function isService() { return ($this->type == Product::TYPE_SERVICE ? true : false); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get a barcode from the module to generate barcode values. * Return value is stored into this->barcode @@ -4648,7 +4697,7 @@ class Product extends CommonObject * @param string $type Barcode type (ean, isbn, ...) * @return void */ - function get_barcode($object, $type = '') + public function get_barcode($object, $type = '') { // phpcs:enable global $conf; @@ -4679,7 +4728,7 @@ class Product extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf,$mysoc; @@ -4724,7 +4773,7 @@ class Product extends CommonObject * @param string $type Label type (long or short) * @return string|int <0 if ko, label if ok */ - function getLabelOfUnit($type = 'long') + public function getLabelOfUnit($type = 'long') { global $langs; @@ -4761,19 +4810,19 @@ class Product extends CommonObject * * @return boolean True if it's has */ - function hasbatch() + public function hasbatch() { return ($this->status_batch == 1 ? true : false); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return minimum product recommended price * * @return int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE */ - function min_recommended_price() + public function min_recommended_price() { // phpcs:enable global $conf; @@ -4950,7 +4999,7 @@ class Product extends CommonObject * @param int $id Id of thirdparty to load * @return void */ - function info($id) + public function info($id) { $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; $sql.= " p.fk_user_author, p.fk_user_modif"; diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 51afbe5edd1..6c115a258e6 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -57,7 +57,7 @@ class Productbatch extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -70,7 +70,7 @@ class Productbatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -142,7 +142,7 @@ class Productbatch extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -201,7 +201,7 @@ class Productbatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -262,17 +262,17 @@ class Productbatch extends CommonObject $this->db->commit(); return 1; } - } + } - /** - * Delete object in database - * - * @param User $user User that deletes + /** + * Delete object in database + * + * @param User $user User that deletes * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger = 0) - { + * @return int <0 if KO, >0 if OK + */ + public function delete($user, $notrigger = 0) + { global $conf, $langs; $error=0; @@ -330,7 +330,7 @@ class Productbatch extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -387,7 +387,7 @@ class Productbatch extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -421,7 +421,7 @@ class Productbatch extends CommonObject * @param string $batch_number batch number for object * @return int <0 if KO, >0 if OK */ - function find($fk_product_stock = 0, $eatby = '', $sellby = '', $batch_number = '') + public function find($fk_product_stock = 0, $eatby = '', $sellby = '', $batch_number = '') { global $langs; $where = array(); @@ -511,10 +511,9 @@ class Productbatch extends CommonObject dol_syslog("productbatch::findAll", LOG_DEBUG); $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i=0; + if ($resql) { + $num = $db->num_rows($resql); + $i=0; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -539,7 +538,7 @@ class Productbatch extends CommonObject } else { - $error="Error ".$db->lasterror(); + $error="Error ".$db->lasterror(); return -1; } } diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 511ce5c3138..f4c7c954156 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -54,7 +54,7 @@ class Productcustomerprice extends CommonObject /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; public $price; public $price_ttc; @@ -81,10 +81,10 @@ class Productcustomerprice extends CommonObject * * @param DoliDb $db handler */ - function __construct($db) + public function __construct($db) { - $this->db = $db; - } + $this->db = $db; + } /** * Create object into database @@ -94,7 +94,7 @@ class Productcustomerprice extends CommonObject * @param int $forceupdateaffiliate update price on each soc child * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0, $forceupdateaffiliate = 0) + public function create($user, $notrigger = 0, $forceupdateaffiliate = 0) { global $conf, $langs; @@ -258,7 +258,7 @@ class Productcustomerprice extends CommonObject * @param int $id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; @@ -332,7 +332,7 @@ class Productcustomerprice extends CommonObject * @param array $filter Filter for select * @return int <0 if KO, >0 if OK */ - function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array()) + public function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array()) { // phpcs:enable global $langs; @@ -447,7 +447,7 @@ class Productcustomerprice extends CommonObject * @param array $filter Filter for sql request * @return int <0 if KO, >0 if OK */ - function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array()) + public function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array()) { // phpcs:enable global $langs; @@ -553,7 +553,7 @@ class Productcustomerprice extends CommonObject * @param int $forceupdateaffiliate update price on each soc child * @return int <0 if KO, >0 if OK */ - function update($user = 0, $notrigger = 0, $forceupdateaffiliate = 0) + public function update($user = 0, $notrigger = 0, $forceupdateaffiliate = 0) { global $conf, $langs; @@ -751,7 +751,7 @@ class Productcustomerprice extends CommonObject * @param int $forceupdateaffiliate update price on each soc child * @return int <0 if KO, >0 if OK */ - function setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate) + public function setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate) { $error = 0; @@ -844,7 +844,7 @@ class Productcustomerprice extends CommonObject * @param int $notrigger triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -898,7 +898,7 @@ class Productcustomerprice extends CommonObject * @param int $fromid of object to clone * @return int id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user, $langs; @@ -950,7 +950,7 @@ class Productcustomerprice extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id = 0; @@ -1014,12 +1014,12 @@ class PriceByCustomerLine public $localtax1_tx; public $localtax2_tx; - /** - * @var int User ID - */ - public $fk_user; + /** + * @var int User ID + */ + public $fk_user; - public $import_key; - public $socname; - public $prodref; + public $import_key; + public $socname; + public $prodref; } diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index 9a62b9c1e6f..89512848c1b 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -41,15 +41,15 @@ class Propalmergepdfproduct extends CommonObject */ public $table_element='propal_merge_pdf_product'; - var $fk_product; - var $file_name; - var $fk_user_author; - var $fk_user_mod; - var $datec=''; - var $tms=''; - var $lang; + public $fk_product; + public $file_name; + public $fk_user_author; + public $fk_user_mod; + public $datec=''; + public $tms=''; + public $lang; - var $lines=array(); + public $lines=array(); @@ -59,7 +59,7 @@ class Propalmergepdfproduct extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -72,7 +72,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -167,7 +167,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs,$conf; @@ -228,7 +228,7 @@ class Propalmergepdfproduct extends CommonObject * @param string $lang Lang string code * @return int <0 if KO, >0 if OK */ - function fetch_by_product($product_id, $lang = '') + public function fetch_by_product($product_id, $lang = '') { // phpcs:enable global $langs,$conf; @@ -303,7 +303,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = 0, $notrigger = 0) + public function update($user = 0, $notrigger = 0) { global $conf, $langs; $error=0; @@ -379,7 +379,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -440,7 +440,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete_by_product($user, $product_id, $lang_id = '', $notrigger = 0) + public function delete_by_product($user, $product_id, $lang_id = '', $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -503,7 +503,7 @@ class Propalmergepdfproduct extends CommonObject * @param User $user User that deletes * @return int <0 if KO, >0 if OK */ - function delete_by_file($user) + public function delete_by_file($user) { // phpcs:enable global $conf, $langs; @@ -563,7 +563,7 @@ class Propalmergepdfproduct extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -620,7 +620,7 @@ class Propalmergepdfproduct extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -639,15 +639,15 @@ class Propalmergepdfproduct extends CommonObject */ class PropalmergepdfproductLine { - /** - * @var int ID - */ - public $id; - - /** + /** * @var int ID */ - public $fk_product; + public $id; + + /** + * @var int ID + */ + public $fk_product; public $file_name; public $lang; @@ -669,7 +669,7 @@ class PropalmergepdfproductLine /** * Constructor */ - function __construct() + public function __construct() { return 1; } diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index e8e3c4b0137..4c5971b8cc4 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -45,7 +45,7 @@ class StockMovements extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -63,7 +63,7 @@ class StockMovements extends DolibarrApi * @throws RestException */ /* - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->stock->lire) { throw new RestException(401); @@ -93,7 +93,7 @@ class StockMovements extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -174,7 +174,7 @@ class StockMovements extends DolibarrApi * @return int ID of stock movement */ //function post($product_id, $warehouse_id, $qty, $lot='', $movementcode='', $movementlabel='', $price=0) - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); @@ -213,7 +213,7 @@ class StockMovements extends DolibarrApi * @return int */ /* - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); @@ -246,7 +246,7 @@ class StockMovements extends DolibarrApi * @return array */ /* - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->stock->supprimer) { throw new RestException(401); @@ -280,7 +280,7 @@ class StockMovements extends DolibarrApi * @param MouvementStock $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -338,7 +338,7 @@ class StockMovements extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $stockmovement = array(); foreach (Warehouses::$FIELDS as $field) { diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 9dd34f18569..b245578da6b 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -43,7 +43,7 @@ class Warehouses extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -60,7 +60,7 @@ class Warehouses extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->stock->lire) { throw new RestException(401); @@ -92,7 +92,7 @@ class Warehouses extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -159,7 +159,7 @@ class Warehouses extends DolibarrApi * @param array $request_data Request data * @return int ID of warehouse */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); @@ -184,7 +184,7 @@ class Warehouses extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); @@ -216,7 +216,7 @@ class Warehouses extends DolibarrApi * @param int $id Warehouse ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->stock->supprimer) { throw new RestException(401); @@ -249,7 +249,7 @@ class Warehouses extends DolibarrApi * @param Entrepot $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -269,7 +269,7 @@ class Warehouses extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $warehouse = array(); foreach (Warehouses::$FIELDS as $field) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 81e8680034e..4713da6e901 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -100,7 +100,7 @@ class Entrepot extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; $this->db = $db; @@ -123,7 +123,7 @@ class Entrepot extends CommonObject * @param User $user Object user that create the warehouse * @return int >0 if OK, =<0 if KO */ - function create($user) + public function create($user) { global $conf; @@ -197,7 +197,7 @@ class Entrepot extends CommonObject * @param User $user User object * @return int >0 if OK, <0 if KO */ - function update($id, $user) + public function update($id, $user) { if (empty($id)) $id = $this->id; @@ -260,7 +260,7 @@ class Entrepot extends CommonObject * @param int $notrigger 1=No trigger * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { $this->db->begin(); @@ -331,7 +331,7 @@ class Entrepot extends CommonObject * @param string $ref Warehouse label * @return int >0 if OK, <0 if KO */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -403,7 +403,7 @@ class Entrepot extends CommonObject * @param int $id warehouse id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT e.rowid, e.datec, e.tms as datem, e.fk_user_author"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; @@ -451,7 +451,7 @@ class Entrepot extends CommonObject * @param int $status Status * @return array Array list of warehouses */ - function list_array($status = 1) + public function list_array($status = 1) { // phpcs:enable $liste = array(); @@ -483,7 +483,7 @@ class Entrepot extends CommonObject * * @return Array Array('nb'=>Nb, 'value'=>Value) */ - function nb_different_products() + public function nb_different_products() { // phpcs:enable $ret=array(); @@ -517,7 +517,7 @@ class Entrepot extends CommonObject * * @return Array Array('nb'=>Nb, 'value'=>Value) */ - function nb_products() + public function nb_products() { // phpcs:enable $ret=array(); @@ -552,7 +552,7 @@ class Entrepot extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } @@ -565,7 +565,7 @@ class Entrepot extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -616,7 +616,7 @@ class Entrepot extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $showfullpath = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $showfullpath = 0, $notooltip = 0) { global $conf, $langs; $langs->load("stocks"); @@ -663,7 +663,7 @@ class Entrepot extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf,$mysoc; @@ -690,7 +690,7 @@ class Entrepot extends CommonObject * * @return string String full path to current warehouse separated by " >> " */ - function get_full_arbo() + public function get_full_arbo() { // phpcs:enable global $user,$langs,$conf; @@ -734,7 +734,7 @@ class Entrepot extends CommonObject * @param integer[] $TChildWarehouses array which will contain all children (param by reference) * @return integer[] $TChildWarehouses array which will contain all children */ - function get_children_warehouses($id, &$TChildWarehouses) + public function get_children_warehouses($id, &$TChildWarehouses) { // phpcs:enable diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8a9baa6499d..19c5a1a0178 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -83,7 +83,7 @@ class MouvementStock extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -111,7 +111,7 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ - function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) { global $conf, $langs; @@ -188,7 +188,7 @@ class MouvementStock extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $i=0; if ($num > 0) { @@ -370,7 +370,7 @@ class MouvementStock extends CommonObject dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $mvid = $this->db->last_insert_id(MAIN_DB_PREFIX."stock_mouvement"); @@ -413,7 +413,7 @@ class MouvementStock extends CommonObject $error = -2; } } - + // Calculate new PMP. $newpmp=0; if (! $error) @@ -640,7 +640,7 @@ class MouvementStock extends CommonObject * @param string $inventorycode Inventory code * @return int <0 if KO, 0 if OK */ - function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '') + private function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '') { global $langs; @@ -712,7 +712,7 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch * @return int <0 if KO, >0 if OK */ - function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0) + public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0) { global $conf; @@ -735,7 +735,7 @@ class MouvementStock extends CommonObject * @param string $batch batch number * @return int <0 if KO, >0 if OK */ - function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '') + public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '') { return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, '', '', $eatby, $sellby, $batch); } @@ -749,7 +749,7 @@ class MouvementStock extends CommonObject * @deprecated A count($product->getChildsArbo($id,1)) is same. No reason to have this in this class. */ /* - function nbOfSubProducts($id) + public function nbOfSubProducts($id) { $nbSP=0; @@ -770,7 +770,7 @@ class MouvementStock extends CommonObject * @param timestamp $datebefore Date limit * @return int Number */ - function calculateBalanceForProductBefore($productidselected, $datebefore) + public function calculateBalanceForProductBefore($productidselected, $datebefore) { $nb=0; @@ -885,7 +885,7 @@ class MouvementStock extends CommonObject * @param int $origintype Type origin * @return string */ - function get_origin($fk_origin, $origintype) + public function get_origin($fk_origin, $origintype) { // phpcs:enable $origin=''; @@ -946,7 +946,7 @@ class MouvementStock extends CommonObject * * @return void */ - function setOrigin($origin_element, $origin_id) + public function setOrigin($origin_element, $origin_id) { if (!empty($origin_element) && $origin_id > 0) { @@ -973,7 +973,7 @@ class MouvementStock extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf,$mysoc; @@ -994,7 +994,7 @@ class MouvementStock extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; @@ -1027,7 +1027,7 @@ class MouvementStock extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($mode); } @@ -1039,7 +1039,7 @@ class MouvementStock extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($mode = 0) + public function LibStatut($mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index a47e627036c..8bb3a984634 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -485,7 +485,7 @@ class Productlot extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut(0, $mode); } @@ -498,7 +498,7 @@ class Productlot extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -521,7 +521,7 @@ class Productlot extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index d3e60d16016..36e302bf661 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -478,7 +478,7 @@ class ProductStockEntrepot extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -501,10 +501,10 @@ class ProductStockEntrepot extends CommonObject { $result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto != 2) $result.=' '; - } - $result.= $link . $this->ref . $linkend; - return $result; - } + } + $result.= $link . $this->ref . $linkend; + return $result; + } /** * Retourne le libelle du status d'un user (actif, inactif) @@ -512,12 +512,12 @@ class ProductStockEntrepot extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -525,7 +525,7 @@ class ProductStockEntrepot extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 882cda1cffd..532f46ccfe4 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -46,7 +46,7 @@ class Projects extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -64,7 +64,7 @@ class Projects extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); @@ -98,7 +98,7 @@ class Projects extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of project objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -180,7 +180,7 @@ class Projects extends DolibarrApi * @param array $request_data Request data * @return int ID of project */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401, "Insuffisant rights"); @@ -215,7 +215,7 @@ class Projects extends DolibarrApi * * @url GET {id}/tasks */ - function getLines($id, $includetimespent = 0) + public function getLines($id, $includetimespent = 0) { if (! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); @@ -258,7 +258,7 @@ class Projects extends DolibarrApi * * @return int */ - function getRoles($id, $userid = 0) + public function getRoles($id, $userid = 0) { global $db; @@ -303,7 +303,7 @@ class Projects extends DolibarrApi * @return int */ /* - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -366,7 +366,7 @@ class Projects extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -423,7 +423,7 @@ class Projects extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -459,7 +459,7 @@ class Projects extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->projet->supprimer) { throw new RestException(401); @@ -503,7 +503,7 @@ class Projects extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -540,7 +540,7 @@ class Projects extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -591,7 +591,7 @@ class Projects extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $object = array(); foreach (self::$FIELDS as $field) { diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index ad49146cfaa..40c3e78f7e6 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -46,10 +46,10 @@ class Tasks extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->task = new Task($this->db); } @@ -64,7 +64,7 @@ class Tasks extends DolibarrApi * * @throws RestException */ - function get($id, $includetimespent = 0) + public function get($id, $includetimespent = 0) { if(! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); @@ -106,7 +106,7 @@ class Tasks extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of project objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -188,7 +188,7 @@ class Tasks extends DolibarrApi * @param array $request_data Request data * @return int ID of project */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401, "Insuffisant rights"); @@ -222,7 +222,7 @@ class Tasks extends DolibarrApi * @url GET {id}/tasks */ /* - function getLines($id, $includetimespent=0) + public function getLines($id, $includetimespent=0) { if(! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); @@ -265,7 +265,7 @@ class Tasks extends DolibarrApi * * @return int */ - function getRoles($id, $userid = 0) + public function getRoles($id, $userid = 0) { global $db; @@ -308,7 +308,7 @@ class Tasks extends DolibarrApi * @return int */ /* - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -371,7 +371,7 @@ class Tasks extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -427,7 +427,7 @@ class Tasks extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -463,11 +463,11 @@ class Tasks extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->projet->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->task->fetch($id); if( ! $result ) { throw new RestException(404, 'Task not found'); @@ -505,7 +505,7 @@ class Tasks extends DolibarrApi * * @return array */ - function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '') + public function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '') { if( ! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); @@ -553,7 +553,7 @@ class Tasks extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -601,7 +601,7 @@ class Tasks extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $object = array(); foreach (self::$FIELDS as $field) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4544f047b6f..34a36e859dc 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -155,7 +155,7 @@ class Project extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -170,7 +170,7 @@ class Project extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, id of created project if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -299,11 +299,11 @@ class Project extends CommonObject * @param int $notrigger 1=Disable all triggers * @return int <=0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs, $conf; - $error=0; + $error=0; // Clean parameters $this->title = trim($this->title); @@ -413,7 +413,7 @@ class Project extends CommonObject $result = -2; } dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); - } + } } else { @@ -431,9 +431,9 @@ class Project extends CommonObject * @param string $ref Ref of project * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { - global $conf; + global $conf; if (empty($id) && empty($ref)) return -1; @@ -508,14 +508,14 @@ class Project extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of projects * * @param int $socid To filter on a particular third party * @return array List of projects */ - function liste_array($socid = '') + public function liste_array($socid = '') { // phpcs:enable global $conf; @@ -551,7 +551,7 @@ class Project extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of elements for type, linked to a project * @@ -563,7 +563,7 @@ class Project extends CommonObject * @param string $projectkey Equivalent key to fk_projet for actual type * @return mixed Array list of object ids linked to project, < 0 or string if error */ - function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet') + public function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet') { // phpcs:enable $elements = array(); @@ -595,7 +595,7 @@ class Project extends CommonObject else { $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$projectkey." IN (". $ids .") AND entity IN (".getEntity($type).")"; - } + } if ($dates > 0) { @@ -647,7 +647,7 @@ class Project extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if not possible, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $langs, $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -772,7 +772,7 @@ class Project extends CommonObject * @param User $user User * @return int <0 if KO, 1 if OK */ - function deleteTasks($user) + public function deleteTasks($user) { $countTasks = count($this->lines); $deleted = false; @@ -807,7 +807,7 @@ class Project extends CommonObject * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { global $langs, $conf; @@ -870,7 +870,7 @@ class Project extends CommonObject * @param User $user User that close project * @return int <0 if KO, 0 if already closed, >0 if OK */ - function setClose($user) + public function setClose($user) { global $langs, $conf; @@ -933,12 +933,12 @@ class Project extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi status label for a status * @@ -946,7 +946,7 @@ class Project extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -998,7 +998,7 @@ class Project extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user, $hookmanager; @@ -1089,7 +1089,7 @@ class Project extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user, $langs, $conf; @@ -1132,7 +1132,7 @@ class Project extends CommonObject * @param string $mode Type of permission we want to know: 'read', 'write' * @return int >0 if user has permission, <0 if user has no permission */ - function restrictedProjectArea($user, $mode = 'read') + public function restrictedProjectArea($user, $mode = 'read') { // To verify role of users $userAccess = 0; @@ -1185,7 +1185,7 @@ class Project extends CommonObject * @param string $filter additionnal filter on project (statut, ref, ...) * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 */ - function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') + public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') { $projects = array(); $temp = array(); @@ -1272,21 +1272,21 @@ class Project extends CommonObject } /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * @param bool $clone_contact Clone contact of project - * @param bool $clone_task Clone task of project - * @param bool $clone_project_file Clone file of project - * @param bool $clone_task_file Clone file of task (if task are copied) - * @param bool $clone_note Clone note of project - * @param bool $move_date Move task date on clone - * @param integer $notrigger No trigger flag - * @param int $newthirdpartyid New thirdparty id - * @return int New id of clone - */ - function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) - { + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @param bool $clone_contact Clone contact of project + * @param bool $clone_task Clone task of project + * @param bool $clone_project_file Clone file of project + * @param bool $clone_task_file Clone file of task (if task are copied) + * @param bool $clone_note Clone note of project + * @param bool $move_date Move task date on clone + * @param integer $notrigger No trigger flag + * @param int $newthirdpartyid New thirdparty id + * @return int New id of clone + */ + public function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) + { global $user,$langs,$conf; $error=0; @@ -1366,11 +1366,11 @@ class Project extends CommonObject $clone_project_id=$clone_project->id; //Note Update - if (!$clone_note) - { + if (!$clone_note) + { $clone_project->note_private=''; $clone_project->note_public=''; - } + } else { $this->db->begin(); @@ -1529,17 +1529,17 @@ class Project extends CommonObject dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); return -1; } - } + } - /** - * Shift project task date from current date to delta - * - * @param timestamp $old_project_dt_start old project start date - * @return int 1 if OK or < 0 if KO - */ - function shiftTaskDate($old_project_dt_start) - { + /** + * Shift project task date from current date to delta + * + * @param timestamp $old_project_dt_start old project start date + * @return int 1 if OK or < 0 if KO + */ + public function shiftTaskDate($old_project_dt_start) + { global $user,$langs,$conf; $error=0; @@ -1573,13 +1573,13 @@ class Project extends CommonObject //Calcultate new task start date with difference between old proj start date and origin task start date if (!empty($tasktoshiftdate->date_start)) { - $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); + $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); } //Calcultate new task end date with difference between origin proj end date and origin task end date if (!empty($tasktoshiftdate->date_end)) { - $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); + $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); } if ($to_update) @@ -1600,7 +1600,7 @@ class Project extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Associate element to a project * @@ -1608,7 +1608,7 @@ class Project extends CommonObject * @param int $elementSelectId Key-rowid of the line of the element to update * @return int 1 if OK or < 0 if KO */ - function update_element($tableName, $elementSelectId) + public function update_element($tableName, $elementSelectId) { // phpcs:enable $sql="UPDATE ".MAIN_DB_PREFIX.$tableName; @@ -1629,12 +1629,12 @@ class Project extends CommonObject if (!$resql) { $this->error=$this->db->lasterror(); return -1; - }else { + } else { return 1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Associate element to a project * @@ -1642,7 +1642,7 @@ class Project extends CommonObject * @param int $elementSelectId Key-rowid of the line of the element to update * @return int 1 if OK or < 0 if KO */ - function remove_element($tableName, $elementSelectId) + public function remove_element($tableName, $elementSelectId) { // phpcs:enable $sql="UPDATE ".MAIN_DB_PREFIX.$tableName; @@ -1710,7 +1710,7 @@ class Project extends CommonObject * @param int $userid Time spent by a particular user * @return int <0 if OK, >0 if KO */ - public function loadTimeSpent($datestart, $taskid = 0, $userid = 0) + public function loadTimeSpent($datestart, $taskid = 0, $userid = 0) { $error=0; @@ -1766,14 +1766,14 @@ class Project extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -1852,13 +1852,13 @@ class Project extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -1918,7 +1918,7 @@ class Project extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec as datec, tms as datem,'; $sql.= ' date_close as datecloture,'; @@ -2027,7 +2027,7 @@ class Project extends CommonObject * @param User $user Object user we want project allowed to * @return int >0 if OK, <0 if KO */ - function getLinesArray($user) + public function getLinesArray($user) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index bd324ba8b1d..b3920480729 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -24,25 +24,25 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class ProjectStats extends Stats { - private $project; - public $userid; - public $socid; - public $year; + private $project; + public $userid; + public $socid; + public $year; /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) - { - global $conf, $user; + public function __construct($db) + { + global $conf, $user; - $this->db = $db; + $this->db = $db; - require_once 'project.class.php'; - $this->project = new Project($this->db); - } + require_once 'project.class.php'; + $this->project = new Project($this->db); + } /** @@ -53,7 +53,7 @@ class ProjectStats extends Stats * @return array|int Array with value or -1 if error * @throws Exception */ - function getAllProjectByStatus($limit = 5) + public function getAllProjectByStatus($limit = 5) { global $conf, $user, $langs; @@ -118,7 +118,7 @@ class ProjectStats extends Stats * * @return array of values */ - function getAllByYear() + public function getAllByYear() { global $conf, $user, $langs; @@ -193,7 +193,7 @@ class ProjectStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -222,7 +222,7 @@ class ProjectStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -253,7 +253,7 @@ class ProjectStats extends Stats * @param int $wonlostfilter Add a filter on status won/lost * @return array Array of values */ - function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1) + public function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1) { global $conf,$user,$langs; @@ -346,7 +346,7 @@ class ProjectStats extends Stats * @param int $wonlostfilter Add a filter on status won/lost * @return array Array with amount by month */ - function getWeightedAmountByMonth($year, $wonlostfilter = 1) + public function getWeightedAmountByMonth($year, $wonlostfilter = 1) { global $user; @@ -375,7 +375,7 @@ class ProjectStats extends Stats * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) * @return array of values */ - function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) + public function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) { global $conf, $user, $langs; @@ -456,7 +456,7 @@ class ProjectStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getTransformRateByMonth($year, $format = 0) + public function getTransformRateByMonth($year, $format = 0) { global $user; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 82f8c9ba169..f0797f3f5b2 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -119,7 +119,7 @@ class Task extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -132,7 +132,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -231,7 +231,7 @@ class Task extends CommonObject * @param int $loadparentdata Also load parent data * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id, $ref = '', $loadparentdata = 0) + public function fetch($id, $ref = '', $loadparentdata = 0) { global $langs, $conf; @@ -333,7 +333,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -444,7 +444,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -567,7 +567,7 @@ class Task extends CommonObject * * @return int <0 if KO, 0 if no children, >0 if OK */ - function hasChildren() + public function hasChildren() { $error=0; $ret=0; @@ -601,7 +601,7 @@ class Task extends CommonObject * * @return int <0 if KO, 0 if no children, >0 if OK */ - function hasTimeSpent() + public function hasTimeSpent() { $error=0; $ret=0; @@ -643,7 +643,7 @@ class Task extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $mode = 'task', $addlabel = 0, $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'task', $addlabel = 0, $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -700,7 +700,7 @@ class Task extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -731,7 +731,7 @@ class Task extends CommonObject * @param string $filterontaskuser Filter on user assigned to task * @return array Array of tasks */ - function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0) + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0) { global $conf; @@ -890,7 +890,7 @@ class Task extends CommonObject * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') */ - function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', $taskid = 0, $filteronprojstatus = -1) + public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', $taskid = 0, $filteronprojstatus = -1) { $arrayroles = array(); @@ -967,7 +967,7 @@ class Task extends CommonObject * @param string $source Source * @return array Array of id of contacts */ - function getListContactId($source = 'internal') + public function getListContactId($source = 'internal') { $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); @@ -991,7 +991,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function addTimeSpent($user, $notrigger = 0) + public function addTimeSpent($user, $notrigger = 0) { global $conf,$langs; @@ -1096,7 +1096,7 @@ class Task extends CommonObject * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') * @return array Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') */ - function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') + public function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') { global $langs; @@ -1159,7 +1159,7 @@ class Task extends CommonObject * @param string $datee End date (ex 23:59:59) * @return array Array of info for task array('amount','nbseconds','nblinesnull') */ - function getSumOfAmount($fuser = '', $dates = '', $datee = '') + public function getSumOfAmount($fuser = '', $dates = '', $datee = '') { global $langs; @@ -1214,7 +1214,7 @@ class Task extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetchTimeSpent($id) + public function fetchTimeSpent($id) { global $langs; @@ -1268,7 +1268,7 @@ class Task extends CommonObject * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') * @return int <0 if KO, array of time spent if OK */ - function fetchAllTimeSpent(User $userobj, $morewherefilter = '') + public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') { global $langs; @@ -1358,7 +1358,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function updateTimeSpent($user, $notrigger = 0) + public function updateTimeSpent($user, $notrigger = 0) { global $conf,$langs; @@ -1443,7 +1443,7 @@ class Task extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delTimeSpent($user, $notrigger = 0) + public function delTimeSpent($user, $notrigger = 0) { global $conf, $langs; @@ -1505,20 +1505,20 @@ class Task extends CommonObject } } - /** Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * @param int $project_id Id of project to attach clone task - * @param int $parent_task_id Id of task to attach clone task - * @param bool $clone_change_dt recalculate date of task regarding new project start date - * @param bool $clone_affectation clone affectation of project - * @param bool $clone_time clone time of project - * @param bool $clone_file clone file of project - * @param bool $clone_note clone note of project - * @param bool $clone_prog clone progress of project - * @return int New id of clone - */ - function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) + /** Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @param int $project_id Id of project to attach clone task + * @param int $parent_task_id Id of task to attach clone task + * @param bool $clone_change_dt recalculate date of task regarding new project start date + * @param bool $clone_affectation clone affectation of project + * @param bool $clone_time clone time of project + * @param bool $clone_file clone file of project + * @param bool $clone_note clone note of project + * @param bool $clone_prog clone progress of project + * @return int New id of clone + */ + public function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { global $user,$langs,$conf; @@ -1745,20 +1745,20 @@ class Task extends CommonObject * @param integer $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->fk_statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return status label for an object + * Return status label for an object * - * @param int $statut Id statut - * @param integer $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label + * @param int $statut Id statut + * @param integer $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable // list of Statut of the task @@ -1869,14 +1869,14 @@ class Task extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -1944,13 +1944,13 @@ class Task extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index c71a2ea0746..ad080068f93 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -34,7 +34,7 @@ class TaskStats extends Stats * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -50,7 +50,7 @@ class TaskStats extends Stats * @return array|int Array with value or -1 if error * @throws Exception */ - function getAllTaskByStatus($limit = 5) + public function getAllTaskByStatus($limit = 5) { global $conf, $user, $langs; @@ -107,7 +107,7 @@ class TaskStats extends Stats * * @return array of values */ - function getAllByYear() + public function getAllByYear() { global $conf, $user, $langs; @@ -166,7 +166,7 @@ class TaskStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; From 461da700d5f1247979e256d44818c6c59a209c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 23:40:32 +0100 Subject: [PATCH 035/187] phpcs fix --- htdocs/datapolicy/class/datapolicy.class.php | 92 ++++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index b3cb0ce3cd9..b9ff3e8b6bd 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -219,68 +219,68 @@ Class DataPolicy */ function sendMailDataPolicyCompany($societe) { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; - $error = 0; + $error = 0; - $from = $user->getFullName($langs) . ' <' . $user->email . '>'; + $from = $user->getFullName($langs) . ' <' . $user->email . '>'; - $sendto = $societe->email; + $sendto = $societe->email; - $code= md5($societe->email); - if (!empty($societe->default_lang)) { - $l = $societe->default_lang; - } else { - $l = $langs->defaultlang; - } - $s = "DATAPOLICIESSUBJECT_" . $l; - $ma = "DATAPOLICIESCONTENT_" . $l; - $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; - $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; + $code= md5($societe->email); + if (!empty($societe->default_lang)) { + $l = $societe->default_lang; + } else { + $l = $langs->defaultlang; + } + $s = "DATAPOLICIESSUBJECT_" . $l; + $ma = "DATAPOLICIESCONTENT_" . $l; + $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; + $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; - $subject = $conf->global->$s; - $message = $conf->global->$ma; - $linka = $conf->global->$la; - $linkr = $conf->global->$lr; - $sendtocc = $sendtobcc = ''; - $filepath = $mimetype = $filename = array(); - $deliveryreceipt = 0; + $subject = $conf->global->$s; + $message = $conf->global->$ma; + $linka = $conf->global->$la; + $linkr = $conf->global->$lr; + $sendtocc = $sendtobcc = ''; + $filepath = $mimetype = $filename = array(); + $deliveryreceipt = 0; - $substitutionarray = array( + $substitutionarray = array( '__LINKACCEPT__' => ''.$linka.'', '__LINKREFUSED__' => ''.$linkr.'', - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + ); + $subject = make_substitutions($subject, $substitutionarray); + $message = make_substitutions($message, $substitutionarray); - $actiontypecode = 'AC_EMAIL'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; - if ($message) { - if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actiontypecode = 'AC_EMAIL'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; + if ($message) { + if ($sendtocc) { + $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg .= dol_concatdesc($actionmsg, $message); } - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); - if ($mailfile->error) { - $resultmasssend .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + if ($mailfile->error) { + $resultmasssend .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); - if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $societe->array_options['options_datapolicy_send'] = date('Y-m-d', time()); - $societe->update($societe->id); - } else { - dol_print_error($db); - } - } - setEventMessage($resultmasssend); + if (!$error) { + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $societe->array_options['options_datapolicy_send'] = date('Y-m-d', time()); + $societe->update($societe->id); + } else { + dol_print_error($db); + } + } + setEventMessage($resultmasssend); } /** From 041310c4ee06b391b30da88a455f28f0888022e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 23:47:00 +0100 Subject: [PATCH 036/187] wip --- htdocs/categories/class/categorie.class.php | 16 +++---- htdocs/don/class/don.class.php | 49 +++++++++++---------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f162bc68bba..27f74e23e21 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -580,7 +580,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link an object to the category * @@ -907,7 +907,7 @@ class Categorie extends CommonObject return $categories; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return childs of a category * @@ -1076,10 +1076,10 @@ class Categorie extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - public function build_path_from_id_categ($id_categ, $protection = 1000) + public function build_path_from_id_categ($id_categ, $protection = 1000) { // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (! empty($this->cats[$id_categ]['fullpath'])) { @@ -1109,8 +1109,8 @@ class Categorie extends CommonObject // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); - return; - } + return; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -1548,7 +1548,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * @@ -1599,7 +1599,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tableau de toutes les photos de la categorie * diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index f6c2ff1847c..872d8ad8b38 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART + * 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 @@ -103,7 +104,7 @@ class Don extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -115,12 +116,12 @@ class Don extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -128,7 +129,7 @@ class Don extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable if (empty($this->labelstatut) || empty($this->labelstatutshort)) @@ -198,7 +199,7 @@ class Don extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user,$langs; @@ -257,7 +258,7 @@ class Don extends CommonObject * @param int $minimum Minimum * @return int 0 if KO, >0 if OK */ - function check($minimum = 0) + public function check($minimum = 0) { global $langs; $langs->load('main'); @@ -350,7 +351,7 @@ class Don extends CommonObject * @return int <0 if KO, id of created donation if OK * TODO add numbering module for Ref */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -429,7 +430,7 @@ class Don extends CommonObject // End call triggers } } - else + else { $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); @@ -473,7 +474,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int >0 if OK, <0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs, $conf; @@ -564,7 +565,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if not possible, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $user, $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -639,7 +640,7 @@ class Don extends CommonObject * @param string $ref Ref of donation to load * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -727,12 +728,12 @@ class Don extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { return $this->valid_promesse($this->id, $user->id, $notrigger); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Validate a promise of donation * @@ -741,7 +742,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function valid_promesse($id, $userid, $notrigger = 0) + public function valid_promesse($id, $userid, $notrigger = 0) { // phpcs:enable global $langs, $user; @@ -784,7 +785,7 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the donation as paid, the donation was received * @@ -792,7 +793,7 @@ class Don extends CommonObject * @param int $modepayment mode of payment * @return int <0 if KO, >0 if OK */ - function set_paid($id, $modepayment = 0) + public function set_paid($id, $modepayment = 0) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; @@ -821,14 +822,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set donation to status cancelled * * @param int $id id of donation * @return int <0 if KO, >0 if OK */ - function set_cancel($id) + public function set_cancel($id) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$id; @@ -852,14 +853,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Sum of donations * * @param string $param 1=promesses de dons validees , 2=xxx, 3=encaisses * @return int Summ of donations */ - function sum_donations($param) + public function sum_donations($param) { // phpcs:enable global $conf; @@ -881,13 +882,13 @@ class Don extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -924,7 +925,7 @@ class Don extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $notooltip = 0) { global $langs; @@ -948,7 +949,7 @@ class Don extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT d.rowid, d.datec, d.fk_user_author, d.fk_user_valid,'; $sql.= ' d.tms'; From 42a13872183885f44c053a439a0cae9763d9a9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 00:56:48 +0100 Subject: [PATCH 037/187] wip --- .../class/accountancycategory.class.php | 28 +- .../class/accountancyexport.class.php | 26 +- .../class/accountancysystem.class.php | 12 +- .../class/accountingaccount.class.php | 62 +- .../class/accountingjournal.class.php | 40 +- htdocs/adherents/class/adherent.class.php | 88 +-- .../adherents/class/adherent_type.class.php | 70 +- .../adherents/class/adherentstats.class.php | 22 +- htdocs/blockedlog/class/authority.class.php | 22 +- htdocs/commande/class/api_orders.class.php | 48 +- htdocs/commande/class/commande.class.php | 272 ++++--- htdocs/commande/class/commandestats.class.php | 34 +- htdocs/contact/class/contact.class.php | 55 +- test/phpunit/AccountingAccountTest.php | 24 +- test/phpunit/ActionCommTest.php | 2 +- test/phpunit/AdherentTest.php | 2 +- test/phpunit/AdminLibTest.php | 2 +- test/phpunit/BankAccountTest.php | 2 +- test/phpunit/BonPrelevementTest.php | 2 +- test/phpunit/BuildDocTest.php | 2 +- test/phpunit/CMailFileTest.php | 2 +- test/phpunit/CategorieTest.php | 2 +- test/phpunit/ChargeSocialesTest.php | 192 ++--- test/phpunit/CodingPhpTest.php | 26 +- test/phpunit/CodingSqlTest.php | 2 +- test/phpunit/CommandeFournisseurTest.php | 2 +- test/phpunit/CommandeTest.php | 2 +- test/phpunit/CommonInvoiceTest.php | 2 +- test/phpunit/CommonObjectTest.php | 2 +- test/phpunit/CompanyBankAccountTest.php | 12 +- test/phpunit/CompanyLibTest.php | 2 +- test/phpunit/ContactTest.php | 10 +- test/phpunit/ContratTest.php | 172 ++--- test/phpunit/CoreTest.php | 2 +- test/phpunit/DateLibTest.php | 10 +- test/phpunit/DateLibTzFranceTest.php | 6 +- test/phpunit/DiscountTest.php | 4 +- test/phpunit/EntrepotTest.php | 6 +- test/phpunit/ExpenseReportTest.php | 2 +- test/phpunit/ExportTest.php | 4 +- test/phpunit/FactureFournisseurTest.php | 4 +- test/phpunit/FactureRecTest.php | 10 +- test/phpunit/FactureTest.php | 2 +- test/phpunit/FactureTestRounding.php | 8 +- test/phpunit/FichinterTest.php | 4 +- test/phpunit/FilesLibTest.php | 6 +- test/phpunit/FormAdminTest.php | 10 +- test/phpunit/Functions2LibTest.php | 2 +- test/phpunit/FunctionsLibTest.php | 662 +++++++++--------- test/phpunit/GetUrlLibTest.php | 194 ++--- test/phpunit/HolidayTest.php | 352 +++++----- test/phpunit/ImagesLibTest.php | 4 +- test/phpunit/ImportTest.php | 4 +- test/phpunit/JsonLibTest.php | 80 +-- test/phpunit/LangTest.php | 4 +- test/phpunit/LoanTest.php | 4 +- test/phpunit/MarginsLibTest.php | 12 +- test/phpunit/ModulesTest.php | 4 +- test/phpunit/MouvementStockTest.php | 4 +- test/phpunit/NumberingModulesTest.php | 6 +- test/phpunit/PaypalTest.php | 6 +- test/phpunit/PdfDocTest.php | 6 +- test/phpunit/PgsqlTest.php | 6 +- test/phpunit/PricesTest.php | 220 +++--- test/phpunit/ProductTest.php | 6 +- test/phpunit/ProjectTest.php | 12 +- test/phpunit/PropalTest.php | 12 +- test/phpunit/RestAPIDocumentTest.php | 4 +- test/phpunit/RestAPIUserTest.php | 2 +- test/phpunit/ScriptsTest.php | 12 +- test/phpunit/SecurityTest.php | 6 +- test/phpunit/SocieteTest.php | 2 +- test/phpunit/SupplierProposalTest.php | 6 +- test/phpunit/UserGroupTest.php | 2 +- test/phpunit/UserTest.php | 2 +- test/phpunit/UtilsTest.php | 4 +- test/phpunit/WebservicesInvoicesTest.php | 2 +- test/phpunit/WebservicesOrdersTest.php | 2 +- test/phpunit/WebservicesOtherTest.php | 2 +- test/phpunit/WebservicesProductsTest.php | 2 +- test/phpunit/WebservicesThirdpartyTest.php | 4 +- test/phpunit/WebservicesUserTest.php | 2 +- test/phpunit/XCalLibTest.php | 2 +- 83 files changed, 1487 insertions(+), 1490 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 010f452755d..73cccdfd721 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -129,7 +129,7 @@ class AccountancyCategory // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -142,7 +142,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -239,7 +239,7 @@ class AccountancyCategory // extends CommonObject * @param string $label Label * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $label = '') + public function fetch($id, $code = '', $label = '') { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -299,7 +299,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -379,7 +379,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -460,7 +460,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -509,7 +509,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -552,7 +552,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to add an accounting account in an accounting category @@ -617,7 +617,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -643,7 +643,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); @@ -651,12 +651,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return - 1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 775974edb6c..01f02a8a80a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2016-2018 Alexandre Spangaro * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz - * Copyright (C) 2017 Frédéric France + * Copyright (C) 2017-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -98,18 +98,18 @@ class AccountancyExport global $langs; return array ( - //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), - self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), - self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), - self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), - self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), - self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), - self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), - self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), - self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), - self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), - ); + //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), + self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), + self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), + self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), + self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), + self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), + self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), + self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), + self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), + self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + ); } /** diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 65852258867..53e824219c5 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -64,10 +64,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; - } + } /** @@ -77,7 +77,7 @@ class AccountancySystem * @param string $ref ref * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = 0, $ref = '') + public function fetch($rowid = 0, $ref = '') { global $conf; @@ -124,7 +124,7 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - function create($user) + public function create($user) { $now = dol_now(); @@ -151,6 +151,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index d889ef37195..f184d30699f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -138,13 +138,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { global $conf; $this->db = $db; $this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -154,7 +154,7 @@ class AccountingAccount extends CommonObject * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { global $conf; @@ -216,7 +216,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error = 0; @@ -317,7 +317,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -325,7 +325,7 @@ class AccountingAccount extends CommonObject * @param User $user Use making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { // Check parameters if (empty($this->pcg_type) || $this->pcg_type == '-1') @@ -368,7 +368,7 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - function checkUsage() + public function checkUsage() { global $langs; @@ -402,7 +402,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; @@ -453,9 +453,9 @@ class AccountingAccount extends CommonObject } else { return - 1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -466,8 +466,8 @@ class AccountingAccount extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -522,7 +522,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; - } + } /** * Information on record @@ -530,7 +530,7 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; @@ -562,14 +562,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account deactivated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_desactivate($id) + public function account_desactivate($id) { // phpcs:enable $result = $this->checkUsage(); @@ -597,14 +597,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_activate($id) + public function account_activate($id) { // phpcs:enable $this->db->begin(); @@ -615,15 +615,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return - 1; - } - } + } + } /** @@ -632,12 +632,12 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -645,7 +645,7 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -655,32 +655,32 @@ class AccountingAccount extends CommonObject { $prefix=''; if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index b4ef9781aa2..eb99badd5f3 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -74,10 +74,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { - $this->db = $db; - } + $this->db = $db; + } /** * Load an object from database @@ -86,7 +86,7 @@ class AccountingJournal extends CommonObject * @param string $journal_code Journal code * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = null, $journal_code = null) + public function fetch($rowid = null, $journal_code = null) { global $conf; @@ -146,7 +146,7 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; @@ -213,7 +213,7 @@ class AccountingJournal extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) { global $langs, $conf, $user; @@ -270,12 +270,12 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function getLibType($mode = 0) + public function getLibType($mode = 0) { return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -283,7 +283,7 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function LibType($nature, $mode = 0) + public function LibType($nature, $mode = 0) { // phpcs:enable global $langs; @@ -294,20 +294,20 @@ class AccountingJournal extends CommonObject { $prefix=''; if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } - if ($mode == 1) + elseif ($mode == 1) { if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 22429de9200..5c20e827bc2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -218,7 +218,7 @@ class Adherent extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = -1; @@ -229,7 +229,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function sending an email to the current member with the text supplied in parameter. * @@ -246,7 +246,7 @@ class Adherent extends CommonObject * @param string $moreinheader Add more html headers * @return int <0 if KO, >0 if OK */ - function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable global $conf,$langs; @@ -291,7 +291,7 @@ class Adherent extends CommonObject * @param string $text Text to make substitution to * @return string Value of input text string with substitutions done */ - function makeSubstitution($text) + public function makeSubstitution($text) { global $conf,$langs; @@ -358,7 +358,7 @@ class Adherent extends CommonObject * @param string $morphy Nature of the adherent (physical or moral) * @return string Label */ - function getmorphylib($morphy = '') + public function getmorphylib($morphy = '') { global $langs; if (! $morphy) { $morphy=$this->morphy; } @@ -374,7 +374,7 @@ class Adherent extends CommonObject * @param int $notrigger 1 ne declenche pas les triggers, 0 sinon * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; @@ -500,7 +500,7 @@ class Adherent extends CommonObject * @param string $action Current action for hookmanager * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') + public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') { global $conf, $langs, $hookmanager; @@ -752,7 +752,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update denormalized last subscription date. * This function is called when we delete a subscription for example. @@ -760,7 +760,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function update_end_date($user) + public function update_end_date($user) { // phpcs:enable $this->db->begin(); @@ -817,7 +817,7 @@ class Adherent extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=nothing to do, >0 if OK */ - function delete($rowid, $user, $notrigger = 0) + public function delete($rowid, $user, $notrigger = 0) { global $conf, $langs; @@ -927,7 +927,7 @@ class Adherent extends CommonObject * @param int $nosyncuser Do not synchronize linked user * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -1038,7 +1038,7 @@ class Adherent extends CommonObject * @param int $userid Id of user to link to * @return int 1=OK, -1=KO */ - function setUserId($userid) + public function setUserId($userid) { global $conf, $langs; @@ -1072,7 +1072,7 @@ class Adherent extends CommonObject * @param int $thirdpartyid Id of user to link to * @return int 1=OK, -1=KO */ - function setThirdPartyId($thirdpartyid) + public function setThirdPartyId($thirdpartyid) { global $conf, $langs; @@ -1108,14 +1108,14 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its login * * @param string $login login of member * @return void */ - function fetch_login($login) + public function fetch_login($login) { // phpcs:enable global $conf; @@ -1139,7 +1139,7 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its name * @@ -1147,7 +1147,7 @@ class Adherent extends CommonObject * @param string $lastname Lastname * @return void */ - function fetch_name($firstname, $lastname) + public function fetch_name($firstname, $lastname) { // phpcs:enable global $conf; @@ -1183,7 +1183,7 @@ class Adherent extends CommonObject * @param bool $fetch_subscriptions To load member subscriptions * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) + public function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) { global $langs; @@ -1316,7 +1316,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get member subscriptions data * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount @@ -1324,7 +1324,7 @@ class Adherent extends CommonObject * * @return int <0 si KO, >0 si OK */ - function fetch_subscriptions() + public function fetch_subscriptions() { // phpcs:enable global $langs; @@ -1400,7 +1400,7 @@ class Adherent extends CommonObject * @param int $datesubend Date end subscription * @return int rowid of record added, <0 if KO */ - function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) + public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) { global $conf,$langs,$user; @@ -1486,7 +1486,7 @@ class Adherent extends CommonObject * @param string $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice. * @return int <0 if KO, >0 if OK */ - function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) + public function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) { global $conf, $langs, $user, $mysoc; @@ -1779,7 +1779,7 @@ class Adherent extends CommonObject * @param User $user user adherent qui valide * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function validate($user) + public function validate($user) { global $langs,$conf; @@ -1832,7 +1832,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function resiliate($user) + public function resiliate($user) { global $langs,$conf; @@ -1874,13 +1874,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to add member into external tools mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function add_to_abo() + public function add_to_abo() { // phpcs:enable global $conf,$langs; @@ -1933,13 +1933,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to delete a member from external tools like mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function del_to_abo() + public function del_to_abo() { // phpcs:enable global $conf,$langs; @@ -1997,7 +1997,7 @@ class Adherent extends CommonObject * * @return string Translated name of civility (translated with transnoentitiesnoconv) */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -2018,7 +2018,7 @@ class Adherent extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $conf, $langs; @@ -2109,12 +2109,12 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2124,7 +2124,7 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) + public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) { // phpcs:enable global $langs; @@ -2202,13 +2202,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -2238,14 +2238,14 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2337,7 +2337,7 @@ class Adherent extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2390,7 +2390,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -2400,7 +2400,7 @@ class Adherent extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2412,13 +2412,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2525,7 +2525,7 @@ class Adherent extends CommonObject * @param int $id Id of member to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec as datec,'; $sql.= ' a.datevalid as datev,'; @@ -2581,7 +2581,7 @@ class Adherent extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9fd7a9b9d38..65085caf42a 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -89,7 +89,7 @@ class AdherentType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; @@ -103,7 +103,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; @@ -170,7 +170,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -238,7 +238,7 @@ class AdherentType extends CommonObject * * @return int > 0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -272,7 +272,7 @@ class AdherentType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -306,13 +306,13 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of members' type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -356,7 +356,7 @@ class AdherentType extends CommonObject * 2=Return array of members id only * @return mixed Array of members or -1 on error */ - function listMembersForMemberType($excludefilter = '', $mode = 0) + public function listMembersForMemberType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -404,14 +404,14 @@ class AdherentType extends CommonObject } /** - * Return clicable name (with picto eventually) + * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -434,12 +434,12 @@ class AdherentType extends CommonObject * * @return string Return status of a type of member */ - function getLibStatut() - { - return ''; - } + public function getLibStatut() + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -449,7 +449,7 @@ class AdherentType extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -461,13 +461,13 @@ class AdherentType extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -502,7 +502,7 @@ class AdherentType extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user, $langs; @@ -530,7 +530,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnValid() + public function getMailOnValid() { global $conf; @@ -547,7 +547,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnSubscription() + public function getMailOnSubscription() { global $conf; @@ -565,16 +565,16 @@ class AdherentType extends CommonObject * * @return string Return mail model content of type or empty */ - function getMailOnResiliate() - { - global $conf; + public function getMailOnResiliate() + { + global $conf; - // NOTE mail_resiliate not defined so never used - if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined - { - return $this->mail_resiliate; - } + // NOTE mail_resiliate not defined so never used + if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined + { + return $this->mail_resiliate; + } - return ''; - } + return ''; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 7468ddb92a9..b9085b1f6b4 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -37,12 +37,12 @@ class AdherentStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -52,7 +52,7 @@ class AdherentStats extends Stats * @param int $socid Id third party * @param int $userid Id user for filter */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; @@ -85,7 +85,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -105,7 +105,7 @@ class AdherentStats extends Stats * * @return array Array of nb each year */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -126,7 +126,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of amount each month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -147,7 +147,7 @@ class AdherentStats extends Stats * @param int $year Year * @return array Array of average each month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -168,7 +168,7 @@ class AdherentStats extends Stats * * @return array Array with nb, total amount, average for each year */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 6db5edf4646..376a1d3986a 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -53,7 +53,7 @@ class BlockedLogAuthority public function __construct($db) { $this->db = $db; - } + } /** * Get the blockchain @@ -76,7 +76,7 @@ class BlockedLogAuthority } return $this->blockchain; - } + } /** * Get hash of the block chain to check @@ -87,7 +87,7 @@ class BlockedLogAuthority { return md5($this->signature.$this->blockchain); - } + } /** * Get hash of the block chain to check @@ -99,7 +99,7 @@ class BlockedLogAuthority { return ($hash === $this->getBlockchainHash() ); - } + } /** * Add a new block to the chain @@ -111,7 +111,7 @@ class BlockedLogAuthority { $this->blockchain.=$block; - } + } /** * hash already exist into chain ? @@ -132,7 +132,7 @@ class BlockedLogAuthority else{ return false; } - } + } /** @@ -191,7 +191,7 @@ class BlockedLogAuthority $this->error=$this->db->error(); return -1; } - } + } /** * Create authority in database. @@ -245,7 +245,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * Create authority in database. @@ -283,7 +283,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * For cron to sync to authority. @@ -326,6 +326,6 @@ class BlockedLogAuthority } } - return 1; - } + return 1; + } } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 95fe3f55d0d..c3e507fb085 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -44,10 +44,10 @@ class Orders extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->commande = new Commande($this->db); } @@ -62,7 +62,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -100,7 +100,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -185,11 +185,11 @@ class Orders extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); - } + } // Check mandatory fields $result = $this->_validate($request_data); @@ -220,7 +220,7 @@ class Orders extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Orders extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -314,7 +314,7 @@ class Orders extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -375,7 +375,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -399,7 +399,7 @@ class Orders extends DolibarrApi throw new RestException(405, $this->commande->error); } } - + /** * Add a contact type of given order * @@ -413,7 +413,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -455,7 +455,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -488,7 +488,7 @@ class Orders extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -529,7 +529,7 @@ class Orders extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); @@ -577,7 +577,7 @@ class Orders extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -629,7 +629,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function reopen($id) + public function reopen($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -667,7 +667,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function setinvoiced($id) + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -710,7 +710,7 @@ class Orders extends DolibarrApi * * @return int */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -756,7 +756,7 @@ class Orders extends DolibarrApi * * @return array */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -807,7 +807,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function createOrderFromProposal($proposalid) + public function createOrderFromProposal($proposalid) { require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; @@ -844,7 +844,7 @@ class Orders extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -866,7 +866,7 @@ class Orders extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $commande = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 26151fd8b72..48c48f608d9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -203,12 +203,12 @@ class Commande extends CommonOrder public $multicurrency_total_ttc; public $oldcopy; - + //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; //! key of pos source ('0', '1', ...) public $pos_source; - + /** * ERR Not enough stock */ @@ -243,7 +243,7 @@ class Commande extends CommonOrder * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -260,7 +260,7 @@ class Commande extends CommonOrder * @param Societe $soc Object thirdparty * @return string Order free reference */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("order"); @@ -318,7 +318,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - function valid($user, $idwarehouse = 0, $notrigger = 0) + public function valid($user, $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -471,7 +471,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -479,8 +479,8 @@ class Commande extends CommonOrder * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) - { + public function set_draft($user, $idwarehouse = -1) + { //phpcs:enable global $conf,$langs; @@ -562,7 +562,7 @@ class Commande extends CommonOrder * @param User $user Object user that change status * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function set_reopen($user) + public function set_reopen($user) { // phpcs:enable $error=0; @@ -622,7 +622,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user, $notrigger = 0) + public function cloture($user, $notrigger = 0) { global $conf; @@ -682,7 +682,7 @@ class Commande extends CommonOrder * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function cancel($idwarehouse = -1) + public function cancel($idwarehouse = -1) { global $conf,$user,$langs; @@ -763,7 +763,7 @@ class Commande extends CommonOrder * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; $error=0; @@ -892,7 +892,7 @@ class Commande extends CommonOrder $vatrate = $line->tva_tx; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -1067,7 +1067,7 @@ class Commande extends CommonOrder * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1152,7 +1152,7 @@ class Commande extends CommonOrder * @param User $user User making creation * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromProposal($object, User $user) + public function createFromProposal($object, User $user) { global $conf, $hookmanager; @@ -1309,7 +1309,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) { global $mysoc, $conf, $langs, $user; @@ -1523,22 +1523,22 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array * $this->client must be loaded * - * @param int $idproduct Product Id - * @param float $qty Quantity - * @param float $remise_percent Product discount relative - * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @return void + * @param int $idproduct Product Id + * @param float $qty Quantity + * @param float $remise_percent Product discount relative + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') + public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { // phpcs:enable global $conf, $mysoc; @@ -1583,7 +1583,6 @@ class Commande extends CommonOrder $line->product_desc=$prod->description; $line->fk_unit=$prod->fk_unit; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Save the start and end date of the line in the object if ($date_start) { $line->date_start = $date_start; } if ($date_end) { $line->date_end = $date_end; } @@ -1623,7 +1622,7 @@ class Commande extends CommonOrder * @param string $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { // Check parameters @@ -1719,7 +1718,7 @@ class Commande extends CommonOrder $this->fk_delivery_address = $obj->fk_delivery_address; $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; - + //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; @@ -1776,7 +1775,7 @@ class Commande extends CommonOrder * @param int $idremise Id de la remise fixe * @return int >0 si ok, <0 si ko */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1848,14 +1847,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable $this->lines=array(); @@ -1971,7 +1970,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of product lines if OK */ - function getNbOfProductsLines() + public function getNbOfProductsLines() { $nb=0; foreach($this->lines as $line) @@ -1986,7 +1985,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of service lines if OK */ - function getNbOfServicesLines() + public function getNbOfServicesLines() { $nb=0; foreach($this->lines as $line) @@ -1997,11 +1996,11 @@ class Commande extends CommonOrder } /** - * Count numbe rof shipments for this order + * Count number of shipments for this order * * @return int <0 if KO, Nb of shipment found if OK */ - function getNbOfShipments() + public function getNbOfShipments() { $nb = 0; @@ -2037,7 +2036,7 @@ class Commande extends CommonOrder * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ - function loadExpeditions($filtre_statut = -1) + public function loadExpeditions($filtre_statut = -1) { $this->expeditions = array(); @@ -2077,7 +2076,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns a array with expeditions lines number * @@ -2085,7 +2084,7 @@ class Commande extends CommonOrder * * TODO deprecate, move to Shipping class */ - function nb_expedition() + public function nb_expedition() { // phpcs:enable $sql = 'SELECT count(*)'; @@ -2104,7 +2103,7 @@ class Commande extends CommonOrder else dol_print_error($this->db); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a array with the pending stock by product * @@ -2113,7 +2112,7 @@ class Commande extends CommonOrder * * TODO FONCTION NON FINIE A FINIR */ - function stock_array($filtre_statut = self::STATUS_CANCELED) + public function stock_array($filtre_statut = self::STATUS_CANCELED) { // phpcs:enable $this->stocks = array(); @@ -2153,7 +2152,7 @@ class Commande extends CommonOrder * @param int $lineid Id of line to delete * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0) { if ($this->statut == self::STATUS_DRAFT) { @@ -2222,7 +2221,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise relative * @@ -2231,7 +2230,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2290,7 +2289,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise absolue * @@ -2299,7 +2298,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2358,7 +2357,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the order date * @@ -2367,7 +2366,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2424,7 +2423,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -2433,7 +2432,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2490,7 +2489,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of orders (eventuelly filtered on a user) into an array * @@ -2504,7 +2503,7 @@ class Commande extends CommonOrder * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { // phpcs:enable global $user; @@ -2572,7 +2571,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO */ - function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -2635,7 +2634,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update order demand_reason * @@ -2643,7 +2642,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if ok, <0 if ko */ - function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { // phpcs:enable global $user; @@ -2707,7 +2706,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -2716,7 +2715,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2779,7 +2778,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error = 0; @@ -2835,7 +2834,7 @@ class Commande extends CommonOrder * * @return int <0 if ko, >0 if ok */ - function classifyUnBilled() + public function classifyUnBilled() { global $conf, $user, $langs; $error = 0; @@ -2914,7 +2913,7 @@ class Commande extends CommonOrder * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $conf, $mysoc, $langs, $user; @@ -3104,7 +3103,7 @@ class Commande extends CommonOrder * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -3199,7 +3198,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -3321,14 +3320,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -3387,7 +3386,7 @@ class Commande extends CommonOrder * * @return string Label */ - function getLabelSource() + public function getLabelSource() { global $langs; @@ -3403,12 +3402,12 @@ class Commande extends CommonOrder * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $this->billed, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status * @@ -3418,7 +3417,7 @@ class Commande extends CommonOrder * @param int $donotshowbilled Do not show billed status after order status * @return string Label of status */ - function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) + public function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) { // phpcs:enable global $langs, $conf; @@ -3430,72 +3429,72 @@ class Commande extends CommonOrder if ($mode == 0) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 1) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 2) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); } elseif ($mode == 3) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 4) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); } elseif ($mode == 5) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 6) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } } @@ -3511,7 +3510,7 @@ class Commande extends CommonOrder * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -3588,7 +3587,7 @@ class Commande extends CommonOrder * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,'; $sql.= ' date_valid as datev,'; @@ -3646,7 +3645,7 @@ class Commande extends CommonOrder * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -3734,7 +3733,7 @@ class Commande extends CommonOrder * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -3776,7 +3775,7 @@ class Commande extends CommonOrder * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3880,7 +3879,7 @@ class OrderLine extends CommonOrderLine public $table_element='commandedet'; - var $oldline; + public $oldline; /** * Id of parent order @@ -3897,38 +3896,37 @@ class OrderLine extends CommonOrderLine public $commande_id; // From llx_commandedet - var $fk_parent_line; - var $fk_facture; + public $fk_parent_line; + public $fk_facture; /** * @var string Order lines label */ public $label; - var $fk_remise_except; - var $rang = 0; - var $fk_fournprice; + public $fk_remise_except; + public $rang = 0; + public $fk_fournprice; /** * Buy price without taxes * @var float */ - var $pa_ht; - var $marge_tx; - var $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; /** * @deprecated * @see remise_percent, fk_remise_except */ - var $remise; + public $remise; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Start and end date of the line - var $date_start; - var $date_end; + public $date_start; + public $date_end; - var $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines /** @@ -3936,10 +3934,10 @@ class OrderLine extends CommonOrderLine * * @param DoliDB $db handler d'acces base de donnee */ - function __construct($db) - { - $this->db= $db; - } + public function __construct($db) + { + $this->db= $db; + } /** * Load line order @@ -3947,7 +3945,7 @@ class OrderLine extends CommonOrderLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; @@ -4032,7 +4030,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 si ko, >0 si ok */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; @@ -4093,7 +4091,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -4238,7 +4236,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 si ko, >0 si ok */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf,$langs; @@ -4365,14 +4363,14 @@ class OrderLine extends CommonOrderLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 7c1dd201d23..15f0c628ce7 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class CommandeStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class CommandeStats extends Stats * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -74,7 +74,7 @@ class CommandeStats extends Stats $this->field_line='total_ht'; $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled } - if ($mode == 'supplier') + elseif ($mode == 'supplier') { $object=new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; @@ -101,7 +101,7 @@ class CommandeStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -123,7 +123,7 @@ class CommandeStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -144,7 +144,7 @@ class CommandeStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -166,7 +166,7 @@ class CommandeStats extends Stats * @param int $year year for stats * @return array array with number by month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -186,7 +186,7 @@ class CommandeStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -206,7 +206,7 @@ class CommandeStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 67b3900ec06..dd095792c40 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -143,19 +143,19 @@ class Contact extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; // By default, status is enabled } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -200,7 +200,7 @@ class Contact extends CommonObject * @param User $user Object user that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -313,7 +313,7 @@ class Contact extends CommonObject * @param int $nosyncuser No sync linked user (external users and contacts are linked) * @return int <0 if KO, >0 if OK */ - function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) + public function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) { global $conf, $langs, $hookmanager; @@ -491,7 +491,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -501,7 +501,7 @@ class Contact extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -513,13 +513,13 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf, $langs; @@ -597,7 +597,7 @@ class Contact extends CommonObject * @param int $notrigger 0=no, 1=yes * @return int <0 if KO, >=0 if OK */ - function update_perso($id, $user = null, $notrigger = 0) + public function update_perso($id, $user = null, $notrigger = 0) { // phpcs:enable $error=0; @@ -686,7 +686,7 @@ class Contact extends CommonObject * @param string $email Email * @return int -1 if KO, 0 if OK but not found, 1 if OK */ - function fetch($id, $user = null, $ref_ext = '', $email = '') + public function fetch($id, $user = null, $ref_ext = '', $email = '') { global $langs; @@ -869,7 +869,7 @@ class Contact extends CommonObject * * @return void */ - function setGenderFromCivility() + public function setGenderFromCivility() { unset($this->gender); if (in_array($this->civility_id, array('MR'))) { @@ -879,7 +879,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -889,7 +889,7 @@ class Contact extends CommonObject * * @return int <0 if KO, >=0 if OK */ - function load_ref_elements() + public function load_ref_elements() { // phpcs:enable // Compte les elements pour lesquels il est contact @@ -931,7 +931,7 @@ class Contact extends CommonObject * @param int $notrigger Disable all trigger * @return int <0 if KO, >0 if OK */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $langs, $user; @@ -1045,7 +1045,7 @@ class Contact extends CommonObject * @param int $id Id du contact a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,"; $sql.= " c.tms as tms, c.fk_user_modif"; @@ -1090,7 +1090,7 @@ class Contact extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m"; @@ -1125,7 +1125,7 @@ class Contact extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $hookmanager; @@ -1203,7 +1203,7 @@ class Contact extends CommonObject * * @return string Translated name of civility */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -1219,12 +1219,12 @@ class Contact extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1232,7 +1232,7 @@ class Contact extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1270,14 +1270,14 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * * @param int $statut Type (0 = public, 1 = private) * @return string Label translated */ - function LibPubPriv($statut) + public function LibPubPriv($statut) { // phpcs:enable global $langs; @@ -1293,14 +1293,13 @@ class Contact extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { // Get first id of existing company and save it into $socid $socid = 0; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe ORDER BY rowid LIMIT 1"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) $socid=$obj->rowid; } @@ -1337,7 +1336,7 @@ class Contact extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; diff --git a/test/phpunit/AccountingAccountTest.php b/test/phpunit/AccountingAccountTest.php index 09a7a21d145..68332563e6c 100644 --- a/test/phpunit/AccountingAccountTest.php +++ b/test/phpunit/AccountingAccountTest.php @@ -57,9 +57,9 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase * * @return AccountingAccountTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -187,19 +187,19 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase */ public function testAccountingAccountUpdate($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject->label='New label'; - $result=$localobject->update($user); + $localobject->label='New label'; + $result=$localobject->update($user); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject->id; } /** diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index 80bb9687529..f9c0928bad2 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -57,7 +57,7 @@ class ActionCommTest extends PHPUnit_Framework_TestCase * * @return ActionCommTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index f3ebb81ea7c..bd5ae5571cc 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -59,7 +59,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase * * @return AdherentTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 9b405b5e360..bbf5ae2da00 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -57,7 +57,7 @@ class AdminLibTest extends PHPUnit_Framework_TestCase * * @return AdminLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index f8917a335ca..fa150742c4b 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -59,7 +59,7 @@ class BankAccountTest extends PHPUnit_Framework_TestCase * * @return BankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 2ca1cfb431f..4ba05b2c0b6 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -60,7 +60,7 @@ class BonPrelevementTest extends PHPUnit_Framework_TestCase * * @return BankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index a4566c92f95..e8fa72a8f40 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -87,7 +87,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase * * @return BuildDocTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index bf365c7ddf7..b664b345c26 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -57,7 +57,7 @@ class CMailFileTest extends PHPUnit_Framework_TestCase * * @return CMailFile */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 005de68d3ef..80761a6e594 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -58,7 +58,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase * * @return CategorieTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index b181c835b01..b037e50752d 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -31,9 +31,9 @@ require_once dirname(__FILE__).'/../../htdocs/compta/sociales/class/chargesocial if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -47,74 +47,74 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class ChargeSocialesTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return ChargeSocialesTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return ChargeSocialesTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -124,19 +124,19 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user, $langs, $conf); - print __METHOD__." result=".$result."\n"; + $localobject=new ChargeSociales($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user, $langs, $conf); + print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + $this->assertLessThan($result, 0); + return $result; } /** @@ -150,18 +150,18 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $result=$localobject->fetch($id); - print __METHOD__." id=".$id." result=".$result."\n"; + $localobject=new ChargeSociales($this->savdb); + $result=$localobject->fetch($id); + print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $localobject; + $this->assertLessThan($result, 0); + return $localobject; } /** @@ -175,17 +175,17 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesValid($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=$localobject->set_paid($user); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $result=$localobject->set_paid($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $localobject; + $this->assertLessThan($result, 0); + return $localobject; } /** @@ -213,7 +213,7 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); - return $localobject->id; + return $localobject->id; } /** @@ -227,18 +227,18 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $result=$localobject->fetch($id); - $result=$localobject->delete($id); + $localobject=new ChargeSociales($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($id); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; } } diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index fa424ba71a6..2a1dad01049 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -70,11 +70,11 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -164,12 +164,12 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($val[1] != '\'"' && $val[1] != '\'\'') - { - $ok=false; - break; - } - //if ($reg[0] != 'db') $ok=false; + if ($val[1] != '\'"' && $val[1] != '\'\'') + { + $ok=false; + break; + } + //if ($reg[0] != 'db') $ok=false; } //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; $this->assertTrue($ok, 'Found a $this->db->idate to forge a sql request without quotes around this date field '.$file['fullname'].' :: '.$val[0]); @@ -201,7 +201,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') + if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') { $ok=false; break; @@ -217,8 +217,8 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - $ok=false; - break; + $ok=false; + break; } $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.'); @@ -230,7 +230,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/
/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($file['name'] != 'functions.lib.php') + if ($file['name'] != 'functions.lib.php') { $ok=false; break; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 7c6d9e750b8..9c9655b1f5c 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -70,7 +70,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index eeed83174c6..277328339ee 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -59,7 +59,7 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase * * @return CommandeFournisseurTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 85e2b972cb5..00a0a4983c9 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -57,7 +57,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * * @return CommandeTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommonInvoiceTest.php b/test/phpunit/CommonInvoiceTest.php index 4fab182ad69..2ce95dcafe1 100644 --- a/test/phpunit/CommonInvoiceTest.php +++ b/test/phpunit/CommonInvoiceTest.php @@ -57,7 +57,7 @@ class CommonInvoiceTest extends PHPUnit\Framework\TestCase * * @return CommonObjectTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 634573bc03f..549540bb0d0 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -58,7 +58,7 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase * * @return CommonObjectTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index c50935c8aac..58eebfd0207 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -58,7 +58,7 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase * * @return CompanyBankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php index 1a08c4512e9..0fb1722aee9 100644 --- a/test/phpunit/CompanyLibTest.php +++ b/test/phpunit/CompanyLibTest.php @@ -57,7 +57,7 @@ class CompanyLibTest extends PHPUnit_Framework_TestCase * * @return AdminLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index edf103cb894..ef43bd06311 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -66,7 +66,7 @@ class ContactTest extends PHPUnit_Framework_TestCase * * @return ContactTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -82,14 +82,14 @@ class ContactTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 74b30e10268..c5342865979 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -31,9 +31,9 @@ require_once dirname(__FILE__).'/../../htdocs/contrat/class/contrat.class.php'; if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -47,74 +47,74 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class ContratTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return ContratTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return ContratTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -124,20 +124,20 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user); + $localobject=new Contrat($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); - print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -151,19 +151,19 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Contrat($this->savdb); + $result=$localobject->fetch($id); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $localobject; + return $localobject; } /** @@ -206,18 +206,18 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $result=$localobject->fetch($id); - $result=$localobject->delete($user); + $localobject=new Contrat($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; } } diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 2d9697f9cfe..51a0f54698f 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -60,7 +60,7 @@ class CoreTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 44c1e77d9ae..6424cb4d8df 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -58,7 +58,7 @@ class DateLibTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,12 +75,12 @@ class DateLibTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index a59eb7bf242..fa7aef2bed8 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -58,7 +58,7 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,8 +74,8 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index 724a97e6f3e..cd73a7ad173 100644 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -58,7 +58,7 @@ class DiscountTest extends PHPUnit_Framework_TestCase * * @return DiscountTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class DiscountTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 1028fc2599d..9672123f103 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -58,7 +58,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase * * @return EntrepotTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,8 +74,8 @@ class EntrepotTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExpenseReportTest.php b/test/phpunit/ExpenseReportTest.php index ed6ddf97fc7..dc053d8edb3 100644 --- a/test/phpunit/ExpenseReportTest.php +++ b/test/phpunit/ExpenseReportTest.php @@ -58,7 +58,7 @@ class ExpenseReportTest extends PHPUnit_Framework_TestCase * * @return ExpenseReportTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 1b479cb1f30..7403cba3ddf 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -62,7 +62,7 @@ class ExportTest extends PHPUnit_Framework_TestCase * * @return ExportTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -79,7 +79,7 @@ class ExportTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 63c28945e65..2d6218471aa 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -59,7 +59,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase * * @return FactureFournisseurTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,7 +76,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 720e1951788..de1bb164451 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -59,7 +59,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,10 +75,10 @@ class FactureRecTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. print __METHOD__."\n"; @@ -114,7 +114,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 9ac4cd05f33..4f680ba32db 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -58,7 +58,7 @@ class FactureTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/FactureTestRounding.php b/test/phpunit/FactureTestRounding.php index dbaf598e1a0..a0df47cd97f 100644 --- a/test/phpunit/FactureTestRounding.php +++ b/test/phpunit/FactureTestRounding.php @@ -58,7 +58,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. @@ -97,7 +97,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return void */ - protected function setUp() + protected function setUp() { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -113,7 +113,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index 5c966f4d4ec..35680559581 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -58,7 +58,7 @@ class FichinterTest extends PHPUnit_Framework_TestCase * * @return ContratTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FichinterTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index c1038271498..2411c5c9cf3 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -59,7 +59,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase * * @return FilesLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,8 +75,8 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index dc6ed409375..8532d6ac283 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -58,7 +58,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. @@ -111,9 +111,9 @@ class FormAdminTest extends PHPUnit_Framework_TestCase /** * End phpunit tests * - * @return void - */ - protected function tearDown() + * @return void + */ + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 2f6a45e2599..50efabf9403 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -61,7 +61,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 2ab796dfba8..5b2b65c9e50 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -61,11 +61,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -97,11 +97,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { global $conf,$user,$langs,$db; @@ -114,10 +114,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase } /** - * End phpunit tests - * - * @return void - */ + * End phpunit tests + * + * @return void + */ protected function tearDown() { print __METHOD__."\n"; @@ -131,22 +131,22 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testIsValidMXRecord() { - // Nb of line is same than entry text + // Nb of line is same than entry text - $input="yahoo.com"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(1, $result); + $input="yahoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(1, $result); - $input="yhaoo.com"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(0, $result); + $input="yhaoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); - $input="dolibarr.fr"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(0, $result); + $input="dolibarr.fr"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); } /** @@ -156,87 +156,87 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolGetFirstLineOfText() { - // Nb of line is same than entry text + // Nb of line is same than entry text - $input="aaaa"; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa", $result); + $input="aaaa"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa", $result); - $input="aaaa\nbbbbbbbbbbbb\n"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); + $input="aaaa\nbbbbbbbbbbbb\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); - $input="aaaa
bbbbbbbbbbbb
"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
\nbbbbbbbbbbbb", $result); + $input="aaaa
bbbbbbbbbbbb
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb", $result); - // Nb of line is lower + // Nb of line is lower - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa...", $result); + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); - $input="aaaa
bbbbbbbbbbbb
cccccc
"; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa...", $result); + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); - $input="aaaa
bbbbbbbbbbbb
cccccc
"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
\nbbbbbbbbbbbb...", $result); + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb...", $result); - // Nb of line is higher + // Nb of line is higher - $input="aaaa
bbbbbbbbbbbb
cccccc"; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); + $input="aaaa
bbbbbbbbbbbb
cccccc"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); - $input="aaaa
bbbbbbbbbbbb
cccccc
"; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); - $input="aaaa
bbbbbbbbbbbb
cccccc
\n"; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); + $input="aaaa
bbbbbbbbbbbb
cccccc
\n"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); } - /** - * testDolBuildPath - * - * @return void - */ - public function testDolBuildPath() - { - /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); - var_dump($tmp); - */ + /** + * testDolBuildPath + * + * @return void + */ + public function testDolBuildPath() + { + /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); + var_dump($tmp); + */ - /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); - var_dump($tmp); - */ + /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); + var_dump($tmp); + */ - $result=dol_buildpath('/google/oauth2callback.php', 2); - print __METHOD__." result=".$result."\n"; - $this->assertStringStartsWith('http', $result); - - $result=dol_buildpath('/google/oauth2callback.php', 3); + $result=dol_buildpath('/google/oauth2callback.php', 2); print __METHOD__." result=".$result."\n"; $this->assertStringStartsWith('http', $result); - } + + $result=dol_buildpath('/google/oauth2callback.php', 3); + print __METHOD__." result=".$result."\n"; + $this->assertStringStartsWith('http', $result); + } /** @@ -246,82 +246,82 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetBrowserInfo() { - // MSIE 5.0 + // MSIE 5.0 $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('ie', $tmp['browsername']); $this->assertEquals('5.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - // Firefox 0.9.1 + // Firefox 0.9.1 $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('firefox', $tmp['browsername']); $this->assertEquals('0.9.1', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('opera', $tmp['browsername']); $this->assertEquals('6.03', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('chrome', $tmp['browsername']); $this->assertEquals('19.0.1042.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('chrome', $tmp['browsername']); $this->assertEquals('17.0.963.56', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('safari', $tmp['browsername']); $this->assertEquals('533.21.1', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //Internet Explorer 11 - $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie', $tmp['browsername']); - $this->assertEquals('11.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + //Internet Explorer 11 + $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //Internet Explorer 11 bis - $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie', $tmp['browsername']); - $this->assertEquals('11.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + //Internet Explorer 11 bis + $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //iPad - $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('safari', $tmp['browsername']); - $this->assertEquals('8536.25', $tmp['browserversion']); - $this->assertEquals('ios', $tmp['browseros']); - $this->assertEquals('tablet', $tmp['layout']); - $this->assertEquals('iphone', $tmp['phone']); + //iPad + $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('safari', $tmp['browsername']); + $this->assertEquals('8536.25', $tmp['browserversion']); + $this->assertEquals('ios', $tmp['browseros']); + $this->assertEquals('tablet', $tmp['layout']); + $this->assertEquals('iphone', $tmp['phone']); } @@ -332,48 +332,48 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetLanguageCodeFromCountryCode() { - global $mysoc; + global $mysoc; - $language = getLanguageCodeFromCountryCode('US'); - $this->assertEquals('en_US', $language, 'US'); + $language = getLanguageCodeFromCountryCode('US'); + $this->assertEquals('en_US', $language, 'US'); - $language = getLanguageCodeFromCountryCode('ES'); - $this->assertEquals('es_ES', $language, 'ES'); + $language = getLanguageCodeFromCountryCode('ES'); + $this->assertEquals('es_ES', $language, 'ES'); - $language = getLanguageCodeFromCountryCode('CL'); - $this->assertEquals('es_CL', $language, 'CL'); + $language = getLanguageCodeFromCountryCode('CL'); + $this->assertEquals('es_CL', $language, 'CL'); - $language = getLanguageCodeFromCountryCode('CA'); - $this->assertEquals('en_CA', $language, 'CA'); + $language = getLanguageCodeFromCountryCode('CA'); + $this->assertEquals('en_CA', $language, 'CA'); - $language = getLanguageCodeFromCountryCode('MQ'); - $this->assertEquals('fr_CA', $language); + $language = getLanguageCodeFromCountryCode('MQ'); + $this->assertEquals('fr_CA', $language); - $language = getLanguageCodeFromCountryCode('FR'); - $this->assertEquals('fr_FR', $language); + $language = getLanguageCodeFromCountryCode('FR'); + $this->assertEquals('fr_FR', $language); - $language = getLanguageCodeFromCountryCode('BE'); - $this->assertEquals('fr_BE', $language); + $language = getLanguageCodeFromCountryCode('BE'); + $this->assertEquals('fr_BE', $language); - $mysoc->country_code = 'FR'; - $language = getLanguageCodeFromCountryCode('CH'); - $this->assertEquals('fr_CH', $language); + $mysoc->country_code = 'FR'; + $language = getLanguageCodeFromCountryCode('CH'); + $this->assertEquals('fr_CH', $language); - $mysoc->country_code = 'DE'; - $language = getLanguageCodeFromCountryCode('CH'); - $this->assertEquals('de_CH', $language); + $mysoc->country_code = 'DE'; + $language = getLanguageCodeFromCountryCode('CH'); + $this->assertEquals('de_CH', $language); - $language = getLanguageCodeFromCountryCode('DE'); - $this->assertEquals('de_DE', $language); + $language = getLanguageCodeFromCountryCode('DE'); + $this->assertEquals('de_DE', $language); - $language = getLanguageCodeFromCountryCode('SA'); - $this->assertEquals('ar_SA', $language); + $language = getLanguageCodeFromCountryCode('SA'); + $this->assertEquals('ar_SA', $language); - $language = getLanguageCodeFromCountryCode('SE'); - $this->assertEquals('sv_SE', $language); + $language = getLanguageCodeFromCountryCode('SE'); + $this->assertEquals('sv_SE', $language); - $language = getLanguageCodeFromCountryCode('DK'); - $this->assertEquals('da_DK', $language); + $language = getLanguageCodeFromCountryCode('DK'); + $this->assertEquals('da_DK', $language); } /** @@ -570,9 +570,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolHtmlEntitiesBr() { - // Text not already HTML + // Text not already HTML - $input="A string\nwith a é, &, < and >."; + $input="A string\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input, 0); // Add
before \n $this->assertEquals("A string
\nwith a é, &, < and >.", $after); @@ -645,9 +645,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolUnaccent() { - // Text not already HTML + // Text not already HTML - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; + $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; $after=dol_string_unaccent($input); $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); } @@ -738,14 +738,14 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolMkTime() { - global $conf; + global $conf; - $savtz=date_default_timezone_get(); + $savtz=date_default_timezone_get(); - // Some test for UTC TZ - date_default_timezone_set('UTC'); + // Some test for UTC TZ + date_default_timezone_set('UTC'); - // Check bad hours + // Check bad hours $result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) print __METHOD__." result=".$result."\n"; $this->assertEquals('', $result); @@ -831,30 +831,30 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolFormatAddress() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $object=new Societe($db); - $object->initAsSpecimen(); + $object=new Societe($db); + $object->initAsSpecimen(); - $object->country_code='FR'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\n99999 MyTown", $address); + $object->country_code='FR'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\n99999 MyTown", $address); - $object->country_code='GB'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); + $object->country_code='GB'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); - $object->country_code='US'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); + $object->country_code='US'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); - $object->country_code='AU'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); + $object->country_code='AU'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); } @@ -903,7 +903,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__." s=".$s."\n"; $this->assertContains('theme', $s, 'testImgPicto1'); - $s=img_picto('title', 'img.png', 'style="float: right"', 0); + $s=img_picto('title', 'img.png', 'style="float: right"', 0); print __METHOD__." s=".$s."\n"; $this->assertContains('theme', $s, 'testImgPicto2'); $this->assertContains('style="float: right"', $s, 'testImgPicto2'); @@ -978,13 +978,13 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $companyfr=new Societe($db); $companyfr->country_code='FR'; $companyfr->tva_assuj=1; - $companyfr->tva_intra='FR9999'; + $companyfr->tva_intra='FR9999'; // Buyers $companymc=new Societe($db); $companymc->country_code='MC'; $companymc->tva_assuj=1; - $companyfr->tva_intra='MC9999'; + $companyfr->tva_intra='MC9999'; $companyit=new Societe($db); $companyit->country_code='IT'; @@ -1068,84 +1068,84 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetDefaultLocalTax() { - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - $companyfrnovat=new Societe($db); - $companyfrnovat->country_code='FR'; - $companyfrnovat->tva_assuj=0; - $companyfrnovat->localtax1_assuj=0; - $companyfrnovat->localtax2_assuj=0; + $companyfrnovat=new Societe($db); + $companyfrnovat->country_code='FR'; + $companyfrnovat->tva_assuj=0; + $companyfrnovat->localtax1_assuj=0; + $companyfrnovat->localtax2_assuj=0; - $companyes=new Societe($db); - $companyes->country_code='ES'; - $companyes->tva_assuj=1; - $companyes->localtax1_assuj=1; - $companyes->localtax2_assuj=1; + $companyes=new Societe($db); + $companyes->country_code='ES'; + $companyes->tva_assuj=1; + $companyes->localtax1_assuj=1; + $companyes->localtax2_assuj=1; - $companymc=new Societe($db); - $companymc->country_code='MC'; - $companymc->tva_assuj=1; - $companymc->localtax1_assuj=0; - $companymc->localtax2_assuj=0; + $companymc=new Societe($db); + $companymc->country_code='MC'; + $companymc->tva_assuj=1; + $companymc->localtax1_assuj=0; + $companymc->localtax2_assuj=0; - $companyit=new Societe($db); - $companyit->country_code='IT'; - $companyit->tva_assuj=1; - $companyit->tva_intra='IT99999'; - $companyit->localtax1_assuj=0; - $companyit->localtax2_assuj=0; + $companyit=new Societe($db); + $companyit->country_code='IT'; + $companyit->tva_assuj=1; + $companyit->tva_intra='IT99999'; + $companyit->localtax1_assuj=0; + $companyit->localtax2_assuj=0; - $notcompanyit=new Societe($db); - $notcompanyit->country_code='IT'; - $notcompanyit->tva_assuj=1; - $notcompanyit->tva_intra=''; - $notcompanyit->typent_code='TE_PRIVATE'; - $notcompanyit->localtax1_assuj=0; - $notcompanyit->localtax2_assuj=0; + $notcompanyit=new Societe($db); + $notcompanyit->country_code='IT'; + $notcompanyit->tva_assuj=1; + $notcompanyit->tva_intra=''; + $notcompanyit->typent_code='TE_PRIVATE'; + $notcompanyit->localtax1_assuj=0; + $notcompanyit->localtax2_assuj=0; - $companyus=new Societe($db); - $companyus->country_code='US'; - $companyus->tva_assuj=1; - $companyus->tva_intra=''; - $companyus->localtax1_assuj=0; - $companyus->localtax2_assuj=0; + $companyus=new Societe($db); + $companyus->country_code='US'; + $companyus->tva_assuj=1; + $companyus->tva_intra=''; + $companyus->localtax1_assuj=0; + $companyus->localtax2_assuj=0; - // Test RULE FR-MC - $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); - $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE FR-MC + $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); + $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE ES-ES - $vat1=get_default_localtax($companyes, $companyes, 1, 0); - $vat2=get_default_localtax($companyes, $companyes, 2, 0); - $this->assertEquals($vat1, 5.2); - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) + // Test RULE ES-ES + $vat1=get_default_localtax($companyes, $companyes, 1, 0); + $vat2=get_default_localtax($companyes, $companyes, 2, 0); + $this->assertEquals($vat1, 5.2); + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) - // Test RULE ES-IT - $vat1=get_default_localtax($companyes, $companyit, 1, 0); - $vat2=get_default_localtax($companyes, $companyit, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-IT + $vat1=get_default_localtax($companyes, $companyit, 1, 0); + $vat2=get_default_localtax($companyes, $companyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE ES-IT - $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); - $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-IT + $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); + $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE FR-IT - // Not tested + // Test RULE FR-IT + // Not tested - // Test RULE ES-US - $vat1=get_default_localtax($companyes, $companyus, 1, 0); - $vat2=get_default_localtax($companyes, $companyus, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-US + $vat1=get_default_localtax($companyes, $companyus, 1, 0); + $vat2=get_default_localtax($companyes, $companyus, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); } @@ -1156,108 +1156,108 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolExplodeIntoArray() { - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; - $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); + $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; + $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); print __METHOD__." tmp=".json_encode($tmp)."\n"; $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); } - /** - * dol_nl2br - * - * @return void - */ + /** + * dol_nl2br + * + * @return void + */ public function testDolNl2Br() { - //String to encode - $string = "a\na"; + //String to encode + $string = "a\na"; - $this->assertEquals(dol_nl2br($string), "a
\na"); + $this->assertEquals(dol_nl2br($string), "a
\na"); - //With $forxml parameter - $this->assertEquals(dol_nl2br($string, 0, 1), "a
\na"); + //With $forxml parameter + $this->assertEquals(dol_nl2br($string, 0, 1), "a
\na"); - //Replacing \n by br - $this->assertEquals(dol_nl2br($string, 1), "a
a"); + //Replacing \n by br + $this->assertEquals(dol_nl2br($string, 1), "a
a"); - //With $forxml parameter - $this->assertEquals(dol_nl2br($string, 1, 1), "a
a"); - } + //With $forxml parameter + $this->assertEquals(dol_nl2br($string, 1, 1), "a
a"); + } - /** - * testDolPrice2Num - * - * @return boolean - */ - public function testDolPrice2Num() - { - $this->assertEquals(1000, price2num('1 000.0')); - $this->assertEquals(1000, price2num('1 000', 'MT')); - $this->assertEquals(1000, price2num('1 000', 'MU')); + /** + * testDolPrice2Num + * + * @return boolean + */ + public function testDolPrice2Num() + { + $this->assertEquals(1000, price2num('1 000.0')); + $this->assertEquals(1000, price2num('1 000', 'MT')); + $this->assertEquals(1000, price2num('1 000', 'MU')); - $this->assertEquals(1000.123456, price2num('1 000.123456')); + $this->assertEquals(1000.123456, price2num('1 000.123456')); - // Round down - $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); - $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); + // Round down + $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); + $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); - // Round up - $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); - $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); + // Round up + $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); + $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); - // Text can't be converted - $this->assertEquals('12.4$', price2num('12.4$')); - $this->assertEquals('12r.4$', price2num('12r.4$')); + // Text can't be converted + $this->assertEquals('12.4$', price2num('12.4$')); + $this->assertEquals('12r.4$', price2num('12r.4$')); - return true; - } + return true; + } - /** - * testDolGetDate - * - * @return boolean - */ - public function testDolGetDate() - { - global $conf; + /** + * testDolGetDate + * + * @return boolean + */ + public function testDolGetDate() + { + global $conf; - $conf->global->MAIN_START_WEEK = 0; + $conf->global->MAIN_START_WEEK = 0; - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday - $this->assertEquals(4, $tmp['wday']); + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday + $this->assertEquals(4, $tmp['wday']); - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday - $this->assertEquals(5, $tmp['wday']); + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday + $this->assertEquals(5, $tmp['wday']); - $conf->global->MAIN_START_WEEK = 1; + $conf->global->MAIN_START_WEEK = 1; - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday - $this->assertEquals(4, $tmp['wday']); + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday + $this->assertEquals(4, $tmp['wday']); - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday - $this->assertEquals(5, $tmp['wday']); + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday + $this->assertEquals(5, $tmp['wday']); - return true; - } + return true; + } - /** - * testDolGetDate - * - * @return boolean - */ - public function testMakeSubstitutions() - { - global $conf, $langs; - $langs->load("main"); + /** + * testDolGetDate + * + * @return boolean + */ + public function testMakeSubstitutions() + { + global $conf, $langs; + $langs->load("main"); - $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); - $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; - $newstring = make_substitutions($chaine, $substit); - $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); + $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); + $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; + $newstring = make_substitutions($chaine, $substit); + $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); - return true; - } + return true; + } } diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index 754cea5f9c9..0e0cfb7d767 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -32,9 +32,9 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/geturl.lib.php'; if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -48,123 +48,123 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class GetUrlLibTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return FilesLibTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return FilesLibTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** + /** * testGetRootURLFromURL * * @return int */ public function testGetRootURLFromURL() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); + $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); - $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); + $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); - $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - $result=getRootURLFromURL('http://www.dolimed.com/'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com/'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com/'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com/'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - $result=getRootURLFromURL('http://www.dolimed.com'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - return 1; + return 1; } @@ -175,20 +175,20 @@ class GetUrlLibTest extends PHPUnit_Framework_TestCase */ public function testRemoveHtmlComment() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=removeHtmlComment('abcdef'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcdef', $result, 'Test 1'); + $result=removeHtmlComment('abcdef'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('abcdef', $result, 'Test 1'); - $result=removeHtmlComment('abcbbdef'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcbbdef', $result, 'Test 1'); + $result=removeHtmlComment('abcbbdef'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('abcbbdef', $result, 'Test 1'); - return 1; + return 1; } } diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index ce50174dc0b..a352a1722b9 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -32,9 +32,9 @@ $langs->load("dict"); if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -49,75 +49,75 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class HolidayTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return HolidayTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return HolidayTest + */ + public function __construct() { - global $conf,$user,$langs,$db; + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -127,20 +127,20 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user); + $localobject=new Holiday($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -153,19 +153,19 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Holiday($this->savdb); + $result=$localobject->fetch($id); print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0); - return $localobject; + return $localobject; } /** @@ -179,55 +179,55 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayUpdate($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject->oldcopy = clone $localobject; + $localobject->oldcopy = clone $localobject; - $localobject->note_private='New private note after update'; - $localobject->note_public='New public note after update'; - $localobject->lastname='New name'; - $localobject->firstname='New firstname'; - $localobject->address='New address'; - $localobject->zip='New zip'; - $localobject->town='New town'; - $localobject->country_id=2; - //$localobject->status=0; - $localobject->phone_pro='New tel pro'; - $localobject->phone_perso='New tel perso'; - $localobject->phone_mobile='New tel mobile'; - $localobject->fax='New fax'; - $localobject->email='newemail@newemail.com'; - $localobject->jabberid='New im id'; - $localobject->default_lang='es_ES'; + $localobject->note_private='New private note after update'; + $localobject->note_public='New public note after update'; + $localobject->lastname='New name'; + $localobject->firstname='New firstname'; + $localobject->address='New address'; + $localobject->zip='New zip'; + $localobject->town='New town'; + $localobject->country_id=2; + //$localobject->status=0; + $localobject->phone_pro='New tel pro'; + $localobject->phone_perso='New tel perso'; + $localobject->phone_mobile='New tel mobile'; + $localobject->fax='New fax'; + $localobject->email='newemail@newemail.com'; + $localobject->jabberid='New im id'; + $localobject->default_lang='es_ES'; - $result=$localobject->update($localobject->id, $user); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update error'); - - $result=$localobject->update_note($localobject->note_private, '_private'); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); - - $result=$localobject->update_note($localobject->note_public, '_public'); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update_note (public) error'); - - - $newobject=new Holiday($this->savdb); - $result=$newobject->fetch($localobject->id); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::fetch error'); + $this->assertLessThan($result, 0, 'Holiday::update error'); - print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n"; - $this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note'); - //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; - //$this->assertEquals($localobject->note_public, $newobject->note_public); + $result=$localobject->update_note($localobject->note_private, '_private'); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); - return $localobject; + $result=$localobject->update_note($localobject->note_public, '_public'); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::update_note (public) error'); + + + $newobject=new Holiday($this->savdb); + $result=$newobject->fetch($localobject->id); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::fetch error'); + + print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n"; + $this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note'); + //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; + //$this->assertEquals($localobject->note_public, $newobject->note_public); + + return $localobject; } /** @@ -241,15 +241,15 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayOther($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - //$localobject->fetch($localobject->id); + //$localobject->fetch($localobject->id); - /* + /* $result=$localobject->getNomUrl(1); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertNotEquals($result, ''); @@ -261,7 +261,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase $localobject->info($localobject->id); print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; $this->assertNotEquals($localobject->date_creation, ''); - */ + */ return $localobject->id; } @@ -277,20 +277,20 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Holiday($this->savdb); + $result=$localobject->fetch($id); - $result=$localobject->delete(0); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $result=$localobject->delete(0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -300,55 +300,55 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testVerifDateHolidayCP() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - // Create a leave request the 1st morning only - $localobjecta=new Holiday($this->savdb); - $localobjecta->initAsSpecimen(); - $localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); - $localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020); - $localobjecta->halfday = 1; - $result=$localobjecta->create($user); + // Create a leave request the 1st morning only + $localobjecta=new Holiday($this->savdb); + $localobjecta->initAsSpecimen(); + $localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); + $localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020); + $localobjecta->halfday = 1; + $result=$localobjecta->create($user); - // Create a leave request the 2 afternoon only - $localobjectb=new Holiday($this->savdb); - $localobjectb->initAsSpecimen(); - $localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectb->halfday = -1; - $result=$localobjectb->create($user); + // Create a leave request the 2 afternoon only + $localobjectb=new Holiday($this->savdb); + $localobjectb->initAsSpecimen(); + $localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020); + $localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); + $localobjectb->halfday = -1; + $result=$localobjectb->create($user); - $date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); - $date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); + $date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); + $date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectc=new Holiday($this->savdb); + $localobjectc=new Holiday($this->savdb); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1); - $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1); - $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1); - $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1); + $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1); + $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1); + $this->assertTrue($result, 'result should be true, there is no overlapping'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1); - $this->assertTrue($result, 'result should be true, there is no overlapping'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1); - $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1); - $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1); + $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1); + $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1); + $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning - $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning + $this->assertTrue($result, 'result should be true, there is no overlapping'); } } diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 0d579b7295d..4ecaab49d39 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -59,7 +59,7 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase * * @return ImagesLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,7 +76,7 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 9797905acdb..10d906f2ede 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -60,7 +60,7 @@ class ImportTest extends PHPUnit_Framework_TestCase * * @return ImportTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,7 +77,7 @@ class ImportTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 113d263eca4..bb33032a4a5 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -28,16 +28,16 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** @@ -60,11 +60,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -94,11 +94,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { global $conf,$user,$langs,$db; @@ -109,11 +109,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { print __METHOD__."\n"; @@ -135,39 +135,39 @@ class JsonLibTest extends PHPUnit_Framework_TestCase // Do a test with an array starting with 0 $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; + $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; $encoded=json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); $encoded=dol_json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=dol_json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=dol_json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); - // Same test but array start with 2 instead of 0 + // Same test but array start with 2 instead of 0 $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; + $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; $encoded=json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); $encoded=dol_json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=dol_json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=dol_json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); // Test with object - $now=gmmktime(12,0,0,1,1,1970); + $now=gmmktime(12, 0, 0, 1, 1, 1970); $objecttotest=new stdClass(); $objecttotest->property1='abc'; $objecttotest->property2=1234; $objecttotest->property3=$now; $encoded=dol_json_encode($objecttotest); - $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); + $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded); } } diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 82c2b45d8c7..228cde51901 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -70,7 +70,7 @@ class LangTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -87,7 +87,7 @@ class LangTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/LoanTest.php b/test/phpunit/LoanTest.php index d54c810049d..b0ecd583514 100644 --- a/test/phpunit/LoanTest.php +++ b/test/phpunit/LoanTest.php @@ -58,7 +58,7 @@ class LoanTest extends PHPUnit_Framework_TestCase * * @return LoanTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class LoanTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index f967d822f9a..81f4a512e4f 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -58,7 +58,7 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index dc999fac750..ea16813d873 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -57,7 +57,7 @@ class ModulesTest extends PHPUnit_Framework_TestCase * * @return BuildDocTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,7 +74,7 @@ class ModulesTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index cc50460e15f..cedd5b4741c 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -60,7 +60,7 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase * * @return ContratTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,7 +77,7 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 16ac7cc0082..66c4c670128 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -57,7 +57,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase * * @return NumberingModulesTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,7 +74,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; @@ -113,7 +113,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index a596f9c88d1..98300a6a86a 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -59,7 +59,7 @@ class PaypalTest extends PHPUnit_Framework_TestCase * * @return ProductTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,8 +75,8 @@ class PaypalTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index d7f81534cde..634a931da56 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -61,7 +61,7 @@ class PdfDocTest extends PHPUnit_Framework_TestCase * * @return PdfDocTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,8 +77,8 @@ class PdfDocTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/PgsqlTest.php b/test/phpunit/PgsqlTest.php index 8347bc32905..a1fcc180528 100644 --- a/test/phpunit/PgsqlTest.php +++ b/test/phpunit/PgsqlTest.php @@ -60,7 +60,7 @@ class PgsqlTest extends PHPUnit_Framework_TestCase * * @return ContactTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,8 +76,8 @@ class PgsqlTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 2fe61f4fa0f..0203a1d4275 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -65,11 +65,11 @@ class PricesTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -100,9 +100,9 @@ class PricesTest extends PHPUnit_Framework_TestCase } /** - * Init phpunit tests - * - * @return void + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -116,9 +116,9 @@ class PricesTest extends PHPUnit_Framework_TestCase } /** - * End phpunit tests - * - * @return void + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -134,68 +134,68 @@ class PricesTest extends PHPUnit_Framework_TestCase */ public function testCalculPriceTotal() { - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - global $mysoc; - $mysoc=new Societe($db); + global $mysoc; + $mysoc=new Societe($db); - // To force status that say module multicompany is on - //$conf->multicurrency=new stdClass(); - //$conf->multicurrency->enabled = 0; + // To force status that say module multicompany is on + //$conf->multicurrency=new stdClass(); + //$conf->multicurrency->enabled = 0; - /* - * Country France - */ + /* + * Country France + */ - // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value) - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); + // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value) + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0), $result1, 'Test1 FR'); - // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); + // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0), $result1, 'Test1b FR'); - // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0), $result1, 'Test1c FR'); /* - * Country Spain - */ + * Country Spain + */ // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (method we provide value) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=0; - $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=0; + $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=0; - $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=0; + $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test2 ES'); @@ -203,76 +203,76 @@ class PricesTest extends PHPUnit_Framework_TestCase // -------------------------------------------------------- // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (method we provide value) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test4 ES'); // -------------------------------------------------------- // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service'); - // -------------------------------------------------------- + // -------------------------------------------------------- // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a product and not a service - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ', $result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service'); /* @@ -280,23 +280,23 @@ class PricesTest extends PHPUnit_Framework_TestCase */ // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (method we provide value) - $mysoc->country_code='CI'; - $mysoc->country_id=21; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='CI'; + $mysoc->country_id=21; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; //$localtaxes=getLocalTaxesFromRate(18, 0, null, $mysoc); //var_dump($locataxes); - $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 + $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) - $mysoc->country_code='CI'; - $mysoc->country_id=21; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; - $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 + $mysoc->country_code='CI'; + $mysoc->country_id=21; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; + $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test10 CI'); @@ -313,17 +313,17 @@ class PricesTest extends PHPUnit_Framework_TestCase */ public function testUpdatePrice() { - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; - // Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode - $localobject=new Facture($this->savdb); + // Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen('nolines'); $invoiceid=$localobject->create($user); diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 742dca85590..c57ef426d0b 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -58,11 +58,11 @@ class ProductTest extends PHPUnit_Framework_TestCase * * @return ProductTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index 2779902cabd..faa533e2c00 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -59,7 +59,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase * * @return ProjectTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,13 +75,13 @@ class ProjectTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 81842063271..6a3d17d7806 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -58,7 +58,7 @@ class PropalTest extends PHPUnit_Framework_TestCase * * @return PropalTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class PropalTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index d1be0630e6d..f0d3efe34e6 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -62,9 +62,9 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase */ public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf = $conf; $this->savuser = $user; diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 153e4166b8e..39f924e7e04 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -62,7 +62,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index d7011d23e06..4e43a036c7e 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -70,7 +70,7 @@ class ScriptsTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -86,13 +86,13 @@ class ScriptsTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 263dc831ade..636fa923bc0 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -70,7 +70,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -86,8 +86,8 @@ class SecurityTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index c102d3467e1..11eb6711862 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -58,7 +58,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase * * @return SocieteTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index c284eb61178..14a63776444 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -61,9 +61,9 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase * * @return PropalTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -78,7 +78,7 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index ba78fdfd8db..e524b989172 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -57,7 +57,7 @@ class UserGroupTest extends PHPUnit_Framework_TestCase * * @return UserGroupTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index c4cfe63e9dc..b87dfd84494 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -57,7 +57,7 @@ class UserTest extends PHPUnit_Framework_TestCase * * @return UserTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/UtilsTest.php b/test/phpunit/UtilsTest.php index f2f44daa31d..58074af1c1f 100644 --- a/test/phpunit/UtilsTest.php +++ b/test/phpunit/UtilsTest.php @@ -57,9 +57,9 @@ class UtilsTest extends PHPUnit_Framework_TestCase * * @return UserTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index e916e3d5a89..fb8e36af6a1 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -67,7 +67,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index 2dc22eb2027..8b989df273f 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -61,7 +61,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index af329bd9de5..bdc3a15b2b9 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -61,7 +61,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index 1e80fd8f433..90147a429a4 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -68,7 +68,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 56425198e09..cb1f26d1980 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -68,9 +68,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 32a96434ac8..7ca0d9e8ee8 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -61,7 +61,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index bcc9ce0128c..4783bf4bc8f 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -57,7 +57,7 @@ class XCalLibTest extends PHPUnit_Framework_TestCase * * @return FilesLibTest */ - function __construct() + public function __construct() { parent::__construct(); From acb9cfe07ac2d13f1a1d7918bd5233adab4f0b38 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 25 Feb 2019 09:07:58 +0100 Subject: [PATCH 038/187] NEW: Add LinkedIn field --- htdocs/adherents/card.php | 23 +++++++++-- htdocs/adherents/class/adherent.class.php | 17 ++++++-- htdocs/admin/socialnetworks.php | 3 +- htdocs/contact/card.php | 24 +++++++++--- htdocs/contact/class/contact.class.php | 9 ++++- htdocs/contact/list.php | 29 +++++++++++--- htdocs/core/class/commonobject.class.php | 2 + htdocs/core/lib/functions.lib.php | 2 +- .../install/mysql/migration/9.0.0-10.0.0.sql | 7 +++- htdocs/install/mysql/tables/llx_adherent.sql | 1 + htdocs/install/mysql/tables/llx_societe.sql | 1 + htdocs/install/mysql/tables/llx_socpeople.sql | 1 + htdocs/install/mysql/tables/llx_user.sql | 1 + htdocs/societe/card.php | 33 ++++++++++++---- htdocs/societe/class/societe.class.php | 13 ++++++- htdocs/user/card.php | 39 ++++++++++++++++++- htdocs/user/class/user.class.php | 14 ++++++- 17 files changed, 185 insertions(+), 34 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b9a2d15c5cd..9903255e52f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -305,6 +305,7 @@ if (empty($reshook)) $object->skype = trim(GETPOST("skype", 'alpha')); $object->twitter = trim(GETPOST("twitter", 'alpha')); $object->facebook = trim(GETPOST("facebook", 'alpha')); + $object->linkedin = trim(GETPOST("linkedin", 'alpha')); $object->birth = $birthdate; $object->typeid = GETPOST("typeid", 'int'); @@ -450,6 +451,7 @@ if (empty($reshook)) $skype=GETPOST("member_skype", 'alpha'); $twitter=GETPOST("member_twitter", 'alpha'); $facebook=GETPOST("member_facebook", 'alpha'); + $linkedin=GETPOST("member_linkedin", 'alpha'); $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $login=GETPOST("member_login", 'alpha'); $pass=GETPOST("password", 'alpha'); @@ -479,6 +481,7 @@ if (empty($reshook)) $object->skype = $skype; $object->twitter = $twitter; $object->facebook = $facebook; + $object->linkedin = $linkedin; $object->email = $email; $object->login = $login; @@ -1029,6 +1032,12 @@ else print ''.$langs->trans("Facebook").''; } + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''.$langs->trans("LinkedIn").''; + } + // Birthday print "".$langs->trans("Birthday")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); @@ -1281,10 +1290,16 @@ else } // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").'facebook).'">'; - } + if (! empty($conf->socialnetworks->enabled)) + { + print ''.$langs->trans("Facebook").'facebook).'">'; + } + + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''.$langs->trans("LinkedIn").'linkedin).'">'; + } // Birthday print "".$langs->trans("Birthday")."\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 22429de9200..66ee5ee16f2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -137,6 +137,11 @@ class Adherent extends CommonObject */ public $facebook; + /** + * @var string linkedin account + */ + public $linkedin; + /** * @var string Phone number */ @@ -550,6 +555,7 @@ class Adherent extends CommonObject $sql.= ", skype = '".$this->db->escape($this->skype)."'"; $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; + $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); @@ -660,6 +666,7 @@ class Adherent extends CommonObject $luser->skype=$this->skype; $luser->twitter=$this->twitter; $luser->facebook=$this->facebook; + $luser->linkedin=$this->linkedin; $luser->office_phone=$this->phone; $luser->user_mobile=$this->phone_mobile; @@ -701,6 +708,7 @@ class Adherent extends CommonObject $lthirdparty->skype=$this->skype; $lthirdparty->twitter=$this->twitter; $lthirdparty->facebook=$this->facebook; + $lthirdparty->linkedin=$this->linkedin; $lthirdparty->phone=$this->phone; $lthirdparty->state_id=$this->state_id; $lthirdparty->country_id=$this->country_id; @@ -1189,7 +1197,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; - $sql.= " d.email, d.skype, d.twitter, d.facebook, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql.= " d.email, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.datec as datec,"; $sql.= " d.tms as datem,"; @@ -1266,6 +1274,7 @@ class Adherent extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->photo = $obj->photo; $this->statut = $obj->statut; @@ -2362,6 +2371,7 @@ class Adherent extends CommonObject $this->skype = 'skypepseudo'; $this->twitter = 'twitterpseudo'; $this->facebook = 'facebookpseudo'; + $this->linkedin = 'linkedinpseudo'; $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; @@ -2469,8 +2479,9 @@ class Adherent extends CommonObject if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; if ($this->twitter && ! empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; - if ($this->facebook && ! empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; - if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; + if ($this->facebook && ! empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; + if ($this->linkedin && ! empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; + if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index f723d13d540..8b7c061dc64 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -1,5 +1,6 @@ + * Copyright (C) 2019 Alexandre Spangaro * * 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 @@ -96,7 +97,7 @@ dol_fiche_head($head, 'setup', '', 0, 'user'); print '
'; -$arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook'); +$arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); foreach($arrayofsocialnetworks as $snkey => $snlabel) { $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 63704ab6bca..1eb9a13f877 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -189,6 +189,7 @@ if (empty($reshook)) $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); + $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = GETPOST("email", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); @@ -362,6 +363,7 @@ if (empty($reshook)) $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); + $object->linkedin = GETPOST("linkedin", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); @@ -698,6 +700,12 @@ else print ''; print 'facebook).'">'; } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''; + print 'linkedin.'">'; + } } // Visibility @@ -979,11 +987,17 @@ else print 'twitter).'">'; } // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print 'facebook).'">'; - } + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print 'facebook).'">'; + } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''; + print 'linkedin).'">'; + } } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 67b3900ec06..58204ae0c94 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -359,6 +359,7 @@ class Contact extends CommonObject $sql .= ", skype='".$this->db->escape($this->skype)."'"; $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; + $sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -455,6 +456,11 @@ class Contact extends CommonObject $tmpobj->facebook = $this->facebook; $usermustbemodified++; } + if ($tmpobj->linkedin != $this->linkedin) + { + $tmpobj->linkedin = $this->linkedin; + $usermustbemodified++; + } if ($usermustbemodified) { $result=$tmpobj->update($user, 0, 1, 1, 1); @@ -705,7 +711,7 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -779,6 +785,7 @@ class Contact extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 244dffcc0e1..6677e882860 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -70,6 +70,7 @@ $search_email=GETPOST("search_email", 'alpha'); $search_skype=GETPOST("search_skype", 'alpha'); $search_twitter=GETPOST("search_twitter", 'alpha'); $search_facebook=GETPOST("search_facebook", 'alpha'); +$search_linkedin=GETPOST("search_linkedin", 'alpha'); $search_priv=GETPOST("search_priv", 'alpha'); $search_categ=GETPOST("search_categ", 'int'); $search_categ_thirdparty=GETPOST("search_categ_thirdparty", 'int'); @@ -162,6 +163,7 @@ $arrayfields=array( 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), + 'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -224,6 +226,7 @@ if (empty($reshook)) $search_skype=""; $search_twitter=""; $search_facebook=""; + $search_linkedin=""; $search_priv=""; $search_status=-1; $search_categ=''; @@ -320,6 +323,7 @@ if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_twitter); if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook); +if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_linkedin); if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); @@ -624,6 +628,12 @@ if (! empty($arrayfields['p.facebook']['checked'])) print ''; print ''; } +if (! empty($arrayfields['p.linkedin']['checked'])) +{ + print ''; + print ''; + print ''; +} if (! empty($arrayfields['p.thirdparty']['checked'])) { print ''; @@ -696,6 +706,7 @@ if (! empty($arrayfields['p.email']['checked'])) print_liste_field if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); +if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, 'align="center"', $sortfield, $sortorder); // Extra fields @@ -843,12 +854,18 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Facebook - if (! empty($arrayfields['p.facebook']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->facebook, $obj->rowid, $obj->socid, 'facebook').''; } - if (! $i) $totalarray['nbfield']++; - } - // Company + if (! empty($arrayfields['p.facebook']['checked'])) + { + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->facebook, $obj->rowid, $obj->socid, 'facebook').''; } + if (! $i) $totalarray['nbfield']++; + } + // LinkedIn + if (! empty($arrayfields['p.linkedin']['checked'])) + { + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->linkedin, $obj->rowid, $obj->socid, 'linkedin').''; } + if (! $i) $totalarray['nbfield']++; + } + // Company if (! empty($arrayfields['p.thirdparty']['checked'])) { print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1f86d60598c..98b9d93580a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -672,6 +672,8 @@ abstract class CommonObject $outdone++; if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); $outdone++; + if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + $outdone++; } $out.=''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index be046ae889d..6826122b93b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2976,7 +2976,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'note', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', - 'jabber','skype','twitter','facebook' + 'jabber','skype','twitter','facebook','linkedin' ) )) { $fakey = $pictowithoutext; diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 1bac8ec18e6..e1d8cb69b78 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -94,4 +94,9 @@ ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; -ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); \ No newline at end of file +ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); + +ALTER TABLE llx_societe ADD COLUMN linkedin varchar(255) after whatsapp; +ALTER TABLE llx_socpeople ADD COLUMN linkedin varchar(255) after whatsapp; +ALTER TABLE llx_adherent ADD COLUMN linkedin varchar(255) after whatsapp; +ALTER TABLE llx_user ADD COLUMN linkedin varchar(255) after whatsapp; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index ede4de2e487..588fb323dae 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -51,6 +51,7 @@ create table llx_adherent skype varchar(255), twitter varchar(255), -- facebook varchar(255), -- + linkedin varchar(255), -- instagram varchar(255), -- snapchat varchar(255), -- googleplus varchar(255), -- diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 6225ae416e8..ed4919c3fc5 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -54,6 +54,7 @@ create table llx_societe skype varchar(255), -- twitter varchar(255), -- facebook varchar(255), -- + linkedin varchar(255), -- instagram varchar(255), -- snapchat varchar(255), -- googleplus varchar(255), -- diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql index 00456e3ece6..4ed401e39da 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.sql @@ -46,6 +46,7 @@ create table llx_socpeople skype varchar(255), twitter varchar(255), -- facebook varchar(255), -- + linkedin varchar(255), -- instagram varchar(255), -- snapchat varchar(255), -- googleplus varchar(255), -- diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 90dc8a835ef..ef00ae046af 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -58,6 +58,7 @@ create table llx_user skype varchar(255), twitter varchar(255), -- facebook varchar(255), -- + linkedin varchar(255), -- instagram varchar(255), -- snapchat varchar(255), -- googleplus varchar(255), -- diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index a8a41527af0..95dc554ef71 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -146,7 +146,7 @@ if (empty($reshook)) $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; $listofproperties=array( - 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'url', 'barcode', + 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', @@ -407,6 +407,7 @@ if (empty($reshook)) $object->skype = GETPOST('skype', 'alpha'); $object->twitter = GETPOST('twitter', 'alpha'); $object->facebook = GETPOST('facebook', 'alpha'); + $object->linkedin = GETPOST('linkedin', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); @@ -970,6 +971,7 @@ else $object->skype = GETPOST('skype', 'alpha'); $object->twitter = GETPOST('twitter', 'alpha'); $object->facebook = GETPOST('facebook', 'alpha'); + $object->linkedin = GETPOST('linkedin', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); @@ -1304,13 +1306,21 @@ else print ''; } // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; - print ''; - print 'facebook).'">'; - print ''; - } + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; + print ''; + print 'facebook).'">'; + print ''; + } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; + print ''; + print 'linkedin).'">'; + print ''; + } } // Phone / Fax @@ -1591,6 +1601,7 @@ else $object->skype = GETPOST('skype', 'alpha'); $object->twitter = GETPOST('twitter', 'alpha'); $object->facebook = GETPOST('facebook', 'alpha'); + $object->linkedin = GETPOST('linkedin', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); @@ -1916,6 +1927,12 @@ else print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; print ''; } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; + print ''; + } } // Phone / Fax diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4c964f591d0..3fb29a17db4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -203,6 +203,11 @@ class Societe extends CommonObject * @var string */ public $facebook; + /** + * LinkedIn username + * @var string + */ + public $linkedin; /** * Webpage * @var string @@ -848,6 +853,7 @@ class Societe extends CommonObject $this->skype = trim($this->skype); $this->twitter = trim($this->twitter); $this->facebook = trim($this->facebook); + $this->linkedin = trim($this->linkedin); $this->url = $this->url?clean_url($this->url, 0):''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); @@ -991,6 +997,7 @@ class Societe extends CommonObject $sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null"); $sql .= ",twitter = ".(! empty($this->twitter)?"'".$this->db->escape($this->twitter)."'":"null"); $sql .= ",facebook = ".(! empty($this->facebook)?"'".$this->db->escape($this->facebook)."'":"null"); + $sql .= ",linkedin = ".(! empty($this->linkedin)?"'".$this->db->escape($this->linkedin)."'":"null"); $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); @@ -1132,6 +1139,7 @@ class Societe extends CommonObject $lmember->skype=$this->skype; $lmember->twitter=$this->twitter; $lmember->facebook=$this->facebook; + $lmember->linkedin=$this->linkedin; $lmember->phone=$this->phone; $result=$lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates @@ -1235,7 +1243,7 @@ class Societe extends CommonObject $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; - $sql .= ', s.phone, s.fax, s.email, s.skype, s.twitter, s.facebook, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; + $sql .= ', s.phone, s.fax, s.email, s.skype, s.twitter, s.facebook, s.linkedin, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; $sql .= ', s.fk_typent as typent_id'; @@ -1332,6 +1340,7 @@ class Societe extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->url = $obj->url; $this->phone = $obj->phone; $this->fax = $obj->fax; @@ -3337,6 +3346,7 @@ class Societe extends CommonObject $this->skype=$member->skype; $this->twitter=$member->twitter; $this->facebook=$member->facebook; + $this->linkedin=$member->linkedin; $this->client = 1; // A member is a customer by default $this->code_client = ($customercode?$customercode:-1); @@ -3480,6 +3490,7 @@ class Societe extends CommonObject $this->skype='tom.hanson'; $this->twitter='tomhanson'; $this->facebook='tomhanson'; + $this->linkedin='tomhanson'; $this->url='http://www.specimen.com'; $this->phone='0909090901'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 859b2220b28..884faf33c3d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -214,6 +214,7 @@ if (empty($reshook)) { $object->skype = GETPOST("skype", 'alphanohtml'); $object->twitter = GETPOST("twitter", 'alphanohtml'); $object->facebook = GETPOST("facebook", 'alphanohtml'); + $object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); @@ -364,6 +365,7 @@ if (empty($reshook)) { $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); + $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature", 'none'); @@ -606,6 +608,7 @@ if (empty($reshook)) { $ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE]; $ldap_twitter = $attribute[$conf->global->LDAP_FIELD_TWITTER]; $ldap_facebook = $attribute[$conf->global->LDAP_FIELD_FACEBOOK]; + $ldap_linkedin = $attribute[$conf->global->LDAP_FIELD_LINKEDIN]; $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } @@ -1067,6 +1070,23 @@ if ($action == 'create' || $action == 'adduserldap') print ''; } + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''.$langs->trans("LinkedIn").''; + print ''; + if (! empty($ldap_linkedin)) + { + print ''; + print $ldap_linkedin; + } + else + { + print ''; + } + print ''; + } + // EMail print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; print ''; @@ -2287,7 +2307,7 @@ else print ''; } - // Skype + // Facebook if (! empty($conf->socialnetworks->enabled)) { print ''.$langs->trans("Facebook").''; @@ -2304,6 +2324,23 @@ else print ''; } + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''.$langs->trans("LinkedIn").''; + print ''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->linkedin; + } + print ''; + } + // EMail print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a6bc202d17f..ef6e2c23971 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -73,6 +73,7 @@ class User extends CommonObject public $skype; public $twitter; public $facebook; + public $linkedin; public $job; // job position public $signature; @@ -227,7 +228,7 @@ class User extends CommonObject $login=trim($login); // Get user - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.job, u.skype, u.twitter, u.facebook,"; + $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.job, u.skype, u.twitter, u.facebook, u.linkedin,"; $sql.= " u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; $sql.= " u.admin, u.login, u.note,"; @@ -335,6 +336,7 @@ class User extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; @@ -1252,6 +1254,7 @@ class User extends CommonObject $this->skype = $contact->skype; $this->twitter = $contact->twitter; $this->facebook = $contact->facebook; + $this->linkedin = $contact->linkedin; $this->office_phone = $contact->phone_pro; $this->office_fax = $contact->fax; $this->user_mobile = $contact->phone_mobile; @@ -1469,6 +1472,7 @@ class User extends CommonObject $this->skype = trim($this->skype); $this->twitter = trim($this->twitter); $this->facebook = trim($this->facebook); + $this->linkedin = trim($this->linkedin); $this->job = trim($this->job); $this->signature = trim($this->signature); @@ -1521,6 +1525,7 @@ class User extends CommonObject $sql.= ", skype = '".$this->db->escape($this->skype)."'"; $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; + $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1609,6 +1614,7 @@ class User extends CommonObject $adh->skype=$this->skype; $adh->twitter=$this->twitter; $adh->facebook=$this->facebook; + $adh->linkedin=$this->linkedin; $adh->phone=$this->office_phone; $adh->phone_mobile=$this->user_mobile; @@ -1661,6 +1667,7 @@ class User extends CommonObject $tmpobj->skype=$this->skype; $tmpobj->twitter=$this->twitter; $tmpobj->facebook=$this->facebook; + $tmpobj->linkedin=$this->linkedin; $tmpobj->phone_pro=$this->office_phone; $tmpobj->phone_mobile=$this->user_mobile; @@ -2528,7 +2535,8 @@ $mailfile = new CMailFile( 'LDAP_FIELD_SID' => 'ldap_sid', 'LDAP_FIELD_SKYPE' => 'skype', 'LDAP_FIELD_TWITTER' => 'twitter', - 'LDAP_FIELD_FACEBOOK' => 'facebook' + 'LDAP_FIELD_FACEBOOK' => 'facebook', + 'LDAP_FIELD_LINKEDIN' => 'linkedin' ); // Champs @@ -2642,6 +2650,7 @@ $mailfile = new CMailFile( $this->skype='skypepseudo'; $this->twitter='twitterpseudo'; $this->facebook='facebookpseudo'; + $this->linkedin='linkedinpseudo'; $this->office_phone='0999999999'; $this->office_fax='0999999998'; $this->user_mobile='0999999997'; @@ -2796,6 +2805,7 @@ $mailfile = new CMailFile( $this->skype=$ldapuser->{$conf->global->LDAP_FIELD_SKYPE}; $this->twitter=$ldapuser->{$conf->global->LDAP_FIELD_TWITTER}; $this->facebook=$ldapuser->{$conf->global->LDAP_FIELD_FACEBOOK}; + $this->linkedin=$ldapuser->{$conf->global->LDAP_FIELD_LINKEDIN}; $this->ldap_sid=$ldapuser->{$conf->global->LDAP_FIELD_SID}; $this->job=$ldapuser->{$conf->global->LDAP_FIELD_TITLE}; From 6fa016dc850cf293718cefc9b21d7ebddec4c725 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 25 Feb 2019 10:44:22 +0100 Subject: [PATCH 039/187] FIX wrong feature2 when user rights "group_advance" is used --- htdocs/user/group/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 1be76e8fb4d..fd497e6986a 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -35,12 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $canreadperms=($user->admin || $user->rights->user->user->lire); $caneditperms=($user->admin || $user->rights->user->user->creer); $candisableperms=($user->admin || $user->rights->user->user->supprimer); +$feature2 = 'user'; + // Advanced permissions if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms=($user->admin || $user->rights->user->group_advance->read); $caneditperms=($user->admin || $user->rights->user->group_advance->write); $candisableperms=($user->admin || $user->rights->user->group_advance->delete); + $feature2 = 'group_advance'; } // Load translation files required by page @@ -55,7 +58,7 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'groupcard' $userid = GETPOST('user', 'int'); // Security check -$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); +$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2); // Users/Groups management only in master entity if transverse mode if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) From c0be66b5e5c496b4f18ca7df2f62ab617f801735 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 14:55:29 +0100 Subject: [PATCH 040/187] FXI Remove duplicate record before trying to create unique key --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 8e9d82c5fd1..966058e88d7 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -266,8 +266,12 @@ CREATE TABLE llx_pos_cash_fence( UPDATE llx_const set name = 'PRELEVEMENT_END_TO_END' where name = 'END_TO_END'; UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD'; --- Delete duplicate accounting account not used +-- Delete duplicate accounting account, but only if not used +DROP TABLE tmp_llx_accouting_account; +CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; +--SELECT * from tmp_llx_accouting_account; +DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)) ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; From 1be1ee16709c7ff16ea99868c8e2e32636d760e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 14:56:28 +0100 Subject: [PATCH 041/187] Remove duplicate record --- htdocs/install/mysql/migration/repair.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 22409441eac..6a2fe099fdd 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -376,6 +376,16 @@ update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_ur drop table tmp_bank_url_expense_user; +-- Delete duplicate accounting account, but only if not used +DROP TABLE tmp_llx_accouting_account; +CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; +--SELECT * from tmp_llx_accouting_account; +DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)) + +ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; +ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); + + -- VMYSQL4.1 update llx_projet_task_time set task_datehour = task_date where task_datehour < task_date or task_datehour > DATE_ADD(task_date, interval 1 day); From 3ba69fc93a182ef3bba70256900f753b20fc3b28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 15:06:55 +0100 Subject: [PATCH 042/187] Fix missing ; after sql request --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 2 +- htdocs/install/mysql/migration/repair.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 966058e88d7..31689120cfc 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -271,7 +271,7 @@ UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD'; DROP TABLE tmp_llx_accouting_account; CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; --SELECT * from tmp_llx_accouting_account; -DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)) +DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)); ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 6a2fe099fdd..b678cab18b7 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -380,7 +380,7 @@ drop table tmp_bank_url_expense_user; DROP TABLE tmp_llx_accouting_account; CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; --SELECT * from tmp_llx_accouting_account; -DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)) +DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)); ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); From f6fc9190f373c14ad4f5bcf60ff2d4f83c44c870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Mon, 25 Feb 2019 19:41:40 +0100 Subject: [PATCH 043/187] Add no_email field in contact list Add no_email field in contact list --- htdocs/contact/list.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index aa27e43ee71..783c887efda 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Josep Lluís Amador * * 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 @@ -68,6 +69,7 @@ $search_phone_pro=GETPOST("search_phone_pro", 'alpha'); $search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); $search_fax=GETPOST("search_fax", 'alpha'); $search_email=GETPOST("search_email", 'alpha'); +$search_no_email=GETPOST("search_no_email",'int'); $search_skype=GETPOST("search_skype", 'alpha'); $search_twitter=GETPOST("search_twitter", 'alpha'); $search_facebook=GETPOST("search_facebook", 'alpha'); @@ -159,6 +161,7 @@ $arrayfields=array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'checked'=>1), + 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), 'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), @@ -222,6 +225,7 @@ if (empty($reshook)) $search_phone_mobile=""; $search_fax=""; $search_email=""; + $search_no_email=-1; $search_skype=""; $search_twitter=""; $search_facebook=""; @@ -258,7 +262,7 @@ $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,"; +$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email, p.skype,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields @@ -325,6 +329,7 @@ if (strlen($search_email)) $sql.= natural_search('p.email', $search_ema if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); +if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql.= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -422,6 +427,7 @@ if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($sea if ($search_phone_mobile != '') $param.='&search_phone_mobile='.urlencode($search_phone_mobile); if ($search_fax != '') $param.='&search_fax='.urlencode($search_fax); if ($search_email != '') $param.='&search_email='.urlencode($search_email); +if ($search_no_email != '') $param.='&search_no_email='.urlencode($search_no_email); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); @@ -607,6 +613,12 @@ if (! empty($arrayfields['p.email']['checked'])) print ''; print ''; } +if (! empty($arrayfields['p.no_email']['checked'])) +{ + print ''; + print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'),'1'=>$langs->trans('Yes')),$search_no_email); + print ''; +} if (! empty($arrayfields['p.skype']['checked'])) { print ''; @@ -696,6 +708,7 @@ if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); +if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'],$_SERVER["PHP_SELF"],"p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); @@ -839,7 +852,12 @@ while ($i < min($num, $limit)) print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18).''; if (! $i) $totalarray['nbfield']++; } - + // No EMail + if (! empty($arrayfields['p.no_email']['checked'])) + { + print ''.yn($obj->no_email).''; + if (! $i) $totalarray['nbfield']++; + } // Skype if (! empty($arrayfields['p.skype']['checked'])) { From 1c07006015b94f202a8a95795cd80ae8a3462b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 20:35:59 +0100 Subject: [PATCH 044/187] wip --- htdocs/api/class/api.class.php | 16 +- htdocs/api/class/api_access.class.php | 18 +- htdocs/api/class/api_documents.class.php | 28 +- htdocs/api/class/api_login.class.php | 10 +- htdocs/api/class/api_setup.class.php | 42 +- htdocs/api/class/api_status.class.php | 2 +- htdocs/asset/class/asset.class.php | 12 +- htdocs/asset/class/asset_type.class.php | 60 +- htdocs/bookmarks/class/bookmark.class.php | 12 +- htdocs/contrat/class/api_contracts.class.php | 278 +-- htdocs/contrat/class/contrat.class.php | 149 +- .../barcode/mod_barcode_product_standard.php | 36 +- .../modules/cheque/mod_chequereceipt_mint.php | 10 +- .../cheque/mod_chequereceipt_thyme.php | 8 +- .../modules/cheque/modules_chequereceipts.php | 18 +- .../modules/commande/mod_commande_marbre.php | 12 +- .../modules/commande/mod_commande_saphir.php | 10 +- .../modules/commande/modules_commande.php | 16 +- .../modules/contract/mod_contract_magre.php | 8 +- .../modules/contract/mod_contract_olive.php | 6 +- .../modules/contract/mod_contract_serpis.php | 12 +- .../modules/contract/modules_contract.php | 16 +- htdocs/core/modules/dons/modules_don.php | 16 +- htdocs/core/modules/modAccounting.class.php | 2 +- htdocs/core/modules/modAdherent.class.php | 154 +- htdocs/core/modules/modAgenda.class.php | 2 +- htdocs/core/modules/modApi.class.php | 2 +- htdocs/core/modules/modAsset.class.php | 26 +- htdocs/core/modules/modBanque.class.php | 2 +- htdocs/core/modules/modBarcode.class.php | 2 +- htdocs/core/modules/modBlockedLog.class.php | 174 +- htdocs/core/modules/modBookmark.class.php | 2 +- htdocs/core/modules/modCashDesk.class.php | 2 +- htdocs/core/modules/modCategorie.class.php | 2 +- htdocs/core/modules/modClickToDial.class.php | 2 +- htdocs/core/modules/modCollab.class.php | 84 +- htdocs/core/modules/modCommande.class.php | 2 +- htdocs/core/modules/modComptabilite.class.php | 2 +- htdocs/core/modules/modContrat.class.php | 2 +- htdocs/core/modules/modCron.class.php | 2 +- htdocs/core/modules/modDataPolicy.class.php | 8 +- htdocs/core/modules/modDeplacement.class.php | 2 +- .../modules/modDocumentGeneration.class.php | 2 +- htdocs/core/modules/modDon.class.php | 2 +- .../core/modules/modDynamicPrices.class.php | 2 +- htdocs/core/modules/modECM.class.php | 2 +- htdocs/core/modules/modExpedition.class.php | 2 +- .../core/modules/modExpenseReport.class.php | 2 +- htdocs/core/modules/modExport.class.php | 2 +- htdocs/core/modules/modExternalRss.class.php | 2 +- htdocs/core/modules/modExternalSite.class.php | 2 +- htdocs/core/modules/modFTP.class.php | 10 +- htdocs/core/modules/modFacture.class.php | 2 +- htdocs/core/modules/modFckeditor.class.php | 2 +- htdocs/core/modules/modFicheinter.class.php | 2 +- htdocs/core/modules/modFournisseur.class.php | 2 +- htdocs/core/modules/modGeoIPMaxmind.class.php | 2 +- htdocs/core/modules/modGravatar.class.php | 2 +- htdocs/core/modules/modHoliday.class.php | 2 +- htdocs/core/modules/modImport.class.php | 2 +- htdocs/core/modules/modIncoterm.class.php | 4 +- htdocs/core/modules/modLabel.class.php | 2 +- htdocs/core/modules/modLdap.class.php | 2 +- htdocs/core/modules/modLoan.class.php | 2 +- htdocs/core/modules/modMailing.class.php | 2 +- htdocs/core/modules/modMailmanSpip.class.php | 2 +- htdocs/core/modules/modMargin.class.php | 2 +- .../core/modules/modModuleBuilder.class.php | 2 +- .../core/modules/modMultiCurrency.class.php | 4 +- htdocs/core/modules/modNotification.class.php | 2 +- htdocs/core/modules/modOauth.class.php | 2 +- htdocs/core/modules/modOpenSurvey.class.php | 2 +- htdocs/core/modules/modPaybox.class.php | 2 +- htdocs/core/modules/modPaypal.class.php | 2 +- htdocs/core/modules/modPrelevement.class.php | 2 +- htdocs/core/modules/modPrinting.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modProductBatch.class.php | 2 +- htdocs/core/modules/modProjet.class.php | 2 +- htdocs/core/modules/modPropale.class.php | 2 +- .../core/modules/modReceiptPrinter.class.php | 2 +- htdocs/core/modules/modReception.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- .../core/modules/modSocialNetworks.class.php | 2 +- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/core/modules/modStock.class.php | 2 +- htdocs/core/modules/modStripe.class.php | 2 +- .../modules/modSupplierProposal.class.php | 8 +- htdocs/core/modules/modSyslog.class.php | 2 +- htdocs/core/modules/modTax.class.php | 2 +- htdocs/core/modules/modUser.class.php | 8 +- htdocs/core/modules/modWebServices.class.php | 2 +- .../modules/modWebServicesClient.class.php | 2 +- htdocs/core/modules/modWebsite.class.php | 2 +- htdocs/core/modules/modWorkflow.class.php | 2 +- htdocs/don/class/api_donations.class.php | 34 +- htdocs/don/class/donstats.class.php | 52 +- htdocs/don/class/paymentdonation.class.php | 36 +- .../class/emailcollector.class.php | 44 +- .../class/emailcollectoraction.class.php | 779 ++++---- .../class/emailcollectorfilter.class.php | 2 +- .../expedition/class/api_shipments.class.php | 124 +- .../class/api_expensereports.class.php | 154 +- .../class/expensereport.class.php | 82 +- .../class/expensereportstats.class.php | 16 +- .../class/paymentexpensereport.class.php | 81 +- htdocs/exports/class/export.class.php | 131 +- .../class/api_interventions.class.php | 140 +- htdocs/fichinter/class/fichinter.class.php | 80 +- .../fichinter/class/fichinterstats.class.php | 282 +-- htdocs/holiday/class/holiday.class.php | 66 +- htdocs/hrm/class/establishment.class.php | 20 +- .../class/api_supplier_proposals.class.php | 288 +-- .../class/supplier_proposal.class.php | 1634 ++++++++--------- htdocs/ticket/class/actions_ticket.class.php | 290 +-- htdocs/ticket/class/api_tickets.class.php | 80 +- htdocs/ticket/class/ticket.class.php | 458 ++--- htdocs/ticket/class/ticketstats.class.php | 6 +- htdocs/user/class/api_users.class.php | 39 +- htdocs/user/class/user.class.php | 226 ++- htdocs/user/class/userbankaccount.class.php | 86 +- htdocs/user/class/usergroup.class.php | 69 +- .../class/ProductAttributeValue.class.php | 2 +- htdocs/website/class/website.class.php | 64 +- htdocs/website/class/websitepage.class.php | 32 +- 125 files changed, 3394 insertions(+), 3402 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5595f94a950..c45d30c3a45 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -37,7 +37,7 @@ class DolibarrApi /** * @var Restler $r Restler object */ - var $r; + public $r; /** * Constructor @@ -46,7 +46,7 @@ class DolibarrApi * @param string $cachedir Cache dir * @param boolean $refreshCache Update cache */ - function __construct($db, $cachedir = '', $refreshCache = false) + public function __construct($db, $cachedir = '', $refreshCache = false) { global $conf, $dolibarr_main_url_root; @@ -94,7 +94,7 @@ class DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { // Remove $db object property for object @@ -222,7 +222,7 @@ class DolibarrApi * @return bool * @throws RestException */ - static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + private static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') { // Features/modules to check @@ -240,7 +240,7 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } /** * Return if a $sqlfilters parameter is valid @@ -248,7 +248,7 @@ class DolibarrApi * @param string $sqlfilters sqlfilter string * @return boolean True if valid, False if not valid */ - function _checkFilters($sqlfilters) + private function _checkFilters($sqlfilters) { //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); @@ -271,14 +271,14 @@ class DolibarrApi return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to forge a SQL criteria * * @param array $matches Array of found string by regex search * @return string Forged criteria. Example: "t.field like 'abc%'" */ - static function _forge_criteria_callback($matches) + private static function _forge_criteria_callback($matches) { // phpcs:enable global $db; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 9c748fb5f03..010bb854f25 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -173,20 +173,20 @@ class DolibarrApiAccess implements iAuthenticate * @example Digest * @example OAuth */ - public function __getWWWAuthenticateString() + public function __getWWWAuthenticateString() { // phpcs:enable return ''; } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ public static function verifyAccess(array $m) { $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8db471855d6..a946aa86333 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -43,7 +43,7 @@ class Documents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -67,7 +67,7 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file='') + public function index($module_part, $original_file = '') { global $conf, $langs; @@ -82,12 +82,11 @@ class Documents extends DolibarrApi $entity=$conf->entity; $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; + $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) - { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -127,7 +126,7 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='') + public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; @@ -153,7 +152,7 @@ class Documents extends DolibarrApi $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -245,7 +244,7 @@ class Documents extends DolibarrApi * * @url GET / */ - function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') + public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '') { global $conf; @@ -376,7 +375,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); } @@ -412,6 +411,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @return string * * @throws 200 * @throws 400 @@ -421,7 +421,7 @@ class Documents extends DolibarrApi * * @url POST /upload */ - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) { global $db, $conf; @@ -501,7 +501,7 @@ class Documents extends DolibarrApi if($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object.'); @@ -576,6 +576,7 @@ class Documents extends DolibarrApi return dol_basename($destfile); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -583,7 +584,8 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - function _validate_file($data) { + private function _validate_file($data) { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 43a0aeb9bbb..2bf464f7296 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -29,11 +29,11 @@ class Login /** * Constructor of the class */ - function __construct() + public function __construct() { - global $db; - $this->db = $db; - } + global $db; + $this->db = $db; + } /** * Login @@ -136,5 +136,5 @@ class Login 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 00a84a00555..766cf79f7be 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -38,7 +38,7 @@ class Setup extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,7 +61,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -76,7 +76,7 @@ class Setup extends DolibarrApi { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -128,7 +128,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') + public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') { $list = array(); @@ -195,7 +195,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCountryByID($id, $lang = '') + public function getCountryByID($id, $lang = '') { $country = new Ccountry($this->db); @@ -228,7 +228,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -279,7 +279,7 @@ class Setup extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -334,7 +334,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') + public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -397,7 +397,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') + public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -442,7 +442,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of currencies. * @@ -458,10 +458,10 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - //TODO link with multicurrency module + //TODO link with multicurrency module $sql = "SELECT t.code_iso, t.label, t.unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql.= " WHERE t.active = ".$active; @@ -516,7 +516,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') { $list = array(); @@ -595,7 +595,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') + public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -659,7 +659,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -720,7 +720,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -780,13 +780,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; // Add sql filters if ($sqlfilters) { @@ -840,13 +840,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; // Add sql filters @@ -898,7 +898,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCheckIntegrity($target) + public function getCheckIntegrity($target) { global $langs, $conf; diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 3ade4ea51b8..3e61b2e6d0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -31,7 +31,7 @@ class Status * * @return array */ - function index() + public function index() { global $conf; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index aca175b59d2..8e9e31e68b2 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -23,8 +23,6 @@ */ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Asset @@ -312,7 +310,7 @@ class Asset extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -369,12 +367,12 @@ class Asset extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -382,7 +380,7 @@ class Asset extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -425,7 +423,7 @@ class Asset extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 58baf280036..9cc96ae6c44 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -76,7 +76,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -89,8 +89,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error=0; @@ -157,7 +157,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -166,7 +166,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -233,7 +233,7 @@ class AssetType extends CommonObject * * @return int >0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -267,7 +267,7 @@ class AssetType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; @@ -282,13 +282,13 @@ class AssetType extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->label = $obj->label; - $this->accountancy_code_asset = $obj->accountancy_code_asset; - $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; - $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; - $this->note = $obj->note; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->label = $obj->label; + $this->accountancy_code_asset = $obj->accountancy_code_asset; + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; + $this->note = $obj->note; } return 1; @@ -300,13 +300,13 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -350,7 +350,7 @@ class AssetType extends CommonObject * 2=Return array of asset id only * @return mixed Array of asset or -1 on error */ - function listAssetForAssetType($excludefilter = '', $mode = 0) + public function listAssetForAssetType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -405,7 +405,7 @@ class AssetType extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -430,8 +430,8 @@ class AssetType extends CommonObject * * @return void */ - function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -446,15 +446,15 @@ class AssetType extends CommonObject $this->asset=array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index f66ef8e4d80..eb1342ad119 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -82,7 +82,7 @@ class Bookmark extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Bookmark extends CommonObject * @param int $id Bookmark Id Loader * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $conf; @@ -135,7 +135,7 @@ class Bookmark extends CommonObject * * @return int <0 si ko, rowid du bookmark cree si ok */ - function create() + public function create() { global $conf; @@ -192,7 +192,7 @@ class Bookmark extends CommonObject * * @return int <0 if KO, > if OK */ - function update() + public function update() { // Clean parameters $this->url=trim($this->url); @@ -227,7 +227,7 @@ class Bookmark extends CommonObject * @param int $id Id removed bookmark * @return int <0 si ko, >0 si ok */ - function remove($id) + public function remove($id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE rowid = ".$id; @@ -268,7 +268,7 @@ class Bookmark extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index b93c9db55d5..6f4a2041670 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -35,9 +35,9 @@ class Contracts extends DolibarrApi */ static $FIELDS = array( 'socid', - 'date_contrat', - 'commercial_signature_id', - 'commercial_suivi_id' + 'date_contrat', + 'commercial_signature_id', + 'commercial_suivi_id' ); /** @@ -48,10 +48,10 @@ class Contracts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->contract = new Contrat($this->db); } @@ -65,23 +65,23 @@ class Contracts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->contract->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->contract); + return $this->_cleanObjectDatas($this->contract); } @@ -99,9 +99,9 @@ class Contracts extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contract objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -136,7 +136,7 @@ class Contracts extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -175,7 +175,7 @@ class Contracts extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No contract found'); } - return $obj_ret; + return $obj_ret; } /** @@ -184,7 +184,7 @@ class Contracts extends DolibarrApi * @param array $request_data Request data * @return int ID of contrat */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Contracts extends DolibarrApi * * @return array */ - function getLines($id) + public function getLines($id) { if (! DolibarrApiAccess::$user->rights->contrat->lire) { throw new RestException(401); @@ -229,8 +229,8 @@ class Contracts extends DolibarrApi throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contract->getLinesArray(); $result = array(); @@ -250,21 +250,21 @@ class Contracts extends DolibarrApi * * @return int|bool */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->contract->addline( $request_data->desc, $request_data->subprice, @@ -274,16 +274,16 @@ class Contracts extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real - $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real + $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real + $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real $request_data->HT, - $request_data->subprice_excl_tax, - $request_data->info_bits, + $request_data->subprice_excl_tax, + $request_data->info_bits, $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit, - $request_data->rang + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit, + $request_data->rang ); if ($updateRes > 0) { @@ -303,20 +303,20 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contrat not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $request_data = (object) $request_data; @@ -328,12 +328,12 @@ class Contracts extends DolibarrApi $request_data->remise_percent, $request_data->date_ouveture_prevue, $request_data->date_fin_validite, - $request_data->tva_tx, + $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->date_ouverture, $request_data->date_cloture, - 'HT', + 'HT', $request_data->info_bits, $request_data->fk_fourn_price, $request_data->pa_ht, @@ -363,30 +363,30 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) + public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { - if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); + $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -401,32 +401,32 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function unactivateLine($id, $lineid, $datestart, $comment = null) + public function unactivateLine($id, $lineid, $datestart, $comment = null) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + $request_data = (object) $request_data; - $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); + $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -442,19 +442,19 @@ class Contracts extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of object @@ -465,7 +465,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(405, $this->contract->error); + throw new RestException(405, $this->contract->error); } } @@ -477,20 +477,20 @@ class Contracts extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->contract->$field = $value; @@ -502,7 +502,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(500, $this->contract->error); + throw new RestException(500, $this->contract->error); } } @@ -513,19 +513,19 @@ class Contracts extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->contrat->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (! $this->contract->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete contract : '.$this->contract->error); @@ -555,27 +555,27 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); - } + $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); + } return array( 'success' => array( @@ -601,34 +601,34 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contract not found'); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contract not found'); + } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already close'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); - } + $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already close'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' + ) + ); } @@ -639,7 +639,7 @@ class Contracts extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -666,7 +666,7 @@ class Contracts extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $contrat = array(); foreach (Contracts::$FIELDS as $field) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6e907699f22..405cfeca0b4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -188,7 +188,7 @@ class Contrat extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -199,7 +199,7 @@ class Contrat extends CommonObject * @param Societe $soc Thirdparty object * @return string free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $db, $langs, $conf; $langs->load("contracts"); @@ -250,7 +250,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -261,7 +261,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $line_id, $date, $date_end = '', $comment = '') + public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); @@ -274,7 +274,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -284,7 +284,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function close_line($user, $line_id, $date_end, $comment = '') + public function close_line($user, $line_id, $date_end, $comment = '') { // phpcs:enable $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); @@ -307,7 +307,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see closeAll */ - function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') + public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') { if (empty($date_start)) $date_start = dol_now(); @@ -363,7 +363,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see activateAll */ - function closeAll(User $user, $notrigger = 0, $comment = '') + public function closeAll(User $user, $notrigger = 0, $comment = '') { $this->db->begin(); @@ -419,7 +419,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function validate(User $user, $force_number = '', $notrigger = 0) + public function validate(User $user, $force_number = '', $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -547,7 +547,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $notrigger = 0) + public function reopen($user, $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -614,7 +614,7 @@ class Contrat extends CommonObject * @param string $ref_supplier Supplier ref * @return int <0 if KO, 0 if not found, Id of contract if OK */ - function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') + public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; @@ -665,7 +665,7 @@ class Contrat extends CommonObject $this->user_author_id = $obj->fk_user_author; - $this->commercial_signature_id = $obj->fk_commercial_signature; + $this->commercial_signature_id = $obj->fk_commercial_signature; $this->commercial_suivi_id = $obj->fk_commercial_suivi; $this->note_private = $obj->note_private; @@ -678,7 +678,7 @@ class Contrat extends CommonObject $this->socid = $obj->fk_soc; $this->fk_soc = $obj->fk_soc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); @@ -711,14 +711,14 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->nbofserviceswait=0; @@ -768,7 +768,7 @@ class Contrat extends CommonObject while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result); $line = new ContratLigne($this->db); $line->id = $objp->rowid; @@ -829,7 +829,7 @@ class Contrat extends CommonObject // fetch optionals attributes and labels $line->fetch_optionals(); - $this->lines[$pos] = $line; + $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; //dol_syslog("1 ".$line->desc); @@ -869,7 +869,7 @@ class Contrat extends CommonObject * @param User $user User that create * @return int <0 if KO, id of contract if OK */ - function create($user) + public function create($user) { global $conf,$langs,$mysoc; @@ -1088,7 +1088,7 @@ class Contrat extends CommonObject * @param User $user Utilisateur qui supprime * @return int < 0 si erreur, > 0 si ok */ - function delete($user) + public function delete($user) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -1242,7 +1242,7 @@ class Contrat extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1360,7 +1360,7 @@ class Contrat extends CommonObject * @param string $rang Position * @return int <0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; $error=0; @@ -1570,7 +1570,7 @@ class Contrat extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) { global $user, $conf, $langs, $mysoc; @@ -1647,21 +1647,21 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='" . price2num($price)."'"; - $sql.= ",subprice='" . price2num($subprice)."'"; - $sql.= ",remise='" . price2num($remise)."'"; + $sql.= ",price_ht='".price2num($price)."'"; + $sql.= ",subprice='".price2num($subprice)."'"; + $sql.= ",remise='".price2num($remise)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='". price2num($tvatx)."'"; - $sql.= ",localtax1_tx='". price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='". price2num($localtax2tx)."'"; + $sql.= ",tva_tx='".price2num($tvatx)."'"; + $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='". price2num($total_ht)."'"; - $sql.= ", total_tva='". price2num($total_tva)."'"; + $sql.= ", total_ht='".price2num($total_ht)."'"; + $sql.= ", total_tva='".price2num($total_tva)."'"; $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='". price2num($total_ttc)."'"; + $sql.= ", total_ttc='".price2num($total_ttc)."'"; $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } @@ -1733,7 +1733,7 @@ class Contrat extends CommonObject * @param User $user User that delete * @return int >0 if OK, <0 if KO */ - function deleteline($idline, User $user) + public function deleteline($idline, User $user) { global $conf, $langs; @@ -1792,7 +1792,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1800,7 +1800,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @deprecated This function will never be used. Status of a contract is status of its lines. */ - function update_statut($user) + public function update_statut($user) { // phpcs:enable dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); @@ -1811,11 +1811,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); -// $newstatut=1; -// foreach($this->lines as $key => $contractline) -// { -// // if ($contractline) // Loop on each service -// } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1827,7 +1827,7 @@ class Contrat extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } @@ -1840,7 +1840,7 @@ class Contrat extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1872,8 +1872,7 @@ class Contrat extends CommonObject elseif ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; - if ($mode == 4) - { + if ($mode == 4) { $text =''; $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $text.=' '.$langs->trans("Services"); @@ -1909,7 +1908,7 @@ class Contrat extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -1973,7 +1972,7 @@ class Contrat extends CommonObject * @param int $id id du contrat a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql.= " c.tms as date_modification,"; @@ -2022,7 +2021,7 @@ class Contrat extends CommonObject * @param int $statut Status of lines to get * @return array Array of line's rowid */ - function array_detail($statut = -1) + public function array_detail($statut = -1) { // phpcs:enable $tab=array(); @@ -2059,7 +2058,7 @@ class Contrat extends CommonObject * @param string $option 'all' or 'others' * @return array Array of contracts id */ - function getListOfContracts($option = 'all') + public function getListOfContracts($option = 'all') { $tab=array(); @@ -2092,7 +2091,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2100,7 +2099,7 @@ class Contrat extends CommonObject * @param string $mode "inactive" pour services a activer, "expired" pour services expires * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $langs; @@ -2172,13 +2171,13 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2223,7 +2222,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -2233,7 +2232,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts prestation */ - function getIdServiceContact() + public function getIdServiceContact() { return $this->getIdContact('external', 'SERVICE'); } @@ -2245,9 +2244,9 @@ class Contrat extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { global $user,$langs,$conf; // Load array of products prodids @@ -2319,7 +2318,7 @@ class Contrat extends CommonObject * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -2382,7 +2381,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - function createFromClone($socid = 0, $notrigger = 0) + public function createFromClone($socid = 0, $notrigger = 0) { global $db, $user, $langs, $conf, $hookmanager, $extrafields; @@ -2631,7 +2630,7 @@ class ContratLigne extends CommonObjectLine * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -2643,12 +2642,12 @@ class ContratLigne extends CommonObjectLine * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2658,7 +2657,7 @@ class ContratLigne extends CommonObjectLine * @param string $moreatt More attribute * @return string Libelle */ - static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') + public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') { // phpcs:enable global $langs; @@ -2720,7 +2719,7 @@ class ContratLigne extends CommonObjectLine * @param int $maxlength Max length * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0) + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; @@ -2741,13 +2740,13 @@ class ContratLigne extends CommonObjectLine } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id object - * @param string $ref Ref of contract - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $ref Ref of contract + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters @@ -2879,7 +2878,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs, $mysoc; @@ -3070,14 +3069,14 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); @@ -3188,7 +3187,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3198,7 +3197,7 @@ class ContratLigne extends CommonObjectLine * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $date, $date_end = '', $comment = '') + public function active_line($user, $date, $date_end = '', $comment = '') { // phpcs:enable global $langs, $conf; @@ -3247,7 +3246,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -3257,7 +3256,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '', $notrigger = 0) + public function close_line($user, $date_end, $comment = '', $notrigger = 0) { // phpcs:enable global $langs, $conf; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 239a1683fad..936e7b87be4 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -61,7 +61,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -77,7 +77,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -119,7 +119,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $objproduct Object product * @return string Return string example */ - function getExample($langs, $objproduct = 0) + public function getExample($langs, $objproduct = 0) { $examplebarcode = $this->getNextValue($objproduct, ''); if (! $examplebarcode) @@ -142,7 +142,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objproduct = null, $type = '') + public function getNextValue($objproduct = null, $type = '') { global $db,$conf; @@ -184,7 +184,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $thirdparty_type, $type) + public function verif($db, &$code, $product, $thirdparty_type, $type) { global $conf; @@ -235,7 +235,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a code is used (by other element) * @@ -244,7 +244,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $product Objet product * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; @@ -269,7 +269,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a barcode value match syntax * @@ -277,7 +277,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $typefortest Type of barcode (ISBN, EAN, ...) * @return int 0 if OK, <0 if KO */ - function verif_syntax($codefortest, $typefortest) + public function verif_syntax($codefortest, $typefortest) { // phpcs:enable global $conf; @@ -296,15 +296,15 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode $newcodefortest=$codefortest; - // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test - if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask - { - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) - { - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); - dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); - } - } + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test + if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask + { + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) + { + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } + } $result=check_value($mask, $newcodefortest); if (is_string($result)) diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 0bdf6f0fc91..e696f086269 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -50,7 +50,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -62,7 +62,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -74,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -109,7 +109,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -153,7 +153,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index c978dbaa0f3..c33699a1a27 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -49,7 +49,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -89,7 +89,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -112,7 +112,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -141,7 +141,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index d13384805d5..29fd071200a 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -46,7 +46,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -56,7 +56,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -68,7 +68,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -80,7 +80,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -127,7 +127,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -135,7 +135,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -154,7 +154,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator /** - * Cree un bordereau remise de cheque + * Cree un bordereau remise de cheque * * @param DoliDB $db Database handler * @param int $id Object invoice (or id of invoice) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e888905b3be..b0b462e96dc 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -60,7 +60,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index bfe853996ce..373f1e01200 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -62,7 +62,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +128,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -151,7 +151,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -159,7 +159,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 6090ad35028..e0a0e454861 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; abstract class ModelePDFCommandes extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ abstract class ModeleNumRefCommandes * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -104,7 +104,7 @@ abstract class ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefCommandes * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index db7689d7855..2eb0e03ec63 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -59,7 +59,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $conf,$langs; @@ -95,7 +95,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -118,7 +118,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 799bd297633..c1a395c4439 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -66,7 +66,7 @@ class mod_contract_olive extends ModelNumRefContracts * * @return string Description of module */ - function info() + public function info() { global $langs; @@ -81,7 +81,7 @@ class mod_contract_olive extends ModelNumRefContracts * @param Contrat $contract Object contract * @return string Return next value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return ''; @@ -101,7 +101,7 @@ class mod_contract_olive extends ModelNumRefContracts * -3 ErrorProductCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 2106463107e..2f644f2762f 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -61,7 +61,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -73,7 +73,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -153,7 +153,7 @@ class mod_contract_serpis extends ModelNumRefContracts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -161,7 +161,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 0c126459436..9cbc2092979 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -43,7 +43,7 @@ abstract class ModelePDFContract extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -51,7 +51,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ class ModelNumRefContracts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ class ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("contracts"); @@ -104,7 +104,7 @@ class ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("contracts"); @@ -116,7 +116,7 @@ class ModelNumRefContracts * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ class ModelNumRefContracts * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ class ModelNumRefContracts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index adda4dce750..9957bf4f326 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -39,7 +39,7 @@ abstract class ModeleDon extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,7 +47,7 @@ abstract class ModeleDon extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefDons * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefDons * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefDons * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefDons * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -123,7 +123,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -134,7 +134,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 2a4ff0fc42e..ea247d3b5f9 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -37,7 +37,7 @@ class modAccounting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 6cf5e45c7f2..763ec1a1370 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -38,23 +38,23 @@ class modAdherent extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $conf; + global $conf; $this->db = $db; $this->numero = 310; $this->family = "hr"; $this->module_position = '55'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Management of members of a foundation or association"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='user'; @@ -67,9 +67,9 @@ class modAdherent extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->langfiles = array("members","companies"); $this->phpmin = array(5,4); // Minimum version of PHP required by module @@ -248,9 +248,9 @@ class modAdherent extends DolibarrModules $this->rights[$r][5] = 'creer'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -269,36 +269,36 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', - 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", - 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", - 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', - 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', - 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' - ); + 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', + 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", + 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", + 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', + 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', + 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' + ); $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", - 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", - 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', - 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' - ); + 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", + 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", + 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', + 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' + ); $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', - 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", - 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", - 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', - 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' - ); + 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', + 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", + 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", + 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', + 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' + ); // Add extra fields $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add axtra fields + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -317,54 +317,54 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", - 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", - 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", - 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' - ); - // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( - 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', - 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", + "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", + 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", + 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", + 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' + ); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r]=array( + 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', + 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array( - 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', - 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', - 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", - 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') - ); + 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', + 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', + 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", + 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') + ); // Cronjobs $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0=>array( - 'label'=>'SendReminderForExpiredSubscriptionTitle', - 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', - 'objectname'=>'Adherent', - 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10;0', - 'comment'=>'SendReminderForExpiredSubscription', - 'frequency'=>1, - 'unitfrequency'=> 3600 * 24, - 'priority'=>50, - 'status'=>1, - 'test'=>'$conf->adherent->enabled', - 'datestart'=>$datestart - ), + 0=>array( + 'label'=>'SendReminderForExpiredSubscriptionTitle', + 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', + 'objectname'=>'Adherent', + 'method'=>'sendReminderForExpiredSubscription', + 'parameters'=>'10;0', + 'comment'=>'SendReminderForExpiredSubscription', + 'frequency'=>1, + 'unitfrequency'=> 3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->adherent->enabled', + 'datestart'=>$datestart + ), ); } diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index fc2c173d90c..20b3c74ee40 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -43,7 +43,7 @@ class modAgenda extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 8bfec6a1734..0ed62e76627 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -38,7 +38,7 @@ class modApi extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index d7464c8ac0e..b162fabc559 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -313,22 +313,22 @@ class modAsset extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - global $conf; + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 08dcd61351d..b578b783ace 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -41,7 +41,7 @@ class modBanque extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 7c4fcd78bf1..8f2023b4a36 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -39,7 +39,7 @@ class modBarcode extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 55; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0ed248f00ab..1ef90f8cc3f 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modBlockedLog extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs, $conf, $mysoc; + global $langs, $conf, $mysoc; $this->db = $db; $this->numero = 3200; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'blockedlog'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "base"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '75'; @@ -67,10 +67,10 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- - $this->hidden = false; // A condition to disable module - $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->hidden = false; // A condition to disable module + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array('blockedlog'); $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) @@ -81,24 +81,24 @@ class modBlockedLog extends DolibarrModules // enable this module. /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) { - $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); - $this->automatic_activation = array(); - foreach($tmp as $key) - { - $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; - } + $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); + $this->automatic_activation = array(); + foreach($tmp as $key) + { + $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; + } }*/ //var_dump($this->automatic_activation); $this->always_enabled = (!empty($conf->blockedlog->enabled) - && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) - && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed(1)); + && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) + && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + && $this->alreadyUsed(1)); // Constants //----------- $this->const = array( - 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) + 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) ); // New pages on tabs @@ -148,9 +148,9 @@ class modBlockedLog extends DolibarrModules function alreadyUsed() { - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $b=new BlockedLog($this->db); - return $b->alreadyUsed(1); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + $b=new BlockedLog($this->db); + return $b->alreadyUsed(1); } @@ -164,87 +164,87 @@ class modBlockedLog extends DolibarrModules */ function init($options = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_SET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_SET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - $res = $b->create($user); - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + $res = $b->create($user); + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_init($sql, $options); + return $this->_init($sql, $options); } /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ function remove($options = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_RESET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_RESET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - if ($b->alreadyUsed(1)) - { - $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error - } - else - { - $res = $b->create($user); - } - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + if ($b->alreadyUsed(1)) + { + $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error + } + else + { + $res = $b->create($user); + } + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_remove($sql, $options); + return $this->_remove($sql, $options); } } diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 38da9a62059..0717236a1bb 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -38,7 +38,7 @@ class modBookmark extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 330; diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ed1a4485152..5a809302ea4 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -35,7 +35,7 @@ class modCashDesk extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 82d0d9d8289..b61ab34f05d 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -37,7 +37,7 @@ class modCategorie extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modClickToDial.class.php b/htdocs/core/modules/modClickToDial.class.php index 6e8ad1d3041..a25b0fd4571 100644 --- a/htdocs/core/modules/modClickToDial.class.php +++ b/htdocs/core/modules/modClickToDial.class.php @@ -38,7 +38,7 @@ class modClickToDial extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 58; diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 1e1db01f616..62de6a62b0c 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -32,33 +32,33 @@ class modCollab extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs,$conf; + global $langs,$conf; $this->db = $db; $this->numero = 30000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "portal"; $this->module_position = '51'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. $this->picto='globe'; - // Data directories to create when module is enabled - $this->dirs = array("/collab/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/collab/temp"); // Config pages //------------- @@ -66,15 +66,15 @@ class modCollab extends DolibarrModules // Dependancies //------------- - $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module - $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module + $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array("collab"); // Constants //----------- - $this->const = array(); + $this->const = array(); // New pages on tabs // ----------------- @@ -84,42 +84,42 @@ class modCollab extends DolibarrModules //------ $this->boxes = array(); - // Permissions - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'collab'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'collab'; + $r=0; - /*$this->rights[$r][0] = 30001; - $this->rights[$r][1] = 'Read website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; - $r++; + /*$this->rights[$r][0] = 30001; + $this->rights[$r][1] = 'Read website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + $r++; - $this->rights[$r][0] = 30002; - $this->rights[$r][1] = 'Create/modify website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'write'; - $r++; + $this->rights[$r][0] = 30002; + $this->rights[$r][1] = 'Create/modify website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $r++; - $this->rights[$r][0] = 30003; - $this->rights[$r][1] = 'Delete website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delete'; - $r++;*/ + $this->rights[$r][0] = 30003; + $this->rights[$r][1] = 'Delete website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++;*/ // Main menu entries $r=0; $this->menu[$r]=array( 'fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Left menu entry - 'titre'=>'Collab', + 'type'=>'top', // This is a Left menu entry + 'titre'=>'Collab', 'mainmenu'=>'collab', - 'url'=>'/collab/index.php', - 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + 'url'=>'/collab/index.php', + 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; } } diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 63e2fe4bf88..631f80c1075 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -43,7 +43,7 @@ class modCommande extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index 226292537f5..cf30480a8df 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -40,7 +40,7 @@ class modComptabilite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8bcc645d3ba..628ca6183f5 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -39,7 +39,7 @@ class modContrat extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 31d27abac0b..f07ddeaeaae 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -37,7 +37,7 @@ class modCron extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs, $conf; diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 5dfc0fb83dd..be88c709090 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -210,15 +210,15 @@ class modDataPolicy extends DolibarrModules { */ public function init($options = '') { - global $langs; + global $langs; - $this->_load_tables('/datapolicy/sql/'); + $this->_load_tables('/datapolicy/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - /* + /* // Extrafield contact $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); @@ -239,7 +239,7 @@ class modDataPolicy extends DolibarrModules { $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0); $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0); - */ + */ $sql = array(); diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ce2a8056e48..c48aaf44449 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -37,7 +37,7 @@ class modDeplacement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 455c28914da..99c7e0ffbdf 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -39,7 +39,7 @@ class modDocumentGeneration extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 1520; diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index bb27b309c1d..c9cd7c417e4 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -40,7 +40,7 @@ class modDon extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 700; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 6e915afc6f8..708f0fb86a7 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -36,7 +36,7 @@ class modDynamicPrices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2200; diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 602bc37a03c..0208541d2e2 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -37,7 +37,7 @@ class modECM extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 443146d13a4..1aa04bb18c8 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -41,7 +41,7 @@ class modExpedition extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index d715cb119ca..977ded085c2 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -36,7 +36,7 @@ class modExpenseReport extends DolibarrModules * * @param Database $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index b0d95137316..d636772caff 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -38,7 +38,7 @@ class modExport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 240; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index e384bccbcba..7925a6c4369 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -38,7 +38,7 @@ class modExternalRss extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 0a720579eda..6cbd7141af8 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -39,7 +39,7 @@ class modExternalSite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index a54cbc24963..699617cd99e 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modFTP extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index c8e29205306..80a3fe5f8c6 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -40,7 +40,7 @@ class modFacture extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 873aba7eb30..7085fbef000 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -39,7 +39,7 @@ class modFckeditor extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2000; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index de2d40490c0..ed2add33648 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -42,7 +42,7 @@ class modFicheinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 3510834a836..55f9adfb0d8 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -39,7 +39,7 @@ class modFournisseur extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index 0b090abfa80..91c82e713db 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -37,7 +37,7 @@ class modGeoIPMaxmind extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2900; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 9dbf4ee124f..bfff235bdae 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -36,7 +36,7 @@ class modGravatar extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 01a70a429ad..09a30e16914 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -41,7 +41,7 @@ class modHoliday extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index e7d47763013..2f5c8c77db8 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -38,7 +38,7 @@ class modImport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 250; diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 9d07028c5dd..8cae0980ff7 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -38,8 +38,8 @@ class modIncoterm extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index c0f02229f2b..0bbddb6adc7 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -38,7 +38,7 @@ class modLabel extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 60; diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index a2a355060d1..b2a290fe46a 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -37,7 +37,7 @@ class modLdap extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 200; diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 43a2876ef79..8bd5d194068 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -37,7 +37,7 @@ class modLoan extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index bbcd651d453..b978b8cb214 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -39,7 +39,7 @@ class modMailing extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 22; diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 2c4123fc3fa..ecae27155b5 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -38,7 +38,7 @@ class modMailmanSpip extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 105; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 22124404673..f5b79570c1a 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -35,7 +35,7 @@ class modMargin extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 94d307ae522..59b3dcde2ce 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -35,7 +35,7 @@ class modModuleBuilder extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 32bd1bd5980..e3f37c5f284 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -38,8 +38,8 @@ class modMultiCurrency extends DolibarrModules * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs, $conf; $this->db = $db; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 54698dca703..c3ccca4ef46 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -36,7 +36,7 @@ class modNotification extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 600; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 27310e9c84e..ec12a6a2c6c 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -40,7 +40,7 @@ class modOauth extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 66000; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index a47a2791b60..c4e7e8b8338 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -37,7 +37,7 @@ class modOpenSurvey extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 6349d5474b3..635c428f3fa 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -36,7 +36,7 @@ class modPayBox extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index a4aa8fcc6b0..99ef4dd45de 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -37,7 +37,7 @@ class modPaypal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index f18bf1bf03c..475d3a1b24b 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -40,7 +40,7 @@ class modPrelevement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index bb8a2be6120..09992bd176d 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -40,7 +40,7 @@ class modPrinting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 64000; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4c6c420aa50..4a0af38dc34 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -42,7 +42,7 @@ class modProduct extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index f5e8fc6324c..be5952c35f5 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -38,7 +38,7 @@ class modProductBatch extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index eeca1e8883f..b50ad86e1e8 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -41,7 +41,7 @@ class modProjet extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index a2a32241065..c297cef47ec 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -41,7 +41,7 @@ class modPropale extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 6d00acb2d16..51313d5b1db 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -40,7 +40,7 @@ class modReceiptPrinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 67000; diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 663a854f7a5..f4d191c472e 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -36,7 +36,7 @@ class modReception extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2e3ed91bf06..eb1b55000b9 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -40,7 +40,7 @@ class modService extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index b7e1bfd44a3..d8d8d8fb76e 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -36,7 +36,7 @@ class modSocialNetworks extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b879959946d..f618236911b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -41,7 +41,7 @@ class modSociete extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index fa283c58137..153634f795e 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -40,7 +40,7 @@ class modStock extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index a2b2a68127a..ae15e763fd8 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -36,7 +36,7 @@ class modStripe extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 3d580fa439c..882b02b5fb4 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -42,7 +42,7 @@ class modSupplierProposal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -57,10 +57,10 @@ class modSupplierProposal extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='supplier_proposal'; - + // Data directories to create when module is enabled. $this->dirs = array(); - + // Config pages. Put here list of php page names stored in admin directory used to setup module. $this->config_page_url = array("supplier_proposal.php"); @@ -206,7 +206,7 @@ class modSupplierProposal extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index a291b7977ee..1ac6ead1087 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -37,7 +37,7 @@ class modSyslog extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 42; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index a2f51ef0cc1..56983bbb207 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -41,7 +41,7 @@ class modTax extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index bef84b3a157..baf7f94d0f4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -38,7 +38,7 @@ class modUser extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -331,8 +331,8 @@ class modUser extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Permissions @@ -341,5 +341,5 @@ class modUser extends DolibarrModules $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 9d32b03df79..2aa98e80679 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -35,7 +35,7 @@ class modWebServices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2600; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 6ec7bb5aae9..33c7bae997a 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -35,7 +35,7 @@ class modWebServicesClient extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2660; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 4fd6cd2976f..3fd1166b171 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -36,7 +36,7 @@ class modWebsite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 955165ffd80..5c1a2163537 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -37,7 +37,7 @@ class modWorkflow extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 6e38b67d2f1..8d722e31a0f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -44,10 +44,10 @@ class Donations extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->don = new Don($this->db); } @@ -61,7 +61,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); @@ -99,7 +99,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class Donations extends DolibarrApi $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; - + // Add sql filters if ($sqlfilters) { @@ -140,7 +140,7 @@ class Donations extends DolibarrApi dol_syslog("API Rest request"); $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -164,7 +164,7 @@ class Donations extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No donation found'); } - + return $obj_ret; } @@ -174,15 +174,15 @@ class Donations extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->don->creer) { + if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->don->$field = $value; } /*if (isset($request_data["lines"])) { @@ -208,7 +208,7 @@ class Donations extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -222,7 +222,7 @@ class Donations extends DolibarrApi if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->don->$field = $value; } @@ -243,7 +243,7 @@ class Donations extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); @@ -291,7 +291,7 @@ class Donations extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -332,7 +332,7 @@ class Donations extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +354,7 @@ class Donations extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $don = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 2418f1babfd..bf6a61bb248 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -39,12 +39,12 @@ class DonationStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class DonationStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -77,13 +77,13 @@ class DonationStats extends Stats } /** - * Return shipment number by month for a year + * Return shipment number by month for a year * - * @param int $year Year to scan - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with number by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -104,7 +104,7 @@ class DonationStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -117,21 +117,21 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index deec339c1cc..ac35e3f5c44 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -88,7 +88,7 @@ class PaymentDonation extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -101,7 +101,7 @@ class PaymentDonation extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, id of payment if OK */ - function create($user, $notrigger = false) + public function create($user, $notrigger = false) { global $conf, $langs; @@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -264,7 +264,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -344,7 +344,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -411,7 +411,7 @@ class PaymentDonation extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -467,12 +467,12 @@ class PaymentDonation extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -480,13 +480,13 @@ class PaymentDonation extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable global $langs; - return ''; - } + return ''; + } /** @@ -496,7 +496,7 @@ class PaymentDonation extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -526,7 +526,7 @@ class PaymentDonation extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -597,14 +597,14 @@ class PaymentDonation extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between the donation payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -629,7 +629,7 @@ class PaymentDonation extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7a4744d789f..e0f745dabec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -99,22 +99,22 @@ class EmailCollector extends CommonObject 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), - //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), - //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), + //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), + //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), - //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), - //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), + //'date_validation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) ); @@ -305,14 +305,16 @@ class EmailCollector extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - /*public function fetchLines() - { - $this->lines=array(); + /* + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -407,7 +409,7 @@ class EmailCollector extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -549,7 +551,7 @@ class EmailCollector extends CommonObject */ public function info($id) { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' WHERE t.rowid = '.$id; @@ -673,7 +675,7 @@ class EmailCollector extends CommonObject * * @return string */ - function getConnectStringIMAP() + public function getConnectStringIMAP() { // Connect to IMAP $flags ='/service=imap'; // IMAP diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 6eec6190b71..d49c28716cf 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -32,298 +32,301 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; */ class EmailCollectorAction extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'emailcollectoraction'; + /** + * @var string ID to identify managed object + */ + public $element = 'emailcollectoraction'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'emailcollector_emailcollectoraction'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'emailcollector_emailcollectoraction'; - /** - * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - */ - public $ismultientitymanaged = 0; + /** + * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; - /** - * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; + /** + * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; - /** - * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png - */ - public $picto = 'emailcollectoraction@emailcollector'; + /** + * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png + */ + public $picto = 'emailcollectoraction@emailcollector'; - /** - * 'type' if the field format. - * 'label' the translation key. - * 'enabled' is a condition when the field must be managed. - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'default' is a default value for creation (can still be replaced by the global setup of default values) - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' is the CSS style to use on field. For example: 'maxwidth200' - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") - */ + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ - // BEGIN MODULEBUILDER PROPERTIES - /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. - */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), - 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), - 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), - 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), - ); - public $rowid; - public $fk_emailcollector; - public $type; - public $actionparam; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $position; - public $import_key; - public $status; - // END MODULEBUILDER PROPERTIES + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), + 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), + 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), + ); + public $rowid; + public $fk_emailcollector; + public $type; + public $actionparam; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $position; + public $import_key; + public $status; + // END MODULEBUILDER PROPERTIES - // If this object has a subtable with lines + // If this object has a subtable with lines - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'emailcollectoractiondet'; + // /** + // * @var int Name of subtable line + // */ + //public $table_element_line = 'emailcollectoractiondet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_emailcollectoraction'; + // /** + // * @var int Field with ID of parent key if this field has a parent + // */ + //public $fk_element = 'fk_emailcollectoraction'; - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'EmailcollectorActionline'; + // /** + // * @var int Name of subtable class that manage subtable lines + // */ + //public $class_element_line = 'EmailcollectorActionline'; - /** - * @var array Array of child tables (child tables to delete before deleting a record) - */ - //protected $childtables=array('emailcollectoractiondet'); + // /** + // * @var array Array of child tables (child tables to delete before deleting a record) + // */ + //protected $childtables=array('emailcollectoractiondet'); - /** - * @var EmailcollectorActionLine[] Array of subtable lines - */ - //public $lines = array(); + // /** + // * @var EmailcollectorActionLine[] Array of subtable lines + // */ + //public $lines = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs, $user; + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; - $this->db = $db; + $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; - // Unset fields that are disabled - foreach($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { - unset($this->fields[$key]); - } - } + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } - // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) - { - if (is_array($this->fields['status']['arrayofkeyval'])) - { - foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) - { - $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); - } - } - } - } + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - global $langs; - if (empty($this->type)) - { - $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); - return -1; - } + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } - return $this->createCommon($user, $notrigger); - } + return $this->createCommon($user, $notrigger); + } - /** - * Clone and object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $object = new self($this->db); + $object = new self($this->db); - $this->db->begin(); + $this->db->begin(); - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $thi /** + * @var EmailcollectorActionLine[] Array of subtable lines + */ + s->error = $object->error; + $this->errors = $object->errors; + } - unset($object->context['createfromclone']); + unset($object->context['createfromclone']); - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); - return $result; - } + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailcollectorActionLine + // Load lines with object EmailcollectorActionLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + }*/ - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) * @param int $notooltip 1=Disable tooltip * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -340,10 +343,10 @@ class EmailCollectorAction extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -366,152 +369,152 @@ class EmailCollectorAction extends CommonObject } else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('emailcollectoractiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('emailcollectoractiondao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Return label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("emailcollector"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("emailcollector"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - } + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } - /** - * Charge les informations d'ordre info dans l'objet commande - * - * @param int $id Id of order - * @return void - */ - public function info($id) - { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->initAsSpecimenCommon(); - } + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index e0556bf865b..d46dfb1c9ae 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -296,7 +296,7 @@ class EmailCollectorFilter extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 4f8d1ac0301..73923105c7d 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -48,8 +48,8 @@ class Shipments extends DolibarrApi */ public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->shipment = new Expedition($this->db); } @@ -65,21 +65,21 @@ class Shipments extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->shipment->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->shipment); + return $this->_cleanObjectDatas($this->shipment); } @@ -97,7 +97,7 @@ class Shipments extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of shipment objects * - * @throws RestException + * @throws RestException */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -134,7 +134,7 @@ class Shipments extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -173,7 +173,7 @@ class Shipments extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No shipment found'); } - return $obj_ret; + return $obj_ret; } /** @@ -378,30 +378,30 @@ class Shipments extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->creer) { + throw new RestException(401); + } - $result = $this->shipment->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Shipment not found'); - } + $result = $this->shipment->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $request_data = (object) $request_data; - $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } - else - { - throw new RestException(405, $this->shipment->error); - } + $request_data = (object) $request_data; + $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } + else + { + throw new RestException(405, $this->shipment->error); + } } /** @@ -423,9 +423,9 @@ class Shipments extends DolibarrApi throw new RestException(404, 'Shipment not found'); } - if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->shipment->$field = $value; @@ -437,7 +437,7 @@ class Shipments extends DolibarrApi } else { - throw new RestException(500, $this->shipment->error); + throw new RestException(500, $this->shipment->error); } } @@ -451,16 +451,16 @@ class Shipments extends DolibarrApi public function delete($id) { if(! DolibarrApiAccess::$user->rights->shipment->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->shipment->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting shipment : '.$this->shipment->error); @@ -496,23 +496,23 @@ class Shipments extends DolibarrApi public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if ( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); + $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); } $result = $this->shipment->fetch($id); if ( ! $result ) { @@ -608,7 +608,7 @@ class Shipments extends DolibarrApi $this->shipment->fetchObjectLinked(); return $this->_cleanObjectDatas($this->shipment); } - */ + */ /** * Clean sensible object datas @@ -634,15 +634,15 @@ class Shipments extends DolibarrApi { foreach ($object->lines as $line) { - unset($line->tva_tx); - unset($line->vat_src_code); - unset($line->total_ht); - unset($line->total_ttc); - unset($line->total_tva); - unset($line->total_localtax1); - unset($line->total_localtax2); - unset($line->remise_percent); - } + unset($line->tva_tx); + unset($line->vat_src_code); + unset($line->total_ht); + unset($line->total_ttc); + unset($line->total_tva); + unset($line->total_localtax1); + unset($line->total_localtax2); + unset($line->remise_percent); + } } return $object; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 02e1021a141..35ce9f9a4a2 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -45,7 +45,7 @@ class ExpenseReports extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -59,26 +59,26 @@ class ExpenseReports extends DolibarrApi * * @param int $id ID of Expense Report * @return array|mixed Data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->expensereport->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->expensereport); + return $this->_cleanObjectDatas($this->expensereport); } /** @@ -94,7 +94,7 @@ class ExpenseReports extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of Expense Report objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class ExpenseReports extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -152,7 +152,7 @@ class ExpenseReports extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No Expense Report found'); } - return $obj_ret; + return $obj_ret; } /** @@ -161,7 +161,7 @@ class ExpenseReports extends DolibarrApi * @param array $request_data Request data * @return int ID of Expense Report */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); @@ -195,8 +195,8 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function getLines($id) + /* + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expensereport->lire) { throw new RestException(401); @@ -217,7 +217,7 @@ class ExpenseReports extends DolibarrApi } return $result; } -*/ + */ /** * Add a line to given Expense Report @@ -229,22 +229,22 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function postLine($id, $request_data = null) + /* + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->expensereport->addline( $request_data->desc, $request_data->subprice, @@ -279,7 +279,7 @@ class ExpenseReports extends DolibarrApi } return false; } -*/ + */ /** * Update a line to given Expense Report @@ -293,22 +293,22 @@ class ExpenseReports extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->updateline( + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( $lineid, $request_data->desc, $request_data->subprice, @@ -330,16 +330,16 @@ class ExpenseReports extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit - ); + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; } - */ + */ /** * Delete a line of given Expense Report @@ -352,19 +352,19 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of ojbect @@ -385,7 +385,7 @@ class ExpenseReports extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); @@ -407,11 +407,11 @@ class ExpenseReports extends DolibarrApi if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { - throw new RestException(500, $this->expensereport->error); - } + } + else + { + throw new RestException(500, $this->expensereport->error); + } } /** @@ -421,19 +421,19 @@ class ExpenseReports extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense Report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); @@ -463,19 +463,19 @@ class ExpenseReports extends DolibarrApi * } */ /* - function validate($id, $idwarehouse=0) + public function validate($id, $idwarehouse=0) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { throw new RestException(500, 'Error when validate expensereport'); @@ -495,17 +495,17 @@ class ExpenseReports extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; + return $object; } /** @@ -515,7 +515,7 @@ class ExpenseReports extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $expensereport = array(); foreach (ExpenseReports::$FIELDS as $field) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8dc0cbcdcf8..9df4596a8d6 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -44,62 +44,62 @@ class ExpenseReport extends CommonObject */ public $table_element='expensereport'; - var $table_element_line = 'expensereport_det'; - var $fk_element = 'fk_expensereport'; - var $picto = 'trip'; + public $table_element_line = 'expensereport_det'; + public $fk_element = 'fk_expensereport'; + public $picto = 'trip'; - var $lines=array(); + public $lines=array(); public $date_debut; public $date_fin; - var $status; - var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied - var $fk_c_paiement; - var $paid; + public $status; + public $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + public $fk_c_paiement; + public $paid; - var $user_author_infos; - var $user_validator_infos; + public $user_author_infos; + public $user_validator_infos; - var $fk_typepayment; - var $num_payment; - var $code_paiement; - var $code_statut; + public $fk_typepayment; + public $num_payment; + public $code_paiement; + public $code_statut; // ACTIONS // Create - var $date_create; - var $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. + public $date_create; + public $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. // Update - var $date_modif; - var $fk_user_modif; + public $date_modif; + public $fk_user_modif; // Refus - var $date_refuse; - var $detail_refuse; - var $fk_user_refuse; + public $date_refuse; + public $detail_refuse; + public $fk_user_refuse; // Annulation - var $date_cancel; - var $detail_cancel; - var $fk_user_cancel; + public $date_cancel; + public $detail_cancel; + public $fk_user_cancel; - var $fk_user_validator; // User that is defined to approve + public $fk_user_validator; // User that is defined to approve // Validation - var $date_valid; // User making validation - var $fk_user_valid; - var $user_valid_infos; + public $date_valid; // User making validation + public $fk_user_valid; + public $user_valid_infos; // Approve - var $date_approve; - var $fk_user_approve; // User that has approved + public $date_approve; + public $fk_user_approve; // User that has approved // Paiement - var $user_paid_infos; + public $user_paid_infos; /* END ACTIONS @@ -2484,17 +2484,17 @@ class ExpenseReportLine public $projet_ref; public $projet_title; - var $vatrate; - var $total_ht; - var $total_tva; - var $total_ttc; + public $vatrate; + public $total_ht; + public $total_tva; + public $total_ttc; /** * Constructor * * @param DoliDB $db Handlet database */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2505,7 +2505,7 @@ class ExpenseReportLine * @param int $rowid Id of object to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet, fde.date,'; $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; @@ -2557,7 +2557,7 @@ class ExpenseReportLine * @param bool $fromaddline false=keep default behavior, true=exclude the update_price() of parent object * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $fromaddline = false) + public function insert($notrigger = 0, $fromaddline = false) { global $langs,$user,$conf; @@ -2679,7 +2679,7 @@ class ExpenseReportLine * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function update($fuser) + public function update($fuser) { global $fuser,$langs,$conf; @@ -2758,7 +2758,6 @@ class ExpenseReportLine } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retourne la liste deroulante des differents etats d'une note de frais. * Les valeurs de la liste sont les id de la table c_expensereport_statuts @@ -2771,7 +2770,6 @@ class ExpenseReportLine */ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) { - // phpcs:enable global $db, $langs; $tmpep=new ExpenseReport($db); @@ -2796,7 +2794,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u print ''; } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of types of notes with select value = id * @@ -2808,7 +2805,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u */ function select_type_fees_id($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) { - // phpcs:enable global $db,$langs,$user; $langs->load("trips"); diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 0eec447d997..082e3ce016e 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -50,7 +50,7 @@ class ExpenseReportStats extends Stats * @param int $userid Id user for filter * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf, $user; @@ -89,7 +89,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -107,7 +107,7 @@ class ExpenseReportStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -129,7 +129,7 @@ class ExpenseReportStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -149,7 +149,7 @@ class ExpenseReportStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -166,7 +166,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; @@ -174,6 +174,6 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 655c148069e..f731638ea1d 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -92,7 +92,7 @@ class PaymentExpenseReport extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentExpenseReport extends CommonObject * @param User $user User making payment * @return int <0 if KO, id of payment if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -113,8 +113,7 @@ class PaymentExpenseReport extends CommonObject $now=dol_now(); // Validate parameters - if (! $this->datepaid) - { + if (! $this->datepaid) { $this->error='ErrorBadValueForParameterCreatePaymentExpenseReport'; return -1; } @@ -184,10 +183,10 @@ class PaymentExpenseReport extends CommonObject /** * Load object in memory from database * - * @param int $id Id object + * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -258,7 +257,7 @@ class PaymentExpenseReport extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -266,7 +265,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); @@ -341,11 +340,11 @@ class PaymentExpenseReport extends CommonObject /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -370,13 +369,16 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $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 (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -386,8 +388,8 @@ class PaymentExpenseReport extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -415,7 +417,7 @@ class PaymentExpenseReport extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -444,11 +446,6 @@ class PaymentExpenseReport extends CommonObject $error++; } - if (! $error) - { - - } - unset($object->context['createfromclone']); // End @@ -471,12 +468,12 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -484,13 +481,13 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable - global $langs; + global $langs; - return ''; - } + return ''; + } /** @@ -500,7 +497,7 @@ class PaymentExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -530,7 +527,7 @@ class PaymentExpenseReport extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $langs,$conf; @@ -631,14 +628,14 @@ class PaymentExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between the expense report payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -659,11 +656,11 @@ class PaymentExpenseReport extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -691,8 +688,8 @@ class PaymentExpenseReport extends CommonObject * @param int $id Payment id * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT e.rowid, e.datec, e.fk_user_creat, e.fk_user_modif, e.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as e'; $sql.= ' WHERE e.rowid = '.$id; @@ -718,7 +715,7 @@ class PaymentExpenseReport extends CommonObject $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); @@ -727,5 +724,5 @@ class PaymentExpenseReport extends CommonObject { dol_print_error($this->db); } - } + } } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index a964f5f373a..5b7205247ac 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -35,28 +35,28 @@ class Export */ public $db; - var $array_export_code=array(); // Tableau de "idmodule_numlot" - var $array_export_module=array(); // Tableau de "nom de modules" - var $array_export_label=array(); // Tableau de "libelle de lots" - var $array_export_sql_start=array(); // Tableau des "requetes sql" - var $array_export_sql_end=array(); // Tableau des "requetes sql" - var $array_export_sql_order=array(); // Tableau des "requetes sql" + public $array_export_code=array(); // Tableau de "idmodule_numlot" + public $array_export_module=array(); // Tableau de "nom de modules" + public $array_export_label=array(); // Tableau de "libelle de lots" + public $array_export_sql_start=array(); // Tableau des "requetes sql" + public $array_export_sql_end=array(); // Tableau des "requetes sql" + public $array_export_sql_order=array(); // Tableau des "requetes sql" - var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter - var $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre - var $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer - var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter - var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export - var $array_export_special=array(); // Tableau des operations speciales sur champ - var $array_export_examplevalues=array(); // array with examples + public $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter + public $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre + public $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer + public $array_export_entities=array(); // Tableau des listes de champ+alias a exporter + public $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export + public $array_export_special=array(); // Tableau des operations speciales sur champ + public $array_export_examplevalues=array(); // array with examples - // To store export modules - var $hexa; - var $hexafiltervalue; - var $datatoexport; - var $model_name; + // To store export modules + public $hexa; + public $hexafiltervalue; + public $datatoexport; + public $model_name; - var $sqlusedforexport; + public $sqlusedforexport; /** @@ -64,13 +64,13 @@ class Export * * @param DoliDB $db Database handler */ - function __construct($db) - { - $this->db=$db; - } + public function __construct($db) + { + $this->db=$db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load an exportable dataset * @@ -78,12 +78,12 @@ class Export * @param string $filter Load a particular dataset only * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') - { + public function load_arrays($user, $filter = '') + { // phpcs:enable - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc; - dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); + dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); $i=0; @@ -209,7 +209,7 @@ class Export } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the sql export request. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -219,8 +219,8 @@ class Export * @param array $array_filterValue Filter records on array of value for fields * @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..." */ - function build_sql($indice, $array_selected, $array_filterValue) - { + public function build_sql($indice, $array_selected, $array_filterValue) + { // phpcs:enable // Build the sql request $sql=$this->array_export_sql_start[$indice]; @@ -273,7 +273,7 @@ class Export return $sql; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the conditionnal string from filter the query * @@ -282,8 +282,8 @@ class Export * @param string $ValueField Value of the field for filter. Must not be '' * @return string sql string of then field ex : "field='xxx'>" */ - function build_filterQuery($TypeField, $NameField, $ValueField) - { + public function build_filterQuery($TypeField, $NameField, $ValueField) + { // phpcs:enable //print $TypeField." ".$NameField." ".$ValueField; $InfoFieldList = explode(":", $TypeField); @@ -352,21 +352,21 @@ class Export } /** - * conditionDate + * conditionDate * * @param string $Field Field operand 1 * @param string $Value Value operand 2 * @param string $Sens Comparison operator * @return string */ - function conditionDate($Field, $Value, $Sens) - { + public function conditionDate($Field, $Value, $Sens) + { // TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; return $Condition; - } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** @@ -377,8 +377,8 @@ class Export * @param string $ValueField Initial value of the field to filter * @return string html string of the input field ex : "" */ - function build_filterField($TypeField, $NameField, $ValueField) - { + public function build_filterField($TypeField, $NameField, $ValueField) + { // phpcs:enable global $conf,$langs; @@ -488,15 +488,15 @@ class Export } return $szFilterField; - } + } - /** - * Build an input field used to filter the query + /** + * Build an input field used to filter the query * * @param string $TypeField Type of Field to filter * @return string html string of the input field ex : "" */ - function genDocFilter($TypeField) + public function genDocFilter($TypeField) { global $langs; @@ -523,7 +523,7 @@ class Export return $szMsg; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build export file. * File is built into directory $conf->export->dir_temp.'/'.$user->id @@ -537,8 +537,8 @@ class Export * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) * @return int <0 if KO, >0 if OK */ - function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') - { + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + { // phpcs:enable global $conf,$langs; @@ -698,7 +698,7 @@ class Export * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -741,11 +741,11 @@ class Export /** * Load an export profil from database * - * @param int $id Id of profil to load - * @return int <0 if KO, >0 if OK + * @param int $id Id of profil to load + * @return int <0 if KO, >0 if OK */ - function fetch($id) - { + public function fetch($id) + { $sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter'; $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em'; $sql.= ' WHERE em.rowid = '.$id; @@ -757,12 +757,12 @@ class Export $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->model_name = $obj->label; - $this->datatoexport = $obj->type; + $this->id = $obj->rowid; + $this->model_name = $obj->label; + $this->datatoexport = $obj->type; - $this->hexa = $obj->field; - $this->hexafiltervalue = $obj->filter; + $this->hexa = $obj->field; + $this->hexafiltervalue = $obj->filter; return 1; } @@ -787,7 +787,7 @@ class Export * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -835,15 +835,15 @@ class Export } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output list all export models * TODO Move this into a class htmlxxx.class.php * * @return void */ - function list_export_model() - { + public function list_export_model() + { // phpcs:enable global $conf, $langs; @@ -886,9 +886,8 @@ class Export $i++; } - } - else { - dol_print_error($this->db); - } - } + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 26173db12af..6ceb56d1a84 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -55,10 +55,10 @@ class Interventions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->fichinter = new Fichinter($this->db); } @@ -72,23 +72,23 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention report not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention report not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->fichinter->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->fichinter); + $this->fichinter->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->fichinter); } /** @@ -106,7 +106,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -141,7 +141,7 @@ class Interventions extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -169,7 +169,7 @@ class Interventions extends DolibarrApi $obj = $db->fetch_object($result); $fichinter_static = new Fichinter($db); if($fichinter_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); } $i++; } @@ -180,7 +180,7 @@ class Interventions extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No finchinter found'); } - return $obj_ret; + return $obj_ret; } /** @@ -189,7 +189,7 @@ class Interventions extends DolibarrApi * @param array $request_data Request data * @return int ID of intervention */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,28 +218,28 @@ class Interventions extends DolibarrApi * @return int */ /* TODO - function getLines($id) + public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->fichinter->getLinesArray(); - $result = array(); - foreach ($this->fichinter->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; } - */ + */ /** * Add a line to given intervention @@ -251,7 +251,7 @@ class Interventions extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -292,30 +292,30 @@ class Interventions extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { - throw new RestException(401); - } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + throw new RestException(401); + } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); - } + if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Intervention deleted' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Intervention deleted' + ) + ); } /** @@ -333,7 +333,7 @@ class Interventions extends DolibarrApi * * @return array */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -369,7 +369,7 @@ class Interventions extends DolibarrApi * * @return array */ - function closeFichinter($id) + public function closeFichinter($id) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { @@ -406,7 +406,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $fichinter = array(); foreach (Interventions::$FIELDS as $field) { @@ -424,16 +424,16 @@ class Interventions extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts); - return $object; + return $object; } /** @@ -444,7 +444,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validateLine($data) + private function _validateLine($data) { $fichinter = array(); foreach (Interventions::$FIELDSLINE as $field) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 97ecffacf95..6db992b4e22 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -122,7 +122,7 @@ class Fichinter extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -135,7 +135,7 @@ class Fichinter extends CommonObject * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -179,7 +179,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -313,7 +313,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { if (! is_numeric($this->duration)) { $this->duration = 0; @@ -373,7 +373,7 @@ class Fichinter extends CommonObject * @param string $ref Ref of intervention * @return int <0 if KO, >0 if OK */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; $sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; @@ -407,15 +407,15 @@ class Fichinter extends CommonObject $this->datet = $this->db->jdate($obj->datet); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); - $this->fk_project = $obj->fk_projet; - $this->note_public = $obj->note_public; + $this->fk_project = $obj->fk_projet; + $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; - $this->modelpdf = $obj->model_pdf; - $this->fk_contrat = $obj->fk_contrat; + $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; - $this->user_creation= $obj->fk_user_author; + $this->user_creation = $obj->fk_user_author; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -447,7 +447,7 @@ class Fichinter extends CommonObject * @param User $user User that set draft * @return int <0 if KO, >0 if OK */ - function setDraft($user) + public function setDraft($user) { global $langs, $conf; @@ -483,7 +483,7 @@ class Fichinter extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -595,7 +595,7 @@ class Fichinter extends CommonObject * * @return float Amount */ - function getAmount() + public function getAmount() { global $db; @@ -653,12 +653,12 @@ class Fichinter extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -666,7 +666,7 @@ class Fichinter extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable // Init/load array of translation of status @@ -716,7 +716,7 @@ class Fichinter extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $hookmanager; @@ -782,7 +782,7 @@ class Fichinter extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for intervention */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("interventions"); @@ -838,7 +838,7 @@ class Fichinter extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -897,7 +897,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1010,7 +1010,7 @@ class Fichinter extends CommonObject * @param date $date_delivery date of delivery * @return int <0 if ko, >0 if ok */ - function set_date_delivery($user, $date_delivery) + public function set_date_delivery($user, $date_delivery) { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define the label of the intervention * @@ -1044,7 +1044,7 @@ class Fichinter extends CommonObject * @param string $description description * @return int <0 if KO, >0 if OK */ - function set_description($user, $description) + public function set_description($user, $description) { // phpcs:enable global $conf; @@ -1071,7 +1071,7 @@ class Fichinter extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link intervention to a contract * @@ -1079,8 +1079,8 @@ class Fichinter extends CommonObject * @param int $contractid Description * @return int <0 if ko, >0 if ok */ - function set_contrat($user, $contractid) - { + public function set_contrat($user, $contractid) + { // phpcs:enable global $conf; @@ -1112,7 +1112,7 @@ class Fichinter extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1205,7 +1205,7 @@ class Fichinter extends CommonObject * @param array $array_options Array option * @return int >0 if ok, <0 if ko */ - function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') + public function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); @@ -1249,7 +1249,7 @@ class Fichinter extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -1280,14 +1280,14 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines ->lines * * @return int <0 if KO, >0 if OK */ - function fetch_lines() - { + public function fetch_lines() + { // phpcs:enable $this->lines = array(); @@ -1395,7 +1395,7 @@ class FichinterLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -1406,7 +1406,7 @@ class FichinterLigne extends CommonObjectLine * @param int $rowid Line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,'; $sql.= ' ft.date as datei'; @@ -1443,7 +1443,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function insert($user, $notrigger = 0) + public function insert($user, $notrigger = 0) { global $langs,$conf; @@ -1539,7 +1539,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf; @@ -1600,13 +1600,13 @@ class FichinterLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total duration into llx_fichinter * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable global $conf; @@ -1660,7 +1660,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int >0 if ok, <0 if ko */ - function deleteline($user, $notrigger = 0) + public function deleteline($user, $notrigger = 0) { global $langs,$conf; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 80d7e6107c8..7112f6cdf77 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -33,181 +33,181 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FichinterStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param string $mode Option ('customer', 'supplier') - * @param int $userid Id user for filter (creation user) - */ - function __construct($db, $socid, $mode, $userid = 0) - { - global $user, $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. + * @param string $mode Option ('customer', 'supplier') + * @param int $userid Id user for filter (creation user) + */ + public function __construct($db, $socid, $mode, $userid = 0) + { + global $user, $conf; - $this->db = $db; + $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; + $this->cachefilesuffix = $mode; - $this->where.= " c.entity = ".$conf->entity; - if ($mode == 'customer') - { - $object=new Fichinter($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='0'; - $this->field_line='0'; - //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled - } - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($this->socid) - { - $this->where.=" AND c.fk_soc = ".$this->socid; - } + $this->where.= " c.entity = ".$conf->entity; + if ($mode == 'customer') + { + $object=new Fichinter($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field='0'; + $this->field_line='0'; + //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled + } + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($this->socid) + { + $this->where.=" AND c.fk_soc = ".$this->socid; + } if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; - } + } - /** - * Return intervention number by month for a year - * - * @param int $year Year to scan + /** + * Return intervention number by month for a year + * + * @param int $year Year to scan * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with number by month - */ - function getNbByMonth($year, $format = 0) - { - global $user; + * @return array Array with number by month + */ + public function getNbByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + return $res; + } - /** - * Return interventions number per year - * - * @return array Array with number by year - * - */ - function getNbByYear() - { - global $user; + /** + * Return interventions number per year + * + * @return array Array with number by year + * + */ + public function getNbByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the intervention amount by month for a year - * - * @param int $year Year to scan + /** + * Return the intervention amount by month for a year + * + * @param int $year Year to scan * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with amount by month - */ - function getAmountByMonth($year, $format = 0) - { - global $user; + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + return $res; + } - /** - * Return the intervention amount average by month for a year - * - * @param int $year year for stats - * @return array array with number by month - */ - function getAverageByMonth($year) - { - global $user; + /** + * Return the intervention amount average by month for a year + * + * @param int $year year for stats + * @return array array with number by month + */ + public function getAverageByMonth($year) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } - /** - * Return nb, amount of predefined product for year - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAllByProduct($year) - { - global $user; + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAllByProduct($year) + { + global $user; - $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; + $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; + $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); - } + return $this->_getAllByProduct($sql); + } } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 078fcb2c59d..b914666011d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -149,7 +149,7 @@ class Holiday extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -162,7 +162,7 @@ class Holiday extends CommonObject * @param Societe $objsoc third party object * @return string Holiday free reference */ - function getNextNumRef($objsoc) + public function getNextNumRef($objsoc) { global $langs, $conf; $langs->load("order"); @@ -221,7 +221,7 @@ class Holiday extends CommonObject * * @return int <0 if KO, >0 if OK */ - function updateBalance() + public function updateBalance() { $this->db->begin(); @@ -250,7 +250,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error=0; @@ -336,7 +336,7 @@ class Holiday extends CommonObject * @param string $ref Ref object * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -420,7 +420,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchByUser($user_id, $order = '', $filter = '') + public function fetchByUser($user_id, $order = '', $filter = '') { global $langs, $conf; @@ -548,7 +548,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchAll($order, $filter) + public function fetchAll($order, $filter) { global $langs; @@ -674,7 +674,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function validate($user = null, $notrigger = 0) + public function validate($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -745,7 +745,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function approve($user = null, $notrigger = 0) + public function approve($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -858,7 +858,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -972,7 +972,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1030,7 +1030,7 @@ class Holiday extends CommonObject * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). * @see verifDateHolidayForTimestamp */ - function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) + public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) { $this->fetchByUser($fk_user, '', ''); @@ -1112,7 +1112,7 @@ class Holiday extends CommonObject * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') + public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') { global $langs, $conf; @@ -1175,7 +1175,7 @@ class Holiday extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -1211,7 +1211,7 @@ class Holiday extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode, $this->date_debut); } @@ -1225,7 +1225,7 @@ class Holiday extends CommonObject * @param date $startdate Date holiday should start * @return string Label */ - function LibStatut($statut, $mode = 0, $startdate = '') + public function LibStatut($statut, $mode = 0, $startdate = '') { // phpcs:enable global $langs; @@ -1290,7 +1290,7 @@ class Holiday extends CommonObject * @param string $htmlname Name of HTML select field * @return string Show select of status */ - function selectStatutCP($selected = '', $htmlname = 'select_statut') + public function selectStatutCP($selected = '', $htmlname = 'select_statut') { global $langs; @@ -1324,7 +1324,7 @@ class Holiday extends CommonObject * @param string $value vrai si mise à jour OK sinon faux * @return boolean ok or ko */ - function updateConfCP($name, $value) + public function updateConfCP($name, $value) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1348,7 +1348,7 @@ class Holiday extends CommonObject * @param string $createifnotfound 'stringvalue'=Create entry with string value if not found. For example 'YYYYMMDDHHMMSS'. * @return string Value of parameter. Example: 'YYYYMMDDHHMMSS' or < 0 if error */ - function getConfCP($name, $createifnotfound = '') + public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; @@ -1403,7 +1403,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ - function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') + public function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') { global $user, $langs; @@ -1552,7 +1552,7 @@ class Holiday extends CommonObject * @param string $name name du paramètre de configuration * @return string retourne checked si > 0 */ - function getCheckOption($name) + public function getCheckOption($name) { $sql = "SELECT value"; @@ -1579,7 +1579,7 @@ class Holiday extends CommonObject * @param int $userid Id user * @return void */ - function createCPusers($single = false, $userid = '') + public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter if (! $single) @@ -1614,7 +1614,7 @@ class Holiday extends CommonObject * @param int $user_id ID de l'utilisateur à supprimer * @return boolean Vrai si pas d'erreur, faut si Erreur */ - function deleteCPuser($user_id) + public function deleteCPuser($user_id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1631,7 +1631,7 @@ class Holiday extends CommonObject * @param int $fk_type Filter on type * @return float Retourne le solde de congés payés de l'utilisateur */ - function getCPforUser($user_id, $fk_type = 0) + public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1661,7 +1661,7 @@ class Holiday extends CommonObject * @param string $filters Filters * @return array|string|int Return an array */ - function fetchUsers($stringlist = true, $type = true, $filters = '') + public function fetchUsers($stringlist = true, $type = true, $filters = '') { global $conf; @@ -1881,7 +1881,7 @@ class Holiday extends CommonObject * * @return array Array of user ids */ - function fetch_users_approver_holiday() + public function fetch_users_approver_holiday() { // phpcs:enable $users_validator=array(); @@ -1922,7 +1922,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsers() + public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -1938,7 +1938,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsersWithoutCP() + public function countActiveUsersWithoutCP() { $sql = "SELECT count(u.rowid) as compteur"; @@ -1958,7 +1958,7 @@ class Holiday extends CommonObject * @param int $userCP Number of active users into table of holidays * @return int <0 if KO, >0 if OK */ - function verifNbUsers($userDolibarrWithoutCP, $userCP) + public function verifNbUsers($userDolibarrWithoutCP, $userCP) { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1976,7 +1976,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int Id of record added, 0 if nothing done, < 0 if KO */ - function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) + public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) { global $conf, $langs; @@ -2045,7 +2045,7 @@ class Holiday extends CommonObject * @param string $filter Filtre de séléction * @return int -1 si erreur, 1 si OK et 2 si pas de résultat */ - function fetchLog($order, $filter) + public function fetchLog($order, $filter) { global $langs; @@ -2122,7 +2122,7 @@ class Holiday extends CommonObject * @param int $affect Filter on affect (a request will change sold or not). -1 = Both * @return array Return array with list of types */ - function getTypes($active = -1, $affect = -1) + public function getTypes($active = -1, $affect = -1) { global $mysoc; @@ -2159,7 +2159,7 @@ class Holiday extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 5759d567761..bb0bfd342ac 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -102,7 +102,7 @@ class Establishment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -116,7 +116,7 @@ class Establishment extends CommonObject * @param User $user User making creation * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -187,7 +187,7 @@ class Establishment extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; @@ -228,7 +228,7 @@ class Establishment extends CommonObject * @param int $id Id of record to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,"; $sql.= ' c.code as country_code, c.label as country'; @@ -269,7 +269,7 @@ class Establishment extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -296,7 +296,7 @@ class Establishment extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } @@ -309,7 +309,7 @@ class Establishment extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -350,7 +350,7 @@ class Establishment extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod'; $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; @@ -396,7 +396,7 @@ class Establishment extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string String with URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -420,7 +420,7 @@ class Establishment extends CommonObject * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index d856cd1250d..15f4278bf49 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -30,164 +30,164 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class class Supplierproposals extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); - /** - * @var SupplierProposal $supplier_proposal {@type SupplierProposal} - */ - public $supplier_proposal; + /** + * @var SupplierProposal $supplier_proposal {@type SupplierProposal} + */ + public $supplier_proposal; - /** - * Constructor - */ - function __construct() - { - global $db, $conf; - $this->db = $db; - $this->supplier_proposal = new SupplierProposal($this->db); - } - - /** - * Get properties of a supplier proposal (price request) object - * - * Return an array with supplier proposal informations - * - * @param int $id ID of supplier proposal - * @return array|mixed data without useless information - * - * @throws RestException - */ - function get($id) - { - if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { - throw new RestException(401); - } - - $result = $this->supplier_proposal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Supplier Proposal not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $this->supplier_proposal->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->supplier_proposal); - } - - /** - * List supplier proposals - * - * Get a list of supplier proposals - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" - * @return array Array of order objects - */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + /** + * Constructor + */ + public function __construct() { - global $db, $conf; + global $db, $conf; + $this->db = $db; + $this->supplier_proposal = new SupplierProposal($this->db); + } - $obj_ret = array(); + /** + * Get properties of a supplier proposal (price request) object + * + * Return an array with supplier proposal informations + * + * @param int $id ID of supplier proposal + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + throw new RestException(401); + } - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $result = $this->supplier_proposal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier Proposal not found'); + } - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; + $this->supplier_proposal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->supplier_proposal); + } - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + /** + * List supplier proposals + * + * Get a list of supplier proposals + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @return array Array of order objects + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $obj_ret = array(); - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; - $sql.= $db->plimit($limit + 1, $offset); - } + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $result = $db->query($sql); + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; - if ($result) - { - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; - while ($i < $min) - { - $obj = $db->fetch_object($result); - $propal_static = new SupplierProposal($db); - if($propal_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($propal_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'No supplier proposal found'); - } - return $obj_ret; - } + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i=0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $propal_static = new SupplierProposal($db); + if($propal_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($propal_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No supplier proposal found'); + } + return $obj_ret; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - function _validate($data) - { - $propal = array(); - foreach (SupplierProposals::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $propal[$field] = $data[$field]; - } - return $propal; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $propal = array(); + foreach (SupplierProposals::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $propal[$field] = $data[$field]; + } + return $propal; + } /** @@ -196,7 +196,7 @@ class Supplierproposals extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index a5c6ee84e86..6b9c5d3db26 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -47,23 +47,23 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php'; class SupplierProposal extends CommonObject { /** - * @var string ID to identify managed object - */ - public $element='supplier_proposal'; + * @var string ID to identify managed object + */ + public $element='supplier_proposal'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposal'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposal'; /** - * @var int Name of subtable line - */ - public $table_element_line='supplier_proposaldet'; + * @var int Name of subtable line + */ + public $table_element_line='supplier_proposaldet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ + /** + * @var int Field with ID of parent key if this field has a parent + */ public $fk_element='fk_supplier_proposal'; public $picto='propal'; @@ -87,10 +87,10 @@ class SupplierProposal extends CommonObject public $socid; // Id client - /** - * @deprecated - * @see user_author_id - */ + /** + * @deprecated + * @see user_author_id + */ public $author; public $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande @@ -99,51 +99,51 @@ class SupplierProposal extends CommonObject public $date; // Date of proposal public $date_livraison; - /** - * @deprecated - * @see date_creation - */ - public $datec; + /** + * @deprecated + * @see date_creation + */ + public $datec; - /** - * Creation date - * @var int - */ - public $date_creation; + /** + * Creation date + * @var int + */ + public $date_creation; - /** - * @deprecated - * @see date_validation - */ - public $datev; + /** + * @deprecated + * @see date_validation + */ + public $datev; - /** - * Validation date - * @var int - */ - public $date_validation; + /** + * Validation date + * @var int + */ + public $date_validation; public $user_author_id; public $user_valid_id; public $user_close_id; - /** - * @deprecated - * @see price_ht - */ + /** + * @deprecated + * @see price_ht + */ public $price; - /** - * @deprecated - * @see total_tva - */ + /** + * @deprecated + * @see total_tva + */ public $tva; - /** - * @deprecated - * @see total_ttc - */ + /** + * @deprecated + * @see total_ttc + */ public $total; public $cond_reglement_code; @@ -166,42 +166,42 @@ class SupplierProposal extends CommonObject public $specimen; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; - /** - * Draft status - */ - const STATUS_DRAFT = 0; + /** + * Draft status + */ + const STATUS_DRAFT = 0; - /** - * Validated status - */ - const STATUS_VALIDATED = 1; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; - /** - * Signed quote - */ - const STATUS_SIGNED = 2; + /** + * Signed quote + */ + const STATUS_SIGNED = 2; - /** - * Not signed quote, canceled - */ - const STATUS_NOTSIGNED = 3; + /** + * Not signed quote, canceled + */ + const STATUS_NOTSIGNED = 3; - /** - * Billed or closed/processed quote - */ - const STATUS_CLOSE = 4; + /** + * Billed or closed/processed quote + */ + const STATUS_CLOSE = 4; @@ -212,7 +212,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id third party * @param int $supplier_proposalid Id supplier_proposal */ - function __construct($db, $socid = "", $supplier_proposalid = 0) + public function __construct($db, $socid = "", $supplier_proposalid = 0) { global $conf,$langs; @@ -225,7 +225,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->client doit etre charge @@ -238,7 +238,7 @@ class SupplierProposal extends CommonObject * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { // phpcs:enable global $conf, $mysoc; @@ -282,14 +282,14 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -386,18 +386,18 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Buying price without tax * @param string $label ??? * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. - * @param string $origin 'order', 'supplier_proposal', ... - * @param int $origin_id Id of origin line + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. + * @param string $origin 'order', 'supplier_proposal', ... + * @param int $origin_id Id of origin line * @param double $pu_ht_devise Amount in currency * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) { - global $mysoc, $conf; + global $mysoc, $conf; dol_syslog(get_class($this)."::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -417,7 +417,7 @@ class SupplierProposal extends CommonObject $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if ($price_base_type=='HT') { $pu=$pu_ht; @@ -436,65 +436,65 @@ class SupplierProposal extends CommonObject if ($fk_product > 0) { - if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) - { - // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); - $prod = new Product($this->db, $fk_product); - if ($prod->fetch($fk_product) > 0) - { - $product_type = $prod->type; - $label = $prod->label; - $fk_prod_fourn_price = $fk_fournprice; + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) + { + $product_type = $prod->type; + $label = $prod->label; + $fk_prod_fourn_price = $fk_fournprice; - // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. - // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc - if ($result > 0) - { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice - // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) - $remise_percent =$prod->remise_percent; - } - if ($result == 0) // If result == 0, we failed to found the supplier reference price - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); - //$pu = $prod->fourn_pu; // We do not overwrite unit price - //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price - return -1; - } - if ($result == -1) - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); - return -1; - } - if ($result < -1) - { - $this->error=$prod->error; - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); - return -1; - } - } - else - { - $this->error=$prod->error; - $this->db->rollback(); - return -1; - } - } + // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) + { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) + $remise_percent =$prod->remise_percent; + } + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } + } + else + { + $this->error=$prod->error; + $this->db->rollback(); + return -1; + } + } } else { - $product_type = $type; + $product_type = $type; } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -517,8 +517,8 @@ class SupplierProposal extends CommonObject $total_localtax2 = $tabprice[10]; $pu = $pu_ht = $tabprice[3]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -552,7 +552,7 @@ class SupplierProposal extends CommonObject $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax2_type = $localtaxes_type[2]; $this->line->fk_product=$fk_product; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; @@ -569,25 +569,25 @@ class SupplierProposal extends CommonObject $this->line->fk_unit=$fk_unit; $this->line->origin=$origin; $this->line->origin_id=$origin_id; - $this->line->ref_fourn = $this->db->escape($ref_supplier); + $this->line->ref_fourn = $this->db->escape($ref_supplier); - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } - $this->line->pa_ht = $pa_ht; + // infos marge + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } + $this->line->pa_ht = $pa_ht; - // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -599,7 +599,7 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } $result=$this->line->insert(); @@ -652,12 +652,12 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. + * @param array $array_option extrafields array + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') { global $conf,$user,$langs, $mysoc; @@ -671,7 +671,7 @@ class SupplierProposal extends CommonObject $txtva = price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag @@ -694,8 +694,8 @@ class SupplierProposal extends CommonObject $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; @@ -730,8 +730,8 @@ class SupplierProposal extends CommonObject $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; $this->line->subprice = $pu; $this->line->info_bits = $info_bits; @@ -744,18 +744,18 @@ class SupplierProposal extends CommonObject $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; $this->line->ref_fourn = $ref_supplier; - $this->line->fk_unit = $fk_unit; + $this->line->fk_unit = $fk_unit; // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { // by external module, take lowest buying price include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // TODO deprecated @@ -763,12 +763,12 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } - // Multicurrency - $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + // Multicurrency + $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -807,7 +807,7 @@ class SupplierProposal extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($lineid) + public function deleteline($lineid) { if ($this->statut == 0) { @@ -842,7 +842,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $langs, $conf, $mysoc, $hookmanager; $error=0; @@ -861,26 +861,26 @@ class SupplierProposal extends CommonObject } // Check parameters - if (! empty($this->ref)) // We check that ref is not already used - { - $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used - if ($result > 0) - { - $this->error='ErrorRefAlreadyExists'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); - $this->db->rollback(); - return -1; - } - } + if (! empty($this->ref)) // We check that ref is not already used + { + $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + if ($result > 0) + { + $this->error='ErrorRefAlreadyExists'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); + $this->db->rollback(); + return -1; + } + } - // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } $this->db->begin(); @@ -931,9 +931,9 @@ class SupplierProposal extends CommonObject $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".$conf->entity; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -953,34 +953,34 @@ class SupplierProposal extends CommonObject if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) - { - dol_print_error($this->db); - $error++; - } - } - } - } + foreach($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (! $ret) + { + dol_print_error($this->db); + $error++; + } + } + } + } } // Add linked object (deprecated, use ->linkedObjectsIds instead) if (! $error && $this->origin && $this->origin_id) { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); } /* @@ -998,31 +998,31 @@ class SupplierProposal extends CommonObject $fk_parent_line = 0; } - $result = $this->addline( - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line, - $this->lines[$i]->fk_fournprice, - $this->lines[$i]->pa_ht, - $this->lines[$i]->label, - $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn, - $this->lines[$i]->fk_unit, - 'supplier_proposal', - $this->lines[$i]->rowid - ); + $result = $this->addline( + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->array_options, + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid + ); if ($result < 0) { @@ -1044,17 +1044,17 @@ class SupplierProposal extends CommonObject $resql=$this->update_price(1); if ($resql) { - $action='update'; + $action='update'; - // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -1065,14 +1065,14 @@ class SupplierProposal extends CommonObject } } else - { + { $this->error=$this->db->lasterror(); $error++; } } } else - { + { $this->error=$this->db->lasterror(); $error++; } @@ -1098,7 +1098,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). * @@ -1106,7 +1106,7 @@ class SupplierProposal extends CommonObject * @return int Id of the new object if ok, <0 if ko * @see create */ - function create_from($user) + public function create_from($user) { // phpcs:enable $this->products=$this->lines; @@ -1120,7 +1120,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$langs,$conf,$hookmanager; @@ -1129,12 +1129,12 @@ class SupplierProposal extends CommonObject $this->db->begin(); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals(); - // Load source object - $objFrom = clone $this; + // Load source object + $objFrom = clone $this; $objsoc=new Societe($this->db); @@ -1215,7 +1215,7 @@ class SupplierProposal extends CommonObject * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { global $conf; @@ -1232,7 +1232,7 @@ class SupplierProposal extends CommonObject $sql.= ", p.fk_mode_reglement"; $sql.= ', p.fk_account'; $sql.= ", p.fk_shipping_method"; - $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; + $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; $sql.= ", c.label as statut_label"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; @@ -1295,13 +1295,13 @@ class SupplierProposal extends CommonObject $this->user_valid_id = $obj->fk_user_valid; $this->user_close_id = $obj->fk_user_cloture; - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; if ($obj->fk_statut == 0) { @@ -1318,10 +1318,10 @@ class SupplierProposal extends CommonObject // Lines of supplier proposals $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; - $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; + $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' d.ref_fourn as ref_produit_fourn,'; - $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; + $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_supplier_proposal = ".$this->id; @@ -1361,11 +1361,11 @@ class SupplierProposal extends CommonObject $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; $line->special_code = $objp->special_code; $line->rang = $objp->rang; @@ -1378,16 +1378,16 @@ class SupplierProposal extends CommonObject $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; - $line->ref_fourn = $objp->ref_produit_fourn; + $line->ref_fourn = $objp->ref_produit_fourn; - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fk_unit = $objp->fk_unit; + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fk_unit = $objp->fk_unit; $this->lines[$i] = $line; @@ -1425,17 +1425,17 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf,$langs; + global $conf,$langs; $error=0; $now=dol_now(); if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) { $this->db->begin(); @@ -1446,11 +1446,11 @@ class SupplierProposal extends CommonObject // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef($soc); + $num = $this->getNextNumRef($soc); } else { - $num = $this->ref; + $num = $this->ref; } $this->newref = $num; @@ -1460,16 +1460,16 @@ class SupplierProposal extends CommonObject $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dol_syslog(get_class($this)."::valid", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - dol_print_error($this->db); - $error++; - } + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } - // Trigger calls - if (! $error && ! $notrigger) - { + // Trigger calls + if (! $error && ! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_VALIDATE', $user); if ($result < 0) { $error++; } @@ -1478,61 +1478,61 @@ class SupplierProposal extends CommonObject if (! $error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; - $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of propal directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; + $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; - if (file_exists($dirsource)) - { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) - { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } - $this->ref=$num; - $this->brouillon=0; - $this->statut = 1; - $this->user_valid_id=$user->id; - $this->datev=$now; + $this->ref=$num; + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else - { - $this->db->rollback(); - return -1; + { + $this->db->rollback(); + return -1; } } else { - dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); - return -2; + dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); + return -2; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery date * @@ -1540,7 +1540,7 @@ class SupplierProposal extends CommonObject * @param int $date_livraison Delivery date * @return int <0 if ko, >0 if ok */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if (! empty($user->rights->supplier_proposal->creer)) @@ -1563,7 +1563,7 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -1571,7 +1571,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_percent($user, $remise) + public function set_remise_percent($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1598,7 +1598,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -1606,7 +1606,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_absolue($user, $remise) + public function set_remise_absolue($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1644,7 +1644,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { global $langs,$conf; @@ -1653,47 +1653,47 @@ class SupplierProposal extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; $sql.= " SET fk_statut = ".$this->statut.","; - if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; + if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; $sql.= " WHERE rowid = ".$this->id; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::reopen", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); - } - if (! $error) - { - if (! $notrigger) - { + dol_syslog(get_class($this)."::reopen", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + if (! $error) + { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_REOPEN', $user); if ($result < 0) { $error++; } // End call triggers - } - } + } + } - // Commit or rollback - if ($error) - { - if (!empty($this->errors)) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } + // Commit or rollback + if ($error) + { + if (!empty($this->errors)) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } } @@ -1705,7 +1705,7 @@ class SupplierProposal extends CommonObject * @param string $note Comment * @return int <0 if KO, >0 if OK */ - function cloture($user, $statut, $note) + public function cloture($user, $statut, $note) { global $langs,$conf; @@ -1722,13 +1722,13 @@ class SupplierProposal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; if ($statut == 2) { - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; - $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; if (! empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists { @@ -1737,21 +1737,21 @@ class SupplierProposal extends CommonObject } if ($statut == 4) { - $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; + $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("", $conf); + $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } // Call trigger @@ -1779,97 +1779,97 @@ class SupplierProposal extends CommonObject } } - /** + /** * Add or update supplier price according to result of proposal * - * @param User $user Object user - * @return int > 0 if OK + * @param User $user Object user + * @return int > 0 if OK */ - function updateOrCreatePriceFournisseur($user) - { - $productsupplier = new ProductFournisseur($this->db); + public function updateOrCreatePriceFournisseur($user) + { + $productsupplier = new ProductFournisseur($this->db); - dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) - { - if ($product->subprice <= 0) continue; + dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); + foreach ($this->lines as $product) + { + if ($product->subprice <= 0) continue; - $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); - $res = $productsupplier->fetch($idProductFourn); + $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); + $res = $productsupplier->fetch($idProductFourn); - if ($productsupplier->id) { - if ($productsupplier->fourn_qty == $product->qty) { - $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); - } else { - $this->createPriceFournisseur($product, $user); - } - } else { - $this->createPriceFournisseur($product, $user); - } - } + if ($productsupplier->id) { + if ($productsupplier->fourn_qty == $product->qty) { + $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); + } else { + $this->createPriceFournisseur($product, $user); + } + } else { + $this->createPriceFournisseur($product, $user); + } + } - return 1; - } + return 1; + } - /** + /** * Upate ProductFournisseur * - * @param int $idProductFournPrice id of llx_product_fournisseur_price - * @param Product $product contain informations to update - * @param User $user Object user + * @param int $idProductFournPrice id of llx_product_fournisseur_price + * @param Product $product contain informations to update + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function updatePriceFournisseur($idProductFournPrice, $product, $user) + public function updatePriceFournisseur($idProductFournPrice, $product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $unitPrice = price2num($product->subprice, 'MU'); + $price=price2num($product->subprice*$product->qty, 'MU'); + $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } - /** + /** * Create ProductFournisseur - * + * * @param Product $product Object Product - * @param User $user Object user + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function createPriceFournisseur($product, $user) + public function createPriceFournisseur($product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $qty=price2num($product->qty); - $unitPrice = price2num($product->subprice, 'MU'); - $now=dol_now(); + $price=price2num($product->subprice*$product->qty, 'MU'); + $qty=price2num($product->qty); + $unitPrice = price2num($product->subprice, 'MU'); + $now=dol_now(); - $values = array( - "'".$this->db->idate($now)."'", - $product->fk_product, - $this->thirdparty->id, - "'".$product->ref_fourn."'", - $price, - $qty, - $unitPrice, - $product->tva_tx, - $user->id - ); + $values = array( + "'".$this->db->idate($now)."'", + $product->fk_product, + $this->thirdparty->id, + "'".$product->ref_fourn."'", + $price, + $qty, + $unitPrice, + $product->tva_tx, + $user->id + ); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; - $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; + $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** @@ -1878,7 +1878,7 @@ class SupplierProposal extends CommonObject * @param User $user Object user that modify * @return int <0 if KO, >0 if OK */ - function set_draft($user) + public function set_draft($user) { // phpcs:enable global $conf,$langs; @@ -1899,7 +1899,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of askprice (eventually filtered on user) into an array * @@ -1913,7 +1913,7 @@ class SupplierProposal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') { // phpcs:enable global $conf,$user; @@ -1925,13 +1925,13 @@ class SupplierProposal extends CommonObject $sql.= " p.datep as dp, p.fin_validite as datelimite"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; if (! $user->rights->societe->client->voir && ! $socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid) $sql.= " AND s.rowid = ".$socid; if ($draft) $sql.= " AND p.fk_statut = 0"; @@ -1959,7 +1959,7 @@ class SupplierProposal extends CommonObject $ga[$obj->supplier_proposalid] = $obj->ref.' ('.$obj->name.')'; } else - { + { $ga[$i]['id'] = $obj->supplier_proposalid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -2029,7 +2029,7 @@ class SupplierProposal extends CommonObject { $this->error='ErrorFailToDeleteFile'; $this->errors=array('ErrorFailToDeleteFile'); - $this->db->rollback(); + $this->db->rollback(); return 0; } } @@ -2050,16 +2050,16 @@ class SupplierProposal extends CommonObject // Removed extrafields if (! $error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag=-4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag=-4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } } if (! $error) @@ -2102,7 +2102,7 @@ class SupplierProposal extends CommonObject * @param int $id Proposal id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -2157,12 +2157,12 @@ class SupplierProposal extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -2170,44 +2170,44 @@ class SupplierProposal extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut, $mode = 1) + public function LibStatut($statut, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); + } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + $statuttrans=''; + if ($statut==0) $statuttrans='statut0'; + elseif ($statut==1) $statuttrans='statut1'; + elseif ($statut==2) $statuttrans='statut3'; + elseif ($statut==3) $statuttrans='statut5'; + elseif ($statut==4) $statuttrans='statut6'; - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - } + if ($mode == 0) return $this->labelstatut[$statut]; + elseif ($mode == 1) return $this->labelstatut_short[$statut]; + elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; + elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; + elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2215,7 +2215,7 @@ class SupplierProposal extends CommonObject * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice * @return int <0 if KO, >0 if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $user, $langs; @@ -2242,21 +2242,21 @@ class SupplierProposal extends CommonObject if ($resql) { if ($mode == 'opened') { - $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - $statut = self::STATUS_VALIDATED; - $label = $langs->trans("SupplierProposalsToClose"); + $delay_warning=$conf->supplier_proposal->cloture->warning_delay; + $statut = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); } if ($mode == 'signed') { - $delay_warning=$conf->supplier_proposal->facturation->warning_delay; - $statut = self::STATUS_SIGNED; - $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + $statut = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered } - $response = new WorkboardResponse(); - $response->warning_delay = $delay_warning/60/60/24; - $response->label = $label; - $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; - $response->img = img_object('', "propal"); + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning/60/60/24; + $response->label = $label; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->img = img_object('', "propal"); // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) @@ -2290,7 +2290,7 @@ class SupplierProposal extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -2355,8 +2355,8 @@ class SupplierProposal extends CommonObject if ($num_prods > 0) { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; } $this->lines[$xnbp]=$line; @@ -2369,13 +2369,13 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2421,14 +2421,14 @@ class SupplierProposal extends CommonObject * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("supplier_proposal"); if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON)) { - $mybool=false; + $mybool=false; $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.".php"; $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON; @@ -2445,8 +2445,8 @@ class SupplierProposal extends CommonObject if (! $mybool) { - dol_print_error('', "Failed to include file ".$file); - return ''; + dol_print_error('', "Failed to include file ".$file); + return ''; } $obj = new $classname(); @@ -2458,13 +2458,13 @@ class SupplierProposal extends CommonObject return $numref; } else - { + { $this->error=$obj->error; return ""; } } else - { + { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; @@ -2481,7 +2481,7 @@ class SupplierProposal extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user; @@ -2510,10 +2510,10 @@ class SupplierProposal extends CommonObject if ($option !== 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -2544,10 +2544,10 @@ class SupplierProposal extends CommonObject /** * Retrieve an array of supplier proposal lines - * - * @return int >0 if OK, <0 if KO + * + * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal @@ -2557,7 +2557,7 @@ class SupplierProposal extends CommonObject $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc, pt.ref_fourn as ref_supplier,'; - $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_supplier_proposal = '.$this->id; @@ -2594,26 +2594,26 @@ class SupplierProposal extends CommonObject $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; - $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); - $this->lines[$i]->pa_ht = $marginInfos[0]; - $this->lines[$i]->marge_tx = $marginInfos[1]; - $this->lines[$i]->marque_tx = $marginInfos[2]; - $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); + $this->lines[$i]->pa_ht = $marginInfos[0]; + $this->lines[$i]->marge_tx = $marginInfos[1]; + $this->lines[$i]->marque_tx = $marginInfos[2]; + $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated $this->lines[$i]->ref_supplier = $obj->ref_supplier; - // Multicurrency - $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; - $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; - $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; - $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->lines[$i]->fk_unit = $obj->fk_unit; + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->lines[$i]->fk_unit = $obj->fk_unit; $i++; } @@ -2628,56 +2628,56 @@ class SupplierProposal extends CommonObject } } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force model to use ('' to not force) - * @param Translate $outputlangs Object langs to use for output - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; - $langs->load("supplier_proposal"); + $langs->load("supplier_proposal"); - if (! dol_strlen($modele)) { + if (! dol_strlen($modele)) { - $modele = 'aurore'; + $modele = 'aurore'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { - $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { + $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; + } + } - $modelpath = "core/modules/supplier_proposal/doc/"; + $modelpath = "core/modules/supplier_proposal/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'supplier_proposal' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'supplier_proposal' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } } @@ -2692,19 +2692,19 @@ class SupplierProposalLine extends CommonObjectLine public $db; /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** - * @var string ID to identify managed object - */ - public $element='supplier_proposaldet'; + * @var string ID to identify managed object + */ + public $element='supplier_proposaldet'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposaldet'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposaldet'; public $oldline; @@ -2712,11 +2712,11 @@ class SupplierProposalLine extends CommonObjectLine public $rowid; // deprecated /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; - /** + /** * @var int ID */ public $fk_supplier_proposal; @@ -2733,16 +2733,16 @@ class SupplierProposalLine extends CommonObjectLine */ public $fk_product; // Id produit predefini - /** - * @deprecated - * @see product_type - */ - public $fk_product_type; - /** - * Product type - * @var int - * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE - */ + /** + * @deprecated + * @see product_type + */ + public $fk_product_type; + /** + * Product type + * @var int + * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE + */ public $product_type = Product::TYPE_PRODUCT; public $qty; @@ -2760,11 +2760,11 @@ class SupplierProposalLine extends CommonObjectLine /** * @var int ID */ - public $fk_fournprice; + public $fk_fournprice; - public $pa_ht; - public $marge_tx; - public $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port @@ -2779,53 +2779,53 @@ class SupplierProposalLine extends CommonObjectLine public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - * @see remise_percent, fk_remise_except - */ + /** + * @deprecated + * @see remise_percent, fk_remise_except + */ public $remise; - /** - * @deprecated - * @see subprice - */ + /** + * @deprecated + * @see subprice + */ public $price; // From llx_product - /** - * @deprecated - * @see product_ref - */ - public $ref; + /** + * @deprecated + * @see product_ref + */ + public $ref; - /** - * Product reference - * @var string - */ - public $product_ref; + /** + * Product reference + * @var string + */ + public $product_ref; - /** - * @deprecated - * @see product_label - */ - public $libelle; + /** + * @deprecated + * @see product_label + */ + public $libelle; - /** - * Product label - * @var string - */ - public $product_label; + /** + * Product label + * @var string + */ + public $product_label; - /** - * Product description - * @var string - */ - public $product_desc; + /** + * Product description + * @var string + */ + public $product_desc; public $localtax1_tx; // Local tax 1 public $localtax2_tx; // Local tax 2 public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type + public $localtax2_type; // Local tax 2 type public $total_localtax1; // Line total local tax 1 public $total_localtax2; // Line total local tax 2 @@ -2834,24 +2834,24 @@ class SupplierProposalLine extends CommonObjectLine public $ref_fourn; public $ref_supplier; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_subprice; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2862,79 +2862,79 @@ class SupplierProposalLine extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) - { - $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; - $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; - $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; - $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; - $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; - $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; - $sql.= ' WHERE pd.rowid = '.$rowid; + public function fetch($rowid) + { + $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; + $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; + $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; + $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; + $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; + $sql.= ' WHERE pd.rowid = '.$rowid; - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; // deprecated - $this->id = $objp->rowid; - $this->fk_supplier_proposal = $objp->fk_supplier_proposal; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; + $this->rowid = $objp->rowid; // deprecated + $this->id = $objp->rowid; + $this->fk_supplier_proposal = $objp->fk_supplier_proposal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; - $this->special_code = $objp->special_code; - $this->product_type = $objp->product_type; - $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->product_type = $objp->product_type; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; - $this->product_desc = $objp->product_desc; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; + $this->product_desc = $objp->product_desc; - $this->ref_fourn = $objp->ref_produit_forun; + $this->ref_fourn = $objp->ref_produit_forun; - // Multicurrency - $this->fk_multicurrency = $objp->fk_multicurrency; - $this->multicurrency_code = $objp->multicurrency_code; - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->fk_unit = $objp->fk_unit; + // Multicurrency + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->fk_unit = $objp->fk_unit; - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } /** * Insert object line propal in database @@ -2942,7 +2942,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf,$langs,$user; @@ -2955,7 +2955,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->rang)) $this->rang=0; @@ -2970,18 +2970,18 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } // Check parameters if ($this->product_type < 0) return -1; @@ -2991,12 +2991,12 @@ class SupplierProposalLine extends CommonObjectLine // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'supplier_proposaldet'; $sql.= ' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,'; - $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; $sql.= ' ref_fourn,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql.= " VALUES (".$this->fk_supplier_proposal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3008,8 +3008,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; + $sql.= " '".$this->db->escape($this->localtax1_type)."',"; + $sql.= " '".$this->db->escape($this->localtax2_type)."',"; $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->db->escape($this->info_bits)."'":"null").","; @@ -3023,29 +3023,29 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ' '.$this->special_code.','; $sql.= ' '.$this->rang.','; $sql.= " '".$this->db->escape($this->ref_fourn)."'"; - $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".$this->multicurrency_subprice; - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; + $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ", ".($this->fk_unit?$this->fk_unit:'null'); - $sql.= ')'; + $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - $this->id=$this->rowid; + $this->id=$this->rowid; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } if (! $error && ! $notrigger) @@ -3076,7 +3076,7 @@ class SupplierProposalLine extends CommonObjectLine * * @return int <0 if ko, >0 if ok */ - function delete() + public function delete() { global $conf,$langs,$user; @@ -3088,17 +3088,17 @@ class SupplierProposalLine extends CommonObjectLine if ($this->db->query($sql) ) { - // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } // Call trigger $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_DELETE', $user); @@ -3127,7 +3127,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $conf,$langs,$user; @@ -3139,8 +3139,8 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->marque_tx)) $this->marque_tx=0; if (empty($this->marge_tx)) $this->marge_tx=0; if (empty($this->price)) $this->price=0; // TODO A virer @@ -3153,20 +3153,20 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_unit)) $this->fk_unit=0; if (empty($this->subprice)) $this->subprice=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } $this->db->begin(); @@ -3178,8 +3178,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); - $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql.= " , qty='".price2num($this->qty)."'"; $sql.= " , subprice=".price2num($this->subprice).""; $sql.= " , remise_percent=".price2num($this->remise_percent).""; @@ -3194,35 +3194,35 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , total_localtax1=".price2num($this->total_localtax1).""; $sql.= " , total_localtax2=".price2num($this->total_localtax2).""; } - $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= " , buy_price_ht=".price2num($this->pa_ht); + $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); + $sql.= " , buy_price_ht=".price2num($this->pa_ht); if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - // Multicurrency - $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -3247,14 +3247,14 @@ class SupplierProposalLine extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if ko, >0 if ok */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 05b30c2b1a3..395ab2078c7 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -45,14 +45,14 @@ class ActionsTicket public $mesg; /** - * @var string Error code (or message) - */ - public $error; + * @var string Error code (or message) + */ + public $error; /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + * @var string[] Error codes (or messages) + */ + public $errors = array(); //! Numero de l'erreur public $errno = 0; @@ -66,18 +66,18 @@ class ActionsTicket public $label; /** - * @var string description - */ - public $description; + * @var string description + */ + public $description; - /** + /** * @var int ID */ public $fk_statut; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** @@ -119,7 +119,7 @@ class ActionsTicket if (GETPOST('addfile')) { // altairis : allow files from public interface if (GETPOST('track_id')) { - $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); + $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); } ////if($res > 0) @@ -374,7 +374,7 @@ class ActionsTicket if (! $error) // Update list of contacts { - // Si déjà un user assigné on le supprime des contacts + // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal'); @@ -760,12 +760,12 @@ class ActionsTicket // If public interface is not enable, use link to internal page into mail $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? - $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : - dol_buildpath('/public/ticket/view.php', 2) - ) : - dol_buildpath('/ticket/card.php', 2) - ) . '?track_id=' . $object->track_id; + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? + $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : + dol_buildpath('/public/ticket/view.php', 2) + ) : + dol_buildpath('/ticket/card.php', 2) + ) . '?track_id=' . $object->track_id; $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; // Build final message @@ -779,8 +779,8 @@ class ActionsTicket } if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; } @@ -954,7 +954,7 @@ class ActionsTicket header("Location: " . $url); exit; } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessages($this->error, $this->errors, 'errors'); @@ -1095,43 +1095,43 @@ class ActionsTicket */ public function viewTimelineTicketLogs($show_user = true, $object = true) { - global $conf, $langs; + global $conf, $langs; - // Load logs in cache - $ret = $object->loadCacheLogsTicket(); + // Load logs in cache + $ret = $object->loadCacheLogsTicket(); - if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { - print '
'; + if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { + print '
'; - foreach ($object->cache_logs_ticket as $id => $arraylogs) { - print '
'; - print '
'; - //print ''; - print '
'; + foreach ($object->cache_logs_ticket as $id => $arraylogs) { + print '
'; + print '
'; + //print ''; + print '
'; - print '
'; - print dol_nl2br($arraylogs['message']); + print '
'; + print dol_nl2br($arraylogs['message']); - print ''; - print dol_print_date($arraylogs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraylogs['datec'], 'dayhour'); - if ($show_user) { - if ($arraylogs['fk_user_create'] > 0) { - $userstat = new User($this->db); - $res = $userstat->fetch($arraylogs['fk_user_create']); - if ($res) { - print '
'.$userstat->getNomUrl(1).''; - } - } - } - print '
'; - print '
'; - print '
'; - } - print '
'; - } else { - print '
' . $langs->trans('NoLogForThisTicket') . '
'; - } + if ($show_user) { + if ($arraylogs['fk_user_create'] > 0) { + $userstat = new User($this->db); + $res = $userstat->fetch($arraylogs['fk_user_create']); + if ($res) { + print '
'.$userstat->getNomUrl(1).''; + } + } + } + print ''; + print ' '; + print ' '; + } + print '
'; + } else { + print '
' . $langs->trans('NoLogForThisTicket') . '
'; + } } /** @@ -1144,55 +1144,55 @@ class ActionsTicket */ public function viewTicketOriginalMessage($user, $action, $object) { - global $langs; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE + global $langs; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE - print '
'; - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; + print ''; + } - // Initial message - print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; + // Initial message + print '
'; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; - print $langs->trans("InitialMessage"); - print ''; - if ($user->rights->ticket->manage) { - print '' . img_edit($langs->trans('Modify')) . ''; - } - print '
'; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'; + print $langs->trans("InitialMessage"); + print ''; + if ($user->rights->ticket->manage) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + print '
'; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE - $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $uselocalbrowser = true; - $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); - $doleditor->Create(); - } else { - // Deal with format differences (text / HTML) - if (dol_textishtml($object->message)) { - print $object->message; - } else { - print dol_nl2br($object->message); - } + print '
'; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE + $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; + include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $uselocalbrowser = true; + $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); + $doleditor->Create(); + } else { + // Deal with format differences (text / HTML) + if (dol_textishtml($object->message)) { + print $object->message; + } else { + print dol_nl2br($object->message); + } - //print '
' . $object->message . '
'; - } - print '
'; - if ($user->rights->ticket->manage && $action == 'edit_message_init') { - print ' '; - print ' '; - print ''; - } + //print '
' . $object->message . '
'; + } + print ''; + print ''; + print ''; + if ($user->rights->ticket->manage && $action == 'edit_message_init') { + print ' '; + print ' '; + print ''; + } } /** * View html list of message for ticket @@ -1275,29 +1275,29 @@ class ActionsTicket */ public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object) { - global $conf, $langs, $user; + global $conf, $langs, $user; - // Load logs in cache - $ret = $object->loadCacheMsgsTicket(); - $action = GETPOST('action'); + // Load logs in cache + $ret = $object->loadCacheMsgsTicket(); + $action = GETPOST('action'); - if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { - print '
'; + if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { + print '
'; - foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { - if (!$arraymsgs['private'] - || ($arraymsgs['private'] == "1" && $show_private) - ) { - print '
'; - print '
'; - print ''; - print '
'; + foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { + if (!$arraymsgs['private'] + || ($arraymsgs['private'] == "1" && $show_private) + ) { + print '
'; + print '
'; + print ''; + print '
'; - print '
'; - print $arraymsgs['message']; + print '
'; + print $arraymsgs['message']; - print ''; - print dol_print_date($arraymsgs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraymsgs['datec'], 'dayhour'); if ($show_user) { if ($arraymsgs['fk_user_action'] > 0) { @@ -1312,18 +1312,18 @@ class ActionsTicket print $langs->trans('Customer'); } } - print ''; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; } - } - print '
'; - } else { - print '
' . $langs->trans('NoMsgForThisTicket') . '
'; - } + } + print '
'; + } else { + print '
' . $langs->trans('NoMsgForThisTicket') . '
'; + } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * load_previous_next_ref * @@ -1331,7 +1331,7 @@ class ActionsTicket * @param int $fieldid Id * @return int 0 */ - function load_previous_next_ref($filter, $fieldid) + public function load_previous_next_ref($filter, $fieldid) { // phpcs:enable $this->getInstanceDao(); @@ -1498,9 +1498,9 @@ class ActionsTicket print '
'; if ($status == 1) - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action - else - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action + else + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; print ''; print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]); @@ -1512,14 +1512,14 @@ class ActionsTicket } - /** - * deleteObjectLinked - * - * @return number - */ + /** + * deleteObjectLinked + * + * @return number + */ public function deleteObjectLinked() { - return $this->dao->deleteObjectLinked(); + return $this->dao->deleteObjectLinked(); } /** @@ -1533,19 +1533,19 @@ class ActionsTicket */ public function emailElementlist($parameters, &$object, &$action, $hookmanager) { - global $langs; + global $langs; - $error = 0; + $error = 0; - if (in_array('admin', explode(':', $parameters['context']))) { + if (in_array('admin', explode(':', $parameters['context']))) { $this->results = array('ticket_send' => $langs->trans('MailToSendTicketMessage')); - } + } - if (! $error) { + if (! $error) { return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } + } else { + $this->errors[] = 'Error message'; + return -1; + } } } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index fd698e6de06..005d8084f31 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -55,8 +55,8 @@ class Tickets extends DolibarrApi */ public function __construct() { - global $db; - $this->db = $db; + global $db; + $this->db = $db; $this->ticket = new Ticket($this->db); } @@ -72,9 +72,9 @@ class Tickets extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id) + public function get($id) { - return $this->getCommon($id, '', ''); + return $this->getCommon($id, '', ''); } /** @@ -93,7 +93,7 @@ class Tickets extends DolibarrApi */ public function getByTrackId($track_id) { - return $this->getCommon(0, $track_id, ''); + return $this->getCommon(0, $track_id, ''); } /** @@ -112,13 +112,13 @@ class Tickets extends DolibarrApi */ public function getByRef($ref) { - try { - return $this->getCommon(0, '', $ref); - } - catch(Exception $e) - { - throw $e; - } + try { + return $this->getCommon(0, '', $ref); + } + catch(Exception $e) + { + throw $e; + } } /** @@ -301,22 +301,22 @@ class Tickets extends DolibarrApi } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql.= $db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); + $sql .= $this->db->plimit($limit, $offset); } $result = $db->query($sql); @@ -341,7 +341,7 @@ class Tickets extends DolibarrApi if (! count($obj_ret)) { throw new RestException(404, 'No ticket found'); } - return $obj_ret; + return $obj_ret; } /** @@ -355,8 +355,8 @@ class Tickets extends DolibarrApi { $ticketstatic = new Ticket($this->db); if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -417,17 +417,17 @@ class Tickets extends DolibarrApi public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach ($request_data as $field => $value) { $this->ticket->$field = $value; @@ -450,16 +450,16 @@ class Tickets extends DolibarrApi public function delete($id) { if (! DolibarrApiAccess::$user->rights->ticket->delete) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (!$this->ticket->delete($id)) { throw new RestException(500); @@ -523,12 +523,12 @@ class Tickets extends DolibarrApi * @todo use an array for properties to clean * */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - // Other attributes to clean + // Other attributes to clean $attr2clean = array( "contact", "contact_id", @@ -568,8 +568,8 @@ class Tickets extends DolibarrApi "civility_id", "cache_msgs_ticket", "cache_logs_ticket", - "statuts_short", - "statuts" + "statuts_short", + "statuts" ); foreach ($attr2clean as $toclean) { unset($object->$toclean); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 618eb654b1c..19b77331b3a 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -179,18 +179,18 @@ class Ticket extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'position'=>1, 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), - 'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), - 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'), - 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), - 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), - 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), - 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), + 'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), + 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'), + 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), + 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), + 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), @@ -200,7 +200,7 @@ class Ticket extends CommonObject 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) ); /** @@ -393,12 +393,12 @@ class Ticket extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "ticket"); if (!$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_CREATE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CREATE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } } @@ -537,10 +537,10 @@ class Ticket extends CommonObject $this->db->free($resql); return 1; } - else - { - return 0; - } + else + { + return 0; + } } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); @@ -595,7 +595,7 @@ class Ticket extends CommonObject $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; // Add fields for extrafields foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); + $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); } $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; @@ -699,7 +699,7 @@ class Ticket extends CommonObject // Extra fields if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) { - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $tmpkey = 'options_' . $key; $line->{$tmpkey} = $obj->$tmpkey; } @@ -839,12 +839,12 @@ class Ticket extends CommonObject } if (! $error && ! $notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MODIFY', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_MODIFY', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } // Commit or rollback @@ -902,18 +902,18 @@ class Ticket extends CommonObject } if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; - $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; - $resql = $this->db->query($sql); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; + $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; + $resql = $this->db->query($sql); } // Removed extrafields if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); + } } if (!$error) { @@ -1167,7 +1167,7 @@ class Ticket extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label of object * @@ -1175,7 +1175,7 @@ class Ticket extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -1331,57 +1331,57 @@ class Ticket extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - 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 = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("ShowTicket") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; - $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; + $label = '' . $langs->trans("ShowTicket") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; + $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; - $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; + $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowTicket"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowTicket"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = '
'; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - return $result; + return $result; } @@ -1406,14 +1406,14 @@ class Ticket extends CommonObject dol_syslog(get_class($this) . "::markAsRead sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { - if (!$error && !$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MARK_READ', $user); - if ($result < 0) { + if (!$error && !$notrigger) { + // Call trigger + $result=$this->call_trigger('TICKET_MARK_READ', $user); + if ($result < 0) { $error++; } - // End call triggers - } + // End call triggers + } if (!$error) { @@ -1434,61 +1434,61 @@ class Ticket extends CommonObject } } - /** - * Mark a message as read - * - * @param User $user Object user - * @param int $id_assign_user ID of user assigned - * @param int $notrigger Disable trigger - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function assignUser($user, $id_assign_user, $notrigger = 0) - { - global $conf, $langs; + /** + * Mark a message as read + * + * @param User $user Object user + * @param int $id_assign_user ID of user assigned + * @param int $notrigger Disable trigger + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function assignUser($user, $id_assign_user, $notrigger = 0) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; - if ($id_assign_user > 0) - { - $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; - } - else - { - $sql .= " SET fk_user_assign=null, fk_statut=1"; - } - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; + if ($id_assign_user > 0) + { + $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; + } + else + { + $sql .= " SET fk_user_assign=null, fk_statut=1"; + } + $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this) . "::assignUser sql=" . $sql); - $resql = $this->db->query($sql); - if ($resql) { - $this->fk_user_assign = $id_assign_user; // May be used by trigger + dol_syslog(get_class($this) . "::assignUser sql=" . $sql); + $resql = $this->db->query($sql); + if ($resql) { + $this->fk_user_assign = $id_assign_user; // May be used by trigger - if (! $notrigger) { - // Call trigger - $result = $this->call_trigger('TICKET_ASSIGNED', $user); - if ($result < 0) { - $error ++; - } - // End call triggers - } + if (! $notrigger) { + // Call trigger + $result = $this->call_trigger('TICKET_ASSIGNED', $user); + if ($result < 0) { + $error ++; + } + // End call triggers + } - if (! $error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = join(',', $this->errors); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } + if (! $error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + $this->error = join(',', $this->errors); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } /** * Create log for the ticket @@ -1521,19 +1521,19 @@ class Ticket extends CommonObject // so the event is stored by the agenda/event trigger if (!$error) { - $this->db->commit(); + $this->db->commit(); - if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { - $this->sendLogByEmail($user, $message); - } + if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { + $this->sendLogByEmail($user, $message); + } - return 1; + return 1; } else { - $this->db->rollback(); + $this->db->rollback(); - return -1; + return -1; } } @@ -1811,32 +1811,32 @@ class Ticket extends CommonObject $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); if ($this->linkedObjectsIds) { - foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { - $fichinter = new Fichinter($this->db); - $fichinter->fetch($fichinter_id); - if($fichinter->statut == 0) { - $result = $fichinter->setValid($user); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - if ($fichinter->statut < 3) { - $result = $fichinter->setStatut(3); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - } + foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { + $fichinter = new Fichinter($this->db); + $fichinter->fetch($fichinter_id); + if($fichinter->statut == 0) { + $result = $fichinter->setValid($user); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + if ($fichinter->statut < 3) { + $result = $fichinter->setStatut(3); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + } } - // Call trigger - $result=$this->call_trigger('TICKET_CLOSE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CLOSE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers if (!$error) { $this->db->commit(); @@ -2363,22 +2363,22 @@ class Ticket extends CommonObject $transkey = "TypeContact_" . $obj->element . "_" . $obj->source . "_" . $obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); $tab[$i] = array( - 'source' => $obj->source, - 'socid' => $obj->socid, - 'id' => $obj->id, - 'nom' => $obj->lastname, // For backward compatibility - 'civility' => $obj->civility, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'email' => $obj->email, - 'rowid' => $obj->rowid, - 'code' => $obj->code, - 'libelle' => $libelle_type, - 'status' => $obj->statuslink, - 'statuscontact'=>$obj->statuscontact, - 'fk_c_type_contact' => $obj->fk_c_type_contact, - 'phone' => $obj->phone, - 'phone_mobile' => $obj->phone_mobile); + 'source' => $obj->source, + 'socid' => $obj->socid, + 'id' => $obj->id, + 'nom' => $obj->lastname, // For backward compatibility + 'civility' => $obj->civility, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'email' => $obj->email, + 'rowid' => $obj->rowid, + 'code' => $obj->code, + 'libelle' => $libelle_type, + 'status' => $obj->statuslink, + 'statuscontact'=>$obj->statuscontact, + 'fk_c_type_contact' => $obj->fk_c_type_contact, + 'phone' => $obj->phone, + 'phone_mobile' => $obj->phone_mobile); } else { $tab[$i] = $obj->id; } @@ -2438,11 +2438,11 @@ class Ticket extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return if at least one photo is available - * - * @param string $sdir Directory to scan - * @return boolean True if at least one photo is available, False if not - */ + * Return if at least one photo is available + * + * @param string $sdir Directory to scan + * @return boolean True if at least one photo is available, False if not + */ function is_photo_available($sdir) { // phpcs:enable @@ -2479,9 +2479,9 @@ class Ticket extends CommonObject class TicketsLine { /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string $ref Ticket reference @@ -2489,107 +2489,107 @@ class TicketsLine public $ref; /** - * Hash to identify ticket - */ + * Hash to identify ticket + */ public $track_id; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** - * Project ID - */ + * Project ID + */ public $fk_project; /** - * Person email who have create ticket - */ + * Person email who have create ticket + */ public $origin_email; /** - * User id who have create ticket - */ + * User id who have create ticket + */ public $fk_user_create; /** - * User id who have ticket assigned - */ + * User id who have ticket assigned + */ public $fk_user_assign; /** - * Ticket subject - */ + * Ticket subject + */ public $subject; /** - * Ticket message - */ + * Ticket message + */ public $message; /** - * Ticket statut - */ + * Ticket statut + */ public $fk_statut; /** - * State resolution - */ + * State resolution + */ public $resolution; /** - * Progress in percent - */ + * Progress in percent + */ public $progress; /** - * Duration for ticket - */ + * Duration for ticket + */ public $timing; /** - * Type code - */ + * Type code + */ public $type_code; /** - * Category code - */ + * Category code + */ public $category_code; /** - * Severity code - */ + * Severity code + */ public $severity_code; /** - * Type label - */ + * Type label + */ public $type_label; /** - * Category label - */ + * Category label + */ public $category_label; /** - * Severity label - */ + * Severity label + */ public $severity_label; /** - * Creation date - */ + * Creation date + */ public $datec = ''; /** - * Read date - */ + * Read date + */ public $date_read = ''; /** - * Close ticket date - */ + * Close ticket date + */ public $date_close = ''; } diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 44360c788a5..2f2e04baba9 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -30,9 +30,9 @@ require_once 'ticket.class.php'; class TicketStats extends Stats { /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + * @var string Name of table without prefix where object is stored + */ + public $table_element; public $socid; public $userid; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 874e518511a..625fd913f5e 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -44,7 +44,7 @@ class Users extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -65,7 +65,7 @@ class Users extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of User objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -139,7 +139,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); @@ -166,7 +166,7 @@ class Users extends DolibarrApi * @param array $request_data New user data * @return int */ - function post($request_data = null) + public function post($request_data = null) { // check user authorization //if(! DolibarrApiAccess::$user->rights->user->creer) { @@ -201,7 +201,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); @@ -256,7 +256,7 @@ class Users extends DolibarrApi * * @url GET {id}/groups */ - function getGroups($id) + public function getGroups($id) { $obj_ret = array(); @@ -290,7 +290,7 @@ class Users extends DolibarrApi * * @url GET {id}/setGroup/{group} */ - function setGroup($id, $group, $entity = 1) + public function setGroup($id, $group, $entity = 1) { global $conf; @@ -335,7 +335,7 @@ class Users extends DolibarrApi * @param int $id Account ID * @return array */ - function delete($id) + public function delete($id) { //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { //throw new RestException(401); @@ -360,7 +360,7 @@ class Users extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { global $conf; @@ -418,16 +418,15 @@ class Users extends DolibarrApi * @param array|null $data Data to validate * @return array * @throws RestException - */ - function _validate($data) + */ + private function _validate($data) { - $account = array(); - foreach (Users::$FIELDS as $field) - { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $account[$field] = $data[$field]; - } - return $account; - } + $account = array(); + foreach (Users::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $account[$field] = $data[$field]; + } + return $account; + } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a6bc202d17f..3b26bb8cdfb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -185,7 +185,7 @@ class User extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -201,11 +201,11 @@ class User extends CommonObject $this->admin = 0; $this->employee = 1; - $this->conf = new stdClass(); - $this->rights = new stdClass(); - $this->rights->user = new stdClass(); - $this->rights->user->user = new stdClass(); - $this->rights->user->self = new stdClass(); + $this->conf = new stdClass(); + $this->rights = new stdClass(); + $this->rights->user = new stdClass(); + $this->rights->user->user = new stdClass(); + $this->rights->user->self = new stdClass(); } /** @@ -219,7 +219,7 @@ class User extends CommonObject * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @return int <0 if KO, 0 not found, >0 if OK */ - function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) + public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) { global $conf, $user; @@ -320,17 +320,17 @@ class User extends CommonObject $this->zip = $obj->zip; $this->town = $obj->town; - $this->country_id = $obj->country_id; + $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; $this->state = ($obj->state!='-'?$obj->state:''); $this->office_phone = $obj->office_phone; - $this->office_fax = $obj->office_fax; - $this->user_mobile = $obj->user_mobile; + $this->office_fax = $obj->office_fax; + $this->user_mobile = $obj->user_mobile; $this->email = $obj->email; $this->skype = $obj->skype; $this->twitter = $obj->twitter; @@ -344,14 +344,14 @@ class User extends CommonObject $this->openid = $obj->openid; $this->lang = $obj->lang; $this->entity = $obj->entity; - $this->accountancy_code = $obj->accountancy_code; + $this->accountancy_code = $obj->accountancy_code; $this->thm = $obj->thm; $this->tjm = $obj->tjm; $this->salary = $obj->salary; $this->salaryextra = $obj->salaryextra; - $this->weeklyhours = $obj->weeklyhours; + $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; - $this->dateemployment = $this->db->jdate($obj->dateemployment); + $this->dateemployment = $this->db->jdate($obj->dateemployment); $this->dateemploymentend = $this->db->jdate($obj->dateemploymentend); $this->datec = $this->db->jdate($obj->datec); @@ -366,8 +366,8 @@ class User extends CommonObject $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->default_range = $obj->default_range; - $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; + $this->default_range = $obj->default_range; + $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. @@ -439,7 +439,7 @@ class User extends CommonObject * * @return int > 0 if OK, < 0 if KO */ - function loadDefaultValues() + public function loadDefaultValues() { global $conf; @@ -501,7 +501,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if KO * @see clearrights, delrights, getrights */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -627,7 +627,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if OK * @see clearrights, addrights, getrights */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -637,8 +637,7 @@ class User extends CommonObject $this->db->begin(); - if (! empty($rid)) - { + if (! empty($rid)) { // Si on a demande supression d'un droit en particulier, on recupere // les caracteristiques module, perms et subperms de ce droit. $sql = "SELECT module, perms, subperms"; @@ -663,8 +662,7 @@ class User extends CommonObject // Suppression des droits induits if ($subperms=='lire' || $subperms=='read') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; if ($perms=='lire' || $perms=='read') $wherefordel.=" OR (module='$module')"; - } - else { + } else { // On a demande suppression d'un droit sur la base d'un nom de module ou perms // Where pour la liste des droits a supprimer if (! empty($allmodule)) @@ -745,7 +743,7 @@ class User extends CommonObject * @return void * @see getrights */ - function clearrights() + public function clearrights() { dol_syslog(get_class($this)."::clearrights reset user->rights"); $this->rights=''; @@ -762,7 +760,7 @@ class User extends CommonObject * @return void * @see clearrights, delrights, addrights */ - function getrights($moduletag = '', $forcereload = 0) + public function getrights($moduletag = '', $forcereload = 0) { global $conf; @@ -919,7 +917,7 @@ class User extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; @@ -1010,7 +1008,7 @@ class User extends CommonObject * @param User $user User than delete * @return int <0 if KO, >0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -1102,7 +1100,7 @@ class User extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int <0 if KO, id of created user if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; global $mysoc; @@ -1227,7 +1225,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1236,7 +1234,7 @@ class User extends CommonObject * @param string $password Password to force * @return int <0 if error, if OK returns id of created user */ - function create_from_contact($contact, $login = '', $password = '') + public function create_from_contact($contact, $login = '', $password = '') { // phpcs:enable global $conf,$user,$langs; @@ -1244,23 +1242,23 @@ class User extends CommonObject $error=0; // Define parameters - $this->admin = 0; - $this->lastname = $contact->lastname; - $this->firstname = $contact->firstname; - $this->gender = $contact->gender; - $this->email = $contact->email; - $this->skype = $contact->skype; - $this->twitter = $contact->twitter; - $this->facebook = $contact->facebook; - $this->office_phone = $contact->phone_pro; - $this->office_fax = $contact->fax; - $this->user_mobile = $contact->phone_mobile; - $this->address = $contact->address; - $this->zip = $contact->zip; - $this->town = $contact->town; - $this->state_id = $contact->state_id; - $this->country_id = $contact->country_id; - $this->employee = 0; + $this->admin = 0; + $this->lastname = $contact->lastname; + $this->firstname = $contact->firstname; + $this->gender = $contact->gender; + $this->email = $contact->email; + $this->skype = $contact->skype; + $this->twitter = $contact->twitter; + $this->facebook = $contact->facebook; + $this->office_phone = $contact->phone_pro; + $this->office_fax = $contact->fax; + $this->user_mobile = $contact->phone_mobile; + $this->address = $contact->address; + $this->zip = $contact->zip; + $this->town = $contact->town; + $this->state_id = $contact->state_id; + $this->country_id = $contact->country_id; + $this->employee = 0; if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4)); $this->login = $login; @@ -1308,7 +1306,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1316,7 +1314,7 @@ class User extends CommonObject * @param string $login Login to force * @return int <0 if KO, if OK, return id of created account */ - function create_from_member($member, $login = '') + public function create_from_member($member, $login = '') { // phpcs:enable global $conf,$user,$langs; @@ -1383,13 +1381,13 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * * @return integer erreur <0, si ok renvoi le nbre de droits par defaut positionnes */ - function set_default_rights() + public function set_default_rights() { // phpcs:enable global $conf; @@ -1438,7 +1436,7 @@ class User extends CommonObject * @param int $nosynccontact 0=Synchronize linked contact, 1=Do not synchronize linked contact * @return int <0 si KO, >=0 si OK */ - function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) + public function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) { global $conf, $langs; @@ -1479,8 +1477,8 @@ class User extends CommonObject $this->zip = empty($this->zip)?'':$this->zip; $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); - $this->color = empty($this->color)?'':$this->color; - $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; + $this->color = empty($this->color)?'':$this->color; + $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; $this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend; // Check parameters @@ -1733,14 +1731,14 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion * * @return <0 si echec, >=0 si ok */ - function update_last_login_date() + public function update_last_login_date() { // phpcs:enable $now=dol_now(); @@ -1777,7 +1775,7 @@ class User extends CommonObject * @param int $nosyncmember Do not synchronize linked member * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT .'/core/lib/security2.lib.php'; @@ -1900,7 +1898,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1909,7 +1907,7 @@ class User extends CommonObject * @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @TODO Add method 2 = Send link to reset password * @return int < 0 si erreur, > 0 si ok */ - function send_password($user, $password = '', $changelater = 0) + public function send_password($user, $password = '', $changelater = 0) { // phpcs:enable global $conf, $langs; @@ -1977,8 +1975,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } -$mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -1988,8 +1986,8 @@ $mailfile = new CMailFile( '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2008,19 +2006,19 @@ $mailfile = new CMailFile( * * @return string chaine erreur */ - function error() + public function error() { return $this->error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * * @return <0 if KO, >0 if OK */ - function fetch_clicktodial() + public function fetch_clicktodial() { // phpcs:enable $sql = "SELECT url, login, pass, poste "; @@ -2052,14 +2050,14 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return integer - */ - function update_clicktodial() - { + */ + public function update_clicktodial() + { // phpcs:enable $this->db->begin(); @@ -2090,10 +2088,10 @@ $mailfile = new CMailFile( $this->error=$this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2102,7 +2100,7 @@ $mailfile = new CMailFile( * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function SetInGroup($group, $entity, $notrigger = 0) + public function SetInGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf, $langs, $user; @@ -2155,7 +2153,7 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2164,7 +2162,7 @@ $mailfile = new CMailFile( * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function RemoveFromGroup($group, $entity, $notrigger = 0) + public function RemoveFromGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf,$langs,$user; @@ -2224,7 +2222,7 @@ $mailfile = new CMailFile( * @param string $imagesize 'mini', 'small' or '' (original) * @return string String with URL link */ - function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') + public function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') { $result =''; $result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize); @@ -2248,7 +2246,7 @@ $mailfile = new CMailFile( * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -2385,7 +2383,7 @@ $mailfile = new CMailFile( * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getLoginUrl($withpicto = 0, $option = '') + public function getLoginUrl($withpicto = 0, $option = '') { global $langs, $user; @@ -2422,12 +2420,12 @@ $mailfile = new CMailFile( * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2435,7 +2433,7 @@ $mailfile = new CMailFile( * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -2484,7 +2482,7 @@ $mailfile = new CMailFile( * 2=Return key only (RDN) (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2501,7 +2499,7 @@ $mailfile = new CMailFile( * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2623,7 +2621,7 @@ $mailfile = new CMailFile( * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2668,7 +2666,7 @@ $mailfile = new CMailFile( * @param int $id Id of user to load * @return void */ - function info($id) + public function info($id) { $sql = "SELECT u.rowid, u.login as ref, u.datec,"; $sql.= " u.tms as date_modification, u.entity"; @@ -2684,10 +2682,10 @@ $mailfile = new CMailFile( $this->id = $obj->rowid; - $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; - $this->date_creation = $this->db->jdate($obj->datec); + $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->entity = $obj->entity; + $this->entity = $obj->entity; } $this->db->free($result); @@ -2704,7 +2702,7 @@ $mailfile = new CMailFile( * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; @@ -2735,7 +2733,7 @@ $mailfile = new CMailFile( * @param int $admin Filter on admin tag * @return int Number of users */ - function getNbOfUsers($limitTo, $option = '', $admin = -1) + public function getNbOfUsers($limitTo, $option = '', $admin = -1) { global $conf; @@ -2769,7 +2767,7 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2777,7 +2775,7 @@ $mailfile = new CMailFile( * * @return int <0 if KO, >0 if OK */ - function update_ldap2dolibarr(&$ldapuser) + public function update_ldap2dolibarr(&$ldapuser) { // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) @@ -2809,14 +2807,14 @@ $mailfile = new CMailFile( } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * * @return void * @see getAllChildIds */ - function get_children() + public function get_children() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; @@ -2844,9 +2842,9 @@ $mailfile = new CMailFile( /** - * Load this->parentof that is array(id_son=>id_parent, ...) + * Load this->parentof that is array(id_son=>id_parent, ...) * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ private function loadParentOf() { @@ -2891,8 +2889,8 @@ $mailfile = new CMailFile( * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - function get_full_tree($deleteafterid = 0, $filter = '') - { + public function get_full_tree($deleteafterid = 0, $filter = '') + { // phpcs:enable global $conf, $user; global $hookmanager; @@ -2993,8 +2991,8 @@ $mailfile = new CMailFile( * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children */ - function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids=array(); if (isset($this->cache_childids[$this->id])) @@ -3022,7 +3020,7 @@ $mailfile = new CMailFile( return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3031,8 +3029,8 @@ $mailfile = new CMailFile( * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - function build_path_from_id_user($id_user, $protection = 0) - { + public function build_path_from_id_user($id_user, $protection = 0) + { // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); @@ -3086,13 +3084,13 @@ $mailfile = new CMailFile( } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -3158,7 +3156,7 @@ $mailfile = new CMailFile( return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3166,7 +3164,7 @@ $mailfile = new CMailFile( * @param string $mode 'email' or 'mobile' * @return string Email of user with format: "Full name " */ - function user_get_property($rowid, $mode) + public function user_get_property($rowid, $mode) { // phpcs:enable $user_property=''; @@ -3208,9 +3206,9 @@ $mailfile = new CMailFile( * @param string $filtermode Filter mode (AND or OR) * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') - { - global $conf; + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') + { + global $conf; $sql="SELECT t.rowid"; $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; @@ -3263,8 +3261,8 @@ $mailfile = new CMailFile( } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 8e9ad2745c3..18c1ab742a1 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -34,16 +34,16 @@ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; */ class UserBankAccount extends Account { - var $socid; + public $socid; - var $datec; - var $datem; + public $datec; + public $datem; /** - * Constructor - * - * @param DoliDB $db Database handler + * Constructor + * + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { @@ -62,7 +62,7 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >= 0 if OK */ - function create(User $user = null, $notrigger = 0) + public function create(User $user = null, $notrigger = 0) { $now=dol_now(); @@ -92,9 +92,9 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <=0 if KO, >0 if OK */ - function update(User $user = null, $notrigger = 0) + public function update(User $user = null, $notrigger = 0) { - global $conf; + global $conf; if (! $this->id) { @@ -113,7 +113,7 @@ class UserBankAccount extends Account $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - if (trim($this->label) != '') + if (trim($this->label) != '') $sql.= ",label = '".$this->db->escape($this->label)."'"; else $sql.= ",label = NULL"; @@ -139,7 +139,7 @@ class UserBankAccount extends Account * @param int $userid User id * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '', $userid = 0) + public function fetch($id, $ref = '', $userid = 0) { if (empty($id) && empty($ref) && empty($userid)) return -1; @@ -157,21 +157,21 @@ class UserBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->socid = $obj->fk_soc; - $this->bank = $obj->bank; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban = $obj->iban; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->owner_address = $obj->owner_address; - $this->label = $obj->label; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); + $this->id = $obj->rowid; + $this->socid = $obj->fk_soc; + $this->bank = $obj->bank; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->owner_address = $obj->owner_address; + $this->label = $obj->label; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); } $this->db->free($resql); @@ -184,25 +184,25 @@ class UserBankAccount extends Account } } - /** - * Return RIB - * - * @param boolean $displayriblabel Prepend or Hide Label - * @return string RIB - */ - public function getRibLabel($displayriblabel = true) - { - $rib = ''; + /** + * Return RIB + * + * @param boolean $displayriblabel Prepend or Hide Label + * @return string RIB + */ + public function getRibLabel($displayriblabel = true) + { + $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - if ($this->label && $displayriblabel) { - $rib = $this->label." : "; - } + if ($this->label && $displayriblabel) { + $rib = $this->label." : "; + } - $rib .= (string) $this; - } + $rib .= (string) $this; + } - return $rib; - } + return $rib; + } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 4b199b4671d..3123900dc85 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -1,5 +1,5 @@ +/* Copyright (c) 2005 Rodolphe Quiedeville * Copyright (c) 2005-2018 Laurent Destailleur * Copyright (c) 2005-2018 Regis Houssin * Copyright (C) 2012 Florian Henry @@ -91,8 +91,8 @@ class UserGroup extends CommonObject * Constructor de la classe * * @param DoliDb $db Database handler - */ - function __construct($db) + */ + public function __construct($db) { $this->db = $db; $this->nb_rights = 0; @@ -100,14 +100,14 @@ class UserGroup extends CommonObject /** - * Charge un objet group avec toutes ces caracteristiques (except ->members array) + * Charge un objet group avec toutes ces caracteristiques (except ->members array) * * @param int $id Id of group to load * @param string $groupname Name of group to load * @param boolean $load_members Load all members of the group * @return int <0 if KO, >0 if OK */ - function fetch($id = '', $groupname = '', $load_members = true) + public function fetch($id = '', $groupname = '', $load_members = true) { global $conf; @@ -163,13 +163,13 @@ class UserGroup extends CommonObject /** - * Return array of groups objects for a particular user + * Return array of groups objects for a particular user * - * @param int $userid User id to search + * @param int $userid User id to search * @param boolean $load_members Load all members of the group - * @return array Array of groups objects + * @return array Array of groups objects */ - function listGroupsForUser($userid, $load_members = true) + public function listGroupsForUser($userid, $load_members = true) { global $conf, $user; @@ -224,7 +224,7 @@ class UserGroup extends CommonObject * @param int $mode 0=Return array of user instance, 1=Return array of users id only * @return mixed Array of users or -1 on error */ - function listUsersForGroup($excludefilter = '', $mode = 0) + public function listUsersForGroup($excludefilter = '', $mode = 0) { global $conf, $user; @@ -289,7 +289,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if KO */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -415,7 +415,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if OK */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -456,8 +456,7 @@ class UserGroup extends CommonObject // Pour compatibilite, si lowid = 0, on est en mode suppression de tout // TODO A virer quand sera gere par l'appelant //if (substr($rid,-1,1) == 0) $wherefordel="module='$module'"; - } - else { + } else { // Where pour la liste des droits a supprimer if (! empty($allmodule)) { @@ -535,9 +534,9 @@ class UserGroup extends CommonObject * Charge dans l'objet group, la liste des permissions auquels le groupe a droit * * @param string $moduletag Name of module we want permissions ('' means all) - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function getrights($moduletag = '') + public function getrights($moduletag = '') { global $conf; @@ -622,7 +621,7 @@ class UserGroup extends CommonObject * @param User $user User that delete * @return <0 if KO, > 0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -676,7 +675,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function create($notrigger = 0) + public function create($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -747,7 +746,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -817,12 +816,12 @@ class UserGroup extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut(0, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -830,7 +829,7 @@ class UserGroup extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -840,16 +839,16 @@ class UserGroup extends CommonObject /** * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname + * Use this->id,this->lastname, this->firstname * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) - * @param string $option On what the link point to ('nolink', ) + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) + * @param string $option On what the link point to ('nolink', ) * @param integer $notooltip 1=Disable tooltip on picto and name * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -925,7 +924,7 @@ class UserGroup extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -943,7 +942,7 @@ class UserGroup extends CommonObject * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -979,8 +978,8 @@ class UserGroup extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() + */ + public function initAsSpecimen() { global $conf, $user, $langs; @@ -994,11 +993,11 @@ class UserGroup extends CommonObject $this->datec=time(); $this->datem=time(); - // Members of this group is just me - $this->members=array( - $user->id => $user - ); - } + // Members of this group is just me + $this->members=array( + $user->id => $user + ); + } /** * Create a document onto disk according to template module. diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index e5257c5fd0a..09c733e3dc7 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -63,7 +63,7 @@ class ProductAttributeValue $this->db = $db; $this->entity = $conf->entity; - } + } /** * Gets a product attribute value diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 9d36449da30..6bfbadfb197 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -134,15 +134,15 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = (int) $this->status; } - if (empty($this->date_creation)) { + if (empty($this->date_creation)) { $this->date_creation = $now; } - if (empty($this->date_modification)) { + if (empty($this->date_modification)) { $this->date_modification = $now; } - // Check parameters - if (empty($this->entity)) { + // Check parameters + if (empty($this->entity)) { $this->entity = $conf->entity; } @@ -671,7 +671,7 @@ class Website extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -707,12 +707,12 @@ class Website extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -720,7 +720,7 @@ class Website extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -728,27 +728,27 @@ class Website extends CommonObject if ($mode == 0 || $mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } @@ -783,7 +783,7 @@ class Website extends CommonObject * * @return string Path to file with zip */ - function exportWebSite() + public function exportWebSite() { global $conf, $mysoc; @@ -958,7 +958,7 @@ class Website extends CommonObject * @param string $pathtofile Path of zip file * @return int <0 if KO, Id of new website if OK */ - function importWebSite($pathtofile) + public function importWebSite($pathtofile) { global $conf, $mysoc; @@ -1195,22 +1195,22 @@ class Website extends CommonObject $out.= ''; } $i=0; - if (is_array($languagecodes)) - { - foreach($languagecodes as $languagecode) - { - if ($languagecode == $languagecodeselected) continue; // Already output - $shortcode = strtolower(substr($languagecode, -2)); - $label = $weblangs->trans("Language_".$languagecode); - if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); - $out.= '
  • '.$label; - if (empty($i) && empty($languagecodeselected)) $out.= ''; - $out.= '
  • '; - $i++; - } - } - $out.= ''; + if (is_array($languagecodes)) + { + foreach($languagecodes as $languagecode) + { + if ($languagecode == $languagecodeselected) continue; // Already output + $shortcode = strtolower(substr($languagecode, -2)); + $label = $weblangs->trans("Language_".$languagecode); + if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); + $out.= '
  • '.$label; + if (empty($i) && empty($languagecodeselected)) $out.= ''; + $out.= '
  • '; + $i++; + } + } + $out.= ''; - return $out; - } + return $out; + } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 62a50ed1a56..8814756284c 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -148,12 +148,12 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object. - * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. - * - If value is < 0, we must exclude this ID. - * @param string $website_id Web site id (page name must also be filled if this parameter is used) - * @param string $page Page name (website id must also be filled if this parameter is used) - * @param string $aliasalt Alternative alias to search page (slow) + * @param int $id Id object. + * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. + * - If value is < 0, we must exclude this ID. + * @param string $website_id Web site id (page name must also be filled if this parameter is used) + * @param string $page Page name (website id must also be filled if this parameter is used) + * @param string $aliasalt Alternative alias to search page (slow) * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -472,7 +472,7 @@ class WebsitePage extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -507,12 +507,12 @@ class WebsitePage extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -520,7 +520,7 @@ class WebsitePage extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -529,32 +529,32 @@ class WebsitePage extends CommonObject { $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } From 1e6ed94c5ea09efede8448a288a009f7da1e9c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 21:39:45 +0100 Subject: [PATCH 045/187] Update extrafields.class.php The property $errno was declared of type integer, but $this->db->lasterrno() is of type string --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0ef7f8d295b..c23f40a0283 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -148,7 +148,7 @@ class ExtraFields public $errors = array(); /** - * @var integer DB Error number + * @var string DB Error number */ public $errno; From 1c5955480645be6fb412e5f10e57265cf2ff53fb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 25 Feb 2019 22:22:31 +0100 Subject: [PATCH 046/187] NEW: Add graphic option for ACCOUNTANCY_COMBO_FOR_AUX --- htdocs/accountancy/admin/index.php | 27 ++++++++++++++++++++++++++- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b3b8a67241b..965b63ba9b9 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -144,6 +144,18 @@ if ($action == 'setenabledraftexport') { } } +if ($action == 'setenablesubsidiarylist') { + $setenablesubsidiarylist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View */ @@ -251,6 +263,19 @@ if (! empty($user->admin)) } print ''; + print ''; + print '' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; + if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print ''; print '' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 472e2166f6b..ca1f98bf64c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -142,6 +142,7 @@ ACCOUNTING_LENGTH_AACCOUNT=Length of the third-party accounting accounts (If you ACCOUNTING_MANAGE_ZERO=Allow to manage different number of zeros at the end of an accounting account. Needed by some countries (like Switzerland). If set to off (default), you can set the following two parameters to ask the application to add virtual zeros. BANK_DISABLE_DIRECT_INPUT=Disable direct recording of transaction in bank account ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL=Enable draft export on journal +ACCOUNTANCY_COMBO_FOR_AUX=Enable combo list for subsidiary account ACCOUNTING_SELL_JOURNAL=Sell journal ACCOUNTING_PURCHASE_JOURNAL=Purchase journal From c89e4d79b807318b51c284ea5b81cf060b21c2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 22:27:04 +0100 Subject: [PATCH 047/187] wip --- dev/translation/autotranslator.class.php | 4 +- .../actions_contactcard_common.class.php | 24 +- .../actions_contactcard_default.class.php | 20 +- htdocs/contact/class/contact.class.php | 4 +- htdocs/core/class/CMailFile.class.php | 102 +++---- htdocs/core/class/antivir.class.php | 8 +- htdocs/core/class/canvas.class.php | 18 +- htdocs/core/class/ccountry.class.php | 10 +- htdocs/core/class/comment.class.php | 10 +- .../core/class/commondocgenerator.class.php | 98 +++---- htdocs/core/class/commoninvoice.class.php | 38 ++- htdocs/core/class/commonobject.class.php | 270 +++++++++--------- .../class/commonstickergenerator.class.php | 34 +-- htdocs/core/class/conf.class.php | 10 +- htdocs/core/class/vcard.class.php | 6 +- .../barcode/doc/phpbarcode.modules.php | 15 +- .../barcode/doc/tcpdfbarcode.modules.php | 12 +- .../modules/barcode/modules_barcode.class.php | 48 ++-- .../class/supplier_proposal.class.php | 18 +- 19 files changed, 376 insertions(+), 373 deletions(-) diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index 4da15890045..789bd8173c4 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -50,7 +50,7 @@ class autoTranslator * @param string $_apikey Api key * @return void */ - function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) + public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) { // Set enviorment variables @@ -346,5 +346,5 @@ class autoTranslator //print "OK ".join('',$src_texts).' => '.$rep."\n"; return $rep; - } + } } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index b78b279122b..9dafaa58f05 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -32,15 +32,15 @@ abstract class ActionsContactCardCommon */ public $db; - var $dirmodule; - var $targetmodule; - var $canvas; - var $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); //! Object container - var $object; + public $object; /** * @var string Error code (or message) @@ -60,7 +60,7 @@ abstract class ActionsContactCardCommon * @param int $id Object id * @return object Object loaded */ - function getObject($id) + public function getObject($id) { /*$ret = $this->getInstanceDao(); @@ -76,7 +76,7 @@ abstract class ActionsContactCardCommon //} } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set content of ->tpl array, to use into template * @@ -84,7 +84,7 @@ abstract class ActionsContactCardCommon * @param int $id Id * @return string HTML output */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $conf, $langs, $user, $canvas; @@ -315,9 +315,9 @@ abstract class ActionsContactCardCommon { dol_print_error($this->db); } - $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; } } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index eee24315dab..4bc23beb2d3 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -37,9 +37,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $targetmodule Name of directory of module where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) - */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -74,7 +74,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param int $id Id * @return void */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -121,7 +121,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -131,13 +131,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { // phpcs:enable - global $conf, $langs; + global $conf, $langs; //$this->getFieldList(); $this->list_datas = array(); - } + } } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index dd095792c40..b2865e8f36f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -273,7 +273,7 @@ class Contact extends CommonObject } } - if (! $error) + if (! $error) { // Call trigger $result=$this->call_trigger('CONTACT_CREATE', $user); @@ -588,7 +588,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c64b408336c..1ad61007ec6 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -40,53 +40,53 @@ class CMailFile public $sendmode; public $sendsetup; - var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - var $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - var $errors_to; // Errors-To: Email where to send errors. - var $addr_to; - var $addr_cc; - var $addr_bcc; - var $trackid; + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. + public $addr_to; + public $addr_cc; + public $addr_bcc; + public $trackid; - var $mixed_boundary; - var $related_boundary; - var $alternative_boundary; - var $deliveryreceipt; + public $mixed_boundary; + public $related_boundary; + public $alternative_boundary; + public $deliveryreceipt; - var $eol; - var $eol2; + public $eol; + public $eol2; /** * @var string Error code (or message) */ public $error=''; - var $smtps; // Contains SMTPs object (if this method is used) - var $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS */ public $css; //! Defined css style for body background - var $styleCSS; + public $styleCSS; //! Defined background directly in body tag - var $bodyCSS; + public $bodyCSS; - var $headers; - var $message; + public $headers; + public $message; // Image - var $html; - var $image_boundary; - var $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - var $html_images=array(); - var $images_encoded=array(); - var $image_types = array( + public $html; + public $image_boundary; + public $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images=array(); + public $images_encoded=array(); + public $image_types = array( 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', @@ -119,7 +119,7 @@ class CMailFile * @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use) * @param string $replyto Reply-to email (will be set to same value than From by default if not provided) */ - function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') + public function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') { global $conf, $dolibarr_main_data_root; @@ -493,7 +493,7 @@ class CMailFile * * @return boolean True if mail sent, false otherwise */ - function sendfile() + public function sendfile() { global $conf,$db,$langs; @@ -844,20 +844,20 @@ class CMailFile * @param string $stringtoencode String to encode * @return string string encoded */ - static function encodetorfc2822($stringtoencode) + public static function encodetorfc2822($stringtoencode) { global $conf; return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read a file on disk and return encoded content for emails (mode = 'mail') * * @param string $sourcefile Path to file to encode * @return int <0 if KO, encoded string if OK */ - function _encode_file($sourcefile) + private function _encode_file($sourcefile) { // phpcs:enable $newsourcefile=dol_osencode($sourcefile); @@ -877,7 +877,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SMTP request into a dump file (mode = all) * Used for debugging. @@ -885,7 +885,7 @@ class CMailFile * * @return void */ - function dump_mail() + public function dump_mail() { // phpcs:enable global $conf,$dolibarr_main_data_root; @@ -923,7 +923,7 @@ class CMailFile * @param string $msg String * @return string Completed string */ - function checkIfHTML($msg) + public function checkIfHTML($msg) { if (!preg_match('/^[\s\t]*css)) { @@ -972,13 +972,13 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create SMTP headers (mode = 'mail') * * @return string headers */ - function write_smtpheaders() + public function write_smtpheaders() { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create header MIME (mode = 'mail') * @@ -1044,7 +1044,7 @@ class CMailFile * @param array $mimefilename_list Array of mime types * @return string mime headers */ - function write_mimeheaders($filename_list, $mimefilename_list) + public function write_mimeheaders($filename_list, $mimefilename_list) { // phpcs:enable $mimedone=0; @@ -1067,14 +1067,14 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return email content (mode = 'mail') * * @param string $msgtext Message string * @return string String content */ - function write_body($msgtext) + public function write_body($msgtext) { // phpcs:enable global $conf; @@ -1169,7 +1169,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach file to email (mode = 'mail') * @@ -1178,7 +1178,7 @@ class CMailFile * @param array $mimefilename_list Tableau * @return string Chaine fichiers encodes */ - function write_files($filename_list, $mimetype_list, $mimefilename_list) + public function write_files($filename_list, $mimetype_list, $mimefilename_list) { // phpcs:enable $out = ''; @@ -1218,14 +1218,14 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach an image to email (mode = 'mail') * * @param array $images_list Array of array image * @return string Chaine images encodees */ - function write_images($images_list) + public function write_images($images_list) { // phpcs:enable $out = ''; @@ -1259,7 +1259,7 @@ class CMailFile * @param int $port Example: 25, 465 * @return int Socket id if ok, 0 if KO */ - function check_server_port($host, $port) + public function check_server_port($host, $port) { // phpcs:enable global $conf; @@ -1315,7 +1315,7 @@ class CMailFile return $_retVal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This function has been modified as provided by SirSir to allow multiline responses when * using SMTP Extensions. @@ -1324,7 +1324,7 @@ class CMailFile * @param string $response Response string * @return boolean true if success */ - function server_parse($socket, $response) + public function server_parse($socket, $response) { // phpcs:enable $_retVal = true; // Indicates if Object was created or not @@ -1354,7 +1354,7 @@ class CMailFile * @param string $images_dir Location of physical images files * @return int >0 if OK, <0 if KO */ - function findHtmlImages($images_dir) + public function findHtmlImages($images_dir) { // Build the list of image extensions $extensions = array_keys($this->image_types); @@ -1456,7 +1456,7 @@ class CMailFile * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists */ - static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) + public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { global $conf; @@ -1523,7 +1523,7 @@ class CMailFile * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' * @return array array of email => name */ - function getArrayAddress($address) + public function getArrayAddress($address) { global $conf; diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index dc0490285be..55bd3a8381d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -55,12 +55,12 @@ class AntiVir * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -69,7 +69,7 @@ class AntiVir * @param string $file File to scan * @return int <0 if KO (-98 if error, -99 if virus), 0 if OK */ - function dol_avscan_file($file) + public function dol_avscan_file($file) { // phpcs:enable global $conf; @@ -153,7 +153,7 @@ class AntiVir * @param string $file File to scan * @return string Full command line to run */ - function getCliCommand($file) + public function getCliCommand($file) { global $conf; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 0250a138fb8..1351f0ea3c7 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -60,7 +60,7 @@ class Canvas * @param DoliDB $db Database handler * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ - function __construct($db, $actiontype = 'view') + public function __construct($db, $actiontype = 'view') { $this->db = $db; @@ -91,7 +91,7 @@ class Canvas * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) * @return void */ - function getCanvas($module, $card, $canvas) + public function getCanvas($module, $card, $canvas) { global $conf, $langs; @@ -133,7 +133,7 @@ class Canvas //print ' => template_dir='.$this->template_dir.'
    '; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Shared method for canvas to assign values for templates * @@ -142,7 +142,7 @@ class Canvas * @param string $ref Object ref (if id not provided) * @return void */ - function assign_values(&$action = 'view', $id = 0, $ref = '') + public function assign_values(&$action = 'view', $id = 0, $ref = '') { // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); @@ -154,7 +154,7 @@ class Canvas * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ - function displayCanvasExists($action) + public function displayCanvasExists($action) { if (empty($this->template_dir)) return 0; @@ -162,7 +162,7 @@ class Canvas else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -170,7 +170,7 @@ class Canvas * @param string $action Action code * @return void */ - function display_canvas($action) + public function display_canvas($action) { // phpcs:enable global $db, $conf, $langs, $user, $canvas; @@ -188,7 +188,7 @@ class Canvas * * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) */ - function hasActions() + public function hasActions() { return (is_object($this->control)); } @@ -204,7 +204,7 @@ class Canvas * @return mixed Return return code of doActions of canvas * @see http://wiki.dolibarr.org/index.php/Canvas_development */ - function doActions(&$action = 'view', $id = 0) + public function doActions(&$action = 'view', $id = 0) { if (method_exists($this->control, 'doActions')) { diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index e93af622a27..a97d992bf89 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -73,7 +73,7 @@ class Ccountry // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -86,7 +86,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -165,7 +165,7 @@ class Ccountry // extends CommonObject * @param string $code Code * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $code = '') + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -214,7 +214,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -285,7 +285,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 6d00b4b8d8d..502ba924513 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -69,7 +69,7 @@ class Comment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -155,7 +155,7 @@ class Comment extends CommonObject * @param int $ref ref object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -213,7 +213,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -278,7 +278,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c1b483efe8c..d4a89c18e19 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -61,7 +61,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -69,7 +69,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_user($user, $outputlangs) + public function get_substitutionarray_user($user, $outputlangs) { // phpcs:enable global $conf; @@ -99,7 +99,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -107,7 +107,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_mysoc($mysoc, $outputlangs) + public function get_substitutionarray_mysoc($mysoc, $outputlangs) { // phpcs:enable global $conf; @@ -159,7 +159,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -167,7 +167,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_thirdparty($object, $outputlangs) + public function get_substitutionarray_thirdparty($object, $outputlangs) { // phpcs:enable global $conf; @@ -240,7 +240,7 @@ abstract class CommonDocGenerator return $array_thirdparty; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -249,7 +249,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution key->code */ - function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -314,14 +314,14 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_other($outputlangs) + public function get_substitutionarray_other($outputlangs) { // phpcs:enable global $conf; @@ -352,7 +352,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -361,7 +361,7 @@ abstract class CommonDocGenerator * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -518,7 +518,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -526,7 +526,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -599,7 +599,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -608,7 +608,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -662,7 +662,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -670,7 +670,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function get_substitutionarray_shipment_lines($line, $outputlangs) + public function get_substitutionarray_shipment_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -683,7 +683,7 @@ abstract class CommonDocGenerator 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), 'line_up'=>price($line->subprice), - 'line_total_up'=>price($line->subprice * $line->qty), + 'line_total_up'=>price($line->subprice * $line->qty), 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, @@ -711,7 +711,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -720,7 +720,7 @@ abstract class CommonDocGenerator * @param boolean $recursive Want to fetch child array or child object * @return array Array of substitution key->code */ - function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) { // phpcs:enable $array_other = array(); @@ -740,7 +740,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fill array with couple extrafield key => extrafield value * @@ -751,8 +751,8 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) - { + public function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) + { // phpcs:enable global $conf; foreach($extrafields->attribute_label as $key=>$label) @@ -838,7 +838,7 @@ abstract class CommonDocGenerator * @param int $hidebottom Hide bottom * @return void */ - function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) + public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) { if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); $pdf->line($x+$l, $y, $x+$l, $y+$h); @@ -848,13 +848,13 @@ abstract class CommonDocGenerator /** - * uasort callback function to Sort colums fields + * uasort callback function to Sort colums fields * - * @param array $a PDF lines array fields configs - * @param array $b PDF lines array fields configs - * @return int Return compare result + * @param array $a PDF lines array fields configs + * @param array $b PDF lines array fields configs + * @return int Return compare result */ - function columnSort($a, $b) + public function columnSort($a, $b) { if(empty($a['rank'])){ $a['rank'] = 0; } if(empty($b['rank'])){ $b['rank'] = 0; } @@ -874,7 +874,7 @@ abstract class CommonDocGenerator * @param int $hideref Do not show ref * @return null */ - function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf; @@ -950,7 +950,7 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return float width in mm */ - function getColumnContentWidth($colKey) + public function getColumnContentWidth($colKey) { $colDef = $this->cols[$colKey]; return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1]; @@ -958,12 +958,12 @@ abstract class CommonDocGenerator /** - * get column content X (abscissa) left position from column key + * get column content X (abscissa) left position from column key * - * @param string $colKey the column key - * @return float X position in mm + * @param string $colKey the column key + * @return float X position in mm */ - function getColumnContentXStart($colKey) + public function getColumnContentXStart($colKey) { $colDef = $this->cols[$colKey]; return $colDef['xStartPos'] + $colDef['content']['padding'][3]; @@ -975,22 +975,22 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return int rank on success and -1 on error */ - function getColumnRank($colKey) + public function getColumnRank($colKey) { if(!isset($this->cols[$colKey]['rank'])) return -1; return $this->cols[$colKey]['rank']; } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ - function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) + public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { // prepare wanted rank $rank = -1; @@ -1033,7 +1033,7 @@ abstract class CommonDocGenerator * @param string $columnText column text * @return int new rank on success and -1 on error */ - function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') + public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { global $hookmanager; @@ -1055,12 +1055,12 @@ abstract class CommonDocGenerator /** - * get column status from column key + * get column status from column key * - * @param string $colKey the column key - * @return float width in mm + * @param string $colKey the column key + * @return float width in mm */ - function getColumnStatus($colKey) + public function getColumnStatus($colKey) { if( !empty($this->cols[$colKey]['status'])){ return true; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7e8c9002042..5926f954a46 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -97,7 +97,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return double Remain of amount to pay */ - function getRemainToPay($multicurrency = 0) + public function getRemainToPay($multicurrency = 0) { $alreadypaid=0; $alreadypaid+=$this->getSommePaiement($multicurrency); @@ -112,7 +112,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement($multicurrency = 0) + public function getSommePaiement($multicurrency = 0) { $table='paiement_facture'; $field='fk_facture'; @@ -149,7 +149,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of deposits amount otherwise */ - function getSumDepositsUsed($multicurrency = 0) + public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -178,7 +178,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumCreditNotesUsed($multicurrency = 0) + public function getSumCreditNotesUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject * * @return array Tableau d'id de factures avoirs */ - function getListIdAvoirFromInvoice() + public function getListIdAvoirFromInvoice() { $idarray=array(); @@ -233,7 +233,7 @@ abstract class CommonInvoice extends CommonObject * @param string $option filtre sur statut ('', 'validated', ...) * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon */ - function getIdReplacingInvoice($option = '') + public function getIdReplacingInvoice($option = '') { $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -274,7 +274,7 @@ abstract class CommonInvoice extends CommonObject * @param string $filtertype 1 to filter on type of payment == 'PRE' * @return array Array with list of payments */ - function getListOfPayments($filtertype = '') + public function getListOfPayments($filtertype = '') { $retarray=array(); @@ -325,7 +325,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -339,8 +339,8 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - function is_erasable() - { + public function is_erasable() + { // phpcs:enable global $conf; @@ -428,7 +428,7 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - function getLibType() + public function getLibType() { global $langs; if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); @@ -447,12 +447,12 @@ abstract class CommonInvoice extends CommonObject * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -463,18 +463,16 @@ abstract class CommonInvoice extends CommonObject * @param int $type Type invoice * @return string Label of status */ - function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; $langs->load('bills'); //print "$paye,$status,$mode,$alreadypaid,$type"; - if ($mode == 0) - { + if ($mode == 0) { $prefix=''; - if (! $paye) - { + if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); @@ -585,7 +583,7 @@ abstract class CommonInvoice extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi une date limite de reglement de facture en fonction des * conditions de reglements de la facture et date de facturation. @@ -593,7 +591,7 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return date Date limite de reglement si ok, <0 si ko */ - function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { // phpcs:enable if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1f86d60598c..b5a166e764b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -423,7 +423,7 @@ abstract class CommonObject * @param string $ref_ext Ref ext of object to check * @return int <0 if KO, 0 if OK but not found, >0 if OK and exists */ - static function isExistingObject($element, $id, $ref = '', $ref_ext = '') + public static function isExistingObject($element, $id, $ref = '', $ref_ext = '') { global $db,$conf; @@ -457,7 +457,7 @@ abstract class CommonObject * * @return string String with errors */ - function errorsToString() + public function errorsToString() { return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ', $this->errors)):''); } @@ -468,7 +468,7 @@ abstract class CommonObject * @param string $objref Customer ref * @return string Customer ref formated */ - function getFormatedCustomerRef($objref) + public function getFormatedCustomerRef($objref) { global $hookmanager; @@ -488,7 +488,7 @@ abstract class CommonObject * @param string $objref Supplier ref * @return string Supplier ref formated */ - function getFormatedSupplierRef($objref) + public function getFormatedSupplierRef($objref) { global $hookmanager; @@ -511,7 +511,7 @@ abstract class CommonObject * @param int $maxlen Maximum length * @return string String with full name */ - function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) { //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."
    \n"; $lastname=$this->lastname; @@ -538,7 +538,7 @@ abstract class CommonObject * @param int $withregion 1=Add region into address string * @return string Full address string */ - function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) + public function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { @@ -569,7 +569,7 @@ abstract class CommonObject * @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member) * @return string Full address string */ - function getBannerAddress($htmlkey, $object) + public function getBannerAddress($htmlkey, $object) { global $conf, $langs; @@ -688,7 +688,7 @@ abstract class CommonObject * @param int $relativelink 0=Return full external link, 1=Return link relative to root of file * @return string Link or empty string if there is no download link */ - function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) + public function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) { global $user, $dolibarr_main_url_root; @@ -775,7 +775,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between element $this->element and a contact * @@ -785,7 +785,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) + public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { // phpcs:enable global $user,$langs; @@ -899,7 +899,7 @@ abstract class CommonObject } else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Copy contact from one element to current * @@ -907,7 +907,7 @@ abstract class CommonObject * @param string $source Nature of contact ('internal' or 'external') * @return int >0 if OK, <0 if KO */ - function copy_linked_contact($objFrom, $source = 'internal') + public function copy_linked_contact($objFrom, $source = 'internal') { // phpcs:enable $contacts = $objFrom->liste_contact(-1, $source); @@ -922,7 +922,7 @@ abstract class CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a link to contact line * @@ -932,7 +932,7 @@ abstract class CommonObject * @param int $fk_socpeople Id of soc_people to update (not modified if 0) * @return int <0 if KO, >= 0 if OK */ - function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) + public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) { // phpcs:enable // Insert into database @@ -953,7 +953,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to contact line * @@ -961,7 +961,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_contact($rowid, $notrigger = 0) + public function delete_contact($rowid, $notrigger = 0) { // phpcs:enable global $user; @@ -992,7 +992,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete all links between an object $this and all its contacts * @@ -1000,7 +1000,7 @@ abstract class CommonObject * @param string $code Type of contact (code or id) * @return int >0 if OK, <0 if KO */ - function delete_linked_contact($source = '', $code = '') + public function delete_linked_contact($source = '', $code = '') { // phpcs:enable $temp = array(); @@ -1029,7 +1029,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get array of all contacts for an object * @@ -1039,7 +1039,7 @@ abstract class CommonObject * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array|int Array of contacts, -1 if error */ - function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') + public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') { // phpcs:enable global $langs; @@ -1109,7 +1109,7 @@ abstract class CommonObject * @param int $rowid Id of link between object and contact * @return int <0 if KO, >=0 if OK */ - function swapContactStatus($rowid) + public function swapContactStatus($rowid) { $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; $sql.= " tc.code, tc.libelle"; @@ -1138,7 +1138,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with list of possible values for type of contacts * @@ -1149,7 +1149,7 @@ abstract class CommonObject * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ - function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') + public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { // phpcs:enable global $langs; @@ -1203,7 +1203,7 @@ abstract class CommonObject * @param int $status limited to a certain status * @return array List of id for such contacts */ - function getIdContact($source, $code, $status = 0) + public function getIdContact($source, $code, $status = 0) { global $conf; @@ -1256,14 +1256,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object contact with id=$this->contactid into $this->contact * * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid = null) + public function fetch_contact($contactid = null) { // phpcs:enable if (empty($contactid)) $contactid=$this->contactid; @@ -1277,14 +1277,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable global $conf; @@ -1340,7 +1340,7 @@ abstract class CommonObject return $this->fetch($result->rowid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load data for barcode into properties ->barcode_type* * Properties ->barcode_type that is id of barcode. Type is used to find other properties, but @@ -1348,7 +1348,7 @@ abstract class CommonObject * * @return int <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded) */ - function fetch_barcode() + public function fetch_barcode() { // phpcs:enable global $conf; @@ -1391,13 +1391,13 @@ abstract class CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ - function fetch_projet() + public function fetch_projet() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -1413,13 +1413,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the product with id $this->fk_product into this->product * * @return int <0 if KO, >=0 if OK */ - function fetch_product() + public function fetch_product() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -1433,14 +1433,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK */ - function fetch_user($userid) + public function fetch_user($userid) { // phpcs:enable $user = new User($this->db); @@ -1449,13 +1449,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read linked origin object * * @return void */ - function fetch_origin() + public function fetch_origin() { // phpcs:enable if ($this->origin == 'shipping') $this->origin = 'expedition'; @@ -1478,7 +1478,7 @@ abstract class CommonObject * @param string $element Element name * @return int <0 if KO, >0 if OK */ - function fetchObjectFrom($table, $field, $key, $element = null) + public function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1514,7 +1514,7 @@ abstract class CommonObject * @param string $field Field selected * @return int <0 if KO, >0 if OK */ - function getValueFrom($table, $id, $field) + public function getValueFrom($table, $id, $field) { $result=false; if (!empty($id) && !empty($field) && !empty($table)) { @@ -1548,7 +1548,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see updateExtraField() */ - function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') + public function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') { global $user,$langs,$conf; @@ -1618,7 +1618,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties id_previous and id_next by comparing $fieldid with $this->ref * @@ -1627,7 +1627,7 @@ abstract class CommonObject * @param int $nodbprefix Do not include DB prefix to forge table name * @return int <0 if KO, >0 if OK */ - function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) + public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) { // phpcs:enable global $conf, $user; @@ -1751,7 +1751,7 @@ abstract class CommonObject * @return array Array of id of contacts (if source=external or internal) * Array of id of third parties with at least one contact on object (if source=thirdparty) */ - function getListContactId($source = 'external') + public function getListContactId($source = 'external') { $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); @@ -1773,7 +1773,7 @@ abstract class CommonObject * @param int $projectid Project id to link element to * @return int <0 if KO, >0 if OK */ - function setProject($projectid) + public function setProject($projectid) { if (! $this->table_element) { @@ -1814,7 +1814,7 @@ abstract class CommonObject * @param int $id Id of new payment method * @return int >0 if OK, <0 if KO */ - function setPaymentMethods($id) + public function setPaymentMethods($id) { dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1856,7 +1856,7 @@ abstract class CommonObject * @param string $code multicurrency code * @return int >0 if OK, <0 if KO */ - function setMulticurrencyCode($code) + public function setMulticurrencyCode($code) { dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1898,7 +1898,7 @@ abstract class CommonObject * @param int $mode mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency * @return int >0 if OK, <0 if KO */ - function setMulticurrencyRate($rate, $mode = 1) + public function setMulticurrencyRate($rate, $mode = 1) { dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1999,7 +1999,7 @@ abstract class CommonObject * @param int $id Id of new payment terms * @return int >0 if OK, <0 if KO */ - function setPaymentTerms($id) + public function setPaymentTerms($id) { dol_syslog(get_class($this).'::setPaymentTerms('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -2043,7 +2043,7 @@ abstract class CommonObject * @param int $id Address id * @return int <0 si ko, >0 si ok */ - function setDeliveryAddress($id) + public function setDeliveryAddress($id) { $fieldname = 'fk_delivery_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; @@ -2074,7 +2074,7 @@ abstract class CommonObject * * @return int 1 if OK, 0 if KO */ - function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) + public function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) { global $user; @@ -2128,7 +2128,7 @@ abstract class CommonObject * @param int $warehouse_id Id of warehouse * @return int 1 if OK, 0 if KO */ - function setWarehouse($warehouse_id) + public function setWarehouse($warehouse_id) { if (! $this->table_element) { dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); @@ -2159,7 +2159,7 @@ abstract class CommonObject * @param string $modelpdf Modele name * @return int <0 if KO, >0 if OK */ - function setDocModel($user, $modelpdf) + public function setDocModel($user, $modelpdf) { if (! $this->table_element) { @@ -2198,7 +2198,7 @@ abstract class CommonObject * @param User $userused Object user * @return int 1 if OK, 0 if KO */ - function setBankAccount($fk_account, $notrigger = false, $userused = null) + public function setBankAccount($fk_account, $notrigger = false, $userused = null) { global $user; @@ -2253,7 +2253,7 @@ abstract class CommonObject // TODO: Move line related operations to CommonObjectLine? - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. @@ -2263,7 +2263,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return int <0 if KO, >0 if OK */ - function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) + public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) { // phpcs:enable if (! $this->table_element_line) @@ -2348,7 +2348,7 @@ abstract class CommonObject * @param int $id Id of parent line * @return array Array with list of children lines id */ - function getChildrenOfLine($id) + public function getChildrenOfLine($id) { $rows=array(); @@ -2374,7 +2374,7 @@ abstract class CommonObject return $rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a lower rank * @@ -2382,7 +2382,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_up($rowid, $fk_parent_line = true) + public function line_up($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2394,7 +2394,7 @@ abstract class CommonObject $this->updateLineUp($rowid, $rang); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a higher rank * @@ -2402,7 +2402,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_down($rowid, $fk_parent_line = true) + public function line_down($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2424,7 +2424,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateRangOfLine($rowid, $rang) + public function updateRangOfLine($rowid, $rang) { $fieldposition = 'rang'; if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; @@ -2439,14 +2439,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update position of line with ajax (rang) * * @param array $rows Array of rows * @return void */ - function line_ajaxorder($rows) + public function line_ajaxorder($rows) { // phpcs:enable $num = count($rows); @@ -2463,7 +2463,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateLineUp($rowid, $rang) + public function updateLineUp($rowid, $rang) { if ($rang > 1) { @@ -2497,7 +2497,7 @@ abstract class CommonObject * @param int $max Max * @return void */ - function updateLineDown($rowid, $rang, $max) + public function updateLineDown($rowid, $rang, $max) { if ($rang < $max) { @@ -2529,7 +2529,7 @@ abstract class CommonObject * @param int $rowid Id of line * @return int Value of rang in table of lines */ - function getRangOfLine($rowid) + public function getRangOfLine($rowid) { $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid ='.$rowid; @@ -2549,7 +2549,7 @@ abstract class CommonObject * @param int $rang Rang value * @return int Rowid of the line */ - function getIdOfLine($rang) + public function getIdOfLine($rang) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; @@ -2562,14 +2562,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value used for position of line (rang) * * @param int $fk_parent_line Parent line id * @return int Max value of rang in table of lines */ - function line_max($fk_parent_line = 0) + public function line_max($fk_parent_line = 0) { // phpcs:enable // Search the last rang with fk_parent_line @@ -2610,14 +2610,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update external ref of element * * @param string $ref_ext Update field ref_ext * @return int <0 if KO, >0 if OK */ - function update_ref_ext($ref_ext) + public function update_ref_ext($ref_ext) { // phpcs:enable if (! $this->table_element) @@ -2643,7 +2643,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update note of element * @@ -2651,7 +2651,7 @@ abstract class CommonObject * @param string $suffix '', '_public' or '_private' * @return int <0 if KO, >0 if OK */ - function update_note($note, $suffix = '') + public function update_note($note, $suffix = '') { // phpcs:enable global $user; @@ -2696,7 +2696,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update public note (kept for backward compatibility) * @@ -2705,13 +2705,13 @@ abstract class CommonObject * @deprecated * @see update_note() */ - function update_note_public($note) + public function update_note_public($note) { // phpcs:enable return $this->update_note($note, '_public'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). * Must be called at end of methods addline or updateline. @@ -2722,7 +2722,7 @@ abstract class CommonObject * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object. * @return int <0 if KO, >0 if OK */ - function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) + public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) { // phpcs:enable global $conf, $hookmanager, $action; @@ -2950,7 +2950,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add objects linked in llx_element_element. * @@ -2959,7 +2959,7 @@ abstract class CommonObject * @return int <=0 if KO, >0 if OK * @see fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked() */ - function add_object_linked($origin = null, $origin_id = null) + public function add_object_linked($origin = null, $origin_id = null) { // phpcs:enable $origin = (! empty($origin) ? $origin : $this->origin); @@ -3020,7 +3020,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see add_object_linked(), updateObjectLinked(), deleteObjectLinked() */ - function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) + public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) { global $conf; @@ -3224,7 +3224,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked(), fetObjectLinked(), deleteObjectLinked() */ - function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') + public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') { $updatesource=false; $updatetarget=false; @@ -3271,7 +3271,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked, updateObjectLinked, fetchObjectLinked */ - function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') { $deletesource=false; $deletetarget=false; @@ -3332,7 +3332,7 @@ abstract class CommonObject * @param string $trigkey Trigger key to use for trigger * @return int <0 if KO, >0 if OK */ - function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') + public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') { global $user,$langs,$conf; @@ -3420,7 +3420,7 @@ abstract class CommonObject * @param string $ref Record ref * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function getCanvas($id = 0, $ref = '') + public function getCanvas($id = 0, $ref = '') { global $conf; @@ -3461,7 +3461,7 @@ abstract class CommonObject * @param int $lineid Id of line * @return int Special code */ - function getSpecialCode($lineid) + public function getSpecialCode($lineid) { $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid = '.$lineid; @@ -3480,7 +3480,7 @@ abstract class CommonObject * @param int $id Force id of object * @return int <0 if KO, 0 if not used, >0 if already used */ - function isObjectUsed($id = 0) + public function isObjectUsed($id = 0) { global $langs; @@ -3549,7 +3549,7 @@ abstract class CommonObject * @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service * @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found */ - function hasProductsOrServices($predefined = -1) + public function hasProductsOrServices($predefined = -1) { $nb=0; @@ -3572,7 +3572,7 @@ abstract class CommonObject * * @return float */ - function getTotalDiscount() + public function getTotalDiscount() { $total_discount=0.00; @@ -3612,7 +3612,7 @@ abstract class CommonObject * * @return array array('weight'=>...,'volume'=>...) */ - function getTotalWeightVolume() + public function getTotalWeightVolume() { $totalWeight = 0; $totalVolume = 0; @@ -3706,7 +3706,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function setExtraParameters() + public function setExtraParameters() { $this->db->begin(); @@ -3739,7 +3739,7 @@ abstract class CommonObject * * @return string incoterms info */ - function display_incoterms() + public function display_incoterms() { // phpcs:enable $out = ''; @@ -3765,7 +3765,7 @@ abstract class CommonObject * * @return string incoterms info */ - function getIncotermsForPDF() + public function getIncotermsForPDF() { $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $resql = $this->db->query($sql); @@ -3796,7 +3796,7 @@ abstract class CommonObject * @param string $location location of incoterm * @return int <0 if KO, >0 if OK */ - function setIncoterms($id_incoterm, $location) + public function setIncoterms($id_incoterm, $location) { if ($this->id && $this->table_element) { @@ -3844,7 +3844,7 @@ abstract class CommonObject * @param Societe $buyer Object thirdparty who buy * @return void */ - function formAddObjectLine($dateSelector, $seller, $buyer) + public function formAddObjectLine($dateSelector, $seller, $buyer) { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; @@ -3887,7 +3887,7 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @return void */ - function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) + public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) { global $conf, $hookmanager, $langs, $user; // TODO We should not use global var for this ! @@ -4029,8 +4029,8 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output * @param string $var Is it a an odd line (true) * @param int $num Number of line (0) * @param int $i I @@ -4041,7 +4041,7 @@ abstract class CommonObject * @param int $extrafieldsline Object of extrafield line attribute * @return void */ - function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) + public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; @@ -4159,7 +4159,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only * @return void */ - function printOriginLinesList($restrictlist = '') + public function printOriginLinesList($restrictlist = '') { global $langs, $hookmanager, $conf; @@ -4213,7 +4213,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @return void */ - function printOriginLine($line, $var, $restrictlist = '') + public function printOriginLine($line, $var, $restrictlist = '') { global $langs, $conf; @@ -4348,7 +4348,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4359,7 +4359,7 @@ abstract class CommonObject * @param int $mandatory Mandatory or not * @return int <=0 if KO, >0 if OK */ - function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) + public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) { // phpcs:enable $this->db->begin(); @@ -4394,7 +4394,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to resource line * @@ -4403,7 +4403,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_resource($rowid, $element, $notrigger = 0) + public function delete_resource($rowid, $element, $notrigger = 0) { // phpcs:enable global $user; @@ -4440,7 +4440,7 @@ abstract class CommonObject * * @return void */ - function __clone() + public function __clone() { // Force a copy of this->lines, otherwise it will point to same object. if (isset($this->lines) && is_array($this->lines)) @@ -4617,9 +4617,15 @@ abstract class CommonObject if ($useonlinesignature) $setsharekey=true; if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } if ($setsharekey) { @@ -4717,7 +4723,7 @@ abstract class CommonObject * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void */ - function addThumbs($file) + public function addThumbs($file) { global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; @@ -4753,7 +4759,7 @@ abstract class CommonObject * @param string $alternatevalue Alternate value to use * @return string|string[] Default value (can be an array if the GETPOST return an array) **/ - function getDefaultCreateValueFor($fieldname, $alternatevalue = null) + public function getDefaultCreateValueFor($fieldname, $alternatevalue = null) { global $conf, $_POST; @@ -4782,7 +4788,7 @@ abstract class CommonObject /* For triggers */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance. * Some context information may also be provided into array property this->context. @@ -4793,7 +4799,7 @@ abstract class CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; @@ -4820,7 +4826,7 @@ abstract class CommonObject /* Functions for extrafields */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get extra fields of an object into $this->array_options * This method is in most cases called by method fetch of objects but you can call it separately. @@ -4829,7 +4835,7 @@ abstract class CommonObject * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ - function fetch_optionals($rowid = null, $optionsArray = null) + public function fetch_optionals($rowid = null, $optionsArray = null) { // phpcs:enable if (empty($rowid)) $rowid=$this->id; @@ -4940,7 +4946,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function deleteExtraFields() + public function deleteExtraFields() { $this->db->begin(); @@ -4973,7 +4979,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see updateExtraField(), setValueFrom() */ - function insertExtraFields($trigger = '', $userused = null) + public function insertExtraFields($trigger = '', $userused = null) { global $conf,$langs,$user; @@ -5219,7 +5225,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see setValueFrom(), insertExtraFields() */ - function updateExtraField($key, $trigger = null, $userused = null) + public function updateExtraField($key, $trigger = null, $userused = null) { global $conf,$langs,$user; @@ -5353,7 +5359,7 @@ abstract class CommonObject * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @return string */ - function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) { global $conf,$langs,$form; @@ -5963,7 +5969,7 @@ abstract class CommonObject * @param mixed $showsize Value for css to define size. May also be a numeric. * @return string */ - function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) + public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) { global $conf,$langs,$form; @@ -6334,7 +6340,7 @@ abstract class CommonObject * @param string $onetrtd All fields in same tr td * @return string */ - function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) { global $db, $conf, $langs, $action, $form; @@ -6642,7 +6648,7 @@ abstract class CommonObject return $buyPrice; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show photos of an object (nbmax maximum), into several columns * @@ -6660,7 +6666,7 @@ abstract class CommonObject * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) + public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) { // phpcs:enable global $conf,$user,$langs; @@ -7474,15 +7480,15 @@ abstract class CommonObject return count($this->comments); } - /** - * Return nb comments already posted - * - * @return int - */ - public function getNbComments() - { - return count($this->comments); - } + /** + * Return nb comments already posted + * + * @return int + */ + public function getNbComments() + { + return count($this->comments); + } /** * Trim object parameters diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 0055559c4dc..bbdc6222921 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -69,23 +69,23 @@ abstract class CommonStickerGenerator public $format; // protected - var $_Avery_Name = ''; // Nom du format de l'etiquette - var $_Margin_Left = 0; // Marge de gauche de l'etiquette - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page - var $_Width = 0; // Largeur de chaque etiquette - var $_Height = 0; // Hauteur de chaque etiquette - var $_Char_Size = 10; // Hauteur des caracteres - var $_Line_Height = 10; // Hauteur par defaut d'une ligne - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. - var $_COUNTX = 1; - var $_COUNTY = 1; - var $_First = 1; - var $Tformat; + public $_Avery_Name = ''; // Nom du format de l'etiquette + public $_Margin_Left = 0; // Marge de gauche de l'etiquette + public $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette + public $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes + public $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes + public $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page + public $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page + public $_Width = 0; // Largeur de chaque etiquette + public $_Height = 0; // Hauteur de chaque etiquette + public $_Char_Size = 10; // Hauteur des caracteres + public $_Line_Height = 10; // Hauteur par defaut d'une ligne + public $_Metric = 'mm'; // Type of metric.. Will help to calculate good values + public $_Metric_Doc = 'mm'; // Type of metric for the doc.. + public $_COUNTX = 1; + public $_COUNTY = 1; + public $_First = 1; + public $Tformat; /** * Constructor diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5de1475a3f0..2e7ef692324 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -34,7 +34,7 @@ class Conf { /** \public */ //! To store properties found in conf file - var $file; + public $file; /** * @var DoliDB Database handler. @@ -42,9 +42,9 @@ class Conf public $db; //! To store properties found into database - var $global; + public $global; //! To store browser info - var $browser; + public $browser; //! To store if javascript/ajax is enabked public $use_javascript_ajax; @@ -59,12 +59,12 @@ class Conf public $modules = array(); // List of activated modules public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array(), 'syslog' =>array()); - var $logbuffer = array(); + public $logbuffer = array(); /** * @var LogHandlerInterface[] */ - var $loghandlers = array(); + public $loghandlers = array(); //! To store properties of multi-company public $multicompany; diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index cf19b43145d..3a2b9e70830 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -84,11 +84,11 @@ function dol_quoted_printable_encode($input, $line_max = 76) */ class vCard { - var $properties; - var $filename; + public $properties; + public $filename; //var $encoding="UTF-8"; - var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; /** diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index cfbe51b0579..19744177e40 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -49,7 +49,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -60,7 +60,7 @@ class modPhpbarcode extends ModeleBarCode * * @return string Texte descripif */ - function info() + public function info() { global $langs; @@ -76,7 +76,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -90,7 +90,7 @@ class modPhpbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { global $genbarcode_loc; //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; @@ -100,8 +100,7 @@ class modPhpbarcode extends ModeleBarCode if ($encoding == 'ISBN') $supported=1; // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not // activated on Windows) - if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) - { + if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) { if ($encoding == 'EAN8') $supported=1; if ($encoding == 'UPC') $supported=1; if ($encoding == 'C39') $supported=1; @@ -120,7 +119,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET,$_SERVER; global $conf; @@ -161,7 +160,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$filebarcode; diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index f6eff1e2c5d..17793a5dfd4 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -49,7 +49,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return string Text with description */ - function info() + public function info() { global $langs; @@ -61,7 +61,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -72,7 +72,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -85,7 +85,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { @@ -105,7 +105,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET; @@ -152,7 +152,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$_GET; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 7e0eba53571..6a205b57d8c 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -29,21 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ abstract class ModeleBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Return if a model can be used or not - * - * @return boolean true if model can be used - */ - function isEnabled() - { - return true; - } + /** + * Return if a model can be used or not + * + * @return boolean true if model can be used + */ + public function isEnabled() + { + return true; + } } @@ -52,17 +52,17 @@ abstract class ModeleBarCode */ abstract class ModeleNumRefBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return default description of numbering model * * @param Translate $langs Object langs * @return string Descriptive text */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -73,7 +73,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Model name */ - function getNom($langs) + public function getNom($langs) { return empty($this->name)?$this->nom:$this->name; } @@ -83,7 +83,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -96,17 +96,17 @@ abstract class ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value */ - function getNextValue($objproduct, $type = '') + public function getNextValue($objproduct, $type = '') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module + /** Return version of module * * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -126,7 +126,7 @@ abstract class ModeleNumRefBarCode * @param int $type -1=Nothing, 0=Product, 1=Service * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 6b9c5d3db26..bf731262cbd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1047,13 +1047,13 @@ class SupplierProposal extends CommonObject $action='update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } if (! $error && ! $notrigger) @@ -1871,7 +1871,7 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -1984,7 +1984,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; From 915841eeb9fba297d6b5cc57d91a4323a79ac025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 22:50:19 +0100 Subject: [PATCH 048/187] wip --- htdocs/core/class/utils.class.php | 18 +- htdocs/core/modules/DolibarrModules.class.php | 179 ++++++++++-------- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modFournisseur.class.php | 15 +- htdocs/core/modules/modOpenSurvey.class.php | 108 ++++++----- htdocs/core/modules/modPrelevement.class.php | 2 +- htdocs/core/modules/modProductBatch.class.php | 2 +- htdocs/core/modules/modSalaries.class.php | 4 +- htdocs/core/modules/modSociete.class.php | 4 +- htdocs/exports/class/export.class.php | 4 +- 10 files changed, 184 insertions(+), 154 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 6cacf353ca1..f0850dabae1 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -32,15 +32,15 @@ class Utils */ public $db; - var $output; // Used by Cron method to return message - var $result; // Used by Cron method to return data + public $output; // Used by Cron method to return message + public $result; // Used by Cron method to return data /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -53,7 +53,7 @@ class Utils * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile') * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function purgeFiles($choice = 'tempfilesold') + public function purgeFiles($choice = 'tempfilesold') { global $conf, $langs, $dolibarr_main_data_root; @@ -182,7 +182,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) + public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; @@ -501,7 +501,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK. */ - function executeCLI($command, $outputfile, $execmethod = 0) + public function executeCLI($command, $outputfile, $execmethod = 0) { global $conf, $langs; @@ -570,7 +570,7 @@ class Utils * @param string $module Module name * @return int <0 if KO, >0 if OK */ - function generateDoc($module) + public function generateDoc($module) { global $conf, $langs; global $dirins; @@ -737,7 +737,7 @@ class Utils * * @return int 0 if OK, < 0 if KO */ - function compressSyslogs() + public function compressSyslogs() { global $conf; @@ -855,7 +855,7 @@ class Utils * @param string $tables Table name or '*' for all * @return int <0 if KO, >0 if OK */ - function backupTables($outputfile, $tables = '*') + public function backupTables($outputfile, $tables = '*') { global $db, $langs; global $errormsg; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 76033d4c0cb..4aa74e22d5f 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2018 Josep Lluís Amador + * 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 @@ -334,7 +335,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin; @@ -381,7 +382,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _init($array_sql, $options = '') + private function _init($array_sql, $options = '') { global $conf; $err=0; @@ -389,39 +390,48 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $this->db->begin(); // Insert activation module constant - if (! $err) { $err+=$this->_active(); + if (! $err) { + $err+=$this->_active(); } // Insert new pages for tabs (into llx_const) - if (! $err) { $err+=$this->insert_tabs(); + if (! $err) { + $err+=$this->insert_tabs(); } // Insert activation of module's parts - if (! $err) { $err+=$this->insert_module_parts(); + if (! $err) { + $err+=$this->insert_module_parts(); } // Insert constant defined by modules (into llx_const) - if (! $err && ! preg_match('/newboxdefonly/', $options)) { $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade + if (! $err && ! preg_match('/newboxdefonly/', $options)) { + $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade } // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) - if (! $err && ! preg_match('/noboxes/', $options)) { $err+=$this->insert_boxes($options); + if (! $err && ! preg_match('/noboxes/', $options)) { + $err+=$this->insert_boxes($options); } // Insert cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->insert_cronjobs(); + if (! $err) { + $err+=$this->insert_cronjobs(); } // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. - if (! $err) { $err+=$this->insert_permissions(1, null, 1); + if (! $err) { + $err+=$this->insert_permissions(1, null, 1); } // Insert specific menus entries into database - if (! $err) { $err+=$this->insert_menus(); + if (! $err) { + $err+=$this->insert_menus(); } // Create module's directories - if (! $err) { $err+=$this->create_dirs(); + if (! $err) { + $err+=$this->create_dirs(); } // Execute addons requests @@ -474,46 +484,55 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _remove($array_sql, $options = '') + private function _remove($array_sql, $options = '') { $err=0; $this->db->begin(); // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const) - if (! $err) { $err+=$this->_unactive(); + if (! $err) { + $err+=$this->_unactive(); } // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const) - if (! $err) { $err+=$this->delete_tabs(); + if (! $err) { + $err+=$this->delete_tabs(); } // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const) - if (! $err) { $err+=$this->delete_module_parts(); + if (! $err) { + $err+=$this->delete_module_parts(); } // Remove constants defined by modules - if (! $err) { $err+=$this->delete_const(); + if (! $err) { + $err+=$this->delete_const(); } // Remove list of module's available boxes (entry in llx_boxes) - if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only + if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { + $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only } // Remove list of module's cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->delete_cronjobs(); + if (! $err) { + $err+=$this->delete_cronjobs(); } // Remove module's permissions from list of available permissions (entries in llx_rights_def) - if (! $err) { $err+=$this->delete_permissions(); + if (! $err) { + $err+=$this->delete_permissions(); } // Remove module's menus (entries in llx_menu) - if (! $err) { $err+=$this->delete_menus(); + if (! $err) { + $err+=$this->delete_menus(); } // Remove module's directories - if (! $err) { $err+=$this->delete_dirs(); + if (! $err) { + $err+=$this->delete_dirs(); } // Run complementary sql requests @@ -549,7 +568,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module name */ - function getName() + public function getName() { global $langs; $langs->load("admin"); @@ -585,7 +604,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module description */ - function getDesc() + public function getDesc() { global $langs; $langs->load("admin"); @@ -621,7 +640,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Long description of a module from README.md of from property. */ - function getDescLong() + public function getDescLong() { global $langs; $langs->load("admin"); @@ -675,7 +694,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Path of file if a README file was found. */ - function getDescLongReadmeFound() + public function getDescLongReadmeFound() { global $langs; @@ -710,7 +729,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Content of ChangeLog */ - function getChangeLog() + public function getChangeLog() { global $langs; $langs->load("admin"); @@ -755,7 +774,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher name */ - function getPublisher() + public function getPublisher() { return $this->editor_name; } @@ -765,7 +784,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher url */ - function getPublisherUrl() + public function getPublisherUrl() { return $this->editor_url; } @@ -778,7 +797,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $translated 1=Special version keys are translated, 0=Special version keys are not translated * @return string Module version */ - function getVersion($translated = 1) + public function getVersion($translated = 1) { global $langs; $langs->load("admin"); @@ -804,7 +823,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string 'core', 'external' or 'unknown' */ - function isCoreOrExternalModule() + public function isCoreOrExternalModule() { if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { return 'core'; } @@ -823,7 +842,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string[] Language files list */ - function getLangFilesArray() + public function getLangFilesArray() { return $this->langfiles; } @@ -835,7 +854,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated databaset label */ - function getExportDatasetLabel($r) + public function getExportDatasetLabel($r) { global $langs; @@ -859,7 +878,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated dataset label */ - function getImportDatasetLabel($r) + public function getImportDatasetLabel($r) { global $langs; @@ -882,7 +901,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return timestamp Date of last activation */ - function getLastActivationDate() + public function getLastActivationDate() { global $conf; @@ -909,7 +928,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) */ - function getLastActivationInfo() + public function getLastActivationInfo() { global $conf; @@ -940,7 +959,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _active() + private function _active() { global $conf, $user; @@ -980,7 +999,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _unactive() + private function _unactive() { global $conf; @@ -1000,7 +1019,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys @@ -1010,7 +1029,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param string $reldir Relative directory where to scan files * @return int <=0 if KO, >0 if OK */ - function _load_tables($reldir) + private function _load_tables($reldir) { // phpcs:enable global $conf; @@ -1119,7 +1138,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds boxes * @@ -1127,7 +1146,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_boxes($option = '') + public function insert_boxes($option = '') { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1219,13 +1238,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_boxes() + public function delete_boxes() { // phpcs:enable global $conf; @@ -1292,13 +1311,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds cronjobs * * @return int Error count (0 if OK) */ - function insert_cronjobs() + public function insert_cronjobs() { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1332,13 +1351,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if cron entry already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; - if ($class) { $sql.= " AND classesname = '".$this->db->escape($class)."'"; + if ($class) { + $sql.= " AND classesname = '".$this->db->escape($class)."'"; } - if ($objectname) { $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; + if ($objectname) { + $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; } - if ($method) { $sql.= " AND methodename = '".$this->db->escape($method)."'"; + if ($method) { + $sql.= " AND methodename = '".$this->db->escape($method)."'"; } - if ($command) { $sql.= " AND command = '".$this->db->escape($command)."'"; + if ($command) { + $sql.= " AND command = '".$this->db->escape($command)."'"; } $sql.= " AND entity = ".$entity; // Must be exact entity @@ -1410,13 +1433,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_cronjobs() + public function delete_cronjobs() { // phpcs:enable global $conf; @@ -1441,13 +1464,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes tabs * * @return int Error count (0 if OK) */ - function delete_tabs() + public function delete_tabs() { // phpcs:enable global $conf; @@ -1467,13 +1490,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds tabs * * @return int Error count (0 if ok) */ - function insert_tabs() + public function insert_tabs() { // phpcs:enable global $conf; @@ -1533,13 +1556,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds constants * * @return int Error count (0 if OK) */ - function insert_const() + public function insert_const() { // phpcs:enable global $conf; @@ -1605,13 +1628,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes constants tagged 'deleteonunactive' * * @return int <0 if KO, 0 if OK */ - function delete_const() + public function delete_const() { // phpcs:enable global $conf; @@ -1641,7 +1664,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds access rights * @@ -1650,7 +1673,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Error count (0 if OK) */ - function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) + public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) { // phpcs:enable global $conf,$user; @@ -1680,7 +1703,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $r_def = $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5])?$this->rights[$key][5]:''; - $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; + $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; if (empty($r_type)) { $r_type='w'; } @@ -1788,13 +1811,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes access rights * * @return int Error count (0 if OK) */ - function delete_permissions() + public function delete_permissions() { // phpcs:enable global $conf; @@ -1814,13 +1837,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds menu entries * * @return int Error count (0 if OK) */ - function insert_menus() + public function insert_menus() { // phpcs:enable global $user; @@ -1918,13 +1941,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes menu entries * * @return int Error count (0 if OK) */ - function delete_menus() + public function delete_menus() { // phpcs:enable global $conf; @@ -1948,13 +1971,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Creates directories * * @return int Error count (0 if OK) */ - function create_dirs() + public function create_dirs() { // phpcs:enable global $langs, $conf; @@ -2008,7 +2031,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds directories definitions * @@ -2017,7 +2040,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_dirs($name, $dir) + public function insert_dirs($name, $dir) { // phpcs:enable global $conf; @@ -2052,13 +2075,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes directories * * @return int Error count (0 if OK) */ - function delete_dirs() + public function delete_dirs() { // phpcs:enable global $conf; @@ -2078,13 +2101,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds generic parts * * @return int Error count (0 if OK) */ - function insert_module_parts() + public function insert_module_parts() { // phpcs:enable global $conf; @@ -2155,13 +2178,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes generic parts * * @return int Error count (0 if OK) */ - function delete_module_parts() + public function delete_module_parts() { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 763ec1a1370..c0d5e8f4116 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -377,7 +377,7 @@ class modAdherent extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 55f9adfb0d8..12193b630c8 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -61,12 +61,13 @@ class modFournisseur extends DolibarrModules $this->picto='company'; // Data directories to create when module is enabled - $this->dirs = array("/fournisseur/temp", - "/fournisseur/commande", - "/fournisseur/commande/temp", - "/fournisseur/facture", - "/fournisseur/facture/temp" - ); + $this->dirs = array( + "/fournisseur/temp", + "/fournisseur/commande", + "/fournisseur/commande/temp", + "/fournisseur/facture", + "/fournisseur/facture/temp" + ); // Dependencies $this->depends = array("modSociete"); @@ -622,7 +623,7 @@ class modFournisseur extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index c4e7e8b8338..be2e9b6e449 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -37,8 +37,8 @@ class modOpenSurvey extends DolibarrModules * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; @@ -119,51 +119,57 @@ class modOpenSurvey extends DolibarrModules $r++; - // Menus - //------- + // Menus + //------- $r=0; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'Survey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', - 'langs'=>'opensurvey', - 'position'=>200, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'Survey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey', + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', + 'langs'=>'opensurvey', + 'position'=>200, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'NewSurvey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_new', - 'url'=>'/opensurvey/wizard/index.php', - 'langs'=>'opensurvey', - 'position'=>210, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->write', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'NewSurvey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_new', + 'url'=>'/opensurvey/wizard/index.php', + 'langs'=>'opensurvey', + 'position'=>210, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->write', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'List', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_list', - 'url'=>'/opensurvey/list.php', - 'langs'=>'opensurvey', - 'position'=>220, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; - } + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'List', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_list', + 'url'=>'/opensurvey/list.php', + 'langs'=>'opensurvey', + 'position'=>220, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; + } /** * Function called when module is enabled. @@ -173,13 +179,13 @@ class modOpenSurvey extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - // Permissions - $this->remove($options); + public function init($options = '') + { + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 475d3a1b24b..17443b18197 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -146,7 +146,7 @@ class modPrelevement extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index be5952c35f5..65cefa6676a 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -114,7 +114,7 @@ class modProductBatch extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $db,$conf; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 4756f2a1a41..390104f18b8 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -43,7 +43,7 @@ class modSalaries extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -166,7 +166,7 @@ class modSalaries extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index f618236911b..4014e2176e0 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -727,8 +727,8 @@ class modSociete extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf, $langs; // We disable this to prevent pb of modules not correctly disabled diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 5b7205247ac..6bae79ba2cf 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -206,7 +206,7 @@ class Export } return 1; - } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -368,7 +368,7 @@ class Export return $Condition; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build an input field used to filter the query * From 346d1f410cee0bc8b68ea5fae5cc555ecb566dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 23:15:48 +0100 Subject: [PATCH 049/187] wip --- .../deplacement/class/deplacement.class.php | 38 ++++----- .../class/deplacementstats.class.php | 36 ++++---- .../facture/class/api_invoices.class.php | 84 +++++++++---------- .../facture/class/facture-rec.class.php | 78 ++++++++--------- .../facture/class/paymentterm.class.php | 40 ++++----- htdocs/core/modules/modLabel.class.php | 6 +- htdocs/core/modules/modReception.class.php | 2 +- htdocs/cron/class/cronjob.class.php | 78 +++++++---------- htdocs/fichinter/class/fichinter.class.php | 20 ++--- 9 files changed, 181 insertions(+), 201 deletions(-) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 518b505efc5..5f52246432b 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -83,7 +83,7 @@ class Deplacement extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -98,7 +98,7 @@ class Deplacement extends CommonObject * @param User $user User that creates * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -183,7 +183,7 @@ class Deplacement extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; @@ -245,7 +245,7 @@ class Deplacement extends CommonObject * @param string $ref Ref of record * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement"; @@ -288,7 +288,7 @@ class Deplacement extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -316,12 +316,12 @@ class Deplacement extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -329,7 +329,7 @@ class Deplacement extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -345,26 +345,26 @@ class Deplacement extends CommonObject elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); } elseif ($mode == 3) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } elseif ($mode == 4) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } } @@ -374,7 +374,7 @@ class Deplacement extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -400,7 +400,7 @@ class Deplacement extends CommonObject * @param int $active Active or not * @return array */ - function listOfTypes($active = 1) + public function listOfTypes($active = 1) { global $langs; @@ -437,7 +437,7 @@ class Deplacement extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, c.datec, c.fk_user_author, c.fk_user_modif,'; $sql.= ' c.tms'; diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 2580e264ee8..e6f3fb7828d 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -35,12 +35,12 @@ class DeplacementStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** * Constructor @@ -50,7 +50,7 @@ class DeplacementStats extends Stats * @param mixed $userid Id user for filter or array of user ids * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf; @@ -78,7 +78,7 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -96,7 +96,7 @@ class DeplacementStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -118,7 +118,7 @@ class DeplacementStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -138,7 +138,7 @@ class DeplacementStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 7da45f33920..52a499cadee 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -43,10 +43,10 @@ class Invoices extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->invoice = new Facture($this->db); } @@ -61,7 +61,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -105,7 +105,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -204,7 +204,7 @@ class Invoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of invoice */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -247,29 +247,29 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function createInvoiceFromOrder($orderid) + public function createInvoiceFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($orderid)) { + if (empty($orderid)) { throw new RestException(400, 'Order ID is mandatory'); } $order = new Commande($this->db); $result = $order->fetch($orderid); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Order not found'); } $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if( $result < 0) { + if ( $result < 0) { throw new RestException(405, $this->invoice->error); } $this->invoice->fetchObjectLinked(); @@ -285,7 +285,7 @@ class Invoices extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -323,7 +323,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -386,7 +386,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -428,7 +428,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -468,7 +468,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -506,7 +506,7 @@ class Invoices extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -547,7 +547,7 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->facture->supprimer) { throw new RestException(401); @@ -597,7 +597,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 400 */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -681,23 +681,23 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) + public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->add_contact($fk_socpeople, $type_contact, $source, $notrigger); if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); + throw new RestException(500, 'Error : '.$this->invoice->error); } $result = $this->invoice->fetch($id); @@ -731,7 +731,7 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -783,7 +783,7 @@ class Invoices extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -834,7 +834,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settopaid($id, $close_code = '', $close_note = '') + public function settopaid($id, $close_code = '', $close_note = '') { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -885,7 +885,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settounpaid($id) + public function settounpaid($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -934,24 +934,24 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function markAsCreditAvailable($id) + public function markAsCreditAvailable($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch_thirdparty(); if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); + throw new RestException(404, 'Thirdparty not found'); } if (! $this->invoice->paye) // protection against multiple submit @@ -1053,7 +1053,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function useDiscount($id, $discountid) + public function useDiscount($id, $discountid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -1144,7 +1144,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function getPayments($id) + public function getPayments($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { @@ -1192,7 +1192,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1257,10 +1257,10 @@ class Invoices extends DolibarrApi $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; + $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); $paiement->num_paiement = $num_paiement; - $paiement->note = $comment; + $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) @@ -1312,7 +1312,7 @@ class Invoices extends DolibarrApi * @throws 403 * @throws 404 */ - function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1423,7 +1423,7 @@ class Invoices extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -1446,7 +1446,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $invoice = array(); foreach (Invoices::$FIELDS as $field) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 488fdaf21e8..d12817ebc67 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -115,7 +115,7 @@ class FactureRec extends CommonInvoice * @param int $facid Id of source invoice * @return int <0 if KO, id of invoice created if OK */ - function create($user, $facid) + public function create($user, $facid) { global $conf; @@ -225,7 +225,7 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( + $result_insert = $this->addline( $facsrc->lines[$i]->desc, $facsrc->lines[$i]->subprice, $facsrc->lines[$i]->qty, @@ -321,7 +321,7 @@ class FactureRec extends CommonInvoice * @param int $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { $sql = 'SELECT f.rowid, f.entity, f.titre, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; @@ -449,7 +449,7 @@ class FactureRec extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -461,7 +461,7 @@ class FactureRec extends CommonInvoice * * @return int 1 if OK, < 0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -573,7 +573,7 @@ class FactureRec extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { $rowid=$this->id; @@ -644,7 +644,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -826,7 +826,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) + public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -962,7 +962,7 @@ class FactureRec extends CommonInvoice * * @return int|false false if KO, timestamp if OK */ - function getNextDate() + public function getNextDate() { if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); @@ -973,7 +973,7 @@ class FactureRec extends CommonInvoice * * @return boolean False by default, True if maximum number of generation is reached */ - function isMaxNbGenReached() + public function isMaxNbGenReached() { $ret = false; if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true; @@ -986,7 +986,7 @@ class FactureRec extends CommonInvoice * @param string $ret Default value to output * @return boolean False by default, True if maximum number of generation is reached */ - function strikeIfMaxNbGenReached($ret) + public function strikeIfMaxNbGenReached($ret) { // Special case to strike the date return ($this->isMaxNbGenReached()?'':'').$ret.($this->isMaxNbGenReached()?'':''); @@ -1002,7 +1002,7 @@ class FactureRec extends CommonInvoice * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) + public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) { global $conf, $langs, $db, $user, $hookmanager; @@ -1159,7 +1159,7 @@ class FactureRec extends CommonInvoice * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) { global $langs; @@ -1210,13 +1210,13 @@ class FactureRec extends CommonInvoice * @param integer $alreadypaid Not used on recurring invoices * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1227,7 +1227,7 @@ class FactureRec extends CommonInvoice * @param int $type Type invoice * @return string Label of status */ - function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; @@ -1328,7 +1328,7 @@ class FactureRec extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -1477,10 +1477,10 @@ class FactureRec extends CommonInvoice * Update frequency and unit * * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) + * @param string $unit unit of frequency (d, m, y) * @return int <0 if KO, >0 if OK */ - function setFrequencyAndUnit($frequency, $unit) + public function setFrequencyAndUnit($frequency, $unit) { if (! $this->table_element) { @@ -1523,7 +1523,7 @@ class FactureRec extends CommonInvoice * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done * @return int <0 if KO, >0 if OK */ - function setNextDate($date, $increment_nb_gen_done = 0) + public function setNextDate($date, $increment_nb_gen_done = 0) { if (! $this->table_element) { @@ -1555,7 +1555,7 @@ class FactureRec extends CommonInvoice * @param int $nb number of maximum period * @return int <0 if KO, >0 if OK */ - function setMaxPeriod($nb) + public function setMaxPeriod($nb) { if (! $this->table_element) { @@ -1588,7 +1588,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 to create in draft, 1 to create and validate invoice * @return int <0 if KO, >0 if OK */ - function setAutoValidate($validate) + public function setAutoValidate($validate) { if (! $this->table_element) { @@ -1619,7 +1619,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 no document, 1 to generate document * @return int <0 if KO, >0 if OK */ - function setGeneratePdf($validate) + public function setGeneratePdf($validate) { if (! $this->table_element) { @@ -1645,12 +1645,12 @@ class FactureRec extends CommonInvoice } /** - * Update the model for documents + * Update the model for documents * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK */ - function setModelPdf($model) + public function setModelPdf($model) { if (! $this->table_element) { @@ -1694,8 +1694,8 @@ class FactureLigneRec extends CommonInvoiceLine */ public $table_element='facturedet_rec'; - var $date_start_fill; - var $date_end_fill; + public $date_start_fill; + public $date_end_fill; /** @@ -1705,7 +1705,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = false) + public function delete(User $user, $notrigger = false) { $error=0; @@ -1748,7 +1748,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $rowid Id of invoice * @return int 1 if OK, < 0 if KO */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; @@ -1823,7 +1823,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger No trigger * @return int <0 if KO, Id of line if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1888,12 +1888,12 @@ class FactureLigneRec extends CommonInvoiceLine } $this->db->commit(); return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } } } diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3d4f0881de2..707b6586b83 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -69,7 +69,7 @@ class PaymentTerm // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class PaymentTerm // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -173,7 +173,7 @@ class PaymentTerm // extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -229,7 +229,7 @@ class PaymentTerm // extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getDefaultId() + public function getDefaultId() { global $langs; @@ -262,13 +262,13 @@ class PaymentTerm // extends CommonObject /** - * Update database + * Update database * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -345,7 +345,7 @@ class PaymentTerm // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -391,12 +391,12 @@ class PaymentTerm // extends CommonObject /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -425,10 +425,6 @@ class PaymentTerm // extends CommonObject $error++; } - //if (! $error) - //{ - //} - unset($object->context['createfromclone']); // End @@ -445,15 +441,15 @@ class PaymentTerm // extends CommonObject } - /** + /** * Initialise an instance with random values. * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { $this->id=0; $this->code=''; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 0bbddb6adc7..fefc7117b10 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -100,13 +100,13 @@ class modLabel extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { // Permissions $this->remove($options); $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index f4d191c472e..9fc82dc9ad6 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -243,7 +243,7 @@ class modReception extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index eaff511a779..1b07d98e7be 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -108,7 +108,7 @@ class Cronjob extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -121,7 +121,7 @@ class Cronjob extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -302,7 +302,7 @@ class Cronjob extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -393,7 +393,7 @@ class Cronjob extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -406,7 +406,7 @@ class Cronjob extends CommonObject * @param int $processing Processing or not * @return int <0 if KO, >0 if OK */ - function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) + public function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) { // phpcs:enable global $langs; @@ -541,7 +541,7 @@ class Cronjob extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -697,31 +697,15 @@ class Cronjob extends CommonObject $this->db->begin(); -// if (! $error) -// { -// if (! $notrigger) -// { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; + $sql.= " WHERE rowid=".$this->id; - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers -// } -// } - -// if (! $error) -// { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; - $sql.= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } -// } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } // Commit or rollback if ($error) @@ -749,7 +733,7 @@ class Cronjob extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -805,7 +789,7 @@ class Cronjob extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; $this->ref=0; @@ -852,7 +836,7 @@ class Cronjob extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -909,7 +893,7 @@ class Cronjob extends CommonObject * * @return int */ - function info() + public function info() { $sql = "SELECT"; $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; @@ -941,7 +925,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Run a job. * Once job is finished, status and nb of run is updated. @@ -950,7 +934,7 @@ class Cronjob extends CommonObject * @param string $userlogin User login * @return int <0 if KO, >0 if OK */ - function run_jobs($userlogin) + public function run_jobs($userlogin) { // phpcs:enable global $langs, $conf; @@ -1217,7 +1201,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reprogram a job * @@ -1225,7 +1209,7 @@ class Cronjob extends CommonObject * @param timestamp $now Date returned by dol_now() * @return int <0 if KO, >0 if OK */ - function reprogram_jobs($userlogin, $now) + public function reprogram_jobs($userlogin, $now) { // phpcs:enable dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); @@ -1301,12 +1285,12 @@ class Cronjob extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode, $this->processing); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1315,7 +1299,7 @@ class Cronjob extends CommonObject * @param int $processing 0=Not running, 1=Running * @return string Label of status */ - function LibStatut($status, $mode = 0, $processing = 0) + public function LibStatut($status, $mode = 0, $processing = 0) { // phpcs:enable global $langs; @@ -1350,11 +1334,11 @@ class Cronjob extends CommonObject elseif ($status == 0) return img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled').$moretext; } elseif ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); - elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); - } - } + { + if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); + elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); + } + } } @@ -1423,7 +1407,7 @@ class Cronjobline * Constructor * */ - function __construct() + public function __construct() { return 1; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6db992b4e22..e2caa591ad6 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -123,13 +123,13 @@ class Fichinter extends CommonObject * @param DoliDB $db Database handler */ public function __construct($db) - { + { $this->db = $db; $this->products = array(); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * @@ -1002,16 +1002,16 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Defines a delivery date of intervention + * Defines a delivery date of intervention * - * @param User $user Object user who define - * @param date $date_delivery date of delivery - * @return int <0 if ko, >0 if ok - */ + * @param User $user Object user who define + * @param date $date_delivery date of delivery + * @return int <0 if ko, >0 if ok + */ public function set_date_delivery($user, $date_delivery) - { + { // phpcs:enable global $conf; From 8a5b1dddb798d461a5aa4cb1bf5816c4f2972769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Feb 2019 23:29:46 +0100 Subject: [PATCH 050/187] wip syntax error --- htdocs/emailcollector/class/emailcollectoraction.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index d49c28716cf..11ccfbc858e 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -243,10 +243,7 @@ class EmailCollectorAction extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $thi /** - * @var EmailcollectorActionLine[] Array of subtable lines - */ - s->error = $object->error; + $this->error = $object->error; $this->errors = $object->errors; } From 06db81f3c30756736191266c9632463ac3692f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Feb 2019 00:02:39 +0100 Subject: [PATCH 051/187] wip --- htdocs/dav/dav.class.php | 20 +- htdocs/ecm/class/ecmdirectory.class.php | 42 +- htdocs/ecm/class/ecmfiles.class.php | 10 +- htdocs/ecm/class/htmlecm.form.class.php | 18 +- htdocs/modulebuilder/template/.editorconfig | 7 +- .../template/class/actions_mymodule.class.php | 320 +++++----- .../template/class/api_mymodule.class.php | 76 ++- .../template/class/myobject.class.php | 46 +- .../core/modules/modMyModule.class.php | 556 ++++++++++-------- 9 files changed, 575 insertions(+), 520 deletions(-) diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 226fdf48c94..eea023951e3 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -41,7 +41,7 @@ class CdavLib * @param DoliDB $db Database handler * @param Translate $langs translation */ - function __construct($user, $db, $langs) + public function __construct($user, $db, $langs) { $this->user = $user; $this->db = $db; @@ -245,15 +245,15 @@ class CdavLib return $caldata; } - /** - * getFullCalendarObjects - * - * @param int $calendarId Calendar id - * @param int $bCalendarData Add calendar data - * @return array|string[][] - */ - public function getFullCalendarObjects($calendarId, $bCalendarData) - { + /** + * getFullCalendarObjects + * + * @param int $calendarId Calendar id + * @param int $bCalendarData Add calendar data + * @return array|string[][] + */ + public function getFullCalendarObjects($calendarId, $bCalendarData) + { $calid = ($calendarId*1); $calevents = array(); diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 1d2b7f34ba6..d0f4f3e6567 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -105,7 +105,7 @@ class EcmDirectory // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; return 1; @@ -118,7 +118,7 @@ class EcmDirectory // extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -230,7 +230,7 @@ class EcmDirectory // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -288,7 +288,7 @@ class EcmDirectory // extends CommonObject * @param string $value '+' or '-' or new number * @return int <0 if KO, >0 if OK */ - function changeNbOfFiles($value) + public function changeNbOfFiles($value) { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; @@ -320,7 +320,7 @@ class EcmDirectory // extends CommonObject * @param int $id Id of object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -375,7 +375,7 @@ class EcmDirectory // extends CommonObject * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) * @return int <0 if KO, >0 if OK */ - function delete($user, $mode = 'all', $deletedirrecursive = 0) + public function delete($user, $mode = 'all', $deletedirrecursive = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -448,7 +448,7 @@ class EcmDirectory // extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -468,7 +468,7 @@ class EcmDirectory // extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) { global $langs; @@ -501,7 +501,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded * @return string Relative physical path */ - function getRelativePath($force = 0) + public function getRelativePath($force = 0) { $this->get_full_arbo($force); @@ -535,13 +535,13 @@ class EcmDirectory // extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->motherof that is array(id_son=>id_parent, ...) * * @return int <0 if KO, >0 if OK */ - function load_motherof() + public function load_motherof() { // phpcs:enable global $conf; @@ -579,12 +579,12 @@ class EcmDirectory // extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -592,7 +592,7 @@ class EcmDirectory // extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -600,7 +600,7 @@ class EcmDirectory // extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: @@ -620,7 +620,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @return array Tableau de array */ - function get_full_arbo($force = 0) + public function get_full_arbo($force = 0) { // phpcs:enable global $conf; @@ -701,7 +701,7 @@ class EcmDirectory // extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs. * Separator between directories is always '/', whatever is OS. @@ -710,7 +710,7 @@ class EcmDirectory // extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 0) + public function build_path_from_id_categ($id_categ, $protection = 0) { // phpcs:enable // Define fullpath @@ -750,7 +750,7 @@ class EcmDirectory // extends CommonObject * @param int $all 0=refresh record using this->id , 1=refresh record using this->entity * @return int -1 if KO, Nb of files in directory if OK */ - function refreshcachenboffile($all = 0) + public function refreshcachenboffile($all = 0) { global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -787,7 +787,7 @@ class EcmDirectory // extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance * @@ -799,7 +799,7 @@ class EcmDirectory // extends CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 3b229f48c1c..4f4c8dfea61 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -28,8 +28,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class to manage ECM files @@ -766,7 +764,7 @@ class EcmFiles extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -815,12 +813,12 @@ class EcmFiles extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -828,7 +826,7 @@ class EcmFiles extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 7877b85b0a5..c210d0ae2d4 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -27,15 +27,15 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; */ class FormEcm { - /** + /** * @var DoliDB Database handler. */ public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -43,7 +43,7 @@ class FormEcm * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -57,7 +57,7 @@ class FormEcm * @param string $module Module ('ecm', 'medias', ...) * @return string String with HTML select */ - function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') + public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') { global $conf, $langs; $langs->load("ecm"); @@ -70,7 +70,7 @@ class FormEcm $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(); } - if ($module == 'medias') + elseif ($module == 'medias') { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $path = $conf->medias->multidir_output[$conf->entity]; diff --git a/htdocs/modulebuilder/template/.editorconfig b/htdocs/modulebuilder/template/.editorconfig index 2df455f0d4f..3c4bd7d679d 100644 --- a/htdocs/modulebuilder/template/.editorconfig +++ b/htdocs/modulebuilder/template/.editorconfig @@ -7,8 +7,13 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true + +# PHP PSR-2 Coding Standards +# http://www.php-fig.org/psr/psr-2/ [*.php] -indent_style = tab +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true [*.js] indent_style = tab [*.css] diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 9143d8bf273..9925374dfac 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -44,201 +44,201 @@ class ActionsMyModule public $errors = array(); - /** - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse - */ - public $results = array(); + /** + * @var array Hook results. Propagated to $hookmanager->resArray for later reuse + */ + public $results = array(); - /** - * @var string String displayed by executeHook() immediately after return - */ - public $resprints; + /** + * @var string String displayed by executeHook() immediately after return + */ + public $resprints; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function getNomUrl($parameters, &$object, &$action) - { - global $db,$langs,$conf,$user; - $this->resprints = ''; - return 0; - } + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function getNomUrl($parameters, &$object, &$action) + { + global $db,$langs,$conf,$user; + $this->resprints = ''; + return 0; + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - // Do what you want here... - // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + // Do what you want here... + // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - foreach($parameters['toselect'] as $objectid) - { - // Do action on each object id - } - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + foreach($parameters['toselect'] as $objectid) + { + // Do action on each object id + } + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the addMoreMassActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - $this->resprints = ''; - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + $this->resprints = ''; + } - if (! $error) { - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $object Object output on PDF - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function beforePDFCreation($parameters, &$object, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $object Object output on PDF + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function beforePDFCreation($parameters, &$object, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $pdfhandler PDF builder handler - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function afterPDFCreation($parameters, &$pdfhandler, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $pdfhandler PDF builder handler + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function afterPDFCreation($parameters, &$pdfhandler, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /* Add here any other hooked methods... */ + /* Add here any other hooked methods... */ } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 30896449c93..20de77def18 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -56,10 +56,10 @@ class MyModuleApi extends DolibarrApi * @url GET / * */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->myobject = new MyObject($this->db); } @@ -70,26 +70,26 @@ class MyModuleApi extends DolibarrApi * * @param int $id ID of myobject * @return array|mixed data without useless information - * + * * @url GET myobjects/{id} * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->myobject->read) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->read) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->myobject); + return $this->_cleanObjectDatas($this->myobject); } @@ -109,7 +109,7 @@ class MyModuleApi extends DolibarrApi * * @url GET /myobjects/ */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -140,17 +140,15 @@ class MyModuleApi extends DolibarrApi if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($restictonsocid && $search_sale > 0) - { + if ($restictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { + if (! DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -185,7 +183,7 @@ class MyModuleApi extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No myobject found'); } - return $obj_ret; + return $obj_ret; } /** @@ -196,7 +194,7 @@ class MyModuleApi extends DolibarrApi * * @url POST myobjects/ */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -222,7 +220,7 @@ class MyModuleApi extends DolibarrApi * * @url PUT myobjects/{id} */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -233,9 +231,9 @@ class MyModuleApi extends DolibarrApi throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { $this->myobject->$field = $value; @@ -255,11 +253,11 @@ class MyModuleApi extends DolibarrApi * * @url DELETE myobject/{id} */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->delete) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->delete) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); @@ -269,7 +267,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) + if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) { throw new RestException(500); } @@ -289,18 +287,18 @@ class MyModuleApi extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder);*/ + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ - return $object; + return $object; } /** @@ -311,7 +309,7 @@ class MyModuleApi extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $myobject = array(); foreach (MyObjectApi::$FIELDS as $field) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index af96bcebf37..1b717c1176e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -432,19 +432,19 @@ class MyObject extends CommonObject //return $this->deleteCommon($user, $notrigger, 1); } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -460,10 +460,10 @@ class MyObject extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -673,11 +673,11 @@ class MyObject extends CommonObject /* class MyObjectLine { - // @var int ID - public $id; - // @var mixed Sample line property 1 - public $prop1; - // @var mixed Sample line property 2 - public $prop2; + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; } */ diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index db6dd961c6c..029213f6804 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -33,314 +34,367 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; */ class modMyModule extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $langs,$conf; $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'mymodule'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mymodule'; - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "other"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '90'; - // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "other"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). - $this->description = "MyModuleDescription"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "MyModule description (Long)"; + // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). + $this->description = "MyModuleDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "MyModule description (Long)"; - $this->editor_name = 'Editor name'; - $this->editor_url = 'https://www.example.com'; + $this->editor_name = 'Editor name'; + $this->editor_url = 'https://www.example.com'; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.0'; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = '1.0'; //Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // 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='generic'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // 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='generic'; - // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) - $this->module_parts = array( - 'triggers' => 1, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file - 'js' => array('/mymodule/js/mymodule.js.php'), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>'0'), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users - ); + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 1, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + '/mymodule/css/mymodule.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + '/mymodule/js/mymodule.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + 'data' => array( + 'hookcontext1', + 'hookcontext2', + ), + 'entity' => '0', + ), + 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users + ); - // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); - $this->dirs = array("/mymodule/temp"); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); + $this->dirs = array("/mymodule/temp"); - // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@mymodule"); + // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@mymodule"); - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // 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(); // 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("mymodule@mymodule"); - //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(4,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'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // 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(); // 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("mymodule@mymodule"); + //$this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4,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'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); - $this->const = array( - 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) - ); + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); - // Some keys to add into the overwriting translation tables - /*$this->overwrite_translation = array( - 'en_US:ParentCompany'=>'Parent company or reseller', - 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' - )*/ + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ - if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) - { - $conf->mymodule=new stdClass(); - $conf->mymodule->enabled=0; - } + if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) { + $conf->mymodule=new stdClass(); + $conf->mymodule->enabled=0; + } - // Array to add new pages in new tabs + // Array to add new pages in new tabs $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be - // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view // Dictionaries - $this->dictionaries=array(); + $this->dictionaries=array(); /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@mymodule', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) // Condition to show each dictionary + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) ); */ // Boxes/Widgets - // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. + // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. $this->boxes = array( - 0=>array('file'=>'mymodulewidget1.php@mymodule','note'=>'Widget provided by MyModule','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), - //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') + 0 => array( + 'file' => 'mymodulewidget1.php@mymodule', + 'note' => 'Widget provided by MyModule', + 'enabledbydefaulton' => 'Home', + ), + //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), + //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') ); - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - // ); + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + 0 => array( + 'label' => 'MyJob label', + 'jobtype' => 'method', + 'class' => '/mymodule/class/myobject.class.php', + 'objectname' => 'MyObject', + 'method' => 'doScheduledJob', + 'parameters' => '', + 'comment' => 'Comment', + 'frequency' => 2, + 'unitfrequency' => 3600, + 'status' => 0, + 'test' => '$conf->mymodule->enabled', + 'priority' => 50, + ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) + // ); - // Permissions - $this->rights = array(); // Permission array used by this module + // Permissions + $this->rights = array(); // Permission array used by this module - $r=0; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; - // Add here entries to declare new menus + // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry - 'titre'=>'MyModule', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'', - 'url'=>'/mymodule/mymoduleindex.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + /* BEGIN MODULEBUILDER TOPMENU */ + $this->menu[$r++]=array( + 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'MyModule', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'', + 'url'=>'/mymodule/mymoduleindex.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); - /* END MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER TOPMENU */ - /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_list', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_new', - 'url'=>'/mymodule/myobject_page.php?action=create', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - END MODULEBUILDER LEFTMENU MYOBJECT */ + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_list', + 'url'=>'/mymodule/myobject_list.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_new', + 'url'=>'/mymodule/myobject_page.php?action=create', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + END MODULEBUILDER LEFTMENU MYOBJECT */ - // Exports - $r=1; + // Exports + $r=1; - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("mymodule@mymodule"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@mymodule'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // 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.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ - } + /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ + /* + $langs->load("mymodule@mymodule"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='myobject@mymodule'; + $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // 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.'myobject as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MYOBJECT */ + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $result=$this->_load_tables('/mymodule/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') + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result=$this->_load_tables('/mymodule/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 - include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); - return $this->_remove($sql, $options); - } + return $this->_remove($sql, $options); + } } From 675a17a74c3268aba45b5b1cc8e5a293ccdd603d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Feb 2019 00:34:43 +0100 Subject: [PATCH 052/187] wip --- htdocs/core/modules/DolibarrModules.class.php | 69 +++++++++++-------- htdocs/core/modules/modNotification.class.php | 2 +- htdocs/core/modules/modPrelevement.class.php | 49 ++++++------- htdocs/core/modules/modProduct.class.php | 30 ++++---- htdocs/core/modules/modSalaries.class.php | 10 +-- .../core/modules/modMyModule.class.php | 2 +- 6 files changed, 89 insertions(+), 73 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 4aa74e22d5f..e5c3c2c63da 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -382,7 +382,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - private function _init($array_sql, $options = '') + protected function _init($array_sql, $options = '') { global $conf; $err=0; @@ -484,7 +484,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - private function _remove($array_sql, $options = '') + protected function _remove($array_sql, $options = '') { $err=0; @@ -658,11 +658,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; $content = dolMd2Html( - $content, 'parsedown', + $content, + 'parsedown', array( - 'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1), - 'img/'=>dol_buildpath(strtolower($this->name).'/img/', 1), - 'images/'=>dol_buildpath(strtolower($this->name).'/imgages/', 1), + 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1), + 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1), + 'images/' => dol_buildpath(strtolower($this->name).'/imgages/', 1), ) ); } @@ -671,8 +672,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $content = nl2br($content); } } - else // Mostly for internal modules + else { + // Mostly for internal modules if (! empty($this->descriptionlong)) { if (is_array($this->langfiles)) { foreach($this->langfiles as $val) @@ -805,14 +807,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $ret=''; $newversion=preg_replace('/_deprecated/', '', $this->version); - if ($newversion == 'experimental') { $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); - } elseif ($newversion == 'development') { $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); - } elseif ($newversion == 'dolibarr') { $ret=DOL_VERSION; - } elseif ($newversion) { $ret=$newversion; - } else { $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); + if ($newversion == 'experimental') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); + } elseif ($newversion == 'development') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); + } elseif ($newversion == 'dolibarr') { + $ret=DOL_VERSION; + } elseif ($newversion) { + $ret=$newversion; + } else { + $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); } - if (preg_match('/_deprecated/', $this->version)) { $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); + if (preg_match('/_deprecated/', $this->version)) { + $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); } return $ret; } @@ -825,13 +833,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ public function isCoreOrExternalModule() { - if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { return 'core'; + if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { + return 'core'; } - if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { return 'external'; + if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { + return 'external'; } - if (! empty($this->editor_name) || ! empty($this->editor_url)) { return 'external'; + if (! empty($this->editor_name) || ! empty($this->editor_url)) { + return 'external'; } - if ($this->numero >= 100000) { return 'external'; + if ($this->numero >= 100000) { + return 'external'; } return 'unknown'; } @@ -911,11 +923,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); - if ($obj) { return $this->db->jdate($obj->tms); + if ($obj) { + return $this->db->jdate($obj->tms); } } @@ -938,15 +951,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); $tmp=array(); if ($obj->note) { $tmp=json_decode($obj->note, true); } - if ($obj) { return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + if ($obj) { + return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); } } @@ -974,7 +988,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; + if (! $resql) { + $err++; } $note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']))); @@ -1029,7 +1044,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param string $reldir Relative directory where to scan files * @return int <=0 if KO, >0 if OK */ - private function _load_tables($reldir) + protected function _load_tables($reldir) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index c3ccca4ef46..c73c8210072 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -89,7 +89,7 @@ class modNotification extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 17443b18197..ec4c4ca3a46 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -124,40 +124,41 @@ class modPrelevement extends DolibarrModules $this->rights[$r][4] = 'bons'; $this->rights[$r][5] = 'credit'; -/* $this->rights[2][0] = 154; + /* + $this->rights[2][0] = 154; $this->rights[2][1] = 'Setup withdraw account'; $this->rights[2][2] = 'w'; $this->rights[2][3] = 0; $this->rights[2][4] = 'bons'; $this->rights[2][5] = 'configurer'; -*/ + */ - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - } + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ public function init($options = '') - { - global $conf; + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", - ); + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", + ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4a0af38dc34..368a41a6fac 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -521,7 +521,7 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); -$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' @@ -625,20 +625,20 @@ $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { - $this->remove($options); + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 390104f18b8..e111e81ef6b 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -159,12 +159,12 @@ class modSalaries extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ public function init($options = '') { diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 029213f6804..d8bd86e36b2 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -360,7 +360,7 @@ class modMyModule extends DolibarrModules * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') From 35762c0d4e01b0a940c104be378cf4b387532f9d Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 26 Feb 2019 10:22:20 +0100 Subject: [PATCH 053/187] add data elem on task list --- htdocs/core/tpl/extrafields_list_print_fields.tpl.php | 7 ++++--- htdocs/core/tpl/extrafields_list_search_title.tpl.php | 2 +- htdocs/projet/tasks/list.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 6b6d22cf822..739126cd2a8 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -20,9 +20,10 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ { $align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey); print ''; - $tmpkey='options_'.$key; + if ($align) print ' align="'.$align.'"'; + print ' data-key="'.$key.'"'; + print '>'; + $tmpkey='options_'.$key; if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey)) { $datenotinstring = $obj->$tmpkey; diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 8020739d5cb..36bdf662b54 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -22,7 +22,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $sortonfield = "ef.".$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print ''; - else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; } } } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e1a77f0b824..17d4bf60df7 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -625,7 +625,7 @@ while ($i < min($num,$limit)) $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { - print ''; + print ''; // Ref if (! empty($arrayfields['t.ref']['checked'])) From e0c7c32faed5e10a98616bd6cd8fc12bf9df8ce0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Feb 2019 11:44:16 +0100 Subject: [PATCH 054/187] Fix preselection when key is '0' --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ee0c35ac3a9..bd87fda5799 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6095,7 +6095,7 @@ class Form foreach ($array as $key => $value) { $out.= '
    '; if ($conf->use_javascript_ajax) @@ -1577,7 +1591,7 @@ if ($step == 5 && $datatoimport) $importid=dol_print_date(dol_now(), '%Y%m%d%H%M%S'); print '
    '; - print $langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
    '; + print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
    '; if (empty($nboferrors)) print $langs->trans("DataLoadedWithId", $importid).'
    '; print '
    '; From dd9a4a8cbc313d14bed93983b91ae2b7c6622689 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 12:29:36 +0100 Subject: [PATCH 174/187] CSS --- 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 fff105d5985..d545a3e1177 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -873,7 +873,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; - print ''; + print ''; print ''; print $companypaymentmodetemp->id; print ''; From 1c775b7b687118dd8bc25f19c7f596025b5333e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 12:46:07 +0100 Subject: [PATCH 175/187] Work of BOM module --- htdocs/bom/admin/setup.php | 6 +++--- htdocs/bom/bom_card.php | 8 ++++---- htdocs/bom/bom_document.php | 4 ++-- htdocs/bom/bom_list.php | 4 ++-- htdocs/bom/bom_note.php | 4 ++-- htdocs/bom/class/bom.class.php | 16 +++++++-------- htdocs/bom/lib/bom.lib.php | 6 +++--- htdocs/core/menus/standard/eldy.lib.php | 4 +++- htdocs/core/modules/modBom.class.php | 26 ++++++++++++------------- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index dd16ad92b8e..561b44fa262 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -44,7 +44,7 @@ require_once '../lib/bom.lib.php'; //require_once "../class/myclass.class.php"; // Translations -$langs->loadLangs(array("admin", "bom@bom")); +$langs->loadLangs(array("admin", "mrp")); // Access control if (! $user->admin) accessforbidden(); @@ -78,11 +78,11 @@ llxHeader('', $langs->trans($page_name)); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom@bom'); +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); // Configuration header $head = bomAdminPrepareHead(); -dol_fiche_head($head, 'settings', '', -1, "bom@bom"); +dol_fiche_head($head, 'settings', '', -1, "bom"); // Setup page goes here echo $langs->trans("BomSetupPage").'

    '; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 9d45b8e86f8..0054e427996 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -63,7 +63,7 @@ dol_include_once('/bom/class/bom.class.php'); dol_include_once('/bom/lib/bom_bom.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("bom@bom","other")); +$langs->loadLangs(array("mrp","other")); // Get parameters $id = GETPOST('id', 'int'); @@ -154,7 +154,7 @@ if (empty($reshook)) $form=new Form($db); $formfile=new FormFile($db); -llxHeader('', 'BillOfMaterials', ''); +llxHeader('', 'NewBOM', ''); // Example : Adding jquery code print '