@@ -655,7 +655,7 @@ |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { |
| 658 | - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct')); |
|
| 658 | + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct')); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | $this->import_convertvalue_array[$r] = array( |
@@ -38,28 +38,28 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct($db) |
| 40 | 40 | { |
| 41 | - global $conf, $langs; |
|
| 41 | + global $conf, $langs; |
|
| 42 | 42 | |
| 43 | - $this->db = $db; |
|
| 44 | - $this->numero = 68000; |
|
| 43 | + $this->db = $db; |
|
| 44 | + $this->numero = 68000; |
|
| 45 | 45 | |
| 46 | - $this->family = "financial"; |
|
| 47 | - $this->module_position = '100'; |
|
| 48 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
| 49 | - $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
| 50 | - $this->description = "Intracomm report management (Support for French DEB/DES format)"; |
|
| 46 | + $this->family = "financial"; |
|
| 47 | + $this->module_position = '100'; |
|
| 48 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
| 49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
| 50 | + $this->description = "Intracomm report management (Support for French DEB/DES format)"; |
|
| 51 | 51 | |
| 52 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
|
| 53 | - $this->version = 'development'; |
|
| 52 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
|
| 53 | + $this->version = 'development'; |
|
| 54 | 54 | |
| 55 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
| 56 | - $this->picto = 'intracommreport'; |
|
| 55 | + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
| 56 | + $this->picto = 'intracommreport'; |
|
| 57 | 57 | |
| 58 | - // Data directories to create when module is enabled |
|
| 59 | - $this->dirs = array('/intracommreport/temp'); |
|
| 58 | + // Data directories to create when module is enabled |
|
| 59 | + $this->dirs = array('/intracommreport/temp'); |
|
| 60 | 60 | |
| 61 | - // Config pages |
|
| 62 | - $this->config_page_url = array("intracommreport.php@intracommreport"); |
|
| 61 | + // Config pages |
|
| 62 | + $this->config_page_url = array("intracommreport.php@intracommreport"); |
|
| 63 | 63 | |
| 64 | 64 | // Dependencies |
| 65 | 65 | $this->depends = array("modFacture","modTax"); // List of modules id that must be enabled if this module is enabled |
@@ -76,48 +76,48 @@ discard block |
||
| 76 | 76 | // ); |
| 77 | 77 | $this->const = array(); |
| 78 | 78 | |
| 79 | - // Tabs |
|
| 80 | - $this->tabs = array(); |
|
| 79 | + // Tabs |
|
| 80 | + $this->tabs = array(); |
|
| 81 | 81 | |
| 82 | - // Css |
|
| 83 | - $this->module_parts = array(); |
|
| 82 | + // Css |
|
| 83 | + $this->module_parts = array(); |
|
| 84 | 84 | |
| 85 | - // Boxes |
|
| 86 | - $this->boxes = array(); |
|
| 85 | + // Boxes |
|
| 86 | + $this->boxes = array(); |
|
| 87 | 87 | |
| 88 | - // Dictionaries |
|
| 89 | - if (! isset($conf->intracommreport->enabled)) |
|
| 90 | - { |
|
| 91 | - $conf->intracommreport=new stdClass(); |
|
| 92 | - $conf->intracommreport->enabled=0; |
|
| 93 | - } |
|
| 88 | + // Dictionaries |
|
| 89 | + if (! isset($conf->intracommreport->enabled)) |
|
| 90 | + { |
|
| 91 | + $conf->intracommreport=new stdClass(); |
|
| 92 | + $conf->intracommreport->enabled=0; |
|
| 93 | + } |
|
| 94 | 94 | $this->dictionaries=array(); |
| 95 | 95 | |
| 96 | - // Permissions |
|
| 96 | + // Permissions |
|
| 97 | 97 | $this->rights = array(); |
| 98 | 98 | $this->rights_class = 'intracommreport'; |
| 99 | - $r = 0; |
|
| 100 | - |
|
| 101 | - $r++; |
|
| 102 | - $this->rights[$r][0] = 68001; |
|
| 103 | - $this->rights[$r][1] = 'Read intracomm report'; |
|
| 104 | - $this->rights[$r][2] = 'r'; |
|
| 105 | - $this->rights[$r][3] = 0; |
|
| 106 | - $this->rights[$r][4] = 'read'; |
|
| 107 | - |
|
| 108 | - $r++; |
|
| 109 | - $this->rights[$r][0] = 68002; |
|
| 110 | - $this->rights[$r][1] = 'Create/modify intracomm report'; |
|
| 111 | - $this->rights[$r][2] = 'w'; |
|
| 112 | - $this->rights[$r][3] = 0; |
|
| 113 | - $this->rights[$r][4] = 'write'; |
|
| 99 | + $r = 0; |
|
| 114 | 100 | |
| 115 | 101 | $r++; |
| 116 | - $this->rights[$r][0] = 68004; |
|
| 117 | - $this->rights[$r][1] = 'Delete intracomm report'; |
|
| 118 | - $this->rights[$r][2] = 'd'; |
|
| 119 | - $this->rights[$r][3] = 0; |
|
| 120 | - $this->rights[$r][4] = 'delete'; |
|
| 102 | + $this->rights[$r][0] = 68001; |
|
| 103 | + $this->rights[$r][1] = 'Read intracomm report'; |
|
| 104 | + $this->rights[$r][2] = 'r'; |
|
| 105 | + $this->rights[$r][3] = 0; |
|
| 106 | + $this->rights[$r][4] = 'read'; |
|
| 107 | + |
|
| 108 | + $r++; |
|
| 109 | + $this->rights[$r][0] = 68002; |
|
| 110 | + $this->rights[$r][1] = 'Create/modify intracomm report'; |
|
| 111 | + $this->rights[$r][2] = 'w'; |
|
| 112 | + $this->rights[$r][3] = 0; |
|
| 113 | + $this->rights[$r][4] = 'write'; |
|
| 114 | + |
|
| 115 | + $r++; |
|
| 116 | + $this->rights[$r][0] = 68004; |
|
| 117 | + $this->rights[$r][1] = 'Delete intracomm report'; |
|
| 118 | + $this->rights[$r][2] = 'd'; |
|
| 119 | + $this->rights[$r][3] = 0; |
|
| 120 | + $this->rights[$r][4] = 'delete'; |
|
| 121 | 121 | |
| 122 | 122 | // Main menu entries |
| 123 | 123 | $this->menu = array(); // List of menus to add |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \ingroup Intracomm report |
| 24 | 24 | * \brief Module to activate intracomm report module |
| 25 | 25 | */ |
| 26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
| 26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
| 53 | 53 | $this->version = 'development'; |
| 54 | 54 | |
| 55 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
| 55 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
| 56 | 56 | $this->picto = 'intracommreport'; |
| 57 | 57 | |
| 58 | 58 | // Data directories to create when module is enabled |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | $this->config_page_url = array("intracommreport.php@intracommreport"); |
| 63 | 63 | |
| 64 | 64 | // Dependencies |
| 65 | - $this->depends = array("modFacture","modTax"); // List of modules id that must be enabled if this module is enabled |
|
| 66 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
| 67 | - $this->conflictwith = array(); // List of modules id this module is in conflict with |
|
| 68 | - $this->phpmin = array(5,5); // Minimum version of PHP required by module |
|
| 69 | - $this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module |
|
| 65 | + $this->depends = array("modFacture", "modTax"); // List of modules id that must be enabled if this module is enabled |
|
| 66 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
| 67 | + $this->conflictwith = array(); // List of modules id this module is in conflict with |
|
| 68 | + $this->phpmin = array(5, 5); // Minimum version of PHP required by module |
|
| 69 | + $this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module |
|
| 70 | 70 | $this->langfiles = array("intracommreport"); |
| 71 | 71 | |
| 72 | 72 | // Constants |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | $this->boxes = array(); |
| 87 | 87 | |
| 88 | 88 | // Dictionaries |
| 89 | - if (! isset($conf->intracommreport->enabled)) |
|
| 89 | + if (!isset($conf->intracommreport->enabled)) |
|
| 90 | 90 | { |
| 91 | - $conf->intracommreport=new stdClass(); |
|
| 92 | - $conf->intracommreport->enabled=0; |
|
| 91 | + $conf->intracommreport = new stdClass(); |
|
| 92 | + $conf->intracommreport->enabled = 0; |
|
| 93 | 93 | } |
| 94 | - $this->dictionaries=array(); |
|
| 94 | + $this->dictionaries = array(); |
|
| 95 | 95 | |
| 96 | 96 | // Permissions |
| 97 | 97 | $this->rights = array(); |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | $this->rights[$r][4] = 'delete'; |
| 121 | 121 | |
| 122 | 122 | // Main menu entries |
| 123 | - $this->menu = array(); // List of menus to add |
|
| 124 | - $r=0; |
|
| 123 | + $this->menu = array(); // List of menus to add |
|
| 124 | + $r = 0; |
|
| 125 | 125 | |
| 126 | 126 | // Exports |
| 127 | - $r=1; |
|
| 127 | + $r = 1; |
|
| 128 | 128 | } |
| 129 | 129 | } |
@@ -30,59 +30,59 @@ |
||
| 30 | 30 | class intracommreportbox extends ModeleBoxes |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - public $boxcode = "mybox"; |
|
| 34 | - public $boximg = "intracommreport"; |
|
| 35 | - public $boxlabel; |
|
| 36 | - public $depends = array("intracommreport"); |
|
| 37 | - public $db; |
|
| 38 | - public $param; |
|
| 39 | - public $info_box_head = array(); |
|
| 40 | - public $info_box_contents = array(); |
|
| 33 | + public $boxcode = "mybox"; |
|
| 34 | + public $boximg = "intracommreport"; |
|
| 35 | + public $boxlabel; |
|
| 36 | + public $depends = array("intracommreport"); |
|
| 37 | + public $db; |
|
| 38 | + public $param; |
|
| 39 | + public $info_box_head = array(); |
|
| 40 | + public $info_box_contents = array(); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor |
|
| 44 | - */ |
|
| 45 | - public function __construct() |
|
| 46 | - { |
|
| 47 | - global $langs; |
|
| 48 | - $langs->load("boxes"); |
|
| 42 | + /** |
|
| 43 | + * Constructor |
|
| 44 | + */ |
|
| 45 | + public function __construct() |
|
| 46 | + { |
|
| 47 | + global $langs; |
|
| 48 | + $langs->load("boxes"); |
|
| 49 | 49 | |
| 50 | - $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); |
|
| 51 | - } |
|
| 50 | + $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Load data into info_box_contents array to show array later. |
|
| 55 | - * |
|
| 56 | - * @param int $max Maximum number of records to load |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - public function loadBox($max = 5) |
|
| 60 | - { |
|
| 61 | - global $conf, $user, $langs, $db; |
|
| 53 | + /** |
|
| 54 | + * Load data into info_box_contents array to show array later. |
|
| 55 | + * |
|
| 56 | + * @param int $max Maximum number of records to load |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + public function loadBox($max = 5) |
|
| 60 | + { |
|
| 61 | + global $conf, $user, $langs, $db; |
|
| 62 | 62 | |
| 63 | - $this->max = $max; |
|
| 63 | + $this->max = $max; |
|
| 64 | 64 | |
| 65 | - //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; |
|
| 65 | + //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; |
|
| 66 | 66 | |
| 67 | - $text = $langs->trans("MyBoxDescription", $max); |
|
| 68 | - $this->info_box_head = array( |
|
| 69 | - 'text' => $text, |
|
| 70 | - 'limit' => dol_strlen($text) |
|
| 71 | - ); |
|
| 67 | + $text = $langs->trans("MyBoxDescription", $max); |
|
| 68 | + $this->info_box_head = array( |
|
| 69 | + 'text' => $text, |
|
| 70 | + 'limit' => dol_strlen($text) |
|
| 71 | + ); |
|
| 72 | 72 | |
| 73 | - $this->info_box_contents[0][0] = array('td' => 'align="left"', |
|
| 74 | - 'text' => $langs->trans("MyBoxContent")); |
|
| 75 | - } |
|
| 73 | + $this->info_box_contents[0][0] = array('td' => 'align="left"', |
|
| 74 | + 'text' => $langs->trans("MyBoxContent")); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Method to show box |
|
| 79 | - * |
|
| 80 | - * @param array $head Array with properties of box title |
|
| 81 | - * @param array $contents Array with properties of box lines |
|
| 82 | - * @return void |
|
| 83 | - */ |
|
| 84 | - public function showBox($head = null, $contents = null) |
|
| 85 | - { |
|
| 86 | - parent::showBox($this->info_box_head, $this->info_box_contents); |
|
| 87 | - } |
|
| 77 | + /** |
|
| 78 | + * Method to show box |
|
| 79 | + * |
|
| 80 | + * @param array $head Array with properties of box title |
|
| 81 | + * @param array $contents Array with properties of box lines |
|
| 82 | + * @return void |
|
| 83 | + */ |
|
| 84 | + public function showBox($head = null, $contents = null) |
|
| 85 | + { |
|
| 86 | + parent::showBox($this->info_box_head, $this->info_box_contents); |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * \brief This file is a sample box definition file |
| 23 | 23 | * Put some comments here |
| 24 | 24 | */ |
| 25 | -include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; |
|
| 25 | +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Class to manage the box |
@@ -1439,16 +1439,16 @@ |
||
| 1439 | 1439 | //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journals"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | - // Intracomm report |
|
| 1443 | - if (! empty($conf->intracommreport->enabled)) |
|
| 1444 | - { |
|
| 1445 | - $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); |
|
| 1446 | - if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { |
|
| 1447 | - // DEB / DES |
|
| 1448 | - $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); |
|
| 1449 | - $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); |
|
| 1450 | - } |
|
| 1451 | - } |
|
| 1442 | + // Intracomm report |
|
| 1443 | + if (! empty($conf->intracommreport->enabled)) |
|
| 1444 | + { |
|
| 1445 | + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); |
|
| 1446 | + if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { |
|
| 1447 | + // DEB / DES |
|
| 1448 | + $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); |
|
| 1449 | + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); |
|
| 1450 | + } |
|
| 1451 | + } |
|
| 1452 | 1452 | |
| 1453 | 1453 | // Assets |
| 1454 | 1454 | if (!empty($conf->asset->enabled)) |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), |
| 355 | 355 | |
| 356 | - 'loadLangs' => array("compta", "accountancy", "assets","intracommreport"), |
|
| 356 | + 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"), |
|
| 357 | 357 | 'submenus' => array(), |
| 358 | 358 | ); |
| 359 | 359 | |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | 1442 | // Intracomm report |
| 1443 | - if (! empty($conf->intracommreport->enabled)) |
|
| 1443 | + if (!empty($conf->intracommreport->enabled)) |
|
| 1444 | 1444 | { |
| 1445 | 1445 | $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); |
| 1446 | 1446 | if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public $cond_reglement_id; |
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * @var int Transport mode ID (For module intracomm report) |
|
| 301 | - * @see setTransportMode() |
|
| 302 | - */ |
|
| 303 | - public $transport_mode_id; |
|
| 299 | + /** |
|
| 300 | + * @var int Transport mode ID (For module intracomm report) |
|
| 301 | + * @see setTransportMode() |
|
| 302 | + */ |
|
| 303 | + public $transport_mode_id; |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * @var int Payment terms ID |
@@ -2196,42 +2196,42 @@ discard block |
||
| 2196 | 2196 | } |
| 2197 | 2197 | } |
| 2198 | 2198 | |
| 2199 | - /** |
|
| 2200 | - * Change the transport mode methods |
|
| 2201 | - * |
|
| 2202 | - * @param int $id Id of new payment method |
|
| 2203 | - * @return int >0 if OK, <0 if KO |
|
| 2204 | - */ |
|
| 2205 | - public function setTransportMode($id) |
|
| 2206 | - { |
|
| 2207 | - dol_syslog(get_class($this).'::setTransportMode('.$id.')'); |
|
| 2208 | - if ($this->statut >= 0 || $this->element == 'societe') |
|
| 2209 | - { |
|
| 2210 | - $fieldname = 'fk_transport_mode'; |
|
| 2211 | - if ($this->element == 'societe') $fieldname = 'transport_mode'; |
|
| 2212 | - if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; |
|
| 2213 | - |
|
| 2214 | - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
|
| 2215 | - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
|
| 2216 | - $sql .= ' WHERE rowid='.$this->id; |
|
| 2217 | - |
|
| 2218 | - if ($this->db->query($sql)) |
|
| 2219 | - { |
|
| 2220 | - $this->transport_mode_id = $id; |
|
| 2221 | - // for supplier |
|
| 2222 | - if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; |
|
| 2223 | - return 1; |
|
| 2224 | - } else { |
|
| 2225 | - dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); |
|
| 2226 | - $this->error=$this->db->error(); |
|
| 2227 | - return -1; |
|
| 2228 | - } |
|
| 2229 | - } else { |
|
| 2230 | - dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); |
|
| 2231 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2232 | - return -2; |
|
| 2233 | - } |
|
| 2234 | - } |
|
| 2199 | + /** |
|
| 2200 | + * Change the transport mode methods |
|
| 2201 | + * |
|
| 2202 | + * @param int $id Id of new payment method |
|
| 2203 | + * @return int >0 if OK, <0 if KO |
|
| 2204 | + */ |
|
| 2205 | + public function setTransportMode($id) |
|
| 2206 | + { |
|
| 2207 | + dol_syslog(get_class($this).'::setTransportMode('.$id.')'); |
|
| 2208 | + if ($this->statut >= 0 || $this->element == 'societe') |
|
| 2209 | + { |
|
| 2210 | + $fieldname = 'fk_transport_mode'; |
|
| 2211 | + if ($this->element == 'societe') $fieldname = 'transport_mode'; |
|
| 2212 | + if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; |
|
| 2213 | + |
|
| 2214 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
|
| 2215 | + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
|
| 2216 | + $sql .= ' WHERE rowid='.$this->id; |
|
| 2217 | + |
|
| 2218 | + if ($this->db->query($sql)) |
|
| 2219 | + { |
|
| 2220 | + $this->transport_mode_id = $id; |
|
| 2221 | + // for supplier |
|
| 2222 | + if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; |
|
| 2223 | + return 1; |
|
| 2224 | + } else { |
|
| 2225 | + dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); |
|
| 2226 | + $this->error=$this->db->error(); |
|
| 2227 | + return -1; |
|
| 2228 | + } |
|
| 2229 | + } else { |
|
| 2230 | + dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); |
|
| 2231 | + $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2232 | + return -2; |
|
| 2233 | + } |
|
| 2234 | + } |
|
| 2235 | 2235 | |
| 2236 | 2236 | /** |
| 2237 | 2237 | * Change the retained warranty payments terms |
@@ -2223,12 +2223,12 @@ discard block |
||
| 2223 | 2223 | return 1; |
| 2224 | 2224 | } else { |
| 2225 | 2225 | dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); |
| 2226 | - $this->error=$this->db->error(); |
|
| 2226 | + $this->error = $this->db->error(); |
|
| 2227 | 2227 | return -1; |
| 2228 | 2228 | } |
| 2229 | 2229 | } else { |
| 2230 | 2230 | dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); |
| 2231 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2231 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 2232 | 2232 | return -2; |
| 2233 | 2233 | } |
| 2234 | 2234 | } |
@@ -6726,7 +6726,7 @@ discard block |
||
| 6726 | 6726 | |
| 6727 | 6727 | switch ($mode) { |
| 6728 | 6728 | case "view": |
| 6729 | - $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later |
|
| 6729 | + $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later |
|
| 6730 | 6730 | break; |
| 6731 | 6731 | case "create": |
| 6732 | 6732 | case "edit": |
@@ -8365,7 +8365,7 @@ discard block |
||
| 8365 | 8365 | |
| 8366 | 8366 | $this->db->begin(); |
| 8367 | 8367 | |
| 8368 | - switch ($this->element){ |
|
| 8368 | + switch ($this->element) { |
|
| 8369 | 8369 | case 'propal': |
| 8370 | 8370 | $element = 'propale'; |
| 8371 | 8371 | break; |
@@ -8373,10 +8373,10 @@ discard block |
||
| 8373 | 8373 | $element = 'produit'; |
| 8374 | 8374 | break; |
| 8375 | 8375 | case 'order_supplier': |
| 8376 | - $element ='fournisseur/commande'; |
|
| 8376 | + $element = 'fournisseur/commande'; |
|
| 8377 | 8377 | break; |
| 8378 | 8378 | case 'invoice_supplier': |
| 8379 | - $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); |
|
| 8379 | + $element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); |
|
| 8380 | 8380 | break; |
| 8381 | 8381 | case 'shipping': |
| 8382 | 8382 | $element = 'expedition/sending'; |
@@ -8386,8 +8386,8 @@ discard block |
||
| 8386 | 8386 | } |
| 8387 | 8387 | |
| 8388 | 8388 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; |
| 8389 | - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; |
|
| 8390 | - $sql.= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; |
|
| 8389 | + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; |
|
| 8390 | + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; |
|
| 8391 | 8391 | |
| 8392 | 8392 | if (!$this->db->query($sql)) { |
| 8393 | 8393 | $this->error = $this->db->lasterror(); |
@@ -469,23 +469,31 @@ discard block |
||
| 469 | 469 | $sql .= " FROM ".MAIN_DB_PREFIX.$element; |
| 470 | 470 | $sql .= " WHERE entity IN (".getEntity($element).")"; |
| 471 | 471 | |
| 472 | - if ($id > 0) $sql .= " AND rowid = ".$db->escape($id); |
|
| 473 | - elseif ($ref) $sql .= " AND ref = '".$db->escape($ref)."'"; |
|
| 474 | - elseif ($ref_ext) $sql .= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 475 | - else { |
|
| 472 | + if ($id > 0) { |
|
| 473 | + $sql .= " AND rowid = ".$db->escape($id); |
|
| 474 | + } elseif ($ref) { |
|
| 475 | + $sql .= " AND ref = '".$db->escape($ref)."'"; |
|
| 476 | + } elseif ($ref_ext) { |
|
| 477 | + $sql .= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 478 | + } else { |
|
| 476 | 479 | $error = 'ErrorWrongParameters'; |
| 477 | 480 | dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); |
| 478 | 481 | return -1; |
| 479 | 482 | } |
| 480 | - if ($ref || $ref_ext) $sql .= " AND entity = ".$conf->entity; |
|
| 483 | + if ($ref || $ref_ext) { |
|
| 484 | + $sql .= " AND entity = ".$conf->entity; |
|
| 485 | + } |
|
| 481 | 486 | |
| 482 | 487 | dol_syslog(get_class()."::isExistingObject", LOG_DEBUG); |
| 483 | 488 | $resql = $db->query($sql); |
| 484 | 489 | if ($resql) |
| 485 | 490 | { |
| 486 | 491 | $num = $db->num_rows($resql); |
| 487 | - if ($num > 0) return 1; |
|
| 488 | - else return 0; |
|
| 492 | + if ($num > 0) { |
|
| 493 | + return 1; |
|
| 494 | + } else { |
|
| 495 | + return 0; |
|
| 496 | + } |
|
| 489 | 497 | } |
| 490 | 498 | return -1; |
| 491 | 499 | } |
@@ -555,13 +563,18 @@ discard block |
||
| 555 | 563 | //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n"; |
| 556 | 564 | $lastname = $this->lastname; |
| 557 | 565 | $firstname = $this->firstname; |
| 558 | - if (empty($lastname)) $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); |
|
| 566 | + if (empty($lastname)) { |
|
| 567 | + $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); |
|
| 568 | + } |
|
| 559 | 569 | |
| 560 | 570 | $ret = ''; |
| 561 | 571 | if ($option && $this->civility_code) |
| 562 | 572 | { |
| 563 | - if ($langs->transnoentitiesnoconv("Civility".$this->civility_code) != "Civility".$this->civility_code) $ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_code).' '; |
|
| 564 | - else $ret .= $this->civility_code.' '; |
|
| 573 | + if ($langs->transnoentitiesnoconv("Civility".$this->civility_code) != "Civility".$this->civility_code) { |
|
| 574 | + $ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_code).' '; |
|
| 575 | + } else { |
|
| 576 | + $ret .= $this->civility_code.' '; |
|
| 577 | + } |
|
| 565 | 578 | } |
| 566 | 579 | |
| 567 | 580 | $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder); |
@@ -680,7 +693,9 @@ discard block |
||
| 680 | 693 | |
| 681 | 694 | // List of extra languages |
| 682 | 695 | $arrayoflangcode = array(); |
| 683 | - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 696 | + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) { |
|
| 697 | + $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 698 | + } |
|
| 684 | 699 | |
| 685 | 700 | if (is_array($arrayoflangcode) && count($arrayoflangcode)) { |
| 686 | 701 | if (!is_object($extralanguages)) { |
@@ -693,7 +708,9 @@ discard block |
||
| 693 | 708 | { |
| 694 | 709 | $out .= "<!-- alternatelanguage for '".$elementforaltlanguage."' set to fields '".join(',', $extralanguages->attributes[$elementforaltlanguage])."' -->\n"; |
| 695 | 710 | $this->fetchValuesForExtraLanguages(); |
| 696 | - if (!is_object($form)) $form = new Form($this->db); |
|
| 711 | + if (!is_object($form)) { |
|
| 712 | + $form = new Form($this->db); |
|
| 713 | + } |
|
| 697 | 714 | $htmltext = ''; |
| 698 | 715 | // If there is extra languages |
| 699 | 716 | foreach ($arrayoflangcode as $extralangcode) { |
@@ -717,7 +734,9 @@ discard block |
||
| 717 | 734 | $outdone++; |
| 718 | 735 | } |
| 719 | 736 | |
| 720 | - if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '<br>' : ''); |
|
| 737 | + if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) { |
|
| 738 | + $out .= ($outdone ? '<br>' : ''); |
|
| 739 | + } |
|
| 721 | 740 | if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone |
| 722 | 741 | $out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
| 723 | 742 | } |
@@ -743,7 +762,9 @@ discard block |
||
| 743 | 762 | $out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; |
| 744 | 763 | } |
| 745 | 764 | |
| 746 | - if ($out) $out .= '<div style="clear: both;"></div>'; |
|
| 765 | + if ($out) { |
|
| 766 | + $out .= '<div style="clear: both;"></div>'; |
|
| 767 | + } |
|
| 747 | 768 | $outdone = 0; |
| 748 | 769 | if (!empty($this->email)) |
| 749 | 770 | { |
@@ -767,15 +788,25 @@ discard block |
||
| 767 | 788 | $outdone++; |
| 768 | 789 | } |
| 769 | 790 | } else { |
| 770 | - if ($this->skype) $outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 791 | + if ($this->skype) { |
|
| 792 | + $outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 793 | + } |
|
| 771 | 794 | $outdone++; |
| 772 | - if ($this->jabberid) $outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 795 | + if ($this->jabberid) { |
|
| 796 | + $outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 797 | + } |
|
| 773 | 798 | $outdone++; |
| 774 | - if ($this->twitter) $outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 799 | + if ($this->twitter) { |
|
| 800 | + $outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 801 | + } |
|
| 775 | 802 | $outdone++; |
| 776 | - if ($this->facebook) $outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 803 | + if ($this->facebook) { |
|
| 804 | + $outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 805 | + } |
|
| 777 | 806 | $outdone++; |
| 778 | - if ($this->linkedin) $outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 807 | + if ($this->linkedin) { |
|
| 808 | + $outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 809 | + } |
|
| 779 | 810 | $outdone++; |
| 780 | 811 | } |
| 781 | 812 | |
@@ -784,8 +815,11 @@ discard block |
||
| 784 | 815 | } |
| 785 | 816 | } |
| 786 | 817 | |
| 787 | - if ($out) return '<!-- BEGIN part to show address block -->'."\n".$out.'<!-- END Part to show address block -->'."\n"; |
|
| 788 | - else return ''; |
|
| 818 | + if ($out) { |
|
| 819 | + return '<!-- BEGIN part to show address block -->'."\n".$out.'<!-- END Part to show address block -->'."\n"; |
|
| 820 | + } else { |
|
| 821 | + return ''; |
|
| 822 | + } |
|
| 789 | 823 | } |
| 790 | 824 | |
| 791 | 825 | /** |
@@ -838,7 +872,9 @@ discard block |
||
| 838 | 872 | $this->errors = $ecmfile->errors; |
| 839 | 873 | } |
| 840 | 874 | */ |
| 841 | - } else return ''; |
|
| 875 | + } else { |
|
| 876 | + return ''; |
|
| 877 | + } |
|
| 842 | 878 | } elseif (empty($ecmfile->share)) |
| 843 | 879 | { |
| 844 | 880 | // Add entry into index |
@@ -847,7 +883,9 @@ discard block |
||
| 847 | 883 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 848 | 884 | $ecmfile->share = getRandomPassword(true); |
| 849 | 885 | $ecmfile->update($user); |
| 850 | - } else return ''; |
|
| 886 | + } else { |
|
| 887 | + return ''; |
|
| 888 | + } |
|
| 851 | 889 | } |
| 852 | 890 | // Define $urlwithroot |
| 853 | 891 | $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
@@ -863,8 +901,13 @@ discard block |
||
| 863 | 901 | //if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required. |
| 864 | 902 | //if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; // For sharing with hash (so public files), entity is not required. |
| 865 | 903 | //$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash |
| 866 | - if (!empty($ecmfile->share)) $paramlink .= ($paramlink ? '&' : '').'hashp='.$ecmfile->share; // Hash for public share |
|
| 867 | - if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
| 904 | + if (!empty($ecmfile->share)) { |
|
| 905 | + $paramlink .= ($paramlink ? '&' : '').'hashp='.$ecmfile->share; |
|
| 906 | + } |
|
| 907 | + // Hash for public share |
|
| 908 | + if ($forcedownload) { |
|
| 909 | + $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
| 910 | + } |
|
| 868 | 911 | |
| 869 | 912 | if ($relativelink) |
| 870 | 913 | { |
@@ -928,7 +971,9 @@ discard block |
||
| 928 | 971 | if ($resql) |
| 929 | 972 | { |
| 930 | 973 | $obj = $this->db->fetch_object($resql); |
| 931 | - if ($obj) $id_type_contact = $obj->rowid; |
|
| 974 | + if ($obj) { |
|
| 975 | + $id_type_contact = $obj->rowid; |
|
| 976 | + } |
|
| 932 | 977 | } |
| 933 | 978 | } |
| 934 | 979 | |
@@ -992,7 +1037,9 @@ discard block |
||
| 992 | 1037 | return -1; |
| 993 | 1038 | } |
| 994 | 1039 | } |
| 995 | - } else return 0; |
|
| 1040 | + } else { |
|
| 1041 | + return 0; |
|
| 1042 | + } |
|
| 996 | 1043 | } |
| 997 | 1044 | |
| 998 | 1045 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -1034,8 +1081,12 @@ discard block |
||
| 1034 | 1081 | // Insert into database |
| 1035 | 1082 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; |
| 1036 | 1083 | $sql .= " statut = ".$statut; |
| 1037 | - if ($type_contact_id) $sql .= ", fk_c_type_contact = ".((int) $type_contact_id); |
|
| 1038 | - if ($fk_socpeople) $sql .= ", fk_socpeople = ".((int) $fk_socpeople); |
|
| 1084 | + if ($type_contact_id) { |
|
| 1085 | + $sql .= ", fk_c_type_contact = ".((int) $type_contact_id); |
|
| 1086 | + } |
|
| 1087 | + if ($fk_socpeople) { |
|
| 1088 | + $sql .= ", fk_socpeople = ".((int) $fk_socpeople); |
|
| 1089 | + } |
|
| 1039 | 1090 | $sql .= " where rowid = ".$rowid; |
| 1040 | 1091 | $resql = $this->db->query($sql); |
| 1041 | 1092 | if ($resql) |
@@ -1106,8 +1157,9 @@ discard block |
||
| 1106 | 1157 | |
| 1107 | 1158 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 1108 | 1159 | $sql .= " WHERE element_id = ".$this->id; |
| 1109 | - if ($listId) |
|
| 1110 | - $sql .= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1160 | + if ($listId) { |
|
| 1161 | + $sql .= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1162 | + } |
|
| 1111 | 1163 | |
| 1112 | 1164 | dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); |
| 1113 | 1165 | if ($this->db->query($sql)) |
@@ -1137,22 +1189,38 @@ discard block |
||
| 1137 | 1189 | $tab = array(); |
| 1138 | 1190 | |
| 1139 | 1191 | $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user |
| 1140 | - if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1141 | - if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1192 | + if ($source == 'internal') { |
|
| 1193 | + $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1194 | + } |
|
| 1195 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1196 | + $sql .= ", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1197 | + } |
|
| 1142 | 1198 | $sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; |
| 1143 | 1199 | $sql .= ", tc.source, tc.element, tc.code, tc.libelle"; |
| 1144 | 1200 | $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; |
| 1145 | 1201 | $sql .= ", ".MAIN_DB_PREFIX."element_contact ec"; |
| 1146 | - if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1147 | - if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1202 | + if ($source == 'internal') { |
|
| 1203 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1204 | + } |
|
| 1205 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1206 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1207 | + } |
|
| 1148 | 1208 | $sql .= " WHERE ec.element_id =".$this->id; |
| 1149 | 1209 | $sql .= " AND ec.fk_c_type_contact=tc.rowid"; |
| 1150 | 1210 | $sql .= " AND tc.element='".$this->db->escape($this->element)."'"; |
| 1151 | - if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1152 | - if ($source == 'internal') $sql .= " AND tc.source = 'internal'"; |
|
| 1153 | - if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'"; |
|
| 1211 | + if ($code) { |
|
| 1212 | + $sql .= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1213 | + } |
|
| 1214 | + if ($source == 'internal') { |
|
| 1215 | + $sql .= " AND tc.source = 'internal'"; |
|
| 1216 | + } |
|
| 1217 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1218 | + $sql .= " AND tc.source = 'external'"; |
|
| 1219 | + } |
|
| 1154 | 1220 | $sql .= " AND tc.active=1"; |
| 1155 | - if ($status >= 0) $sql .= " AND ec.statut = ".$status; |
|
| 1221 | + if ($status >= 0) { |
|
| 1222 | + $sql .= " AND ec.statut = ".$status; |
|
| 1223 | + } |
|
| 1156 | 1224 | $sql .= " ORDER BY t.lastname ASC"; |
| 1157 | 1225 | |
| 1158 | 1226 | dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); |
@@ -1238,16 +1306,27 @@ discard block |
||
| 1238 | 1306 | // phpcs:enable |
| 1239 | 1307 | global $langs; |
| 1240 | 1308 | |
| 1241 | - if (empty($order)) $order = 'position'; |
|
| 1242 | - if ($order == 'position') $order .= ',code'; |
|
| 1309 | + if (empty($order)) { |
|
| 1310 | + $order = 'position'; |
|
| 1311 | + } |
|
| 1312 | + if ($order == 'position') { |
|
| 1313 | + $order .= ',code'; |
|
| 1314 | + } |
|
| 1243 | 1315 | |
| 1244 | 1316 | $tab = array(); |
| 1245 | 1317 | $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position"; |
| 1246 | 1318 | $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1247 | 1319 | $sql .= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
| 1248 | - if ($activeonly == 1) $sql .= " AND tc.active=1"; // only the active types |
|
| 1249 | - if (!empty($source) && $source != 'all') $sql .= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1250 | - if (!empty($code)) $sql .= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1320 | + if ($activeonly == 1) { |
|
| 1321 | + $sql .= " AND tc.active=1"; |
|
| 1322 | + } |
|
| 1323 | + // only the active types |
|
| 1324 | + if (!empty($source) && $source != 'all') { |
|
| 1325 | + $sql .= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1326 | + } |
|
| 1327 | + if (!empty($code)) { |
|
| 1328 | + $sql .= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1329 | + } |
|
| 1251 | 1330 | $sql .= $this->db->order($order, 'ASC'); |
| 1252 | 1331 | |
| 1253 | 1332 | //print "sql=".$sql; |
@@ -1262,8 +1341,11 @@ discard block |
||
| 1262 | 1341 | |
| 1263 | 1342 | $transkey = "TypeContact_".$this->element."_".$source."_".$obj->code; |
| 1264 | 1343 | $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1265 | - if (empty($option)) $tab[$obj->rowid] = $libelle_type; |
|
| 1266 | - else $tab[$obj->code] = $libelle_type; |
|
| 1344 | + if (empty($option)) { |
|
| 1345 | + $tab[$obj->rowid] = $libelle_type; |
|
| 1346 | + } else { |
|
| 1347 | + $tab[$obj->code] = $libelle_type; |
|
| 1348 | + } |
|
| 1267 | 1349 | $i++; |
| 1268 | 1350 | } |
| 1269 | 1351 | return $tab; |
@@ -1306,14 +1388,18 @@ discard block |
||
| 1306 | 1388 | $sqlWhere[] = " tc.element <> '".$this->db->escape($excludeelement)."'"; |
| 1307 | 1389 | } |
| 1308 | 1390 | |
| 1309 | - if ($activeonly == 1) |
|
| 1310 | - $sqlWhere[] = " tc.active=1"; // only the active types |
|
| 1391 | + if ($activeonly == 1) { |
|
| 1392 | + $sqlWhere[] = " tc.active=1"; |
|
| 1393 | + } |
|
| 1394 | + // only the active types |
|
| 1311 | 1395 | |
| 1312 | - if (!empty($source) && $source != 'all') |
|
| 1313 | - $sqlWhere[] = " tc.source='".$this->db->escape($source)."'"; |
|
| 1396 | + if (!empty($source) && $source != 'all') { |
|
| 1397 | + $sqlWhere[] = " tc.source='".$this->db->escape($source)."'"; |
|
| 1398 | + } |
|
| 1314 | 1399 | |
| 1315 | - if (!empty($code)) |
|
| 1316 | - $sqlWhere[] = " tc.code='".$this->db->escape($code)."'"; |
|
| 1400 | + if (!empty($code)) { |
|
| 1401 | + $sqlWhere[] = " tc.code='".$this->db->escape($code)."'"; |
|
| 1402 | + } |
|
| 1317 | 1403 | |
| 1318 | 1404 | if (count($sqlWhere) > 0) { |
| 1319 | 1405 | $sql .= " WHERE ".implode(' AND ', $sqlWhere); |
@@ -1343,9 +1429,11 @@ discard block |
||
| 1343 | 1429 | $libelle_element = $langs->trans('ContactDefault_'.$obj->element); |
| 1344 | 1430 | $transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code; |
| 1345 | 1431 | $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1346 | - if (empty($option)) |
|
| 1432 | + if (empty($option)) { |
|
| 1433 | + $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; |
|
| 1434 | + } else { |
|
| 1347 | 1435 | $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; |
| 1348 | - else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; |
|
| 1436 | + } |
|
| 1349 | 1437 | } |
| 1350 | 1438 | } |
| 1351 | 1439 | } |
@@ -1387,19 +1475,31 @@ discard block |
||
| 1387 | 1475 | |
| 1388 | 1476 | $sql = "SELECT ec.fk_socpeople"; |
| 1389 | 1477 | $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; |
| 1390 | - if ($source == 'internal') $sql .= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1391 | - if ($source == 'external') $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1478 | + if ($source == 'internal') { |
|
| 1479 | + $sql .= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1480 | + } |
|
| 1481 | + if ($source == 'external') { |
|
| 1482 | + $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1483 | + } |
|
| 1392 | 1484 | $sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1393 | 1485 | $sql .= " WHERE ec.element_id = ".$id; |
| 1394 | 1486 | $sql .= " AND ec.fk_socpeople = c.rowid"; |
| 1395 | - if ($source == 'internal') $sql .= " AND c.entity IN (".getEntity('user').")"; |
|
| 1396 | - if ($source == 'external') $sql .= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1487 | + if ($source == 'internal') { |
|
| 1488 | + $sql .= " AND c.entity IN (".getEntity('user').")"; |
|
| 1489 | + } |
|
| 1490 | + if ($source == 'external') { |
|
| 1491 | + $sql .= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1492 | + } |
|
| 1397 | 1493 | $sql .= " AND ec.fk_c_type_contact = tc.rowid"; |
| 1398 | 1494 | $sql .= " AND tc.element = '".$this->db->escape($element)."'"; |
| 1399 | 1495 | $sql .= " AND tc.source = '".$this->db->escape($source)."'"; |
| 1400 | - if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1496 | + if ($code) { |
|
| 1497 | + $sql .= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1498 | + } |
|
| 1401 | 1499 | $sql .= " AND tc.active = 1"; |
| 1402 | - if ($status) $sql .= " AND ec.statut = ".$status; |
|
| 1500 | + if ($status) { |
|
| 1501 | + $sql .= " AND ec.statut = ".$status; |
|
| 1502 | + } |
|
| 1403 | 1503 | |
| 1404 | 1504 | dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); |
| 1405 | 1505 | $resql = $this->db->query($sql); |
@@ -1428,9 +1528,13 @@ discard block |
||
| 1428 | 1528 | public function fetch_contact($contactid = null) |
| 1429 | 1529 | { |
| 1430 | 1530 | // phpcs:enable |
| 1431 | - if (empty($contactid)) $contactid = $this->contact_id; |
|
| 1531 | + if (empty($contactid)) { |
|
| 1532 | + $contactid = $this->contact_id; |
|
| 1533 | + } |
|
| 1432 | 1534 | |
| 1433 | - if (empty($contactid)) return 0; |
|
| 1535 | + if (empty($contactid)) { |
|
| 1536 | + return 0; |
|
| 1537 | + } |
|
| 1434 | 1538 | |
| 1435 | 1539 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 1436 | 1540 | $contact = new Contact($this->db); |
@@ -1451,14 +1555,16 @@ discard block |
||
| 1451 | 1555 | // phpcs:enable |
| 1452 | 1556 | global $conf; |
| 1453 | 1557 | |
| 1454 | - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) |
|
| 1455 | - return 0; |
|
| 1558 | + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) { |
|
| 1559 | + return 0; |
|
| 1560 | + } |
|
| 1456 | 1561 | |
| 1457 | 1562 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 1458 | 1563 | |
| 1459 | 1564 | $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); |
| 1460 | - if ($force_thirdparty_id) |
|
| 1461 | - $idtofetch = $force_thirdparty_id; |
|
| 1565 | + if ($force_thirdparty_id) { |
|
| 1566 | + $idtofetch = $force_thirdparty_id; |
|
| 1567 | + } |
|
| 1462 | 1568 | |
| 1463 | 1569 | if ($idtofetch) { |
| 1464 | 1570 | $thirdparty = new Societe($this->db); |
@@ -1471,7 +1577,9 @@ discard block |
||
| 1471 | 1577 | } |
| 1472 | 1578 | |
| 1473 | 1579 | return $result; |
| 1474 | - } else return -1; |
|
| 1580 | + } else { |
|
| 1581 | + return -1; |
|
| 1582 | + } |
|
| 1475 | 1583 | } |
| 1476 | 1584 | |
| 1477 | 1585 | |
@@ -1517,18 +1625,24 @@ discard block |
||
| 1517 | 1625 | dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); |
| 1518 | 1626 | |
| 1519 | 1627 | $idtype = $this->barcode_type; |
| 1520 | - if (empty($idtype) && $idtype != '0') // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1628 | + if (empty($idtype) && $idtype != '0') { |
|
| 1629 | + // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1521 | 1630 | { |
| 1522 | 1631 | if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
| 1523 | - elseif ($this->element == 'societe') $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1524 | - else dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING); |
|
| 1632 | + } elseif ($this->element == 'societe') { |
|
| 1633 | + $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1634 | + } else { |
|
| 1635 | + dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING); |
|
| 1636 | + } |
|
| 1525 | 1637 | } |
| 1526 | 1638 | |
| 1527 | 1639 | if ($idtype > 0) |
| 1528 | 1640 | { |
| 1529 | - if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) // If data not already loaded |
|
| 1641 | + if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { |
|
| 1642 | + // If data not already loaded |
|
| 1530 | 1643 | { |
| 1531 | 1644 | $sql = "SELECT rowid, code, libelle as label, coder"; |
| 1645 | + } |
|
| 1532 | 1646 | $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; |
| 1533 | 1647 | $sql .= " WHERE rowid = ".$idtype; |
| 1534 | 1648 | dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); |
@@ -1561,8 +1675,13 @@ discard block |
||
| 1561 | 1675 | // phpcs:enable |
| 1562 | 1676 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1563 | 1677 | |
| 1564 | - if (empty($this->fk_project) && !empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility |
|
| 1565 | - if (empty($this->fk_project)) return 0; |
|
| 1678 | + if (empty($this->fk_project) && !empty($this->fk_projet)) { |
|
| 1679 | + $this->fk_project = $this->fk_projet; |
|
| 1680 | + } |
|
| 1681 | + // For backward compatibility |
|
| 1682 | + if (empty($this->fk_project)) { |
|
| 1683 | + return 0; |
|
| 1684 | + } |
|
| 1566 | 1685 | |
| 1567 | 1686 | $project = new Project($this->db); |
| 1568 | 1687 | $result = $project->fetch($this->fk_project); |
@@ -1583,7 +1702,9 @@ discard block |
||
| 1583 | 1702 | // phpcs:enable |
| 1584 | 1703 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 1585 | 1704 | |
| 1586 | - if (empty($this->fk_product)) return 0; |
|
| 1705 | + if (empty($this->fk_product)) { |
|
| 1706 | + return 0; |
|
| 1707 | + } |
|
| 1587 | 1708 | |
| 1588 | 1709 | $product = new Product($this->db); |
| 1589 | 1710 | $result = $product->fetch($this->fk_product); |
@@ -1617,9 +1738,15 @@ discard block |
||
| 1617 | 1738 | public function fetch_origin() |
| 1618 | 1739 | { |
| 1619 | 1740 | // phpcs:enable |
| 1620 | - if ($this->origin == 'shipping') $this->origin = 'expedition'; |
|
| 1621 | - if ($this->origin == 'delivery') $this->origin = 'livraison'; |
|
| 1622 | - if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; |
|
| 1741 | + if ($this->origin == 'shipping') { |
|
| 1742 | + $this->origin = 'expedition'; |
|
| 1743 | + } |
|
| 1744 | + if ($this->origin == 'delivery') { |
|
| 1745 | + $this->origin = 'livraison'; |
|
| 1746 | + } |
|
| 1747 | + if ($this->origin == 'order_supplier') { |
|
| 1748 | + $this->origin = 'commandeFournisseur'; |
|
| 1749 | + } |
|
| 1623 | 1750 | |
| 1624 | 1751 | $origin = $this->origin; |
| 1625 | 1752 | |
@@ -1711,29 +1838,48 @@ discard block |
||
| 1711 | 1838 | { |
| 1712 | 1839 | global $user, $langs, $conf; |
| 1713 | 1840 | |
| 1714 | - if (empty($table)) $table = $this->table_element; |
|
| 1715 | - if (empty($id)) $id = $this->id; |
|
| 1716 | - if (empty($format)) $format = 'text'; |
|
| 1717 | - if (empty($id_field)) $id_field = 'rowid'; |
|
| 1841 | + if (empty($table)) { |
|
| 1842 | + $table = $this->table_element; |
|
| 1843 | + } |
|
| 1844 | + if (empty($id)) { |
|
| 1845 | + $id = $this->id; |
|
| 1846 | + } |
|
| 1847 | + if (empty($format)) { |
|
| 1848 | + $format = 'text'; |
|
| 1849 | + } |
|
| 1850 | + if (empty($id_field)) { |
|
| 1851 | + $id_field = 'rowid'; |
|
| 1852 | + } |
|
| 1718 | 1853 | |
| 1719 | 1854 | $error = 0; |
| 1720 | 1855 | |
| 1721 | 1856 | $this->db->begin(); |
| 1722 | 1857 | |
| 1723 | 1858 | // Special case |
| 1724 | - if ($table == 'product' && $field == 'note_private') $field = 'note'; |
|
| 1725 | - if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod'; |
|
| 1859 | + if ($table == 'product' && $field == 'note_private') { |
|
| 1860 | + $field = 'note'; |
|
| 1861 | + } |
|
| 1862 | + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { |
|
| 1863 | + $fk_user_field = 'fk_user_mod'; |
|
| 1864 | + } |
|
| 1726 | 1865 | |
| 1727 | 1866 | $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; |
| 1728 | 1867 | |
| 1729 | - if ($format == 'text') $sql .= $field." = '".$this->db->escape($value)."'"; |
|
| 1730 | - elseif ($format == 'int') $sql .= $field." = ".$this->db->escape($value); |
|
| 1731 | - elseif ($format == 'date') $sql .= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1868 | + if ($format == 'text') { |
|
| 1869 | + $sql .= $field." = '".$this->db->escape($value)."'"; |
|
| 1870 | + } elseif ($format == 'int') { |
|
| 1871 | + $sql .= $field." = ".$this->db->escape($value); |
|
| 1872 | + } elseif ($format == 'date') { |
|
| 1873 | + $sql .= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1874 | + } |
|
| 1732 | 1875 | |
| 1733 | 1876 | if ($fk_user_field) |
| 1734 | 1877 | { |
| 1735 | - if (!empty($fuser) && is_object($fuser)) $sql .= ", ".$fk_user_field." = ".$fuser->id; |
|
| 1736 | - elseif (empty($fuser) || $fuser != 'none') $sql .= ", ".$fk_user_field." = ".$user->id; |
|
| 1878 | + if (!empty($fuser) && is_object($fuser)) { |
|
| 1879 | + $sql .= ", ".$fk_user_field." = ".$fuser->id; |
|
| 1880 | + } elseif (empty($fuser) || $fuser != 'none') { |
|
| 1881 | + $sql .= ", ".$fk_user_field." = ".$user->id; |
|
| 1882 | + } |
|
| 1737 | 1883 | } |
| 1738 | 1884 | |
| 1739 | 1885 | $sql .= " WHERE ".$id_field." = ".$id; |
@@ -1751,13 +1897,20 @@ discard block |
||
| 1751 | 1897 | } else { |
| 1752 | 1898 | $result = $this->fetchCommon($id); |
| 1753 | 1899 | } |
| 1754 | - if ($result >= 0) $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors |
|
| 1755 | - if ($result < 0) $error++; |
|
| 1900 | + if ($result >= 0) { |
|
| 1901 | + $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); |
|
| 1902 | + } |
|
| 1903 | + // This may set this->errors |
|
| 1904 | + if ($result < 0) { |
|
| 1905 | + $error++; |
|
| 1906 | + } |
|
| 1756 | 1907 | } |
| 1757 | 1908 | |
| 1758 | 1909 | if (!$error) |
| 1759 | 1910 | { |
| 1760 | - if (property_exists($this, $field)) $this->$field = $value; |
|
| 1911 | + if (property_exists($this, $field)) { |
|
| 1912 | + $this->$field = $value; |
|
| 1913 | + } |
|
| 1761 | 1914 | $this->db->commit(); |
| 1762 | 1915 | return 1; |
| 1763 | 1916 | } else { |
@@ -1790,16 +1943,23 @@ discard block |
||
| 1790 | 1943 | dol_print_error('', get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined"); |
| 1791 | 1944 | return -1; |
| 1792 | 1945 | } |
| 1793 | - if ($fieldid == 'none') return 1; |
|
| 1946 | + if ($fieldid == 'none') { |
|
| 1947 | + return 1; |
|
| 1948 | + } |
|
| 1794 | 1949 | |
| 1795 | 1950 | // Security on socid |
| 1796 | 1951 | $socid = 0; |
| 1797 | - if ($user->socid > 0) $socid = $user->socid; |
|
| 1952 | + if ($user->socid > 0) { |
|
| 1953 | + $socid = $user->socid; |
|
| 1954 | + } |
|
| 1798 | 1955 | |
| 1799 | 1956 | // this->ismultientitymanaged contains |
| 1800 | 1957 | // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table |
| 1801 | 1958 | $aliastablesociete = 's'; |
| 1802 | - if ($this->element == 'societe') $aliastablesociete = 'te'; // te as table_element |
|
| 1959 | + if ($this->element == 'societe') { |
|
| 1960 | + $aliastablesociete = 'te'; |
|
| 1961 | + } |
|
| 1962 | + // te as table_element |
|
| 1803 | 1963 | |
| 1804 | 1964 | $sql = "SELECT MAX(te.".$fieldid.")"; |
| 1805 | 1965 | $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
@@ -1809,21 +1969,39 @@ discard block |
||
| 1809 | 1969 | if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { |
| 1810 | 1970 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1811 | 1971 | $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity |
| 1812 | - } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1813 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1814 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; |
|
| 1972 | + } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1973 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1974 | + } |
|
| 1975 | + // If we need to link to societe to limit select to socid |
|
| 1976 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1977 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 1978 | + } |
|
| 1979 | + // If we need to link to societe to limit select to socid |
|
| 1980 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 1981 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; |
|
| 1982 | + } |
|
| 1815 | 1983 | $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1816 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; |
|
| 1817 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1984 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1985 | + $sql .= " AND sc.fk_user = ".$user->id; |
|
| 1986 | + } |
|
| 1987 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1988 | + $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1989 | + } |
|
| 1818 | 1990 | if (!empty($filter)) |
| 1819 | 1991 | { |
| 1820 | - if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility |
|
| 1992 | + if (!preg_match('/^\s*AND/i', $filter)) { |
|
| 1993 | + $sql .= " AND "; |
|
| 1994 | + } |
|
| 1995 | + // For backward compatibility |
|
| 1821 | 1996 | $sql .= $filter; |
| 1822 | 1997 | } |
| 1823 | 1998 | if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { |
| 1824 | 1999 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1825 | 2000 | $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity |
| 1826 | - } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 2001 | + } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 2002 | + $sql .= ' AND te.fk_soc = s.rowid'; |
|
| 2003 | + } |
|
| 2004 | + // If we need to link to societe to limit select to socid |
|
| 1827 | 2005 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1828 | 2006 | if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1829 | 2007 | if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
@@ -1840,9 +2018,15 @@ discard block |
||
| 1840 | 2018 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1841 | 2019 | $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; |
| 1842 | 2020 | } |
| 1843 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid; |
|
| 1844 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 1845 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid; |
|
| 2021 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 2022 | + $sql .= ' AND te.fk_soc = '.$socid; |
|
| 2023 | + } |
|
| 2024 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 2025 | + $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 2026 | + } |
|
| 2027 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 2028 | + $sql .= ' AND te.rowid = '.$socid; |
|
| 2029 | + } |
|
| 1846 | 2030 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1847 | 2031 | |
| 1848 | 2032 | $result = $this->db->query($sql); |
@@ -1862,21 +2046,39 @@ discard block |
||
| 1862 | 2046 | if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { |
| 1863 | 2047 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1864 | 2048 | $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity |
| 1865 | - } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1866 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1867 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; |
|
| 2049 | + } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 2050 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2051 | + } |
|
| 2052 | + // If we need to link to societe to limit select to socid |
|
| 2053 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 2054 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 2055 | + } |
|
| 2056 | + // If we need to link to societe to limit select to socid |
|
| 2057 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 2058 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; |
|
| 2059 | + } |
|
| 1868 | 2060 | $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1869 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; |
|
| 1870 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 2061 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 2062 | + $sql .= " AND sc.fk_user = ".$user->id; |
|
| 2063 | + } |
|
| 2064 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 2065 | + $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 2066 | + } |
|
| 1871 | 2067 | if (!empty($filter)) |
| 1872 | 2068 | { |
| 1873 | - if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility |
|
| 2069 | + if (!preg_match('/^\s*AND/i', $filter)) { |
|
| 2070 | + $sql .= " AND "; |
|
| 2071 | + } |
|
| 2072 | + // For backward compatibility |
|
| 1874 | 2073 | $sql .= $filter; |
| 1875 | 2074 | } |
| 1876 | 2075 | if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { |
| 1877 | 2076 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1878 | 2077 | $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity |
| 1879 | - } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 2078 | + } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 2079 | + $sql .= ' AND te.fk_soc = s.rowid'; |
|
| 2080 | + } |
|
| 2081 | + // If we need to link to societe to limit select to socid |
|
| 1880 | 2082 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1881 | 2083 | if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1882 | 2084 | if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
@@ -1893,9 +2095,15 @@ discard block |
||
| 1893 | 2095 | $tmparray = explode('@', $this->ismultientitymanaged); |
| 1894 | 2096 | $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; |
| 1895 | 2097 | } |
| 1896 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid; |
|
| 1897 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 1898 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid; |
|
| 2098 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 2099 | + $sql .= ' AND te.fk_soc = '.$socid; |
|
| 2100 | + } |
|
| 2101 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 2102 | + $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 2103 | + } |
|
| 2104 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 2105 | + $sql .= ' AND te.rowid = '.$socid; |
|
| 2106 | + } |
|
| 1899 | 2107 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1900 | 2108 | // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null |
| 1901 | 2109 | |
@@ -1927,8 +2135,11 @@ discard block |
||
| 1927 | 2135 | $i = 0; |
| 1928 | 2136 | while ($i < $num) |
| 1929 | 2137 | { |
| 1930 | - if ($source == 'thirdparty') $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 1931 | - else $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 2138 | + if ($source == 'thirdparty') { |
|
| 2139 | + $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 2140 | + } else { |
|
| 2141 | + $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 2142 | + } |
|
| 1932 | 2143 | $i++; |
| 1933 | 2144 | } |
| 1934 | 2145 | return $contactAlreadySelected; |
@@ -1950,20 +2161,29 @@ discard block |
||
| 1950 | 2161 | } |
| 1951 | 2162 | |
| 1952 | 2163 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1953 | - if (!empty($this->fields['fk_project'])) // Common case |
|
| 2164 | + if (!empty($this->fields['fk_project'])) { |
|
| 2165 | + // Common case |
|
| 1954 | 2166 | { |
| 1955 | 2167 | if ($projectid) $sql .= ' SET fk_project = '.$projectid; |
| 1956 | - else $sql .= ' SET fk_project = NULL'; |
|
| 2168 | + } else { |
|
| 2169 | + $sql .= ' SET fk_project = NULL'; |
|
| 2170 | + } |
|
| 1957 | 2171 | $sql .= ' WHERE rowid = '.$this->id; |
| 1958 | - } elseif ($this->table_element == 'actioncomm') // Special case for actioncomm |
|
| 2172 | + } elseif ($this->table_element == 'actioncomm') { |
|
| 2173 | + // Special case for actioncomm |
|
| 1959 | 2174 | { |
| 1960 | 2175 | if ($projectid) $sql .= ' SET fk_project = '.$projectid; |
| 1961 | - else $sql .= ' SET fk_project = NULL'; |
|
| 2176 | + } else { |
|
| 2177 | + $sql .= ' SET fk_project = NULL'; |
|
| 2178 | + } |
|
| 1962 | 2179 | $sql .= ' WHERE id = '.$this->id; |
| 1963 | 2180 | } else // Special case for old architecture objects |
| 1964 | 2181 | { |
| 1965 | - if ($projectid) $sql .= ' SET fk_projet = '.$projectid; |
|
| 1966 | - else $sql .= ' SET fk_projet = NULL'; |
|
| 2182 | + if ($projectid) { |
|
| 2183 | + $sql .= ' SET fk_projet = '.$projectid; |
|
| 2184 | + } else { |
|
| 2185 | + $sql .= ' SET fk_projet = NULL'; |
|
| 2186 | + } |
|
| 1967 | 2187 | $sql .= ' WHERE rowid = '.$this->id; |
| 1968 | 2188 | } |
| 1969 | 2189 | |
@@ -1991,8 +2211,12 @@ discard block |
||
| 1991 | 2211 | { |
| 1992 | 2212 | // TODO uniformize field name |
| 1993 | 2213 | $fieldname = 'fk_mode_reglement'; |
| 1994 | - if ($this->element == 'societe') $fieldname = 'mode_reglement'; |
|
| 1995 | - if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; |
|
| 2214 | + if ($this->element == 'societe') { |
|
| 2215 | + $fieldname = 'mode_reglement'; |
|
| 2216 | + } |
|
| 2217 | + if (get_class($this) == 'Fournisseur') { |
|
| 2218 | + $fieldname = 'mode_reglement_supplier'; |
|
| 2219 | + } |
|
| 1996 | 2220 | |
| 1997 | 2221 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1998 | 2222 | $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
@@ -2002,7 +2226,9 @@ discard block |
||
| 2002 | 2226 | { |
| 2003 | 2227 | $this->mode_reglement_id = $id; |
| 2004 | 2228 | // for supplier |
| 2005 | - if (get_class($this) == 'Fournisseur') $this->mode_reglement_supplier_id = $id; |
|
| 2229 | + if (get_class($this) == 'Fournisseur') { |
|
| 2230 | + $this->mode_reglement_supplier_id = $id; |
|
| 2231 | + } |
|
| 2006 | 2232 | return 1; |
| 2007 | 2233 | } else { |
| 2008 | 2234 | dol_syslog(get_class($this).'::setPaymentMethods Error '.$sql.' - '.$this->db->error()); |
@@ -2038,7 +2264,9 @@ discard block |
||
| 2038 | 2264 | $this->multicurrency_code = $code; |
| 2039 | 2265 | |
| 2040 | 2266 | list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code); |
| 2041 | - if ($rate) $this->setMulticurrencyRate($rate, 2); |
|
| 2267 | + if ($rate) { |
|
| 2268 | + $this->setMulticurrencyRate($rate, 2); |
|
| 2269 | + } |
|
| 2042 | 2270 | |
| 2043 | 2271 | return 1; |
| 2044 | 2272 | } else { |
@@ -2170,8 +2398,12 @@ discard block |
||
| 2170 | 2398 | { |
| 2171 | 2399 | // TODO uniformize field name |
| 2172 | 2400 | $fieldname = 'fk_cond_reglement'; |
| 2173 | - if ($this->element == 'societe') $fieldname = 'cond_reglement'; |
|
| 2174 | - if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier'; |
|
| 2401 | + if ($this->element == 'societe') { |
|
| 2402 | + $fieldname = 'cond_reglement'; |
|
| 2403 | + } |
|
| 2404 | + if (get_class($this) == 'Fournisseur') { |
|
| 2405 | + $fieldname = 'cond_reglement_supplier'; |
|
| 2406 | + } |
|
| 2175 | 2407 | |
| 2176 | 2408 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2177 | 2409 | $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
@@ -2181,7 +2413,9 @@ discard block |
||
| 2181 | 2413 | { |
| 2182 | 2414 | $this->cond_reglement_id = $id; |
| 2183 | 2415 | // for supplier |
| 2184 | - if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id; |
|
| 2416 | + if (get_class($this) == 'Fournisseur') { |
|
| 2417 | + $this->cond_reglement_supplier_id = $id; |
|
| 2418 | + } |
|
| 2185 | 2419 | $this->cond_reglement = $id; // for compatibility |
| 2186 | 2420 | return 1; |
| 2187 | 2421 | } else { |
@@ -2208,8 +2442,12 @@ discard block |
||
| 2208 | 2442 | if ($this->statut >= 0 || $this->element == 'societe') |
| 2209 | 2443 | { |
| 2210 | 2444 | $fieldname = 'fk_transport_mode'; |
| 2211 | - if ($this->element == 'societe') $fieldname = 'transport_mode'; |
|
| 2212 | - if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; |
|
| 2445 | + if ($this->element == 'societe') { |
|
| 2446 | + $fieldname = 'transport_mode'; |
|
| 2447 | + } |
|
| 2448 | + if (get_class($this) == 'Fournisseur') { |
|
| 2449 | + $fieldname = 'transport_mode_supplier'; |
|
| 2450 | + } |
|
| 2213 | 2451 | |
| 2214 | 2452 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2215 | 2453 | $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
@@ -2219,7 +2457,9 @@ discard block |
||
| 2219 | 2457 | { |
| 2220 | 2458 | $this->transport_mode_id = $id; |
| 2221 | 2459 | // for supplier |
| 2222 | - if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; |
|
| 2460 | + if (get_class($this) == 'Fournisseur') { |
|
| 2461 | + $this->transport_mode_supplier_id = $id; |
|
| 2462 | + } |
|
| 2223 | 2463 | return 1; |
| 2224 | 2464 | } else { |
| 2225 | 2465 | dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); |
@@ -2276,7 +2516,9 @@ discard block |
||
| 2276 | 2516 | public function setDeliveryAddress($id) |
| 2277 | 2517 | { |
| 2278 | 2518 | $fieldname = 'fk_delivery_address'; |
| 2279 | - if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; |
|
| 2519 | + if ($this->element == 'delivery' || $this->element == 'shipping') { |
|
| 2520 | + $fieldname = 'fk_address'; |
|
| 2521 | + } |
|
| 2280 | 2522 | |
| 2281 | 2523 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; |
| 2282 | 2524 | $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; |
@@ -2306,7 +2548,9 @@ discard block |
||
| 2306 | 2548 | { |
| 2307 | 2549 | global $user; |
| 2308 | 2550 | |
| 2309 | - if (empty($userused)) $userused = $user; |
|
| 2551 | + if (empty($userused)) { |
|
| 2552 | + $userused = $user; |
|
| 2553 | + } |
|
| 2310 | 2554 | |
| 2311 | 2555 | $error = 0; |
| 2312 | 2556 | |
@@ -2317,7 +2561,9 @@ discard block |
||
| 2317 | 2561 | |
| 2318 | 2562 | $this->db->begin(); |
| 2319 | 2563 | |
| 2320 | - if ($shipping_method_id < 0) $shipping_method_id = 'NULL'; |
|
| 2564 | + if ($shipping_method_id < 0) { |
|
| 2565 | + $shipping_method_id = 'NULL'; |
|
| 2566 | + } |
|
| 2321 | 2567 | dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')'); |
| 2322 | 2568 | |
| 2323 | 2569 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2334,7 +2580,9 @@ discard block |
||
| 2334 | 2580 | // Call trigger |
| 2335 | 2581 | $this->context = array('shippingmethodupdate'=>1); |
| 2336 | 2582 | $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused); |
| 2337 | - if ($result < 0) $error++; |
|
| 2583 | + if ($result < 0) { |
|
| 2584 | + $error++; |
|
| 2585 | + } |
|
| 2338 | 2586 | // End call trigger |
| 2339 | 2587 | } |
| 2340 | 2588 | } |
@@ -2362,7 +2610,9 @@ discard block |
||
| 2362 | 2610 | dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); |
| 2363 | 2611 | return -1; |
| 2364 | 2612 | } |
| 2365 | - if ($warehouse_id < 0) $warehouse_id = 'NULL'; |
|
| 2613 | + if ($warehouse_id < 0) { |
|
| 2614 | + $warehouse_id = 'NULL'; |
|
| 2615 | + } |
|
| 2366 | 2616 | dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); |
| 2367 | 2617 | |
| 2368 | 2618 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2429,7 +2679,9 @@ discard block |
||
| 2429 | 2679 | { |
| 2430 | 2680 | global $user; |
| 2431 | 2681 | |
| 2432 | - if (empty($userused)) $userused = $user; |
|
| 2682 | + if (empty($userused)) { |
|
| 2683 | + $userused = $user; |
|
| 2684 | + } |
|
| 2433 | 2685 | |
| 2434 | 2686 | $error = 0; |
| 2435 | 2687 | |
@@ -2439,7 +2691,9 @@ discard block |
||
| 2439 | 2691 | } |
| 2440 | 2692 | $this->db->begin(); |
| 2441 | 2693 | |
| 2442 | - if ($fk_account < 0) $fk_account = 'NULL'; |
|
| 2694 | + if ($fk_account < 0) { |
|
| 2695 | + $fk_account = 'NULL'; |
|
| 2696 | + } |
|
| 2443 | 2697 | dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); |
| 2444 | 2698 | |
| 2445 | 2699 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2458,7 +2712,9 @@ discard block |
||
| 2458 | 2712 | // Call trigger |
| 2459 | 2713 | $this->context = array('bankaccountupdate'=>1); |
| 2460 | 2714 | $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused); |
| 2461 | - if ($result < 0) $error++; |
|
| 2715 | + if ($result < 0) { |
|
| 2716 | + $error++; |
|
| 2717 | + } |
|
| 2462 | 2718 | // End call trigger |
| 2463 | 2719 | } |
| 2464 | 2720 | } |
@@ -2504,8 +2760,12 @@ discard block |
||
| 2504 | 2760 | $nl = 0; |
| 2505 | 2761 | $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2506 | 2762 | $sql .= ' WHERE '.$this->fk_element.'='.$this->id; |
| 2507 | - if (!$renum) $sql .= ' AND rang = 0'; |
|
| 2508 | - if ($renum) $sql .= ' AND rang <> 0'; |
|
| 2763 | + if (!$renum) { |
|
| 2764 | + $sql .= ' AND rang = 0'; |
|
| 2765 | + } |
|
| 2766 | + if ($renum) { |
|
| 2767 | + $sql .= ' AND rang <> 0'; |
|
| 2768 | + } |
|
| 2509 | 2769 | |
| 2510 | 2770 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG); |
| 2511 | 2771 | $resql = $this->db->query($sql); |
@@ -2513,7 +2773,9 @@ discard block |
||
| 2513 | 2773 | { |
| 2514 | 2774 | $row = $this->db->fetch_row($resql); |
| 2515 | 2775 | $nl = $row[0]; |
| 2516 | - } else dol_print_error($this->db); |
|
| 2776 | + } else { |
|
| 2777 | + dol_print_error($this->db); |
|
| 2778 | + } |
|
| 2517 | 2779 | if ($nl > 0) |
| 2518 | 2780 | { |
| 2519 | 2781 | // The goal of this part is to reorder all lines, with all children lines sharing the same |
@@ -2523,7 +2785,9 @@ discard block |
||
| 2523 | 2785 | // We first search all lines that are parent lines (for multilevel details lines) |
| 2524 | 2786 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2525 | 2787 | $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 2526 | - if ($fk_parent_line) $sql .= ' AND fk_parent_line IS NULL'; |
|
| 2788 | + if ($fk_parent_line) { |
|
| 2789 | + $sql .= ' AND fk_parent_line IS NULL'; |
|
| 2790 | + } |
|
| 2527 | 2791 | $sql .= ' ORDER BY rang ASC, rowid '.$rowidorder; |
| 2528 | 2792 | |
| 2529 | 2793 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); |
@@ -2585,7 +2849,9 @@ discard block |
||
| 2585 | 2849 | if ($this->db->num_rows($resql) > 0) { |
| 2586 | 2850 | while ($row = $this->db->fetch_row($resql)) { |
| 2587 | 2851 | $rows[] = $row[0]; |
| 2588 | - if (!empty($includealltree)) $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree); |
|
| 2852 | + if (!empty($includealltree)) { |
|
| 2853 | + $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree); |
|
| 2854 | + } |
|
| 2589 | 2855 | } |
| 2590 | 2856 | } |
| 2591 | 2857 | } |
@@ -2645,7 +2911,9 @@ discard block |
||
| 2645 | 2911 | public function updateRangOfLine($rowid, $rang) |
| 2646 | 2912 | { |
| 2647 | 2913 | $fieldposition = 'rang'; // @todo Rename 'rang' into 'position' |
| 2648 | - if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2914 | + if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2915 | + $fieldposition = 'position'; |
|
| 2916 | + } |
|
| 2649 | 2917 | |
| 2650 | 2918 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2651 | 2919 | $sql .= ' WHERE rowid = '.$rowid; |
@@ -2686,7 +2954,9 @@ discard block |
||
| 2686 | 2954 | if ($rang > 1) |
| 2687 | 2955 | { |
| 2688 | 2956 | $fieldposition = 'rang'; |
| 2689 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2957 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2958 | + $fieldposition = 'position'; |
|
| 2959 | + } |
|
| 2690 | 2960 | |
| 2691 | 2961 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2692 | 2962 | $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2718,7 +2988,9 @@ discard block |
||
| 2718 | 2988 | if ($rang < $max) |
| 2719 | 2989 | { |
| 2720 | 2990 | $fieldposition = 'rang'; |
| 2721 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2991 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2992 | + $fieldposition = 'position'; |
|
| 2993 | + } |
|
| 2722 | 2994 | |
| 2723 | 2995 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2724 | 2996 | $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2787,7 +3059,9 @@ discard block |
||
| 2787 | 3059 | { |
| 2788 | 3060 | // phpcs:enable |
| 2789 | 3061 | $positionfield = 'rang'; |
| 2790 | - if ($this->table_element == 'bom') $positionfield = 'position'; |
|
| 3062 | + if ($this->table_element == 'bom') { |
|
| 3063 | + $positionfield = 'position'; |
|
| 3064 | + } |
|
| 2791 | 3065 | |
| 2792 | 3066 | // Search the last rang with fk_parent_line |
| 2793 | 3067 | if ($fk_parent_line) |
@@ -2884,7 +3158,9 @@ discard block |
||
| 2884 | 3158 | $newsuffix = $suffix; |
| 2885 | 3159 | |
| 2886 | 3160 | // Special cas |
| 2887 | - if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = ''; |
|
| 3161 | + if ($this->table_element == 'product' && $newsuffix == '_private') { |
|
| 3162 | + $newsuffix = ''; |
|
| 3163 | + } |
|
| 2888 | 3164 | |
| 2889 | 3165 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2890 | 3166 | $sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); |
@@ -2894,9 +3170,11 @@ discard block |
||
| 2894 | 3170 | dol_syslog(get_class($this)."::update_note", LOG_DEBUG); |
| 2895 | 3171 | if ($this->db->query($sql)) |
| 2896 | 3172 | { |
| 2897 | - if ($suffix == '_public') $this->note_public = $note; |
|
| 2898 | - elseif ($suffix == '_private') $this->note_private = $note; |
|
| 2899 | - else { |
|
| 3173 | + if ($suffix == '_public') { |
|
| 3174 | + $this->note_public = $note; |
|
| 3175 | + } elseif ($suffix == '_private') { |
|
| 3176 | + $this->note_private = $note; |
|
| 3177 | + } else { |
|
| 2900 | 3178 | $this->note = $note; // deprecated |
| 2901 | 3179 | $this->note_private = $note; |
| 2902 | 3180 | } |
@@ -2948,36 +3226,45 @@ discard block |
||
| 2948 | 3226 | |
| 2949 | 3227 | // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) |
| 2950 | 3228 | $MODULE = ""; |
| 2951 | - if ($this->element == 'propal') |
|
| 2952 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 2953 | - elseif ($this->element == 'commande' || $this->element == 'order') |
|
| 2954 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 2955 | - elseif ($this->element == 'facture' || $this->element == 'invoice') |
|
| 2956 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 2957 | - elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice' || $this->element == 'invoice_supplier') |
|
| 2958 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 2959 | - elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') |
|
| 2960 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 2961 | - elseif ($this->element == 'supplier_proposal') |
|
| 2962 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 3229 | + if ($this->element == 'propal') { |
|
| 3230 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 3231 | + } elseif ($this->element == 'commande' || $this->element == 'order') { |
|
| 3232 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 3233 | + } elseif ($this->element == 'facture' || $this->element == 'invoice') { |
|
| 3234 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 3235 | + } elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice' || $this->element == 'invoice_supplier') { |
|
| 3236 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 3237 | + } elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') { |
|
| 3238 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 3239 | + } elseif ($this->element == 'supplier_proposal') { |
|
| 3240 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 3241 | + } |
|
| 2963 | 3242 | |
| 2964 | 3243 | if (!empty($MODULE)) { |
| 2965 | 3244 | if (!empty($conf->global->$MODULE)) { |
| 2966 | 3245 | $modsactivated = explode(',', $conf->global->$MODULE); |
| 2967 | 3246 | foreach ($modsactivated as $mod) { |
| 2968 | - if ($conf->$mod->enabled) |
|
| 2969 | - return 1; // update was disabled by specific setup |
|
| 3247 | + if ($conf->$mod->enabled) { |
|
| 3248 | + return 1; |
|
| 3249 | + } |
|
| 3250 | + // update was disabled by specific setup |
|
| 2970 | 3251 | } |
| 2971 | 3252 | } |
| 2972 | 3253 | } |
| 2973 | 3254 | |
| 2974 | 3255 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2975 | 3256 | |
| 2976 | - if ($roundingadjust == '-1') $roundingadjust = 'auto'; // For backward compatibility |
|
| 3257 | + if ($roundingadjust == '-1') { |
|
| 3258 | + $roundingadjust = 'auto'; |
|
| 3259 | + } |
|
| 3260 | + // For backward compatibility |
|
| 2977 | 3261 | |
| 2978 | 3262 | $forcedroundingmode = $roundingadjust; |
| 2979 | - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2980 | - elseif ($forcedroundingmode == 'auto') $forcedroundingmode = '0'; |
|
| 3263 | + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { |
|
| 3264 | + $forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 3265 | + } elseif ($forcedroundingmode == 'auto') { |
|
| 3266 | + $forcedroundingmode = '0'; |
|
| 3267 | + } |
|
| 2981 | 3268 | |
| 2982 | 3269 | $error = 0; |
| 2983 | 3270 | |
@@ -3000,15 +3287,22 @@ discard block |
||
| 3000 | 3287 | |
| 3001 | 3288 | $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; |
| 3002 | 3289 | $sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; |
| 3003 | - if ($this->table_element_line == 'facturedet') $sql .= ', situation_percent'; |
|
| 3290 | + if ($this->table_element_line == 'facturedet') { |
|
| 3291 | + $sql .= ', situation_percent'; |
|
| 3292 | + } |
|
| 3004 | 3293 | $sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
| 3005 | 3294 | $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 3006 | 3295 | $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 3007 | 3296 | if ($exclspec) |
| 3008 | 3297 | { |
| 3009 | 3298 | $product_field = 'product_type'; |
| 3010 | - if ($this->table_element_line == 'contratdet') $product_field = ''; // contratdet table has no product_type field |
|
| 3011 | - if ($product_field) $sql .= ' AND '.$product_field.' <> 9'; |
|
| 3299 | + if ($this->table_element_line == 'contratdet') { |
|
| 3300 | + $product_field = ''; |
|
| 3301 | + } |
|
| 3302 | + // contratdet table has no product_type field |
|
| 3303 | + if ($product_field) { |
|
| 3304 | + $sql .= ' AND '.$product_field.' <> 9'; |
|
| 3305 | + } |
|
| 3012 | 3306 | } |
| 3013 | 3307 | $sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used |
| 3014 | 3308 | |
@@ -3038,10 +3332,12 @@ discard block |
||
| 3038 | 3332 | $parameters = array('fk_element' => $obj->rowid); |
| 3039 | 3333 | $reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 3040 | 3334 | |
| 3041 | - if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 3335 | + if (empty($reshook) && $forcedroundingmode == '0') { |
|
| 3336 | + // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 3042 | 3337 | { |
| 3043 | 3338 | // This part of code is to fix data. We should not call it too often. |
| 3044 | 3339 | $localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx); |
| 3340 | + } |
|
| 3045 | 3341 | $tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); |
| 3046 | 3342 | |
| 3047 | 3343 | $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price adn unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT. |
@@ -3054,7 +3350,9 @@ discard block |
||
| 3054 | 3350 | $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; |
| 3055 | 3351 | dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING); |
| 3056 | 3352 | $resqlfix = $this->db->query($sqlfix); |
| 3057 | - if (!$resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3353 | + if (!$resqlfix) { |
|
| 3354 | + dol_print_error($this->db, 'Failed to update line'); |
|
| 3355 | + } |
|
| 3058 | 3356 | $obj->total_tva = $tmpcal[1]; |
| 3059 | 3357 | $obj->total_ttc = $tmpcal[2]; |
| 3060 | 3358 | } |
@@ -3069,16 +3367,24 @@ discard block |
||
| 3069 | 3367 | $this->multicurrency_total_tva += $obj->multicurrency_total_tva; |
| 3070 | 3368 | $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; |
| 3071 | 3369 | |
| 3072 | - if (!isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate] = 0; |
|
| 3073 | - if (!isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate] = 0; |
|
| 3074 | - if (!isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate] = 0; |
|
| 3370 | + if (!isset($total_ht_by_vats[$obj->vatrate])) { |
|
| 3371 | + $total_ht_by_vats[$obj->vatrate] = 0; |
|
| 3372 | + } |
|
| 3373 | + if (!isset($total_tva_by_vats[$obj->vatrate])) { |
|
| 3374 | + $total_tva_by_vats[$obj->vatrate] = 0; |
|
| 3375 | + } |
|
| 3376 | + if (!isset($total_ttc_by_vats[$obj->vatrate])) { |
|
| 3377 | + $total_ttc_by_vats[$obj->vatrate] = 0; |
|
| 3378 | + } |
|
| 3075 | 3379 | $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; |
| 3076 | 3380 | $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; |
| 3077 | 3381 | $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; |
| 3078 | 3382 | |
| 3079 | - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 3383 | + if ($forcedroundingmode == '1') { |
|
| 3384 | + // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 3080 | 3385 | { |
| 3081 | 3386 | $tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
| 3387 | + } |
|
| 3082 | 3388 | $diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1); |
| 3083 | 3389 | //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n"; |
| 3084 | 3390 | if ($diff) |
@@ -3092,7 +3398,9 @@ discard block |
||
| 3092 | 3398 | $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; |
| 3093 | 3399 | dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); |
| 3094 | 3400 | $resqlfix = $this->db->query($sqlfix); |
| 3095 | - if (!$resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3401 | + if (!$resqlfix) { |
|
| 3402 | + dol_print_error($this->db, 'Failed to update line'); |
|
| 3403 | + } |
|
| 3096 | 3404 | $this->total_tva -= $diff; |
| 3097 | 3405 | $this->total_ttc -= $diff; |
| 3098 | 3406 | $total_tva_by_vats[$obj->vatrate] -= $diff; |
@@ -3133,11 +3441,21 @@ discard block |
||
| 3133 | 3441 | $fieldlocaltax2 = 'localtax2'; |
| 3134 | 3442 | $fieldttc = 'total_ttc'; |
| 3135 | 3443 | // Specific code for backward compatibility with old field names |
| 3136 | - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total'; |
|
| 3137 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva'; |
|
| 3138 | - if ($this->element == 'propal') $fieldttc = 'total'; |
|
| 3139 | - if ($this->element == 'expensereport') $fieldtva = 'total_tva'; |
|
| 3140 | - if ($this->element == 'supplier_proposal') $fieldttc = 'total'; |
|
| 3444 | + if ($this->element == 'facture' || $this->element == 'facturerec') { |
|
| 3445 | + $fieldht = 'total'; |
|
| 3446 | + } |
|
| 3447 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { |
|
| 3448 | + $fieldtva = 'total_tva'; |
|
| 3449 | + } |
|
| 3450 | + if ($this->element == 'propal') { |
|
| 3451 | + $fieldttc = 'total'; |
|
| 3452 | + } |
|
| 3453 | + if ($this->element == 'expensereport') { |
|
| 3454 | + $fieldtva = 'total_tva'; |
|
| 3455 | + } |
|
| 3456 | + if ($this->element == 'supplier_proposal') { |
|
| 3457 | + $fieldttc = 'total'; |
|
| 3458 | + } |
|
| 3141 | 3459 | |
| 3142 | 3460 | if (empty($nodatabaseupdate)) |
| 3143 | 3461 | { |
@@ -3191,10 +3509,18 @@ discard block |
||
| 3191 | 3509 | $origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id); |
| 3192 | 3510 | |
| 3193 | 3511 | // Special case |
| 3194 | - if ($origin == 'order') $origin = 'commande'; |
|
| 3195 | - if ($origin == 'invoice') $origin = 'facture'; |
|
| 3196 | - if ($origin == 'invoice_template') $origin = 'facturerec'; |
|
| 3197 | - if ($origin == 'supplierorder') $origin = 'order_supplier'; |
|
| 3512 | + if ($origin == 'order') { |
|
| 3513 | + $origin = 'commande'; |
|
| 3514 | + } |
|
| 3515 | + if ($origin == 'invoice') { |
|
| 3516 | + $origin = 'facture'; |
|
| 3517 | + } |
|
| 3518 | + if ($origin == 'invoice_template') { |
|
| 3519 | + $origin = 'facturerec'; |
|
| 3520 | + } |
|
| 3521 | + if ($origin == 'supplierorder') { |
|
| 3522 | + $origin = 'order_supplier'; |
|
| 3523 | + } |
|
| 3198 | 3524 | $this->db->begin(); |
| 3199 | 3525 | |
| 3200 | 3526 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; |
@@ -3258,12 +3584,16 @@ discard block |
||
| 3258 | 3584 | if (!empty($sourceid) && !empty($sourcetype) && empty($targetid)) |
| 3259 | 3585 | { |
| 3260 | 3586 | $justsource = true; // the source (id and type) is a search criteria |
| 3261 | - if (!empty($targettype)) $withtargettype = true; |
|
| 3587 | + if (!empty($targettype)) { |
|
| 3588 | + $withtargettype = true; |
|
| 3589 | + } |
|
| 3262 | 3590 | } |
| 3263 | 3591 | if (!empty($targetid) && !empty($targettype) && empty($sourceid)) |
| 3264 | 3592 | { |
| 3265 | 3593 | $justtarget = true; // the target (id and type) is a search criteria |
| 3266 | - if (!empty($sourcetype)) $withsourcetype = true; |
|
| 3594 | + if (!empty($sourcetype)) { |
|
| 3595 | + $withsourcetype = true; |
|
| 3596 | + } |
|
| 3267 | 3597 | } |
| 3268 | 3598 | |
| 3269 | 3599 | $sourceid = (!empty($sourceid) ? $sourceid : $this->id); |
@@ -3286,11 +3616,15 @@ discard block |
||
| 3286 | 3616 | if ($justsource) |
| 3287 | 3617 | { |
| 3288 | 3618 | $sql .= "fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
| 3289 | - if ($withtargettype) $sql .= " AND targettype = '".$this->db->escape($targettype)."'"; |
|
| 3619 | + if ($withtargettype) { |
|
| 3620 | + $sql .= " AND targettype = '".$this->db->escape($targettype)."'"; |
|
| 3621 | + } |
|
| 3290 | 3622 | } elseif ($justtarget) |
| 3291 | 3623 | { |
| 3292 | 3624 | $sql .= "fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; |
| 3293 | - if ($withsourcetype) $sql .= " AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3625 | + if ($withsourcetype) { |
|
| 3626 | + $sql .= " AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3627 | + } |
|
| 3294 | 3628 | } |
| 3295 | 3629 | } else { |
| 3296 | 3630 | $sql .= "(fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."')"; |
@@ -3332,10 +3666,12 @@ discard block |
||
| 3332 | 3666 | if (!empty($this->linkedObjectsIds)) |
| 3333 | 3667 | { |
| 3334 | 3668 | $tmparray = $this->linkedObjectsIds; |
| 3335 | - foreach ($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3669 | + foreach ($tmparray as $objecttype => $objectids) { |
|
| 3670 | + // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3336 | 3671 | { |
| 3337 | 3672 | // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) |
| 3338 | 3673 | $module = $element = $subelement = $objecttype; |
| 3674 | + } |
|
| 3339 | 3675 | if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier' |
| 3340 | 3676 | && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) |
| 3341 | 3677 | { |
@@ -3395,9 +3731,11 @@ discard block |
||
| 3395 | 3731 | //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); |
| 3396 | 3732 | if (class_exists($classname)) |
| 3397 | 3733 | { |
| 3398 | - foreach ($objectids as $i => $objectid) // $i is rowid into llx_element_element |
|
| 3734 | + foreach ($objectids as $i => $objectid) { |
|
| 3735 | + // $i is rowid into llx_element_element |
|
| 3399 | 3736 | { |
| 3400 | 3737 | $object = new $classname($this->db); |
| 3738 | + } |
|
| 3401 | 3739 | $ret = $object->fetch($objectid); |
| 3402 | 3740 | if ($ret >= 0) |
| 3403 | 3741 | { |
@@ -3433,8 +3771,11 @@ discard block |
||
| 3433 | 3771 | $updatesource = false; |
| 3434 | 3772 | $updatetarget = false; |
| 3435 | 3773 | |
| 3436 | - if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource = true; |
|
| 3437 | - elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $updatetarget = true; |
|
| 3774 | + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3775 | + $updatesource = true; |
|
| 3776 | + } elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) { |
|
| 3777 | + $updatetarget = true; |
|
| 3778 | + } |
|
| 3438 | 3779 | |
| 3439 | 3780 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET "; |
| 3440 | 3781 | if ($updatesource) |
@@ -3477,8 +3818,11 @@ discard block |
||
| 3477 | 3818 | $deletesource = false; |
| 3478 | 3819 | $deletetarget = false; |
| 3479 | 3820 | |
| 3480 | - if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource = true; |
|
| 3481 | - elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $deletetarget = true; |
|
| 3821 | + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3822 | + $deletesource = true; |
|
| 3823 | + } elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) { |
|
| 3824 | + $deletetarget = true; |
|
| 3825 | + } |
|
| 3482 | 3826 | |
| 3483 | 3827 | $sourceid = (!empty($sourceid) ? $sourceid : $this->id); |
| 3484 | 3828 | $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); |
@@ -3538,18 +3882,34 @@ discard block |
||
| 3538 | 3882 | $this->db->begin(); |
| 3539 | 3883 | |
| 3540 | 3884 | $fieldstatus = "fk_statut"; |
| 3541 | - if ($elementTable == 'facture_rec') $fieldstatus = "suspended"; |
|
| 3542 | - if ($elementTable == 'mailing') $fieldstatus = "statut"; |
|
| 3543 | - if ($elementTable == 'cronjob') $fieldstatus = "status"; |
|
| 3544 | - if ($elementTable == 'user') $fieldstatus = "statut"; |
|
| 3545 | - if ($elementTable == 'expensereport') $fieldstatus = "fk_statut"; |
|
| 3546 | - if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus = "status"; |
|
| 3547 | - if (is_array($this->fields) && array_key_exists('status', $this->fields)) $fieldstatus = 'status'; |
|
| 3885 | + if ($elementTable == 'facture_rec') { |
|
| 3886 | + $fieldstatus = "suspended"; |
|
| 3887 | + } |
|
| 3888 | + if ($elementTable == 'mailing') { |
|
| 3889 | + $fieldstatus = "statut"; |
|
| 3890 | + } |
|
| 3891 | + if ($elementTable == 'cronjob') { |
|
| 3892 | + $fieldstatus = "status"; |
|
| 3893 | + } |
|
| 3894 | + if ($elementTable == 'user') { |
|
| 3895 | + $fieldstatus = "statut"; |
|
| 3896 | + } |
|
| 3897 | + if ($elementTable == 'expensereport') { |
|
| 3898 | + $fieldstatus = "fk_statut"; |
|
| 3899 | + } |
|
| 3900 | + if ($elementTable == 'commande_fournisseur_dispatch') { |
|
| 3901 | + $fieldstatus = "status"; |
|
| 3902 | + } |
|
| 3903 | + if (is_array($this->fields) && array_key_exists('status', $this->fields)) { |
|
| 3904 | + $fieldstatus = 'status'; |
|
| 3905 | + } |
|
| 3548 | 3906 | |
| 3549 | 3907 | $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; |
| 3550 | 3908 | $sql .= " SET ".$fieldstatus." = ".$status; |
| 3551 | 3909 | // If status = 1 = validated, update also fk_user_valid |
| 3552 | - if ($status == 1 && $elementTable == 'expensereport') $sql .= ", fk_user_valid = ".$user->id; |
|
| 3910 | + if ($status == 1 && $elementTable == 'expensereport') { |
|
| 3911 | + $sql .= ", fk_user_valid = ".$user->id; |
|
| 3912 | + } |
|
| 3553 | 3913 | $sql .= " WHERE rowid=".$elementId; |
| 3554 | 3914 | |
| 3555 | 3915 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); |
@@ -3560,19 +3920,36 @@ discard block |
||
| 3560 | 3920 | // Try autoset of trigkey |
| 3561 | 3921 | if (empty($trigkey)) |
| 3562 | 3922 | { |
| 3563 | - if ($this->element == 'supplier_proposal' && $status == 2) $trigkey = 'SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3564 | - if ($this->element == 'supplier_proposal' && $status == 3) $trigkey = 'SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3565 | - if ($this->element == 'supplier_proposal' && $status == 4) $trigkey = 'SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3566 | - if ($this->element == 'fichinter' && $status == 3) $trigkey = 'FICHINTER_CLASSIFY_DONE'; |
|
| 3567 | - if ($this->element == 'fichinter' && $status == 2) $trigkey = 'FICHINTER_CLASSIFY_BILLED'; |
|
| 3568 | - if ($this->element == 'fichinter' && $status == 1) $trigkey = 'FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3923 | + if ($this->element == 'supplier_proposal' && $status == 2) { |
|
| 3924 | + $trigkey = 'SUPPLIER_PROPOSAL_SIGN'; |
|
| 3925 | + } |
|
| 3926 | + // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3927 | + if ($this->element == 'supplier_proposal' && $status == 3) { |
|
| 3928 | + $trigkey = 'SUPPLIER_PROPOSAL_REFUSE'; |
|
| 3929 | + } |
|
| 3930 | + // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3931 | + if ($this->element == 'supplier_proposal' && $status == 4) { |
|
| 3932 | + $trigkey = 'SUPPLIER_PROPOSAL_CLOSE'; |
|
| 3933 | + } |
|
| 3934 | + // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3935 | + if ($this->element == 'fichinter' && $status == 3) { |
|
| 3936 | + $trigkey = 'FICHINTER_CLASSIFY_DONE'; |
|
| 3937 | + } |
|
| 3938 | + if ($this->element == 'fichinter' && $status == 2) { |
|
| 3939 | + $trigkey = 'FICHINTER_CLASSIFY_BILLED'; |
|
| 3940 | + } |
|
| 3941 | + if ($this->element == 'fichinter' && $status == 1) { |
|
| 3942 | + $trigkey = 'FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3943 | + } |
|
| 3569 | 3944 | } |
| 3570 | 3945 | |
| 3571 | 3946 | if ($trigkey) |
| 3572 | 3947 | { |
| 3573 | 3948 | // Call trigger |
| 3574 | 3949 | $result = $this->call_trigger($trigkey, $user); |
| 3575 | - if ($result < 0) $error++; |
|
| 3950 | + if ($result < 0) { |
|
| 3951 | + $error++; |
|
| 3952 | + } |
|
| 3576 | 3953 | // End call triggers |
| 3577 | 3954 | } |
| 3578 | 3955 | |
@@ -3580,9 +3957,11 @@ discard block |
||
| 3580 | 3957 | { |
| 3581 | 3958 | $this->db->commit(); |
| 3582 | 3959 | |
| 3583 | - if (empty($savElementId)) // If the element we update was $this (so $elementId is null) |
|
| 3960 | + if (empty($savElementId)) { |
|
| 3961 | + // If the element we update was $this (so $elementId is null) |
|
| 3584 | 3962 | { |
| 3585 | 3963 | $this->statut = $status; |
| 3964 | + } |
|
| 3586 | 3965 | $this->status = $status; |
| 3587 | 3966 | } |
| 3588 | 3967 | |
@@ -3611,8 +3990,13 @@ discard block |
||
| 3611 | 3990 | { |
| 3612 | 3991 | global $conf; |
| 3613 | 3992 | |
| 3614 | - if (empty($id) && empty($ref)) return 0; |
|
| 3615 | - if (!empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default. |
|
| 3993 | + if (empty($id) && empty($ref)) { |
|
| 3994 | + return 0; |
|
| 3995 | + } |
|
| 3996 | + if (!empty($conf->global->MAIN_DISABLE_CANVAS)) { |
|
| 3997 | + return 0; |
|
| 3998 | + } |
|
| 3999 | + // To increase speed. Not enabled by default. |
|
| 3616 | 4000 | |
| 3617 | 4001 | // Clean parameters |
| 3618 | 4002 | $ref = trim($ref); |
@@ -3620,8 +4004,12 @@ discard block |
||
| 3620 | 4004 | $sql = "SELECT rowid, canvas"; |
| 3621 | 4005 | $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
| 3622 | 4006 | $sql .= " WHERE entity IN (".getEntity($this->element).")"; |
| 3623 | - if (!empty($id)) $sql .= " AND rowid = ".$id; |
|
| 3624 | - if (!empty($ref)) $sql .= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 4007 | + if (!empty($id)) { |
|
| 4008 | + $sql .= " AND rowid = ".$id; |
|
| 4009 | + } |
|
| 4010 | + if (!empty($ref)) { |
|
| 4011 | + $sql .= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 4012 | + } |
|
| 3625 | 4013 | |
| 3626 | 4014 | $resql = $this->db->query($sql); |
| 3627 | 4015 | if ($resql) |
@@ -3631,7 +4019,9 @@ discard block |
||
| 3631 | 4019 | { |
| 3632 | 4020 | $this->canvas = $obj->canvas; |
| 3633 | 4021 | return 1; |
| 3634 | - } else return 0; |
|
| 4022 | + } else { |
|
| 4023 | + return 0; |
|
| 4024 | + } |
|
| 3635 | 4025 | } else { |
| 3636 | 4026 | dol_print_error($this->db); |
| 3637 | 4027 | return -1; |
@@ -3668,7 +4058,9 @@ discard block |
||
| 3668 | 4058 | { |
| 3669 | 4059 | global $langs; |
| 3670 | 4060 | |
| 3671 | - if (empty($id)) $id = $this->id; |
|
| 4061 | + if (empty($id)) { |
|
| 4062 | + $id = $this->id; |
|
| 4063 | + } |
|
| 3672 | 4064 | |
| 3673 | 4065 | // Check parameters |
| 3674 | 4066 | if (!isset($this->childtables) || !is_array($this->childtables) || count($this->childtables) == 0) |
@@ -3702,9 +4094,11 @@ discard block |
||
| 3702 | 4094 | $langs->load("errors"); |
| 3703 | 4095 | //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; |
| 3704 | 4096 | $haschild += $obj->nb; |
| 3705 | - if (is_numeric($elementname)) // old usage |
|
| 4097 | + if (is_numeric($elementname)) { |
|
| 4098 | + // old usage |
|
| 3706 | 4099 | { |
| 3707 | 4100 | $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); |
| 4101 | + } |
|
| 3708 | 4102 | } else // new usage: $elementname=Translation key |
| 3709 | 4103 | { |
| 3710 | 4104 | $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); |
@@ -3720,7 +4114,9 @@ discard block |
||
| 3720 | 4114 | { |
| 3721 | 4115 | $this->errors[] = "ErrorRecordHasChildren"; |
| 3722 | 4116 | return $haschild; |
| 3723 | - } else return 0; |
|
| 4117 | + } else { |
|
| 4118 | + return 0; |
|
| 4119 | + } |
|
| 3724 | 4120 | } |
| 3725 | 4121 | |
| 3726 | 4122 | /** |
@@ -3736,12 +4132,24 @@ discard block |
||
| 3736 | 4132 | foreach ($this->lines as $key => $val) |
| 3737 | 4133 | { |
| 3738 | 4134 | $qualified = 0; |
| 3739 | - if ($predefined == -1) $qualified = 1; |
|
| 3740 | - if ($predefined == 1 && $val->fk_product > 0) $qualified = 1; |
|
| 3741 | - if ($predefined == 0 && $val->fk_product <= 0) $qualified = 1; |
|
| 3742 | - if ($predefined == 2 && $val->fk_product > 0 && $val->product_type == 0) $qualified = 1; |
|
| 3743 | - if ($predefined == 3 && $val->fk_product > 0 && $val->product_type == 1) $qualified = 1; |
|
| 3744 | - if ($qualified) $nb++; |
|
| 4135 | + if ($predefined == -1) { |
|
| 4136 | + $qualified = 1; |
|
| 4137 | + } |
|
| 4138 | + if ($predefined == 1 && $val->fk_product > 0) { |
|
| 4139 | + $qualified = 1; |
|
| 4140 | + } |
|
| 4141 | + if ($predefined == 0 && $val->fk_product <= 0) { |
|
| 4142 | + $qualified = 1; |
|
| 4143 | + } |
|
| 4144 | + if ($predefined == 2 && $val->fk_product > 0 && $val->product_type == 0) { |
|
| 4145 | + $qualified = 1; |
|
| 4146 | + } |
|
| 4147 | + if ($predefined == 3 && $val->fk_product > 0 && $val->product_type == 1) { |
|
| 4148 | + $qualified = 1; |
|
| 4149 | + } |
|
| 4150 | + if ($qualified) { |
|
| 4151 | + $nb++; |
|
| 4152 | + } |
|
| 3745 | 4153 | } |
| 3746 | 4154 | dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); |
| 3747 | 4155 | return $nb; |
@@ -3805,16 +4213,24 @@ discard block |
||
| 3805 | 4213 | { |
| 3806 | 4214 | if (isset($line->qty_asked)) |
| 3807 | 4215 | { |
| 3808 | - if (empty($totalOrdered)) $totalOrdered = 0; // Avoid warning because $totalOrdered is '' |
|
| 4216 | + if (empty($totalOrdered)) { |
|
| 4217 | + $totalOrdered = 0; |
|
| 4218 | + } |
|
| 4219 | + // Avoid warning because $totalOrdered is '' |
|
| 3809 | 4220 | $totalOrdered += $line->qty_asked; // defined for shipment only |
| 3810 | 4221 | } |
| 3811 | 4222 | if (isset($line->qty_shipped)) |
| 3812 | 4223 | { |
| 3813 | - if (empty($totalToShip)) $totalToShip = 0; // Avoid warning because $totalToShip is '' |
|
| 4224 | + if (empty($totalToShip)) { |
|
| 4225 | + $totalToShip = 0; |
|
| 4226 | + } |
|
| 4227 | + // Avoid warning because $totalToShip is '' |
|
| 3814 | 4228 | $totalToShip += $line->qty_shipped; // defined for shipment only |
| 3815 | 4229 | } elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
| 3816 | 4230 | { |
| 3817 | - if (empty($totalToShip)) $totalToShip = 0; |
|
| 4231 | + if (empty($totalToShip)) { |
|
| 4232 | + $totalToShip = 0; |
|
| 4233 | + } |
|
| 3818 | 4234 | $totalToShip += $line->qty; // defined for reception only |
| 3819 | 4235 | } |
| 3820 | 4236 | |
@@ -3838,16 +4254,28 @@ discard block |
||
| 3838 | 4254 | |
| 3839 | 4255 | $weightUnit = 0; |
| 3840 | 4256 | $volumeUnit = 0; |
| 3841 | - if (!empty($weight_units)) $weightUnit = $weight_units; |
|
| 3842 | - if (!empty($volume_units)) $volumeUnit = $volume_units; |
|
| 4257 | + if (!empty($weight_units)) { |
|
| 4258 | + $weightUnit = $weight_units; |
|
| 4259 | + } |
|
| 4260 | + if (!empty($volume_units)) { |
|
| 4261 | + $volumeUnit = $volume_units; |
|
| 4262 | + } |
|
| 3843 | 4263 | |
| 3844 | - if (empty($totalWeight)) $totalWeight = 0; // Avoid warning because $totalWeight is '' |
|
| 3845 | - if (empty($totalVolume)) $totalVolume = 0; // Avoid warning because $totalVolume is '' |
|
| 4264 | + if (empty($totalWeight)) { |
|
| 4265 | + $totalWeight = 0; |
|
| 4266 | + } |
|
| 4267 | + // Avoid warning because $totalWeight is '' |
|
| 4268 | + if (empty($totalVolume)) { |
|
| 4269 | + $totalVolume = 0; |
|
| 4270 | + } |
|
| 4271 | + // Avoid warning because $totalVolume is '' |
|
| 3846 | 4272 | |
| 3847 | 4273 | //var_dump($line->volume_units); |
| 3848 | - if ($weight_units < 50) // < 50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 4274 | + if ($weight_units < 50) { |
|
| 4275 | + // < 50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3849 | 4276 | { |
| 3850 | 4277 | $trueWeightUnit = pow(10, $weightUnit); |
| 4278 | + } |
|
| 3851 | 4279 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3852 | 4280 | } else { |
| 3853 | 4281 | if ($weight_units == 99) { |
@@ -3862,10 +4290,12 @@ discard block |
||
| 3862 | 4290 | $totalWeight += $weight * $qty; // This may be wrong if we mix different units |
| 3863 | 4291 | } |
| 3864 | 4292 | } |
| 3865 | - if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 4293 | + if ($volume_units < 50) { |
|
| 4294 | + // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3866 | 4295 | { |
| 3867 | 4296 | //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; |
| 3868 | 4297 | $trueVolumeUnit = pow(10, $volumeUnit); |
| 4298 | + } |
|
| 3869 | 4299 | //print $line->volume; |
| 3870 | 4300 | $totalVolume += $volume * $qty * $trueVolumeUnit; |
| 3871 | 4301 | } else { |
@@ -3952,7 +4382,9 @@ discard block |
||
| 3952 | 4382 | } else { |
| 3953 | 4383 | $res = include $tpl; // for debug |
| 3954 | 4384 | } |
| 3955 | - if ($res) break; |
|
| 4385 | + if ($res) { |
|
| 4386 | + break; |
|
| 4387 | + } |
|
| 3956 | 4388 | } |
| 3957 | 4389 | } |
| 3958 | 4390 | |
@@ -3983,7 +4415,9 @@ discard block |
||
| 3983 | 4415 | |
| 3984 | 4416 | // Define usemargins |
| 3985 | 4417 | $usemargins = 0; |
| 3986 | - if (!empty($conf->margin->enabled) && !empty($this->element) && in_array($this->element, array('facture', 'facturerec', 'propal', 'commande'))) $usemargins = 1; |
|
| 4418 | + if (!empty($conf->margin->enabled) && !empty($this->element) && in_array($this->element, array('facture', 'facturerec', 'propal', 'commande'))) { |
|
| 4419 | + $usemargins = 1; |
|
| 4420 | + } |
|
| 3987 | 4421 | |
| 3988 | 4422 | $num = count($this->lines); |
| 3989 | 4423 | |
@@ -4016,7 +4450,9 @@ discard block |
||
| 4016 | 4450 | } else { |
| 4017 | 4451 | $res = include $tpl; // for debug |
| 4018 | 4452 | } |
| 4019 | - if ($res) break; |
|
| 4453 | + if ($res) { |
|
| 4454 | + break; |
|
| 4455 | + } |
|
| 4020 | 4456 | } |
| 4021 | 4457 | } |
| 4022 | 4458 | |
@@ -4029,11 +4465,13 @@ discard block |
||
| 4029 | 4465 | $line->fetch_optionals(); |
| 4030 | 4466 | |
| 4031 | 4467 | //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) |
| 4032 | - if (is_object($hookmanager)) // Old code is commented on preceding line. |
|
| 4468 | + if (is_object($hookmanager)) { |
|
| 4469 | + // Old code is commented on preceding line. |
|
| 4033 | 4470 | { |
| 4034 | 4471 | if (empty($line->fk_parent_line)) |
| 4035 | 4472 | { |
| 4036 | 4473 | $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element); |
| 4474 | + } |
|
| 4037 | 4475 | $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 4038 | 4476 | } else { |
| 4039 | 4477 | $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); |
@@ -4107,8 +4545,13 @@ discard block |
||
| 4107 | 4545 | |
| 4108 | 4546 | $outputlangs = $langs; |
| 4109 | 4547 | $newlang = ''; |
| 4110 | - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 4111 | - if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) $newlang = $this->thirdparty->default_lang; // To use language of customer |
|
| 4548 | + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
|
| 4549 | + $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 4550 | + } |
|
| 4551 | + if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) { |
|
| 4552 | + $newlang = $this->thirdparty->default_lang; |
|
| 4553 | + } |
|
| 4554 | + // To use language of customer |
|
| 4112 | 4555 | if (!empty($newlang)) |
| 4113 | 4556 | { |
| 4114 | 4557 | $outputlangs = new Translate("", $conf); |
@@ -4144,7 +4587,9 @@ discard block |
||
| 4144 | 4587 | } else { |
| 4145 | 4588 | $res = include $tpl; // for debug |
| 4146 | 4589 | } |
| 4147 | - if ($res) break; |
|
| 4590 | + if ($res) { |
|
| 4591 | + break; |
|
| 4592 | + } |
|
| 4148 | 4593 | } |
| 4149 | 4594 | } |
| 4150 | 4595 | |
@@ -4173,7 +4618,9 @@ discard block |
||
| 4173 | 4618 | } else { |
| 4174 | 4619 | $res = include $tpl; // for debug |
| 4175 | 4620 | } |
| 4176 | - if ($res) break; |
|
| 4621 | + if ($res) { |
|
| 4622 | + break; |
|
| 4623 | + } |
|
| 4177 | 4624 | } |
| 4178 | 4625 | } |
| 4179 | 4626 | } |
@@ -4201,7 +4648,9 @@ discard block |
||
| 4201 | 4648 | print '<td>'.$langs->trans('Description').'</td>'; |
| 4202 | 4649 | print '<td class="right">'.$langs->trans('VATRate').'</td>'; |
| 4203 | 4650 | print '<td class="right">'.$langs->trans('PriceUHT').'</td>'; |
| 4204 | - if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
|
| 4651 | + if (!empty($conf->multicurrency->enabled)) { |
|
| 4652 | + print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
|
| 4653 | + } |
|
| 4205 | 4654 | print '<td class="right">'.$langs->trans('Qty').'</td>'; |
| 4206 | 4655 | if ($conf->global->PRODUCT_USE_UNITS) |
| 4207 | 4656 | { |
@@ -4256,24 +4705,32 @@ discard block |
||
| 4256 | 4705 | $date_start = $line->date_start; |
| 4257 | 4706 | } else { |
| 4258 | 4707 | $date_start = $line->date_debut_prevue; |
| 4259 | - if ($line->date_debut_reel) $date_start = $line->date_debut_reel; |
|
| 4708 | + if ($line->date_debut_reel) { |
|
| 4709 | + $date_start = $line->date_debut_reel; |
|
| 4710 | + } |
|
| 4260 | 4711 | } |
| 4261 | 4712 | if (!empty($line->date_end)) |
| 4262 | 4713 | { |
| 4263 | 4714 | $date_end = $line->date_end; |
| 4264 | 4715 | } else { |
| 4265 | 4716 | $date_end = $line->date_fin_prevue; |
| 4266 | - if ($line->date_fin_reel) $date_end = $line->date_fin_reel; |
|
| 4717 | + if ($line->date_fin_reel) { |
|
| 4718 | + $date_end = $line->date_fin_reel; |
|
| 4719 | + } |
|
| 4267 | 4720 | } |
| 4268 | 4721 | |
| 4269 | 4722 | $this->tpl['id'] = $line->id; |
| 4270 | 4723 | |
| 4271 | 4724 | $this->tpl['label'] = ''; |
| 4272 | - if (!empty($line->fk_parent_line)) $this->tpl['label'] .= img_picto('', 'rightarrow'); |
|
| 4725 | + if (!empty($line->fk_parent_line)) { |
|
| 4726 | + $this->tpl['label'] .= img_picto('', 'rightarrow'); |
|
| 4727 | + } |
|
| 4273 | 4728 | |
| 4274 | - if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object |
|
| 4729 | + if (($line->info_bits & 2) == 2) { |
|
| 4730 | + // TODO Not sure this is used for source object |
|
| 4275 | 4731 | { |
| 4276 | 4732 | $discount = new DiscountAbsolute($this->db); |
| 4733 | + } |
|
| 4277 | 4734 | $discount->fk_soc = $this->socid; |
| 4278 | 4735 | $this->tpl['label'] .= $discount->getNomUrl(0, 'discount'); |
| 4279 | 4736 | } elseif (!empty($line->fk_product)) |
@@ -4311,14 +4768,18 @@ discard block |
||
| 4311 | 4768 | |
| 4312 | 4769 | if (!empty($line->desc)) |
| 4313 | 4770 | { |
| 4314 | - if ($line->desc == '(CREDIT_NOTE)') // TODO Not sure this is used for source object |
|
| 4771 | + if ($line->desc == '(CREDIT_NOTE)') { |
|
| 4772 | + // TODO Not sure this is used for source object |
|
| 4315 | 4773 | { |
| 4316 | 4774 | $discount = new DiscountAbsolute($this->db); |
| 4775 | + } |
|
| 4317 | 4776 | $discount->fetch($line->fk_remise_except); |
| 4318 | 4777 | $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); |
| 4319 | - } elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object |
|
| 4778 | + } elseif ($line->desc == '(DEPOSIT)') { |
|
| 4779 | + // TODO Not sure this is used for source object |
|
| 4320 | 4780 | { |
| 4321 | 4781 | $discount = new DiscountAbsolute($this->db); |
| 4782 | + } |
|
| 4322 | 4783 | $discount->fetch($line->fk_remise_except); |
| 4323 | 4784 | $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); |
| 4324 | 4785 | } elseif ($line->desc == '(EXCESS RECEIVED)') |
@@ -4341,17 +4802,23 @@ discard block |
||
| 4341 | 4802 | // VAT Rate |
| 4342 | 4803 | $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); |
| 4343 | 4804 | $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; |
| 4344 | - if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; |
|
| 4805 | + if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) { |
|
| 4806 | + $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; |
|
| 4807 | + } |
|
| 4345 | 4808 | |
| 4346 | 4809 | $this->tpl['price'] = price($line->subprice); |
| 4347 | 4810 | $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); |
| 4348 | 4811 | $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; |
| 4349 | - if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); |
|
| 4812 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 4813 | + $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); |
|
| 4814 | + } |
|
| 4350 | 4815 | $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; |
| 4351 | 4816 | |
| 4352 | 4817 | // Is the line strike or not |
| 4353 | 4818 | $this->tpl['strike'] = 0; |
| 4354 | - if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike'] = 1; |
|
| 4819 | + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) { |
|
| 4820 | + $this->tpl['strike'] = 1; |
|
| 4821 | + } |
|
| 4355 | 4822 | |
| 4356 | 4823 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4357 | 4824 | // Use global variables + $dateSelector + $seller and $buyer |
@@ -4370,7 +4837,9 @@ discard block |
||
| 4370 | 4837 | } else { |
| 4371 | 4838 | $res = include $tpl; // for debug |
| 4372 | 4839 | } |
| 4373 | - if ($res) break; |
|
| 4840 | + if ($res) { |
|
| 4841 | + break; |
|
| 4842 | + } |
|
| 4374 | 4843 | } |
| 4375 | 4844 | } |
| 4376 | 4845 | |
@@ -4521,13 +4990,20 @@ discard block |
||
| 4521 | 4990 | $classname = ''; |
| 4522 | 4991 | $filefound = ''; |
| 4523 | 4992 | $dirmodels = array('/'); |
| 4524 | - if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 4993 | + if (is_array($conf->modules_parts['models'])) { |
|
| 4994 | + $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 4995 | + } |
|
| 4525 | 4996 | foreach ($dirmodels as $reldir) |
| 4526 | 4997 | { |
| 4527 | 4998 | foreach (array('doc', 'pdf') as $prefix) |
| 4528 | 4999 | { |
| 4529 | - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php |
|
| 4530 | - else $file = $prefix."_".$modele.".modules.php"; |
|
| 5000 | + if (in_array(get_class($this), array('Adherent'))) { |
|
| 5001 | + $file = $prefix."_".$modele.".class.php"; |
|
| 5002 | + } |
|
| 5003 | + // Member module use prefix_module.class.php |
|
| 5004 | + else { |
|
| 5005 | + $file = $prefix."_".$modele.".modules.php"; |
|
| 5006 | + } |
|
| 4531 | 5007 | |
| 4532 | 5008 | // On verifie l'emplacement du modele |
| 4533 | 5009 | $file = dol_buildpath($reldir.$modelspath.$file, 0); |
@@ -4538,7 +5014,9 @@ discard block |
||
| 4538 | 5014 | break; |
| 4539 | 5015 | } |
| 4540 | 5016 | } |
| 4541 | - if ($filefound) break; |
|
| 5017 | + if ($filefound) { |
|
| 5018 | + break; |
|
| 5019 | + } |
|
| 4542 | 5020 | } |
| 4543 | 5021 | |
| 4544 | 5022 | // If generator was found |
@@ -4570,7 +5048,9 @@ discard block |
||
| 4570 | 5048 | if (is_dir($tmpdir)) |
| 4571 | 5049 | { |
| 4572 | 5050 | $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); |
| 4573 | - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
| 5051 | + if (count($tmpfiles)) { |
|
| 5052 | + $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
| 5053 | + } |
|
| 4574 | 5054 | } |
| 4575 | 5055 | } |
| 4576 | 5056 | |
@@ -4630,9 +5110,11 @@ discard block |
||
| 4630 | 5110 | $destfile = basename($destfull); |
| 4631 | 5111 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); |
| 4632 | 5112 | |
| 4633 | - if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
| 5113 | + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) { |
|
| 5114 | + // If not a tmp dir |
|
| 4634 | 5115 | { |
| 4635 | 5116 | $filename = basename($destfile); |
| 5117 | + } |
|
| 4636 | 5118 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
| 4637 | 5119 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
| 4638 | 5120 | |
@@ -4645,8 +5127,12 @@ discard block |
||
| 4645 | 5127 | if ($this->element == 'propal') |
| 4646 | 5128 | { |
| 4647 | 5129 | $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok |
| 4648 | - if ($useonlinesignature) $setsharekey = true; |
|
| 4649 | - if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; |
|
| 5130 | + if ($useonlinesignature) { |
|
| 5131 | + $setsharekey = true; |
|
| 5132 | + } |
|
| 5133 | + if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 5134 | + $setsharekey = true; |
|
| 5135 | + } |
|
| 4650 | 5136 | } |
| 4651 | 5137 | if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { |
| 4652 | 5138 | $setsharekey = true; |
@@ -4659,9 +5145,11 @@ discard block |
||
| 4659 | 5145 | } |
| 4660 | 5146 | |
| 4661 | 5147 | if ($setsharekey) { |
| 4662 | - if (empty($ecmfile->share)) // Because object not found or share not set yet |
|
| 5148 | + if (empty($ecmfile->share)) { |
|
| 5149 | + // Because object not found or share not set yet |
|
| 4663 | 5150 | { |
| 4664 | 5151 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 5152 | + } |
|
| 4665 | 5153 | $ecmfile->share = getRandomPassword(true); |
| 4666 | 5154 | } |
| 4667 | 5155 | } |
@@ -4702,7 +5190,9 @@ discard block |
||
| 4702 | 5190 | |
| 4703 | 5191 | // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) |
| 4704 | 5192 | $update_main_doc_field = 0; |
| 4705 | - if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; |
|
| 5193 | + if (!empty($obj->update_main_doc_field)) { |
|
| 5194 | + $update_main_doc_field = 1; |
|
| 5195 | + } |
|
| 4706 | 5196 | if ($update_main_doc_field && !empty($this->table_element)) |
| 4707 | 5197 | { |
| 4708 | 5198 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; |
@@ -4739,7 +5229,9 @@ discard block |
||
| 4739 | 5229 | } |
| 4740 | 5230 | return -1; |
| 4741 | 5231 | } |
| 4742 | - } else return $reshook; |
|
| 5232 | + } else { |
|
| 5233 | + return $reshook; |
|
| 5234 | + } |
|
| 4743 | 5235 | } |
| 4744 | 5236 | |
| 4745 | 5237 | /** |
@@ -4790,13 +5282,21 @@ discard block |
||
| 4790 | 5282 | global $conf, $_POST; |
| 4791 | 5283 | |
| 4792 | 5284 | // If param here has been posted, we use this value first. |
| 4793 | - if (GETPOSTISSET($fieldname)) return GETPOST($fieldname, 'alphanohtml', 3); |
|
| 5285 | + if (GETPOSTISSET($fieldname)) { |
|
| 5286 | + return GETPOST($fieldname, 'alphanohtml', 3); |
|
| 5287 | + } |
|
| 4794 | 5288 | |
| 4795 | - if (isset($alternatevalue)) return $alternatevalue; |
|
| 5289 | + if (isset($alternatevalue)) { |
|
| 5290 | + return $alternatevalue; |
|
| 5291 | + } |
|
| 4796 | 5292 | |
| 4797 | 5293 | $newelement = $this->element; |
| 4798 | - if ($newelement == 'facture') $newelement = 'invoice'; |
|
| 4799 | - if ($newelement == 'commande') $newelement = 'order'; |
|
| 5294 | + if ($newelement == 'facture') { |
|
| 5295 | + $newelement = 'invoice'; |
|
| 5296 | + } |
|
| 5297 | + if ($newelement == 'commande') { |
|
| 5298 | + $newelement = 'order'; |
|
| 5299 | + } |
|
| 4800 | 5300 | if (empty($newelement)) |
| 4801 | 5301 | { |
| 4802 | 5302 | dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING); |
@@ -4805,7 +5305,9 @@ discard block |
||
| 4805 | 5305 | |
| 4806 | 5306 | $keyforfieldname = strtoupper($newelement.'_DEFAULT_'.$fieldname); |
| 4807 | 5307 | //var_dump($keyforfieldname); |
| 4808 | - if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; |
|
| 5308 | + if (isset($conf->global->$keyforfieldname)) { |
|
| 5309 | + return $conf->global->$keyforfieldname; |
|
| 5310 | + } |
|
| 4809 | 5311 | |
| 4810 | 5312 | // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname |
| 4811 | 5313 | } |
@@ -4878,7 +5380,10 @@ discard block |
||
| 4878 | 5380 | $this->array_languages = array(); |
| 4879 | 5381 | |
| 4880 | 5382 | $element = $this->element; |
| 4881 | - if ($element == 'categorie') $element = 'categories'; // For compatibility |
|
| 5383 | + if ($element == 'categorie') { |
|
| 5384 | + $element = 'categories'; |
|
| 5385 | + } |
|
| 5386 | + // For compatibility |
|
| 4882 | 5387 | |
| 4883 | 5388 | // Request to get translation values for object |
| 4884 | 5389 | $sql = "SELECT rowid, property, lang , value"; |
@@ -4915,8 +5420,11 @@ discard block |
||
| 4915 | 5420 | |
| 4916 | 5421 | $this->db->free($resql); |
| 4917 | 5422 | |
| 4918 | - if ($numrows) return $numrows; |
|
| 4919 | - else return 0; |
|
| 5423 | + if ($numrows) { |
|
| 5424 | + return $numrows; |
|
| 5425 | + } else { |
|
| 5426 | + return 0; |
|
| 5427 | + } |
|
| 4920 | 5428 | } else { |
| 4921 | 5429 | dol_print_error($this->db); |
| 4922 | 5430 | return -1; |
@@ -4936,15 +5444,21 @@ discard block |
||
| 4936 | 5444 | // Get extra fields |
| 4937 | 5445 | foreach ($_POST as $postfieldkey => $postfieldvalue) { |
| 4938 | 5446 | $tmparray = explode('-', $postfieldkey); |
| 4939 | - if ($tmparray[0] != 'field') continue; |
|
| 5447 | + if ($tmparray[0] != 'field') { |
|
| 5448 | + continue; |
|
| 5449 | + } |
|
| 4940 | 5450 | |
| 4941 | 5451 | $element = $tmparray[1]; |
| 4942 | 5452 | $key = $tmparray[2]; |
| 4943 | 5453 | $codelang = $tmparray[3]; |
| 4944 | 5454 | //var_dump("postfieldkey=".$postfieldkey." element=".$element." key=".$key." codelang=".$codelang); |
| 4945 | 5455 | |
| 4946 | - if (!empty($onlykey) && $key != $onlykey) continue; |
|
| 4947 | - if ($element != $this->element) continue; |
|
| 5456 | + if (!empty($onlykey) && $key != $onlykey) { |
|
| 5457 | + continue; |
|
| 5458 | + } |
|
| 5459 | + if ($element != $this->element) { |
|
| 5460 | + continue; |
|
| 5461 | + } |
|
| 4948 | 5462 | |
| 4949 | 5463 | $key_type = $this->fields[$key]['type']; |
| 4950 | 5464 | |
@@ -4958,7 +5472,9 @@ discard block |
||
| 4958 | 5472 | { |
| 4959 | 5473 | $perms = dol_eval($this->fields[$key]['perms'], 1); |
| 4960 | 5474 | }*/ |
| 4961 | - if (empty($enabled)) continue; |
|
| 5475 | + if (empty($enabled)) { |
|
| 5476 | + continue; |
|
| 5477 | + } |
|
| 4962 | 5478 | //if (empty($perms)) continue; |
| 4963 | 5479 | |
| 4964 | 5480 | if (in_array($key_type, array('date'))) |
@@ -4985,7 +5501,9 @@ discard block |
||
| 4985 | 5501 | $value_key = price2num($value_arr); |
| 4986 | 5502 | } else { |
| 4987 | 5503 | $value_key = GETPOST($postfieldkey); |
| 4988 | - if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; |
|
| 5504 | + if (in_array($key_type, array('link')) && $value_key == '-1') { |
|
| 5505 | + $value_key = ''; |
|
| 5506 | + } |
|
| 4989 | 5507 | } |
| 4990 | 5508 | |
| 4991 | 5509 | $this->array_languages[$key][$codelang] = $value_key; |
@@ -5038,8 +5556,12 @@ discard block |
||
| 5038 | 5556 | // phpcs:enable |
| 5039 | 5557 | global $conf, $extrafields; |
| 5040 | 5558 | |
| 5041 | - if (empty($rowid)) $rowid = $this->id; |
|
| 5042 | - if (empty($rowid)) $rowid = $this->rowid; |
|
| 5559 | + if (empty($rowid)) { |
|
| 5560 | + $rowid = $this->id; |
|
| 5561 | + } |
|
| 5562 | + if (empty($rowid)) { |
|
| 5563 | + $rowid = $this->rowid; |
|
| 5564 | + } |
|
| 5043 | 5565 | |
| 5044 | 5566 | // To avoid SQL errors. Probably not the better solution though |
| 5045 | 5567 | if (!$this->table_element) { |
@@ -5069,7 +5591,10 @@ discard block |
||
| 5069 | 5591 | } |
| 5070 | 5592 | |
| 5071 | 5593 | $table_element = $this->table_element; |
| 5072 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5594 | + if ($table_element == 'categorie') { |
|
| 5595 | + $table_element = 'categories'; |
|
| 5596 | + } |
|
| 5597 | + // For compatibility |
|
| 5073 | 5598 | |
| 5074 | 5599 | // Request to get complementary values |
| 5075 | 5600 | if (is_array($optionsArray) && count($optionsArray) > 0) |
@@ -5126,8 +5651,11 @@ discard block |
||
| 5126 | 5651 | |
| 5127 | 5652 | $this->db->free($resql); |
| 5128 | 5653 | |
| 5129 | - if ($numrows) return $numrows; |
|
| 5130 | - else return 0; |
|
| 5654 | + if ($numrows) { |
|
| 5655 | + return $numrows; |
|
| 5656 | + } else { |
|
| 5657 | + return 0; |
|
| 5658 | + } |
|
| 5131 | 5659 | } else { |
| 5132 | 5660 | dol_print_error($this->db); |
| 5133 | 5661 | return -1; |
@@ -5146,12 +5674,17 @@ discard block |
||
| 5146 | 5674 | { |
| 5147 | 5675 | global $conf; |
| 5148 | 5676 | |
| 5149 | - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; |
|
| 5677 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5678 | + return 0; |
|
| 5679 | + } |
|
| 5150 | 5680 | |
| 5151 | 5681 | $this->db->begin(); |
| 5152 | 5682 | |
| 5153 | 5683 | $table_element = $this->table_element; |
| 5154 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5684 | + if ($table_element == 'categorie') { |
|
| 5685 | + $table_element = 'categories'; |
|
| 5686 | + } |
|
| 5687 | + // For compatibility |
|
| 5155 | 5688 | |
| 5156 | 5689 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; |
| 5157 | 5690 | dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); |
@@ -5181,9 +5714,13 @@ discard block |
||
| 5181 | 5714 | { |
| 5182 | 5715 | global $conf, $langs, $user; |
| 5183 | 5716 | |
| 5184 | - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; |
|
| 5717 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5718 | + return 0; |
|
| 5719 | + } |
|
| 5185 | 5720 | |
| 5186 | - if (empty($userused)) $userused = $user; |
|
| 5721 | + if (empty($userused)) { |
|
| 5722 | + $userused = $user; |
|
| 5723 | + } |
|
| 5187 | 5724 | |
| 5188 | 5725 | $error = 0; |
| 5189 | 5726 | |
@@ -5198,10 +5735,13 @@ discard block |
||
| 5198 | 5735 | //Eliminate copied source object extra_fields that do not exist in target object |
| 5199 | 5736 | $new_array_options = array(); |
| 5200 | 5737 | foreach ($this->array_options as $key => $value) { |
| 5201 | - if (in_array(substr($key, 8), array_keys($target_extrafields))) // We remove the 'options_' from $key for test |
|
| 5738 | + if (in_array(substr($key, 8), array_keys($target_extrafields))) { |
|
| 5739 | + // We remove the 'options_' from $key for test |
|
| 5202 | 5740 | $new_array_options[$key] = $value; |
| 5203 | - elseif (in_array($key, array_keys($target_extrafields))) // We test on $key that does not contains the 'options_' prefix |
|
| 5741 | + } elseif (in_array($key, array_keys($target_extrafields))) { |
|
| 5742 | + // We test on $key that does not contains the 'options_' prefix |
|
| 5204 | 5743 | $new_array_options['options_'.$key] = $value; |
| 5744 | + } |
|
| 5205 | 5745 | } |
| 5206 | 5746 | |
| 5207 | 5747 | foreach ($new_array_options as $key => $value) |
@@ -5216,8 +5756,12 @@ discard block |
||
| 5216 | 5756 | if ($attributeRequired) |
| 5217 | 5757 | { |
| 5218 | 5758 | $mandatorypb = false; |
| 5219 | - if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true; |
|
| 5220 | - if ($this->array_options[$key] === '') $mandatorypb = true; |
|
| 5759 | + if ($attributeType == 'link' && $this->array_options[$key] == '-1') { |
|
| 5760 | + $mandatorypb = true; |
|
| 5761 | + } |
|
| 5762 | + if ($this->array_options[$key] === '') { |
|
| 5763 | + $mandatorypb = true; |
|
| 5764 | + } |
|
| 5221 | 5765 | if ($mandatorypb) |
| 5222 | 5766 | { |
| 5223 | 5767 | dol_syslog("Mandatory extra field ".$key." is empty"); |
@@ -5286,12 +5830,15 @@ discard block |
||
| 5286 | 5830 | //global $action; // $action may be 'create', 'update', 'update_extras'... |
| 5287 | 5831 | //var_dump($action); |
| 5288 | 5832 | //var_dump($this->oldcopy);exit; |
| 5289 | - if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 5833 | + if (is_object($this->oldcopy)) { |
|
| 5834 | + // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 5290 | 5835 | { |
| 5291 | 5836 | //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); |
| 5292 | 5837 | if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
| 5293 | 5838 | { |
| 5294 | - $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5839 | + $new_array_options[$key] = $this->array_options[$key]; |
|
| 5840 | + } |
|
| 5841 | + // Value is kept |
|
| 5295 | 5842 | } else { |
| 5296 | 5843 | // var_dump($algo); |
| 5297 | 5844 | $newvalue = dol_hash($this->array_options[$key], $algo); |
@@ -5322,17 +5869,23 @@ discard block |
||
| 5322 | 5869 | dol_include_once($InfoFieldList[1]); |
| 5323 | 5870 | if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) |
| 5324 | 5871 | { |
| 5325 | - if ($value == '-1') // -1 is key for no defined in combo list of objects |
|
| 5872 | + if ($value == '-1') { |
|
| 5873 | + // -1 is key for no defined in combo list of objects |
|
| 5326 | 5874 | { |
| 5327 | 5875 | $new_array_options[$key] = ''; |
| 5876 | + } |
|
| 5328 | 5877 | } elseif ($value) |
| 5329 | 5878 | { |
| 5330 | 5879 | $object = new $InfoFieldList[0]($this->db); |
| 5331 | - if (is_numeric($value)) $res = $object->fetch($value); |
|
| 5332 | - else $res = $object->fetch('', $value); |
|
| 5880 | + if (is_numeric($value)) { |
|
| 5881 | + $res = $object->fetch($value); |
|
| 5882 | + } else { |
|
| 5883 | + $res = $object->fetch('', $value); |
|
| 5884 | + } |
|
| 5333 | 5885 | |
| 5334 | - if ($res > 0) $new_array_options[$key] = $object->id; |
|
| 5335 | - else { |
|
| 5886 | + if ($res > 0) { |
|
| 5887 | + $new_array_options[$key] = $object->id; |
|
| 5888 | + } else { |
|
| 5336 | 5889 | $this->error = "Id/Ref '".$value."' for object '".$object->element."' not found"; |
| 5337 | 5890 | $this->db->rollback(); |
| 5338 | 5891 | return -1; |
@@ -5348,7 +5901,10 @@ discard block |
||
| 5348 | 5901 | $this->db->begin(); |
| 5349 | 5902 | |
| 5350 | 5903 | $table_element = $this->table_element; |
| 5351 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5904 | + if ($table_element == 'categorie') { |
|
| 5905 | + $table_element = 'categories'; |
|
| 5906 | + } |
|
| 5907 | + // For compatibility |
|
| 5352 | 5908 | |
| 5353 | 5909 | dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG); |
| 5354 | 5910 | |
@@ -5360,18 +5916,22 @@ discard block |
||
| 5360 | 5916 | { |
| 5361 | 5917 | $attributeKey = substr($key, 8); // Remove 'options_' prefix |
| 5362 | 5918 | // Add field of attribut |
| 5363 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator |
|
| 5919 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5920 | + // Only for other type than separator |
|
| 5364 | 5921 | $sql .= ",".$attributeKey; |
| 5922 | + } |
|
| 5365 | 5923 | } |
| 5366 | 5924 | // We must insert a default value for fields for other entities that are mandatory to avoid not null error |
| 5367 | 5925 | if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) |
| 5368 | 5926 | { |
| 5369 | 5927 | foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
| 5370 | 5928 | { |
| 5371 | - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5929 | + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { |
|
| 5930 | + // If field not already added previously |
|
| 5372 | 5931 | { |
| 5373 | 5932 | $sql .= ",".$tmpkey; |
| 5374 | 5933 | } |
| 5934 | + } |
|
| 5375 | 5935 | } |
| 5376 | 5936 | } |
| 5377 | 5937 | $sql .= ") VALUES (".$this->id; |
@@ -5380,11 +5940,13 @@ discard block |
||
| 5380 | 5940 | { |
| 5381 | 5941 | $attributeKey = substr($key, 8); // Remove 'options_' prefix |
| 5382 | 5942 | // Add field of attribute |
| 5383 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) |
|
| 5943 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5944 | + // Only for other type than separator) |
|
| 5384 | 5945 | { |
| 5385 | 5946 | if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') |
| 5386 | 5947 | { |
| 5387 | 5948 | $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; |
| 5949 | + } |
|
| 5388 | 5950 | } else { |
| 5389 | 5951 | $sql .= ",null"; |
| 5390 | 5952 | } |
@@ -5395,10 +5957,13 @@ discard block |
||
| 5395 | 5957 | { |
| 5396 | 5958 | foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
| 5397 | 5959 | { |
| 5398 | - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5960 | + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { |
|
| 5961 | + // If field not already added previously |
|
| 5399 | 5962 | { |
| 5400 | 5963 | if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; |
| 5401 | - else $sql .= ", ''"; |
|
| 5964 | + } else { |
|
| 5965 | + $sql .= ", ''"; |
|
| 5966 | + } |
|
| 5402 | 5967 | } |
| 5403 | 5968 | } |
| 5404 | 5969 | } |
@@ -5418,7 +5983,9 @@ discard block |
||
| 5418 | 5983 | // Call trigger |
| 5419 | 5984 | $this->context = array('extrafieldaddupdate'=>1); |
| 5420 | 5985 | $result = $this->call_trigger($trigger, $userused); |
| 5421 | - if ($result < 0) $error++; |
|
| 5986 | + if ($result < 0) { |
|
| 5987 | + $error++; |
|
| 5988 | + } |
|
| 5422 | 5989 | // End call trigger |
| 5423 | 5990 | } |
| 5424 | 5991 | |
@@ -5430,7 +5997,9 @@ discard block |
||
| 5430 | 5997 | $this->db->commit(); |
| 5431 | 5998 | return 1; |
| 5432 | 5999 | } |
| 5433 | - } else return 0; |
|
| 6000 | + } else { |
|
| 6001 | + return 0; |
|
| 6002 | + } |
|
| 5434 | 6003 | } |
| 5435 | 6004 | |
| 5436 | 6005 | /** |
@@ -5447,11 +6016,16 @@ discard block |
||
| 5447 | 6016 | { |
| 5448 | 6017 | global $conf, $langs, $user; |
| 5449 | 6018 | |
| 5450 | - if (empty($userused)) $userused = $user; |
|
| 6019 | + if (empty($userused)) { |
|
| 6020 | + $userused = $user; |
|
| 6021 | + } |
|
| 5451 | 6022 | |
| 5452 | 6023 | $error = 0; |
| 5453 | 6024 | |
| 5454 | - if (!empty($conf->global->MAIN_EXTRALANGUAGES_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 6025 | + if (!empty($conf->global->MAIN_EXTRALANGUAGES_DISABLED)) { |
|
| 6026 | + return 0; |
|
| 6027 | + } |
|
| 6028 | + // For avoid conflicts if trigger used |
|
| 5455 | 6029 | |
| 5456 | 6030 | if (is_array($this->array_languages)) |
| 5457 | 6031 | { |
@@ -5504,7 +6078,10 @@ discard block |
||
| 5504 | 6078 | $this->db->begin(); |
| 5505 | 6079 | |
| 5506 | 6080 | $table_element = $this->table_element; |
| 5507 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 6081 | + if ($table_element == 'categorie') { |
|
| 6082 | + $table_element = 'categories'; |
|
| 6083 | + } |
|
| 6084 | + // For compatibility |
|
| 5508 | 6085 | |
| 5509 | 6086 | dol_syslog(get_class($this)."::insertExtraLanguages delete then insert", LOG_DEBUG); |
| 5510 | 6087 | |
@@ -5536,7 +6113,9 @@ discard block |
||
| 5536 | 6113 | // Call trigger |
| 5537 | 6114 | $this->context = array('extralanguagesaddupdate'=>1); |
| 5538 | 6115 | $result = $this->call_trigger($trigger, $userused); |
| 5539 | - if ($result < 0) $error++; |
|
| 6116 | + if ($result < 0) { |
|
| 6117 | + $error++; |
|
| 6118 | + } |
|
| 5540 | 6119 | // End call trigger |
| 5541 | 6120 | } |
| 5542 | 6121 | |
@@ -5548,7 +6127,9 @@ discard block |
||
| 5548 | 6127 | $this->db->commit(); |
| 5549 | 6128 | return 1; |
| 5550 | 6129 | } |
| 5551 | - } else return 0; |
|
| 6130 | + } else { |
|
| 6131 | + return 0; |
|
| 6132 | + } |
|
| 5552 | 6133 | } |
| 5553 | 6134 | |
| 5554 | 6135 | /** |
@@ -5565,9 +6146,13 @@ discard block |
||
| 5565 | 6146 | { |
| 5566 | 6147 | global $conf, $langs, $user; |
| 5567 | 6148 | |
| 5568 | - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; |
|
| 6149 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 6150 | + return 0; |
|
| 6151 | + } |
|
| 5569 | 6152 | |
| 5570 | - if (empty($userused)) $userused = $user; |
|
| 6153 | + if (empty($userused)) { |
|
| 6154 | + $userused = $user; |
|
| 6155 | + } |
|
| 5571 | 6156 | |
| 5572 | 6157 | $error = 0; |
| 5573 | 6158 | |
@@ -5660,7 +6245,9 @@ discard block |
||
| 5660 | 6245 | // Call trigger |
| 5661 | 6246 | $this->context = array('extrafieldupdate'=>1); |
| 5662 | 6247 | $result = $this->call_trigger($trigger, $userused); |
| 5663 | - if ($result < 0) $error++; |
|
| 6248 | + if ($result < 0) { |
|
| 6249 | + $error++; |
|
| 6250 | + } |
|
| 5664 | 6251 | // End call trigger |
| 5665 | 6252 | } |
| 5666 | 6253 | |
@@ -5673,7 +6260,9 @@ discard block |
||
| 5673 | 6260 | $this->db->commit(); |
| 5674 | 6261 | return 1; |
| 5675 | 6262 | } |
| 5676 | - } else return 0; |
|
| 6263 | + } else { |
|
| 6264 | + return 0; |
|
| 6265 | + } |
|
| 5677 | 6266 | } |
| 5678 | 6267 | |
| 5679 | 6268 | /** |
@@ -5690,11 +6279,16 @@ discard block |
||
| 5690 | 6279 | { |
| 5691 | 6280 | global $conf, $langs, $user; |
| 5692 | 6281 | |
| 5693 | - if (empty($userused)) $userused = $user; |
|
| 6282 | + if (empty($userused)) { |
|
| 6283 | + $userused = $user; |
|
| 6284 | + } |
|
| 5694 | 6285 | |
| 5695 | 6286 | $error = 0; |
| 5696 | 6287 | |
| 5697 | - if (!empty($conf->global->MAIN_EXTRALANGUAGES_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 6288 | + if (!empty($conf->global->MAIN_EXTRALANGUAGES_DISABLED)) { |
|
| 6289 | + return 0; |
|
| 6290 | + } |
|
| 6291 | + // For avoid conflicts if trigger used |
|
| 5698 | 6292 | |
| 5699 | 6293 | return 0; |
| 5700 | 6294 | } |
@@ -5778,8 +6372,11 @@ discard block |
||
| 5778 | 6372 | |
| 5779 | 6373 | if ($computed) |
| 5780 | 6374 | { |
| 5781 | - if (!preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 5782 | - else return ''; |
|
| 6375 | + if (!preg_match('/^search_/', $keyprefix)) { |
|
| 6376 | + return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 6377 | + } else { |
|
| 6378 | + return ''; |
|
| 6379 | + } |
|
| 5783 | 6380 | } |
| 5784 | 6381 | |
| 5785 | 6382 | // Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine |
@@ -5789,9 +6386,11 @@ discard block |
||
| 5789 | 6386 | if ($type == 'date') |
| 5790 | 6387 | { |
| 5791 | 6388 | $morecss = 'minwidth100imp'; |
| 5792 | - } elseif ($type == 'datetime' || $type == 'link') // link means an foreign key to another primary id |
|
| 6389 | + } elseif ($type == 'datetime' || $type == 'link') { |
|
| 6390 | + // link means an foreign key to another primary id |
|
| 5793 | 6391 | { |
| 5794 | 6392 | $morecss = 'minwidth200imp'; |
| 6393 | + } |
|
| 5795 | 6394 | } elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
| 5796 | 6395 | { |
| 5797 | 6396 | $morecss = 'maxwidth75'; |
@@ -5821,7 +6420,9 @@ discard block |
||
| 5821 | 6420 | $showtime = in_array($type, array('datetime')) ? 1 : 0; |
| 5822 | 6421 | |
| 5823 | 6422 | // Do not show current date when field not required (see selectDate() method) |
| 5824 | - if (!$required && $value == '') $value = '-1'; |
|
| 6423 | + if (!$required && $value == '') { |
|
| 6424 | + $value = '-1'; |
|
| 6425 | + } |
|
| 5825 | 6426 | |
| 5826 | 6427 | // TODO Must also support $moreparam |
| 5827 | 6428 | $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); |
@@ -5844,9 +6445,11 @@ discard block |
||
| 5844 | 6445 | $out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>'; |
| 5845 | 6446 | } elseif (preg_match('/^text/', $type)) |
| 5846 | 6447 | { |
| 5847 | - if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 6448 | + if (!preg_match('/search_/', $keyprefix)) { |
|
| 6449 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5848 | 6450 | { |
| 5849 | 6451 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 6452 | + } |
|
| 5850 | 6453 | $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); |
| 5851 | 6454 | $out = $doleditor->Create(1); |
| 5852 | 6455 | } else { |
@@ -5854,9 +6457,11 @@ discard block |
||
| 5854 | 6457 | } |
| 5855 | 6458 | } elseif (preg_match('/^html/', $type)) |
| 5856 | 6459 | { |
| 5857 | - if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 6460 | + if (!preg_match('/search_/', $keyprefix)) { |
|
| 6461 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5858 | 6462 | { |
| 5859 | 6463 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 6464 | + } |
|
| 5860 | 6465 | $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); |
| 5861 | 6466 | $out = $doleditor->Create(1); |
| 5862 | 6467 | } else { |
@@ -5893,10 +6498,14 @@ discard block |
||
| 5893 | 6498 | } |
| 5894 | 6499 | |
| 5895 | 6500 | $out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>'; |
| 5896 | - if ((!isset($this->fields[$key]['default'])) || ($this->fields[$key]['notnull'] != 1))$out .= '<option value="0"> </option>'; |
|
| 6501 | + if ((!isset($this->fields[$key]['default'])) || ($this->fields[$key]['notnull'] != 1)) { |
|
| 6502 | + $out .= '<option value="0"> </option>'; |
|
| 6503 | + } |
|
| 5897 | 6504 | foreach ($param['options'] as $key => $val) |
| 5898 | 6505 | { |
| 5899 | - if ((string) $key == '') continue; |
|
| 6506 | + if ((string) $key == '') { |
|
| 6507 | + continue; |
|
| 6508 | + } |
|
| 5900 | 6509 | list($val, $parent) = explode('|', $val); |
| 5901 | 6510 | $out .= '<option value="'.$key.'"'; |
| 5902 | 6511 | $out .= (((string) $value == (string) $key) ? ' selected' : ''); |
@@ -6036,7 +6645,9 @@ discard block |
||
| 6036 | 6645 | $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); |
| 6037 | 6646 | } |
| 6038 | 6647 | } |
| 6039 | - if (empty($labeltoshow)) $labeltoshow = '(not defined)'; |
|
| 6648 | + if (empty($labeltoshow)) { |
|
| 6649 | + $labeltoshow = '(not defined)'; |
|
| 6650 | + } |
|
| 6040 | 6651 | if ($value == $obj->rowid) |
| 6041 | 6652 | { |
| 6042 | 6653 | $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
@@ -6230,11 +6841,16 @@ discard block |
||
| 6230 | 6841 | $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, empty($val['disabled']) ? 0 : 1); |
| 6231 | 6842 | |
| 6232 | 6843 | if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button |
| 6233 | - if (!GETPOSTISSET('backtopage') && empty($val['disabled']) && empty($nonewbutton)) // To avoid to open several times the 'Create Object' button and to avoid to have button if field is protected by a "disabled". |
|
| 6844 | + if (!GETPOSTISSET('backtopage') && empty($val['disabled']) && empty($nonewbutton)) { |
|
| 6845 | + // To avoid to open several times the 'Create Object' button and to avoid to have button if field is protected by a "disabled". |
|
| 6234 | 6846 | { |
| 6235 | 6847 | list($class, $classfile) = explode(':', $param_list[0]); |
| 6236 | - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6237 | - else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6848 | + } |
|
| 6849 | + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) { |
|
| 6850 | + $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6851 | + } else { |
|
| 6852 | + $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6853 | + } |
|
| 6238 | 6854 | $paramforthenewlink = ''; |
| 6239 | 6855 | $paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : ''); |
| 6240 | 6856 | $paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : ''); |
@@ -6326,9 +6942,16 @@ discard block |
||
| 6326 | 6942 | { |
| 6327 | 6943 | $type = 'varchar'; // convert varchar(xx) int varchar |
| 6328 | 6944 | $size = $reg[1]; |
| 6329 | - } elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6330 | - if (is_array($val['arrayofkeyval'])) $type = 'select'; |
|
| 6331 | - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link'; |
|
| 6945 | + } elseif (preg_match('/varchar/', $type)) { |
|
| 6946 | + $type = 'varchar'; |
|
| 6947 | + } |
|
| 6948 | + // convert varchar(xx) int varchar |
|
| 6949 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6950 | + $type = 'select'; |
|
| 6951 | + } |
|
| 6952 | + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6953 | + $type = 'link'; |
|
| 6954 | + } |
|
| 6332 | 6955 | |
| 6333 | 6956 | $default = $val['default']; |
| 6334 | 6957 | $computed = $val['computed']; |
@@ -6337,7 +6960,9 @@ discard block |
||
| 6337 | 6960 | $param = array(); |
| 6338 | 6961 | $param['options'] = array(); |
| 6339 | 6962 | |
| 6340 | - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; |
|
| 6963 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6964 | + $param['options'] = $val['arrayofkeyval']; |
|
| 6965 | + } |
|
| 6341 | 6966 | if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) |
| 6342 | 6967 | { |
| 6343 | 6968 | $type = 'link'; |
@@ -6352,7 +6977,9 @@ discard block |
||
| 6352 | 6977 | $help = $val['help']; |
| 6353 | 6978 | $hidden = (($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) |
| 6354 | 6979 | |
| 6355 | - if ($hidden) return ''; |
|
| 6980 | + if ($hidden) { |
|
| 6981 | + return ''; |
|
| 6982 | + } |
|
| 6356 | 6983 | |
| 6357 | 6984 | // If field is a computed field, value must become result of compute |
| 6358 | 6985 | if ($computed) |
@@ -6393,9 +7020,11 @@ discard block |
||
| 6393 | 7020 | } |
| 6394 | 7021 | |
| 6395 | 7022 | // Format output value differently according to properties of field |
| 6396 | - if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value = $this->getNomUrl(1, '', 0, '', 1); |
|
| 6397 | - elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value = $this->getLibStatut(3); |
|
| 6398 | - elseif ($type == 'date') |
|
| 7023 | + if ($key == 'ref' && method_exists($this, 'getNomUrl')) { |
|
| 7024 | + $value = $this->getNomUrl(1, '', 0, '', 1); |
|
| 7025 | + } elseif ($key == 'status' && method_exists($this, 'getLibStatut')) { |
|
| 7026 | + $value = $this->getLibStatut(3); |
|
| 7027 | + } elseif ($type == 'date') |
|
| 6399 | 7028 | { |
| 6400 | 7029 | if (!empty($value)) { |
| 6401 | 7030 | $value = dol_print_date($value, 'day'); |
@@ -6516,7 +7145,9 @@ discard block |
||
| 6516 | 7145 | $value = $obj->{$InfoFieldList[1]}; |
| 6517 | 7146 | } |
| 6518 | 7147 | } |
| 6519 | - } else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 7148 | + } else { |
|
| 7149 | + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 7150 | + } |
|
| 6520 | 7151 | } elseif ($type == 'radio') |
| 6521 | 7152 | { |
| 6522 | 7153 | $value = $param['options'][$value]; |
@@ -6625,7 +7256,9 @@ discard block |
||
| 6625 | 7256 | dol_syslog('Error bad setup of extrafield', LOG_WARNING); |
| 6626 | 7257 | return 'Error bad setup of extrafield'; |
| 6627 | 7258 | } |
| 6628 | - } else $value = ''; |
|
| 7259 | + } else { |
|
| 7260 | + $value = ''; |
|
| 7261 | + } |
|
| 6629 | 7262 | } elseif (preg_match('/^(text|html)/', $type)) |
| 6630 | 7263 | { |
| 6631 | 7264 | $value = dol_htmlentitiesbr($value); |
@@ -6660,7 +7293,9 @@ discard block |
||
| 6660 | 7293 | { |
| 6661 | 7294 | global $db, $conf, $langs, $action, $form, $hookmanager; |
| 6662 | 7295 | |
| 6663 | - if (!is_object($form)) $form = new Form($db); |
|
| 7296 | + if (!is_object($form)) { |
|
| 7297 | + $form = new Form($db); |
|
| 7298 | + } |
|
| 6664 | 7299 | |
| 6665 | 7300 | $out = ''; |
| 6666 | 7301 | |
@@ -6679,7 +7314,9 @@ discard block |
||
| 6679 | 7314 | foreach ($extrafields->attributes[$this->table_element]['label'] as $key=>$label) |
| 6680 | 7315 | { |
| 6681 | 7316 | // Show only the key field in params |
| 6682 | - if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue; |
|
| 7317 | + if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) { |
|
| 7318 | + continue; |
|
| 7319 | + } |
|
| 6683 | 7320 | |
| 6684 | 7321 | // Test on 'enabled' ('enabled' is different than 'list' = 'visibility') |
| 6685 | 7322 | $enabled = 1; |
@@ -6687,7 +7324,9 @@ discard block |
||
| 6687 | 7324 | { |
| 6688 | 7325 | $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1); |
| 6689 | 7326 | } |
| 6690 | - if (empty($enabled)) continue; |
|
| 7327 | + if (empty($enabled)) { |
|
| 7328 | + continue; |
|
| 7329 | + } |
|
| 6691 | 7330 | |
| 6692 | 7331 | $visibility = 1; |
| 6693 | 7332 | if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) |
@@ -6701,10 +7340,20 @@ discard block |
||
| 6701 | 7340 | $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); |
| 6702 | 7341 | } |
| 6703 | 7342 | |
| 6704 | - if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6705 | - elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation |
|
| 6706 | - elseif ($mode == 'view' && empty($visibility)) continue; |
|
| 6707 | - if (empty($perms)) continue; |
|
| 7343 | + if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) { |
|
| 7344 | + continue; |
|
| 7345 | + } |
|
| 7346 | + // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 7347 | + elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) { |
|
| 7348 | + continue; |
|
| 7349 | + } |
|
| 7350 | + // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation |
|
| 7351 | + elseif ($mode == 'view' && empty($visibility)) { |
|
| 7352 | + continue; |
|
| 7353 | + } |
|
| 7354 | + if (empty($perms)) { |
|
| 7355 | + continue; |
|
| 7356 | + } |
|
| 6708 | 7357 | // Load language if required |
| 6709 | 7358 | if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { |
| 6710 | 7359 | $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
@@ -6797,10 +7446,12 @@ discard block |
||
| 6797 | 7446 | if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) |
| 6798 | 7447 | { |
| 6799 | 7448 | $datenotinstring = $this->array_options['options_'.$key]; |
| 6800 | - if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility |
|
| 7449 | + if (!is_numeric($this->array_options['options_'.$key])) { |
|
| 7450 | + // For backward compatibility |
|
| 6801 | 7451 | { |
| 6802 | 7452 | $datenotinstring = $this->db->jdate($datenotinstring); |
| 6803 | 7453 | } |
| 7454 | + } |
|
| 6804 | 7455 | $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; |
| 6805 | 7456 | } |
| 6806 | 7457 | // Convert float submited string into real php numeric (value in memory must be a php numeric) |
@@ -6812,7 +7463,9 @@ discard block |
||
| 6812 | 7463 | // HTML, text, select, integer and varchar: take into account default value in database if in create mode |
| 6813 | 7464 | if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int'))) |
| 6814 | 7465 | { |
| 6815 | - if ($action == 'create') $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key]; |
|
| 7466 | + if ($action == 'create') { |
|
| 7467 | + $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key]; |
|
| 7468 | + } |
|
| 6816 | 7469 | } |
| 6817 | 7470 | |
| 6818 | 7471 | $labeltoshow = $langs->trans($label); |
@@ -6826,14 +7479,24 @@ discard block |
||
| 6826 | 7479 | $tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none"; |
| 6827 | 7480 | if ($tpl_context == "public") { // Public page : red dot instead of fieldrequired characters |
| 6828 | 7481 | $out .= '">'; |
| 6829 | - if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow); |
|
| 6830 | - else $out .= $labeltoshow; |
|
| 6831 | - if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' <font color="red">*</font>'; |
|
| 7482 | + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) { |
|
| 7483 | + $out .= $form->textwithpicto($labeltoshow, $helptoshow); |
|
| 7484 | + } else { |
|
| 7485 | + $out .= $labeltoshow; |
|
| 7486 | + } |
|
| 7487 | + if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) { |
|
| 7488 | + $out .= ' <font color="red">*</font>'; |
|
| 7489 | + } |
|
| 6832 | 7490 | } else { |
| 6833 | - if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; |
|
| 7491 | + if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) { |
|
| 7492 | + $out .= ' fieldrequired'; |
|
| 7493 | + } |
|
| 6834 | 7494 | $out .= '">'; |
| 6835 | - if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow); |
|
| 6836 | - else $out .= $labeltoshow; |
|
| 7495 | + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) { |
|
| 7496 | + $out .= $form->textwithpicto($labeltoshow, $helptoshow); |
|
| 7497 | + } else { |
|
| 7498 | + $out .= $labeltoshow; |
|
| 7499 | + } |
|
| 6837 | 7500 | } |
| 6838 | 7501 | $out .= '</td>'; |
| 6839 | 7502 | |
@@ -6860,8 +7523,11 @@ discard block |
||
| 6860 | 7523 | $out .='<td class="'.$this->element.'_extras_'.$key.'"></td>'; |
| 6861 | 7524 | }*/ |
| 6862 | 7525 | |
| 6863 | - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>'; |
|
| 6864 | - else $out .= '</tr>'; |
|
| 7526 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { |
|
| 7527 | + $out .= '</tr>'; |
|
| 7528 | + } else { |
|
| 7529 | + $out .= '</tr>'; |
|
| 7530 | + } |
|
| 6865 | 7531 | $e++; |
| 6866 | 7532 | } |
| 6867 | 7533 | } |
@@ -6918,7 +7584,9 @@ discard block |
||
| 6918 | 7584 | global $user; |
| 6919 | 7585 | |
| 6920 | 7586 | $element = $this->element; |
| 6921 | - if ($element == 'facturerec') $element = 'facture'; |
|
| 7587 | + if ($element == 'facturerec') { |
|
| 7588 | + $element = 'facture'; |
|
| 7589 | + } |
|
| 6922 | 7590 | |
| 6923 | 7591 | return $user->rights->{$element}; |
| 6924 | 7592 | } |
@@ -6943,7 +7611,10 @@ discard block |
||
| 6943 | 7611 | |
| 6944 | 7612 | if (!$db->query($sql)) |
| 6945 | 7613 | { |
| 6946 | - if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 7614 | + if ($ignoreerrors) { |
|
| 7615 | + return true; |
|
| 7616 | + } |
|
| 7617 | + // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6947 | 7618 | //$this->errors = $db->lasterror(); |
| 6948 | 7619 | return false; |
| 6949 | 7620 | } |
@@ -6970,9 +7641,11 @@ discard block |
||
| 6970 | 7641 | |
| 6971 | 7642 | $buyPrice = 0; |
| 6972 | 7643 | |
| 6973 | - if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) // In most cases, test here is false |
|
| 7644 | + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { |
|
| 7645 | + // In most cases, test here is false |
|
| 6974 | 7646 | { |
| 6975 | 7647 | $buyPrice = $unitPrice * (1 - $discountPercent / 100); |
| 7648 | + } |
|
| 6976 | 7649 | } else { |
| 6977 | 7650 | // Get cost price for margin calculation |
| 6978 | 7651 | if (!empty($fk_product)) |
@@ -7119,18 +7792,26 @@ discard block |
||
| 7119 | 7792 | if ($size == 1 || $size == 'small') { // Format vignette |
| 7120 | 7793 | // Find name of thumb file |
| 7121 | 7794 | $photo_vignette = basename(getImageFileNameForSize($dir.$file, '_small')); |
| 7122 | - if (!dol_is_file($dirthumb.$photo_vignette)) $photo_vignette = ''; |
|
| 7795 | + if (!dol_is_file($dirthumb.$photo_vignette)) { |
|
| 7796 | + $photo_vignette = ''; |
|
| 7797 | + } |
|
| 7123 | 7798 | |
| 7124 | 7799 | // Get filesize of original file |
| 7125 | 7800 | $imgarray = dol_getImageSize($dir.$photo); |
| 7126 | 7801 | |
| 7127 | 7802 | if ($nbbyrow > 0) |
| 7128 | 7803 | { |
| 7129 | - if ($nbphoto == 1) $return .= '<table class="valigntop center centpercent" style="border: 0; padding: 2px; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7804 | + if ($nbphoto == 1) { |
|
| 7805 | + $return .= '<table class="valigntop center centpercent" style="border: 0; padding: 2px; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7806 | + } |
|
| 7130 | 7807 | |
| 7131 | - if ($nbphoto % $nbbyrow == 1) $return .= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7808 | + if ($nbphoto % $nbbyrow == 1) { |
|
| 7809 | + $return .= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7810 | + } |
|
| 7132 | 7811 | $return .= '<td style="width: '.ceil(100 / $nbbyrow).'%" class="photo">'; |
| 7133 | - } elseif ($nbbyrow < 0) $return .= '<div class="inline-block">'; |
|
| 7812 | + } elseif ($nbbyrow < 0) { |
|
| 7813 | + $return .= '<div class="inline-block">'; |
|
| 7814 | + } |
|
| 7134 | 7815 | |
| 7135 | 7816 | $return .= "\n"; |
| 7136 | 7817 | |
@@ -7138,15 +7819,20 @@ discard block |
||
| 7138 | 7819 | if (empty($nolink)) |
| 7139 | 7820 | { |
| 7140 | 7821 | $urladvanced = getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); |
| 7141 | - if ($urladvanced) $return .= '<a href="'.$urladvanced.'">'; |
|
| 7142 | - else $return .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7822 | + if ($urladvanced) { |
|
| 7823 | + $return .= '<a href="'.$urladvanced.'">'; |
|
| 7824 | + } else { |
|
| 7825 | + $return .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7826 | + } |
|
| 7143 | 7827 | } |
| 7144 | 7828 | |
| 7145 | 7829 | // Show image (width height=$maxHeight) |
| 7146 | 7830 | // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine |
| 7147 | 7831 | $alt = $langs->transnoentitiesnoconv('File').': '.$relativefile; |
| 7148 | 7832 | $alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; |
| 7149 | - if ($notitle) $alt = ''; |
|
| 7833 | + if ($notitle) { |
|
| 7834 | + $alt = ''; |
|
| 7835 | + } |
|
| 7150 | 7836 | |
| 7151 | 7837 | if ($usesharelink) |
| 7152 | 7838 | { |
@@ -7175,10 +7861,14 @@ discard block |
||
| 7175 | 7861 | } |
| 7176 | 7862 | } |
| 7177 | 7863 | |
| 7178 | - if (empty($nolink)) $return .= '</a>'; |
|
| 7864 | + if (empty($nolink)) { |
|
| 7865 | + $return .= '</a>'; |
|
| 7866 | + } |
|
| 7179 | 7867 | $return .= "\n"; |
| 7180 | 7868 | |
| 7181 | - if ($showfilename) $return .= '<br>'.$viewfilename; |
|
| 7869 | + if ($showfilename) { |
|
| 7870 | + $return .= '<br>'.$viewfilename; |
|
| 7871 | + } |
|
| 7182 | 7872 | if ($showaction) |
| 7183 | 7873 | { |
| 7184 | 7874 | $return .= '<br>'; |
@@ -7203,14 +7893,20 @@ discard block |
||
| 7203 | 7893 | if ($nbbyrow > 0) |
| 7204 | 7894 | { |
| 7205 | 7895 | $return .= '</td>'; |
| 7206 | - if (($nbphoto % $nbbyrow) == 0) $return .= '</tr>'; |
|
| 7207 | - } elseif ($nbbyrow < 0) $return .= '</div>'; |
|
| 7896 | + if (($nbphoto % $nbbyrow) == 0) { |
|
| 7897 | + $return .= '</tr>'; |
|
| 7898 | + } |
|
| 7899 | + } elseif ($nbbyrow < 0) { |
|
| 7900 | + $return .= '</div>'; |
|
| 7901 | + } |
|
| 7208 | 7902 | } |
| 7209 | 7903 | |
| 7210 | 7904 | if (empty($size)) { // Format origine |
| 7211 | 7905 | $return .= '<img class="photo photowithmargin" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; |
| 7212 | 7906 | |
| 7213 | - if ($showfilename) $return .= '<br>'.$viewfilename; |
|
| 7907 | + if ($showfilename) { |
|
| 7908 | + $return .= '<br>'.$viewfilename; |
|
| 7909 | + } |
|
| 7214 | 7910 | if ($showaction) |
| 7215 | 7911 | { |
| 7216 | 7912 | // Special case for product |
@@ -7227,7 +7923,9 @@ discard block |
||
| 7227 | 7923 | } |
| 7228 | 7924 | |
| 7229 | 7925 | // On continue ou on arrete de boucler ? |
| 7230 | - if ($nbmax && $nbphoto >= $nbmax) break; |
|
| 7926 | + if ($nbmax && $nbphoto >= $nbmax) { |
|
| 7927 | + break; |
|
| 7928 | + } |
|
| 7231 | 7929 | } |
| 7232 | 7930 | } |
| 7233 | 7931 | |
@@ -7242,7 +7940,9 @@ discard block |
||
| 7242 | 7940 | $nbphoto++; |
| 7243 | 7941 | } |
| 7244 | 7942 | |
| 7245 | - if ($nbphoto) $return .= '</table>'; |
|
| 7943 | + if ($nbphoto) { |
|
| 7944 | + $return .= '</table>'; |
|
| 7945 | + } |
|
| 7246 | 7946 | } |
| 7247 | 7947 | } |
| 7248 | 7948 | } |
@@ -7263,8 +7963,11 @@ discard block |
||
| 7263 | 7963 | { |
| 7264 | 7964 | if (is_array($info)) |
| 7265 | 7965 | { |
| 7266 | - if (isset($info['type']) && $info['type'] == 'array') return true; |
|
| 7267 | - else return false; |
|
| 7966 | + if (isset($info['type']) && $info['type'] == 'array') { |
|
| 7967 | + return true; |
|
| 7968 | + } else { |
|
| 7969 | + return false; |
|
| 7970 | + } |
|
| 7268 | 7971 | } |
| 7269 | 7972 | return false; |
| 7270 | 7973 | } |
@@ -7277,7 +7980,9 @@ discard block |
||
| 7277 | 7980 | */ |
| 7278 | 7981 | public function isDate($info) |
| 7279 | 7982 | { |
| 7280 | - if (isset($info['type']) && ($info['type'] == 'date' || $info['type'] == 'datetime' || $info['type'] == 'timestamp')) return true; |
|
| 7983 | + if (isset($info['type']) && ($info['type'] == 'date' || $info['type'] == 'datetime' || $info['type'] == 'timestamp')) { |
|
| 7984 | + return true; |
|
| 7985 | + } |
|
| 7281 | 7986 | return false; |
| 7282 | 7987 | } |
| 7283 | 7988 | |
@@ -7291,9 +7996,14 @@ discard block |
||
| 7291 | 7996 | { |
| 7292 | 7997 | if (is_array($info)) |
| 7293 | 7998 | { |
| 7294 | - if (isset($info['type']) && ($info['type'] == 'duration')) return true; |
|
| 7295 | - else return false; |
|
| 7296 | - } else return false; |
|
| 7999 | + if (isset($info['type']) && ($info['type'] == 'duration')) { |
|
| 8000 | + return true; |
|
| 8001 | + } else { |
|
| 8002 | + return false; |
|
| 8003 | + } |
|
| 8004 | + } else { |
|
| 8005 | + return false; |
|
| 8006 | + } |
|
| 7297 | 8007 | } |
| 7298 | 8008 | |
| 7299 | 8009 | /** |
@@ -7306,9 +8016,14 @@ discard block |
||
| 7306 | 8016 | { |
| 7307 | 8017 | if (is_array($info)) |
| 7308 | 8018 | { |
| 7309 | - if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true; |
|
| 7310 | - else return false; |
|
| 7311 | - } else return false; |
|
| 8019 | + if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) { |
|
| 8020 | + return true; |
|
| 8021 | + } else { |
|
| 8022 | + return false; |
|
| 8023 | + } |
|
| 8024 | + } else { |
|
| 8025 | + return false; |
|
| 8026 | + } |
|
| 7312 | 8027 | } |
| 7313 | 8028 | |
| 7314 | 8029 | /** |
@@ -7321,8 +8036,11 @@ discard block |
||
| 7321 | 8036 | { |
| 7322 | 8037 | if (is_array($info)) |
| 7323 | 8038 | { |
| 7324 | - if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) return true; |
|
| 7325 | - else return false; |
|
| 8039 | + if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) { |
|
| 8040 | + return true; |
|
| 8041 | + } else { |
|
| 8042 | + return false; |
|
| 8043 | + } |
|
| 7326 | 8044 | } |
| 7327 | 8045 | return false; |
| 7328 | 8046 | } |
@@ -7337,8 +8055,11 @@ discard block |
||
| 7337 | 8055 | { |
| 7338 | 8056 | if (is_array($info)) |
| 7339 | 8057 | { |
| 7340 | - if (isset($info['type']) && $info['type'] == 'text') return true; |
|
| 7341 | - else return false; |
|
| 8058 | + if (isset($info['type']) && $info['type'] == 'text') { |
|
| 8059 | + return true; |
|
| 8060 | + } else { |
|
| 8061 | + return false; |
|
| 8062 | + } |
|
| 7342 | 8063 | } |
| 7343 | 8064 | return false; |
| 7344 | 8065 | } |
@@ -7353,8 +8074,11 @@ discard block |
||
| 7353 | 8074 | { |
| 7354 | 8075 | if (is_array($info)) |
| 7355 | 8076 | { |
| 7356 | - if (isset($info['notnull']) && $info['notnull'] != '1') return true; |
|
| 7357 | - else return false; |
|
| 8077 | + if (isset($info['notnull']) && $info['notnull'] != '1') { |
|
| 8078 | + return true; |
|
| 8079 | + } else { |
|
| 8080 | + return false; |
|
| 8081 | + } |
|
| 7358 | 8082 | } |
| 7359 | 8083 | return true; |
| 7360 | 8084 | } |
@@ -7369,8 +8093,11 @@ discard block |
||
| 7369 | 8093 | { |
| 7370 | 8094 | if (is_array($info)) |
| 7371 | 8095 | { |
| 7372 | - if (isset($info['notnull']) && $info['notnull'] == '-1') return true; |
|
| 7373 | - else return false; |
|
| 8096 | + if (isset($info['notnull']) && $info['notnull'] == '-1') { |
|
| 8097 | + return true; |
|
| 8098 | + } else { |
|
| 8099 | + return false; |
|
| 8100 | + } |
|
| 7374 | 8101 | } |
| 7375 | 8102 | return false; |
| 7376 | 8103 | } |
@@ -7385,8 +8112,11 @@ discard block |
||
| 7385 | 8112 | { |
| 7386 | 8113 | if (is_array($info)) |
| 7387 | 8114 | { |
| 7388 | - if (isset($info['index']) && $info['index'] == true) return true; |
|
| 7389 | - else return false; |
|
| 8115 | + if (isset($info['index']) && $info['index'] == true) { |
|
| 8116 | + return true; |
|
| 8117 | + } else { |
|
| 8118 | + return false; |
|
| 8119 | + } |
|
| 7390 | 8120 | } |
| 7391 | 8121 | return false; |
| 7392 | 8122 | } |
@@ -7404,7 +8134,8 @@ discard block |
||
| 7404 | 8134 | global $conf; |
| 7405 | 8135 | |
| 7406 | 8136 | $queryarray = array(); |
| 7407 | - foreach ($this->fields as $field => $info) // Loop on definition of fields |
|
| 8137 | + foreach ($this->fields as $field => $info) { |
|
| 8138 | + // Loop on definition of fields |
|
| 7408 | 8139 | { |
| 7409 | 8140 | // Depending on field type ('datetime', ...) |
| 7410 | 8141 | if ($this->isDate($info)) |
@@ -7412,6 +8143,7 @@ discard block |
||
| 7412 | 8143 | if (empty($this->{$field})) |
| 7413 | 8144 | { |
| 7414 | 8145 | $queryarray[$field] = null; |
| 8146 | + } |
|
| 7415 | 8147 | } else { |
| 7416 | 8148 | $queryarray[$field] = $this->db->idate($this->{$field}); |
| 7417 | 8149 | } |
@@ -7428,24 +8160,43 @@ discard block |
||
| 7428 | 8160 | } elseif ($this->isDuration($info)) |
| 7429 | 8161 | { |
| 7430 | 8162 | // $this->{$field} may be null, '', 0, '0', 123, '123' |
| 7431 | - if ($this->{$field} != '' || !empty($info['notnull'])) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 7432 | - else $queryarray[$field] = null; |
|
| 8163 | + if ($this->{$field} != '' || !empty($info['notnull'])) { |
|
| 8164 | + $queryarray[$field] = (int) $this->{$field}; |
|
| 8165 | + } |
|
| 8166 | + // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 8167 | + else { |
|
| 8168 | + $queryarray[$field] = null; |
|
| 8169 | + } |
|
| 7433 | 8170 | } elseif ($this->isInt($info) || $this->isFloat($info)) |
| 7434 | 8171 | { |
| 7435 | - if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity; |
|
| 7436 | - else { |
|
| 8172 | + if ($field == 'entity' && is_null($this->{$field})) { |
|
| 8173 | + $queryarray[$field] = $conf->entity; |
|
| 8174 | + } else { |
|
| 7437 | 8175 | // $this->{$field} may be null, '', 0, '0', 123, '123' |
| 7438 | 8176 | if ($this->{$field} != '' || !empty($info['notnull'])) { |
| 7439 | - if ($this->isInt($info)) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 7440 | - if ($this->isFloat($info)) $queryarray[$field] = (double) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 7441 | - } else $queryarray[$field] = null; |
|
| 8177 | + if ($this->isInt($info)) { |
|
| 8178 | + $queryarray[$field] = (int) $this->{$field}; |
|
| 8179 | + } |
|
| 8180 | + // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 8181 | + if ($this->isFloat($info)) { |
|
| 8182 | + $queryarray[$field] = (double) $this->{$field}; |
|
| 8183 | + } |
|
| 8184 | + // If '0', it may be set to null later if $info['notnull'] == -1 |
|
| 8185 | + } else { |
|
| 8186 | + $queryarray[$field] = null; |
|
| 8187 | + } |
|
| 7442 | 8188 | } |
| 7443 | 8189 | } else { |
| 7444 | 8190 | $queryarray[$field] = $this->{$field}; |
| 7445 | 8191 | } |
| 7446 | 8192 | |
| 7447 | - if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); |
|
| 7448 | - if (!empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; // May force 0 to null |
|
| 8193 | + if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { |
|
| 8194 | + unset($queryarray[$field]); |
|
| 8195 | + } |
|
| 8196 | + if (!empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) { |
|
| 8197 | + $queryarray[$field] = null; |
|
| 8198 | + } |
|
| 8199 | + // May force 0 to null |
|
| 7449 | 8200 | } |
| 7450 | 8201 | |
| 7451 | 8202 | return $queryarray; |
@@ -7463,25 +8214,34 @@ discard block |
||
| 7463 | 8214 | { |
| 7464 | 8215 | if ($this->isDate($info)) |
| 7465 | 8216 | { |
| 7466 | - if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; |
|
| 7467 | - else $this->{$field} = strtotime($obj->{$field}); |
|
| 8217 | + if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { |
|
| 8218 | + $this->{$field} = 0; |
|
| 8219 | + } else { |
|
| 8220 | + $this->{$field} = strtotime($obj->{$field}); |
|
| 8221 | + } |
|
| 7468 | 8222 | } elseif ($this->isArray($info)) |
| 7469 | 8223 | { |
| 7470 | 8224 | if (!empty($obj->{$field})) { |
| 7471 | 8225 | $this->{$field} = @unserialize($obj->{$field}); |
| 7472 | 8226 | // Hack for data not in UTF8 |
| 7473 | - if ($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); |
|
| 8227 | + if ($this->{$field } === false) { |
|
| 8228 | + @unserialize(utf8_decode($obj->{$field})); |
|
| 8229 | + } |
|
| 7474 | 8230 | } else { |
| 7475 | 8231 | $this->{$field} = array(); |
| 7476 | 8232 | } |
| 7477 | 8233 | } elseif ($this->isInt($info)) |
| 7478 | 8234 | { |
| 7479 | - if ($field == 'rowid') $this->id = (int) $obj->{$field}; |
|
| 7480 | - else { |
|
| 8235 | + if ($field == 'rowid') { |
|
| 8236 | + $this->id = (int) $obj->{$field}; |
|
| 8237 | + } else { |
|
| 7481 | 8238 | if ($this->isForcedToNullIfZero($info)) |
| 7482 | 8239 | { |
| 7483 | - if (empty($obj->{$field})) $this->{$field} = null; |
|
| 7484 | - else $this->{$field} = (double) $obj->{$field}; |
|
| 8240 | + if (empty($obj->{$field})) { |
|
| 8241 | + $this->{$field} = null; |
|
| 8242 | + } else { |
|
| 8243 | + $this->{$field} = (double) $obj->{$field}; |
|
| 8244 | + } |
|
| 7485 | 8245 | } else { |
| 7486 | 8246 | if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { |
| 7487 | 8247 | $this->{$field} = (int) $obj->{$field}; |
@@ -7494,8 +8254,11 @@ discard block |
||
| 7494 | 8254 | { |
| 7495 | 8255 | if ($this->isForcedToNullIfZero($info)) |
| 7496 | 8256 | { |
| 7497 | - if (empty($obj->{$field})) $this->{$field} = null; |
|
| 7498 | - else $this->{$field} = (double) $obj->{$field}; |
|
| 8257 | + if (empty($obj->{$field})) { |
|
| 8258 | + $this->{$field} = null; |
|
| 8259 | + } else { |
|
| 8260 | + $this->{$field} = (double) $obj->{$field}; |
|
| 8261 | + } |
|
| 7499 | 8262 | } else { |
| 7500 | 8263 | if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { |
| 7501 | 8264 | $this->{$field} = (double) $obj->{$field}; |
@@ -7509,7 +8272,9 @@ discard block |
||
| 7509 | 8272 | } |
| 7510 | 8273 | |
| 7511 | 8274 | // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. |
| 7512 | - if (!isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; |
|
| 8275 | + if (!isset($this->fields['ref']) && isset($this->id)) { |
|
| 8276 | + $this->ref = $this->id; |
|
| 8277 | + } |
|
| 7513 | 8278 | } |
| 7514 | 8279 | |
| 7515 | 8280 | /** |
@@ -7532,13 +8297,19 @@ discard block |
||
| 7532 | 8297 | */ |
| 7533 | 8298 | protected function quote($value, $fieldsentry) |
| 7534 | 8299 | { |
| 7535 | - if (is_null($value)) return 'NULL'; |
|
| 7536 | - elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) return $this->db->escape("$value"); |
|
| 7537 | - elseif ($fieldsentry['type'] == 'boolean') { |
|
| 7538 | - if ($value) return 'true'; |
|
| 7539 | - else return 'false'; |
|
| 8300 | + if (is_null($value)) { |
|
| 8301 | + return 'NULL'; |
|
| 8302 | + } elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) { |
|
| 8303 | + return $this->db->escape("$value"); |
|
| 8304 | + } elseif ($fieldsentry['type'] == 'boolean') { |
|
| 8305 | + if ($value) { |
|
| 8306 | + return 'true'; |
|
| 8307 | + } else { |
|
| 8308 | + return 'false'; |
|
| 8309 | + } |
|
| 8310 | + } else { |
|
| 8311 | + return "'".$this->db->escape($value)."'"; |
|
| 7540 | 8312 | } |
| 7541 | - else return "'".$this->db->escape($value)."'"; |
|
| 7542 | 8313 | } |
| 7543 | 8314 | |
| 7544 | 8315 | |
@@ -7560,10 +8331,17 @@ discard block |
||
| 7560 | 8331 | |
| 7561 | 8332 | $fieldvalues = $this->setSaveQuery(); |
| 7562 | 8333 | |
| 7563 | - if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); |
|
| 7564 | - if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; |
|
| 8334 | + if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) { |
|
| 8335 | + $fieldvalues['date_creation'] = $this->db->idate($now); |
|
| 8336 | + } |
|
| 8337 | + if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) { |
|
| 8338 | + $fieldvalues['fk_user_creat'] = $user->id; |
|
| 8339 | + } |
|
| 7565 | 8340 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. |
| 7566 | - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data |
|
| 8341 | + if (array_key_exists('ref', $fieldvalues)) { |
|
| 8342 | + $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); |
|
| 8343 | + } |
|
| 8344 | + // If field is a ref, we sanitize data |
|
| 7567 | 8345 | |
| 7568 | 8346 | $keys = array(); |
| 7569 | 8347 | $values = array(); // Array to store string forged for SQL syntax |
@@ -7577,8 +8355,12 @@ discard block |
||
| 7577 | 8355 | foreach ($keys as $key) |
| 7578 | 8356 | { |
| 7579 | 8357 | // If field is an implicit foreign key field |
| 7580 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; |
|
| 7581 | - if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; |
|
| 8358 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 8359 | + $values[$key] = ''; |
|
| 8360 | + } |
|
| 8361 | + if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 8362 | + $values[$key] = ''; |
|
| 8363 | + } |
|
| 7582 | 8364 | |
| 7583 | 8365 | if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && (!isset($values[$key]) || $values[$key] === 'NULL') && is_null($this->fields[$key]['default'])) |
| 7584 | 8366 | { |
@@ -7594,13 +8376,20 @@ discard block |
||
| 7594 | 8376 | |
| 7595 | 8377 | // If field is an implicit foreign key field |
| 7596 | 8378 | if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { |
| 7597 | - if (isset($this->fields[$key]['default'])) $values[$key] = $this->fields[$key]['default']; |
|
| 7598 | - else $values[$key] = 'null'; |
|
| 8379 | + if (isset($this->fields[$key]['default'])) { |
|
| 8380 | + $values[$key] = $this->fields[$key]['default']; |
|
| 8381 | + } else { |
|
| 8382 | + $values[$key] = 'null'; |
|
| 8383 | + } |
|
| 8384 | + } |
|
| 8385 | + if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) { |
|
| 8386 | + $values[$key] = 'null'; |
|
| 7599 | 8387 | } |
| 7600 | - if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key] = 'null'; |
|
| 7601 | 8388 | } |
| 7602 | 8389 | |
| 7603 | - if ($error) return -1; |
|
| 8390 | + if ($error) { |
|
| 8391 | + return -1; |
|
| 8392 | + } |
|
| 7604 | 8393 | |
| 7605 | 8394 | $this->db->begin(); |
| 7606 | 8395 | |
@@ -7644,7 +8433,9 @@ discard block |
||
| 7644 | 8433 | if (!$error) |
| 7645 | 8434 | { |
| 7646 | 8435 | $result = $this->insertExtraFields(); |
| 7647 | - if ($result < 0) $error++; |
|
| 8436 | + if ($result < 0) { |
|
| 8437 | + $error++; |
|
| 8438 | + } |
|
| 7648 | 8439 | } |
| 7649 | 8440 | |
| 7650 | 8441 | // Create lines |
@@ -7660,7 +8451,9 @@ discard block |
||
| 7660 | 8451 | |
| 7661 | 8452 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
| 7662 | 8453 | //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. |
| 7663 | - if (!is_object($line)) $line = (object) $line; |
|
| 8454 | + if (!is_object($line)) { |
|
| 8455 | + $line = (object) $line; |
|
| 8456 | + } |
|
| 7664 | 8457 | |
| 7665 | 8458 | $result = $line->create($user, 1); |
| 7666 | 8459 | if ($result < 0) |
@@ -7702,19 +8495,32 @@ discard block |
||
| 7702 | 8495 | */ |
| 7703 | 8496 | public function fetchCommon($id, $ref = null, $morewhere = '') |
| 7704 | 8497 | { |
| 7705 | - if (empty($id) && empty($ref) && empty($morewhere)) return -1; |
|
| 8498 | + if (empty($id) && empty($ref) && empty($morewhere)) { |
|
| 8499 | + return -1; |
|
| 8500 | + } |
|
| 7706 | 8501 | |
| 7707 | 8502 | $fieldlist = $this->getFieldList(); |
| 7708 | - if (empty($fieldlist)) return 0; |
|
| 8503 | + if (empty($fieldlist)) { |
|
| 8504 | + return 0; |
|
| 8505 | + } |
|
| 7709 | 8506 | |
| 7710 | 8507 | $sql = 'SELECT '.$fieldlist; |
| 7711 | 8508 | $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
| 7712 | 8509 | |
| 7713 | - if (!empty($id)) $sql .= ' WHERE rowid = '.$id; |
|
| 7714 | - elseif (!empty($ref)) $sql .= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7715 | - else $sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare |
|
| 7716 | - if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 7717 | - if ($morewhere) $sql .= $morewhere; |
|
| 8510 | + if (!empty($id)) { |
|
| 8511 | + $sql .= ' WHERE rowid = '.$id; |
|
| 8512 | + } elseif (!empty($ref)) { |
|
| 8513 | + $sql .= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 8514 | + } else { |
|
| 8515 | + $sql .= ' WHERE 1 = 1'; |
|
| 8516 | + } |
|
| 8517 | + // usage with empty id and empty ref is very rare |
|
| 8518 | + if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
|
| 8519 | + $sql .= ' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 8520 | + } |
|
| 8521 | + if ($morewhere) { |
|
| 8522 | + $sql .= $morewhere; |
|
| 8523 | + } |
|
| 7718 | 8524 | $sql .= ' LIMIT 1'; // This is a fetch, to be sure to get only one record |
| 7719 | 8525 | |
| 7720 | 8526 | $res = $this->db->query($sql); |
@@ -7760,7 +8566,9 @@ discard block |
||
| 7760 | 8566 | $sql = 'SELECT '.$objectline->getFieldList(); |
| 7761 | 8567 | $sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element; |
| 7762 | 8568 | $sql .= ' WHERE fk_'.$this->element.' = '.$this->id; |
| 7763 | - if ($morewhere) $sql .= $morewhere; |
|
| 8569 | + if ($morewhere) { |
|
| 8570 | + $sql .= $morewhere; |
|
| 8571 | + } |
|
| 7764 | 8572 | if (isset($objectline->fields['position'])) { |
| 7765 | 8573 | $sql .= $this->db->order('position', 'ASC'); |
| 7766 | 8574 | } |
@@ -7809,10 +8617,17 @@ discard block |
||
| 7809 | 8617 | |
| 7810 | 8618 | $fieldvalues = $this->setSaveQuery(); |
| 7811 | 8619 | |
| 7812 | - if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); |
|
| 7813 | - if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; |
|
| 8620 | + if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) { |
|
| 8621 | + $fieldvalues['date_modification'] = $this->db->idate($now); |
|
| 8622 | + } |
|
| 8623 | + if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) { |
|
| 8624 | + $fieldvalues['fk_user_modif'] = $user->id; |
|
| 8625 | + } |
|
| 7814 | 8626 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. |
| 7815 | - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data |
|
| 8627 | + if (array_key_exists('ref', $fieldvalues)) { |
|
| 8628 | + $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); |
|
| 8629 | + } |
|
| 8630 | + // If field is a ref, we sanitize data |
|
| 7816 | 8631 | |
| 7817 | 8632 | $keys = array(); |
| 7818 | 8633 | $values = array(); |
@@ -7827,8 +8642,14 @@ discard block |
||
| 7827 | 8642 | // Clean and check mandatory |
| 7828 | 8643 | foreach ($keys as $key) |
| 7829 | 8644 | { |
| 7830 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field |
|
| 7831 | - if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; // This is an explicit foreign key field |
|
| 8645 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 8646 | + $values[$key] = ''; |
|
| 8647 | + } |
|
| 8648 | + // This is an implicit foreign key field |
|
| 8649 | + if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 8650 | + $values[$key] = ''; |
|
| 8651 | + } |
|
| 8652 | + // This is an explicit foreign key field |
|
| 7832 | 8653 | |
| 7833 | 8654 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7834 | 8655 | /* |
@@ -7897,11 +8718,13 @@ discard block |
||
| 7897 | 8718 | |
| 7898 | 8719 | $this->db->begin(); |
| 7899 | 8720 | |
| 7900 | - if ($forcechilddeletion) // Force also delete of childtables that should lock deletion in standard case when option force is off |
|
| 8721 | + if ($forcechilddeletion) { |
|
| 8722 | + // Force also delete of childtables that should lock deletion in standard case when option force is off |
|
| 7901 | 8723 | { |
| 7902 | 8724 | foreach ($this->childtables as $table) |
| 7903 | 8725 | { |
| 7904 | 8726 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; |
| 8727 | + } |
|
| 7905 | 8728 | $resql = $this->db->query($sql); |
| 7906 | 8729 | if (!$resql) |
| 7907 | 8730 | { |
@@ -7911,9 +8734,11 @@ discard block |
||
| 7911 | 8734 | return -1; |
| 7912 | 8735 | } |
| 7913 | 8736 | } |
| 7914 | - } elseif (!empty($this->fk_element) && !empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. |
|
| 8737 | + } elseif (!empty($this->fk_element) && !empty($this->childtables)) { |
|
| 8738 | + // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7915 | 8739 | { |
| 7916 | 8740 | $objectisused = $this->isObjectUsed($this->id); |
| 8741 | + } |
|
| 7917 | 8742 | if (!empty($objectisused)) |
| 7918 | 8743 | { |
| 7919 | 8744 | dol_syslog(get_class($this)."::deleteCommon Can't delete record as it has some child", LOG_WARNING); |
@@ -8082,7 +8907,9 @@ discard block |
||
| 8082 | 8907 | |
| 8083 | 8908 | // Call trigger |
| 8084 | 8909 | $result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); |
| 8085 | - if ($result < 0) return -1; |
|
| 8910 | + if ($result < 0) { |
|
| 8911 | + return -1; |
|
| 8912 | + } |
|
| 8086 | 8913 | // End call triggers |
| 8087 | 8914 | |
| 8088 | 8915 | $this->db->begin(); |
@@ -8152,7 +8979,9 @@ discard block |
||
| 8152 | 8979 | if (!$error && !$notrigger) { |
| 8153 | 8980 | // Call trigger |
| 8154 | 8981 | $result = $this->call_trigger($triggercode, $user); |
| 8155 | - if ($result < 0) $error++; |
|
| 8982 | + if ($result < 0) { |
|
| 8983 | + $error++; |
|
| 8984 | + } |
|
| 8156 | 8985 | } |
| 8157 | 8986 | |
| 8158 | 8987 | if (!$error) { |
@@ -8182,14 +9011,30 @@ discard block |
||
| 8182 | 9011 | global $user; |
| 8183 | 9012 | |
| 8184 | 9013 | $this->id = 0; |
| 8185 | - if (array_key_exists('label', $this->fields)) $this->label = 'This is label'; |
|
| 8186 | - if (array_key_exists('note_public', $this->fields)) $this->note_public = 'Public note'; |
|
| 8187 | - if (array_key_exists('note_private', $this->fields)) $this->note_private = 'Private note'; |
|
| 8188 | - if (array_key_exists('date_creation', $this->fields)) $this->date_creation = (dol_now() - 3600 * 24); |
|
| 8189 | - if (array_key_exists('date_modification', $this->fields)) $this->date_modification = (dol_now() - 3600 * 24); |
|
| 8190 | - if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat = $user->id; |
|
| 8191 | - if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif = $user->id; |
|
| 8192 | - if (array_key_exists('date', $this->fields)) $this->date = dol_now(); |
|
| 9014 | + if (array_key_exists('label', $this->fields)) { |
|
| 9015 | + $this->label = 'This is label'; |
|
| 9016 | + } |
|
| 9017 | + if (array_key_exists('note_public', $this->fields)) { |
|
| 9018 | + $this->note_public = 'Public note'; |
|
| 9019 | + } |
|
| 9020 | + if (array_key_exists('note_private', $this->fields)) { |
|
| 9021 | + $this->note_private = 'Private note'; |
|
| 9022 | + } |
|
| 9023 | + if (array_key_exists('date_creation', $this->fields)) { |
|
| 9024 | + $this->date_creation = (dol_now() - 3600 * 24); |
|
| 9025 | + } |
|
| 9026 | + if (array_key_exists('date_modification', $this->fields)) { |
|
| 9027 | + $this->date_modification = (dol_now() - 3600 * 24); |
|
| 9028 | + } |
|
| 9029 | + if (array_key_exists('fk_user_creat', $this->fields)) { |
|
| 9030 | + $this->fk_user_creat = $user->id; |
|
| 9031 | + } |
|
| 9032 | + if (array_key_exists('fk_user_modif', $this->fields)) { |
|
| 9033 | + $this->fk_user_modif = $user->id; |
|
| 9034 | + } |
|
| 9035 | + if (array_key_exists('date', $this->fields)) { |
|
| 9036 | + $this->date = dol_now(); |
|
| 9037 | + } |
|
| 8193 | 9038 | // ... |
| 8194 | 9039 | } |
| 8195 | 9040 | |
@@ -8233,7 +9078,9 @@ discard block |
||
| 8233 | 9078 | */ |
| 8234 | 9079 | public function trimParameters($parameters) |
| 8235 | 9080 | { |
| 8236 | - if (!is_array($parameters)) return; |
|
| 9081 | + if (!is_array($parameters)) { |
|
| 9082 | + return; |
|
| 9083 | + } |
|
| 8237 | 9084 | foreach ($parameters as $parameter) { |
| 8238 | 9085 | if (isset($this->$parameter)) { |
| 8239 | 9086 | $this->$parameter = trim($this->$parameter); |
@@ -8334,7 +9181,9 @@ discard block |
||
| 8334 | 9181 | { |
| 8335 | 9182 | $this->db->begin(); |
| 8336 | 9183 | |
| 8337 | - if (empty($type)) $type = $this->table_element; |
|
| 9184 | + if (empty($type)) { |
|
| 9185 | + $type = $this->table_element; |
|
| 9186 | + } |
|
| 8338 | 9187 | |
| 8339 | 9188 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 8340 | 9189 | $categorystatic = new Categorie($this->db); |
@@ -3549,106 +3549,106 @@ discard block |
||
| 3549 | 3549 | return $return; |
| 3550 | 3550 | } |
| 3551 | 3551 | |
| 3552 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3553 | - /** |
|
| 3554 | - * Load in cache list of transport mode |
|
| 3555 | - * |
|
| 3556 | - * @return int Nb of lines loaded, <0 if KO |
|
| 3557 | - */ |
|
| 3558 | - public function load_cache_transport_mode() |
|
| 3559 | - { |
|
| 3560 | - // phpcs:enable |
|
| 3561 | - global $langs; |
|
| 3562 | - |
|
| 3563 | - $num=count($this->cache_transport_mode); |
|
| 3564 | - if ($num > 0) return $num; // Cache already loaded |
|
| 3565 | - |
|
| 3566 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
| 3567 | - |
|
| 3568 | - $this->cache_transport_mode = array(); |
|
| 3569 | - |
|
| 3570 | - $sql = "SELECT rowid, code, label, active"; |
|
| 3571 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; |
|
| 3572 | - $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; |
|
| 3573 | - //if ($active >= 0) $sql.= " AND active = ".$active; |
|
| 3574 | - |
|
| 3575 | - $resql = $this->db->query($sql); |
|
| 3576 | - if ($resql) |
|
| 3577 | - { |
|
| 3578 | - $num = $this->db->num_rows($resql); |
|
| 3579 | - $i = 0; |
|
| 3580 | - while ($i < $num) |
|
| 3581 | - { |
|
| 3582 | - $obj = $this->db->fetch_object($resql); |
|
| 3583 | - |
|
| 3584 | - // If traduction exist, we use it else we take the default label |
|
| 3585 | - $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); |
|
| 3586 | - $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; |
|
| 3587 | - $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; |
|
| 3588 | - $this->cache_transport_mode[$obj->rowid]['label']= $label; |
|
| 3589 | - $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; |
|
| 3590 | - $i++; |
|
| 3591 | - } |
|
| 3552 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3553 | + /** |
|
| 3554 | + * Load in cache list of transport mode |
|
| 3555 | + * |
|
| 3556 | + * @return int Nb of lines loaded, <0 if KO |
|
| 3557 | + */ |
|
| 3558 | + public function load_cache_transport_mode() |
|
| 3559 | + { |
|
| 3560 | + // phpcs:enable |
|
| 3561 | + global $langs; |
|
| 3562 | + |
|
| 3563 | + $num=count($this->cache_transport_mode); |
|
| 3564 | + if ($num > 0) return $num; // Cache already loaded |
|
| 3565 | + |
|
| 3566 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
| 3567 | + |
|
| 3568 | + $this->cache_transport_mode = array(); |
|
| 3569 | + |
|
| 3570 | + $sql = "SELECT rowid, code, label, active"; |
|
| 3571 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; |
|
| 3572 | + $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; |
|
| 3573 | + //if ($active >= 0) $sql.= " AND active = ".$active; |
|
| 3574 | + |
|
| 3575 | + $resql = $this->db->query($sql); |
|
| 3576 | + if ($resql) |
|
| 3577 | + { |
|
| 3578 | + $num = $this->db->num_rows($resql); |
|
| 3579 | + $i = 0; |
|
| 3580 | + while ($i < $num) |
|
| 3581 | + { |
|
| 3582 | + $obj = $this->db->fetch_object($resql); |
|
| 3583 | + |
|
| 3584 | + // If traduction exist, we use it else we take the default label |
|
| 3585 | + $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); |
|
| 3586 | + $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; |
|
| 3587 | + $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; |
|
| 3588 | + $this->cache_transport_mode[$obj->rowid]['label']= $label; |
|
| 3589 | + $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; |
|
| 3590 | + $i++; |
|
| 3591 | + } |
|
| 3592 | + |
|
| 3593 | + $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); |
|
| 3594 | + |
|
| 3595 | + return $num; |
|
| 3596 | + } |
|
| 3597 | + else { |
|
| 3598 | + dol_print_error($this->db); |
|
| 3599 | + return -1; |
|
| 3600 | + } |
|
| 3601 | + } |
|
| 3602 | + |
|
| 3603 | + /** |
|
| 3604 | + * Return list of transport mode for intracomm report |
|
| 3605 | + * |
|
| 3606 | + * @param string $selected Id of the transport mode pre-selected |
|
| 3607 | + * @param string $htmlname Name of the select field |
|
| 3608 | + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code |
|
| 3609 | + * @param int $empty 1=can be empty, 0 else |
|
| 3610 | + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info |
|
| 3611 | + * @param int $maxlength Max length of label |
|
| 3612 | + * @param int $active Active or not, -1 = all |
|
| 3613 | + * @param string $morecss Add more CSS on select tag |
|
| 3614 | + * @return void |
|
| 3615 | + */ |
|
| 3616 | + public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') |
|
| 3617 | + { |
|
| 3618 | + global $langs,$user; |
|
| 3592 | 3619 | |
| 3593 | - $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); |
|
| 3594 | - |
|
| 3595 | - return $num; |
|
| 3596 | - } |
|
| 3597 | - else { |
|
| 3598 | - dol_print_error($this->db); |
|
| 3599 | - return -1; |
|
| 3600 | - } |
|
| 3601 | - } |
|
| 3602 | - |
|
| 3603 | - /** |
|
| 3604 | - * Return list of transport mode for intracomm report |
|
| 3605 | - * |
|
| 3606 | - * @param string $selected Id of the transport mode pre-selected |
|
| 3607 | - * @param string $htmlname Name of the select field |
|
| 3608 | - * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code |
|
| 3609 | - * @param int $empty 1=can be empty, 0 else |
|
| 3610 | - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info |
|
| 3611 | - * @param int $maxlength Max length of label |
|
| 3612 | - * @param int $active Active or not, -1 = all |
|
| 3613 | - * @param string $morecss Add more CSS on select tag |
|
| 3614 | - * @return void |
|
| 3615 | - */ |
|
| 3616 | - public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') |
|
| 3617 | - { |
|
| 3618 | - global $langs,$user; |
|
| 3619 | - |
|
| 3620 | - dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); |
|
| 3621 | - |
|
| 3622 | - $this->load_cache_transport_mode(); |
|
| 3623 | - |
|
| 3624 | - print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; |
|
| 3625 | - if ($empty) print '<option value=""> </option>'; |
|
| 3626 | - foreach ($this->cache_transport_mode as $id => $arraytypes) |
|
| 3627 | - { |
|
| 3628 | - // If not good status |
|
| 3629 | - if ($active >= 0 && $arraytypes['active'] != $active) continue; |
|
| 3630 | - |
|
| 3631 | - // We discard empty line if showempty is on because an empty line has already been output. |
|
| 3632 | - if ($empty && empty($arraytypes['code'])) continue; |
|
| 3633 | - |
|
| 3634 | - if ($format == 0) print '<option value="'.$id.'"'; |
|
| 3635 | - elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3636 | - elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3637 | - elseif ($format == 3) print '<option value="'.$id.'"'; |
|
| 3638 | - // If text is selected, we compare with code, else with id |
|
| 3639 | - if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected'; |
|
| 3640 | - elseif ($selected == $id) print ' selected'; |
|
| 3641 | - print '>'; |
|
| 3642 | - if ($format == 0) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3643 | - elseif ($format == 1) $value=$arraytypes['code']; |
|
| 3644 | - elseif ($format == 2) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3645 | - elseif ($format == 3) $value=$arraytypes['code']; |
|
| 3646 | - print $value?$value:' '; |
|
| 3647 | - print '</option>'; |
|
| 3648 | - } |
|
| 3649 | - print '</select>'; |
|
| 3650 | - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3651 | - } |
|
| 3620 | + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); |
|
| 3621 | + |
|
| 3622 | + $this->load_cache_transport_mode(); |
|
| 3623 | + |
|
| 3624 | + print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; |
|
| 3625 | + if ($empty) print '<option value=""> </option>'; |
|
| 3626 | + foreach ($this->cache_transport_mode as $id => $arraytypes) |
|
| 3627 | + { |
|
| 3628 | + // If not good status |
|
| 3629 | + if ($active >= 0 && $arraytypes['active'] != $active) continue; |
|
| 3630 | + |
|
| 3631 | + // We discard empty line if showempty is on because an empty line has already been output. |
|
| 3632 | + if ($empty && empty($arraytypes['code'])) continue; |
|
| 3633 | + |
|
| 3634 | + if ($format == 0) print '<option value="'.$id.'"'; |
|
| 3635 | + elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3636 | + elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3637 | + elseif ($format == 3) print '<option value="'.$id.'"'; |
|
| 3638 | + // If text is selected, we compare with code, else with id |
|
| 3639 | + if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected'; |
|
| 3640 | + elseif ($selected == $id) print ' selected'; |
|
| 3641 | + print '>'; |
|
| 3642 | + if ($format == 0) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3643 | + elseif ($format == 1) $value=$arraytypes['code']; |
|
| 3644 | + elseif ($format == 2) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3645 | + elseif ($format == 3) $value=$arraytypes['code']; |
|
| 3646 | + print $value?$value:' '; |
|
| 3647 | + print '</option>'; |
|
| 3648 | + } |
|
| 3649 | + print '</select>'; |
|
| 3650 | + if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3651 | + } |
|
| 3652 | 3652 | |
| 3653 | 3653 | /** |
| 3654 | 3654 | * Return a HTML select list of shipping mode |
@@ -4683,40 +4683,40 @@ discard block |
||
| 4683 | 4683 | } |
| 4684 | 4684 | } |
| 4685 | 4685 | |
| 4686 | - /** |
|
| 4687 | - * Show form with transport mode |
|
| 4688 | - * |
|
| 4689 | - * @param string $page Page |
|
| 4690 | - * @param int $selected Id mode pre-select |
|
| 4691 | - * @param string $htmlname Name of select html field |
|
| 4692 | - * @param int $active Active or not, -1 = all |
|
| 4693 | - * @param int $addempty 1=Add empty entry |
|
| 4694 | - * @return void |
|
| 4695 | - */ |
|
| 4696 | - public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) |
|
| 4697 | - { |
|
| 4698 | - global $langs; |
|
| 4699 | - if ($htmlname != "none") |
|
| 4700 | - { |
|
| 4701 | - print '<form method="POST" action="'.$page.'">'; |
|
| 4702 | - print '<input type="hidden" name="action" value="setmode">'; |
|
| 4703 | - print '<input type="hidden" name="token" value="'.newToken().'">'; |
|
| 4704 | - $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); |
|
| 4705 | - print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 4706 | - print '</form>'; |
|
| 4707 | - } |
|
| 4708 | - else { |
|
| 4709 | - if ($selected) |
|
| 4710 | - { |
|
| 4711 | - $this->load_cache_transport_mode(); |
|
| 4712 | - print $this->cache_transport_mode[$selected]['label']; |
|
| 4713 | - } else { |
|
| 4714 | - print " "; |
|
| 4715 | - } |
|
| 4716 | - } |
|
| 4717 | - } |
|
| 4686 | + /** |
|
| 4687 | + * Show form with transport mode |
|
| 4688 | + * |
|
| 4689 | + * @param string $page Page |
|
| 4690 | + * @param int $selected Id mode pre-select |
|
| 4691 | + * @param string $htmlname Name of select html field |
|
| 4692 | + * @param int $active Active or not, -1 = all |
|
| 4693 | + * @param int $addempty 1=Add empty entry |
|
| 4694 | + * @return void |
|
| 4695 | + */ |
|
| 4696 | + public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) |
|
| 4697 | + { |
|
| 4698 | + global $langs; |
|
| 4699 | + if ($htmlname != "none") |
|
| 4700 | + { |
|
| 4701 | + print '<form method="POST" action="'.$page.'">'; |
|
| 4702 | + print '<input type="hidden" name="action" value="setmode">'; |
|
| 4703 | + print '<input type="hidden" name="token" value="'.newToken().'">'; |
|
| 4704 | + $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); |
|
| 4705 | + print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 4706 | + print '</form>'; |
|
| 4707 | + } |
|
| 4708 | + else { |
|
| 4709 | + if ($selected) |
|
| 4710 | + { |
|
| 4711 | + $this->load_cache_transport_mode(); |
|
| 4712 | + print $this->cache_transport_mode[$selected]['label']; |
|
| 4713 | + } else { |
|
| 4714 | + print " "; |
|
| 4715 | + } |
|
| 4716 | + } |
|
| 4717 | + } |
|
| 4718 | 4718 | |
| 4719 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4719 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4720 | 4720 | /** |
| 4721 | 4721 | * Show form with multicurrency code |
| 4722 | 4722 | * |
@@ -3560,16 +3560,16 @@ discard block |
||
| 3560 | 3560 | // phpcs:enable |
| 3561 | 3561 | global $langs; |
| 3562 | 3562 | |
| 3563 | - $num=count($this->cache_transport_mode); |
|
| 3564 | - if ($num > 0) return $num; // Cache already loaded |
|
| 3563 | + $num = count($this->cache_transport_mode); |
|
| 3564 | + if ($num > 0) return $num; // Cache already loaded |
|
| 3565 | 3565 | |
| 3566 | 3566 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3567 | 3567 | |
| 3568 | 3568 | $this->cache_transport_mode = array(); |
| 3569 | 3569 | |
| 3570 | 3570 | $sql = "SELECT rowid, code, label, active"; |
| 3571 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; |
|
| 3572 | - $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; |
|
| 3571 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; |
|
| 3572 | + $sql .= " WHERE entity IN (".getEntity('c_transport_mode').")"; |
|
| 3573 | 3573 | //if ($active >= 0) $sql.= " AND active = ".$active; |
| 3574 | 3574 | |
| 3575 | 3575 | $resql = $this->db->query($sql); |
@@ -3582,10 +3582,10 @@ discard block |
||
| 3582 | 3582 | $obj = $this->db->fetch_object($resql); |
| 3583 | 3583 | |
| 3584 | 3584 | // If traduction exist, we use it else we take the default label |
| 3585 | - $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); |
|
| 3585 | + $label = ($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) != ("PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); |
|
| 3586 | 3586 | $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; |
| 3587 | 3587 | $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; |
| 3588 | - $this->cache_transport_mode[$obj->rowid]['label']= $label; |
|
| 3588 | + $this->cache_transport_mode[$obj->rowid]['label'] = $label; |
|
| 3589 | 3589 | $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; |
| 3590 | 3590 | $i++; |
| 3591 | 3591 | } |
@@ -3615,13 +3615,13 @@ discard block |
||
| 3615 | 3615 | */ |
| 3616 | 3616 | public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') |
| 3617 | 3617 | { |
| 3618 | - global $langs,$user; |
|
| 3618 | + global $langs, $user; |
|
| 3619 | 3619 | |
| 3620 | 3620 | dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); |
| 3621 | 3621 | |
| 3622 | 3622 | $this->load_cache_transport_mode(); |
| 3623 | 3623 | |
| 3624 | - print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; |
|
| 3624 | + print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
|
| 3625 | 3625 | if ($empty) print '<option value=""> </option>'; |
| 3626 | 3626 | foreach ($this->cache_transport_mode as $id => $arraytypes) |
| 3627 | 3627 | { |
@@ -3639,15 +3639,15 @@ discard block |
||
| 3639 | 3639 | if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected'; |
| 3640 | 3640 | elseif ($selected == $id) print ' selected'; |
| 3641 | 3641 | print '>'; |
| 3642 | - if ($format == 0) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3643 | - elseif ($format == 1) $value=$arraytypes['code']; |
|
| 3644 | - elseif ($format == 2) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3645 | - elseif ($format == 3) $value=$arraytypes['code']; |
|
| 3646 | - print $value?$value:' '; |
|
| 3642 | + if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3643 | + elseif ($format == 1) $value = $arraytypes['code']; |
|
| 3644 | + elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3645 | + elseif ($format == 3) $value = $arraytypes['code']; |
|
| 3646 | + print $value ? $value : ' '; |
|
| 3647 | 3647 | print '</option>'; |
| 3648 | 3648 | } |
| 3649 | 3649 | print '</select>'; |
| 3650 | - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3650 | + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3651 | 3651 | } |
| 3652 | 3652 | |
| 3653 | 3653 | /** |
@@ -6590,7 +6590,7 @@ discard block |
||
| 6590 | 6590 | templateSelection: formatSelection /* For 4.0 */ |
| 6591 | 6591 | }); |
| 6592 | 6592 | });'."\n"; |
| 6593 | - } elseif ($addjscombo == 2 && ! defined('DISABLE_MULTISELECT')) |
|
| 6593 | + } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) |
|
| 6594 | 6594 | { |
| 6595 | 6595 | // Add other js lib |
| 6596 | 6596 | // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin |
@@ -117,40 +117,70 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $tmp = explode(':', $typeofdata); |
| 119 | 119 | $ret .= '<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ? ' '.$tmp[1] : '').'" id="'.$htmlname.'">'; |
| 120 | - if ($fieldrequired) $ret .= '<span class="fieldrequired">'; |
|
| 120 | + if ($fieldrequired) { |
|
| 121 | + $ret .= '<span class="fieldrequired">'; |
|
| 122 | + } |
|
| 121 | 123 | if ($help) { |
| 122 | 124 | $ret .= $this->textwithpicto($langs->trans($text), $help); |
| 123 | 125 | } else { |
| 124 | 126 | $ret .= $langs->trans($text); |
| 125 | 127 | } |
| 126 | - if ($fieldrequired) $ret .= '</span>'; |
|
| 128 | + if ($fieldrequired) { |
|
| 129 | + $ret .= '</span>'; |
|
| 130 | + } |
|
| 127 | 131 | $ret .= '</div>'."\n"; |
| 128 | 132 | } else { |
| 129 | - if ($fieldrequired) $ret .= '<span class="fieldrequired">'; |
|
| 133 | + if ($fieldrequired) { |
|
| 134 | + $ret .= '<span class="fieldrequired">'; |
|
| 135 | + } |
|
| 130 | 136 | if ($help) { |
| 131 | 137 | $ret .= $this->textwithpicto($langs->trans($text), $help); |
| 132 | 138 | } else { |
| 133 | 139 | $ret .= $langs->trans($text); |
| 134 | 140 | } |
| 135 | - if ($fieldrequired) $ret .= '</span>'; |
|
| 141 | + if ($fieldrequired) { |
|
| 142 | + $ret .= '</span>'; |
|
| 143 | + } |
|
| 136 | 144 | } |
| 137 | 145 | } else { |
| 138 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; |
|
| 139 | - if ($fieldrequired) $ret .= '<span class="fieldrequired">'; |
|
| 146 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 147 | + $ret .= '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; |
|
| 148 | + } |
|
| 149 | + if ($fieldrequired) { |
|
| 150 | + $ret .= '<span class="fieldrequired">'; |
|
| 151 | + } |
|
| 140 | 152 | if ($help) { |
| 141 | 153 | $ret .= $this->textwithpicto($langs->trans($text), $help); |
| 142 | 154 | } else { |
| 143 | 155 | $ret .= $langs->trans($text); |
| 144 | 156 | } |
| 145 | - if ($fieldrequired) $ret .= '</span>'; |
|
| 146 | - if (!empty($notabletag)) $ret .= ' '; |
|
| 147 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</td>'; |
|
| 148 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<td class="right">'; |
|
| 149 | - if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&'.$paramid.'='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>'; |
|
| 150 | - if (!empty($notabletag) && $notabletag == 1) $ret .= ' : '; |
|
| 151 | - if (!empty($notabletag) && $notabletag == 3) $ret .= ' '; |
|
| 152 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</td>'; |
|
| 153 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</tr></table>'; |
|
| 157 | + if ($fieldrequired) { |
|
| 158 | + $ret .= '</span>'; |
|
| 159 | + } |
|
| 160 | + if (!empty($notabletag)) { |
|
| 161 | + $ret .= ' '; |
|
| 162 | + } |
|
| 163 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 164 | + $ret .= '</td>'; |
|
| 165 | + } |
|
| 166 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 167 | + $ret .= '<td class="right">'; |
|
| 168 | + } |
|
| 169 | + if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 170 | + $ret .= '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&'.$paramid.'='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>'; |
|
| 171 | + } |
|
| 172 | + if (!empty($notabletag) && $notabletag == 1) { |
|
| 173 | + $ret .= ' : '; |
|
| 174 | + } |
|
| 175 | + if (!empty($notabletag) && $notabletag == 3) { |
|
| 176 | + $ret .= ' '; |
|
| 177 | + } |
|
| 178 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 179 | + $ret .= '</td>'; |
|
| 180 | + } |
|
| 181 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { |
|
| 182 | + $ret .= '</tr></table>'; |
|
| 183 | + } |
|
| 154 | 184 | } |
| 155 | 185 | |
| 156 | 186 | return $ret; |
@@ -181,12 +211,16 @@ discard block |
||
| 181 | 211 | $ret = ''; |
| 182 | 212 | |
| 183 | 213 | // Check parameters |
| 184 | - if (empty($typeofdata)) return 'ErrorBadParameter'; |
|
| 214 | + if (empty($typeofdata)) { |
|
| 215 | + return 'ErrorBadParameter'; |
|
| 216 | + } |
|
| 185 | 217 | |
| 186 | 218 | // When option to edit inline is activated |
| 187 | - if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) // TODO add jquery timepicker and support select |
|
| 219 | + if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) { |
|
| 220 | + // TODO add jquery timepicker and support select |
|
| 188 | 221 | { |
| 189 | 222 | $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg); |
| 223 | + } |
|
| 190 | 224 | } else { |
| 191 | 225 | if (GETPOST('action', 'aZ09') == 'edit'.$htmlname) |
| 192 | 226 | { |
@@ -195,8 +229,12 @@ discard block |
||
| 195 | 229 | $ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">'; |
| 196 | 230 | $ret .= '<input type="hidden" name="token" value="'.newToken().'">'; |
| 197 | 231 | $ret .= '<input type="hidden" name="'.$paramid.'" value="'.$object->id.'">'; |
| 198 | - if (empty($notabletag)) $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">'; |
|
| 199 | - if (empty($notabletag)) $ret .= '<tr><td>'; |
|
| 232 | + if (empty($notabletag)) { |
|
| 233 | + $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">'; |
|
| 234 | + } |
|
| 235 | + if (empty($notabletag)) { |
|
| 236 | + $ret .= '<tr><td>'; |
|
| 237 | + } |
|
| 200 | 238 | if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) |
| 201 | 239 | { |
| 202 | 240 | $tmp = explode(':', $typeofdata); |
@@ -206,9 +244,11 @@ discard block |
||
| 206 | 244 | $tmp = explode(':', $typeofdata); |
| 207 | 245 | $valuetoshow = price2num($editvalue ? $editvalue : $value); |
| 208 | 246 | $ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ?price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>'; |
| 209 | - } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) // if wysiwyg is enabled $typeofdata = 'ckeditor' |
|
| 247 | + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { |
|
| 248 | + // if wysiwyg is enabled $typeofdata = 'ckeditor' |
|
| 210 | 249 | { |
| 211 | 250 | $tmp = explode(':', $typeofdata); |
| 251 | + } |
|
| 212 | 252 | $cols = $tmp[2]; |
| 213 | 253 | $morealt = ''; |
| 214 | 254 | if (preg_match('/%/', $cols)) |
@@ -248,25 +288,41 @@ discard block |
||
| 248 | 288 | $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), (isset($tmp[8]) ? ($tmp[8] ?true:false) : true), true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100')); |
| 249 | 289 | $ret .= $doleditor->Create(1); |
| 250 | 290 | } |
| 251 | - if (empty($notabletag)) $ret .= '</td>'; |
|
| 291 | + if (empty($notabletag)) { |
|
| 292 | + $ret .= '</td>'; |
|
| 293 | + } |
|
| 252 | 294 | |
| 253 | - if (empty($notabletag)) $ret .= '<td class="left">'; |
|
| 295 | + if (empty($notabletag)) { |
|
| 296 | + $ret .= '<td class="left">'; |
|
| 297 | + } |
|
| 254 | 298 | //else $ret.='<div class="clearboth"></div>'; |
| 255 | 299 | $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">'; |
| 256 | - if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .= '<br>'."\n"; |
|
| 300 | + if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) { |
|
| 301 | + $ret .= '<br>'."\n"; |
|
| 302 | + } |
|
| 257 | 303 | $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">'; |
| 258 | - if (empty($notabletag)) $ret .= '</td>'; |
|
| 304 | + if (empty($notabletag)) { |
|
| 305 | + $ret .= '</td>'; |
|
| 306 | + } |
|
| 259 | 307 | |
| 260 | - if (empty($notabletag)) $ret .= '</tr></table>'."\n"; |
|
| 308 | + if (empty($notabletag)) { |
|
| 309 | + $ret .= '</tr></table>'."\n"; |
|
| 310 | + } |
|
| 261 | 311 | $ret .= '</form>'."\n"; |
| 262 | 312 | } else { |
| 263 | - if (preg_match('/^(email)/', $typeofdata)) $ret .= dol_print_email($value, 0, 0, 0, 0, 1); |
|
| 264 | - elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); |
|
| 265 | - elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value); |
|
| 266 | - elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value); |
|
| 267 | - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= dol_print_date($value, 'day'); |
|
| 268 | - elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= dol_print_date($value, 'dayhour'); |
|
| 269 | - elseif (preg_match('/^select;/', $typeofdata)) |
|
| 313 | + if (preg_match('/^(email)/', $typeofdata)) { |
|
| 314 | + $ret .= dol_print_email($value, 0, 0, 0, 0, 1); |
|
| 315 | + } elseif (preg_match('/^(amount|numeric)/', $typeofdata)) { |
|
| 316 | + $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); |
|
| 317 | + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { |
|
| 318 | + $ret .= dol_htmlentitiesbr($value); |
|
| 319 | + } elseif (preg_match('/^safehtmlstring/', $typeofdata)) { |
|
| 320 | + $ret .= dol_string_onlythesehtmltags($value); |
|
| 321 | + } elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') { |
|
| 322 | + $ret .= dol_print_date($value, 'day'); |
|
| 323 | + } elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') { |
|
| 324 | + $ret .= dol_print_date($value, 'dayhour'); |
|
| 325 | + } elseif (preg_match('/^select;/', $typeofdata)) |
|
| 270 | 326 | { |
| 271 | 327 | $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata)); |
| 272 | 328 | $arraylist = array(); |
@@ -320,7 +376,9 @@ discard block |
||
| 320 | 376 | |
| 321 | 377 | // List of extra languages |
| 322 | 378 | $arrayoflangcode = array(); |
| 323 | - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 379 | + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) { |
|
| 380 | + $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 381 | + } |
|
| 324 | 382 | |
| 325 | 383 | if (is_array($arrayoflangcode) && count($arrayoflangcode)) { |
| 326 | 384 | if (!is_object($extralanguages)) { |
@@ -392,9 +450,13 @@ discard block |
||
| 392 | 450 | $out = ''; |
| 393 | 451 | |
| 394 | 452 | // Check parameters |
| 395 | - if (preg_match('/^text/', $inputType)) $value = dol_nl2br($value); |
|
| 396 | - elseif (preg_match('/^numeric/', $inputType)) $value = price($value); |
|
| 397 | - elseif ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day'); |
|
| 453 | + if (preg_match('/^text/', $inputType)) { |
|
| 454 | + $value = dol_nl2br($value); |
|
| 455 | + } elseif (preg_match('/^numeric/', $inputType)) { |
|
| 456 | + $value = price($value); |
|
| 457 | + } elseif ($inputType == 'day' || $inputType == 'datepicker') { |
|
| 458 | + $value = dol_print_date($value, 'day'); |
|
| 459 | + } |
|
| 398 | 460 | |
| 399 | 461 | if ($condition) |
| 400 | 462 | { |
@@ -423,23 +485,35 @@ discard block |
||
| 423 | 485 | { |
| 424 | 486 | $tmp = explode(':', $inputType); |
| 425 | 487 | $inputType = $tmp[0]; |
| 426 | - if (!empty($tmp[1])) $inputOption = $tmp[1]; |
|
| 427 | - if (!empty($tmp[2])) $savemethod = $tmp[2]; |
|
| 488 | + if (!empty($tmp[1])) { |
|
| 489 | + $inputOption = $tmp[1]; |
|
| 490 | + } |
|
| 491 | + if (!empty($tmp[2])) { |
|
| 492 | + $savemethod = $tmp[2]; |
|
| 493 | + } |
|
| 428 | 494 | $out .= '<input id="width_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n"; |
| 429 | 495 | } elseif ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) |
| 430 | 496 | { |
| 431 | 497 | $tmp = explode(':', $inputType); |
| 432 | 498 | $inputType = $tmp[0]; |
| 433 | - if (!empty($tmp[1])) $inputOption = $tmp[1]; |
|
| 434 | - if (!empty($tmp[2])) $savemethod = $tmp[2]; |
|
| 499 | + if (!empty($tmp[1])) { |
|
| 500 | + $inputOption = $tmp[1]; |
|
| 501 | + } |
|
| 502 | + if (!empty($tmp[2])) { |
|
| 503 | + $savemethod = $tmp[2]; |
|
| 504 | + } |
|
| 435 | 505 | |
| 436 | 506 | $out .= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format |
| 437 | 507 | } elseif (preg_match('/^(select|autocomplete)/', $inputType)) |
| 438 | 508 | { |
| 439 | 509 | $tmp = explode(':', $inputType); |
| 440 | 510 | $inputType = $tmp[0]; $loadmethod = $tmp[1]; |
| 441 | - if (!empty($tmp[2])) $savemethod = $tmp[2]; |
|
| 442 | - if (!empty($tmp[3])) $button_only = true; |
|
| 511 | + if (!empty($tmp[2])) { |
|
| 512 | + $savemethod = $tmp[2]; |
|
| 513 | + } |
|
| 514 | + if (!empty($tmp[3])) { |
|
| 515 | + $button_only = true; |
|
| 516 | + } |
|
| 443 | 517 | } elseif (preg_match('/^textarea/', $inputType)) |
| 444 | 518 | { |
| 445 | 519 | $tmp = explode(':', $inputType); |
@@ -450,9 +524,15 @@ discard block |
||
| 450 | 524 | { |
| 451 | 525 | $tmp = explode(':', $inputType); |
| 452 | 526 | $inputType = $tmp[0]; $toolbar = $tmp[1]; |
| 453 | - if (!empty($tmp[2])) $width = $tmp[2]; |
|
| 454 | - if (!empty($tmp[3])) $heigth = $tmp[3]; |
|
| 455 | - if (!empty($tmp[4])) $savemethod = $tmp[4]; |
|
| 527 | + if (!empty($tmp[2])) { |
|
| 528 | + $width = $tmp[2]; |
|
| 529 | + } |
|
| 530 | + if (!empty($tmp[3])) { |
|
| 531 | + $heigth = $tmp[3]; |
|
| 532 | + } |
|
| 533 | + if (!empty($tmp[4])) { |
|
| 534 | + $savemethod = $tmp[4]; |
|
| 535 | + } |
|
| 456 | 536 | |
| 457 | 537 | if (!empty($conf->fckeditor->enabled)) |
| 458 | 538 | { |
@@ -466,17 +546,25 @@ discard block |
||
| 466 | 546 | $out .= '<input id="table_element_'.$htmlname.'" value="'.$table_element.'" type="hidden"/>'."\n"; |
| 467 | 547 | $out .= '<input id="fk_element_'.$htmlname.'" value="'.$fk_element.'" type="hidden"/>'."\n"; |
| 468 | 548 | $out .= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n"; |
| 469 | - if (!empty($savemethod)) $out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n"; |
|
| 470 | - if (!empty($ext_element)) $out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n"; |
|
| 549 | + if (!empty($savemethod)) { |
|
| 550 | + $out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n"; |
|
| 551 | + } |
|
| 552 | + if (!empty($ext_element)) { |
|
| 553 | + $out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n"; |
|
| 554 | + } |
|
| 471 | 555 | if (!empty($custommsg)) |
| 472 | 556 | { |
| 473 | 557 | if (is_array($custommsg)) |
| 474 | 558 | { |
| 475 | - if (!empty($custommsg['success'])) |
|
| 476 | - $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n"; |
|
| 477 | - if (!empty($custommsg['error'])) |
|
| 478 | - $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n"; |
|
| 479 | - } else $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n"; |
|
| 559 | + if (!empty($custommsg['success'])) { |
|
| 560 | + $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n"; |
|
| 561 | + } |
|
| 562 | + if (!empty($custommsg['error'])) { |
|
| 563 | + $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n"; |
|
| 564 | + } |
|
| 565 | + } else { |
|
| 566 | + $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n"; |
|
| 567 | + } |
|
| 480 | 568 | } |
| 481 | 569 | if ($inputType == 'textarea') { |
| 482 | 570 | $out .= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n"; |
@@ -512,12 +600,20 @@ discard block |
||
| 512 | 600 | */ |
| 513 | 601 | public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) |
| 514 | 602 | { |
| 515 | - if ($incbefore) $text = $incbefore.$text; |
|
| 516 | - if (!$htmltext) return $text; |
|
| 603 | + if ($incbefore) { |
|
| 604 | + $text = $incbefore.$text; |
|
| 605 | + } |
|
| 606 | + if (!$htmltext) { |
|
| 607 | + return $text; |
|
| 608 | + } |
|
| 517 | 609 | |
| 518 | 610 | $tag = 'td'; |
| 519 | - if ($notabs == 2) $tag = 'div'; |
|
| 520 | - if ($notabs == 3) $tag = 'span'; |
|
| 611 | + if ($notabs == 2) { |
|
| 612 | + $tag = 'div'; |
|
| 613 | + } |
|
| 614 | + if ($notabs == 3) { |
|
| 615 | + $tag = 'span'; |
|
| 616 | + } |
|
| 521 | 617 | // Sanitize tooltip |
| 522 | 618 | $htmltext = str_replace(array("\r", "\n"), '', $htmltext); |
| 523 | 619 | |
@@ -539,17 +635,36 @@ discard block |
||
| 539 | 635 | if ($tooltipon == 2 || $tooltipon == 3) |
| 540 | 636 | { |
| 541 | 637 | $paramfortooltipimg = ' class="'.$classfortooltip.($notabs != 3 ? ' inline-block' : '').($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"'; |
| 542 | - if ($tooltiptrigger == '') $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip |
|
| 543 | - else $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"'; |
|
| 544 | - } else $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag |
|
| 638 | + if ($tooltiptrigger == '') { |
|
| 639 | + $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; |
|
| 640 | + } |
|
| 641 | + // Attribut to put on img tag to store tooltip |
|
| 642 | + else { |
|
| 643 | + $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"'; |
|
| 644 | + } |
|
| 645 | + } else { |
|
| 646 | + $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); |
|
| 647 | + } |
|
| 648 | + // Attribut to put on td text tag |
|
| 545 | 649 | if ($tooltipon == 1 || $tooltipon == 3) |
| 546 | 650 | { |
| 547 | 651 | $paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" '; |
| 548 | - if ($tooltiptrigger == '') $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip |
|
| 549 | - else $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"'; |
|
| 550 | - } else $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag |
|
| 551 | - if (empty($notabs)) $s .= '<table class="nobordernopadding"><tr style="height: auto;">'; |
|
| 552 | - elseif ($notabs == 2) $s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">'; |
|
| 652 | + if ($tooltiptrigger == '') { |
|
| 653 | + $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; |
|
| 654 | + } |
|
| 655 | + // Attribut to put on td tag to store tooltip |
|
| 656 | + else { |
|
| 657 | + $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"'; |
|
| 658 | + } |
|
| 659 | + } else { |
|
| 660 | + $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); |
|
| 661 | + } |
|
| 662 | + // Attribut to put on td text tag |
|
| 663 | + if (empty($notabs)) { |
|
| 664 | + $s .= '<table class="nobordernopadding"><tr style="height: auto;">'; |
|
| 665 | + } elseif ($notabs == 2) { |
|
| 666 | + $s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">'; |
|
| 667 | + } |
|
| 553 | 668 | // Define value if value is before |
| 554 | 669 | if ($direction < 0) { |
| 555 | 670 | $s .= '<'.$tag.$paramfortooltipimg; |
@@ -560,15 +675,22 @@ discard block |
||
| 560 | 675 | } |
| 561 | 676 | // Use another method to help avoid having a space in value in order to use this value with jquery |
| 562 | 677 | // Define label |
| 563 | - if ((string) $text != '') $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>'; |
|
| 678 | + if ((string) $text != '') { |
|
| 679 | + $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>'; |
|
| 680 | + } |
|
| 564 | 681 | // Define value if value is after |
| 565 | 682 | if ($direction > 0) { |
| 566 | 683 | $s .= '<'.$tag.$paramfortooltipimg; |
| 567 | - if ($tag == 'td') $s .= ' class="valignmiddle" width="14"'; |
|
| 684 | + if ($tag == 'td') { |
|
| 685 | + $s .= ' class="valignmiddle" width="14"'; |
|
| 686 | + } |
|
| 568 | 687 | $s .= '>'.$textfordialog.$img.'</'.$tag.'>'; |
| 569 | 688 | } |
| 570 | - if (empty($notabs)) $s .= '</tr></table>'; |
|
| 571 | - elseif ($notabs == 2) $s .= '</div>'; |
|
| 689 | + if (empty($notabs)) { |
|
| 690 | + $s .= '</tr></table>'; |
|
| 691 | + } elseif ($notabs == 2) { |
|
| 692 | + $s .= '</div>'; |
|
| 693 | + } |
|
| 572 | 694 | |
| 573 | 695 | return $s; |
| 574 | 696 | } |
@@ -592,17 +714,23 @@ discard block |
||
| 592 | 714 | global $conf, $langs; |
| 593 | 715 | |
| 594 | 716 | $alt = ''; |
| 595 | - if ($tooltiptrigger) $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); |
|
| 717 | + if ($tooltiptrigger) { |
|
| 718 | + $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); |
|
| 719 | + } |
|
| 596 | 720 | |
| 597 | 721 | //For backwards compatibility |
| 598 | - if ($type == '0') $type = 'info'; |
|
| 599 | - elseif ($type == '1') $type = 'help'; |
|
| 722 | + if ($type == '0') { |
|
| 723 | + $type = 'info'; |
|
| 724 | + } elseif ($type == '1') { |
|
| 725 | + $type = 'help'; |
|
| 726 | + } |
|
| 600 | 727 | |
| 601 | 728 | // If info or help with no javascript, show only text |
| 602 | 729 | if (empty($conf->use_javascript_ajax)) |
| 603 | 730 | { |
| 604 | - if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') return $text; |
|
| 605 | - else { |
|
| 731 | + if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { |
|
| 732 | + return $text; |
|
| 733 | + } else { |
|
| 606 | 734 | $alt = $htmltext; |
| 607 | 735 | $htmltext = ''; |
| 608 | 736 | } |
@@ -611,7 +739,9 @@ discard block |
||
| 611 | 739 | // If info or help with smartphone, show only text (tooltip hover can't works) |
| 612 | 740 | if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) |
| 613 | 741 | { |
| 614 | - if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') return $text; |
|
| 742 | + if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { |
|
| 743 | + return $text; |
|
| 744 | + } |
|
| 615 | 745 | } |
| 616 | 746 | // If info or help with smartphone, show only text (tooltip on click does not works with dialog on smaprtphone) |
| 617 | 747 | //if (! empty($conf->dol_no_mouse_hover) && ! empty($tooltiptrigger)) |
@@ -620,13 +750,22 @@ discard block |
||
| 620 | 750 | //} |
| 621 | 751 | |
| 622 | 752 | $img = ''; |
| 623 | - if ($type == 'info') $img = img_help(0, $alt); |
|
| 624 | - elseif ($type == 'help') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 625 | - elseif ($type == 'helpclickable') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 626 | - elseif ($type == 'superadmin') $img = img_picto($alt, 'redstar'); |
|
| 627 | - elseif ($type == 'admin') $img = img_picto($alt, 'star'); |
|
| 628 | - elseif ($type == 'warning') $img = img_warning($alt); |
|
| 629 | - elseif ($type != 'none') $img = img_picto($alt, $type); // $type can be an image path |
|
| 753 | + if ($type == 'info') { |
|
| 754 | + $img = img_help(0, $alt); |
|
| 755 | + } elseif ($type == 'help') { |
|
| 756 | + $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 757 | + } elseif ($type == 'helpclickable') { |
|
| 758 | + $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 759 | + } elseif ($type == 'superadmin') { |
|
| 760 | + $img = img_picto($alt, 'redstar'); |
|
| 761 | + } elseif ($type == 'admin') { |
|
| 762 | + $img = img_picto($alt, 'star'); |
|
| 763 | + } elseif ($type == 'warning') { |
|
| 764 | + $img = img_warning($alt); |
|
| 765 | + } elseif ($type != 'none') { |
|
| 766 | + $img = img_picto($alt, $type); |
|
| 767 | + } |
|
| 768 | + // $type can be an image path |
|
| 630 | 769 | |
| 631 | 770 | return $this->textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap); |
| 632 | 771 | } |
@@ -654,7 +793,9 @@ discard block |
||
| 654 | 793 | $parameters = array(); |
| 655 | 794 | $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook |
| 656 | 795 | // check if there is a mass action |
| 657 | - if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) return; |
|
| 796 | + if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) { |
|
| 797 | + return; |
|
| 798 | + } |
|
| 658 | 799 | if (empty($reshook)) |
| 659 | 800 | { |
| 660 | 801 | $ret .= '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>-- '.$langs->trans("SelectAction").' --</option>'; |
@@ -667,7 +808,9 @@ discard block |
||
| 667 | 808 | |
| 668 | 809 | $ret .= '</select>'; |
| 669 | 810 | |
| 670 | - if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select'); |
|
| 811 | + if (empty($conf->dol_optimize_smallscreen)) { |
|
| 812 | + $ret .= ajax_combobox('.'.$name.'select'); |
|
| 813 | + } |
|
| 671 | 814 | |
| 672 | 815 | // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button |
| 673 | 816 | $ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER. |
@@ -795,20 +938,27 @@ discard block |
||
| 795 | 938 | $i++; |
| 796 | 939 | } |
| 797 | 940 | |
| 798 | - if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); |
|
| 799 | - else $countryArray = dol_sort_array($countryArray, 'label'); |
|
| 941 | + if (empty($disablefavorites)) { |
|
| 942 | + array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); |
|
| 943 | + } else { |
|
| 944 | + $countryArray = dol_sort_array($countryArray, 'label'); |
|
| 945 | + } |
|
| 800 | 946 | |
| 801 | 947 | if ($showempty) |
| 802 | 948 | { |
| 803 | 949 | $out .= '<option value=""> </option>'."\n"; |
| 804 | 950 | } |
| 805 | 951 | |
| 806 | - if ($addspecialentries) // Add dedicated entries for groups of countries |
|
| 952 | + if ($addspecialentries) { |
|
| 953 | + // Add dedicated entries for groups of countries |
|
| 807 | 954 | { |
| 808 | 955 | //if ($showempty) $out.= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; |
| 809 | 956 | $out .= '<option value="special_allnotme"'.($selected == 'special_allnotme' ? ' selected' : '').'>'.$langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>'; |
| 957 | + } |
|
| 810 | 958 | $out .= '<option value="special_eec"'.($selected == 'special_eec' ? ' selected' : '').'>'.$langs->trans("CountriesInEEC").'</option>'; |
| 811 | - if ($mysoc->isInEEC()) $out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>'; |
|
| 959 | + if ($mysoc->isInEEC()) { |
|
| 960 | + $out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>'; |
|
| 961 | + } |
|
| 812 | 962 | $out .= '<option value="special_noteec"'.($selected == 'special_noteec' ? ' selected' : '').'>'.$langs->trans("CountriesNotInEEC").'</option>'; |
| 813 | 963 | $out .= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; |
| 814 | 964 | } |
@@ -816,10 +966,17 @@ discard block |
||
| 816 | 966 | foreach ($countryArray as $row) |
| 817 | 967 | { |
| 818 | 968 | //if (empty($showempty) && empty($row['rowid'])) continue; |
| 819 | - if (empty($row['rowid'])) continue; |
|
| 820 | - if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) continue; // exclude some countries |
|
| 969 | + if (empty($row['rowid'])) { |
|
| 970 | + continue; |
|
| 971 | + } |
|
| 972 | + if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) { |
|
| 973 | + continue; |
|
| 974 | + } |
|
| 975 | + // exclude some countries |
|
| 821 | 976 | |
| 822 | - if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++; |
|
| 977 | + if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) { |
|
| 978 | + $atleastonefavorite++; |
|
| 979 | + } |
|
| 823 | 980 | if (empty($row['favorite']) && $atleastonefavorite) |
| 824 | 981 | { |
| 825 | 982 | $atleastonefavorite = 0; |
@@ -832,9 +989,14 @@ discard block |
||
| 832 | 989 | } else { |
| 833 | 990 | $out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'">'; |
| 834 | 991 | } |
| 835 | - if ($row['label']) $out .= dol_trunc($row['label'], $maxlength, 'middle'); |
|
| 836 | - else $out .= ' '; |
|
| 837 | - if ($row['code_iso']) $out .= ' ('.$row['code_iso'].')'; |
|
| 992 | + if ($row['label']) { |
|
| 993 | + $out .= dol_trunc($row['label'], $maxlength, 'middle'); |
|
| 994 | + } else { |
|
| 995 | + $out .= ' '; |
|
| 996 | + } |
|
| 997 | + if ($row['code_iso']) { |
|
| 998 | + $out .= ' ('.$row['code_iso'].')'; |
|
| 999 | + } |
|
| 838 | 1000 | $out .= '</option>'; |
| 839 | 1001 | } |
| 840 | 1002 | } |
@@ -920,7 +1082,9 @@ discard block |
||
| 920 | 1082 | $out .= '<option value="'.$row['rowid'].'">'; |
| 921 | 1083 | } |
| 922 | 1084 | |
| 923 | - if ($row['code']) $out .= $row['code']; |
|
| 1085 | + if ($row['code']) { |
|
| 1086 | + $out .= $row['code']; |
|
| 1087 | + } |
|
| 924 | 1088 | |
| 925 | 1089 | $out .= '</option>'; |
| 926 | 1090 | } |
@@ -961,21 +1125,29 @@ discard block |
||
| 961 | 1125 | if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled)) |
| 962 | 1126 | || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) |
| 963 | 1127 | { |
| 964 | - if (empty($hidetext)) print $langs->trans("Type").': '; |
|
| 1128 | + if (empty($hidetext)) { |
|
| 1129 | + print $langs->trans("Type").': '; |
|
| 1130 | + } |
|
| 965 | 1131 | print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; |
| 966 | 1132 | if ($showempty) |
| 967 | 1133 | { |
| 968 | 1134 | print '<option value="-1"'; |
| 969 | - if ($selected == -1) print ' selected'; |
|
| 1135 | + if ($selected == -1) { |
|
| 1136 | + print ' selected'; |
|
| 1137 | + } |
|
| 970 | 1138 | print '> </option>'; |
| 971 | 1139 | } |
| 972 | 1140 | |
| 973 | 1141 | print '<option value="0"'; |
| 974 | - if (0 == $selected) print ' selected'; |
|
| 1142 | + if (0 == $selected) { |
|
| 1143 | + print ' selected'; |
|
| 1144 | + } |
|
| 975 | 1145 | print '>'.$langs->trans("Product"); |
| 976 | 1146 | |
| 977 | 1147 | print '<option value="1"'; |
| 978 | - if (1 == $selected) print ' selected'; |
|
| 1148 | + if (1 == $selected) { |
|
| 1149 | + print ' selected'; |
|
| 1150 | + } |
|
| 979 | 1151 | print '>'.$langs->trans("Service"); |
| 980 | 1152 | |
| 981 | 1153 | print '</select>'; |
@@ -991,9 +1163,12 @@ discard block |
||
| 991 | 1163 | print $langs->trans("Product"); |
| 992 | 1164 | print '<input type="hidden" name="'.$htmlname.'" value="0">'; |
| 993 | 1165 | } |
| 994 | - if ($forceall < 0) // This should happened only for contracts when both predefined product and service are disabled. |
|
| 1166 | + if ($forceall < 0) { |
|
| 1167 | + // This should happened only for contracts when both predefined product and service are disabled. |
|
| 995 | 1168 | { |
| 996 | - print '<input type="hidden" name="'.$htmlname.'" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1 |
|
| 1169 | + print '<input type="hidden" name="'.$htmlname.'" value="1">'; |
|
| 1170 | + } |
|
| 1171 | + // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1 |
|
| 997 | 1172 | } |
| 998 | 1173 | } |
| 999 | 1174 | |
@@ -1009,7 +1184,10 @@ discard block |
||
| 1009 | 1184 | global $langs; |
| 1010 | 1185 | |
| 1011 | 1186 | $num = count($this->cache_types_fees); |
| 1012 | - if ($num > 0) return 0; // Cache already loaded |
|
| 1187 | + if ($num > 0) { |
|
| 1188 | + return 0; |
|
| 1189 | + } |
|
| 1190 | + // Cache already loaded |
|
| 1013 | 1191 | |
| 1014 | 1192 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 1015 | 1193 | |
@@ -1066,21 +1244,27 @@ discard block |
||
| 1066 | 1244 | if ($showempty) |
| 1067 | 1245 | { |
| 1068 | 1246 | print '<option value="-1"'; |
| 1069 | - if ($selected == -1) print ' selected'; |
|
| 1247 | + if ($selected == -1) { |
|
| 1248 | + print ' selected'; |
|
| 1249 | + } |
|
| 1070 | 1250 | print '> </option>'; |
| 1071 | 1251 | } |
| 1072 | 1252 | |
| 1073 | 1253 | foreach ($this->cache_types_fees as $key => $value) |
| 1074 | 1254 | { |
| 1075 | 1255 | print '<option value="'.$key.'"'; |
| 1076 | - if ($key == $selected) print ' selected'; |
|
| 1256 | + if ($key == $selected) { |
|
| 1257 | + print ' selected'; |
|
| 1258 | + } |
|
| 1077 | 1259 | print '>'; |
| 1078 | 1260 | print $value; |
| 1079 | 1261 | print '</option>'; |
| 1080 | 1262 | } |
| 1081 | 1263 | |
| 1082 | 1264 | print '</select>'; |
| 1083 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1265 | + if ($user->admin) { |
|
| 1266 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1267 | + } |
|
| 1084 | 1268 | } |
| 1085 | 1269 | |
| 1086 | 1270 | |
@@ -1127,8 +1311,9 @@ discard block |
||
| 1127 | 1311 | $urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&filter='.urlencode($filter).($showtype ? '&showtype='.urlencode($showtype) : ''); |
| 1128 | 1312 | $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); |
| 1129 | 1313 | $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>'; |
| 1130 | - if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; |
|
| 1131 | - elseif ($hidelabel > 1) { |
|
| 1314 | + if (empty($hidelabel)) { |
|
| 1315 | + print $langs->trans("RefOrLabel").' : '; |
|
| 1316 | + } elseif ($hidelabel > 1) { |
|
| 1132 | 1317 | $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"'; |
| 1133 | 1318 | if ($hidelabel == 2) { |
| 1134 | 1319 | $out .= img_picto($langs->trans("Search"), 'search'); |
@@ -1175,8 +1360,11 @@ discard block |
||
| 1175 | 1360 | $num = 0; |
| 1176 | 1361 | $outarray = array(); |
| 1177 | 1362 | |
| 1178 | - if ($selected === '') $selected = array(); |
|
| 1179 | - elseif (!is_array($selected)) $selected = array($selected); |
|
| 1363 | + if ($selected === '') { |
|
| 1364 | + $selected = array(); |
|
| 1365 | + } elseif (!is_array($selected)) { |
|
| 1366 | + $selected = array($selected); |
|
| 1367 | + } |
|
| 1180 | 1368 | |
| 1181 | 1369 | // Clean $filter that may contains sql conditions so sql code |
| 1182 | 1370 | if (function_exists('testSqlAndScriptInject')) { |
@@ -1194,15 +1382,25 @@ discard block |
||
| 1194 | 1382 | } |
| 1195 | 1383 | |
| 1196 | 1384 | $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
| 1197 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 1385 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1386 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 1387 | + } |
|
| 1198 | 1388 | if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { |
| 1199 | 1389 | $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays"; |
| 1200 | 1390 | } |
| 1201 | 1391 | $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
| 1202 | - if (!empty($user->socid)) $sql .= " AND s.rowid = ".$user->socid; |
|
| 1203 | - if ($filter) $sql .= " AND (".$filter.")"; |
|
| 1204 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 1205 | - if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql .= " AND s.status <> 0"; |
|
| 1392 | + if (!empty($user->socid)) { |
|
| 1393 | + $sql .= " AND s.rowid = ".$user->socid; |
|
| 1394 | + } |
|
| 1395 | + if ($filter) { |
|
| 1396 | + $sql .= " AND (".$filter.")"; |
|
| 1397 | + } |
|
| 1398 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1399 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 1400 | + } |
|
| 1401 | + if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { |
|
| 1402 | + $sql .= " AND s.status <> 0"; |
|
| 1403 | + } |
|
| 1206 | 1404 | // Add criteria |
| 1207 | 1405 | if ($filterkey && $filterkey != '') |
| 1208 | 1406 | { |
@@ -1211,13 +1409,19 @@ discard block |
||
| 1211 | 1409 | // For natural search |
| 1212 | 1410 | $scrit = explode(' ', $filterkey); |
| 1213 | 1411 | $i = 0; |
| 1214 | - if (count($scrit) > 1) $sql .= "("; |
|
| 1412 | + if (count($scrit) > 1) { |
|
| 1413 | + $sql .= "("; |
|
| 1414 | + } |
|
| 1215 | 1415 | foreach ($scrit as $crit) { |
| 1216 | - if ($i > 0) $sql .= " AND "; |
|
| 1416 | + if ($i > 0) { |
|
| 1417 | + $sql .= " AND "; |
|
| 1418 | + } |
|
| 1217 | 1419 | $sql .= "(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')"; |
| 1218 | 1420 | $i++; |
| 1219 | 1421 | } |
| 1220 | - if (count($scrit) > 1) $sql .= ")"; |
|
| 1422 | + if (count($scrit) > 1) { |
|
| 1423 | + $sql .= ")"; |
|
| 1424 | + } |
|
| 1221 | 1425 | if (!empty($conf->barcode->enabled)) |
| 1222 | 1426 | { |
| 1223 | 1427 | $sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
@@ -1247,10 +1451,15 @@ discard block |
||
| 1247 | 1451 | { |
| 1248 | 1452 | // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. |
| 1249 | 1453 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 1250 | - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 1251 | - else $textifempty .= $langs->trans("All"); |
|
| 1454 | + if ($showempty && !is_numeric($showempty)) { |
|
| 1455 | + $textifempty = $langs->trans($showempty); |
|
| 1456 | + } else { |
|
| 1457 | + $textifempty .= $langs->trans("All"); |
|
| 1458 | + } |
|
| 1459 | + } |
|
| 1460 | + if ($showempty) { |
|
| 1461 | + $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; |
|
| 1252 | 1462 | } |
| 1253 | - if ($showempty) $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; |
|
| 1254 | 1463 | |
| 1255 | 1464 | $num = $this->db->num_rows($resql); |
| 1256 | 1465 | $i = 0; |
@@ -1278,11 +1487,21 @@ discard block |
||
| 1278 | 1487 | |
| 1279 | 1488 | if ($showtype) |
| 1280 | 1489 | { |
| 1281 | - if ($obj->client || $obj->fournisseur) $label .= ' ('; |
|
| 1282 | - if ($obj->client == 1 || $obj->client == 3) $label .= $langs->trans("Customer"); |
|
| 1283 | - if ($obj->client == 2 || $obj->client == 3) $label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect"); |
|
| 1284 | - if ($obj->fournisseur) $label .= ($obj->client ? ', ' : '').$langs->trans("Supplier"); |
|
| 1285 | - if ($obj->client || $obj->fournisseur) $label .= ')'; |
|
| 1490 | + if ($obj->client || $obj->fournisseur) { |
|
| 1491 | + $label .= ' ('; |
|
| 1492 | + } |
|
| 1493 | + if ($obj->client == 1 || $obj->client == 3) { |
|
| 1494 | + $label .= $langs->trans("Customer"); |
|
| 1495 | + } |
|
| 1496 | + if ($obj->client == 2 || $obj->client == 3) { |
|
| 1497 | + $label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect"); |
|
| 1498 | + } |
|
| 1499 | + if ($obj->fournisseur) { |
|
| 1500 | + $label .= ($obj->client ? ', ' : '').$langs->trans("Supplier"); |
|
| 1501 | + } |
|
| 1502 | + if ($obj->client || $obj->fournisseur) { |
|
| 1503 | + $label .= ')'; |
|
| 1504 | + } |
|
| 1286 | 1505 | } |
| 1287 | 1506 | |
| 1288 | 1507 | if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { |
@@ -1305,7 +1524,9 @@ discard block |
||
| 1305 | 1524 | } |
| 1306 | 1525 | |
| 1307 | 1526 | $i++; |
| 1308 | - if (($i % 10) == 0) $out .= "\n"; |
|
| 1527 | + if (($i % 10) == 0) { |
|
| 1528 | + $out .= "\n"; |
|
| 1529 | + } |
|
| 1309 | 1530 | } |
| 1310 | 1531 | } |
| 1311 | 1532 | $out .= '</select>'."\n"; |
@@ -1315,7 +1536,9 @@ discard block |
||
| 1315 | 1536 | |
| 1316 | 1537 | $this->result = array('nbofthirdparties'=>$num); |
| 1317 | 1538 | |
| 1318 | - if ($outputmode) return $outarray; |
|
| 1539 | + if ($outputmode) { |
|
| 1540 | + return $outarray; |
|
| 1541 | + } |
|
| 1319 | 1542 | return $out; |
| 1320 | 1543 | } |
| 1321 | 1544 | |
@@ -1342,7 +1565,9 @@ discard block |
||
| 1342 | 1565 | $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; |
| 1343 | 1566 | $sql .= " WHERE re.fk_soc = ".(int) $socid; |
| 1344 | 1567 | $sql .= " AND re.entity = ".$conf->entity; |
| 1345 | - if ($filter) $sql .= " AND ".$filter; |
|
| 1568 | + if ($filter) { |
|
| 1569 | + $sql .= " AND ".$filter; |
|
| 1570 | + } |
|
| 1346 | 1571 | $sql .= " ORDER BY re.description ASC"; |
| 1347 | 1572 | |
| 1348 | 1573 | dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); |
@@ -1362,13 +1587,23 @@ discard block |
||
| 1362 | 1587 | { |
| 1363 | 1588 | $obj = $this->db->fetch_object($resql); |
| 1364 | 1589 | $desc = dol_trunc($obj->description, 40); |
| 1365 | - if (preg_match('/\(CREDIT_NOTE\)/', $desc)) $desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc); |
|
| 1366 | - if (preg_match('/\(DEPOSIT\)/', $desc)) $desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc); |
|
| 1367 | - if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) $desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc); |
|
| 1368 | - if (preg_match('/\(EXCESS PAID\)/', $desc)) $desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc); |
|
| 1590 | + if (preg_match('/\(CREDIT_NOTE\)/', $desc)) { |
|
| 1591 | + $desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc); |
|
| 1592 | + } |
|
| 1593 | + if (preg_match('/\(DEPOSIT\)/', $desc)) { |
|
| 1594 | + $desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc); |
|
| 1595 | + } |
|
| 1596 | + if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) { |
|
| 1597 | + $desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc); |
|
| 1598 | + } |
|
| 1599 | + if (preg_match('/\(EXCESS PAID\)/', $desc)) { |
|
| 1600 | + $desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc); |
|
| 1601 | + } |
|
| 1369 | 1602 | |
| 1370 | 1603 | $selectstring = ''; |
| 1371 | - if ($selected > 0 && $selected == $obj->rowid) $selectstring = ' selected'; |
|
| 1604 | + if ($selected > 0 && $selected == $obj->rowid) { |
|
| 1605 | + $selectstring = ' selected'; |
|
| 1606 | + } |
|
| 1372 | 1607 | |
| 1373 | 1608 | $disabled = ''; |
| 1374 | 1609 | if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) |
@@ -1380,7 +1615,9 @@ discard block |
||
| 1380 | 1615 | if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) |
| 1381 | 1616 | { |
| 1382 | 1617 | $tmpfac = new Facture($this->db); |
| 1383 | - if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc = $desc.' - '.$tmpfac->ref; |
|
| 1618 | + if ($tmpfac->fetch($obj->fk_facture_source) > 0) { |
|
| 1619 | + $desc = $desc.' - '.$tmpfac->ref; |
|
| 1620 | + } |
|
| 1384 | 1621 | } |
| 1385 | 1622 | |
| 1386 | 1623 | print '<option value="'.$obj->rowid.'"'.$selectstring.$disabled.'>'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>'; |
@@ -1452,10 +1689,15 @@ discard block |
||
| 1452 | 1689 | |
| 1453 | 1690 | $langs->load('companies'); |
| 1454 | 1691 | |
| 1455 | - if (empty($htmlid)) $htmlid = $htmlname; |
|
| 1692 | + if (empty($htmlid)) { |
|
| 1693 | + $htmlid = $htmlname; |
|
| 1694 | + } |
|
| 1456 | 1695 | |
| 1457 | - if ($selected === '') $selected = array(); |
|
| 1458 | - elseif (!is_array($selected)) $selected = array($selected); |
|
| 1696 | + if ($selected === '') { |
|
| 1697 | + $selected = array(); |
|
| 1698 | + } elseif (!is_array($selected)) { |
|
| 1699 | + $selected = array($selected); |
|
| 1700 | + } |
|
| 1459 | 1701 | $out = ''; |
| 1460 | 1702 | |
| 1461 | 1703 | if (!is_object($hookmanager)) |
@@ -1466,12 +1708,20 @@ discard block |
||
| 1466 | 1708 | |
| 1467 | 1709 | // We search third parties |
| 1468 | 1710 | $sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste"; |
| 1469 | - if ($showsoc > 0) $sql .= " , s.nom as company"; |
|
| 1711 | + if ($showsoc > 0) { |
|
| 1712 | + $sql .= " , s.nom as company"; |
|
| 1713 | + } |
|
| 1470 | 1714 | $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
| 1471 | - if ($showsoc > 0) $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc"; |
|
| 1715 | + if ($showsoc > 0) { |
|
| 1716 | + $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc"; |
|
| 1717 | + } |
|
| 1472 | 1718 | $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; |
| 1473 | - if ($socid > 0 || $socid == -1) $sql .= " AND sp.fk_soc=".$socid; |
|
| 1474 | - if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql .= " AND sp.statut <> 0"; |
|
| 1719 | + if ($socid > 0 || $socid == -1) { |
|
| 1720 | + $sql .= " AND sp.fk_soc=".$socid; |
|
| 1721 | + } |
|
| 1722 | + if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) { |
|
| 1723 | + $sql .= " AND sp.statut <> 0"; |
|
| 1724 | + } |
|
| 1475 | 1725 | $sql .= " ORDER BY sp.lastname ASC"; |
| 1476 | 1726 | |
| 1477 | 1727 | dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG); |
@@ -1486,9 +1736,15 @@ discard block |
||
| 1486 | 1736 | $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); |
| 1487 | 1737 | } |
| 1488 | 1738 | |
| 1489 | - if ($htmlname != 'none' && !$options_only) $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>'; |
|
| 1490 | - if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'> </option>'; |
|
| 1491 | - if ($showempty == 2) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>'; |
|
| 1739 | + if ($htmlname != 'none' && !$options_only) { |
|
| 1740 | + $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>'; |
|
| 1741 | + } |
|
| 1742 | + if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) { |
|
| 1743 | + $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'> </option>'; |
|
| 1744 | + } |
|
| 1745 | + if ($showempty == 2) { |
|
| 1746 | + $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>'; |
|
| 1747 | + } |
|
| 1492 | 1748 | |
| 1493 | 1749 | $num = $this->db->num_rows($resql); |
| 1494 | 1750 | $i = 0; |
@@ -1508,32 +1764,52 @@ discard block |
||
| 1508 | 1764 | if ($htmlname != 'none') |
| 1509 | 1765 | { |
| 1510 | 1766 | $disabled = 0; |
| 1511 | - if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) $disabled = 1; |
|
| 1512 | - if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1; |
|
| 1767 | + if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) { |
|
| 1768 | + $disabled = 1; |
|
| 1769 | + } |
|
| 1770 | + if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) { |
|
| 1771 | + $disabled = 1; |
|
| 1772 | + } |
|
| 1513 | 1773 | if (!empty($selected) && in_array($obj->rowid, $selected)) |
| 1514 | 1774 | { |
| 1515 | 1775 | $out .= '<option value="'.$obj->rowid.'"'; |
| 1516 | - if ($disabled) $out .= ' disabled'; |
|
| 1776 | + if ($disabled) { |
|
| 1777 | + $out .= ' disabled'; |
|
| 1778 | + } |
|
| 1517 | 1779 | $out .= ' selected>'; |
| 1518 | 1780 | $out .= $contactstatic->getFullName($langs); |
| 1519 | - if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')'; |
|
| 1520 | - if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')'; |
|
| 1781 | + if ($showfunction && $obj->poste) { |
|
| 1782 | + $out .= ' ('.$obj->poste.')'; |
|
| 1783 | + } |
|
| 1784 | + if (($showsoc > 0) && $obj->company) { |
|
| 1785 | + $out .= ' - ('.$obj->company.')'; |
|
| 1786 | + } |
|
| 1521 | 1787 | $out .= '</option>'; |
| 1522 | 1788 | } else { |
| 1523 | 1789 | $out .= '<option value="'.$obj->rowid.'"'; |
| 1524 | - if ($disabled) $out .= ' disabled'; |
|
| 1790 | + if ($disabled) { |
|
| 1791 | + $out .= ' disabled'; |
|
| 1792 | + } |
|
| 1525 | 1793 | $out .= '>'; |
| 1526 | 1794 | $out .= $contactstatic->getFullName($langs); |
| 1527 | - if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')'; |
|
| 1528 | - if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')'; |
|
| 1795 | + if ($showfunction && $obj->poste) { |
|
| 1796 | + $out .= ' ('.$obj->poste.')'; |
|
| 1797 | + } |
|
| 1798 | + if (($showsoc > 0) && $obj->company) { |
|
| 1799 | + $out .= ' - ('.$obj->company.')'; |
|
| 1800 | + } |
|
| 1529 | 1801 | $out .= '</option>'; |
| 1530 | 1802 | } |
| 1531 | 1803 | } else { |
| 1532 | 1804 | if (in_array($obj->rowid, $selected)) |
| 1533 | 1805 | { |
| 1534 | 1806 | $out .= $contactstatic->getFullName($langs); |
| 1535 | - if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')'; |
|
| 1536 | - if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')'; |
|
| 1807 | + if ($showfunction && $obj->poste) { |
|
| 1808 | + $out .= ' ('.$obj->poste.')'; |
|
| 1809 | + } |
|
| 1810 | + if (($showsoc > 0) && $obj->company) { |
|
| 1811 | + $out .= ' - ('.$obj->company.')'; |
|
| 1812 | + } |
|
| 1537 | 1813 | } |
| 1538 | 1814 | } |
| 1539 | 1815 | } |
@@ -1621,19 +1897,27 @@ discard block |
||
| 1621 | 1897 | global $conf, $user, $langs, $hookmanager; |
| 1622 | 1898 | |
| 1623 | 1899 | // If no preselected user defined, we take current user |
| 1624 | - if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id; |
|
| 1900 | + if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) { |
|
| 1901 | + $selected = $user->id; |
|
| 1902 | + } |
|
| 1625 | 1903 | |
| 1626 | - if ($selected === '') $selected = array(); |
|
| 1627 | - elseif (!is_array($selected)) $selected = array($selected); |
|
| 1904 | + if ($selected === '') { |
|
| 1905 | + $selected = array(); |
|
| 1906 | + } elseif (!is_array($selected)) { |
|
| 1907 | + $selected = array($selected); |
|
| 1908 | + } |
|
| 1628 | 1909 | |
| 1629 | 1910 | $excludeUsers = null; |
| 1630 | 1911 | $includeUsers = null; |
| 1631 | 1912 | |
| 1632 | 1913 | // Permettre l'exclusion d'utilisateurs |
| 1633 | - if (is_array($exclude)) $excludeUsers = implode(",", $exclude); |
|
| 1914 | + if (is_array($exclude)) { |
|
| 1915 | + $excludeUsers = implode(",", $exclude); |
|
| 1916 | + } |
|
| 1634 | 1917 | // Permettre l'inclusion d'utilisateurs |
| 1635 | - if (is_array($include)) $includeUsers = implode(",", $include); |
|
| 1636 | - elseif ($include == 'hierarchy') |
|
| 1918 | + if (is_array($include)) { |
|
| 1919 | + $includeUsers = implode(",", $include); |
|
| 1920 | + } elseif ($include == 'hierarchy') |
|
| 1637 | 1921 | { |
| 1638 | 1922 | // Build list includeUsers to have only hierarchy |
| 1639 | 1923 | $includeUsers = implode(",", $user->getAllChildIds(0)); |
@@ -1656,8 +1940,11 @@ discard block |
||
| 1656 | 1940 | if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) |
| 1657 | 1941 | { |
| 1658 | 1942 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity"; |
| 1659 | - if ($force_entity) $sql .= " WHERE u.entity IN (0,".$force_entity.")"; |
|
| 1660 | - else $sql .= " WHERE u.entity IS NOT NULL"; |
|
| 1943 | + if ($force_entity) { |
|
| 1944 | + $sql .= " WHERE u.entity IN (0,".$force_entity.")"; |
|
| 1945 | + } else { |
|
| 1946 | + $sql .= " WHERE u.entity IS NOT NULL"; |
|
| 1947 | + } |
|
| 1661 | 1948 | } else { |
| 1662 | 1949 | if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) |
| 1663 | 1950 | { |
@@ -1668,19 +1955,33 @@ discard block |
||
| 1668 | 1955 | $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; |
| 1669 | 1956 | } |
| 1670 | 1957 | } |
| 1671 | - if (!empty($user->socid)) $sql .= " AND u.fk_soc = ".$user->socid; |
|
| 1672 | - if (is_array($exclude) && $excludeUsers) $sql .= " AND u.rowid NOT IN (".$excludeUsers.")"; |
|
| 1673 | - if ($includeUsers) $sql .= " AND u.rowid IN (".$includeUsers.")"; |
|
| 1674 | - if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0"; |
|
| 1675 | - if (!empty($morefilter)) $sql .= " ".$morefilter; |
|
| 1958 | + if (!empty($user->socid)) { |
|
| 1959 | + $sql .= " AND u.fk_soc = ".$user->socid; |
|
| 1960 | + } |
|
| 1961 | + if (is_array($exclude) && $excludeUsers) { |
|
| 1962 | + $sql .= " AND u.rowid NOT IN (".$excludeUsers.")"; |
|
| 1963 | + } |
|
| 1964 | + if ($includeUsers) { |
|
| 1965 | + $sql .= " AND u.rowid IN (".$includeUsers.")"; |
|
| 1966 | + } |
|
| 1967 | + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) { |
|
| 1968 | + $sql .= " AND u.statut <> 0"; |
|
| 1969 | + } |
|
| 1970 | + if (!empty($morefilter)) { |
|
| 1971 | + $sql .= " ".$morefilter; |
|
| 1972 | + } |
|
| 1676 | 1973 | |
| 1677 | 1974 | //Add hook to filter on user (for exemple on usergroup define in custom modules) |
| 1678 | 1975 | $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectUsers', array(), $this, $action); |
| 1679 | - if (!empty($reshook)) $sql .= $hookmanager->resPrint; |
|
| 1976 | + if (!empty($reshook)) { |
|
| 1977 | + $sql .= $hookmanager->resPrint; |
|
| 1978 | + } |
|
| 1680 | 1979 | |
| 1681 | - if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname |
|
| 1980 | + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { |
|
| 1981 | + // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname |
|
| 1682 | 1982 | { |
| 1683 | 1983 | $sql .= " ORDER BY u.firstname ASC"; |
| 1984 | + } |
|
| 1684 | 1985 | } else { |
| 1685 | 1986 | $sql .= " ORDER BY u.lastname ASC"; |
| 1686 | 1987 | } |
@@ -1699,8 +2000,12 @@ discard block |
||
| 1699 | 2000 | |
| 1700 | 2001 | // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined |
| 1701 | 2002 | $out .= '<select class="flat'.($morecss ? ' minwidth100imp '.$morecss : ' minwidth200').'" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>'; |
| 1702 | - if ($show_empty && !$multiple) $out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'> </option>'."\n"; |
|
| 1703 | - if ($show_every) $out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n"; |
|
| 2003 | + if ($show_empty && !$multiple) { |
|
| 2004 | + $out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'> </option>'."\n"; |
|
| 2005 | + } |
|
| 2006 | + if ($show_every) { |
|
| 2007 | + $out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n"; |
|
| 2008 | + } |
|
| 1704 | 2009 | |
| 1705 | 2010 | $userstatic = new User($this->db); |
| 1706 | 2011 | |
@@ -1713,7 +2018,9 @@ discard block |
||
| 1713 | 2018 | $userstatic->firstname = $obj->firstname; |
| 1714 | 2019 | |
| 1715 | 2020 | $disableline = ''; |
| 1716 | - if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext : '1'); |
|
| 2021 | + if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) { |
|
| 2022 | + $disableline = ($enableonlytext ? $enableonlytext : '1'); |
|
| 2023 | + } |
|
| 1717 | 2024 | |
| 1718 | 2025 | $labeltoshow = ''; |
| 1719 | 2026 | |
@@ -1759,7 +2066,9 @@ discard block |
||
| 1759 | 2066 | $labeltoshow .= $moreinfo; |
| 1760 | 2067 | |
| 1761 | 2068 | $out .= '<option value="'.$obj->rowid.'"'; |
| 1762 | - if ($disableline) $out .= ' disabled'; |
|
| 2069 | + if ($disableline) { |
|
| 2070 | + $out .= ' disabled'; |
|
| 2071 | + } |
|
| 1763 | 2072 | if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) { |
| 1764 | 2073 | $out .= ' selected'; |
| 1765 | 2074 | } |
@@ -1783,7 +2092,9 @@ discard block |
||
| 1783 | 2092 | dol_print_error($this->db); |
| 1784 | 2093 | } |
| 1785 | 2094 | |
| 1786 | - if ($outputmode) return $outarray; |
|
| 2095 | + if ($outputmode) { |
|
| 2096 | + return $outarray; |
|
| 2097 | + } |
|
| 1787 | 2098 | return $out; |
| 1788 | 2099 | } |
| 1789 | 2100 | |
@@ -1828,11 +2139,15 @@ discard block |
||
| 1828 | 2139 | $nbassignetouser = count($assignedtouser); |
| 1829 | 2140 | |
| 1830 | 2141 | //if ($nbassignetouser && $action != 'view') $out .= '<br>'; |
| 1831 | - if ($nbassignetouser) $out .= '<ul class="attendees">'; |
|
| 2142 | + if ($nbassignetouser) { |
|
| 2143 | + $out .= '<ul class="attendees">'; |
|
| 2144 | + } |
|
| 1832 | 2145 | $i = 0; $ownerid = 0; |
| 1833 | 2146 | foreach ($assignedtouser as $key => $value) |
| 1834 | 2147 | { |
| 1835 | - if ($value['id'] == $ownerid) continue; |
|
| 2148 | + if ($value['id'] == $ownerid) { |
|
| 2149 | + continue; |
|
| 2150 | + } |
|
| 1836 | 2151 | |
| 1837 | 2152 | $out .= '<li>'; |
| 1838 | 2153 | $userstatic->fetch($value['id']); |
@@ -1858,7 +2173,9 @@ discard block |
||
| 1858 | 2173 | $out .= '</li>'; |
| 1859 | 2174 | $i++; |
| 1860 | 2175 | } |
| 1861 | - if ($nbassignetouser) $out .= '</ul>'; |
|
| 2176 | + if ($nbassignetouser) { |
|
| 2177 | + $out .= '</ul>'; |
|
| 2178 | + } |
|
| 1862 | 2179 | |
| 1863 | 2180 | // Method with no ajax |
| 1864 | 2181 | if ($action != 'view') |
@@ -1910,7 +2227,9 @@ discard block |
||
| 1910 | 2227 | |
| 1911 | 2228 | // check parameters |
| 1912 | 2229 | $price_level = (!empty($price_level) ? $price_level : 0); |
| 1913 | - if (is_null($ajaxoptions)) $ajaxoptions = array(); |
|
| 2230 | + if (is_null($ajaxoptions)) { |
|
| 2231 | + $ajaxoptions = array(); |
|
| 2232 | + } |
|
| 1914 | 2233 | |
| 1915 | 2234 | if (strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { |
| 1916 | 2235 | if (!empty($conf->product->enabled) && empty($conf->service->enabled)) { |
@@ -2021,8 +2340,9 @@ discard block |
||
| 2021 | 2340 | '; |
| 2022 | 2341 | } |
| 2023 | 2342 | |
| 2024 | - if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : '; |
|
| 2025 | - elseif ($hidelabel > 1) { |
|
| 2343 | + if (empty($hidelabel)) { |
|
| 2344 | + $out .= $langs->trans("RefOrLabel").' : '; |
|
| 2345 | + } elseif ($hidelabel > 1) { |
|
| 2026 | 2346 | $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"'; |
| 2027 | 2347 | if ($hidelabel == 2) { |
| 2028 | 2348 | $out .= img_picto($langs->trans("Search"), 'search'); |
@@ -2036,8 +2356,11 @@ discard block |
||
| 2036 | 2356 | $out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus); |
| 2037 | 2357 | } |
| 2038 | 2358 | |
| 2039 | - if (empty($nooutput)) print $out; |
|
| 2040 | - else return $out; |
|
| 2359 | + if (empty($nooutput)) { |
|
| 2360 | + print $out; |
|
| 2361 | + } else { |
|
| 2362 | + return $out; |
|
| 2363 | + } |
|
| 2041 | 2364 | } |
| 2042 | 2365 | |
| 2043 | 2366 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -2140,11 +2463,15 @@ discard block |
||
| 2140 | 2463 | if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) |
| 2141 | 2464 | { |
| 2142 | 2465 | $sql .= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; |
| 2143 | - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level; |
|
| 2466 | + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { |
|
| 2467 | + $sql .= " AND price_level=".$price_level; |
|
| 2468 | + } |
|
| 2144 | 2469 | $sql .= " ORDER BY date_price"; |
| 2145 | 2470 | $sql .= " DESC LIMIT 1) as price_rowid"; |
| 2146 | 2471 | $sql .= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable |
| 2147 | - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level; |
|
| 2472 | + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { |
|
| 2473 | + $sql .= " AND price_level=".$price_level; |
|
| 2474 | + } |
|
| 2148 | 2475 | $sql .= " ORDER BY date_price"; |
| 2149 | 2476 | $sql .= " DESC LIMIT 1) as price_by_qty"; |
| 2150 | 2477 | $selectFields .= ", price_rowid, price_by_qty"; |
@@ -2193,14 +2520,17 @@ discard block |
||
| 2193 | 2520 | } elseif ($finished == 1) |
| 2194 | 2521 | { |
| 2195 | 2522 | $sql .= " AND p.finished = ".$finished; |
| 2196 | - if ($status >= 0) $sql .= " AND p.tosell = ".$status; |
|
| 2523 | + if ($status >= 0) { |
|
| 2524 | + $sql .= " AND p.tosell = ".$status; |
|
| 2525 | + } |
|
| 2197 | 2526 | } elseif ($status >= 0) |
| 2198 | 2527 | { |
| 2199 | 2528 | $sql .= " AND p.tosell = ".$status; |
| 2200 | 2529 | } |
| 2201 | 2530 | // Filter by product type |
| 2202 | - if (strval($filtertype) != '') $sql .= " AND p.fk_product_type = ".$filtertype; |
|
| 2203 | - elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only |
|
| 2531 | + if (strval($filtertype) != '') { |
|
| 2532 | + $sql .= " AND p.fk_product_type = ".$filtertype; |
|
| 2533 | + } elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only |
|
| 2204 | 2534 | $sql .= " AND p.fk_product_type = 1"; |
| 2205 | 2535 | } elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only |
| 2206 | 2536 | $sql .= " AND p.fk_product_type = 0"; |
@@ -2213,23 +2543,37 @@ discard block |
||
| 2213 | 2543 | // For natural search |
| 2214 | 2544 | $scrit = explode(' ', $filterkey); |
| 2215 | 2545 | $i = 0; |
| 2216 | - if (count($scrit) > 1) $sql .= "("; |
|
| 2546 | + if (count($scrit) > 1) { |
|
| 2547 | + $sql .= "("; |
|
| 2548 | + } |
|
| 2217 | 2549 | foreach ($scrit as $crit) |
| 2218 | 2550 | { |
| 2219 | - if ($i > 0) $sql .= " AND "; |
|
| 2551 | + if ($i > 0) { |
|
| 2552 | + $sql .= " AND "; |
|
| 2553 | + } |
|
| 2220 | 2554 | $sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; |
| 2221 | - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2555 | + if (!empty($conf->global->MAIN_MULTILANGS)) { |
|
| 2556 | + $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2557 | + } |
|
| 2222 | 2558 | if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) |
| 2223 | 2559 | { |
| 2224 | 2560 | $sql .= " OR p.description LIKE '".$this->db->escape($prefix.$crit)."%'"; |
| 2225 | - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2561 | + if (!empty($conf->global->MAIN_MULTILANGS)) { |
|
| 2562 | + $sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2563 | + } |
|
| 2564 | + } |
|
| 2565 | + if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { |
|
| 2566 | + $sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2226 | 2567 | } |
| 2227 | - if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) $sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; |
|
| 2228 | 2568 | $sql .= ")"; |
| 2229 | 2569 | $i++; |
| 2230 | 2570 | } |
| 2231 | - if (count($scrit) > 1) $sql .= ")"; |
|
| 2232 | - if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2571 | + if (count($scrit) > 1) { |
|
| 2572 | + $sql .= ")"; |
|
| 2573 | + } |
|
| 2574 | + if (!empty($conf->barcode->enabled)) { |
|
| 2575 | + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2576 | + } |
|
| 2233 | 2577 | $sql .= ')'; |
| 2234 | 2578 | } |
| 2235 | 2579 | if (count($warehouseStatusArray)) |
@@ -2275,12 +2619,19 @@ discard block |
||
| 2275 | 2619 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 2276 | 2620 | if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) |
| 2277 | 2621 | { |
| 2278 | - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 2279 | - else $textifempty .= $langs->trans("All"); |
|
| 2622 | + if ($showempty && !is_numeric($showempty)) { |
|
| 2623 | + $textifempty = $langs->trans($showempty); |
|
| 2624 | + } else { |
|
| 2625 | + $textifempty .= $langs->trans("All"); |
|
| 2626 | + } |
|
| 2280 | 2627 | } else { |
| 2281 | - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 2628 | + if ($showempty && !is_numeric($showempty)) { |
|
| 2629 | + $textifempty = $langs->trans($showempty); |
|
| 2630 | + } |
|
| 2631 | + } |
|
| 2632 | + if ($showempty) { |
|
| 2633 | + $out .= '<option value="0" selected>'.$textifempty.'</option>'; |
|
| 2282 | 2634 | } |
| 2283 | - if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>'; |
|
| 2284 | 2635 | |
| 2285 | 2636 | $i = 0; |
| 2286 | 2637 | while ($num && $i < $num) |
@@ -2358,7 +2709,9 @@ discard block |
||
| 2358 | 2709 | |
| 2359 | 2710 | $this->db->free($result); |
| 2360 | 2711 | |
| 2361 | - if (empty($outputmode)) return $out; |
|
| 2712 | + if (empty($outputmode)) { |
|
| 2713 | + return $out; |
|
| 2714 | + } |
|
| 2362 | 2715 | return $outarray; |
| 2363 | 2716 | } else { |
| 2364 | 2717 | dol_print_error($db); |
@@ -2401,8 +2754,12 @@ discard block |
||
| 2401 | 2754 | $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); |
| 2402 | 2755 | |
| 2403 | 2756 | $label = $objp->label; |
| 2404 | - if (!empty($objp->label_translated)) $label = $objp->label_translated; |
|
| 2405 | - if (!empty($filterkey) && $filterkey != '') $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1); |
|
| 2757 | + if (!empty($objp->label_translated)) { |
|
| 2758 | + $label = $objp->label_translated; |
|
| 2759 | + } |
|
| 2760 | + if (!empty($filterkey) && $filterkey != '') { |
|
| 2761 | + $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1); |
|
| 2762 | + } |
|
| 2406 | 2763 | |
| 2407 | 2764 | $outkey = $objp->rowid; |
| 2408 | 2765 | $outref = $objp->ref; |
@@ -2416,7 +2773,9 @@ discard block |
||
| 2416 | 2773 | $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; |
| 2417 | 2774 | $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; |
| 2418 | 2775 | |
| 2419 | - if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 2776 | + if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) { |
|
| 2777 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 2778 | + } |
|
| 2420 | 2779 | |
| 2421 | 2780 | // Units |
| 2422 | 2781 | $outvalUnits = ''; |
@@ -2465,22 +2824,35 @@ discard block |
||
| 2465 | 2824 | if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) |
| 2466 | 2825 | { |
| 2467 | 2826 | if (!empty($user->rights->stock->lire)) { |
| 2468 | - if ($objp->stock > 0) $opt .= ' class="product_line_stock_ok"'; |
|
| 2469 | - elseif ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"'; |
|
| 2827 | + if ($objp->stock > 0) { |
|
| 2828 | + $opt .= ' class="product_line_stock_ok"'; |
|
| 2829 | + } elseif ($objp->stock <= 0) { |
|
| 2830 | + $opt .= ' class="product_line_stock_too_low"'; |
|
| 2831 | + } |
|
| 2470 | 2832 | } |
| 2471 | 2833 | } |
| 2472 | 2834 | $opt .= '>'; |
| 2473 | 2835 | $opt .= $objp->ref; |
| 2474 | - if ($outbarcode) $opt .= ' ('.$outbarcode.')'; |
|
| 2836 | + if ($outbarcode) { |
|
| 2837 | + $opt .= ' ('.$outbarcode.')'; |
|
| 2838 | + } |
|
| 2475 | 2839 | $opt .= ' - '.dol_trunc($label, $maxlengtharticle); |
| 2476 | - if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .= ' ('.getCountry($outorigin, 1).')'; |
|
| 2840 | + if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) { |
|
| 2841 | + $opt .= ' ('.getCountry($outorigin, 1).')'; |
|
| 2842 | + } |
|
| 2477 | 2843 | |
| 2478 | 2844 | $objRef = $objp->ref; |
| 2479 | - if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 2845 | + if (!empty($filterkey) && $filterkey != '') { |
|
| 2846 | + $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 2847 | + } |
|
| 2480 | 2848 | $outval .= $objRef; |
| 2481 | - if ($outbarcode) $outval .= ' ('.$outbarcode.')'; |
|
| 2849 | + if ($outbarcode) { |
|
| 2850 | + $outval .= ' ('.$outbarcode.')'; |
|
| 2851 | + } |
|
| 2482 | 2852 | $outval .= ' - '.dol_trunc($label, $maxlengtharticle); |
| 2483 | - if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .= ' ('.getCountry($outorigin, 1).')'; |
|
| 2853 | + if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) { |
|
| 2854 | + $outval .= ' ('.getCountry($outorigin, 1).')'; |
|
| 2855 | + } |
|
| 2484 | 2856 | |
| 2485 | 2857 | // Units |
| 2486 | 2858 | $opt .= $outvalUnits; |
@@ -2613,9 +2985,11 @@ discard block |
||
| 2613 | 2985 | } |
| 2614 | 2986 | $outval .= $langs->transnoentities("Stock").':'.$objp->stock; |
| 2615 | 2987 | $outval .= '</span>'; |
| 2616 | - if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation |
|
| 2988 | + if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) { |
|
| 2989 | + // Warning, this option may slow down combo list generation |
|
| 2617 | 2990 | { |
| 2618 | 2991 | $langs->load("stocks"); |
| 2992 | + } |
|
| 2619 | 2993 | |
| 2620 | 2994 | $tmpproduct = new Product($this->db); |
| 2621 | 2995 | $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) |
@@ -2725,10 +3099,14 @@ discard block |
||
| 2725 | 3099 | if ($conf->global->PRODUCT_USE_UNITS) { |
| 2726 | 3100 | $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; |
| 2727 | 3101 | } |
| 2728 | - if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; |
|
| 3102 | + if (!empty($conf->barcode->enabled)) { |
|
| 3103 | + $sql .= ", pfp.barcode"; |
|
| 3104 | + } |
|
| 2729 | 3105 | $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; |
| 2730 | 3106 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; |
| 2731 | - if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; |
|
| 3107 | + if ($socid) { |
|
| 3108 | + $sql .= " AND pfp.fk_soc = ".$socid; |
|
| 3109 | + } |
|
| 2732 | 3110 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; |
| 2733 | 3111 | // Units |
| 2734 | 3112 | if ($conf->global->PRODUCT_USE_UNITS) { |
@@ -2736,8 +3114,12 @@ discard block |
||
| 2736 | 3114 | } |
| 2737 | 3115 | $sql .= " WHERE p.entity IN (".getEntity('product').")"; |
| 2738 | 3116 | $sql .= " AND p.tobuy = 1"; |
| 2739 | - if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); |
|
| 2740 | - if (!empty($filtre)) $sql .= " ".$filtre; |
|
| 3117 | + if (strval($filtertype) != '') { |
|
| 3118 | + $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); |
|
| 3119 | + } |
|
| 3120 | + if (!empty($filtre)) { |
|
| 3121 | + $sql .= " ".$filtre; |
|
| 3122 | + } |
|
| 2741 | 3123 | // Add criteria on ref/label |
| 2742 | 3124 | if ($filterkey != '') |
| 2743 | 3125 | { |
@@ -2746,14 +3128,20 @@ discard block |
||
| 2746 | 3128 | // For natural search |
| 2747 | 3129 | $scrit = explode(' ', $filterkey); |
| 2748 | 3130 | $i = 0; |
| 2749 | - if (count($scrit) > 1) $sql .= "("; |
|
| 3131 | + if (count($scrit) > 1) { |
|
| 3132 | + $sql .= "("; |
|
| 3133 | + } |
|
| 2750 | 3134 | foreach ($scrit as $crit) |
| 2751 | 3135 | { |
| 2752 | - if ($i > 0) $sql .= " AND "; |
|
| 3136 | + if ($i > 0) { |
|
| 3137 | + $sql .= " AND "; |
|
| 3138 | + } |
|
| 2753 | 3139 | $sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')"; |
| 2754 | 3140 | $i++; |
| 2755 | 3141 | } |
| 2756 | - if (count($scrit) > 1) $sql .= ")"; |
|
| 3142 | + if (count($scrit) > 1) { |
|
| 3143 | + $sql .= ")"; |
|
| 3144 | + } |
|
| 2757 | 3145 | if (!empty($conf->barcode->enabled)) { |
| 2758 | 3146 | $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
| 2759 | 3147 | $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
@@ -2776,8 +3164,11 @@ discard block |
||
| 2776 | 3164 | |
| 2777 | 3165 | //$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax |
| 2778 | 3166 | $out .= '<select class="flat maxwidthonsmartphone'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
| 2779 | - if (!$selected) $out .= '<option value="0" selected> </option>'; |
|
| 2780 | - else $out .= '<option value="0"> </option>'; |
|
| 3167 | + if (!$selected) { |
|
| 3168 | + $out .= '<option value="0" selected> </option>'; |
|
| 3169 | + } else { |
|
| 3170 | + $out .= '<option value="0"> </option>'; |
|
| 3171 | + } |
|
| 2781 | 3172 | |
| 2782 | 3173 | $i = 0; |
| 2783 | 3174 | while ($i < $num) |
@@ -2785,7 +3176,10 @@ discard block |
||
| 2785 | 3176 | $objp = $this->db->fetch_object($result); |
| 2786 | 3177 | |
| 2787 | 3178 | $outkey = $objp->idprodfournprice; // id in table of price |
| 2788 | - if (!$outkey && $alsoproductwithnosupplierprice) $outkey = 'idprod_'.$objp->rowid; // id of product |
|
| 3179 | + if (!$outkey && $alsoproductwithnosupplierprice) { |
|
| 3180 | + $outkey = 'idprod_'.$objp->rowid; |
|
| 3181 | + } |
|
| 3182 | + // id of product |
|
| 2789 | 3183 | |
| 2790 | 3184 | $outref = $objp->ref; |
| 2791 | 3185 | $outval = ''; |
@@ -2833,11 +3227,17 @@ discard block |
||
| 2833 | 3227 | } |
| 2834 | 3228 | |
| 2835 | 3229 | $objRef = $objp->ref; |
| 2836 | - if ($filterkey && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 3230 | + if ($filterkey && $filterkey != '') { |
|
| 3231 | + $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 3232 | + } |
|
| 2837 | 3233 | $objRefFourn = $objp->ref_fourn; |
| 2838 | - if ($filterkey && $filterkey != '') $objRefFourn = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRefFourn, 1); |
|
| 3234 | + if ($filterkey && $filterkey != '') { |
|
| 3235 | + $objRefFourn = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRefFourn, 1); |
|
| 3236 | + } |
|
| 2839 | 3237 | $label = $objp->label; |
| 2840 | - if ($filterkey && $filterkey != '') $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1); |
|
| 3238 | + if ($filterkey && $filterkey != '') { |
|
| 3239 | + $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1); |
|
| 3240 | + } |
|
| 2841 | 3241 | |
| 2842 | 3242 | $optlabel = $objp->ref; |
| 2843 | 3243 | if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) { |
@@ -2924,9 +3324,11 @@ discard block |
||
| 2924 | 3324 | $outvallabel .= " - ".$reputations[$objp->supplier_reputation]; |
| 2925 | 3325 | } |
| 2926 | 3326 | } else { |
| 2927 | - if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier |
|
| 3327 | + if (empty($alsoproductwithnosupplierprice)) { |
|
| 3328 | + // No supplier price defined for couple product/supplier |
|
| 2928 | 3329 | { |
| 2929 | 3330 | $optlabel .= " - <span class='opacitymedium'>".$langs->trans("NoPriceDefinedForThisSupplier").'</span>'; |
| 3331 | + } |
|
| 2930 | 3332 | $outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier"); |
| 2931 | 3333 | } else // No supplier price defined for product, even on other suppliers |
| 2932 | 3334 | { |
@@ -2936,8 +3338,12 @@ discard block |
||
| 2936 | 3338 | } |
| 2937 | 3339 | |
| 2938 | 3340 | $opt = '<option value="'.$outkey.'"'; |
| 2939 | - if ($selected && $selected == $objp->idprodfournprice) $opt .= ' selected'; |
|
| 2940 | - if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled'; |
|
| 3341 | + if ($selected && $selected == $objp->idprodfournprice) { |
|
| 3342 | + $opt .= ' selected'; |
|
| 3343 | + } |
|
| 3344 | + if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) { |
|
| 3345 | + $opt .= ' disabled'; |
|
| 3346 | + } |
|
| 2941 | 3347 | if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) |
| 2942 | 3348 | { |
| 2943 | 3349 | $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"'; |
@@ -2974,7 +3380,9 @@ discard block |
||
| 2974 | 3380 | include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
| 2975 | 3381 | $out .= ajax_combobox($htmlname); |
| 2976 | 3382 | |
| 2977 | - if (empty($outputmode)) return $out; |
|
| 3383 | + if (empty($outputmode)) { |
|
| 3384 | + return $out; |
|
| 3385 | + } |
|
| 2978 | 3386 | return $outarray; |
| 2979 | 3387 | } else { |
| 2980 | 3388 | dol_print_error($this->db); |
@@ -3072,7 +3480,9 @@ discard block |
||
| 3072 | 3480 | $opt .= " - "; |
| 3073 | 3481 | $opt .= price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); |
| 3074 | 3482 | } |
| 3075 | - if ($objp->duration) $opt .= " - ".$objp->duration; |
|
| 3483 | + if ($objp->duration) { |
|
| 3484 | + $opt .= " - ".$objp->duration; |
|
| 3485 | + } |
|
| 3076 | 3486 | $opt .= "</option>\n"; |
| 3077 | 3487 | |
| 3078 | 3488 | $form .= $opt; |
@@ -3112,7 +3522,9 @@ discard block |
||
| 3112 | 3522 | if ($resql) |
| 3113 | 3523 | { |
| 3114 | 3524 | print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; |
| 3115 | - if ($showempty) print '<option value="0"> </option>'; |
|
| 3525 | + if ($showempty) { |
|
| 3526 | + print '<option value="0"> </option>'; |
|
| 3527 | + } |
|
| 3116 | 3528 | $num = $this->db->num_rows($resql); |
| 3117 | 3529 | $i = 0; |
| 3118 | 3530 | if ($num) |
@@ -3150,7 +3562,10 @@ discard block |
||
| 3150 | 3562 | global $langs; |
| 3151 | 3563 | |
| 3152 | 3564 | $num = count($this->cache_conditions_paiements); |
| 3153 | - if ($num > 0) return 0; // Cache already loaded |
|
| 3565 | + if ($num > 0) { |
|
| 3566 | + return 0; |
|
| 3567 | + } |
|
| 3568 | + // Cache already loaded |
|
| 3154 | 3569 | |
| 3155 | 3570 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3156 | 3571 | |
@@ -3197,7 +3612,10 @@ discard block |
||
| 3197 | 3612 | global $langs; |
| 3198 | 3613 | |
| 3199 | 3614 | $num = count($this->cache_availability); |
| 3200 | - if ($num > 0) return 0; // Cache already loaded |
|
| 3615 | + if ($num > 0) { |
|
| 3616 | + return 0; |
|
| 3617 | + } |
|
| 3618 | + // Cache already loaded |
|
| 3201 | 3619 | |
| 3202 | 3620 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3203 | 3621 | |
@@ -3250,7 +3668,9 @@ discard block |
||
| 3250 | 3668 | dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); |
| 3251 | 3669 | |
| 3252 | 3670 | print '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'; |
| 3253 | - if ($addempty) print '<option value="0"> </option>'; |
|
| 3671 | + if ($addempty) { |
|
| 3672 | + print '<option value="0"> </option>'; |
|
| 3673 | + } |
|
| 3254 | 3674 | foreach ($this->cache_availability as $id => $arrayavailability) |
| 3255 | 3675 | { |
| 3256 | 3676 | if ($selected == $id) |
@@ -3263,7 +3683,9 @@ discard block |
||
| 3263 | 3683 | print '</option>'; |
| 3264 | 3684 | } |
| 3265 | 3685 | print '</select>'; |
| 3266 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3686 | + if ($user->admin) { |
|
| 3687 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3688 | + } |
|
| 3267 | 3689 | } |
| 3268 | 3690 | |
| 3269 | 3691 | /** |
@@ -3276,7 +3698,10 @@ discard block |
||
| 3276 | 3698 | global $langs; |
| 3277 | 3699 | |
| 3278 | 3700 | $num = count($this->cache_demand_reason); |
| 3279 | - if ($num > 0) return 0; // Cache already loaded |
|
| 3701 | + if ($num > 0) { |
|
| 3702 | + return 0; |
|
| 3703 | + } |
|
| 3704 | + // Cache already loaded |
|
| 3280 | 3705 | |
| 3281 | 3706 | $sql = "SELECT rowid, code, label"; |
| 3282 | 3707 | $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; |
@@ -3294,8 +3719,14 @@ discard block |
||
| 3294 | 3719 | |
| 3295 | 3720 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 3296 | 3721 | $label = ($obj->label != '-' ? $obj->label : ''); |
| 3297 | - if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) $label = $langs->trans("DemandReasonType".$obj->code); // So translation key DemandReasonTypeSRC_XXX will work |
|
| 3298 | - if ($langs->trans($obj->code) != $obj->code) $label = $langs->trans($obj->code); // So translation key SRC_XXX will work |
|
| 3722 | + if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) { |
|
| 3723 | + $label = $langs->trans("DemandReasonType".$obj->code); |
|
| 3724 | + } |
|
| 3725 | + // So translation key DemandReasonTypeSRC_XXX will work |
|
| 3726 | + if ($langs->trans($obj->code) != $obj->code) { |
|
| 3727 | + $label = $langs->trans($obj->code); |
|
| 3728 | + } |
|
| 3729 | + // So translation key SRC_XXX will work |
|
| 3299 | 3730 | |
| 3300 | 3731 | $tmparray[$obj->rowid]['id'] = $obj->rowid; |
| 3301 | 3732 | $tmparray[$obj->rowid]['code'] = $obj->code; |
@@ -3330,10 +3761,14 @@ discard block |
||
| 3330 | 3761 | $this->loadCacheInputReason(); |
| 3331 | 3762 | |
| 3332 | 3763 | print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; |
| 3333 | - if ($addempty) print '<option value="0"'.(empty($selected) ? ' selected' : '').'> </option>'; |
|
| 3764 | + if ($addempty) { |
|
| 3765 | + print '<option value="0"'.(empty($selected) ? ' selected' : '').'> </option>'; |
|
| 3766 | + } |
|
| 3334 | 3767 | foreach ($this->cache_demand_reason as $id => $arraydemandreason) |
| 3335 | 3768 | { |
| 3336 | - if ($arraydemandreason['code'] == $exclude) continue; |
|
| 3769 | + if ($arraydemandreason['code'] == $exclude) { |
|
| 3770 | + continue; |
|
| 3771 | + } |
|
| 3337 | 3772 | |
| 3338 | 3773 | if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code'])) |
| 3339 | 3774 | { |
@@ -3346,7 +3781,9 @@ discard block |
||
| 3346 | 3781 | print '</option>'; |
| 3347 | 3782 | } |
| 3348 | 3783 | print '</select>'; |
| 3349 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3784 | + if ($user->admin) { |
|
| 3785 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3786 | + } |
|
| 3350 | 3787 | } |
| 3351 | 3788 | |
| 3352 | 3789 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -3361,7 +3798,10 @@ discard block |
||
| 3361 | 3798 | global $langs; |
| 3362 | 3799 | |
| 3363 | 3800 | $num = count($this->cache_types_paiements); |
| 3364 | - if ($num > 0) return $num; // Cache already loaded |
|
| 3801 | + if ($num > 0) { |
|
| 3802 | + return $num; |
|
| 3803 | + } |
|
| 3804 | + // Cache already loaded |
|
| 3365 | 3805 | |
| 3366 | 3806 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3367 | 3807 | |
@@ -3425,10 +3865,14 @@ discard block |
||
| 3425 | 3865 | $this->load_cache_conditions_paiements(); |
| 3426 | 3866 | |
| 3427 | 3867 | // Set default value if not already set by caller |
| 3428 | - if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; |
|
| 3868 | + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) { |
|
| 3869 | + $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; |
|
| 3870 | + } |
|
| 3429 | 3871 | |
| 3430 | 3872 | print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
| 3431 | - if ($addempty) print '<option value="0"> </option>'; |
|
| 3873 | + if ($addempty) { |
|
| 3874 | + print '<option value="0"> </option>'; |
|
| 3875 | + } |
|
| 3432 | 3876 | foreach ($this->cache_conditions_paiements as $id => $arrayconditions) |
| 3433 | 3877 | { |
| 3434 | 3878 | if ($selected == $id) |
@@ -3441,7 +3885,9 @@ discard block |
||
| 3441 | 3885 | print '</option>'; |
| 3442 | 3886 | } |
| 3443 | 3887 | print '</select>'; |
| 3444 | - if ($user->admin && empty($noinfoadmin)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3888 | + if ($user->admin && empty($noinfoadmin)) { |
|
| 3889 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3890 | + } |
|
| 3445 | 3891 | print ajax_combobox($htmlname); |
| 3446 | 3892 | } |
| 3447 | 3893 | |
@@ -3470,48 +3916,78 @@ discard block |
||
| 3470 | 3916 | dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); |
| 3471 | 3917 | |
| 3472 | 3918 | $filterarray = array(); |
| 3473 | - if ($filtertype == 'CRDT') $filterarray = array(0, 2, 3); |
|
| 3474 | - elseif ($filtertype == 'DBIT') $filterarray = array(1, 2, 3); |
|
| 3475 | - elseif ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype); |
|
| 3919 | + if ($filtertype == 'CRDT') { |
|
| 3920 | + $filterarray = array(0, 2, 3); |
|
| 3921 | + } elseif ($filtertype == 'DBIT') { |
|
| 3922 | + $filterarray = array(1, 2, 3); |
|
| 3923 | + } elseif ($filtertype != '' && $filtertype != '-1') { |
|
| 3924 | + $filterarray = explode(',', $filtertype); |
|
| 3925 | + } |
|
| 3476 | 3926 | |
| 3477 | 3927 | $this->load_cache_types_paiements(); |
| 3478 | 3928 | |
| 3479 | 3929 | // Set default value if not already set by caller |
| 3480 | - if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID; |
|
| 3930 | + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) { |
|
| 3931 | + $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID; |
|
| 3932 | + } |
|
| 3481 | 3933 | |
| 3482 | 3934 | print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
| 3483 | - if ($empty) print '<option value=""> </option>'; |
|
| 3935 | + if ($empty) { |
|
| 3936 | + print '<option value=""> </option>'; |
|
| 3937 | + } |
|
| 3484 | 3938 | foreach ($this->cache_types_paiements as $id => $arraytypes) |
| 3485 | 3939 | { |
| 3486 | 3940 | // If not good status |
| 3487 | - if ($active >= 0 && $arraytypes['active'] != $active) continue; |
|
| 3941 | + if ($active >= 0 && $arraytypes['active'] != $active) { |
|
| 3942 | + continue; |
|
| 3943 | + } |
|
| 3488 | 3944 | |
| 3489 | 3945 | // On passe si on a demande de filtrer sur des modes de paiments particuliers |
| 3490 | - if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) continue; |
|
| 3946 | + if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) { |
|
| 3947 | + continue; |
|
| 3948 | + } |
|
| 3491 | 3949 | |
| 3492 | 3950 | // We discard empty line if showempty is on because an empty line has already been output. |
| 3493 | - if ($empty && empty($arraytypes['code'])) continue; |
|
| 3951 | + if ($empty && empty($arraytypes['code'])) { |
|
| 3952 | + continue; |
|
| 3953 | + } |
|
| 3494 | 3954 | |
| 3495 | - if ($format == 0) print '<option value="'.$id.'"'; |
|
| 3496 | - elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3497 | - elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3498 | - elseif ($format == 3) print '<option value="'.$id.'"'; |
|
| 3955 | + if ($format == 0) { |
|
| 3956 | + print '<option value="'.$id.'"'; |
|
| 3957 | + } elseif ($format == 1) { |
|
| 3958 | + print '<option value="'.$arraytypes['code'].'"'; |
|
| 3959 | + } elseif ($format == 2) { |
|
| 3960 | + print '<option value="'.$arraytypes['code'].'"'; |
|
| 3961 | + } elseif ($format == 3) { |
|
| 3962 | + print '<option value="'.$id.'"'; |
|
| 3963 | + } |
|
| 3499 | 3964 | // Print attribute selected or not |
| 3500 | 3965 | if ($format == 1 || $format == 2) { |
| 3501 | - if ($selected == $arraytypes['code']) print ' selected'; |
|
| 3966 | + if ($selected == $arraytypes['code']) { |
|
| 3967 | + print ' selected'; |
|
| 3968 | + } |
|
| 3502 | 3969 | } else { |
| 3503 | - if ($selected == $id) print ' selected'; |
|
| 3970 | + if ($selected == $id) { |
|
| 3971 | + print ' selected'; |
|
| 3972 | + } |
|
| 3504 | 3973 | } |
| 3505 | 3974 | print '>'; |
| 3506 | - if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3507 | - elseif ($format == 1) $value = $arraytypes['code']; |
|
| 3508 | - elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3509 | - elseif ($format == 3) $value = $arraytypes['code']; |
|
| 3975 | + if ($format == 0) { |
|
| 3976 | + $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3977 | + } elseif ($format == 1) { |
|
| 3978 | + $value = $arraytypes['code']; |
|
| 3979 | + } elseif ($format == 2) { |
|
| 3980 | + $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3981 | + } elseif ($format == 3) { |
|
| 3982 | + $value = $arraytypes['code']; |
|
| 3983 | + } |
|
| 3510 | 3984 | print $value ? $value : ' '; |
| 3511 | 3985 | print '</option>'; |
| 3512 | 3986 | } |
| 3513 | 3987 | print '</select>'; |
| 3514 | - if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3988 | + if ($user->admin && !$noadmininfo) { |
|
| 3989 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3990 | + } |
|
| 3515 | 3991 | print ajax_combobox('select'.$htmlname); |
| 3516 | 3992 | } |
| 3517 | 3993 | |
@@ -3561,7 +4037,10 @@ discard block |
||
| 3561 | 4037 | global $langs; |
| 3562 | 4038 | |
| 3563 | 4039 | $num=count($this->cache_transport_mode); |
| 3564 | - if ($num > 0) return $num; // Cache already loaded |
|
| 4040 | + if ($num > 0) { |
|
| 4041 | + return $num; |
|
| 4042 | + } |
|
| 4043 | + // Cache already loaded |
|
| 3565 | 4044 | |
| 3566 | 4045 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3567 | 4046 | |
@@ -3593,8 +4072,7 @@ discard block |
||
| 3593 | 4072 | $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); |
| 3594 | 4073 | |
| 3595 | 4074 | return $num; |
| 3596 | - } |
|
| 3597 | - else { |
|
| 4075 | + } else { |
|
| 3598 | 4076 | dol_print_error($this->db); |
| 3599 | 4077 | return -1; |
| 3600 | 4078 | } |
@@ -3622,32 +4100,53 @@ discard block |
||
| 3622 | 4100 | $this->load_cache_transport_mode(); |
| 3623 | 4101 | |
| 3624 | 4102 | print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; |
| 3625 | - if ($empty) print '<option value=""> </option>'; |
|
| 4103 | + if ($empty) { |
|
| 4104 | + print '<option value=""> </option>'; |
|
| 4105 | + } |
|
| 3626 | 4106 | foreach ($this->cache_transport_mode as $id => $arraytypes) |
| 3627 | 4107 | { |
| 3628 | 4108 | // If not good status |
| 3629 | - if ($active >= 0 && $arraytypes['active'] != $active) continue; |
|
| 4109 | + if ($active >= 0 && $arraytypes['active'] != $active) { |
|
| 4110 | + continue; |
|
| 4111 | + } |
|
| 3630 | 4112 | |
| 3631 | 4113 | // We discard empty line if showempty is on because an empty line has already been output. |
| 3632 | - if ($empty && empty($arraytypes['code'])) continue; |
|
| 4114 | + if ($empty && empty($arraytypes['code'])) { |
|
| 4115 | + continue; |
|
| 4116 | + } |
|
| 3633 | 4117 | |
| 3634 | - if ($format == 0) print '<option value="'.$id.'"'; |
|
| 3635 | - elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3636 | - elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"'; |
|
| 3637 | - elseif ($format == 3) print '<option value="'.$id.'"'; |
|
| 4118 | + if ($format == 0) { |
|
| 4119 | + print '<option value="'.$id.'"'; |
|
| 4120 | + } elseif ($format == 1) { |
|
| 4121 | + print '<option value="'.$arraytypes['code'].'"'; |
|
| 4122 | + } elseif ($format == 2) { |
|
| 4123 | + print '<option value="'.$arraytypes['code'].'"'; |
|
| 4124 | + } elseif ($format == 3) { |
|
| 4125 | + print '<option value="'.$id.'"'; |
|
| 4126 | + } |
|
| 3638 | 4127 | // If text is selected, we compare with code, else with id |
| 3639 | - if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected'; |
|
| 3640 | - elseif ($selected == $id) print ' selected'; |
|
| 4128 | + if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) { |
|
| 4129 | + print ' selected'; |
|
| 4130 | + } elseif ($selected == $id) { |
|
| 4131 | + print ' selected'; |
|
| 4132 | + } |
|
| 3641 | 4133 | print '>'; |
| 3642 | - if ($format == 0) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3643 | - elseif ($format == 1) $value=$arraytypes['code']; |
|
| 3644 | - elseif ($format == 2) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 3645 | - elseif ($format == 3) $value=$arraytypes['code']; |
|
| 4134 | + if ($format == 0) { |
|
| 4135 | + $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 4136 | + } elseif ($format == 1) { |
|
| 4137 | + $value=$arraytypes['code']; |
|
| 4138 | + } elseif ($format == 2) { |
|
| 4139 | + $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']); |
|
| 4140 | + } elseif ($format == 3) { |
|
| 4141 | + $value=$arraytypes['code']; |
|
| 4142 | + } |
|
| 3646 | 4143 | print $value?$value:' '; |
| 3647 | 4144 | print '</option>'; |
| 3648 | 4145 | } |
| 3649 | 4146 | print '</select>'; |
| 3650 | - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 4147 | + if ($user->admin && ! $noadmininfo) { |
|
| 4148 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 4149 | + } |
|
| 3651 | 4150 | } |
| 3652 | 4151 | |
| 3653 | 4152 | /** |
@@ -3670,7 +4169,9 @@ discard block |
||
| 3670 | 4169 | $sql = "SELECT rowid, code, libelle as label"; |
| 3671 | 4170 | $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; |
| 3672 | 4171 | $sql .= " WHERE active > 0"; |
| 3673 | - if ($filtre) $sql .= " AND ".$filtre; |
|
| 4172 | + if ($filtre) { |
|
| 4173 | + $sql .= " AND ".$filtre; |
|
| 4174 | + } |
|
| 3674 | 4175 | $sql .= " ORDER BY libelle ASC"; |
| 3675 | 4176 | |
| 3676 | 4177 | dol_syslog(get_class($this)."::selectShippingMode", LOG_DEBUG); |
@@ -3695,7 +4196,9 @@ discard block |
||
| 3695 | 4196 | $i++; |
| 3696 | 4197 | } |
| 3697 | 4198 | print "</select>"; |
| 3698 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 4199 | + if ($user->admin) { |
|
| 4200 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 4201 | + } |
|
| 3699 | 4202 | } else { |
| 3700 | 4203 | print $langs->trans("NoShippingMethodDefined"); |
| 3701 | 4204 | } |
@@ -3813,15 +4316,19 @@ discard block |
||
| 3813 | 4316 | $resql = $this->db->query($sql); |
| 3814 | 4317 | if ($resql && $this->db->num_rows($resql) > 0) |
| 3815 | 4318 | { |
| 3816 | - if ($showempty) $return .= '<option value="none"></option>'; |
|
| 4319 | + if ($showempty) { |
|
| 4320 | + $return .= '<option value="none"></option>'; |
|
| 4321 | + } |
|
| 3817 | 4322 | |
| 3818 | 4323 | while ($res = $this->db->fetch_object($resql)) |
| 3819 | 4324 | { |
| 3820 | 4325 | $unitLabel = $res->label; |
| 3821 | - if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before |
|
| 4326 | + if (!empty($langs->tab_translate['unit'.$res->code])) { |
|
| 4327 | + // check if Translation is available before |
|
| 3822 | 4328 | { |
| 3823 | 4329 | $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; |
| 3824 | 4330 | } |
| 4331 | + } |
|
| 3825 | 4332 | |
| 3826 | 4333 | if ($selected == $res->rowid) |
| 3827 | 4334 | { |
@@ -3860,8 +4367,12 @@ discard block |
||
| 3860 | 4367 | $sql = "SELECT rowid, label, bank, clos as status, currency_code"; |
| 3861 | 4368 | $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; |
| 3862 | 4369 | $sql .= " WHERE entity IN (".getEntity('bank_account').")"; |
| 3863 | - if ($status != 2) $sql .= " AND clos = ".(int) $status; |
|
| 3864 | - if ($filtre) $sql .= " AND ".$filtre; |
|
| 4370 | + if ($status != 2) { |
|
| 4371 | + $sql .= " AND clos = ".(int) $status; |
|
| 4372 | + } |
|
| 4373 | + if ($filtre) { |
|
| 4374 | + $sql .= " AND ".$filtre; |
|
| 4375 | + } |
|
| 3865 | 4376 | $sql .= " ORDER BY label"; |
| 3866 | 4377 | |
| 3867 | 4378 | dol_syslog(get_class($this)."::select_comptes", LOG_DEBUG); |
@@ -3888,15 +4399,22 @@ discard block |
||
| 3888 | 4399 | print '<option value="'.$obj->rowid.'">'; |
| 3889 | 4400 | } |
| 3890 | 4401 | print trim($obj->label); |
| 3891 | - if ($showcurrency) print ' ('.$obj->currency_code.')'; |
|
| 3892 | - if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; |
|
| 4402 | + if ($showcurrency) { |
|
| 4403 | + print ' ('.$obj->currency_code.')'; |
|
| 4404 | + } |
|
| 4405 | + if ($status == 2 && $obj->status == 1) { |
|
| 4406 | + print ' ('.$langs->trans("Closed").')'; |
|
| 4407 | + } |
|
| 3893 | 4408 | print '</option>'; |
| 3894 | 4409 | $i++; |
| 3895 | 4410 | } |
| 3896 | 4411 | print "</select>"; |
| 3897 | 4412 | } else { |
| 3898 | - if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>'; |
|
| 3899 | - else print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>'; |
|
| 4413 | + if ($status == 0) { |
|
| 4414 | + print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>'; |
|
| 4415 | + } else { |
|
| 4416 | + print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>'; |
|
| 4417 | + } |
|
| 3900 | 4418 | } |
| 3901 | 4419 | } else { |
| 3902 | 4420 | dol_print_error($this->db); |
@@ -3927,8 +4445,12 @@ discard block |
||
| 3927 | 4445 | $sql = "SELECT rowid, name, fk_country, status, entity"; |
| 3928 | 4446 | $sql .= " FROM ".MAIN_DB_PREFIX."establishment"; |
| 3929 | 4447 | $sql .= " WHERE 1=1"; |
| 3930 | - if ($status != 2) $sql .= " AND status = ".(int) $status; |
|
| 3931 | - if ($filtre) $sql .= " AND ".$filtre; |
|
| 4448 | + if ($status != 2) { |
|
| 4449 | + $sql .= " AND status = ".(int) $status; |
|
| 4450 | + } |
|
| 4451 | + if ($filtre) { |
|
| 4452 | + $sql .= " AND ".$filtre; |
|
| 4453 | + } |
|
| 3932 | 4454 | $sql .= " ORDER BY name"; |
| 3933 | 4455 | |
| 3934 | 4456 | dol_syslog(get_class($this)."::select_establishment", LOG_DEBUG); |
@@ -3955,14 +4477,19 @@ discard block |
||
| 3955 | 4477 | print '<option value="'.$obj->rowid.'">'; |
| 3956 | 4478 | } |
| 3957 | 4479 | print trim($obj->name); |
| 3958 | - if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; |
|
| 4480 | + if ($status == 2 && $obj->status == 1) { |
|
| 4481 | + print ' ('.$langs->trans("Closed").')'; |
|
| 4482 | + } |
|
| 3959 | 4483 | print '</option>'; |
| 3960 | 4484 | $i++; |
| 3961 | 4485 | } |
| 3962 | 4486 | print "</select>"; |
| 3963 | 4487 | } else { |
| 3964 | - if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveEstablishmentDefined").'</span>'; |
|
| 3965 | - else print '<span class="opacitymedium">'.$langs->trans("NoEstablishmentFound").'</span>'; |
|
| 4488 | + if ($status == 0) { |
|
| 4489 | + print '<span class="opacitymedium">'.$langs->trans("NoActiveEstablishmentDefined").'</span>'; |
|
| 4490 | + } else { |
|
| 4491 | + print '<span class="opacitymedium">'.$langs->trans("NoEstablishmentFound").'</span>'; |
|
| 4492 | + } |
|
| 3966 | 4493 | } |
| 3967 | 4494 | } else { |
| 3968 | 4495 | dol_print_error($this->db); |
@@ -3986,7 +4513,9 @@ discard block |
||
| 3986 | 4513 | print '<input type="hidden" name="action" value="setbankaccount">'; |
| 3987 | 4514 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 3988 | 4515 | $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty); |
| 3989 | - if ($nbaccountfound > 0) print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 4516 | + if ($nbaccountfound > 0) { |
|
| 4517 | + print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 4518 | + } |
|
| 3990 | 4519 | print '</form>'; |
| 3991 | 4520 | } else { |
| 3992 | 4521 | $langs->load('banks'); |
@@ -3995,7 +4524,9 @@ discard block |
||
| 3995 | 4524 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
| 3996 | 4525 | $bankstatic = new Account($this->db); |
| 3997 | 4526 | $result = $bankstatic->fetch($selected); |
| 3998 | - if ($result) print $bankstatic->getNomUrl(1); |
|
| 4527 | + if ($result) { |
|
| 4528 | + print $bankstatic->getNomUrl(1); |
|
| 4529 | + } |
|
| 3999 | 4530 | } else { |
| 4000 | 4531 | print " "; |
| 4001 | 4532 | } |
@@ -4051,11 +4582,15 @@ discard block |
||
| 4051 | 4582 | while ($i < $num) |
| 4052 | 4583 | { |
| 4053 | 4584 | $objp = $this->db->fetch_object($result); |
| 4054 | - if ($objp) $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label); |
|
| 4585 | + if ($objp) { |
|
| 4586 | + $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label); |
|
| 4587 | + } |
|
| 4055 | 4588 | $i++; |
| 4056 | 4589 | } |
| 4057 | 4590 | $this->db->free($result); |
| 4058 | - } else dol_print_error($this->db); |
|
| 4591 | + } else { |
|
| 4592 | + dol_print_error($this->db); |
|
| 4593 | + } |
|
| 4059 | 4594 | } else { |
| 4060 | 4595 | $cat = new Categorie($this->db); |
| 4061 | 4596 | $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); |
@@ -4065,8 +4600,9 @@ discard block |
||
| 4065 | 4600 | $outarray = array(); |
| 4066 | 4601 | if (is_array($cate_arbo)) |
| 4067 | 4602 | { |
| 4068 | - if (!count($cate_arbo)) $output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>'; |
|
| 4069 | - else { |
|
| 4603 | + if (!count($cate_arbo)) { |
|
| 4604 | + $output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>'; |
|
| 4605 | + } else { |
|
| 4070 | 4606 | $output .= '<option value="-1"> </option>'; |
| 4071 | 4607 | foreach ($cate_arbo as $key => $value) |
| 4072 | 4608 | { |
@@ -4085,7 +4621,9 @@ discard block |
||
| 4085 | 4621 | $output .= '</select>'; |
| 4086 | 4622 | $output .= "\n"; |
| 4087 | 4623 | |
| 4088 | - if ($outputmode) return $outarray; |
|
| 4624 | + if ($outputmode) { |
|
| 4625 | + return $outarray; |
|
| 4626 | + } |
|
| 4089 | 4627 | return $output; |
| 4090 | 4628 | } |
| 4091 | 4629 | |
@@ -4148,7 +4686,9 @@ discard block |
||
| 4148 | 4686 | |
| 4149 | 4687 | // Clean parameters |
| 4150 | 4688 | $newselectedchoice = empty($selectedchoice) ? "no" : $selectedchoice; |
| 4151 | - if ($conf->browser->layout == 'phone') $width = '95%'; |
|
| 4689 | + if ($conf->browser->layout == 'phone') { |
|
| 4690 | + $width = '95%'; |
|
| 4691 | + } |
|
| 4152 | 4692 | |
| 4153 | 4693 | // Set height automatically if not defined |
| 4154 | 4694 | if (empty($height)) { |
@@ -4192,7 +4732,9 @@ discard block |
||
| 4192 | 4732 | } elseif ($input['type'] == 'select') |
| 4193 | 4733 | { |
| 4194 | 4734 | $more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">'; |
| 4195 | - if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd left">'; |
|
| 4735 | + if (!empty($input['label'])) { |
|
| 4736 | + $more .= $input['label'].'</div><div class="tagtd left">'; |
|
| 4737 | + } |
|
| 4196 | 4738 | $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); |
| 4197 | 4739 | $more .= '</div></div>'."\n"; |
| 4198 | 4740 | } elseif ($input['type'] == 'checkbox') |
@@ -4200,9 +4742,15 @@ discard block |
||
| 4200 | 4742 | $more .= '<div class="tagtr">'; |
| 4201 | 4743 | $more .= '<div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">'.$input['label'].' </div><div class="tagtd">'; |
| 4202 | 4744 | $more .= '<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr; |
| 4203 | - if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more .= ' checked'; |
|
| 4204 | - if (is_bool($input['value']) && $input['value']) $more .= ' checked'; |
|
| 4205 | - if (isset($input['disabled'])) $more .= ' disabled'; |
|
| 4745 | + if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') { |
|
| 4746 | + $more .= ' checked'; |
|
| 4747 | + } |
|
| 4748 | + if (is_bool($input['value']) && $input['value']) { |
|
| 4749 | + $more .= ' checked'; |
|
| 4750 | + } |
|
| 4751 | + if (isset($input['disabled'])) { |
|
| 4752 | + $more .= ' disabled'; |
|
| 4753 | + } |
|
| 4206 | 4754 | $more .= ' /></div>'; |
| 4207 | 4755 | $more .= '</div>'."\n"; |
| 4208 | 4756 | } elseif ($input['type'] == 'radio') |
@@ -4211,10 +4759,15 @@ discard block |
||
| 4211 | 4759 | foreach ($input['values'] as $selkey => $selval) |
| 4212 | 4760 | { |
| 4213 | 4761 | $more .= '<div class="tagtr">'; |
| 4214 | - if ($i == 0) $more .= '<div class="tagtd'.(empty($input['tdclass']) ? ' tdtop' : (' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>'; |
|
| 4215 | - else $more .= '<div clas="tagtd'.(empty($input['tdclass']) ? '' : (' "'.$input['tdclass'])).'"> </div>'; |
|
| 4762 | + if ($i == 0) { |
|
| 4763 | + $more .= '<div class="tagtd'.(empty($input['tdclass']) ? ' tdtop' : (' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>'; |
|
| 4764 | + } else { |
|
| 4765 | + $more .= '<div clas="tagtd'.(empty($input['tdclass']) ? '' : (' "'.$input['tdclass'])).'"> </div>'; |
|
| 4766 | + } |
|
| 4216 | 4767 | $more .= '<div class="tagtd"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr; |
| 4217 | - if ($input['disabled']) $more .= ' disabled'; |
|
| 4768 | + if ($input['disabled']) { |
|
| 4769 | + $more .= ' disabled'; |
|
| 4770 | + } |
|
| 4218 | 4771 | $more .= ' /> '; |
| 4219 | 4772 | $more .= $selval; |
| 4220 | 4773 | $more .= '</div></div>'."\n"; |
@@ -4234,7 +4787,9 @@ discard block |
||
| 4234 | 4787 | } elseif ($input['type'] == 'other') |
| 4235 | 4788 | { |
| 4236 | 4789 | $more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">'; |
| 4237 | - if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd">'; |
|
| 4790 | + if (!empty($input['label'])) { |
|
| 4791 | + $more .= $input['label'].'</div><div class="tagtd">'; |
|
| 4792 | + } |
|
| 4238 | 4793 | $more .= $input['value']; |
| 4239 | 4794 | $more .= '</div></div>'."\n"; |
| 4240 | 4795 | } elseif ($input['type'] == 'onecolumn') |
@@ -4252,8 +4807,12 @@ discard block |
||
| 4252 | 4807 | // JQUI method dialog is broken with jmobile, we use standard HTML. |
| 4253 | 4808 | // Note: When using dol_use_jmobile or no js, you must also check code for button use a GET url with action=xxx and check that you also output the confirm code when action=xxx |
| 4254 | 4809 | // See page product/card.php for example |
| 4255 | - if (!empty($conf->dol_use_jmobile)) $useajax = 0; |
|
| 4256 | - if (empty($conf->use_javascript_ajax)) $useajax = 0; |
|
| 4810 | + if (!empty($conf->dol_use_jmobile)) { |
|
| 4811 | + $useajax = 0; |
|
| 4812 | + } |
|
| 4813 | + if (empty($conf->use_javascript_ajax)) { |
|
| 4814 | + $useajax = 0; |
|
| 4815 | + } |
|
| 4257 | 4816 | |
| 4258 | 4817 | if ($useajax) |
| 4259 | 4818 | { |
@@ -4275,8 +4834,12 @@ discard block |
||
| 4275 | 4834 | foreach ($formquestion as $key => $input) |
| 4276 | 4835 | { |
| 4277 | 4836 | //print "xx ".$key." rr ".is_array($input)."<br>\n"; |
| 4278 | - if (is_array($input) && isset($input['name'])) array_push($inputok, $input['name']); |
|
| 4279 | - if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko, $input['name']); |
|
| 4837 | + if (is_array($input) && isset($input['name'])) { |
|
| 4838 | + array_push($inputok, $input['name']); |
|
| 4839 | + } |
|
| 4840 | + if (isset($input['inputko']) && $input['inputko'] == 1) { |
|
| 4841 | + array_push($inputko, $input['name']); |
|
| 4842 | + } |
|
| 4280 | 4843 | } |
| 4281 | 4844 | } |
| 4282 | 4845 | // Show JQuery confirm box. |
@@ -4364,7 +4927,9 @@ discard block |
||
| 4364 | 4927 | } else { |
| 4365 | 4928 | $formconfirm .= "\n<!-- begin formconfirm page=".$page." -->\n"; |
| 4366 | 4929 | |
| 4367 | - if (empty($disableformtag)) $formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n"; |
|
| 4930 | + if (empty($disableformtag)) { |
|
| 4931 | + $formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n"; |
|
| 4932 | + } |
|
| 4368 | 4933 | |
| 4369 | 4934 | $formconfirm .= '<input type="hidden" name="action" value="'.$action.'">'."\n"; |
| 4370 | 4935 | $formconfirm .= '<input type="hidden" name="token" value="'.newToken().'">'."\n"; |
@@ -4398,7 +4963,9 @@ discard block |
||
| 4398 | 4963 | |
| 4399 | 4964 | $formconfirm .= '</table>'."\n"; |
| 4400 | 4965 | |
| 4401 | - if (empty($disableformtag)) $formconfirm .= "</form>\n"; |
|
| 4966 | + if (empty($disableformtag)) { |
|
| 4967 | + $formconfirm .= "</form>\n"; |
|
| 4968 | + } |
|
| 4402 | 4969 | $formconfirm .= '<br>'; |
| 4403 | 4970 | |
| 4404 | 4971 | $formconfirm .= "<!-- end formconfirm -->\n"; |
@@ -4601,11 +5168,16 @@ discard block |
||
| 4601 | 5168 | $ret .= '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
| 4602 | 5169 | $ret .= '</tr></table></form>'; |
| 4603 | 5170 | } else { |
| 4604 | - if ($displayhour) $ret .= dol_print_date($selected, 'dayhour'); |
|
| 4605 | - else $ret .= dol_print_date($selected, 'day'); |
|
| 5171 | + if ($displayhour) { |
|
| 5172 | + $ret .= dol_print_date($selected, 'dayhour'); |
|
| 5173 | + } else { |
|
| 5174 | + $ret .= dol_print_date($selected, 'day'); |
|
| 5175 | + } |
|
| 4606 | 5176 | } |
| 4607 | 5177 | |
| 4608 | - if (empty($nooutput)) print $ret; |
|
| 5178 | + if (empty($nooutput)) { |
|
| 5179 | + print $ret; |
|
| 5180 | + } |
|
| 4609 | 5181 | return $ret; |
| 4610 | 5182 | } |
| 4611 | 5183 | |
@@ -4704,8 +5276,7 @@ discard block |
||
| 4704 | 5276 | $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); |
| 4705 | 5277 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
| 4706 | 5278 | print '</form>'; |
| 4707 | - } |
|
| 4708 | - else { |
|
| 5279 | + } else { |
|
| 4709 | 5280 | if ($selected) |
| 4710 | 5281 | { |
| 4711 | 5282 | $this->load_cache_transport_mode(); |
@@ -4774,7 +5345,9 @@ discard block |
||
| 4774 | 5345 | if (!empty($rate)) |
| 4775 | 5346 | { |
| 4776 | 5347 | print price($rate, 1, $langs, 1, 0); |
| 4777 | - if ($currency && $rate != 1) print ' ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; |
|
| 5348 | + if ($currency && $rate != 1) { |
|
| 5349 | + print ' ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; |
|
| 5350 | + } |
|
| 4778 | 5351 | } else { |
| 4779 | 5352 | print 1; |
| 4780 | 5353 | } |
@@ -4811,24 +5384,42 @@ discard block |
||
| 4811 | 5384 | if (!empty($discount_type)) { |
| 4812 | 5385 | if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) |
| 4813 | 5386 | { |
| 4814 | - if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4815 | - else $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 5387 | + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") { |
|
| 5388 | + $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 5389 | + } |
|
| 5390 | + // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 5391 | + else { |
|
| 5392 | + $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 5393 | + } |
|
| 4816 | 5394 | } else { |
| 4817 | - if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 4818 | - else $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 5395 | + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") { |
|
| 5396 | + $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 5397 | + } else { |
|
| 5398 | + $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 5399 | + } |
|
| 4819 | 5400 | } |
| 4820 | 5401 | } else { |
| 4821 | 5402 | if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) |
| 4822 | 5403 | { |
| 4823 | - if (!$filter || $filter == "fk_facture_source IS NULL") $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4824 | - else $translationKey = 'CompanyHasCreditNote'; |
|
| 5404 | + if (!$filter || $filter == "fk_facture_source IS NULL") { |
|
| 5405 | + $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 5406 | + } |
|
| 5407 | + // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 5408 | + else { |
|
| 5409 | + $translationKey = 'CompanyHasCreditNote'; |
|
| 5410 | + } |
|
| 4825 | 5411 | } else { |
| 4826 | - if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 4827 | - else $translationKey = 'CompanyHasCreditNote'; |
|
| 5412 | + if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") { |
|
| 5413 | + $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 5414 | + } else { |
|
| 5415 | + $translationKey = 'CompanyHasCreditNote'; |
|
| 5416 | + } |
|
| 4828 | 5417 | } |
| 4829 | 5418 | } |
| 4830 | 5419 | print $langs->trans($translationKey, price($amount, 0, $langs, 0, 0, -1, $conf->currency)); |
| 4831 | - if (empty($hidelist)) print ': '; |
|
| 5420 | + if (empty($hidelist)) { |
|
| 5421 | + print ': '; |
|
| 5422 | + } |
|
| 4832 | 5423 | print '</div>'; |
| 4833 | 5424 | if (empty($hidelist)) |
| 4834 | 5425 | { |
@@ -4839,15 +5430,19 @@ discard block |
||
| 4839 | 5430 | } else { |
| 4840 | 5431 | $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available |
| 4841 | 5432 | } |
| 4842 | - if ($filter) $newfilter .= ' AND ('.$filter.')'; |
|
| 5433 | + if ($filter) { |
|
| 5434 | + $newfilter .= ' AND ('.$filter.')'; |
|
| 5435 | + } |
|
| 4843 | 5436 | $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); |
| 4844 | 5437 | if ($nbqualifiedlines > 0) |
| 4845 | 5438 | { |
| 4846 | 5439 | print ' <input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"'; |
| 4847 | - if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") |
|
| 4848 | - print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"'; |
|
| 4849 | - if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") |
|
| 4850 | - print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"'; |
|
| 5440 | + if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") { |
|
| 5441 | + print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"'; |
|
| 5442 | + } |
|
| 5443 | + if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") { |
|
| 5444 | + print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"'; |
|
| 5445 | + } |
|
| 4851 | 5446 | |
| 4852 | 5447 | print '>'; |
| 4853 | 5448 | } |
@@ -4956,8 +5551,11 @@ discard block |
||
| 4956 | 5551 | } |
| 4957 | 5552 | } |
| 4958 | 5553 | |
| 4959 | - if ($nooutput) return $out; |
|
| 4960 | - else print $out; |
|
| 5554 | + if ($nooutput) { |
|
| 5555 | + return $out; |
|
| 5556 | + } else { |
|
| 5557 | + print $out; |
|
| 5558 | + } |
|
| 4961 | 5559 | } |
| 4962 | 5560 | |
| 4963 | 5561 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -4991,7 +5589,10 @@ discard block |
||
| 4991 | 5589 | |
| 4992 | 5590 | $out = ''; |
| 4993 | 5591 | |
| 4994 | - if ($selected == 'euro' || $selected == 'euros') $selected = 'EUR'; // Pour compatibilite |
|
| 5592 | + if ($selected == 'euro' || $selected == 'euros') { |
|
| 5593 | + $selected = 'EUR'; |
|
| 5594 | + } |
|
| 5595 | + // Pour compatibilite |
|
| 4995 | 5596 | |
| 4996 | 5597 | $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 4997 | 5598 | foreach ($langs->cache_currencies as $code_iso => $currency) |
@@ -5012,7 +5613,9 @@ discard block |
||
| 5012 | 5613 | $out .= '</option>'; |
| 5013 | 5614 | } |
| 5014 | 5615 | $out .= '</select>'; |
| 5015 | - if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 5616 | + if ($user->admin) { |
|
| 5617 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 5618 | + } |
|
| 5016 | 5619 | |
| 5017 | 5620 | // Make select dynamic |
| 5018 | 5621 | include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
@@ -5042,12 +5645,16 @@ discard block |
||
| 5042 | 5645 | $resql = $this->db->query($sql); |
| 5043 | 5646 | if ($resql) |
| 5044 | 5647 | { |
| 5045 | - while ($obj = $this->db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; |
|
| 5648 | + while ($obj = $this->db->fetch_object($resql)) { |
|
| 5649 | + $TCurrency[$obj->code] = $obj->code; |
|
| 5650 | + } |
|
| 5046 | 5651 | } |
| 5047 | 5652 | |
| 5048 | 5653 | $out = ''; |
| 5049 | 5654 | $out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 5050 | - if ($useempty) $out .= '<option value=""> </option>'; |
|
| 5655 | + if ($useempty) { |
|
| 5656 | + $out .= '<option value=""> </option>'; |
|
| 5657 | + } |
|
| 5051 | 5658 | // If company current currency not in table, we add it into list. Should always be available. |
| 5052 | 5659 | if (!in_array($conf->currency, $TCurrency)) |
| 5053 | 5660 | { |
@@ -5059,8 +5666,11 @@ discard block |
||
| 5059 | 5666 | { |
| 5060 | 5667 | if (isset($TCurrency[$code_iso])) |
| 5061 | 5668 | { |
| 5062 | - if (!empty($selected) && $selected == $code_iso) $out .= '<option value="'.$code_iso.'" selected="selected">'; |
|
| 5063 | - else $out .= '<option value="'.$code_iso.'">'; |
|
| 5669 | + if (!empty($selected) && $selected == $code_iso) { |
|
| 5670 | + $out .= '<option value="'.$code_iso.'" selected="selected">'; |
|
| 5671 | + } else { |
|
| 5672 | + $out .= '<option value="'.$code_iso.'">'; |
|
| 5673 | + } |
|
| 5064 | 5674 | |
| 5065 | 5675 | $out .= $currency['label']; |
| 5066 | 5676 | $out .= ' ('.$langs->getCurrencySymbol($code_iso).')'; |
@@ -5090,7 +5700,10 @@ discard block |
||
| 5090 | 5700 | global $langs; |
| 5091 | 5701 | |
| 5092 | 5702 | $num = count($this->cache_vatrates); |
| 5093 | - if ($num > 0) return $num; // Cache already loaded |
|
| 5703 | + if ($num > 0) { |
|
| 5704 | + return $num; |
|
| 5705 | + } |
|
| 5706 | + // Cache already loaded |
|
| 5094 | 5707 | |
| 5095 | 5708 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 5096 | 5709 | |
@@ -5122,10 +5735,18 @@ discard block |
||
| 5122 | 5735 | $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or * |
| 5123 | 5736 | $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1 ? $obj->localtax1 : '0').'/'.($obj->localtax2 ? $obj->localtax2 : '0').($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label |
| 5124 | 5737 | $positiverates = ''; |
| 5125 | - if ($obj->taux) $positiverates .= ($positiverates ? '/' : '').$obj->taux; |
|
| 5126 | - if ($obj->localtax1) $positiverates .= ($positiverates ? '/' : '').$obj->localtax1; |
|
| 5127 | - if ($obj->localtax2) $positiverates .= ($positiverates ? '/' : '').$obj->localtax2; |
|
| 5128 | - if (empty($positiverates)) $positiverates = '0'; |
|
| 5738 | + if ($obj->taux) { |
|
| 5739 | + $positiverates .= ($positiverates ? '/' : '').$obj->taux; |
|
| 5740 | + } |
|
| 5741 | + if ($obj->localtax1) { |
|
| 5742 | + $positiverates .= ($positiverates ? '/' : '').$obj->localtax1; |
|
| 5743 | + } |
|
| 5744 | + if ($obj->localtax2) { |
|
| 5745 | + $positiverates .= ($positiverates ? '/' : '').$obj->localtax2; |
|
| 5746 | + } |
|
| 5747 | + if (empty($positiverates)) { |
|
| 5748 | + $positiverates = '0'; |
|
| 5749 | + } |
|
| 5129 | 5750 | $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label |
| 5130 | 5751 | } |
| 5131 | 5752 | |
@@ -5207,28 +5828,36 @@ discard block |
||
| 5207 | 5828 | } else { |
| 5208 | 5829 | $code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente |
| 5209 | 5830 | } |
| 5210 | - if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) // If option to have vat for end customer for services is on |
|
| 5831 | + if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { |
|
| 5832 | + // If option to have vat for end customer for services is on |
|
| 5211 | 5833 | { |
| 5212 | 5834 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
| 5835 | + } |
|
| 5213 | 5836 | if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) |
| 5214 | 5837 | { |
| 5215 | 5838 | // We also add the buyer |
| 5216 | 5839 | if (is_numeric($type)) |
| 5217 | 5840 | { |
| 5218 | - if ($type == 1) // We know product is a service |
|
| 5841 | + if ($type == 1) { |
|
| 5842 | + // We know product is a service |
|
| 5219 | 5843 | { |
| 5220 | 5844 | $code_country .= ",'".$societe_acheteuse->country_code."'"; |
| 5221 | 5845 | } |
| 5222 | - } elseif (!$idprod) // We don't know type of product |
|
| 5846 | + } |
|
| 5847 | + } elseif (!$idprod) { |
|
| 5848 | + // We don't know type of product |
|
| 5223 | 5849 | { |
| 5224 | 5850 | $code_country .= ",'".$societe_acheteuse->country_code."'"; |
| 5851 | + } |
|
| 5225 | 5852 | } else { |
| 5226 | 5853 | $prodstatic = new Product($this->db); |
| 5227 | 5854 | $prodstatic->fetch($idprod); |
| 5228 | - if ($prodstatic->type == Product::TYPE_SERVICE) // We know product is a service |
|
| 5855 | + if ($prodstatic->type == Product::TYPE_SERVICE) { |
|
| 5856 | + // We know product is a service |
|
| 5229 | 5857 | { |
| 5230 | 5858 | $code_country .= ",'".$societe_acheteuse->country_code."'"; |
| 5231 | 5859 | } |
| 5860 | + } |
|
| 5232 | 5861 | } |
| 5233 | 5862 | } |
| 5234 | 5863 | } |
@@ -5248,15 +5877,20 @@ discard block |
||
| 5248 | 5877 | $defaultcode = $reg[1]; |
| 5249 | 5878 | $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); |
| 5250 | 5879 | } |
| 5251 | - if (empty($defaulttx)) $defaultnpr = 0; |
|
| 5880 | + if (empty($defaulttx)) { |
|
| 5881 | + $defaultnpr = 0; |
|
| 5882 | + } |
|
| 5252 | 5883 | } |
| 5253 | 5884 | |
| 5254 | 5885 | // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. |
| 5255 | 5886 | // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant |
| 5256 | 5887 | if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) |
| 5257 | 5888 | { |
| 5258 | - if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) $defaulttx = $this->cache_vatrates[$num - 1]['txtva']; |
|
| 5259 | - else $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); |
|
| 5889 | + if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) { |
|
| 5890 | + $defaulttx = $this->cache_vatrates[$num - 1]['txtva']; |
|
| 5891 | + } else { |
|
| 5892 | + $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); |
|
| 5893 | + } |
|
| 5260 | 5894 | } |
| 5261 | 5895 | |
| 5262 | 5896 | // Disabled if seller is not subject to VAT |
@@ -5272,28 +5906,38 @@ discard block |
||
| 5272 | 5906 | } |
| 5273 | 5907 | } |
| 5274 | 5908 | |
| 5275 | - if (!$options_only) $return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>'; |
|
| 5909 | + if (!$options_only) { |
|
| 5910 | + $return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>'; |
|
| 5911 | + } |
|
| 5276 | 5912 | |
| 5277 | 5913 | $selectedfound = false; |
| 5278 | 5914 | foreach ($this->cache_vatrates as $rate) |
| 5279 | 5915 | { |
| 5280 | 5916 | // Keep only 0 if seller is not subject to VAT |
| 5281 | - if ($disabled && $rate['txtva'] != 0) continue; |
|
| 5917 | + if ($disabled && $rate['txtva'] != 0) { |
|
| 5918 | + continue; |
|
| 5919 | + } |
|
| 5282 | 5920 | |
| 5283 | 5921 | // Define key to use into select list |
| 5284 | 5922 | $key = $rate['txtva']; |
| 5285 | 5923 | $key .= $rate['nprtva'] ? '*' : ''; |
| 5286 | - if ($mode > 0 && $rate['code']) $key .= ' ('.$rate['code'].')'; |
|
| 5287 | - if ($mode < 0) $key = $rate['rowid']; |
|
| 5924 | + if ($mode > 0 && $rate['code']) { |
|
| 5925 | + $key .= ' ('.$rate['code'].')'; |
|
| 5926 | + } |
|
| 5927 | + if ($mode < 0) { |
|
| 5928 | + $key = $rate['rowid']; |
|
| 5929 | + } |
|
| 5288 | 5930 | |
| 5289 | 5931 | $return .= '<option value="'.$key.'"'; |
| 5290 | 5932 | if (!$selectedfound) |
| 5291 | 5933 | { |
| 5292 | - if ($defaultcode) // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag |
|
| 5934 | + if ($defaultcode) { |
|
| 5935 | + // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag |
|
| 5293 | 5936 | { |
| 5294 | 5937 | if ($defaultcode == $rate['code']) |
| 5295 | 5938 | { |
| 5296 | 5939 | $return .= ' selected'; |
| 5940 | + } |
|
| 5297 | 5941 | $selectedfound = true; |
| 5298 | 5942 | } |
| 5299 | 5943 | } elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) |
@@ -5316,7 +5960,9 @@ discard block |
||
| 5316 | 5960 | $return .= '</option>'; |
| 5317 | 5961 | } |
| 5318 | 5962 | |
| 5319 | - if (!$options_only) $return .= '</select>'; |
|
| 5963 | + if (!$options_only) { |
|
| 5964 | + $return .= '</select>'; |
|
| 5965 | + } |
|
| 5320 | 5966 | } else { |
| 5321 | 5967 | $return .= $this->error; |
| 5322 | 5968 | } |
@@ -5416,12 +6062,20 @@ discard block |
||
| 5416 | 6062 | |
| 5417 | 6063 | $retstring = ''; |
| 5418 | 6064 | |
| 5419 | - if ($prefix == '') $prefix = 're'; |
|
| 5420 | - if ($h == '') $h = 0; |
|
| 5421 | - if ($m == '') $m = 0; |
|
| 6065 | + if ($prefix == '') { |
|
| 6066 | + $prefix = 're'; |
|
| 6067 | + } |
|
| 6068 | + if ($h == '') { |
|
| 6069 | + $h = 0; |
|
| 6070 | + } |
|
| 6071 | + if ($m == '') { |
|
| 6072 | + $m = 0; |
|
| 6073 | + } |
|
| 5422 | 6074 | $emptydate = 0; |
| 5423 | 6075 | $emptyhours = 0; |
| 5424 | - if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1; |
|
| 6076 | + if ($stepminutes <= 0 || $stepminutes > 30) { |
|
| 6077 | + $stepminutes = 1; |
|
| 6078 | + } |
|
| 5425 | 6079 | if ($empty == 1) { $emptydate = 1; $emptyhours = 1; } |
| 5426 | 6080 | if ($empty == 2) { $emptydate = 0; $emptyhours = 1; } |
| 5427 | 6081 | $orig_set_time = $set_time; |
@@ -5434,10 +6088,12 @@ discard block |
||
| 5434 | 6088 | |
| 5435 | 6089 | // Analysis of the pre-selection date |
| 5436 | 6090 | $reg = array(); |
| 5437 | - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) // deprecated usage |
|
| 6091 | + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) { |
|
| 6092 | + // deprecated usage |
|
| 5438 | 6093 | { |
| 5439 | 6094 | // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' |
| 5440 | 6095 | $syear = (!empty($reg[1]) ? $reg[1] : ''); |
| 6096 | + } |
|
| 5441 | 6097 | $smonth = (!empty($reg[2]) ? $reg[2] : ''); |
| 5442 | 6098 | $sday = (!empty($reg[3]) ? $reg[3] : ''); |
| 5443 | 6099 | $shour = (!empty($reg[4]) ? $reg[4] : ''); |
@@ -5467,8 +6123,12 @@ discard block |
||
| 5467 | 6123 | $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_MIN; |
| 5468 | 6124 | $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_SEC; |
| 5469 | 6125 | } |
| 5470 | - if ($h == 3) $shour = ''; |
|
| 5471 | - if ($m == 3) $smin = ''; |
|
| 6126 | + if ($h == 3) { |
|
| 6127 | + $shour = ''; |
|
| 6128 | + } |
|
| 6129 | + if ($m == 3) { |
|
| 6130 | + $smin = ''; |
|
| 6131 | + } |
|
| 5472 | 6132 | |
| 5473 | 6133 | // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' |
| 5474 | 6134 | $usecalendar = 'combo'; |
@@ -5505,7 +6165,9 @@ discard block |
||
| 5505 | 6165 | $base = DOL_URL_ROOT.'/core/'; |
| 5506 | 6166 | $retstring .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"'; |
| 5507 | 6167 | $retstring .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').'</button>'; |
| 5508 | - } else $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>'; |
|
| 6168 | + } else { |
|
| 6169 | + $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>'; |
|
| 6170 | + } |
|
| 5509 | 6171 | |
| 5510 | 6172 | $retstring .= '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; |
| 5511 | 6173 | $retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; |
@@ -5626,7 +6288,9 @@ discard block |
||
| 5626 | 6288 | } |
| 5627 | 6289 | } |
| 5628 | 6290 | |
| 5629 | - if ($d && $h) $retstring .= ($h == 2 ? '<br>' : ' '); |
|
| 6291 | + if ($d && $h) { |
|
| 6292 | + $retstring .= ($h == 2 ? '<br>' : ' '); |
|
| 6293 | + } |
|
| 5630 | 6294 | |
| 5631 | 6295 | if ($h) |
| 5632 | 6296 | { |
@@ -5636,28 +6300,40 @@ discard block |
||
| 5636 | 6300 | $openinghours = explode(',', $openinghours); |
| 5637 | 6301 | $hourstart = $openinghours[0]; |
| 5638 | 6302 | $hourend = $openinghours[1]; |
| 5639 | - if ($hourend < $hourstart) $hourend = $hourstart; |
|
| 6303 | + if ($hourend < $hourstart) { |
|
| 6304 | + $hourend = $hourstart; |
|
| 6305 | + } |
|
| 5640 | 6306 | } |
| 5641 | 6307 | // Show hour |
| 5642 | 6308 | $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'hour' : '').'" id="'.$prefix.'hour" name="'.$prefix.'hour">'; |
| 5643 | - if ($emptyhours) $retstring .= '<option value="-1"> </option>'; |
|
| 6309 | + if ($emptyhours) { |
|
| 6310 | + $retstring .= '<option value="-1"> </option>'; |
|
| 6311 | + } |
|
| 5644 | 6312 | for ($hour = $hourstart; $hour < $hourend; $hour++) |
| 5645 | 6313 | { |
| 5646 | - if (strlen($hour) < 2) $hour = "0".$hour; |
|
| 6314 | + if (strlen($hour) < 2) { |
|
| 6315 | + $hour = "0".$hour; |
|
| 6316 | + } |
|
| 5647 | 6317 | $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour.(empty($conf->dol_optimize_smallscreen) ? '' : 'H').'</option>'; |
| 5648 | 6318 | } |
| 5649 | 6319 | $retstring .= '</select>'; |
| 5650 | - if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; |
|
| 6320 | + if ($m && empty($conf->dol_optimize_smallscreen)) { |
|
| 6321 | + $retstring .= ":"; |
|
| 6322 | + } |
|
| 5651 | 6323 | } |
| 5652 | 6324 | |
| 5653 | 6325 | if ($m) |
| 5654 | 6326 | { |
| 5655 | 6327 | // Show minutes |
| 5656 | 6328 | $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'min' : '').'" id="'.$prefix.'min" name="'.$prefix.'min">'; |
| 5657 | - if ($emptyhours) $retstring .= '<option value="-1"> </option>'; |
|
| 6329 | + if ($emptyhours) { |
|
| 6330 | + $retstring .= '<option value="-1"> </option>'; |
|
| 6331 | + } |
|
| 5658 | 6332 | for ($min = 0; $min < 60; $min += $stepminutes) |
| 5659 | 6333 | { |
| 5660 | - if (strlen($min) < 2) $min = "0".$min; |
|
| 6334 | + if (strlen($min) < 2) { |
|
| 6335 | + $min = "0".$min; |
|
| 6336 | + } |
|
| 5661 | 6337 | $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>'; |
| 5662 | 6338 | } |
| 5663 | 6339 | $retstring .= '</select>'; |
@@ -5670,7 +6346,8 @@ discard block |
||
| 5670 | 6346 | { |
| 5671 | 6347 | // Script which will be inserted in the onClick of the "Now" link |
| 5672 | 6348 | $reset_scripts = ""; |
| 5673 | - if ($addnowlink == 2) // local computer time |
|
| 6349 | + if ($addnowlink == 2) { |
|
| 6350 | + // local computer time |
|
| 5674 | 6351 | { |
| 5675 | 6352 | // pad add leading 0 on numbers |
| 5676 | 6353 | $reset_scripts .= "Number.prototype.pad = function(size) { |
@@ -5680,11 +6357,14 @@ discard block |
||
| 5680 | 6357 | }; |
| 5681 | 6358 | var d = new Date();"; |
| 5682 | 6359 | } |
| 6360 | + } |
|
| 5683 | 6361 | |
| 5684 | 6362 | // Generate the date part, depending on the use or not of the javascript calendar |
| 5685 | - if ($addnowlink == 1) // server time expressed in user time setup |
|
| 6363 | + if ($addnowlink == 1) { |
|
| 6364 | + // server time expressed in user time setup |
|
| 5686 | 6365 | { |
| 5687 | 6366 | $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; |
| 6367 | + } |
|
| 5688 | 6368 | $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; |
| 5689 | 6369 | $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; |
| 5690 | 6370 | $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; |
@@ -5716,7 +6396,9 @@ discard block |
||
| 5716 | 6396 | // Update the hour part |
| 5717 | 6397 | if ($h) |
| 5718 | 6398 | { |
| 5719 | - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6399 | + if ($fullday) { |
|
| 6400 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6401 | + } |
|
| 5720 | 6402 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; |
| 5721 | 6403 | if ($addnowlink == 1) |
| 5722 | 6404 | { |
@@ -5728,12 +6410,16 @@ discard block |
||
| 5728 | 6410 | $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; |
| 5729 | 6411 | } |
| 5730 | 6412 | |
| 5731 | - if ($fullday) $reset_scripts .= ' } '; |
|
| 6413 | + if ($fullday) { |
|
| 6414 | + $reset_scripts .= ' } '; |
|
| 6415 | + } |
|
| 5732 | 6416 | } |
| 5733 | 6417 | // Update the minute part |
| 5734 | 6418 | if ($m) |
| 5735 | 6419 | { |
| 5736 | - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6420 | + if ($fullday) { |
|
| 6421 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6422 | + } |
|
| 5737 | 6423 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; |
| 5738 | 6424 | if ($addnowlink == 1) |
| 5739 | 6425 | { |
@@ -5744,7 +6430,9 @@ discard block |
||
| 5744 | 6430 | $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; |
| 5745 | 6431 | $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; |
| 5746 | 6432 | } |
| 5747 | - if ($fullday) $reset_scripts .= ' } '; |
|
| 6433 | + if ($fullday) { |
|
| 6434 | + $reset_scripts .= ' } '; |
|
| 6435 | + } |
|
| 5748 | 6436 | } |
| 5749 | 6437 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick |
| 5750 | 6438 | if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) |
@@ -5769,16 +6457,24 @@ discard block |
||
| 5769 | 6457 | // Update the hour part |
| 5770 | 6458 | if ($h) |
| 5771 | 6459 | { |
| 5772 | - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6460 | + if ($fullday) { |
|
| 6461 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6462 | + } |
|
| 5773 | 6463 | $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; |
| 5774 | - if ($fullday) $reset_scripts .= ' } '; |
|
| 6464 | + if ($fullday) { |
|
| 6465 | + $reset_scripts .= ' } '; |
|
| 6466 | + } |
|
| 5775 | 6467 | } |
| 5776 | 6468 | // Update the minute part |
| 5777 | 6469 | if ($m) |
| 5778 | 6470 | { |
| 5779 | - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6471 | + if ($fullday) { |
|
| 6472 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 6473 | + } |
|
| 5780 | 6474 | $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; |
| 5781 | - if ($fullday) $reset_scripts .= ' } '; |
|
| 6475 | + if ($fullday) { |
|
| 6476 | + $reset_scripts .= ' } '; |
|
| 6477 | + } |
|
| 5782 | 6478 | } |
| 5783 | 6479 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick |
| 5784 | 6480 | if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) |
@@ -5793,7 +6489,9 @@ discard block |
||
| 5793 | 6489 | if ($conf->use_javascript_ajax && $adddateof) |
| 5794 | 6490 | { |
| 5795 | 6491 | $tmparray = dol_getdate($adddateof); |
| 5796 | - if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice"); |
|
| 6492 | + if (empty($labeladddateof)) { |
|
| 6493 | + $labeladddateof = $langs->trans("DateInvoice"); |
|
| 6494 | + } |
|
| 5797 | 6495 | $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$labeladddateof.'</a>'; |
| 5798 | 6496 | } |
| 5799 | 6497 | |
@@ -5860,9 +6558,11 @@ discard block |
||
| 5860 | 6558 | |
| 5861 | 6559 | if ($typehour == 'select') { |
| 5862 | 6560 | $retstring .= '<select class="flat" id="select_'.$prefix.'hour" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').'>'; |
| 5863 | - for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours |
|
| 6561 | + for ($hour = 0; $hour < 25; $hour++) { |
|
| 6562 | + // For a duration, we allow 24 hours |
|
| 5864 | 6563 | { |
| 5865 | 6564 | $retstring .= '<option value="'.$hour.'"'; |
| 6565 | + } |
|
| 5866 | 6566 | if ($hourSelected == $hour) |
| 5867 | 6567 | { |
| 5868 | 6568 | $retstring .= " selected"; |
@@ -5876,12 +6576,18 @@ discard block |
||
| 5876 | 6576 | return 'BadValueForParameterTypeHour'; |
| 5877 | 6577 | } |
| 5878 | 6578 | |
| 5879 | - if ($typehour != 'text') $retstring .= ' '.$langs->trans('HourShort'); |
|
| 5880 | - else $retstring .= '<span class="hideonsmartphone">:</span>'; |
|
| 6579 | + if ($typehour != 'text') { |
|
| 6580 | + $retstring .= ' '.$langs->trans('HourShort'); |
|
| 6581 | + } else { |
|
| 6582 | + $retstring .= '<span class="hideonsmartphone">:</span>'; |
|
| 6583 | + } |
|
| 5881 | 6584 | |
| 5882 | 6585 | // Minutes |
| 5883 | - if ($minunderhours) $retstring .= '<br>'; |
|
| 5884 | - else $retstring .= '<span class="hideonsmartphone"> </span>'; |
|
| 6586 | + if ($minunderhours) { |
|
| 6587 | + $retstring .= '<br>'; |
|
| 6588 | + } else { |
|
| 6589 | + $retstring .= '<span class="hideonsmartphone"> </span>'; |
|
| 6590 | + } |
|
| 5885 | 6591 | |
| 5886 | 6592 | if ($typehour == 'select' || $typehour == 'textselect') |
| 5887 | 6593 | { |
@@ -5889,7 +6595,9 @@ discard block |
||
| 5889 | 6595 | for ($min = 0; $min <= 55; $min = $min + 5) |
| 5890 | 6596 | { |
| 5891 | 6597 | $retstring .= '<option value="'.$min.'"'; |
| 5892 | - if ($minSelected == $min) $retstring .= ' selected'; |
|
| 6598 | + if ($minSelected == $min) { |
|
| 6599 | + $retstring .= ' selected'; |
|
| 6600 | + } |
|
| 5893 | 6601 | $retstring .= '>'.$min.'</option>'; |
| 5894 | 6602 | } |
| 5895 | 6603 | $retstring .= "</select>"; |
@@ -5898,11 +6606,15 @@ discard block |
||
| 5898 | 6606 | $retstring .= '<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">'; |
| 5899 | 6607 | } |
| 5900 | 6608 | |
| 5901 | - if ($typehour != 'text') $retstring .= ' '.$langs->trans('MinuteShort'); |
|
| 6609 | + if ($typehour != 'text') { |
|
| 6610 | + $retstring .= ' '.$langs->trans('MinuteShort'); |
|
| 6611 | + } |
|
| 5902 | 6612 | |
| 5903 | 6613 | //$retstring.=" "; |
| 5904 | 6614 | |
| 5905 | - if (!empty($nooutput)) return $retstring; |
|
| 6615 | + if (!empty($nooutput)) { |
|
| 6616 | + return $retstring; |
|
| 6617 | + } |
|
| 5906 | 6618 | |
| 5907 | 6619 | print $retstring; |
| 5908 | 6620 | return; |
@@ -5963,8 +6675,12 @@ discard block |
||
| 5963 | 6675 | |
| 5964 | 6676 | //var_dump($objecttmp->filter); |
| 5965 | 6677 | $prefixforautocompletemode = $objecttmp->element; |
| 5966 | - if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company'; |
|
| 5967 | - if ($prefixforautocompletemode == 'product') $prefixforautocompletemode = 'produit'; |
|
| 6678 | + if ($prefixforautocompletemode == 'societe') { |
|
| 6679 | + $prefixforautocompletemode = 'company'; |
|
| 6680 | + } |
|
| 6681 | + if ($prefixforautocompletemode == 'product') { |
|
| 6682 | + $prefixforautocompletemode = 'produit'; |
|
| 6683 | + } |
|
| 5968 | 6684 | $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT |
| 5969 | 6685 | |
| 5970 | 6686 | dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG); |
@@ -5988,7 +6704,9 @@ discard block |
||
| 5988 | 6704 | // Activate the auto complete using ajax call. |
| 5989 | 6705 | $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); |
| 5990 | 6706 | $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>'; |
| 5991 | - if ($placeholder) $placeholder = ' placeholder="'.$placeholder.'"'; |
|
| 6707 | + if ($placeholder) { |
|
| 6708 | + $placeholder = ' placeholder="'.$placeholder.'"'; |
|
| 6709 | + } |
|
| 5992 | 6710 | $out .= '<input type="text" class="'.$morecss.'"'.($disabled ? ' disabled="disabled"' : '').' name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />'; |
| 5993 | 6711 | } else { |
| 5994 | 6712 | // Immediate load of table record. Note: filter is inside $objecttmp->filter |
@@ -6009,9 +6727,13 @@ discard block |
||
| 6009 | 6727 | global $db; |
| 6010 | 6728 | |
| 6011 | 6729 | //dol_syslog("Convert matches ".$matches[1]); |
| 6012 | - if (empty($matches[1])) return ''; |
|
| 6730 | + if (empty($matches[1])) { |
|
| 6731 | + return ''; |
|
| 6732 | + } |
|
| 6013 | 6733 | $tmp = explode(':', $matches[1]); |
| 6014 | - if (count($tmp) < 3) return ''; |
|
| 6734 | + if (count($tmp) < 3) { |
|
| 6735 | + return ''; |
|
| 6736 | + } |
|
| 6015 | 6737 | |
| 6016 | 6738 | $tmpescaped = $tmp[2]; |
| 6017 | 6739 | $regbis = array(); |
@@ -6049,17 +6771,25 @@ discard block |
||
| 6049 | 6771 | //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled"; |
| 6050 | 6772 | |
| 6051 | 6773 | $prefixforautocompletemode = $objecttmp->element; |
| 6052 | - if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company'; |
|
| 6774 | + if ($prefixforautocompletemode == 'societe') { |
|
| 6775 | + $prefixforautocompletemode = 'company'; |
|
| 6776 | + } |
|
| 6053 | 6777 | $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT |
| 6054 | 6778 | |
| 6055 | - if (!empty($objecttmp->fields)) // For object that declare it, it is better to use declared fields (like societe, contact, ...) |
|
| 6779 | + if (!empty($objecttmp->fields)) { |
|
| 6780 | + // For object that declare it, it is better to use declared fields (like societe, contact, ...) |
|
| 6056 | 6781 | { |
| 6057 | 6782 | $tmpfieldstoshow = ''; |
| 6783 | + } |
|
| 6058 | 6784 | foreach ($objecttmp->fields as $key => $val) |
| 6059 | 6785 | { |
| 6060 | - if ($val['showoncombobox']) $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key; |
|
| 6786 | + if ($val['showoncombobox']) { |
|
| 6787 | + $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key; |
|
| 6788 | + } |
|
| 6789 | + } |
|
| 6790 | + if ($tmpfieldstoshow) { |
|
| 6791 | + $fieldstoshow = $tmpfieldstoshow; |
|
| 6061 | 6792 | } |
| 6062 | - if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow; |
|
| 6063 | 6793 | } else { |
| 6064 | 6794 | // For backward compatibility |
| 6065 | 6795 | $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1); |
@@ -6087,20 +6817,30 @@ discard block |
||
| 6087 | 6817 | $tmparray = explode('@', $objecttmp->ismultientitymanaged); |
| 6088 | 6818 | $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0]; |
| 6089 | 6819 | } |
| 6090 | - if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') |
|
| 6091 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 6820 | + if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') { |
|
| 6821 | + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 6822 | + } |
|
| 6092 | 6823 | $sql .= " WHERE 1=1"; |
| 6093 | - if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; |
|
| 6824 | + if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) { |
|
| 6825 | + $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; |
|
| 6826 | + } |
|
| 6094 | 6827 | if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) { |
| 6095 | 6828 | $sql .= ' AND parenttable.entity = t.'.$tmparray[0]; |
| 6096 | 6829 | } |
| 6097 | 6830 | if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) { |
| 6098 | - if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid; |
|
| 6099 | - else $sql .= " AND t.fk_soc = ".$user->socid; |
|
| 6831 | + if ($objecttmp->element == 'societe') { |
|
| 6832 | + $sql .= " AND t.rowid = ".$user->socid; |
|
| 6833 | + } else { |
|
| 6834 | + $sql .= " AND t.fk_soc = ".$user->socid; |
|
| 6835 | + } |
|
| 6836 | + } |
|
| 6837 | + if ($searchkey != '') { |
|
| 6838 | + $sql .= natural_search(explode(',', $fieldstoshow), $searchkey); |
|
| 6100 | 6839 | } |
| 6101 | - if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey); |
|
| 6102 | 6840 | if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') { |
| 6103 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 6841 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 6842 | + $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 6843 | + } |
|
| 6104 | 6844 | } |
| 6105 | 6845 | if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" |
| 6106 | 6846 | /*if (! DolibarrApi::_checkFilters($objecttmp->filter)) |
@@ -6133,10 +6873,15 @@ discard block |
||
| 6133 | 6873 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 6134 | 6874 | if (!empty($conf->global->$confkeyforautocompletemode)) |
| 6135 | 6875 | { |
| 6136 | - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 6137 | - else $textifempty .= $langs->trans("All"); |
|
| 6876 | + if ($showempty && !is_numeric($showempty)) { |
|
| 6877 | + $textifempty = $langs->trans($showempty); |
|
| 6878 | + } else { |
|
| 6879 | + $textifempty .= $langs->trans("All"); |
|
| 6880 | + } |
|
| 6881 | + } |
|
| 6882 | + if ($showempty) { |
|
| 6883 | + $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; |
|
| 6138 | 6884 | } |
| 6139 | - if ($showempty) $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; |
|
| 6140 | 6885 | |
| 6141 | 6886 | $num = $this->db->num_rows($resql); |
| 6142 | 6887 | $i = 0; |
@@ -6165,7 +6910,9 @@ discard block |
||
| 6165 | 6910 | } |
| 6166 | 6911 | |
| 6167 | 6912 | $i++; |
| 6168 | - if (($i % 10) == 0) $out .= "\n"; |
|
| 6913 | + if (($i % 10) == 0) { |
|
| 6914 | + $out .= "\n"; |
|
| 6915 | + } |
|
| 6169 | 6916 | } |
| 6170 | 6917 | } |
| 6171 | 6918 | |
@@ -6176,7 +6923,9 @@ discard block |
||
| 6176 | 6923 | |
| 6177 | 6924 | $this->result = array('nbofelement'=>$num); |
| 6178 | 6925 | |
| 6179 | - if ($outputmode) return $outarray; |
|
| 6926 | + if ($outputmode) { |
|
| 6927 | + return $outarray; |
|
| 6928 | + } |
|
| 6180 | 6929 | return $out; |
| 6181 | 6930 | } |
| 6182 | 6931 | |
@@ -6213,7 +6962,9 @@ discard block |
||
| 6213 | 6962 | //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1; |
| 6214 | 6963 | $jsbeautify = 1; |
| 6215 | 6964 | |
| 6216 | - if ($value_as_key) $array = array_combine($array, $array); |
|
| 6965 | + if ($value_as_key) { |
|
| 6966 | + $array = array_combine($array, $array); |
|
| 6967 | + } |
|
| 6217 | 6968 | |
| 6218 | 6969 | $out = ''; |
| 6219 | 6970 | |
@@ -6235,8 +6986,13 @@ discard block |
||
| 6235 | 6986 | if ($show_empty) |
| 6236 | 6987 | { |
| 6237 | 6988 | $textforempty = ' '; |
| 6238 | - if (!empty($conf->use_javascript_ajax)) $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small. |
|
| 6239 | - if (!is_numeric($show_empty)) $textforempty = $show_empty; |
|
| 6989 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 6990 | + $textforempty = ' '; |
|
| 6991 | + } |
|
| 6992 | + // If we use ajaxcombo, we need here to avoid to have an empty element that is too small. |
|
| 6993 | + if (!is_numeric($show_empty)) { |
|
| 6994 | + $textforempty = $show_empty; |
|
| 6995 | + } |
|
| 6240 | 6996 | $out .= '<option class="optiongrey" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n"; |
| 6241 | 6997 | } |
| 6242 | 6998 | |
@@ -6247,19 +7003,28 @@ discard block |
||
| 6247 | 7003 | { |
| 6248 | 7004 | foreach ($array as $key => $value) |
| 6249 | 7005 | { |
| 6250 | - if (!is_array($value)) $array[$key] = $langs->trans($value); |
|
| 6251 | - else $array[$key]['label'] = $langs->trans($value['label']); |
|
| 7006 | + if (!is_array($value)) { |
|
| 7007 | + $array[$key] = $langs->trans($value); |
|
| 7008 | + } else { |
|
| 7009 | + $array[$key]['label'] = $langs->trans($value['label']); |
|
| 7010 | + } |
|
| 6252 | 7011 | } |
| 6253 | 7012 | } |
| 6254 | 7013 | |
| 6255 | 7014 | // Sort |
| 6256 | - if ($sort == 'ASC') asort($array); |
|
| 6257 | - elseif ($sort == 'DESC') arsort($array); |
|
| 7015 | + if ($sort == 'ASC') { |
|
| 7016 | + asort($array); |
|
| 7017 | + } elseif ($sort == 'DESC') { |
|
| 7018 | + arsort($array); |
|
| 7019 | + } |
|
| 6258 | 7020 | |
| 6259 | 7021 | foreach ($array as $key => $tmpvalue) |
| 6260 | 7022 | { |
| 6261 | - if (is_array($tmpvalue)) $value = $tmpvalue['label']; |
|
| 6262 | - else $value = $tmpvalue; |
|
| 7023 | + if (is_array($tmpvalue)) { |
|
| 7024 | + $value = $tmpvalue['label']; |
|
| 7025 | + } else { |
|
| 7026 | + $value = $tmpvalue; |
|
| 7027 | + } |
|
| 6263 | 7028 | |
| 6264 | 7029 | $disabled = ''; $style = ''; |
| 6265 | 7030 | if (!empty($disablebademail)) |
@@ -6274,28 +7039,46 @@ discard block |
||
| 6274 | 7039 | |
| 6275 | 7040 | if ($key_in_label) |
| 6276 | 7041 | { |
| 6277 | - if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value)); |
|
| 6278 | - else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value); |
|
| 7042 | + if (empty($nohtmlescape)) { |
|
| 7043 | + $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value)); |
|
| 7044 | + } else { |
|
| 7045 | + $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value); |
|
| 7046 | + } |
|
| 6279 | 7047 | } else { |
| 6280 | - if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value); |
|
| 6281 | - else $selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value; |
|
| 6282 | - if ($value == '' || $value == '-') $selectOptionValue = ' '; |
|
| 7048 | + if (empty($nohtmlescape)) { |
|
| 7049 | + $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value); |
|
| 7050 | + } else { |
|
| 7051 | + $selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value; |
|
| 7052 | + } |
|
| 7053 | + if ($value == '' || $value == '-') { |
|
| 7054 | + $selectOptionValue = ' '; |
|
| 7055 | + } |
|
| 6283 | 7056 | } |
| 6284 | 7057 | |
| 6285 | 7058 | $out .= '<option value="'.$key.'"'; |
| 6286 | 7059 | $out .= $style.$disabled; |
| 6287 | 7060 | if (is_array($id)) { |
| 6288 | - if (in_array($key, $id) && !$disabled) $out .= ' selected'; // To preselect a value |
|
| 7061 | + if (in_array($key, $id) && !$disabled) { |
|
| 7062 | + $out .= ' selected'; |
|
| 7063 | + } |
|
| 7064 | + // To preselect a value |
|
| 6289 | 7065 | } else { |
| 6290 | 7066 | $id = (string) $id; // if $id = 0, then $id = '0' |
| 6291 | - if ($id != '' && $id == $key && !$disabled) $out .= ' selected'; // To preselect a value |
|
| 7067 | + if ($id != '' && $id == $key && !$disabled) { |
|
| 7068 | + $out .= ' selected'; |
|
| 7069 | + } |
|
| 7070 | + // To preselect a value |
|
| 7071 | + } |
|
| 7072 | + if ($nohtmlescape) { |
|
| 7073 | + $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; |
|
| 6292 | 7074 | } |
| 6293 | - if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; |
|
| 6294 | 7075 | if (is_array($tmpvalue)) |
| 6295 | 7076 | { |
| 6296 | 7077 | foreach ($tmpvalue as $keyforvalue => $valueforvalue) |
| 6297 | 7078 | { |
| 6298 | - if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; |
|
| 7079 | + if (preg_match('/^data-/', $keyforvalue)) { |
|
| 7080 | + $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; |
|
| 7081 | + } |
|
| 6299 | 7082 | } |
| 6300 | 7083 | } |
| 6301 | 7084 | $out .= '>'; |
@@ -6334,7 +7117,9 @@ discard block |
||
| 6334 | 7117 | global $delayedhtmlcontent; |
| 6335 | 7118 | |
| 6336 | 7119 | // TODO Use an internal dolibarr component instead of select2 |
| 6337 | - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; |
|
| 7120 | + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { |
|
| 7121 | + return ''; |
|
| 7122 | + } |
|
| 6338 | 7123 | |
| 6339 | 7124 | $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>'; |
| 6340 | 7125 | |
@@ -6434,7 +7219,9 @@ discard block |
||
| 6434 | 7219 | global $delayedhtmlcontent; |
| 6435 | 7220 | |
| 6436 | 7221 | // TODO Use an internal dolibarr component instead of select2 |
| 6437 | - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; |
|
| 7222 | + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { |
|
| 7223 | + return ''; |
|
| 7224 | + } |
|
| 6438 | 7225 | |
| 6439 | 7226 | $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"><option></option></select>'; |
| 6440 | 7227 | |
@@ -6551,8 +7338,11 @@ discard block |
||
| 6551 | 7338 | $out = ''; |
| 6552 | 7339 | |
| 6553 | 7340 | if ($addjscombo < 0) { |
| 6554 | - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; |
|
| 6555 | - else $addjscombo = 0; |
|
| 7341 | + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 7342 | + $addjscombo = 1; |
|
| 7343 | + } else { |
|
| 7344 | + $addjscombo = 0; |
|
| 7345 | + } |
|
| 6556 | 7346 | } |
| 6557 | 7347 | |
| 6558 | 7348 | // Add code for jquery to use multiselect |
@@ -6614,7 +7404,9 @@ discard block |
||
| 6614 | 7404 | $out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n"; |
| 6615 | 7405 | if (is_array($array) && !empty($array)) |
| 6616 | 7406 | { |
| 6617 | - if ($value_as_key) $array = array_combine($array, $array); |
|
| 7407 | + if ($value_as_key) { |
|
| 7408 | + $array = array_combine($array, $array); |
|
| 7409 | + } |
|
| 6618 | 7410 | |
| 6619 | 7411 | if (!empty($array)) |
| 6620 | 7412 | { |
@@ -6654,7 +7446,9 @@ discard block |
||
| 6654 | 7446 | { |
| 6655 | 7447 | global $conf, $langs, $user, $extrafields; |
| 6656 | 7448 | |
| 6657 | - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; |
|
| 7449 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 7450 | + return ''; |
|
| 7451 | + } |
|
| 6658 | 7452 | |
| 6659 | 7453 | $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties |
| 6660 | 7454 | if (!empty($user->conf->$tmpvar)) |
@@ -6664,8 +7458,11 @@ discard block |
||
| 6664 | 7458 | { |
| 6665 | 7459 | //var_dump($key); |
| 6666 | 7460 | //var_dump($tmparray); |
| 6667 | - if (in_array($key, $tmparray)) $array[$key]['checked'] = 1; |
|
| 6668 | - else $array[$key]['checked'] = 0; |
|
| 7461 | + if (in_array($key, $tmparray)) { |
|
| 7462 | + $array[$key]['checked'] = 1; |
|
| 7463 | + } else { |
|
| 7464 | + $array[$key]['checked'] = 0; |
|
| 7465 | + } |
|
| 6669 | 7466 | } |
| 6670 | 7467 | } |
| 6671 | 7468 | |
@@ -6851,25 +7648,46 @@ discard block |
||
| 6851 | 7648 | // To work with non standard path |
| 6852 | 7649 | if ($objecttype == 'facture') { |
| 6853 | 7650 | $tplpath = 'compta/'.$element; |
| 6854 | - if (empty($conf->facture->enabled)) continue; // Do not show if module disabled |
|
| 7651 | + if (empty($conf->facture->enabled)) { |
|
| 7652 | + continue; |
|
| 7653 | + } |
|
| 7654 | + // Do not show if module disabled |
|
| 6855 | 7655 | } elseif ($objecttype == 'facturerec') { |
| 6856 | 7656 | $tplpath = 'compta/facture'; |
| 6857 | 7657 | $tplname = 'linkedobjectblockForRec'; |
| 6858 | - if (empty($conf->facture->enabled)) continue; // Do not show if module disabled |
|
| 7658 | + if (empty($conf->facture->enabled)) { |
|
| 7659 | + continue; |
|
| 7660 | + } |
|
| 7661 | + // Do not show if module disabled |
|
| 6859 | 7662 | } elseif ($objecttype == 'propal') { |
| 6860 | 7663 | $tplpath = 'comm/'.$element; |
| 6861 | - if (empty($conf->propal->enabled)) continue; // Do not show if module disabled |
|
| 7664 | + if (empty($conf->propal->enabled)) { |
|
| 7665 | + continue; |
|
| 7666 | + } |
|
| 7667 | + // Do not show if module disabled |
|
| 6862 | 7668 | } elseif ($objecttype == 'supplier_proposal') { |
| 6863 | - if (empty($conf->supplier_proposal->enabled)) continue; // Do not show if module disabled |
|
| 7669 | + if (empty($conf->supplier_proposal->enabled)) { |
|
| 7670 | + continue; |
|
| 7671 | + } |
|
| 7672 | + // Do not show if module disabled |
|
| 6864 | 7673 | } elseif ($objecttype == 'shipping' || $objecttype == 'shipment') { |
| 6865 | 7674 | $tplpath = 'expedition'; |
| 6866 | - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled |
|
| 7675 | + if (empty($conf->expedition->enabled)) { |
|
| 7676 | + continue; |
|
| 7677 | + } |
|
| 7678 | + // Do not show if module disabled |
|
| 6867 | 7679 | } elseif ($objecttype == 'reception') { |
| 6868 | 7680 | $tplpath = 'reception'; |
| 6869 | - if (empty($conf->reception->enabled)) continue; // Do not show if module disabled |
|
| 7681 | + if (empty($conf->reception->enabled)) { |
|
| 7682 | + continue; |
|
| 7683 | + } |
|
| 7684 | + // Do not show if module disabled |
|
| 6870 | 7685 | } elseif ($objecttype == 'delivery') { |
| 6871 | 7686 | $tplpath = 'livraison'; |
| 6872 | - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled |
|
| 7687 | + if (empty($conf->expedition->enabled)) { |
|
| 7688 | + continue; |
|
| 7689 | + } |
|
| 7690 | + // Do not show if module disabled |
|
| 6873 | 7691 | } elseif ($objecttype == 'invoice_supplier') { |
| 6874 | 7692 | $tplpath = 'fourn/facture'; |
| 6875 | 7693 | } elseif ($objecttype == 'order_supplier') { |
@@ -6888,9 +7706,11 @@ discard block |
||
| 6888 | 7706 | $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); |
| 6889 | 7707 | foreach ($dirtpls as $reldir) |
| 6890 | 7708 | { |
| 6891 | - if ($nboftypesoutput == ($nbofdifferenttypes - 1)) // No more type to show after |
|
| 7709 | + if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { |
|
| 7710 | + // No more type to show after |
|
| 6892 | 7711 | { |
| 6893 | 7712 | global $noMoreLinkedObjectBlockAfter; |
| 7713 | + } |
|
| 6894 | 7714 | $noMoreLinkedObjectBlockAfter = 1; |
| 6895 | 7715 | } |
| 6896 | 7716 | |
@@ -6939,19 +7759,25 @@ discard block |
||
| 6939 | 7759 | $linktoelemlist = ''; |
| 6940 | 7760 | $listofidcompanytoscan = ''; |
| 6941 | 7761 | |
| 6942 | - if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
| 7762 | + if (!is_object($object->thirdparty)) { |
|
| 7763 | + $object->fetch_thirdparty(); |
|
| 7764 | + } |
|
| 6943 | 7765 | |
| 6944 | 7766 | $possiblelinks = array(); |
| 6945 | 7767 | if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) |
| 6946 | 7768 | { |
| 6947 | 7769 | $listofidcompanytoscan = $object->thirdparty->id; |
| 6948 | - if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan .= ','.$object->thirdparty->parent; |
|
| 7770 | + if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) { |
|
| 7771 | + $listofidcompanytoscan .= ','.$object->thirdparty->parent; |
|
| 7772 | + } |
|
| 6949 | 7773 | if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) |
| 6950 | 7774 | { |
| 6951 | 7775 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 6952 | 7776 | $tmpproject = new Project($this->db); |
| 6953 | 7777 | $tmpproject->fetch($object->fk_project); |
| 6954 | - if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan .= ','.$tmpproject->socid; |
|
| 7778 | + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) { |
|
| 7779 | + $listofidcompanytoscan .= ','.$tmpproject->socid; |
|
| 7780 | + } |
|
| 6955 | 7781 | unset($tmpproject); |
| 6956 | 7782 | } |
| 6957 | 7783 | |
@@ -6974,9 +7800,12 @@ discard block |
||
| 6974 | 7800 | $hookmanager->initHooks(array('commonobject')); |
| 6975 | 7801 | $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); |
| 6976 | 7802 | |
| 6977 | - if (!empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the object we can link to |
|
| 7803 | + if (!empty($listofidcompanytoscan)) { |
|
| 7804 | + // If empty, we don't have criteria to scan the object we can link to |
|
| 6978 | 7805 | { |
| 6979 | - $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 7806 | + $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); |
|
| 7807 | + } |
|
| 7808 | + // Note that $action and $object may have been modified by hook |
|
| 6980 | 7809 | } |
| 6981 | 7810 | |
| 6982 | 7811 | if (empty($reshook)) |
@@ -6997,7 +7826,9 @@ discard block |
||
| 6997 | 7826 | { |
| 6998 | 7827 | $num = 0; |
| 6999 | 7828 | |
| 7000 | - if (empty($possiblelink['enabled'])) continue; |
|
| 7829 | + if (empty($possiblelink['enabled'])) { |
|
| 7830 | + continue; |
|
| 7831 | + } |
|
| 7001 | 7832 | |
| 7002 | 7833 | if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) |
| 7003 | 7834 | { |
@@ -7053,9 +7884,13 @@ discard block |
||
| 7053 | 7884 | } |
| 7054 | 7885 | |
| 7055 | 7886 | //$linktoelem.=($linktoelem?' ':''); |
| 7056 | - if ($num > 0) $linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>'; |
|
| 7887 | + if ($num > 0) { |
|
| 7888 | + $linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>'; |
|
| 7889 | + } |
|
| 7057 | 7890 | //else $linktoelem.=$langs->trans($possiblelink['label']); |
| 7058 | - else $linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>'; |
|
| 7891 | + else { |
|
| 7892 | + $linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>'; |
|
| 7893 | + } |
|
| 7059 | 7894 | } |
| 7060 | 7895 | } |
| 7061 | 7896 | |
@@ -7064,7 +7899,9 @@ discard block |
||
| 7064 | 7899 | $linktoelem = ' |
| 7065 | 7900 | <dl class="dropdown" id="linktoobjectname"> |
| 7066 | 7901 | '; |
| 7067 | - if (!empty($conf->use_javascript_ajax)) $linktoelem .= '<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>'; |
|
| 7902 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 7903 | + $linktoelem .= '<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>'; |
|
| 7904 | + } |
|
| 7068 | 7905 | $linktoelem .= '<dd> |
| 7069 | 7906 | <div class="multiselectlinkto"> |
| 7070 | 7907 | <ul class="ulselectedfields">'.$linktoelemlist.' |
@@ -7117,7 +7954,9 @@ discard block |
||
| 7117 | 7954 | $disabled = ($disabled ? ' disabled' : ''); |
| 7118 | 7955 | |
| 7119 | 7956 | $resultyesno = '<select class="flat width75" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n"; |
| 7120 | - if ($useempty) $resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'> </option>'."\n"; |
|
| 7957 | + if ($useempty) { |
|
| 7958 | + $resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'> </option>'."\n"; |
|
| 7959 | + } |
|
| 7121 | 7960 | if (("$value" == 'yes') || ($value == 1)) |
| 7122 | 7961 | { |
| 7123 | 7962 | $resultyesno .= '<option value="'.$yes.'" selected>'.$langs->trans("Yes").'</option>'."\n"; |
@@ -7201,8 +8040,12 @@ discard block |
||
| 7201 | 8040 | global $langs, $conf, $hookmanager, $extralanguages; |
| 7202 | 8041 | |
| 7203 | 8042 | $ret = ''; |
| 7204 | - if (empty($fieldid)) $fieldid = 'rowid'; |
|
| 7205 | - if (empty($fieldref)) $fieldref = 'ref'; |
|
| 8043 | + if (empty($fieldid)) { |
|
| 8044 | + $fieldid = 'rowid'; |
|
| 8045 | + } |
|
| 8046 | + if (empty($fieldref)) { |
|
| 8047 | + $fieldref = 'ref'; |
|
| 8048 | + } |
|
| 7206 | 8049 | |
| 7207 | 8050 | // Add where from hooks |
| 7208 | 8051 | if (is_object($hookmanager)) |
@@ -7221,9 +8064,11 @@ discard block |
||
| 7221 | 8064 | // Special case for project/task page |
| 7222 | 8065 | if ($paramid == 'project_ref') |
| 7223 | 8066 | { |
| 7224 | - if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl)) // TODO Remove this when nav with project_ref on task pages are ok |
|
| 8067 | + if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl)) { |
|
| 8068 | + // TODO Remove this when nav with project_ref on task pages are ok |
|
| 7225 | 8069 | { |
| 7226 | 8070 | $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/', '/tasks.php', $navurl); |
| 8071 | + } |
|
| 7227 | 8072 | $paramid = 'ref'; |
| 7228 | 8073 | } |
| 7229 | 8074 | } |
@@ -7249,7 +8094,9 @@ discard block |
||
| 7249 | 8094 | $ret .= '<!-- Start banner content --><div style="vertical-align: middle">'; |
| 7250 | 8095 | |
| 7251 | 8096 | // Right part of banner |
| 7252 | - if ($morehtmlright) $ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>'; |
|
| 8097 | + if ($morehtmlright) { |
|
| 8098 | + $ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>'; |
|
| 8099 | + } |
|
| 7253 | 8100 | |
| 7254 | 8101 | if ($previous_ref || $next_ref || $morehtml) |
| 7255 | 8102 | { |
@@ -7271,20 +8118,33 @@ discard block |
||
| 7271 | 8118 | |
| 7272 | 8119 | $parameters = array(); |
| 7273 | 8120 | $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object); // Note that $action and $object may have been modified by hook |
| 7274 | - if (empty($reshook)) $morehtmlstatus .= $hookmanager->resPrint; |
|
| 7275 | - else $morehtmlstatus = $hookmanager->resPrint; |
|
| 7276 | - if ($morehtmlstatus) $ret .= '<div class="statusref">'.$morehtmlstatus.'</div>'; |
|
| 8121 | + if (empty($reshook)) { |
|
| 8122 | + $morehtmlstatus .= $hookmanager->resPrint; |
|
| 8123 | + } else { |
|
| 8124 | + $morehtmlstatus = $hookmanager->resPrint; |
|
| 8125 | + } |
|
| 8126 | + if ($morehtmlstatus) { |
|
| 8127 | + $ret .= '<div class="statusref">'.$morehtmlstatus.'</div>'; |
|
| 8128 | + } |
|
| 7277 | 8129 | |
| 7278 | 8130 | $parameters = array(); |
| 7279 | 8131 | $reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook |
| 7280 | - if (empty($reshook)) $morehtmlref .= $hookmanager->resPrint; |
|
| 7281 | - elseif ($reshook > 0) $morehtmlref = $hookmanager->resPrint; |
|
| 8132 | + if (empty($reshook)) { |
|
| 8133 | + $morehtmlref .= $hookmanager->resPrint; |
|
| 8134 | + } elseif ($reshook > 0) { |
|
| 8135 | + $morehtmlref = $hookmanager->resPrint; |
|
| 8136 | + } |
|
| 7282 | 8137 | |
| 7283 | 8138 | // Left part of banner |
| 7284 | 8139 | if ($morehtmlleft) |
| 7285 | 8140 | { |
| 7286 | - if ($conf->browser->layout == 'phone') $ret .= '<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle |
|
| 7287 | - else $ret .= '<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>'; |
|
| 8141 | + if ($conf->browser->layout == 'phone') { |
|
| 8142 | + $ret .= '<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.'</div>'; |
|
| 8143 | + } |
|
| 8144 | + // class="center" to have photo in middle |
|
| 8145 | + else { |
|
| 8146 | + $ret .= '<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>'; |
|
| 8147 | + } |
|
| 7288 | 8148 | } |
| 7289 | 8149 | |
| 7290 | 8150 | //if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>'; |
@@ -7297,7 +8157,9 @@ discard block |
||
| 7297 | 8157 | |
| 7298 | 8158 | // List of extra languages |
| 7299 | 8159 | $arrayoflangcode = array(); |
| 7300 | - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 8160 | + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) { |
|
| 8161 | + $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; |
|
| 8162 | + } |
|
| 7301 | 8163 | |
| 7302 | 8164 | if (is_array($arrayoflangcode) && count($arrayoflangcode)) { |
| 7303 | 8165 | if (!is_object($extralanguages)) { |
@@ -7381,14 +8243,18 @@ discard block |
||
| 7381 | 8243 | global $conf; |
| 7382 | 8244 | |
| 7383 | 8245 | //Check if barcode is filled in the card |
| 7384 | - if (empty($object->barcode)) return ''; |
|
| 8246 | + if (empty($object->barcode)) { |
|
| 8247 | + return ''; |
|
| 8248 | + } |
|
| 7385 | 8249 | |
| 7386 | 8250 | // Complete object if not complete |
| 7387 | 8251 | if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) |
| 7388 | 8252 | { |
| 7389 | 8253 | $result = $object->fetch_barcode(); |
| 7390 | 8254 | //Check if fetch_barcode() failed |
| 7391 | - if ($result < 1) return '<!-- ErrorFetchBarcode -->'; |
|
| 8255 | + if ($result < 1) { |
|
| 8256 | + return '<!-- ErrorFetchBarcode -->'; |
|
| 8257 | + } |
|
| 7392 | 8258 | } |
| 7393 | 8259 | |
| 7394 | 8260 | // Barcode image |
@@ -7426,9 +8292,15 @@ discard block |
||
| 7426 | 8292 | $dir = $conf->societe->multidir_output[$entity]; |
| 7427 | 8293 | if (!empty($object->logo)) |
| 7428 | 8294 | { |
| 7429 | - if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs |
|
| 7430 | - elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_small'); |
|
| 7431 | - else $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; |
|
| 8295 | + if ((string) $imagesize == 'mini') { |
|
| 8296 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_mini'); |
|
| 8297 | + } |
|
| 8298 | + // getImageFileNameForSize include the thumbs |
|
| 8299 | + elseif ((string) $imagesize == 'small') { |
|
| 8300 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_small'); |
|
| 8301 | + } else { |
|
| 8302 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; |
|
| 8303 | + } |
|
| 7432 | 8304 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; |
| 7433 | 8305 | } |
| 7434 | 8306 | $email = $object->email; |
@@ -7437,9 +8309,13 @@ discard block |
||
| 7437 | 8309 | $dir = $conf->societe->multidir_output[$entity].'/contact'; |
| 7438 | 8310 | if (!empty($object->photo)) |
| 7439 | 8311 | { |
| 7440 | - if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 7441 | - elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 7442 | - else $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; |
|
| 8312 | + if ((string) $imagesize == 'mini') { |
|
| 8313 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 8314 | + } elseif ((string) $imagesize == 'small') { |
|
| 8315 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 8316 | + } else { |
|
| 8317 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; |
|
| 8318 | + } |
|
| 7443 | 8319 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; |
| 7444 | 8320 | } |
| 7445 | 8321 | $email = $object->email; |
@@ -7449,12 +8325,19 @@ discard block |
||
| 7449 | 8325 | $dir = $conf->user->dir_output; |
| 7450 | 8326 | if (!empty($object->photo)) |
| 7451 | 8327 | { |
| 7452 | - if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 7453 | - elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 7454 | - else $file = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; |
|
| 8328 | + if ((string) $imagesize == 'mini') { |
|
| 8329 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 8330 | + } elseif ((string) $imagesize == 'small') { |
|
| 8331 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 8332 | + } else { |
|
| 8333 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; |
|
| 8334 | + } |
|
| 7455 | 8335 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; |
| 7456 | 8336 | } |
| 7457 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility |
|
| 8337 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 8338 | + $altfile = $object->id.".jpg"; |
|
| 8339 | + } |
|
| 8340 | + // For backward compatibility |
|
| 7458 | 8341 | $email = $object->email; |
| 7459 | 8342 | $capture = 'user'; |
| 7460 | 8343 | } elseif ($modulepart == 'memberphoto') |
@@ -7462,12 +8345,19 @@ discard block |
||
| 7462 | 8345 | $dir = $conf->adherent->dir_output; |
| 7463 | 8346 | if (!empty($object->photo)) |
| 7464 | 8347 | { |
| 7465 | - if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 7466 | - elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 7467 | - else $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo; |
|
| 8348 | + if ((string) $imagesize == 'mini') { |
|
| 8349 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 8350 | + } elseif ((string) $imagesize == 'small') { |
|
| 8351 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 8352 | + } else { |
|
| 8353 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo; |
|
| 8354 | + } |
|
| 7468 | 8355 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo; |
| 7469 | 8356 | } |
| 7470 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility |
|
| 8357 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 8358 | + $altfile = $object->id.".jpg"; |
|
| 8359 | + } |
|
| 8360 | + // For backward compatibility |
|
| 7471 | 8361 | $email = $object->email; |
| 7472 | 8362 | $capture = 'user'; |
| 7473 | 8363 | } else { |
@@ -7475,16 +8365,25 @@ discard block |
||
| 7475 | 8365 | $dir = $conf->$modulepart->dir_output; |
| 7476 | 8366 | if (!empty($object->photo)) |
| 7477 | 8367 | { |
| 7478 | - if ((string) $imagesize == 'mini') $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 7479 | - elseif ((string) $imagesize == 'small') $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 7480 | - else $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo; |
|
| 8368 | + if ((string) $imagesize == 'mini') { |
|
| 8369 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini'); |
|
| 8370 | + } elseif ((string) $imagesize == 'small') { |
|
| 8371 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small'); |
|
| 8372 | + } else { |
|
| 8373 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo; |
|
| 8374 | + } |
|
| 7481 | 8375 | $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo; |
| 7482 | 8376 | } |
| 7483 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility |
|
| 8377 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 8378 | + $altfile = $object->id.".jpg"; |
|
| 8379 | + } |
|
| 8380 | + // For backward compatibility |
|
| 7484 | 8381 | $email = $object->email; |
| 7485 | 8382 | } |
| 7486 | 8383 | |
| 7487 | - if ($forcecapture) $capture = $forcecapture; |
|
| 8384 | + if ($forcecapture) { |
|
| 8385 | + $capture = $forcecapture; |
|
| 8386 | + } |
|
| 7488 | 8387 | |
| 7489 | 8388 | if ($dir) |
| 7490 | 8389 | { |
@@ -7493,31 +8392,47 @@ discard block |
||
| 7493 | 8392 | if ($addlinktofullsize) |
| 7494 | 8393 | { |
| 7495 | 8394 | $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); |
| 7496 | - if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">'; |
|
| 7497 | - else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; |
|
| 8395 | + if ($urladvanced) { |
|
| 8396 | + $ret .= '<a href="'.$urladvanced.'">'; |
|
| 8397 | + } else { |
|
| 8398 | + $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; |
|
| 8399 | + } |
|
| 7498 | 8400 | } |
| 7499 | 8401 | $ret .= '<img alt="Photo" class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').' photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">'; |
| 7500 | - if ($addlinktofullsize) $ret .= '</a>'; |
|
| 8402 | + if ($addlinktofullsize) { |
|
| 8403 | + $ret .= '</a>'; |
|
| 8404 | + } |
|
| 7501 | 8405 | } elseif ($altfile && file_exists($dir."/".$altfile)) |
| 7502 | 8406 | { |
| 7503 | 8407 | if ($addlinktofullsize) |
| 7504 | 8408 | { |
| 7505 | 8409 | $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); |
| 7506 | - if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">'; |
|
| 7507 | - else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; |
|
| 8410 | + if ($urladvanced) { |
|
| 8411 | + $ret .= '<a href="'.$urladvanced.'">'; |
|
| 8412 | + } else { |
|
| 8413 | + $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; |
|
| 8414 | + } |
|
| 7508 | 8415 | } |
| 7509 | 8416 | $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" class="'.$cssclass.'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">'; |
| 7510 | - if ($addlinktofullsize) $ret .= '</a>'; |
|
| 8417 | + if ($addlinktofullsize) { |
|
| 8418 | + $ret .= '</a>'; |
|
| 8419 | + } |
|
| 7511 | 8420 | } else { |
| 7512 | 8421 | $nophoto = '/public/theme/common/nophoto.png'; |
| 7513 | - if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) // For module that are "physical" users |
|
| 8422 | + if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) { |
|
| 8423 | + // For module that are "physical" users |
|
| 7514 | 8424 | { |
| 7515 | 8425 | if ($modulepart == 'memberphoto' && strpos($object->morphy, 'mor') !== false) { |
| 7516 | 8426 | $nophoto = '/public/theme/common/company.png'; |
| 8427 | + } |
|
| 7517 | 8428 | } else { |
| 7518 | 8429 | $nophoto = '/public/theme/common/user_anonymous.png'; |
| 7519 | - if ($object->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; |
|
| 7520 | - if ($object->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; |
|
| 8430 | + if ($object->gender == 'man') { |
|
| 8431 | + $nophoto = '/public/theme/common/user_man.png'; |
|
| 8432 | + } |
|
| 8433 | + if ($object->gender == 'woman') { |
|
| 8434 | + $nophoto = '/public/theme/common/user_woman.png'; |
|
| 8435 | + } |
|
| 7521 | 8436 | } |
| 7522 | 8437 | } |
| 7523 | 8438 | |
@@ -7538,13 +8453,19 @@ discard block |
||
| 7538 | 8453 | |
| 7539 | 8454 | if ($caneditfield) |
| 7540 | 8455 | { |
| 7541 | - if ($object->photo) $ret .= "<br>\n"; |
|
| 8456 | + if ($object->photo) { |
|
| 8457 | + $ret .= "<br>\n"; |
|
| 8458 | + } |
|
| 7542 | 8459 | $ret .= '<table class="nobordernopadding centpercent">'; |
| 7543 | - if ($object->photo) $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>'; |
|
| 8460 | + if ($object->photo) { |
|
| 8461 | + $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>'; |
|
| 8462 | + } |
|
| 7544 | 8463 | $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ? ' capture="'.$capture.'"' : '').'></td></tr>'; |
| 7545 | 8464 | $ret .= '</table>'; |
| 7546 | 8465 | } |
| 7547 | - } else dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart); |
|
| 8466 | + } else { |
|
| 8467 | + dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart); |
|
| 8468 | + } |
|
| 7548 | 8469 | |
| 7549 | 8470 | return $ret; |
| 7550 | 8471 | } |
@@ -7572,11 +8493,17 @@ discard block |
||
| 7572 | 8493 | global $conf, $user, $langs; |
| 7573 | 8494 | |
| 7574 | 8495 | // Permettre l'exclusion de groupes |
| 7575 | - if (is_array($exclude)) $excludeGroups = implode("','", $exclude); |
|
| 8496 | + if (is_array($exclude)) { |
|
| 8497 | + $excludeGroups = implode("','", $exclude); |
|
| 8498 | + } |
|
| 7576 | 8499 | // Permettre l'inclusion de groupes |
| 7577 | - if (is_array($include)) $includeGroups = implode("','", $include); |
|
| 8500 | + if (is_array($include)) { |
|
| 8501 | + $includeGroups = implode("','", $include); |
|
| 8502 | + } |
|
| 7578 | 8503 | |
| 7579 | - if (!is_array($selected)) $selected = array($selected); |
|
| 8504 | + if (!is_array($selected)) { |
|
| 8505 | + $selected = array($selected); |
|
| 8506 | + } |
|
| 7580 | 8507 | |
| 7581 | 8508 | $out = ''; |
| 7582 | 8509 | |
@@ -7590,13 +8517,20 @@ discard block |
||
| 7590 | 8517 | if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) |
| 7591 | 8518 | { |
| 7592 | 8519 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=ug.entity"; |
| 7593 | - if ($force_entity) $sql .= " WHERE ug.entity IN (0, ".$force_entity.")"; |
|
| 7594 | - else $sql .= " WHERE ug.entity IS NOT NULL"; |
|
| 8520 | + if ($force_entity) { |
|
| 8521 | + $sql .= " WHERE ug.entity IN (0, ".$force_entity.")"; |
|
| 8522 | + } else { |
|
| 8523 | + $sql .= " WHERE ug.entity IS NOT NULL"; |
|
| 8524 | + } |
|
| 7595 | 8525 | } else { |
| 7596 | 8526 | $sql .= " WHERE ug.entity IN (0, ".$conf->entity.")"; |
| 7597 | 8527 | } |
| 7598 | - if (is_array($exclude) && $excludeGroups) $sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')"; |
|
| 7599 | - if (is_array($include) && $includeGroups) $sql .= " AND ug.rowid IN ('".$includeGroups."')"; |
|
| 8528 | + if (is_array($exclude) && $excludeGroups) { |
|
| 8529 | + $sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')"; |
|
| 8530 | + } |
|
| 8531 | + if (is_array($include) && $includeGroups) { |
|
| 8532 | + $sql .= " AND ug.rowid IN ('".$includeGroups."')"; |
|
| 8533 | + } |
|
| 7600 | 8534 | $sql .= " ORDER BY ug.nom ASC"; |
| 7601 | 8535 | |
| 7602 | 8536 | dol_syslog(get_class($this)."::select_dolgroups", LOG_DEBUG); |
@@ -7613,16 +8547,22 @@ discard block |
||
| 7613 | 8547 | $i = 0; |
| 7614 | 8548 | if ($num) |
| 7615 | 8549 | { |
| 7616 | - if ($show_empty && !$multiple) $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'> </option>'."\n"; |
|
| 8550 | + if ($show_empty && !$multiple) { |
|
| 8551 | + $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'> </option>'."\n"; |
|
| 8552 | + } |
|
| 7617 | 8553 | |
| 7618 | 8554 | while ($i < $num) |
| 7619 | 8555 | { |
| 7620 | 8556 | $obj = $this->db->fetch_object($resql); |
| 7621 | 8557 | $disableline = 0; |
| 7622 | - if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = 1; |
|
| 8558 | + if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) { |
|
| 8559 | + $disableline = 1; |
|
| 8560 | + } |
|
| 7623 | 8561 | |
| 7624 | 8562 | $out .= '<option value="'.$obj->rowid.'"'; |
| 7625 | - if ($disableline) $out .= ' disabled'; |
|
| 8563 | + if ($disableline) { |
|
| 8564 | + $out .= ' disabled'; |
|
| 8565 | + } |
|
| 7626 | 8566 | if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected))) |
| 7627 | 8567 | { |
| 7628 | 8568 | $out .= ' selected'; |
@@ -7639,7 +8579,9 @@ discard block |
||
| 7639 | 8579 | $i++; |
| 7640 | 8580 | } |
| 7641 | 8581 | } else { |
| 7642 | - if ($show_empty) $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n"; |
|
| 8582 | + if ($show_empty) { |
|
| 8583 | + $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n"; |
|
| 8584 | + } |
|
| 7643 | 8585 | $out .= '<option value="" disabled>'.$langs->trans("NoUserGroupDefined").'</option>'; |
| 7644 | 8586 | } |
| 7645 | 8587 | $out .= '</select>'; |
@@ -7680,7 +8622,9 @@ discard block |
||
| 7680 | 8622 | |
| 7681 | 8623 | $out = ''; |
| 7682 | 8624 | |
| 7683 | - if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>'; |
|
| 8625 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 8626 | + $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>'; |
|
| 8627 | + } |
|
| 7684 | 8628 | $out .= '<script> |
| 7685 | 8629 | $(document).ready(function() { |
| 7686 | 8630 | $("#' . $cssclass.'s").click(function() { |
@@ -7693,7 +8637,9 @@ discard block |
||
| 7693 | 8637 | console.log("We uncheck all"); |
| 7694 | 8638 | $(".'.$cssclass.'").prop(\'checked\', false).trigger(\'change\'); |
| 7695 | 8639 | }'."\n"; |
| 7696 | - if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; |
|
| 8640 | + if ($calljsfunction) { |
|
| 8641 | + $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; |
|
| 8642 | + } |
|
| 7697 | 8643 | $out .= ' }); |
| 7698 | 8644 | $(".' . $cssclass.'").change(function() { |
| 7699 | 8645 | $(this).closest("tr").toggleClass("highlight", this.checked); |
@@ -7743,14 +8689,18 @@ discard block |
||
| 7743 | 8689 | $out = ''; |
| 7744 | 8690 | $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; |
| 7745 | 8691 | $sql .= ' AND entity IN (0,'.getEntity('exp_tax_cat').')'; |
| 7746 | - if (!empty($excludeid)) $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')'; |
|
| 8692 | + if (!empty($excludeid)) { |
|
| 8693 | + $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')'; |
|
| 8694 | + } |
|
| 7747 | 8695 | $sql .= ' ORDER BY label'; |
| 7748 | 8696 | |
| 7749 | 8697 | $resql = $db->query($sql); |
| 7750 | 8698 | if ($resql) |
| 7751 | 8699 | { |
| 7752 | 8700 | $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp maxwidth200">'; |
| 7753 | - if ($useempty) $out .= '<option value="0"> </option>'; |
|
| 8701 | + if ($useempty) { |
|
| 8702 | + $out .= '<option value="0"> </option>'; |
|
| 8703 | + } |
|
| 7754 | 8704 | |
| 7755 | 8705 | while ($obj = $db->fetch_object($resql)) |
| 7756 | 8706 | { |
@@ -7759,7 +8709,9 @@ discard block |
||
| 7759 | 8709 | $out .= '</select>'; |
| 7760 | 8710 | $out .= ajax_combobox('select_'.$htmlname); |
| 7761 | 8711 | |
| 7762 | - if (!empty($htmlname) && $user->admin && $info_admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 8712 | + if (!empty($htmlname) && $user->admin && $info_admin) { |
|
| 8713 | + $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 8714 | + } |
|
| 7763 | 8715 | |
| 7764 | 8716 | if (!empty($target)) |
| 7765 | 8717 | { |
@@ -7775,7 +8727,9 @@ discard block |
||
| 7775 | 8727 | $("select[name='.$target.']").on("change", function() { |
| 7776 | 8728 | var current_val = $(this).val(); |
| 7777 | 8729 | if (current_val == '.$obj->id.') {'; |
| 7778 | - if (!empty($default_selected) || !empty($selected)) $out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");'; |
|
| 8730 | + if (!empty($default_selected) || !empty($selected)) { |
|
| 8731 | + $out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");'; |
|
| 8732 | + } |
|
| 7779 | 8733 | |
| 7780 | 8734 | $out .= ' |
| 7781 | 8735 | $("select[name='.$htmlname.']").change(); |
@@ -7838,7 +8792,9 @@ discard block |
||
| 7838 | 8792 | if ($resql) |
| 7839 | 8793 | { |
| 7840 | 8794 | $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; |
| 7841 | - if ($useempty) $out .= '<option value="0"></option>'; |
|
| 8795 | + if ($useempty) { |
|
| 8796 | + $out .= '<option value="0"></option>'; |
|
| 8797 | + } |
|
| 7842 | 8798 | |
| 7843 | 8799 | while ($obj = $db->fetch_object($resql)) |
| 7844 | 8800 | { |
@@ -7874,11 +8830,17 @@ discard block |
||
| 7874 | 8830 | if ($resql) |
| 7875 | 8831 | { |
| 7876 | 8832 | $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; |
| 7877 | - if ($useempty) $out .= '<option value="0"></option>'; |
|
| 7878 | - if ($allchoice) $out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>'; |
|
| 8833 | + if ($useempty) { |
|
| 8834 | + $out .= '<option value="0"></option>'; |
|
| 8835 | + } |
|
| 8836 | + if ($allchoice) { |
|
| 8837 | + $out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>'; |
|
| 8838 | + } |
|
| 7879 | 8839 | |
| 7880 | 8840 | $field = 'code'; |
| 7881 | - if ($useid) $field = 'id'; |
|
| 8841 | + if ($useid) { |
|
| 8842 | + $field = 'id'; |
|
| 8843 | + } |
|
| 7882 | 8844 | |
| 7883 | 8845 | while ($obj = $db->fetch_object($resql)) |
| 7884 | 8846 | { |
@@ -7925,7 +8887,9 @@ discard block |
||
| 7925 | 8887 | $out = ''; |
| 7926 | 8888 | |
| 7927 | 8889 | $hideunselectables = false; |
| 7928 | - if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
| 8890 | + if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) { |
|
| 8891 | + $hideunselectables = true; |
|
| 8892 | + } |
|
| 7929 | 8893 | |
| 7930 | 8894 | if (empty($projectsListId)) |
| 7931 | 8895 | { |
@@ -7967,8 +8931,11 @@ discard block |
||
| 7967 | 8931 | } |
| 7968 | 8932 | if (!empty($show_empty)) { |
| 7969 | 8933 | $out .= '<option value="0" class="optiongrey">'; |
| 7970 | - if (!is_numeric($show_empty)) $out .= $show_empty; |
|
| 7971 | - else $out .= ' '; |
|
| 8934 | + if (!is_numeric($show_empty)) { |
|
| 8935 | + $out .= $show_empty; |
|
| 8936 | + } else { |
|
| 8937 | + $out .= ' '; |
|
| 8938 | + } |
|
| 7972 | 8939 | $out .= '</option>'; |
| 7973 | 8940 | } |
| 7974 | 8941 | $num = $this->db->num_rows($resql); |
@@ -7994,7 +8961,10 @@ discard block |
||
| 7994 | 8961 | if ($showproject == 'all') |
| 7995 | 8962 | { |
| 7996 | 8963 | $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref |
| 7997 | - if ($obj->name) $labeltoshow .= ' - '.$obj->name; // Soc name |
|
| 8964 | + if ($obj->name) { |
|
| 8965 | + $labeltoshow .= ' - '.$obj->name; |
|
| 8966 | + } |
|
| 8967 | + // Soc name |
|
| 7998 | 8968 | |
| 7999 | 8969 | $disabled = 0; |
| 8000 | 8970 | if ($obj->fk_statut == Project::STATUS_DRAFT) |
@@ -8003,7 +8973,9 @@ discard block |
||
| 8003 | 8973 | $labeltoshow .= ' - '.$langs->trans("Draft"); |
| 8004 | 8974 | } elseif ($obj->fk_statut == Project::STATUS_CLOSED) |
| 8005 | 8975 | { |
| 8006 | - if ($discard_closed == 2) $disabled = 1; |
|
| 8976 | + if ($discard_closed == 2) { |
|
| 8977 | + $disabled = 1; |
|
| 8978 | + } |
|
| 8007 | 8979 | $labeltoshow .= ' - '.$langs->trans("Closed"); |
| 8008 | 8980 | } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
| 8009 | 8981 | { |
@@ -8023,7 +8995,9 @@ discard block |
||
| 8023 | 8995 | $resultat = ''; |
| 8024 | 8996 | } else { |
| 8025 | 8997 | $resultat = '<option value="'.$obj->rowid.'"'; |
| 8026 | - if ($disabled) $resultat .= ' disabled'; |
|
| 8998 | + if ($disabled) { |
|
| 8999 | + $resultat .= ' disabled'; |
|
| 9000 | + } |
|
| 8027 | 9001 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
| 8028 | 9002 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
| 8029 | 9003 | $resultat .= '>'; |
@@ -8080,8 +9054,12 @@ discard block |
||
| 8080 | 9054 | // For compatibility with forms that show themself the search criteria in addition of this component, we output the fields |
| 8081 | 9055 | foreach ($arrayofcriterias as $criterias) { |
| 8082 | 9056 | foreach ($criterias as $criteriafamilykey => $criteriafamilyval) { |
| 8083 | - if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; |
|
| 8084 | - if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; |
|
| 9057 | + if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) { |
|
| 9058 | + continue; |
|
| 9059 | + } |
|
| 9060 | + if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) { |
|
| 9061 | + continue; |
|
| 9062 | + } |
|
| 8085 | 9063 | if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { |
| 8086 | 9064 | $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_start">'; |
| 8087 | 9065 | $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startyear">'; |
@@ -8122,7 +9100,9 @@ discard block |
||
| 8122 | 9100 | $formmail = new FormMail($db); |
| 8123 | 9101 | $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); |
| 8124 | 9102 | |
| 8125 | - if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); |
|
| 9103 | + if ($default) { |
|
| 9104 | + $TModels[0] = $langs->trans('DefaultMailModel'); |
|
| 9105 | + } |
|
| 8126 | 9106 | if ($result > 0) { |
| 8127 | 9107 | foreach ($formmail->lines_model as $model) { |
| 8128 | 9108 | $TModels[$model->id] = $model->label; |
@@ -29,26 +29,26 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function intracommReportAdminPrepareHead() |
| 31 | 31 | { |
| 32 | - global $langs, $conf; |
|
| 32 | + global $langs, $conf; |
|
| 33 | 33 | |
| 34 | - $langs->load("intracommreport"); |
|
| 34 | + $langs->load("intracommreport"); |
|
| 35 | 35 | |
| 36 | - $h = 0; |
|
| 37 | - $head = array(); |
|
| 36 | + $h = 0; |
|
| 37 | + $head = array(); |
|
| 38 | 38 | |
| 39 | - $head[$h][0] = DOL_URL_ROOT.'/intracommreport/admin/intracommreport.php'; |
|
| 40 | - $head[$h][1] = $langs->trans("Parameters"); |
|
| 41 | - $head[$h][2] = 'general'; |
|
| 42 | - $h++; |
|
| 39 | + $head[$h][0] = DOL_URL_ROOT.'/intracommreport/admin/intracommreport.php'; |
|
| 40 | + $head[$h][1] = $langs->trans("Parameters"); |
|
| 41 | + $head[$h][2] = 'general'; |
|
| 42 | + $h++; |
|
| 43 | 43 | |
| 44 | - // Show more tabs from modules |
|
| 45 | - // Entries must be declared in modules descriptor with line |
|
| 46 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 47 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 48 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin'); |
|
| 44 | + // Show more tabs from modules |
|
| 45 | + // Entries must be declared in modules descriptor with line |
|
| 46 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 47 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 48 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin'); |
|
| 49 | 49 | |
| 50 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove'); |
|
| 51 | - return $head; |
|
| 50 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove'); |
|
| 51 | + return $head; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -58,24 +58,24 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | function intracommReportPrepareHead() |
| 60 | 60 | { |
| 61 | - global $langs, $conf; |
|
| 61 | + global $langs, $conf; |
|
| 62 | 62 | |
| 63 | - $langs->load("intracommreport"); |
|
| 63 | + $langs->load("intracommreport"); |
|
| 64 | 64 | |
| 65 | - $h = 0; |
|
| 66 | - $head = array(); |
|
| 65 | + $h = 0; |
|
| 66 | + $head = array(); |
|
| 67 | 67 | |
| 68 | - $head[$h][0] = DOL_URL_ROOT.'/intracommreport/card.php?rowid='.$object->id; |
|
| 69 | - $head[$h][1] = $langs->trans("Card"); |
|
| 70 | - $head[$h][2] = 'card'; |
|
| 71 | - $h++; |
|
| 68 | + $head[$h][0] = DOL_URL_ROOT.'/intracommreport/card.php?rowid='.$object->id; |
|
| 69 | + $head[$h][1] = $langs->trans("Card"); |
|
| 70 | + $head[$h][2] = 'card'; |
|
| 71 | + $h++; |
|
| 72 | 72 | |
| 73 | - // Show more tabs from modules |
|
| 74 | - // Entries must be declared in modules descriptor with line |
|
| 75 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 76 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 77 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport'); |
|
| 73 | + // Show more tabs from modules |
|
| 74 | + // Entries must be declared in modules descriptor with line |
|
| 75 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
| 76 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
| 77 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport'); |
|
| 78 | 78 | |
| 79 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport', 'remove'); |
|
| 80 | - return $head; |
|
| 79 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport', 'remove'); |
|
| 80 | + return $head; |
|
| 81 | 81 | } |
@@ -487,26 +487,26 @@ |
||
| 487 | 487 | print '</tr>'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if (! empty($conf->intracommreport->enabled)) |
|
| 491 | - { |
|
| 492 | - // Transport mode by default |
|
| 493 | - print '<tr><td class="nowrap">'; |
|
| 494 | - print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 495 | - print $langs->trans('IntracommReportTransportMode'); |
|
| 496 | - print '<td>'; |
|
| 497 | - if (($action != 'edittransportmode') && $user->rights->societe->creer) print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edittransportmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 498 | - print '</tr></table>'; |
|
| 499 | - print '</td><td>'; |
|
| 500 | - if ($action == 'edittransportmode') |
|
| 501 | - { |
|
| 502 | - $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); |
|
| 503 | - } |
|
| 504 | - else { |
|
| 505 | - $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); |
|
| 506 | - } |
|
| 507 | - print "</td>"; |
|
| 508 | - print '</tr>'; |
|
| 509 | - } |
|
| 490 | + if (! empty($conf->intracommreport->enabled)) |
|
| 491 | + { |
|
| 492 | + // Transport mode by default |
|
| 493 | + print '<tr><td class="nowrap">'; |
|
| 494 | + print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 495 | + print $langs->trans('IntracommReportTransportMode'); |
|
| 496 | + print '<td>'; |
|
| 497 | + if (($action != 'edittransportmode') && $user->rights->societe->creer) print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edittransportmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 498 | + print '</tr></table>'; |
|
| 499 | + print '</td><td>'; |
|
| 500 | + if ($action == 'edittransportmode') |
|
| 501 | + { |
|
| 502 | + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); |
|
| 503 | + } |
|
| 504 | + else { |
|
| 505 | + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); |
|
| 506 | + } |
|
| 507 | + print "</td>"; |
|
| 508 | + print '</tr>'; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | 511 | // Categories |
| 512 | 512 | if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | print '</tr>'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if (! empty($conf->intracommreport->enabled)) |
|
| 490 | + if (!empty($conf->intracommreport->enabled)) |
|
| 491 | 491 | { |
| 492 | 492 | // Transport mode by default |
| 493 | 493 | print '<tr><td class="nowrap">'; |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $late = ''; |
| 955 | 955 | foreach ($contrat->lines as $line) { |
| 956 | 956 | if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { |
| 957 | - if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); |
|
| 957 | + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); |
|
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | |
@@ -38,29 +38,61 @@ discard block |
||
| 38 | 38 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
| 40 | 40 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 41 | -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 42 | -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 43 | -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 44 | -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 45 | -if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; |
|
| 46 | -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 47 | -if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
| 48 | -if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 41 | +if (!empty($conf->facture->enabled)) { |
|
| 42 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 43 | +} |
|
| 44 | +if (!empty($conf->facture->enabled)) { |
|
| 45 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 46 | +} |
|
| 47 | +if (!empty($conf->propal->enabled)) { |
|
| 48 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 49 | +} |
|
| 50 | +if (!empty($conf->commande->enabled)) { |
|
| 51 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 52 | +} |
|
| 53 | +if (!empty($conf->expedition->enabled)) { |
|
| 54 | + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; |
|
| 55 | +} |
|
| 56 | +if (!empty($conf->contrat->enabled)) { |
|
| 57 | + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 58 | +} |
|
| 59 | +if (!empty($conf->adherent->enabled)) { |
|
| 60 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
| 61 | +} |
|
| 62 | +if (!empty($conf->ficheinter->enabled)) { |
|
| 63 | + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 64 | +} |
|
| 49 | 65 | |
| 50 | 66 | // Load translation files required by the page |
| 51 | 67 | $langs->loadLangs(array('companies', 'banks')); |
| 52 | 68 | |
| 53 | -if (!empty($conf->contrat->enabled)) $langs->load("contracts"); |
|
| 54 | -if (!empty($conf->commande->enabled)) $langs->load("orders"); |
|
| 55 | -if (!empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
| 56 | -if (!empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 57 | -if (!empty($conf->projet->enabled)) $langs->load("projects"); |
|
| 58 | -if (!empty($conf->ficheinter->enabled)) $langs->load("interventions"); |
|
| 59 | -if (!empty($conf->notification->enabled)) $langs->load("mails"); |
|
| 69 | +if (!empty($conf->contrat->enabled)) { |
|
| 70 | + $langs->load("contracts"); |
|
| 71 | +} |
|
| 72 | +if (!empty($conf->commande->enabled)) { |
|
| 73 | + $langs->load("orders"); |
|
| 74 | +} |
|
| 75 | +if (!empty($conf->expedition->enabled)) { |
|
| 76 | + $langs->load("sendings"); |
|
| 77 | +} |
|
| 78 | +if (!empty($conf->facture->enabled)) { |
|
| 79 | + $langs->load("bills"); |
|
| 80 | +} |
|
| 81 | +if (!empty($conf->projet->enabled)) { |
|
| 82 | + $langs->load("projects"); |
|
| 83 | +} |
|
| 84 | +if (!empty($conf->ficheinter->enabled)) { |
|
| 85 | + $langs->load("interventions"); |
|
| 86 | +} |
|
| 87 | +if (!empty($conf->notification->enabled)) { |
|
| 88 | + $langs->load("mails"); |
|
| 89 | +} |
|
| 60 | 90 | |
| 61 | 91 | // Security check |
| 62 | 92 | $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); |
| 63 | -if ($user->socid > 0) $id = $user->socid; |
|
| 93 | +if ($user->socid > 0) { |
|
| 94 | + $id = $user->socid; |
|
| 95 | +} |
|
| 64 | 96 | $result = restrictedArea($user, 'societe', $id, '&societe'); |
| 65 | 97 | |
| 66 | 98 | $action = GETPOST('action', 'aZ09'); |
@@ -73,8 +105,12 @@ discard block |
||
| 73 | 105 | $offset = $limit * $page; |
| 74 | 106 | $pageprev = $page - 1; |
| 75 | 107 | $pagenext = $page + 1; |
| 76 | -if (!$sortorder) $sortorder = "ASC"; |
|
| 77 | -if (!$sortfield) $sortfield = "nom"; |
|
| 108 | +if (!$sortorder) { |
|
| 109 | + $sortorder = "ASC"; |
|
| 110 | +} |
|
| 111 | +if (!$sortfield) { |
|
| 112 | + $sortfield = "nom"; |
|
| 113 | +} |
|
| 78 | 114 | $cancelbutton = GETPOST('cancel', 'alpha'); |
| 79 | 115 | |
| 80 | 116 | $object = new Client($db); |
@@ -95,7 +131,9 @@ discard block |
||
| 95 | 131 | |
| 96 | 132 | $parameters = array('id' => $id, 'socid' => $id); |
| 97 | 133 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some |
| 98 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 134 | +if ($reshook < 0) { |
|
| 135 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 136 | +} |
|
| 99 | 137 | |
| 100 | 138 | if (empty($reshook)) |
| 101 | 139 | { |
@@ -110,7 +148,9 @@ discard block |
||
| 110 | 148 | $result = $object->fetch($id); |
| 111 | 149 | $object->code_compta = $_POST["customeraccountancycode"]; |
| 112 | 150 | $result = $object->update($object->id, $user, 1, 1, 0); |
| 113 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 151 | + if ($result < 0) { |
|
| 152 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 153 | + } |
|
| 114 | 154 | } |
| 115 | 155 | |
| 116 | 156 | // terms of the settlement |
@@ -118,7 +158,9 @@ discard block |
||
| 118 | 158 | { |
| 119 | 159 | $object->fetch($id); |
| 120 | 160 | $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); |
| 121 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 161 | + if ($result < 0) { |
|
| 162 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 163 | + } |
|
| 122 | 164 | } |
| 123 | 165 | |
| 124 | 166 | // mode de reglement |
@@ -126,7 +168,9 @@ discard block |
||
| 126 | 168 | { |
| 127 | 169 | $object->fetch($id); |
| 128 | 170 | $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); |
| 129 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 171 | + if ($result < 0) { |
|
| 172 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 173 | + } |
|
| 130 | 174 | } |
| 131 | 175 | |
| 132 | 176 | // Bank account |
@@ -134,7 +178,9 @@ discard block |
||
| 134 | 178 | { |
| 135 | 179 | $object->fetch($id); |
| 136 | 180 | $result = $object->setBankAccount(GETPOST('fk_account', 'int')); |
| 137 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 181 | + if ($result < 0) { |
|
| 182 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 183 | + } |
|
| 138 | 184 | } |
| 139 | 185 | |
| 140 | 186 | // customer preferred shipping method |
@@ -142,7 +188,9 @@ discard block |
||
| 142 | 188 | { |
| 143 | 189 | $object->fetch($id); |
| 144 | 190 | $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); |
| 145 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 191 | + if ($result < 0) { |
|
| 192 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 193 | + } |
|
| 146 | 194 | } |
| 147 | 195 | |
| 148 | 196 | // assujetissement a la TVA |
@@ -151,7 +199,9 @@ discard block |
||
| 151 | 199 | $object->fetch($id); |
| 152 | 200 | $object->tva_assuj = $_POST['assujtva_value']; |
| 153 | 201 | $result = $object->update($object->id); |
| 154 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 202 | + if ($result < 0) { |
|
| 203 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 204 | + } |
|
| 155 | 205 | } |
| 156 | 206 | |
| 157 | 207 | // set prospect level |
@@ -160,7 +210,9 @@ discard block |
||
| 160 | 210 | $object->fetch($id); |
| 161 | 211 | $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); |
| 162 | 212 | $result = $object->update($object->id, $user); |
| 163 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 213 | + if ($result < 0) { |
|
| 214 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 215 | + } |
|
| 164 | 216 | } |
| 165 | 217 | |
| 166 | 218 | // set communication status |
@@ -169,7 +221,9 @@ discard block |
||
| 169 | 221 | $object->fetch($id); |
| 170 | 222 | $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); |
| 171 | 223 | $result = $object->update($object->id, $user); |
| 172 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 224 | + if ($result < 0) { |
|
| 225 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 226 | + } |
|
| 173 | 227 | } |
| 174 | 228 | |
| 175 | 229 | // update outstandng limit |
@@ -178,7 +232,9 @@ discard block |
||
| 178 | 232 | $object->fetch($id); |
| 179 | 233 | $object->outstanding_limit = GETPOST('outstanding_limit'); |
| 180 | 234 | $result = $object->update($object->id, $user); |
| 181 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 235 | + if ($result < 0) { |
|
| 236 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 237 | + } |
|
| 182 | 238 | } |
| 183 | 239 | |
| 184 | 240 | // update order min amount |
@@ -187,7 +243,9 @@ discard block |
||
| 187 | 243 | $object->fetch($id); |
| 188 | 244 | $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha')); |
| 189 | 245 | $result = $object->update($object->id, $user); |
| 190 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 246 | + if ($result < 0) { |
|
| 247 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 248 | + } |
|
| 191 | 249 | } |
| 192 | 250 | |
| 193 | 251 | // Set sales representatives |
@@ -204,7 +262,9 @@ discard block |
||
| 204 | 262 | |
| 205 | 263 | // Fill array 'array_options' with data from update form |
| 206 | 264 | $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); |
| 207 | - if ($ret < 0) $error++; |
|
| 265 | + if ($ret < 0) { |
|
| 266 | + $error++; |
|
| 267 | + } |
|
| 208 | 268 | if (!$error) |
| 209 | 269 | { |
| 210 | 270 | $result = $object->insertExtraFields('COMPANY_MODIFY'); |
@@ -214,7 +274,9 @@ discard block |
||
| 214 | 274 | $error++; |
| 215 | 275 | } |
| 216 | 276 | } |
| 217 | - if ($error) $action = 'edit_extras'; |
|
| 277 | + if ($error) { |
|
| 278 | + $action = 'edit_extras'; |
|
| 279 | + } |
|
| 218 | 280 | } |
| 219 | 281 | } |
| 220 | 282 | |
@@ -232,11 +294,15 @@ discard block |
||
| 232 | 294 | { |
| 233 | 295 | // Load data of third party |
| 234 | 296 | $res = $object->fetch($id); |
| 235 | - if ($object->id < 0) dol_print_error($db, $object->error, $object->errors); |
|
| 236 | -} |
|
| 297 | + if ($object->id < 0) { |
|
| 298 | + dol_print_error($db, $object->error, $object->errors); |
|
| 299 | + } |
|
| 300 | + } |
|
| 237 | 301 | |
| 238 | 302 | $title = $langs->trans("CustomerCard"); |
| 239 | -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name; |
|
| 303 | +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
| 304 | + $title = $object->name; |
|
| 305 | +} |
|
| 240 | 306 | $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
| 241 | 307 | llxHeader('', $title, $help_url); |
| 242 | 308 | |
@@ -262,9 +328,11 @@ discard block |
||
| 262 | 328 | print '</td></tr>'; |
| 263 | 329 | |
| 264 | 330 | // Prefix |
| 265 | - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
| 331 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) { |
|
| 332 | + // Old not used prefix field |
|
| 266 | 333 | { |
| 267 | 334 | print '<tr><td>'.$langs->trans("Prefix").'</td><td>'; |
| 335 | + } |
|
| 268 | 336 | print ($object->prefix_comm ? $object->prefix_comm : ' '); |
| 269 | 337 | print '</td></tr>'; |
| 270 | 338 | } |
@@ -276,7 +344,9 @@ discard block |
||
| 276 | 344 | print '<tr><td>'; |
| 277 | 345 | print $langs->trans('CustomerCode').'</td><td>'; |
| 278 | 346 | print $object->code_client; |
| 279 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
| 347 | + if ($object->check_codeclient() <> 0) { |
|
| 348 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
| 349 | + } |
|
| 280 | 350 | print '</td></tr>'; |
| 281 | 351 | |
| 282 | 352 | print '<tr>'; |
@@ -332,7 +402,9 @@ discard block |
||
| 332 | 402 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
| 333 | 403 | print $langs->trans('PaymentConditions'); |
| 334 | 404 | print '<td>'; |
| 335 | - if (($action != 'editconditions') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; |
|
| 405 | + if (($action != 'editconditions') && $user->rights->societe->creer) { |
|
| 406 | + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; |
|
| 407 | + } |
|
| 336 | 408 | print '</tr></table>'; |
| 337 | 409 | print '</td><td>'; |
| 338 | 410 | if ($action == 'editconditions') |
@@ -349,7 +421,9 @@ discard block |
||
| 349 | 421 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 350 | 422 | print $langs->trans('PaymentMode'); |
| 351 | 423 | print '<td>'; |
| 352 | - if (($action != 'editmode') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 424 | + if (($action != 'editmode') && $user->rights->societe->creer) { |
|
| 425 | + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 426 | + } |
|
| 353 | 427 | print '</tr></table>'; |
| 354 | 428 | print '</td><td>'; |
| 355 | 429 | if ($action == 'editmode') |
@@ -368,7 +442,9 @@ discard block |
||
| 368 | 442 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 369 | 443 | print $langs->trans('PaymentBankAccount'); |
| 370 | 444 | print '<td>'; |
| 371 | - if (($action != 'editbankaccount') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&socid='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; |
|
| 445 | + if (($action != 'editbankaccount') && $user->rights->societe->creer) { |
|
| 446 | + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&socid='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; |
|
| 447 | + } |
|
| 372 | 448 | print '</tr></table>'; |
| 373 | 449 | print '</td><td>'; |
| 374 | 450 | if ($action == 'editbankaccount') |
@@ -412,8 +488,12 @@ discard block |
||
| 412 | 488 | print '</td>'; |
| 413 | 489 | print '<td>'; |
| 414 | 490 | $amount_discount = $object->getAvailableDiscounts(); |
| 415 | - if ($amount_discount < 0) dol_print_error($db, $object->error); |
|
| 416 | - if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>'; |
|
| 491 | + if ($amount_discount < 0) { |
|
| 492 | + dol_print_error($db, $object->error); |
|
| 493 | + } |
|
| 494 | + if ($amount_discount > 0) { |
|
| 495 | + print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>'; |
|
| 496 | + } |
|
| 417 | 497 | //else print $langs->trans("DiscountNone"); |
| 418 | 498 | print '</td>'; |
| 419 | 499 | print '</tr>'; |
@@ -463,7 +543,9 @@ discard block |
||
| 463 | 543 | print '</td><td>'; |
| 464 | 544 | print $object->price_level; |
| 465 | 545 | $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; |
| 466 | - if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); |
|
| 546 | + if (!empty($conf->global->$keyforlabel)) { |
|
| 547 | + print ' - '.$langs->trans($conf->global->$keyforlabel); |
|
| 548 | + } |
|
| 467 | 549 | print "</td>"; |
| 468 | 550 | print '</tr>'; |
| 469 | 551 | } |
@@ -474,7 +556,9 @@ discard block |
||
| 474 | 556 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 475 | 557 | print $langs->trans('SendingMethod'); |
| 476 | 558 | print '<td>'; |
| 477 | - if (($action != 'editshipping') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 559 | + if (($action != 'editshipping') && $user->rights->societe->creer) { |
|
| 560 | + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 561 | + } |
|
| 478 | 562 | print '</tr></table>'; |
| 479 | 563 | print '</td><td>'; |
| 480 | 564 | if ($action == 'editshipping') |
@@ -494,14 +578,15 @@ discard block |
||
| 494 | 578 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 495 | 579 | print $langs->trans('IntracommReportTransportMode'); |
| 496 | 580 | print '<td>'; |
| 497 | - if (($action != 'edittransportmode') && $user->rights->societe->creer) print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edittransportmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 581 | + if (($action != 'edittransportmode') && $user->rights->societe->creer) { |
|
| 582 | + print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edittransportmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
| 583 | + } |
|
| 498 | 584 | print '</tr></table>'; |
| 499 | 585 | print '</td><td>'; |
| 500 | 586 | if ($action == 'edittransportmode') |
| 501 | 587 | { |
| 502 | 588 | $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); |
| 503 | - } |
|
| 504 | - else { |
|
| 589 | + } else { |
|
| 505 | 590 | $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); |
| 506 | 591 | } |
| 507 | 592 | print "</td>"; |
@@ -560,7 +645,9 @@ discard block |
||
| 560 | 645 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 561 | 646 | print $langs->trans('ProspectLevel'); |
| 562 | 647 | print '<td>'; |
| 563 | - if ($action != 'editlevel' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>'; |
|
| 648 | + if ($action != 'editlevel' && $user->rights->societe->creer) { |
|
| 649 | + print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>'; |
|
| 650 | + } |
|
| 564 | 651 | print '</tr></table>'; |
| 565 | 652 | print '</td><td>'; |
| 566 | 653 | if ($action == 'editlevel') |
@@ -580,8 +667,12 @@ discard block |
||
| 580 | 667 | foreach ($object->cacheprospectstatus as $key => $val) |
| 581 | 668 | { |
| 582 | 669 | $titlealt = 'default'; |
| 583 | - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; |
|
| 584 | - if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>'; |
|
| 670 | + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { |
|
| 671 | + $titlealt = $val['label']; |
|
| 672 | + } |
|
| 673 | + if ($object->stcomm_id != $val['id']) { |
|
| 674 | + print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>'; |
|
| 675 | + } |
|
| 585 | 676 | } |
| 586 | 677 | print '</div></td></tr>'; |
| 587 | 678 | print "</table>"; |
@@ -610,12 +701,16 @@ discard block |
||
| 610 | 701 | $text = $langs->trans("OverAllProposals"); |
| 611 | 702 | $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; |
| 612 | 703 | $icon = 'bill'; |
| 613 | - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 704 | + if ($link) { |
|
| 705 | + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 706 | + } |
|
| 614 | 707 | $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; |
| 615 | 708 | $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; |
| 616 | 709 | $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; |
| 617 | 710 | $boxstat .= '</div>'; |
| 618 | - if ($link) $boxstat .= '</a>'; |
|
| 711 | + if ($link) { |
|
| 712 | + $boxstat .= '</a>'; |
|
| 713 | + } |
|
| 619 | 714 | } |
| 620 | 715 | |
| 621 | 716 | if (!empty($conf->commande->enabled) && $user->rights->commande->lire) |
@@ -628,12 +723,16 @@ discard block |
||
| 628 | 723 | $text = $langs->trans("OverAllOrders"); |
| 629 | 724 | $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; |
| 630 | 725 | $icon = 'bill'; |
| 631 | - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 726 | + if ($link) { |
|
| 727 | + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 728 | + } |
|
| 632 | 729 | $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; |
| 633 | 730 | $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; |
| 634 | 731 | $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; |
| 635 | 732 | $boxstat .= '</div>'; |
| 636 | - if ($link) $boxstat .= '</a>'; |
|
| 733 | + if ($link) { |
|
| 734 | + $boxstat .= '</a>'; |
|
| 735 | + } |
|
| 637 | 736 | } |
| 638 | 737 | |
| 639 | 738 | if (!empty($conf->facture->enabled) && $user->rights->facture->lire) |
@@ -646,12 +745,16 @@ discard block |
||
| 646 | 745 | $text = $langs->trans("OverAllInvoices"); |
| 647 | 746 | $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; |
| 648 | 747 | $icon = 'bill'; |
| 649 | - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 748 | + if ($link) { |
|
| 749 | + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 750 | + } |
|
| 650 | 751 | $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; |
| 651 | 752 | $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; |
| 652 | 753 | $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; |
| 653 | 754 | $boxstat .= '</div>'; |
| 654 | - if ($link) $boxstat .= '</a>'; |
|
| 755 | + if ($link) { |
|
| 756 | + $boxstat .= '</a>'; |
|
| 757 | + } |
|
| 655 | 758 | |
| 656 | 759 | // Box outstanding bill |
| 657 | 760 | $warn = ''; |
@@ -662,12 +765,16 @@ discard block |
||
| 662 | 765 | $text = $langs->trans("CurrentOutstandingBill"); |
| 663 | 766 | $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; |
| 664 | 767 | $icon = 'bill'; |
| 665 | - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 768 | + if ($link) { |
|
| 769 | + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 770 | + } |
|
| 666 | 771 | $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; |
| 667 | 772 | $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; |
| 668 | 773 | $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>'; |
| 669 | 774 | $boxstat .= '</div>'; |
| 670 | - if ($link) $boxstat .= '</a>'; |
|
| 775 | + if ($link) { |
|
| 776 | + $boxstat .= '</a>'; |
|
| 777 | + } |
|
| 671 | 778 | } |
| 672 | 779 | |
| 673 | 780 | $parameters = array(); |
@@ -954,7 +1061,9 @@ discard block |
||
| 954 | 1061 | $late = ''; |
| 955 | 1062 | foreach ($contrat->lines as $line) { |
| 956 | 1063 | if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { |
| 957 | - if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); |
|
| 1064 | + if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) { |
|
| 1065 | + $late = img_warning($langs->trans("Late")); |
|
| 1066 | + } |
|
| 958 | 1067 | } |
| 959 | 1068 | } |
| 960 | 1069 | |
@@ -1300,13 +1409,21 @@ discard block |
||
| 1300 | 1409 | if (!empty($conf->commande->enabled)) |
| 1301 | 1410 | { |
| 1302 | 1411 | if ($object->client != 0 && $object->client != 2) { |
| 1303 | - if (!empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; |
|
| 1304 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; |
|
| 1305 | - } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1412 | + if (!empty($orders2invoice) && $orders2invoice > 0) { |
|
| 1413 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; |
|
| 1414 | + } else { |
|
| 1415 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; |
|
| 1416 | + } |
|
| 1417 | + } else { |
|
| 1418 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1419 | + } |
|
| 1306 | 1420 | } |
| 1307 | 1421 | |
| 1308 | - if ($object->client != 0 && $object->client != 2) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1309 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1422 | + if ($object->client != 0 && $object->client != 2) { |
|
| 1423 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1424 | + } else { |
|
| 1425 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; |
|
| 1426 | + } |
|
| 1310 | 1427 | } |
| 1311 | 1428 | } |
| 1312 | 1429 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | $langs->loadLangs(array("errors", "admin", "modulebuilder")); |
| 40 | 40 | |
| 41 | 41 | $mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common'); |
| 42 | -if (empty($mode)) $mode = 'common'; |
|
| 42 | +if (empty($mode)) { |
|
| 43 | + $mode = 'common'; |
|
| 44 | +} |
|
| 43 | 45 | $action = GETPOST('action', 'aZ09'); |
| 44 | 46 | //var_dump($_POST);exit; |
| 45 | 47 | $value = GETPOST('value', 'alpha'); |
@@ -60,8 +62,9 @@ discard block |
||
| 60 | 62 | $dolistore = new Dolistore(false); |
| 61 | 63 | |
| 62 | 64 | |
| 63 | -if (!$user->admin) |
|
| 65 | +if (!$user->admin) { |
|
| 64 | 66 | accessforbidden(); |
| 67 | +} |
|
| 65 | 68 | |
| 66 | 69 | $familyinfo = array( |
| 67 | 70 | 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")), |
@@ -81,11 +84,19 @@ discard block |
||
| 81 | 84 | $param = ''; |
| 82 | 85 | if (!GETPOST('buttonreset', 'alpha')) |
| 83 | 86 | { |
| 84 | - if ($search_keyword) $param .= '&search_keyword='.urlencode($search_keyword); |
|
| 85 | - if ($search_status && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); |
|
| 86 | - if ($search_nature && $search_nature != '-1') $param .= '&search_nature='.urlencode($search_nature); |
|
| 87 | - if ($search_version && $search_version != '-1') $param .= '&search_version='.urlencode($search_version); |
|
| 88 | -} |
|
| 87 | + if ($search_keyword) { |
|
| 88 | + $param .= '&search_keyword='.urlencode($search_keyword); |
|
| 89 | + } |
|
| 90 | + if ($search_status && $search_status != '-1') { |
|
| 91 | + $param .= '&search_status='.urlencode($search_status); |
|
| 92 | + } |
|
| 93 | + if ($search_nature && $search_nature != '-1') { |
|
| 94 | + $param .= '&search_nature='.urlencode($search_nature); |
|
| 95 | + } |
|
| 96 | + if ($search_version && $search_version != '-1') { |
|
| 97 | + $param .= '&search_version='.urlencode($search_version); |
|
| 98 | + } |
|
| 99 | + } |
|
| 89 | 100 | |
| 90 | 101 | $dirins = DOL_DOCUMENT_ROOT.'/custom'; |
| 91 | 102 | $urldolibarrmodules = 'https://www.dolistore.com/'; |
@@ -102,7 +113,9 @@ discard block |
||
| 102 | 113 | |
| 103 | 114 | $parameters = array(); |
| 104 | 115 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 105 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 116 | +if ($reshook < 0) { |
|
| 117 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 118 | +} |
|
| 106 | 119 | |
| 107 | 120 | if (GETPOST('buttonreset', 'alpha')) |
| 108 | 121 | { |
@@ -207,9 +220,17 @@ discard block |
||
| 207 | 220 | //var_dump($modulenamearrays);exit; |
| 208 | 221 | |
| 209 | 222 | foreach ($modulenamearrays as $modulenameval) { |
| 210 | - if (strpos($modulenameval, '#') === 0) continue; // Discard comments |
|
| 211 | - if (strpos($modulenameval, '//') === 0) continue; // Discard comments |
|
| 212 | - if (!trim($modulenameval)) continue; |
|
| 223 | + if (strpos($modulenameval, '#') === 0) { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 226 | + // Discard comments |
|
| 227 | + if (strpos($modulenameval, '//') === 0) { |
|
| 228 | + continue; |
|
| 229 | + } |
|
| 230 | + // Discard comments |
|
| 231 | + if (!trim($modulenameval)) { |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 213 | 234 | |
| 214 | 235 | // Now we install the module |
| 215 | 236 | if (!$error) |
@@ -242,8 +263,9 @@ discard block |
||
| 242 | 263 | if ($action == 'set' && $user->admin) |
| 243 | 264 | { |
| 244 | 265 | $resarray = activateModule($value); |
| 245 | - if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); |
|
| 246 | - else { |
|
| 266 | + if (!empty($resarray['errors'])) { |
|
| 267 | + setEventMessages('', $resarray['errors'], 'errors'); |
|
| 268 | + } else { |
|
| 247 | 269 | //var_dump($resarray);exit; |
| 248 | 270 | if ($resarray['nbperms'] > 0) |
| 249 | 271 | { |
@@ -258,7 +280,9 @@ discard block |
||
| 258 | 280 | $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); |
| 259 | 281 | setEventMessages($msg, null, 'warnings'); |
| 260 | 282 | } |
| 261 | - } else dol_print_error($db); |
|
| 283 | + } else { |
|
| 284 | + dol_print_error($db); |
|
| 285 | + } |
|
| 262 | 286 | } |
| 263 | 287 | } |
| 264 | 288 | header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); |
@@ -266,7 +290,9 @@ discard block |
||
| 266 | 290 | } elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') |
| 267 | 291 | { |
| 268 | 292 | $result = unActivateModule($value); |
| 269 | - if ($result) setEventMessages($result, null, 'errors'); |
|
| 293 | + if ($result) { |
|
| 294 | + setEventMessages($result, null, 'errors'); |
|
| 295 | + } |
|
| 270 | 296 | header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); |
| 271 | 297 | exit; |
| 272 | 298 | } |
@@ -325,9 +351,11 @@ discard block |
||
| 325 | 351 | |
| 326 | 352 | if ($modName) |
| 327 | 353 | { |
| 328 | - if (!empty($modNameLoaded[$modName])) // In cache of already loaded modules ? |
|
| 354 | + if (!empty($modNameLoaded[$modName])) { |
|
| 355 | + // In cache of already loaded modules ? |
|
| 329 | 356 | { |
| 330 | 357 | $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>"; |
| 358 | + } |
|
| 331 | 359 | setEventMessages($mesg, null, 'warnings'); |
| 332 | 360 | dol_syslog($mesg, LOG_ERR); |
| 333 | 361 | continue; |
@@ -350,12 +378,20 @@ discard block |
||
| 350 | 378 | |
| 351 | 379 | // We discard modules according to features level (PS: if module is activated we always show it) |
| 352 | 380 | $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); |
| 353 | - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; |
|
| 354 | - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; |
|
| 355 | - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; |
|
| 381 | + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) { |
|
| 382 | + $modulequalified = 0; |
|
| 383 | + } |
|
| 384 | + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) { |
|
| 385 | + $modulequalified = 0; |
|
| 386 | + } |
|
| 387 | + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) { |
|
| 388 | + $modulequalified = 0; |
|
| 389 | + } |
|
| 356 | 390 | |
| 357 | 391 | // We discard modules according to property ->hidden |
| 358 | - if (!empty($objMod->hidden)) $modulequalified = 0; |
|
| 392 | + if (!empty($objMod->hidden)) { |
|
| 393 | + $modulequalified = 0; |
|
| 394 | + } |
|
| 359 | 395 | |
| 360 | 396 | if ($modulequalified > 0) |
| 361 | 397 | { |
@@ -414,12 +450,21 @@ discard block |
||
| 414 | 450 | |
| 415 | 451 | // Set categ[$i] |
| 416 | 452 | $specialstring = 'unknown'; |
| 417 | - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; |
|
| 418 | - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories |
|
| 419 | - else $categ[$specialstring] = 1; |
|
| 453 | + if ($objMod->version == 'development' || $objMod->version == 'experimental') { |
|
| 454 | + $specialstring = 'expdev'; |
|
| 455 | + } |
|
| 456 | + if (isset($categ[$specialstring])) { |
|
| 457 | + $categ[$specialstring]++; |
|
| 458 | + } |
|
| 459 | + // Array of all different modules categories |
|
| 460 | + else { |
|
| 461 | + $categ[$specialstring] = 1; |
|
| 462 | + } |
|
| 420 | 463 | $j++; |
| 421 | 464 | $i++; |
| 422 | - } else dol_syslog("Module ".get_class($objMod)." not qualified"); |
|
| 465 | + } else { |
|
| 466 | + dol_syslog("Module ".get_class($objMod)." not qualified"); |
|
| 467 | + } |
|
| 423 | 468 | } catch (Exception $e) |
| 424 | 469 | { |
| 425 | 470 | dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); |
@@ -445,7 +490,9 @@ discard block |
||
| 445 | 490 | if (!empty($modules[$value])) { |
| 446 | 491 | $objMod = $modules[$value]; |
| 447 | 492 | |
| 448 | - if (!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); |
|
| 493 | + if (!empty($objMod->langfiles)) { |
|
| 494 | + $langs->loadLangs($objMod->langfiles); |
|
| 495 | + } |
|
| 449 | 496 | |
| 450 | 497 | $form = new Form($db); |
| 451 | 498 | $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1); |
@@ -462,16 +509,28 @@ discard block |
||
| 462 | 509 | $nbofactivatedmodules = count($conf->modules); |
| 463 | 510 | $moreinfo = $langs->trans("TitleNumberOfActivatedModules"); |
| 464 | 511 | $moreinfo2 = ($nbofactivatedmodules - 1)." / ".count($modules); |
| 465 | -if ($nbofactivatedmodules <= 1) $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); |
|
| 512 | +if ($nbofactivatedmodules <= 1) { |
|
| 513 | + $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); |
|
| 514 | +} |
|
| 466 | 515 | |
| 467 | 516 | print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup'); |
| 468 | 517 | |
| 469 | 518 | // Start to show page |
| 470 | -if ($mode == 'common') print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."<br></span>\n"; |
|
| 471 | -if ($mode == 'commonkanban') print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."<br></span>\n"; |
|
| 472 | -if ($mode == 'marketplace') print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesMarketPlaceDesc")."<br></span>\n"; |
|
| 473 | -if ($mode == 'deploy') print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br></span>\n"; |
|
| 474 | -if ($mode == 'develop') print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br></span>\n"; |
|
| 519 | +if ($mode == 'common') { |
|
| 520 | + print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."<br></span>\n"; |
|
| 521 | +} |
|
| 522 | +if ($mode == 'commonkanban') { |
|
| 523 | + print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."<br></span>\n"; |
|
| 524 | +} |
|
| 525 | +if ($mode == 'marketplace') { |
|
| 526 | + print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesMarketPlaceDesc")."<br></span>\n"; |
|
| 527 | +} |
|
| 528 | +if ($mode == 'deploy') { |
|
| 529 | + print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br></span>\n"; |
|
| 530 | +} |
|
| 531 | +if ($mode == 'develop') { |
|
| 532 | + print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br></span>\n"; |
|
| 533 | +} |
|
| 475 | 534 | |
| 476 | 535 | $head = modules_prepare_head(); |
| 477 | 536 | |
@@ -484,7 +543,9 @@ discard block |
||
| 484 | 543 | dol_set_focus('#search_keyword'); |
| 485 | 544 | |
| 486 | 545 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
| 487 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 546 | + if ($optioncss != '') { |
|
| 547 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 548 | + } |
|
| 488 | 549 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 489 | 550 | print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
| 490 | 551 | print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
@@ -492,7 +553,9 @@ discard block |
||
| 492 | 553 | print '<input type="hidden" name="mode" value="'.$mode.'">'; |
| 493 | 554 | |
| 494 | 555 | $newmode = $mode; |
| 495 | - if ($newmode == 'common') $newmode = 'commonkanban'; |
|
| 556 | + if ($newmode == 'common') { |
|
| 557 | + $newmode = 'commonkanban'; |
|
| 558 | + } |
|
| 496 | 559 | |
| 497 | 560 | dol_fiche_head($head, $newmode, '', -1); |
| 498 | 561 | |
@@ -515,9 +578,15 @@ discard block |
||
| 515 | 578 | if (!empty($conf->global->MAIN_FEATURES_LEVEL)) |
| 516 | 579 | { |
| 517 | 580 | $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); |
| 518 | - if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated'] = $langs->trans("Deprecated"); |
|
| 519 | - if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental'] = $langs->trans("Experimental"); |
|
| 520 | - if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development'] = $langs->trans("Development"); |
|
| 581 | + if ($conf->global->MAIN_FEATURES_LEVEL < 0) { |
|
| 582 | + $array_version['deprecated'] = $langs->trans("Deprecated"); |
|
| 583 | + } |
|
| 584 | + if ($conf->global->MAIN_FEATURES_LEVEL > 0) { |
|
| 585 | + $array_version['experimental'] = $langs->trans("Experimental"); |
|
| 586 | + } |
|
| 587 | + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { |
|
| 588 | + $array_version['development'] = $langs->trans("Development"); |
|
| 589 | + } |
|
| 521 | 590 | $moreforfilter .= '<div class="divsearchfield paddingtop">'; |
| 522 | 591 | $moreforfilter .= $langs->trans('Version').': '.$form->selectarray('search_version', $array_version, $search_version, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); |
| 523 | 592 | $moreforfilter .= '</div>'; |
@@ -550,7 +619,9 @@ discard block |
||
| 550 | 619 | $object = new stdClass(); |
| 551 | 620 | $parameters = array(); |
| 552 | 621 | $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 553 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 622 | + if ($reshook < 0) { |
|
| 623 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 624 | + } |
|
| 554 | 625 | |
| 555 | 626 | // Show list of modules |
| 556 | 627 | $oldfamily = ''; |
@@ -567,7 +638,10 @@ discard block |
||
| 567 | 638 | $objMod = $modules[$modName]; |
| 568 | 639 | |
| 569 | 640 | //print $objMod->name." - ".$key." - ".$objMod->version."<br>"; |
| 570 | - if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab |
|
| 641 | + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') { |
|
| 642 | + continue; |
|
| 643 | + } |
|
| 644 | + // Discard if not for current tab |
|
| 571 | 645 | |
| 572 | 646 | if (!$objMod->getName()) |
| 573 | 647 | { |
@@ -593,33 +667,57 @@ discard block |
||
| 593 | 667 | || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc) |
| 594 | 668 | || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong) |
| 595 | 669 | || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor) |
| 596 | - ) $qualified = 1; |
|
| 597 | - if (!$qualified) continue; |
|
| 670 | + ) { |
|
| 671 | + $qualified = 1; |
|
| 672 | + } |
|
| 673 | + if (!$qualified) { |
|
| 674 | + continue; |
|
| 675 | + } |
|
| 598 | 676 | } |
| 599 | 677 | if ($search_status) |
| 600 | 678 | { |
| 601 | - if ($search_status == 'active' && empty($conf->global->$const_name)) continue; |
|
| 602 | - if ($search_status == 'disabled' && !empty($conf->global->$const_name)) continue; |
|
| 679 | + if ($search_status == 'active' && empty($conf->global->$const_name)) { |
|
| 680 | + continue; |
|
| 681 | + } |
|
| 682 | + if ($search_status == 'disabled' && !empty($conf->global->$const_name)) { |
|
| 683 | + continue; |
|
| 684 | + } |
|
| 603 | 685 | } |
| 604 | 686 | if ($search_nature) |
| 605 | 687 | { |
| 606 | - if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue; |
|
| 688 | + if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') { |
|
| 689 | + continue; |
|
| 690 | + } |
|
| 607 | 691 | $reg = array(); |
| 608 | 692 | if (preg_match('/^external_(.*)$/', $search_nature, $reg)) |
| 609 | 693 | { |
| 610 | 694 | //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher()); |
| 611 | 695 | $publisher = dol_escape_htmltag($objMod->getPublisher()); |
| 612 | - if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) continue; |
|
| 613 | - if (!$reg[1] && !empty($publisher)) continue; |
|
| 696 | + if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) { |
|
| 697 | + continue; |
|
| 698 | + } |
|
| 699 | + if (!$reg[1] && !empty($publisher)) { |
|
| 700 | + continue; |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') { |
|
| 704 | + continue; |
|
| 614 | 705 | } |
| 615 | - if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue; |
|
| 616 | 706 | } |
| 617 | 707 | if ($search_version) |
| 618 | 708 | { |
| 619 | - if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue; |
|
| 620 | - if ($objMod->version != 'development' && ($search_version == 'development')) continue; |
|
| 621 | - if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue; |
|
| 622 | - if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue; |
|
| 709 | + if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') { |
|
| 710 | + continue; |
|
| 711 | + } |
|
| 712 | + if ($objMod->version != 'development' && ($search_version == 'development')) { |
|
| 713 | + continue; |
|
| 714 | + } |
|
| 715 | + if ($objMod->version != 'experimental' && ($search_version == 'experimental')) { |
|
| 716 | + continue; |
|
| 717 | + } |
|
| 718 | + if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) { |
|
| 719 | + continue; |
|
| 720 | + } |
|
| 623 | 721 | } |
| 624 | 722 | |
| 625 | 723 | // Load all lang files of module |
@@ -662,9 +760,15 @@ discard block |
||
| 662 | 760 | // Version (with picto warning or not) |
| 663 | 761 | $version = $objMod->getVersion(0); |
| 664 | 762 | $versiontrans = ''; |
| 665 | - if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); |
|
| 666 | - if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); |
|
| 667 | - if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); |
|
| 763 | + if (preg_match('/development/i', $version)) { |
|
| 764 | + $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); |
|
| 765 | + } |
|
| 766 | + if (preg_match('/experimental/i', $version)) { |
|
| 767 | + $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); |
|
| 768 | + } |
|
| 769 | + if (preg_match('/deprecated/i', $version)) { |
|
| 770 | + $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); |
|
| 771 | + } |
|
| 668 | 772 | if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { |
| 669 | 773 | $versiontrans .= $objMod->getVersion(1); |
| 670 | 774 | } |
@@ -680,10 +784,12 @@ discard block |
||
| 680 | 784 | $codetoconfig = ''; |
| 681 | 785 | |
| 682 | 786 | // Activate/Disable and Setup (2 columns) |
| 683 | - if (!empty($conf->global->$const_name)) // If module is already activated |
|
| 787 | + if (!empty($conf->global->$const_name)) { |
|
| 788 | + // If module is already activated |
|
| 684 | 789 | { |
| 685 | 790 | // Set $codeenabledisable |
| 686 | 791 | $disableSetup = 0; |
| 792 | + } |
|
| 687 | 793 | if (!empty($arrayofwarnings[$modName])) |
| 688 | 794 | { |
| 689 | 795 | $codeenabledisable .= '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n"; |
@@ -693,12 +799,15 @@ discard block |
||
| 693 | 799 | $codeenabledisable .= $langs->trans("Disabled"); |
| 694 | 800 | } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) |
| 695 | 801 | { |
| 696 | - if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) $codeenabledisable .= $langs->trans("Used"); |
|
| 697 | - else { |
|
| 802 | + if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { |
|
| 803 | + $codeenabledisable .= $langs->trans("Used"); |
|
| 804 | + } else { |
|
| 698 | 805 | $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle'); |
| 699 | 806 | //print $langs->trans("Required"); |
| 700 | 807 | } |
| 701 | - if (!empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; |
|
| 808 | + if (!empty($conf->multicompany->enabled) && $user->entity) { |
|
| 809 | + $disableSetup++; |
|
| 810 | + } |
|
| 702 | 811 | } else { |
| 703 | 812 | if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { |
| 704 | 813 | $codeenabledisable .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&module_position='.$module_position.'&action=reset_confirm&confirm_message_code='.$objMod->warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; |
@@ -715,10 +824,19 @@ discard block |
||
| 715 | 824 | if (!empty($objMod->config_page_url) && !$disableSetup) |
| 716 | 825 | { |
| 717 | 826 | $backtourlparam = ''; |
| 718 | - if ($search_keyword != '') $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; // No urlencode here, done later |
|
| 719 | - if ($search_nature > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; |
|
| 720 | - if ($search_version > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; |
|
| 721 | - if ($search_status > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; |
|
| 827 | + if ($search_keyword != '') { |
|
| 828 | + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; |
|
| 829 | + } |
|
| 830 | + // No urlencode here, done later |
|
| 831 | + if ($search_nature > -1) { |
|
| 832 | + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; |
|
| 833 | + } |
|
| 834 | + if ($search_version > -1) { |
|
| 835 | + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; |
|
| 836 | + } |
|
| 837 | + if ($search_status > -1) { |
|
| 838 | + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; |
|
| 839 | + } |
|
| 722 | 840 | $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; |
| 723 | 841 | |
| 724 | 842 | $regs = array(); |
@@ -781,16 +899,22 @@ discard block |
||
| 781 | 899 | foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) |
| 782 | 900 | { |
| 783 | 901 | $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule)); |
| 784 | - if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on |
|
| 902 | + if (in_array($keymodulelowercase, $conf->modules)) { |
|
| 903 | + // If module that request warning is on |
|
| 785 | 904 | { |
| 786 | 905 | foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) |
| 787 | 906 | { |
| 788 | 907 | if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) |
| 789 | 908 | { |
| 790 | 909 | $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); |
| 910 | + } |
|
| 791 | 911 | $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName(); |
| 792 | - if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name; |
|
| 793 | - if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); |
|
| 912 | + if (!empty($objMod->editor_name)) { |
|
| 913 | + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name; |
|
| 914 | + } |
|
| 915 | + if (!empty($objMod->editor_name)) { |
|
| 916 | + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); |
|
| 917 | + } |
|
| 794 | 918 | } |
| 795 | 919 | } |
| 796 | 920 | } |
@@ -798,7 +922,9 @@ discard block |
||
| 798 | 922 | } |
| 799 | 923 | $codeenabledisable .= '<!-- Message to show: '.$warningmessage.' -->'."\n"; |
| 800 | 924 | $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&value='.$modName.'&mode='.$mode.$param.'"'; |
| 801 | - if ($warningmessage) $codeenabledisable .= ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"'; |
|
| 925 | + if ($warningmessage) { |
|
| 926 | + $codeenabledisable .= ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"'; |
|
| 927 | + } |
|
| 802 | 928 | $codeenabledisable .= '>'; |
| 803 | 929 | $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off'); |
| 804 | 930 | $codeenabledisable .= "</a>\n"; |
@@ -813,7 +939,9 @@ discard block |
||
| 813 | 939 | print $objMod->getKanbanView($codeenabledisable, $codetoconfig); |
| 814 | 940 | } else { |
| 815 | 941 | print '<tr class="oddeven">'."\n"; |
| 816 | - if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print '<td width="20px">'.$linenum.'</td>'; |
|
| 942 | + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { |
|
| 943 | + print '<td width="20px">'.$linenum.'</td>'; |
|
| 944 | + } |
|
| 817 | 945 | |
| 818 | 946 | // Picto + Name of module |
| 819 | 947 | print ' <td width="200px">'; |
@@ -822,8 +950,11 @@ discard block |
||
| 822 | 950 | //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin); |
| 823 | 951 | if (!empty($objMod->picto)) |
| 824 | 952 | { |
| 825 | - if (preg_match('/^\//i', $objMod->picto)) print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1); |
|
| 826 | - else print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); |
|
| 953 | + if (preg_match('/^\//i', $objMod->picto)) { |
|
| 954 | + print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1); |
|
| 955 | + } else { |
|
| 956 | + print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); |
|
| 957 | + } |
|
| 827 | 958 | } else { |
| 828 | 959 | print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"'); |
| 829 | 960 | } |
@@ -983,7 +1114,9 @@ discard block |
||
| 983 | 1114 | $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT); |
| 984 | 1115 | $allowonlineinstall = true; |
| 985 | 1116 | $allowfromweb = 1; |
| 986 | - if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall = false; |
|
| 1117 | + if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) { |
|
| 1118 | + $allowonlineinstall = false; |
|
| 1119 | + } |
|
| 987 | 1120 | |
| 988 | 1121 | $fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>'; |
| 989 | 1122 | $message = ''; |
@@ -1051,15 +1184,31 @@ discard block |
||
| 1051 | 1184 | |
| 1052 | 1185 | $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb |
| 1053 | 1186 | $maxphp = @ini_get('upload_max_filesize'); // In unknown |
| 1054 | - if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; |
|
| 1055 | - if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; |
|
| 1056 | - if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; |
|
| 1057 | - if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; |
|
| 1187 | + if (preg_match('/k$/i', $maxphp)) { |
|
| 1188 | + $maxphp = $maxphp * 1; |
|
| 1189 | + } |
|
| 1190 | + if (preg_match('/m$/i', $maxphp)) { |
|
| 1191 | + $maxphp = $maxphp * 1024; |
|
| 1192 | + } |
|
| 1193 | + if (preg_match('/g$/i', $maxphp)) { |
|
| 1194 | + $maxphp = $maxphp * 1024 * 1024; |
|
| 1195 | + } |
|
| 1196 | + if (preg_match('/t$/i', $maxphp)) { |
|
| 1197 | + $maxphp = $maxphp * 1024 * 1024 * 1024; |
|
| 1198 | + } |
|
| 1058 | 1199 | $maxphp2 = @ini_get('post_max_size'); // In unknown |
| 1059 | - if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; |
|
| 1060 | - if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; |
|
| 1061 | - if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; |
|
| 1062 | - if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; |
|
| 1200 | + if (preg_match('/k$/i', $maxphp2)) { |
|
| 1201 | + $maxphp2 = $maxphp2 * 1; |
|
| 1202 | + } |
|
| 1203 | + if (preg_match('/m$/i', $maxphp2)) { |
|
| 1204 | + $maxphp2 = $maxphp2 * 1024; |
|
| 1205 | + } |
|
| 1206 | + if (preg_match('/g$/i', $maxphp2)) { |
|
| 1207 | + $maxphp2 = $maxphp2 * 1024 * 1024; |
|
| 1208 | + } |
|
| 1209 | + if (preg_match('/t$/i', $maxphp2)) { |
|
| 1210 | + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; |
|
| 1211 | + } |
|
| 1063 | 1212 | // Now $max and $maxphp and $maxphp2 are in Kb |
| 1064 | 1213 | $maxmin = $max; |
| 1065 | 1214 | $maxphptoshow = $maxphptoshowparam = ''; |