@@ -67,10 +67,10 @@ |
||
67 | 67 | |
68 | 68 | // Dependencies |
69 | 69 | $this->hidden = false; // A condition to hide module |
70 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
72 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
70 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
72 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
74 | 74 | $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module |
75 | 75 | $this->conflictwith = array(); |
76 | 76 | $this->langfiles = array("printing"); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \ingroup printing |
26 | 26 | * \brief File of class to describe and activate module Direct Printing |
27 | 27 | */ |
28 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
28 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function __construct($db) |
44 | 44 | { |
45 | - $this->db = $db ; |
|
45 | + $this->db = $db; |
|
46 | 46 | $this->numero = 64000; |
47 | 47 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
48 | 48 | // It is used to group modules in module setup page |
49 | 49 | $this->family = "interface"; |
50 | 50 | $this->module_position = '52'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
54 | 54 | $this->description = "Enable Direct Printing System."; |
55 | - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version |
|
55 | + $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version |
|
56 | 56 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
57 | 57 | // Name of image file used for this module. |
58 | 58 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $this->config_page_url = array("printing.php@printing"); |
67 | 67 | |
68 | 68 | // Dependencies |
69 | - $this->hidden = false; // A condition to hide module |
|
70 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
72 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
74 | - $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module |
|
69 | + $this->hidden = false; // A condition to hide module |
|
70 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
72 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
74 | + $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module |
|
75 | 75 | $this->conflictwith = array(); |
76 | 76 | $this->langfiles = array("printing"); |
77 | 77 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->rights = array(); |
86 | 86 | $this->rights_class = 'printing'; |
87 | 87 | |
88 | - $r=0; |
|
88 | + $r = 0; |
|
89 | 89 | // $this->rights[$r][0] Id permission (unique tous modules confondus) |
90 | 90 | // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) |
91 | 91 | // $this->rights[$r][2] Non utilise |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | $this->rights[$r][4] = 'read'; |
102 | 102 | |
103 | 103 | // Main menu entries |
104 | - $this->menus = array(); // List of menus to add |
|
105 | - $r=0; |
|
104 | + $this->menus = array(); // List of menus to add |
|
105 | + $r = 0; |
|
106 | 106 | |
107 | 107 | // This is to declare the Top Menu entry: |
108 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu |
|
109 | - 'type'=>'left', // This is a Top menu entry |
|
108 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu |
|
109 | + 'type'=>'left', // This is a Top menu entry |
|
110 | 110 | 'titre'=>'MenuDirectPrinting', |
111 | 111 | 'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools', |
112 | - 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
112 | + 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
113 | 113 | 'position'=>300, |
114 | 114 | 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', |
115 | - 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules |
|
115 | + 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules |
|
116 | 116 | 'target'=>'', |
117 | - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
117 | + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
118 | 118 | |
119 | 119 | $r++; |
120 | 120 | } |
@@ -34,128 +34,128 @@ |
||
34 | 34 | class modMailing extends DolibarrModules |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
39 | - * |
|
40 | - * @param DoliDB $db Database handler |
|
41 | - */ |
|
42 | - function __construct($db) |
|
43 | - { |
|
44 | - $this->db = $db; |
|
45 | - $this->numero = 22; |
|
46 | - |
|
47 | - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' |
|
48 | - // It is used to group modules by family in module setup page |
|
49 | - $this->family = "interface"; |
|
50 | - // Module position in the family on 2 digits ('01', '10', '20', ...) |
|
51 | - $this->module_position = '11'; |
|
52 | - |
|
53 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | - $this->description = "Gestion des EMailings"; |
|
56 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
57 | - $this->version = 'dolibarr'; |
|
58 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
59 | - $this->picto='email'; |
|
60 | - |
|
61 | - // Data directories to create when module is enabled |
|
62 | - $this->dirs = array("/mailing/temp"); |
|
63 | - |
|
64 | - // Dependencies |
|
65 | - $this->hidden = false; // A condition to hide module |
|
66 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
67 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
68 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
69 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
70 | - $this->langfiles = array("mails"); |
|
71 | - |
|
72 | - // Config pages |
|
73 | - $this->config_page_url = array("mailing.php"); |
|
74 | - |
|
75 | - // Constants |
|
76 | - $this->const = array(); |
|
77 | - |
|
78 | - // Boxes |
|
79 | - $this->boxes = array(); |
|
80 | - |
|
81 | - // Permissions |
|
82 | - $this->rights = array(); |
|
83 | - $this->rights_class = 'mailing'; |
|
84 | - $r=0; |
|
85 | - |
|
86 | - $r++; |
|
87 | - $this->rights[$r][0] = 221; // id de la permission |
|
88 | - $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission |
|
89 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
90 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
91 | - $this->rights[$r][4] = 'lire'; |
|
92 | - |
|
93 | - $r++; |
|
94 | - $this->rights[$r][0] = 222; |
|
95 | - $this->rights[$r][1] = 'Creer/modifier les mailings (sujet, destinataires...)'; |
|
96 | - $this->rights[$r][2] = 'w'; |
|
97 | - $this->rights[$r][3] = 0; |
|
98 | - $this->rights[$r][4] = 'creer'; |
|
99 | - |
|
100 | - $r++; |
|
101 | - $this->rights[$r][0] = 223; |
|
102 | - $this->rights[$r][1] = 'Valider les mailings (permet leur envoi)'; |
|
103 | - $this->rights[$r][2] = 'w'; |
|
104 | - $this->rights[$r][3] = 0; |
|
105 | - $this->rights[$r][4] = 'valider'; |
|
106 | - |
|
107 | - $r++; |
|
108 | - $this->rights[$r][0] = 229; |
|
109 | - $this->rights[$r][1] = 'Supprimer les mailings'; |
|
110 | - $this->rights[$r][2] = 'd'; |
|
111 | - $this->rights[$r][3] = 0; |
|
112 | - $this->rights[$r][4] = 'supprimer'; |
|
113 | - |
|
114 | - $r++; |
|
115 | - $this->rights[$r][0] = 237; |
|
116 | - $this->rights[$r][1] = 'View recipients and info'; |
|
117 | - $this->rights[$r][2] = 'r'; |
|
118 | - $this->rights[$r][3] = 0; |
|
119 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
120 | - $this->rights[$r][5] = 'recipient'; |
|
121 | - |
|
122 | - $r++; |
|
123 | - $this->rights[$r][0] = 238; |
|
124 | - $this->rights[$r][1] = 'Manually send mailings'; |
|
125 | - $this->rights[$r][2] = 'w'; |
|
126 | - $this->rights[$r][3] = 0; |
|
127 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
128 | - $this->rights[$r][5] = 'send'; |
|
129 | - |
|
130 | - $r++; |
|
131 | - $this->rights[$r][0] = 239; |
|
132 | - $this->rights[$r][1] = 'Delete mailings after validation and/or sent'; |
|
133 | - $this->rights[$r][2] = 'd'; |
|
134 | - $this->rights[$r][3] = 0; |
|
135 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
136 | - $this->rights[$r][5] = 'delete'; |
|
137 | - |
|
138 | - // Menus |
|
139 | - //------- |
|
140 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * Function called when module is enabled. |
|
146 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
147 | - * It also creates data directories |
|
148 | - * |
|
37 | + /** |
|
38 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
39 | + * |
|
40 | + * @param DoliDB $db Database handler |
|
41 | + */ |
|
42 | + function __construct($db) |
|
43 | + { |
|
44 | + $this->db = $db; |
|
45 | + $this->numero = 22; |
|
46 | + |
|
47 | + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' |
|
48 | + // It is used to group modules by family in module setup page |
|
49 | + $this->family = "interface"; |
|
50 | + // Module position in the family on 2 digits ('01', '10', '20', ...) |
|
51 | + $this->module_position = '11'; |
|
52 | + |
|
53 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->description = "Gestion des EMailings"; |
|
56 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
57 | + $this->version = 'dolibarr'; |
|
58 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
59 | + $this->picto='email'; |
|
60 | + |
|
61 | + // Data directories to create when module is enabled |
|
62 | + $this->dirs = array("/mailing/temp"); |
|
63 | + |
|
64 | + // Dependencies |
|
65 | + $this->hidden = false; // A condition to hide module |
|
66 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
67 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
68 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
69 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
70 | + $this->langfiles = array("mails"); |
|
71 | + |
|
72 | + // Config pages |
|
73 | + $this->config_page_url = array("mailing.php"); |
|
74 | + |
|
75 | + // Constants |
|
76 | + $this->const = array(); |
|
77 | + |
|
78 | + // Boxes |
|
79 | + $this->boxes = array(); |
|
80 | + |
|
81 | + // Permissions |
|
82 | + $this->rights = array(); |
|
83 | + $this->rights_class = 'mailing'; |
|
84 | + $r=0; |
|
85 | + |
|
86 | + $r++; |
|
87 | + $this->rights[$r][0] = 221; // id de la permission |
|
88 | + $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission |
|
89 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
90 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
91 | + $this->rights[$r][4] = 'lire'; |
|
92 | + |
|
93 | + $r++; |
|
94 | + $this->rights[$r][0] = 222; |
|
95 | + $this->rights[$r][1] = 'Creer/modifier les mailings (sujet, destinataires...)'; |
|
96 | + $this->rights[$r][2] = 'w'; |
|
97 | + $this->rights[$r][3] = 0; |
|
98 | + $this->rights[$r][4] = 'creer'; |
|
99 | + |
|
100 | + $r++; |
|
101 | + $this->rights[$r][0] = 223; |
|
102 | + $this->rights[$r][1] = 'Valider les mailings (permet leur envoi)'; |
|
103 | + $this->rights[$r][2] = 'w'; |
|
104 | + $this->rights[$r][3] = 0; |
|
105 | + $this->rights[$r][4] = 'valider'; |
|
106 | + |
|
107 | + $r++; |
|
108 | + $this->rights[$r][0] = 229; |
|
109 | + $this->rights[$r][1] = 'Supprimer les mailings'; |
|
110 | + $this->rights[$r][2] = 'd'; |
|
111 | + $this->rights[$r][3] = 0; |
|
112 | + $this->rights[$r][4] = 'supprimer'; |
|
113 | + |
|
114 | + $r++; |
|
115 | + $this->rights[$r][0] = 237; |
|
116 | + $this->rights[$r][1] = 'View recipients and info'; |
|
117 | + $this->rights[$r][2] = 'r'; |
|
118 | + $this->rights[$r][3] = 0; |
|
119 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
120 | + $this->rights[$r][5] = 'recipient'; |
|
121 | + |
|
122 | + $r++; |
|
123 | + $this->rights[$r][0] = 238; |
|
124 | + $this->rights[$r][1] = 'Manually send mailings'; |
|
125 | + $this->rights[$r][2] = 'w'; |
|
126 | + $this->rights[$r][3] = 0; |
|
127 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
128 | + $this->rights[$r][5] = 'send'; |
|
129 | + |
|
130 | + $r++; |
|
131 | + $this->rights[$r][0] = 239; |
|
132 | + $this->rights[$r][1] = 'Delete mailings after validation and/or sent'; |
|
133 | + $this->rights[$r][2] = 'd'; |
|
134 | + $this->rights[$r][3] = 0; |
|
135 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
136 | + $this->rights[$r][5] = 'delete'; |
|
137 | + |
|
138 | + // Menus |
|
139 | + //------- |
|
140 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * Function called when module is enabled. |
|
146 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
147 | + * It also creates data directories |
|
148 | + * |
|
149 | 149 | * @param string $options Options when enabling module ('', 'noboxes') |
150 | - * @return int 1 if OK, 0 if KO |
|
151 | - */ |
|
152 | - function init($options='') |
|
153 | - { |
|
154 | - // Permissions |
|
155 | - $this->remove($options); |
|
150 | + * @return int 1 if OK, 0 if KO |
|
151 | + */ |
|
152 | + function init($options='') |
|
153 | + { |
|
154 | + // Permissions |
|
155 | + $this->remove($options); |
|
156 | 156 | |
157 | - $sql = array(); |
|
157 | + $sql = array(); |
|
158 | 158 | |
159 | - return $this->_init($sql,$options); |
|
160 | - } |
|
159 | + return $this->_init($sql,$options); |
|
160 | + } |
|
161 | 161 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \brief Fichier de description et activation du module Mailing |
26 | 26 | */ |
27 | 27 | |
28 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
28 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | $this->module_position = '11'; |
52 | 52 | |
53 | 53 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | $this->description = "Gestion des EMailings"; |
56 | 56 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
57 | 57 | $this->version = 'dolibarr'; |
58 | 58 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
59 | - $this->picto='email'; |
|
59 | + $this->picto = 'email'; |
|
60 | 60 | |
61 | 61 | // Data directories to create when module is enabled |
62 | 62 | $this->dirs = array("/mailing/temp"); |
63 | 63 | |
64 | 64 | // Dependencies |
65 | - $this->hidden = false; // A condition to hide module |
|
66 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
67 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
68 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
69 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
65 | + $this->hidden = false; // A condition to hide module |
|
66 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
67 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
68 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
69 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
70 | 70 | $this->langfiles = array("mails"); |
71 | 71 | |
72 | 72 | // Config pages |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | // Permissions |
82 | 82 | $this->rights = array(); |
83 | 83 | $this->rights_class = 'mailing'; |
84 | - $r=0; |
|
84 | + $r = 0; |
|
85 | 85 | |
86 | 86 | $r++; |
87 | 87 | $this->rights[$r][0] = 221; // id de la permission |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $this->rights[$r][1] = 'View recipients and info'; |
117 | 117 | $this->rights[$r][2] = 'r'; |
118 | 118 | $this->rights[$r][3] = 0; |
119 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
119 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
120 | 120 | $this->rights[$r][5] = 'recipient'; |
121 | 121 | |
122 | 122 | $r++; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->rights[$r][1] = 'Manually send mailings'; |
125 | 125 | $this->rights[$r][2] = 'w'; |
126 | 126 | $this->rights[$r][3] = 0; |
127 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
127 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
128 | 128 | $this->rights[$r][5] = 'send'; |
129 | 129 | |
130 | 130 | $r++; |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | $this->rights[$r][1] = 'Delete mailings after validation and/or sent'; |
133 | 133 | $this->rights[$r][2] = 'd'; |
134 | 134 | $this->rights[$r][3] = 0; |
135 | - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
135 | + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
136 | 136 | $this->rights[$r][5] = 'delete'; |
137 | 137 | |
138 | 138 | // Menus |
139 | 139 | //------- |
140 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
140 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | * @param string $options Options when enabling module ('', 'noboxes') |
150 | 150 | * @return int 1 if OK, 0 if KO |
151 | 151 | */ |
152 | - function init($options='') |
|
152 | + function init($options = '') |
|
153 | 153 | { |
154 | 154 | // Permissions |
155 | 155 | $this->remove($options); |
156 | 156 | |
157 | 157 | $sql = array(); |
158 | 158 | |
159 | - return $this->_init($sql,$options); |
|
159 | + return $this->_init($sql, $options); |
|
160 | 160 | } |
161 | 161 | } |
@@ -32,133 +32,133 @@ |
||
32 | 32 | class modDeplacement extends DolibarrModules |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
39 | - */ |
|
40 | - function __construct($db) |
|
41 | - { |
|
42 | - global $conf, $user; |
|
43 | - |
|
44 | - $this->db = $db; |
|
45 | - $this->numero = 75 ; |
|
46 | - |
|
47 | - $this->family = "hr"; |
|
48 | - $this->module_position = '41'; |
|
49 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
50 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | - $this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee |
|
52 | - |
|
53 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
|
54 | - $this->version = 'dolibarr_deprecated'; |
|
55 | - |
|
56 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
57 | - $this->picto = "trip"; |
|
58 | - |
|
59 | - // Data directories to create when module is enabled |
|
60 | - $this->dirs = array(); |
|
61 | - |
|
62 | - // Config pages |
|
63 | - $this->config_page_url = array(); |
|
64 | - $this->langfiles = array("companies","trips"); |
|
65 | - |
|
66 | - // Dependancies |
|
67 | - $this->depends = array(); |
|
68 | - $this->requiredby = array(); |
|
69 | - |
|
70 | - // Constants |
|
71 | - $this->const = array(); |
|
72 | - |
|
73 | - // Boxes |
|
74 | - $this->boxes = array(); |
|
75 | - |
|
76 | - // Permissions |
|
77 | - $this->rights = array(); |
|
78 | - $this->rights_class = 'deplacement'; |
|
79 | - |
|
80 | - $this->rights[1][0] = 171; |
|
81 | - $this->rights[1][1] = 'Lire ses notes de frais et deplacements et celles de sa hierarchy'; |
|
82 | - $this->rights[1][2] = 'r'; |
|
83 | - $this->rights[1][3] = 1; |
|
84 | - $this->rights[1][4] = 'lire'; |
|
85 | - |
|
86 | - $this->rights[2][0] = 172; |
|
87 | - $this->rights[2][1] = 'Creer/modifier une note de frais et deplacements'; |
|
88 | - $this->rights[2][2] = 'w'; |
|
89 | - $this->rights[2][3] = 0; |
|
90 | - $this->rights[2][4] = 'creer'; |
|
91 | - |
|
92 | - $this->rights[3][0] = 173; |
|
93 | - $this->rights[3][1] = 'Supprimer les notes de frais et deplacements'; |
|
94 | - $this->rights[3][2] = 'd'; |
|
95 | - $this->rights[3][3] = 0; |
|
96 | - $this->rights[3][4] = 'supprimer'; |
|
97 | - |
|
98 | - $this->rights[4][0] = 174; |
|
99 | - $this->rights[4][1] = 'Lire toutes les notes de frais'; |
|
100 | - $this->rights[4][2] = 'd'; |
|
101 | - $this->rights[4][3] = 0; |
|
102 | - $this->rights[4][4] = 'readall'; |
|
103 | - |
|
104 | - $this->rights[5][0] = 178; |
|
105 | - $this->rights[5][1] = 'Exporter les notes de frais et deplacements'; |
|
106 | - $this->rights[5][2] = 'd'; |
|
107 | - $this->rights[5][3] = 0; |
|
108 | - $this->rights[5][4] = 'export'; |
|
109 | - |
|
110 | - |
|
111 | - // Menus |
|
112 | - //------- |
|
113 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
114 | - |
|
115 | - |
|
116 | - // Exports |
|
117 | - $r=0; |
|
118 | - |
|
119 | - $r++; |
|
120 | - $this->export_code[$r]='trips_'.$r; |
|
121 | - $this->export_label[$r]='ListTripsAndExpenses'; |
|
122 | - $this->export_permission[$r]=array(array("deplacement","export")); |
|
35 | + /** |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | + */ |
|
40 | + function __construct($db) |
|
41 | + { |
|
42 | + global $conf, $user; |
|
43 | + |
|
44 | + $this->db = $db; |
|
45 | + $this->numero = 75 ; |
|
46 | + |
|
47 | + $this->family = "hr"; |
|
48 | + $this->module_position = '41'; |
|
49 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
50 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | + $this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee |
|
52 | + |
|
53 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
|
54 | + $this->version = 'dolibarr_deprecated'; |
|
55 | + |
|
56 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
57 | + $this->picto = "trip"; |
|
58 | + |
|
59 | + // Data directories to create when module is enabled |
|
60 | + $this->dirs = array(); |
|
61 | + |
|
62 | + // Config pages |
|
63 | + $this->config_page_url = array(); |
|
64 | + $this->langfiles = array("companies","trips"); |
|
65 | + |
|
66 | + // Dependancies |
|
67 | + $this->depends = array(); |
|
68 | + $this->requiredby = array(); |
|
69 | + |
|
70 | + // Constants |
|
71 | + $this->const = array(); |
|
72 | + |
|
73 | + // Boxes |
|
74 | + $this->boxes = array(); |
|
75 | + |
|
76 | + // Permissions |
|
77 | + $this->rights = array(); |
|
78 | + $this->rights_class = 'deplacement'; |
|
79 | + |
|
80 | + $this->rights[1][0] = 171; |
|
81 | + $this->rights[1][1] = 'Lire ses notes de frais et deplacements et celles de sa hierarchy'; |
|
82 | + $this->rights[1][2] = 'r'; |
|
83 | + $this->rights[1][3] = 1; |
|
84 | + $this->rights[1][4] = 'lire'; |
|
85 | + |
|
86 | + $this->rights[2][0] = 172; |
|
87 | + $this->rights[2][1] = 'Creer/modifier une note de frais et deplacements'; |
|
88 | + $this->rights[2][2] = 'w'; |
|
89 | + $this->rights[2][3] = 0; |
|
90 | + $this->rights[2][4] = 'creer'; |
|
91 | + |
|
92 | + $this->rights[3][0] = 173; |
|
93 | + $this->rights[3][1] = 'Supprimer les notes de frais et deplacements'; |
|
94 | + $this->rights[3][2] = 'd'; |
|
95 | + $this->rights[3][3] = 0; |
|
96 | + $this->rights[3][4] = 'supprimer'; |
|
97 | + |
|
98 | + $this->rights[4][0] = 174; |
|
99 | + $this->rights[4][1] = 'Lire toutes les notes de frais'; |
|
100 | + $this->rights[4][2] = 'd'; |
|
101 | + $this->rights[4][3] = 0; |
|
102 | + $this->rights[4][4] = 'readall'; |
|
103 | + |
|
104 | + $this->rights[5][0] = 178; |
|
105 | + $this->rights[5][1] = 'Exporter les notes de frais et deplacements'; |
|
106 | + $this->rights[5][2] = 'd'; |
|
107 | + $this->rights[5][3] = 0; |
|
108 | + $this->rights[5][4] = 'export'; |
|
109 | + |
|
110 | + |
|
111 | + // Menus |
|
112 | + //------- |
|
113 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
114 | + |
|
115 | + |
|
116 | + // Exports |
|
117 | + $r=0; |
|
118 | + |
|
119 | + $r++; |
|
120 | + $this->export_code[$r]='trips_'.$r; |
|
121 | + $this->export_label[$r]='ListTripsAndExpenses'; |
|
122 | + $this->export_permission[$r]=array(array("deplacement","export")); |
|
123 | 123 | $this->export_fields_array[$r]=array('u.login'=>'Login','u.lastname'=>'Lastname','u.firstname'=>'Firstname','d.rowid'=>"TripId",'d.type'=>"Type",'d.km'=>"FeesKilometersOrAmout",'d.dated'=>"Date",'d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','s.nom'=>'ThirdParty'); |
124 | 124 | $this->export_TypeFields_array[$r]=array('u.rowid'=>'List:user:name','u.login'=>'Text','u.lastname'=>'Text','u.firstname'=>'Text','d.type'=>"Text",'d.km'=>"Numeric",'d.dated'=>"Date",'d.note_private'=>'Text','d.note_public'=>'Text','s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text'); |
125 | 125 | $this->export_entities_array[$r]=array('u.login'=>'user','u.lastname'=>'user','u.firstname'=>'user','d.rowid'=>"trip",'d.type'=>"trip",'d.km'=>"trip",'d.dated'=>"trip",'d.note_private'=>'trip','d.note_public'=>'trip','s.nom'=>'company'); |
126 | 126 | $this->export_dependencies_array[$r]=array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
127 | 127 | |
128 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
129 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; |
|
130 | - $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; |
|
131 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; |
|
132 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
133 | - $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
134 | - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; |
|
135 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; |
|
136 | - |
|
137 | - if (! empty($user)) // Not defined during migration process |
|
138 | - { |
|
139 | - $childids = $user->getAllChildIds(); |
|
140 | - $childids[]=$user->id; |
|
141 | - |
|
142 | - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Function called when module is enabled. |
|
149 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
150 | - * It also creates data directories |
|
151 | - * |
|
128 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
129 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; |
|
130 | + $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; |
|
131 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; |
|
132 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
133 | + $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
134 | + $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; |
|
135 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; |
|
136 | + |
|
137 | + if (! empty($user)) // Not defined during migration process |
|
138 | + { |
|
139 | + $childids = $user->getAllChildIds(); |
|
140 | + $childids[]=$user->id; |
|
141 | + |
|
142 | + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Function called when module is enabled. |
|
149 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
150 | + * It also creates data directories |
|
151 | + * |
|
152 | 152 | * @param string $options Options when enabling module ('', 'noboxes') |
153 | - * @return int 1 if OK, 0 if KO |
|
154 | - */ |
|
155 | - function init($options='') |
|
156 | - { |
|
157 | - // Permissions |
|
158 | - $this->remove($options); |
|
153 | + * @return int 1 if OK, 0 if KO |
|
154 | + */ |
|
155 | + function init($options='') |
|
156 | + { |
|
157 | + // Permissions |
|
158 | + $this->remove($options); |
|
159 | 159 | |
160 | - $sql = array(); |
|
160 | + $sql = array(); |
|
161 | 161 | |
162 | - return $this->_init($sql,$options); |
|
163 | - } |
|
162 | + return $this->_init($sql,$options); |
|
163 | + } |
|
164 | 164 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup deplacement |
24 | 24 | * \brief Fichier de description et activation du module Deplacement et notes de frais |
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 | /** |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | global $conf, $user; |
43 | 43 | |
44 | 44 | $this->db = $db; |
45 | - $this->numero = 75 ; |
|
45 | + $this->numero = 75; |
|
46 | 46 | |
47 | 47 | $this->family = "hr"; |
48 | 48 | $this->module_position = '41'; |
49 | 49 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
50 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | - $this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee |
|
50 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
51 | + $this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee |
|
52 | 52 | |
53 | 53 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
54 | 54 | $this->version = 'dolibarr_deprecated'; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | // Config pages |
63 | 63 | $this->config_page_url = array(); |
64 | - $this->langfiles = array("companies","trips"); |
|
64 | + $this->langfiles = array("companies", "trips"); |
|
65 | 65 | |
66 | 66 | // Dependancies |
67 | 67 | $this->depends = array(); |
@@ -110,36 +110,36 @@ discard block |
||
110 | 110 | |
111 | 111 | // Menus |
112 | 112 | //------- |
113 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
113 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
114 | 114 | |
115 | 115 | |
116 | 116 | // Exports |
117 | - $r=0; |
|
117 | + $r = 0; |
|
118 | 118 | |
119 | 119 | $r++; |
120 | - $this->export_code[$r]='trips_'.$r; |
|
121 | - $this->export_label[$r]='ListTripsAndExpenses'; |
|
122 | - $this->export_permission[$r]=array(array("deplacement","export")); |
|
123 | - $this->export_fields_array[$r]=array('u.login'=>'Login','u.lastname'=>'Lastname','u.firstname'=>'Firstname','d.rowid'=>"TripId",'d.type'=>"Type",'d.km'=>"FeesKilometersOrAmout",'d.dated'=>"Date",'d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','s.nom'=>'ThirdParty'); |
|
124 | - $this->export_TypeFields_array[$r]=array('u.rowid'=>'List:user:name','u.login'=>'Text','u.lastname'=>'Text','u.firstname'=>'Text','d.type'=>"Text",'d.km'=>"Numeric",'d.dated'=>"Date",'d.note_private'=>'Text','d.note_public'=>'Text','s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text'); |
|
125 | - $this->export_entities_array[$r]=array('u.login'=>'user','u.lastname'=>'user','u.firstname'=>'user','d.rowid'=>"trip",'d.type'=>"trip",'d.km'=>"trip",'d.dated'=>"trip",'d.note_private'=>'trip','d.note_public'=>'trip','s.nom'=>'company'); |
|
126 | - $this->export_dependencies_array[$r]=array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
127 | - |
|
128 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
129 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; |
|
130 | - $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; |
|
131 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; |
|
132 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
133 | - $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
|
134 | - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; |
|
135 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; |
|
136 | - |
|
137 | - if (! empty($user)) // Not defined during migration process |
|
120 | + $this->export_code[$r] = 'trips_'.$r; |
|
121 | + $this->export_label[$r] = 'ListTripsAndExpenses'; |
|
122 | + $this->export_permission[$r] = array(array("deplacement", "export")); |
|
123 | + $this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty'); |
|
124 | + $this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"List:societe:CompanyName", 's.nom'=>'Text'); |
|
125 | + $this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company'); |
|
126 | + $this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
127 | + |
|
128 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
129 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u'; |
|
130 | + $this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'deplacement as d'; |
|
131 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; |
|
132 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
133 | + $this->export_sql_end[$r] .= ' WHERE d.fk_user = u.rowid'; |
|
134 | + $this->export_sql_end[$r] .= ' AND d.entity IN ('.getEntity('deplacement').')'; |
|
135 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR d.fk_soc IS NULL)'; |
|
136 | + |
|
137 | + if (!empty($user)) // Not defined during migration process |
|
138 | 138 | { |
139 | 139 | $childids = $user->getAllChildIds(); |
140 | - $childids[]=$user->id; |
|
140 | + $childids[] = $user->id; |
|
141 | 141 | |
142 | - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; |
|
142 | + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * @param string $options Options when enabling module ('', 'noboxes') |
153 | 153 | * @return int 1 if OK, 0 if KO |
154 | 154 | */ |
155 | - function init($options='') |
|
155 | + function init($options = '') |
|
156 | 156 | { |
157 | 157 | // Permissions |
158 | 158 | $this->remove($options); |
159 | 159 | |
160 | 160 | $sql = array(); |
161 | 161 | |
162 | - return $this->_init($sql,$options); |
|
162 | + return $this->_init($sql, $options); |
|
163 | 163 | } |
164 | 164 | } |
@@ -129,17 +129,25 @@ |
||
129 | 129 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; |
130 | 130 | $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; |
131 | 131 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; |
132 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
132 | + if (empty($user->rights->societe->client->voir)) { |
|
133 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
134 | + } |
|
133 | 135 | $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; |
134 | 136 | $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; |
135 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; |
|
137 | + if (empty($user->rights->societe->client->voir)) { |
|
138 | + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; |
|
139 | + } |
|
136 | 140 | |
137 | - if (! empty($user)) // Not defined during migration process |
|
141 | + if (! empty($user)) { |
|
142 | + // Not defined during migration process |
|
138 | 143 | { |
139 | 144 | $childids = $user->getAllChildIds(); |
145 | + } |
|
140 | 146 | $childids[]=$user->id; |
141 | 147 | |
142 | - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; |
|
148 | + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) { |
|
149 | + $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | } |
145 | 153 |
@@ -32,155 +32,155 @@ |
||
32 | 32 | class modOpenSurvey extends DolibarrModules |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
39 | - */ |
|
40 | - function __construct($db) |
|
41 | - { |
|
42 | - global $langs,$conf; |
|
43 | - |
|
44 | - $this->db = $db; |
|
45 | - |
|
46 | - // Id for module (must be unique). |
|
47 | - // Use here a free id (See in Home -> System information -> Dolibarr for list of used module id). |
|
48 | - $this->numero = 55000; |
|
49 | - // Key text used to identify module (for permission, menus, etc...) |
|
50 | - $this->rights_class = 'opensurvey'; |
|
51 | - |
|
52 | - // Family can be 'crm','financial','hr','projects','product','technic','other' |
|
53 | - // It is used to group modules in module setup page |
|
54 | - $this->family = "portal"; |
|
55 | - $this->module_position = '40'; |
|
56 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
57 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
58 | - // Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule) |
|
59 | - $this->description = "Module to make online surveys (like Doodle, Studs, Rdvz, ...)"; |
|
60 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
61 | - $this->version = 'dolibarr'; |
|
62 | - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
|
63 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
64 | - // Name of image file used for this module. |
|
65 | - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
66 | - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
67 | - $this->picto='opensurvey.png@opensurvey'; |
|
68 | - |
|
69 | - // Data directories to create when module is enabled |
|
70 | - $this->dirs = array(); |
|
71 | - //$this->dirs[0] = DOL_DATA_ROOT.'/mymodule; |
|
72 | - //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; |
|
73 | - |
|
74 | - // Dependencies |
|
75 | - $this->hidden = false; // A condition to hide module |
|
76 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
77 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
78 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
79 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
80 | - $this->need_dolibarr_version = array(3,4,0); // Minimum version of Dolibarr required by module |
|
81 | - |
|
82 | - // Constants |
|
83 | - $this->const = array(); // List of parameters |
|
84 | - |
|
85 | - // Dictionaries |
|
35 | + /** |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | + */ |
|
40 | + function __construct($db) |
|
41 | + { |
|
42 | + global $langs,$conf; |
|
43 | + |
|
44 | + $this->db = $db; |
|
45 | + |
|
46 | + // Id for module (must be unique). |
|
47 | + // Use here a free id (See in Home -> System information -> Dolibarr for list of used module id). |
|
48 | + $this->numero = 55000; |
|
49 | + // Key text used to identify module (for permission, menus, etc...) |
|
50 | + $this->rights_class = 'opensurvey'; |
|
51 | + |
|
52 | + // Family can be 'crm','financial','hr','projects','product','technic','other' |
|
53 | + // It is used to group modules in module setup page |
|
54 | + $this->family = "portal"; |
|
55 | + $this->module_position = '40'; |
|
56 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
57 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
58 | + // Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule) |
|
59 | + $this->description = "Module to make online surveys (like Doodle, Studs, Rdvz, ...)"; |
|
60 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
61 | + $this->version = 'dolibarr'; |
|
62 | + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
|
63 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
64 | + // Name of image file used for this module. |
|
65 | + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
66 | + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
67 | + $this->picto='opensurvey.png@opensurvey'; |
|
68 | + |
|
69 | + // Data directories to create when module is enabled |
|
70 | + $this->dirs = array(); |
|
71 | + //$this->dirs[0] = DOL_DATA_ROOT.'/mymodule; |
|
72 | + //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; |
|
73 | + |
|
74 | + // Dependencies |
|
75 | + $this->hidden = false; // A condition to hide module |
|
76 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
77 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
78 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
79 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
80 | + $this->need_dolibarr_version = array(3,4,0); // Minimum version of Dolibarr required by module |
|
81 | + |
|
82 | + // Constants |
|
83 | + $this->const = array(); // List of parameters |
|
84 | + |
|
85 | + // Dictionaries |
|
86 | 86 | $this->dictionaries=array(); |
87 | 87 | |
88 | - // Boxes |
|
89 | - $this->boxes = array(); // List of boxes |
|
90 | - $r=0; |
|
91 | - |
|
92 | - // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
|
93 | - // Example: |
|
94 | - //$this->boxes[$r][1] = "myboxa.php"; |
|
95 | - //$r++; |
|
96 | - //$this->boxes[$r][1] = "myboxb.php"; |
|
97 | - //$r++; |
|
98 | - |
|
99 | - // Permissions |
|
100 | - $this->rights = array(); // Permission array used by this module |
|
101 | - $r=0; |
|
102 | - |
|
103 | - // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
|
104 | - // Example: |
|
105 | - $this->rights[$r][0] = 55001; // Permission id (must not be already used) |
|
106 | - $this->rights[$r][1] = 'Read surveys'; // Permission label |
|
107 | - $this->rights[$r][2] = 'r'; // Permission by default for new user (0/1) |
|
108 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
109 | - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
110 | - $r++; |
|
111 | - |
|
112 | - // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
|
113 | - // Example: |
|
114 | - $this->rights[$r][0] = 55002; // Permission id (must not be already used) |
|
115 | - $this->rights[$r][1] = 'Create/modify surveys'; // Permission label |
|
116 | - $this->rights[$r][2] = 'w'; // Permission by default for new user (0/1) |
|
117 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
118 | - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
119 | - $r++; |
|
120 | - |
|
121 | - |
|
122 | - // Menus |
|
123 | - //------- |
|
88 | + // Boxes |
|
89 | + $this->boxes = array(); // List of boxes |
|
124 | 90 | $r=0; |
125 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
126 | - 'type'=>'left', |
|
127 | - 'titre'=>'Survey', |
|
128 | - 'mainmenu'=>'tools', |
|
129 | - 'leftmenu'=>'opensurvey', |
|
130 | - 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', |
|
131 | - 'langs'=>'opensurvey', |
|
132 | - 'position'=>200, |
|
133 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
134 | - 'perms'=>'$user->rights->opensurvey->read', |
|
135 | - 'target'=>'', |
|
136 | - 'user'=>0); |
|
137 | - $r++; |
|
138 | - |
|
139 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
140 | - 'type'=>'left', |
|
141 | - 'titre'=>'NewSurvey', |
|
142 | - 'mainmenu'=>'tools', |
|
143 | - 'leftmenu'=>'opensurvey_new', |
|
144 | - 'url'=>'/opensurvey/wizard/index.php', |
|
145 | - 'langs'=>'opensurvey', |
|
146 | - 'position'=>210, |
|
147 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
148 | - 'perms'=>'$user->rights->opensurvey->write', |
|
149 | - 'target'=>'', |
|
150 | - 'user'=>0); |
|
151 | - $r++; |
|
152 | - |
|
153 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
154 | - 'type'=>'left', |
|
155 | - 'titre'=>'List', |
|
156 | - 'mainmenu'=>'tools', |
|
157 | - 'leftmenu'=>'opensurvey_list', |
|
158 | - 'url'=>'/opensurvey/list.php', |
|
159 | - 'langs'=>'opensurvey', |
|
160 | - 'position'=>220, |
|
161 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
162 | - 'perms'=>'$user->rights->opensurvey->read', |
|
163 | - 'target'=>'', |
|
164 | - 'user'=>0); |
|
165 | - $r++; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Function called when module is enabled. |
|
170 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
171 | - * It also creates data directories |
|
172 | - * |
|
91 | + |
|
92 | + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
|
93 | + // Example: |
|
94 | + //$this->boxes[$r][1] = "myboxa.php"; |
|
95 | + //$r++; |
|
96 | + //$this->boxes[$r][1] = "myboxb.php"; |
|
97 | + //$r++; |
|
98 | + |
|
99 | + // Permissions |
|
100 | + $this->rights = array(); // Permission array used by this module |
|
101 | + $r=0; |
|
102 | + |
|
103 | + // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
|
104 | + // Example: |
|
105 | + $this->rights[$r][0] = 55001; // Permission id (must not be already used) |
|
106 | + $this->rights[$r][1] = 'Read surveys'; // Permission label |
|
107 | + $this->rights[$r][2] = 'r'; // Permission by default for new user (0/1) |
|
108 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
109 | + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
110 | + $r++; |
|
111 | + |
|
112 | + // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
|
113 | + // Example: |
|
114 | + $this->rights[$r][0] = 55002; // Permission id (must not be already used) |
|
115 | + $this->rights[$r][1] = 'Create/modify surveys'; // Permission label |
|
116 | + $this->rights[$r][2] = 'w'; // Permission by default for new user (0/1) |
|
117 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
118 | + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
119 | + $r++; |
|
120 | + |
|
121 | + |
|
122 | + // Menus |
|
123 | + //------- |
|
124 | + $r=0; |
|
125 | + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
126 | + 'type'=>'left', |
|
127 | + 'titre'=>'Survey', |
|
128 | + 'mainmenu'=>'tools', |
|
129 | + 'leftmenu'=>'opensurvey', |
|
130 | + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', |
|
131 | + 'langs'=>'opensurvey', |
|
132 | + 'position'=>200, |
|
133 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
134 | + 'perms'=>'$user->rights->opensurvey->read', |
|
135 | + 'target'=>'', |
|
136 | + 'user'=>0); |
|
137 | + $r++; |
|
138 | + |
|
139 | + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
140 | + 'type'=>'left', |
|
141 | + 'titre'=>'NewSurvey', |
|
142 | + 'mainmenu'=>'tools', |
|
143 | + 'leftmenu'=>'opensurvey_new', |
|
144 | + 'url'=>'/opensurvey/wizard/index.php', |
|
145 | + 'langs'=>'opensurvey', |
|
146 | + 'position'=>210, |
|
147 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
148 | + 'perms'=>'$user->rights->opensurvey->write', |
|
149 | + 'target'=>'', |
|
150 | + 'user'=>0); |
|
151 | + $r++; |
|
152 | + |
|
153 | + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
154 | + 'type'=>'left', |
|
155 | + 'titre'=>'List', |
|
156 | + 'mainmenu'=>'tools', |
|
157 | + 'leftmenu'=>'opensurvey_list', |
|
158 | + 'url'=>'/opensurvey/list.php', |
|
159 | + 'langs'=>'opensurvey', |
|
160 | + 'position'=>220, |
|
161 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
162 | + 'perms'=>'$user->rights->opensurvey->read', |
|
163 | + 'target'=>'', |
|
164 | + 'user'=>0); |
|
165 | + $r++; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Function called when module is enabled. |
|
170 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
171 | + * It also creates data directories |
|
172 | + * |
|
173 | 173 | * @param string $options Options when enabling module ('', 'noboxes') |
174 | - * @return int 1 if OK, 0 if KO |
|
175 | - */ |
|
176 | - function init($options='') |
|
177 | - { |
|
178 | - // Permissions |
|
179 | - $this->remove($options); |
|
174 | + * @return int 1 if OK, 0 if KO |
|
175 | + */ |
|
176 | + function init($options='') |
|
177 | + { |
|
178 | + // Permissions |
|
179 | + $this->remove($options); |
|
180 | 180 | |
181 | - $sql = array(); |
|
181 | + $sql = array(); |
|
182 | 182 | |
183 | - return $this->_init($sql,$options); |
|
184 | - } |
|
183 | + return $this->_init($sql,$options); |
|
184 | + } |
|
185 | 185 | } |
186 | 186 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup opensurvey |
24 | 24 | * \brief Description and activation file for module OpenSurvey |
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 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function __construct($db) |
41 | 41 | { |
42 | - global $langs,$conf; |
|
42 | + global $langs, $conf; |
|
43 | 43 | |
44 | 44 | $this->db = $db; |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->family = "portal"; |
55 | 55 | $this->module_position = '40'; |
56 | 56 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
57 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
57 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
58 | 58 | // Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule) |
59 | 59 | $this->description = "Module to make online surveys (like Doodle, Studs, Rdvz, ...)"; |
60 | 60 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // Name of image file used for this module. |
65 | 65 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
66 | 66 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
67 | - $this->picto='opensurvey.png@opensurvey'; |
|
67 | + $this->picto = 'opensurvey.png@opensurvey'; |
|
68 | 68 | |
69 | 69 | // Data directories to create when module is enabled |
70 | 70 | $this->dirs = array(); |
@@ -72,22 +72,22 @@ discard block |
||
72 | 72 | //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; |
73 | 73 | |
74 | 74 | // Dependencies |
75 | - $this->hidden = false; // A condition to hide module |
|
76 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
77 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
78 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
79 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
80 | - $this->need_dolibarr_version = array(3,4,0); // Minimum version of Dolibarr required by module |
|
75 | + $this->hidden = false; // A condition to hide module |
|
76 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
77 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
78 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
79 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
80 | + $this->need_dolibarr_version = array(3, 4, 0); // Minimum version of Dolibarr required by module |
|
81 | 81 | |
82 | 82 | // Constants |
83 | - $this->const = array(); // List of parameters |
|
83 | + $this->const = array(); // List of parameters |
|
84 | 84 | |
85 | 85 | // Dictionaries |
86 | - $this->dictionaries=array(); |
|
86 | + $this->dictionaries = array(); |
|
87 | 87 | |
88 | 88 | // Boxes |
89 | - $this->boxes = array(); // List of boxes |
|
90 | - $r=0; |
|
89 | + $this->boxes = array(); // List of boxes |
|
90 | + $r = 0; |
|
91 | 91 | |
92 | 92 | // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
93 | 93 | // Example: |
@@ -97,32 +97,32 @@ discard block |
||
97 | 97 | //$r++; |
98 | 98 | |
99 | 99 | // Permissions |
100 | - $this->rights = array(); // Permission array used by this module |
|
101 | - $r=0; |
|
100 | + $this->rights = array(); // Permission array used by this module |
|
101 | + $r = 0; |
|
102 | 102 | |
103 | 103 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
104 | 104 | // Example: |
105 | - $this->rights[$r][0] = 55001; // Permission id (must not be already used) |
|
106 | - $this->rights[$r][1] = 'Read surveys'; // Permission label |
|
107 | - $this->rights[$r][2] = 'r'; // Permission by default for new user (0/1) |
|
108 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
109 | - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
105 | + $this->rights[$r][0] = 55001; // Permission id (must not be already used) |
|
106 | + $this->rights[$r][1] = 'Read surveys'; // Permission label |
|
107 | + $this->rights[$r][2] = 'r'; // Permission by default for new user (0/1) |
|
108 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
109 | + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
110 | 110 | $r++; |
111 | 111 | |
112 | 112 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
113 | 113 | // Example: |
114 | - $this->rights[$r][0] = 55002; // Permission id (must not be already used) |
|
115 | - $this->rights[$r][1] = 'Create/modify surveys'; // Permission label |
|
116 | - $this->rights[$r][2] = 'w'; // Permission by default for new user (0/1) |
|
117 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
118 | - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
114 | + $this->rights[$r][0] = 55002; // Permission id (must not be already used) |
|
115 | + $this->rights[$r][1] = 'Create/modify surveys'; // Permission label |
|
116 | + $this->rights[$r][2] = 'w'; // Permission by default for new user (0/1) |
|
117 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
118 | + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
119 | 119 | $r++; |
120 | 120 | |
121 | 121 | |
122 | 122 | // Menus |
123 | 123 | //------- |
124 | - $r=0; |
|
125 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
124 | + $r = 0; |
|
125 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
126 | 126 | 'type'=>'left', |
127 | 127 | 'titre'=>'Survey', |
128 | 128 | 'mainmenu'=>'tools', |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', |
131 | 131 | 'langs'=>'opensurvey', |
132 | 132 | 'position'=>200, |
133 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
133 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
134 | 134 | 'perms'=>'$user->rights->opensurvey->read', |
135 | 135 | 'target'=>'', |
136 | 136 | 'user'=>0); |
137 | 137 | $r++; |
138 | 138 | |
139 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
139 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
140 | 140 | 'type'=>'left', |
141 | 141 | 'titre'=>'NewSurvey', |
142 | 142 | 'mainmenu'=>'tools', |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | 'url'=>'/opensurvey/wizard/index.php', |
145 | 145 | 'langs'=>'opensurvey', |
146 | 146 | 'position'=>210, |
147 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
147 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
148 | 148 | 'perms'=>'$user->rights->opensurvey->write', |
149 | 149 | 'target'=>'', |
150 | 150 | 'user'=>0); |
151 | 151 | $r++; |
152 | 152 | |
153 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
153 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
154 | 154 | 'type'=>'left', |
155 | 155 | 'titre'=>'List', |
156 | 156 | 'mainmenu'=>'tools', |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'url'=>'/opensurvey/list.php', |
159 | 159 | 'langs'=>'opensurvey', |
160 | 160 | 'position'=>220, |
161 | - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
161 | + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. |
|
162 | 162 | 'perms'=>'$user->rights->opensurvey->read', |
163 | 163 | 'target'=>'', |
164 | 164 | 'user'=>0); |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * @param string $options Options when enabling module ('', 'noboxes') |
174 | 174 | * @return int 1 if OK, 0 if KO |
175 | 175 | */ |
176 | - function init($options='') |
|
176 | + function init($options = '') |
|
177 | 177 | { |
178 | 178 | // Permissions |
179 | 179 | $this->remove($options); |
180 | 180 | |
181 | 181 | $sql = array(); |
182 | 182 | |
183 | - return $this->_init($sql,$options); |
|
183 | + return $this->_init($sql, $options); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -38,259 +38,259 @@ |
||
38 | 38 | class modCommande extends DolibarrModules |
39 | 39 | { |
40 | 40 | |
41 | - /** |
|
42 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
43 | - * |
|
44 | - * @param DoliDB $db Database handler |
|
45 | - */ |
|
46 | - function __construct($db) |
|
47 | - { |
|
48 | - global $conf, $user; |
|
49 | - |
|
50 | - $this->db = $db; |
|
51 | - $this->numero = 25; |
|
52 | - |
|
53 | - $this->family = "crm"; |
|
54 | - $this->module_position = '30'; |
|
55 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
56 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
57 | - $this->description = "Gestion des commandes clients"; |
|
58 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
59 | - $this->version = 'dolibarr'; |
|
60 | - |
|
61 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
62 | - $this->picto='order'; |
|
63 | - |
|
64 | - // Data directories to create when module is enabled |
|
65 | - $this->dirs = array("/commande/temp"); |
|
66 | - |
|
67 | - // Config pages |
|
68 | - $this->config_page_url = array("commande.php"); |
|
69 | - |
|
70 | - // Dependancies |
|
71 | - $this->depends = array("modSociete"); |
|
72 | - $this->requiredby = array("modExpedition"); |
|
73 | - $this->conflictwith = array(); |
|
74 | - $this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings'); |
|
75 | - |
|
76 | - // Constants |
|
77 | - $this->const = array(); |
|
78 | - $r=0; |
|
79 | - |
|
80 | - $this->const[$r][0] = "COMMANDE_ADDON_PDF"; |
|
81 | - $this->const[$r][1] = "chaine"; |
|
82 | - $this->const[$r][2] = "einstein"; |
|
83 | - $this->const[$r][3] = 'Name of PDF model of order'; |
|
84 | - $this->const[$r][4] = 0; |
|
85 | - |
|
86 | - $r++; |
|
87 | - $this->const[$r][0] = "COMMANDE_ADDON"; |
|
88 | - $this->const[$r][1] = "chaine"; |
|
89 | - $this->const[$r][2] = "mod_commande_marbre"; |
|
90 | - $this->const[$r][3] = 'Name of numbering numerotation rules of order'; |
|
91 | - $this->const[$r][4] = 0; |
|
92 | - |
|
93 | - $r++; |
|
94 | - $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH"; |
|
95 | - $this->const[$r][1] = "chaine"; |
|
96 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/orders"; |
|
97 | - $this->const[$r][3] = ""; |
|
98 | - $this->const[$r][4] = 0; |
|
99 | - |
|
100 | - /*$r++; |
|
41 | + /** |
|
42 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
43 | + * |
|
44 | + * @param DoliDB $db Database handler |
|
45 | + */ |
|
46 | + function __construct($db) |
|
47 | + { |
|
48 | + global $conf, $user; |
|
49 | + |
|
50 | + $this->db = $db; |
|
51 | + $this->numero = 25; |
|
52 | + |
|
53 | + $this->family = "crm"; |
|
54 | + $this->module_position = '30'; |
|
55 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
56 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
57 | + $this->description = "Gestion des commandes clients"; |
|
58 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
59 | + $this->version = 'dolibarr'; |
|
60 | + |
|
61 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
62 | + $this->picto='order'; |
|
63 | + |
|
64 | + // Data directories to create when module is enabled |
|
65 | + $this->dirs = array("/commande/temp"); |
|
66 | + |
|
67 | + // Config pages |
|
68 | + $this->config_page_url = array("commande.php"); |
|
69 | + |
|
70 | + // Dependancies |
|
71 | + $this->depends = array("modSociete"); |
|
72 | + $this->requiredby = array("modExpedition"); |
|
73 | + $this->conflictwith = array(); |
|
74 | + $this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings'); |
|
75 | + |
|
76 | + // Constants |
|
77 | + $this->const = array(); |
|
78 | + $r=0; |
|
79 | + |
|
80 | + $this->const[$r][0] = "COMMANDE_ADDON_PDF"; |
|
81 | + $this->const[$r][1] = "chaine"; |
|
82 | + $this->const[$r][2] = "einstein"; |
|
83 | + $this->const[$r][3] = 'Name of PDF model of order'; |
|
84 | + $this->const[$r][4] = 0; |
|
85 | + |
|
86 | + $r++; |
|
87 | + $this->const[$r][0] = "COMMANDE_ADDON"; |
|
88 | + $this->const[$r][1] = "chaine"; |
|
89 | + $this->const[$r][2] = "mod_commande_marbre"; |
|
90 | + $this->const[$r][3] = 'Name of numbering numerotation rules of order'; |
|
91 | + $this->const[$r][4] = 0; |
|
92 | + |
|
93 | + $r++; |
|
94 | + $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH"; |
|
95 | + $this->const[$r][1] = "chaine"; |
|
96 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/orders"; |
|
97 | + $this->const[$r][3] = ""; |
|
98 | + $this->const[$r][4] = 0; |
|
99 | + |
|
100 | + /*$r++; |
|
101 | 101 | $this->const[$r][0] = "COMMANDE_DRAFT_WATERMARK"; |
102 | 102 | $this->const[$r][1] = "chaine"; |
103 | 103 | $this->const[$r][2] = "__(Draft)__"; |
104 | 104 | $this->const[$r][3] = 'Watermark to show on draft orders'; |
105 | 105 | $this->const[$r][4] = 0;*/ |
106 | 106 | |
107 | - // Boxes |
|
108 | - $this->boxes = array( |
|
109 | - 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'), |
|
110 | - 2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home') |
|
111 | - ); |
|
112 | - |
|
113 | - // Permissions |
|
114 | - $this->rights = array(); |
|
115 | - $this->rights_class = 'commande'; |
|
116 | - |
|
117 | - $r=0; |
|
118 | - |
|
119 | - $r++; |
|
120 | - $this->rights[$r][0] = 81; |
|
121 | - $this->rights[$r][1] = 'Lire les commandes clients'; |
|
122 | - $this->rights[$r][2] = 'r'; |
|
123 | - $this->rights[$r][3] = 0; |
|
124 | - $this->rights[$r][4] = 'lire'; |
|
125 | - |
|
126 | - $r++; |
|
127 | - $this->rights[$r][0] = 82; |
|
128 | - $this->rights[$r][1] = 'Creer/modifier les commandes clients'; |
|
129 | - $this->rights[$r][2] = 'w'; |
|
130 | - $this->rights[$r][3] = 0; |
|
131 | - $this->rights[$r][4] = 'creer'; |
|
132 | - |
|
133 | - $r++; |
|
134 | - $this->rights[$r][0] = 84; |
|
135 | - $this->rights[$r][1] = 'Valider les commandes clients'; |
|
136 | - $this->rights[$r][2] = 'd'; |
|
137 | - $this->rights[$r][3] = 0; |
|
138 | - $this->rights[$r][4] = 'order_advance'; |
|
139 | - $this->rights[$r][5] = 'validate'; |
|
140 | - |
|
141 | - $r++; |
|
142 | - $this->rights[$r][0] = 86; |
|
143 | - $this->rights[$r][1] = 'Envoyer les commandes clients'; |
|
144 | - $this->rights[$r][2] = 'd'; |
|
145 | - $this->rights[$r][3] = 0; |
|
146 | - $this->rights[$r][4] = 'order_advance'; |
|
107 | + // Boxes |
|
108 | + $this->boxes = array( |
|
109 | + 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'), |
|
110 | + 2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home') |
|
111 | + ); |
|
112 | + |
|
113 | + // Permissions |
|
114 | + $this->rights = array(); |
|
115 | + $this->rights_class = 'commande'; |
|
116 | + |
|
117 | + $r=0; |
|
118 | + |
|
119 | + $r++; |
|
120 | + $this->rights[$r][0] = 81; |
|
121 | + $this->rights[$r][1] = 'Lire les commandes clients'; |
|
122 | + $this->rights[$r][2] = 'r'; |
|
123 | + $this->rights[$r][3] = 0; |
|
124 | + $this->rights[$r][4] = 'lire'; |
|
125 | + |
|
126 | + $r++; |
|
127 | + $this->rights[$r][0] = 82; |
|
128 | + $this->rights[$r][1] = 'Creer/modifier les commandes clients'; |
|
129 | + $this->rights[$r][2] = 'w'; |
|
130 | + $this->rights[$r][3] = 0; |
|
131 | + $this->rights[$r][4] = 'creer'; |
|
132 | + |
|
133 | + $r++; |
|
134 | + $this->rights[$r][0] = 84; |
|
135 | + $this->rights[$r][1] = 'Valider les commandes clients'; |
|
136 | + $this->rights[$r][2] = 'd'; |
|
137 | + $this->rights[$r][3] = 0; |
|
138 | + $this->rights[$r][4] = 'order_advance'; |
|
139 | + $this->rights[$r][5] = 'validate'; |
|
140 | + |
|
141 | + $r++; |
|
142 | + $this->rights[$r][0] = 86; |
|
143 | + $this->rights[$r][1] = 'Envoyer les commandes clients'; |
|
144 | + $this->rights[$r][2] = 'd'; |
|
145 | + $this->rights[$r][3] = 0; |
|
146 | + $this->rights[$r][4] = 'order_advance'; |
|
147 | 147 | $this->rights[$r][5] = 'send'; |
148 | 148 | |
149 | - $r++; |
|
150 | - $this->rights[$r][0] = 87; |
|
151 | - $this->rights[$r][1] = 'Cloturer les commandes clients'; |
|
152 | - $this->rights[$r][2] = 'd'; |
|
153 | - $this->rights[$r][3] = 0; |
|
154 | - $this->rights[$r][4] = 'cloturer'; |
|
155 | - |
|
156 | - $r++; |
|
157 | - $this->rights[$r][0] = 88; |
|
158 | - $this->rights[$r][1] = 'Annuler les commandes clients'; |
|
159 | - $this->rights[$r][2] = 'd'; |
|
160 | - $this->rights[$r][3] = 0; |
|
161 | - $this->rights[$r][4] = 'order_advance'; |
|
162 | - $this->rights[$r][5] = 'annuler'; |
|
163 | - |
|
164 | - $r++; |
|
165 | - $this->rights[$r][0] = 89; |
|
166 | - $this->rights[$r][1] = 'Supprimer les commandes clients'; |
|
167 | - $this->rights[$r][2] = 'd'; |
|
168 | - $this->rights[$r][3] = 0; |
|
169 | - $this->rights[$r][4] = 'supprimer'; |
|
170 | - |
|
171 | - $r++; |
|
172 | - $this->rights[$r][0] = 1421; |
|
173 | - $this->rights[$r][1] = 'Exporter les commandes clients et attributs'; |
|
174 | - $this->rights[$r][2] = 'r'; |
|
175 | - $this->rights[$r][3] = 0; |
|
176 | - $this->rights[$r][4] = 'commande'; |
|
177 | - $this->rights[$r][5] = 'export'; |
|
178 | - |
|
179 | - |
|
180 | - // Menus |
|
181 | - //------- |
|
182 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
183 | - |
|
184 | - |
|
185 | - // Exports |
|
186 | - //-------- |
|
187 | - $r=0; |
|
188 | - |
|
189 | - $r++; |
|
190 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
191 | - $this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
192 | - $this->export_permission[$r]=array(array("commande","commande","export")); |
|
193 | - $this->export_fields_array[$r]=array( |
|
194 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', |
|
195 | - 'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id", |
|
196 | - 'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate", |
|
197 | - 'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT", |
|
198 | - 'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
199 | - 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
200 | - 'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
201 | - 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
202 | - 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
203 | - ); |
|
204 | - //$this->export_TypeFields_array[$r]=array( |
|
205 | - // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
|
206 | - // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", |
|
207 | - // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
208 | - // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text", |
|
209 | - // 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric", |
|
210 | - // 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text' |
|
211 | - //); |
|
212 | - $this->export_TypeFields_array[$r]=array( |
|
213 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', |
|
214 | - 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date", |
|
215 | - 'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
216 | - 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text', |
|
217 | - 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric", |
|
218 | - 'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text' |
|
219 | - ); |
|
220 | - $this->export_entities_array[$r]=array( |
|
221 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', |
|
222 | - 'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order", |
|
223 | - 'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order", |
|
224 | - 'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order", |
|
225 | - 'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line", |
|
226 | - 'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line", |
|
227 | - 'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
228 | - ); |
|
229 | - $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
230 | - $keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra'; |
|
231 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
232 | - $keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2'; |
|
233 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
234 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
235 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
236 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
237 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
238 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
239 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
240 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
241 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; |
|
242 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
243 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
244 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
245 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object'; |
|
246 | - $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
247 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
248 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
249 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
250 | - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; |
|
251 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')'; |
|
252 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Function called when module is enabled. |
|
258 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
259 | - * It also creates data directories |
|
260 | - * |
|
149 | + $r++; |
|
150 | + $this->rights[$r][0] = 87; |
|
151 | + $this->rights[$r][1] = 'Cloturer les commandes clients'; |
|
152 | + $this->rights[$r][2] = 'd'; |
|
153 | + $this->rights[$r][3] = 0; |
|
154 | + $this->rights[$r][4] = 'cloturer'; |
|
155 | + |
|
156 | + $r++; |
|
157 | + $this->rights[$r][0] = 88; |
|
158 | + $this->rights[$r][1] = 'Annuler les commandes clients'; |
|
159 | + $this->rights[$r][2] = 'd'; |
|
160 | + $this->rights[$r][3] = 0; |
|
161 | + $this->rights[$r][4] = 'order_advance'; |
|
162 | + $this->rights[$r][5] = 'annuler'; |
|
163 | + |
|
164 | + $r++; |
|
165 | + $this->rights[$r][0] = 89; |
|
166 | + $this->rights[$r][1] = 'Supprimer les commandes clients'; |
|
167 | + $this->rights[$r][2] = 'd'; |
|
168 | + $this->rights[$r][3] = 0; |
|
169 | + $this->rights[$r][4] = 'supprimer'; |
|
170 | + |
|
171 | + $r++; |
|
172 | + $this->rights[$r][0] = 1421; |
|
173 | + $this->rights[$r][1] = 'Exporter les commandes clients et attributs'; |
|
174 | + $this->rights[$r][2] = 'r'; |
|
175 | + $this->rights[$r][3] = 0; |
|
176 | + $this->rights[$r][4] = 'commande'; |
|
177 | + $this->rights[$r][5] = 'export'; |
|
178 | + |
|
179 | + |
|
180 | + // Menus |
|
181 | + //------- |
|
182 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
183 | + |
|
184 | + |
|
185 | + // Exports |
|
186 | + //-------- |
|
187 | + $r=0; |
|
188 | + |
|
189 | + $r++; |
|
190 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
191 | + $this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
192 | + $this->export_permission[$r]=array(array("commande","commande","export")); |
|
193 | + $this->export_fields_array[$r]=array( |
|
194 | + 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', |
|
195 | + 'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id", |
|
196 | + 'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate", |
|
197 | + 'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT", |
|
198 | + 'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
199 | + 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
200 | + 'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
201 | + 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
202 | + 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
203 | + ); |
|
204 | + //$this->export_TypeFields_array[$r]=array( |
|
205 | + // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
|
206 | + // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", |
|
207 | + // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
208 | + // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text", |
|
209 | + // 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric", |
|
210 | + // 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text' |
|
211 | + //); |
|
212 | + $this->export_TypeFields_array[$r]=array( |
|
213 | + 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', |
|
214 | + 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date", |
|
215 | + 'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
216 | + 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text', |
|
217 | + 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric", |
|
218 | + 'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text' |
|
219 | + ); |
|
220 | + $this->export_entities_array[$r]=array( |
|
221 | + 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', |
|
222 | + 'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order", |
|
223 | + 'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order", |
|
224 | + 'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order", |
|
225 | + 'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line", |
|
226 | + 'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line", |
|
227 | + 'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
228 | + ); |
|
229 | + $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
230 | + $keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra'; |
|
231 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
232 | + $keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2'; |
|
233 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
234 | + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
235 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
236 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
237 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
238 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
239 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
240 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
241 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; |
|
242 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
243 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
244 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
245 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object'; |
|
246 | + $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
247 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
248 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
249 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
250 | + $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; |
|
251 | + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')'; |
|
252 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Function called when module is enabled. |
|
258 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
259 | + * It also creates data directories |
|
260 | + * |
|
261 | 261 | * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
262 | - * @return int 1 if OK, 0 if KO |
|
263 | - */ |
|
264 | - function init($options='') |
|
265 | - { |
|
266 | - global $conf,$langs; |
|
267 | - |
|
268 | - // Permissions |
|
269 | - $this->remove($options); |
|
270 | - |
|
271 | - //ODT template |
|
272 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; |
|
273 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; |
|
274 | - $dest=$dirodt.'/template_order.odt'; |
|
275 | - |
|
276 | - if (file_exists($src) && ! file_exists($dest)) |
|
277 | - { |
|
278 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
279 | - dol_mkdir($dirodt); |
|
280 | - $result=dol_copy($src,$dest,0,0); |
|
281 | - if ($result < 0) |
|
282 | - { |
|
283 | - $langs->load("errors"); |
|
284 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
285 | - return 0; |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - $sql = array( |
|
290 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".$conf->entity, |
|
291 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")" |
|
292 | - ); |
|
293 | - |
|
294 | - return $this->_init($sql,$options); |
|
295 | - } |
|
262 | + * @return int 1 if OK, 0 if KO |
|
263 | + */ |
|
264 | + function init($options='') |
|
265 | + { |
|
266 | + global $conf,$langs; |
|
267 | + |
|
268 | + // Permissions |
|
269 | + $this->remove($options); |
|
270 | + |
|
271 | + //ODT template |
|
272 | + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; |
|
273 | + $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; |
|
274 | + $dest=$dirodt.'/template_order.odt'; |
|
275 | + |
|
276 | + if (file_exists($src) && ! file_exists($dest)) |
|
277 | + { |
|
278 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
279 | + dol_mkdir($dirodt); |
|
280 | + $result=dol_copy($src,$dest,0,0); |
|
281 | + if ($result < 0) |
|
282 | + { |
|
283 | + $langs->load("errors"); |
|
284 | + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
285 | + return 0; |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + $sql = array( |
|
290 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".$conf->entity, |
|
291 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")" |
|
292 | + ); |
|
293 | + |
|
294 | + return $this->_init($sql,$options); |
|
295 | + } |
|
296 | 296 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * \brief Fichier de description et activation du module Commande |
30 | 30 | */ |
31 | 31 | |
32 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
32 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $this->family = "crm"; |
54 | 54 | $this->module_position = '30'; |
55 | 55 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
56 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
56 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
57 | 57 | $this->description = "Gestion des commandes clients"; |
58 | 58 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
59 | 59 | $this->version = 'dolibarr'; |
60 | 60 | |
61 | 61 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
62 | - $this->picto='order'; |
|
62 | + $this->picto = 'order'; |
|
63 | 63 | |
64 | 64 | // Data directories to create when module is enabled |
65 | 65 | $this->dirs = array("/commande/temp"); |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | $this->depends = array("modSociete"); |
72 | 72 | $this->requiredby = array("modExpedition"); |
73 | 73 | $this->conflictwith = array(); |
74 | - $this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings'); |
|
74 | + $this->langfiles = array('orders', 'bills', 'companies', 'products', 'deliveries', 'sendings'); |
|
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $this->const[$r][0] = "COMMANDE_ADDON_PDF"; |
81 | 81 | $this->const[$r][1] = "chaine"; |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | |
107 | 107 | // Boxes |
108 | 108 | $this->boxes = array( |
109 | - 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'), |
|
110 | - 2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home') |
|
109 | + 0=>array('file'=>'box_commandes.php', 'enabledbydefaulton'=>'Home'), |
|
110 | + 2=>array('file'=>'box_graph_orders_permonth.php', 'enabledbydefaulton'=>'Home') |
|
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Permissions |
114 | 114 | $this->rights = array(); |
115 | 115 | $this->rights_class = 'commande'; |
116 | 116 | |
117 | - $r=0; |
|
117 | + $r = 0; |
|
118 | 118 | |
119 | 119 | $r++; |
120 | 120 | $this->rights[$r][0] = 81; |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | |
180 | 180 | // Menus |
181 | 181 | //------- |
182 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
182 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
183 | 183 | |
184 | 184 | |
185 | 185 | // Exports |
186 | 186 | //-------- |
187 | - $r=0; |
|
187 | + $r = 0; |
|
188 | 188 | |
189 | 189 | $r++; |
190 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
191 | - $this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
192 | - $this->export_permission[$r]=array(array("commande","commande","export")); |
|
193 | - $this->export_fields_array[$r]=array( |
|
194 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', |
|
195 | - 'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id", |
|
196 | - 'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate", |
|
197 | - 'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT", |
|
198 | - 'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
199 | - 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
200 | - 'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
201 | - 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
202 | - 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
190 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
191 | + $this->export_label[$r] = 'CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
192 | + $this->export_permission[$r] = array(array("commande", "commande", "export")); |
|
193 | + $this->export_fields_array[$r] = array( |
|
194 | + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', |
|
195 | + 'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", |
|
196 | + 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate", |
|
197 | + 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT", |
|
198 | + 'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', |
|
199 | + 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', |
|
200 | + 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
201 | + 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", |
|
202 | + 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel' |
|
203 | 203 | ); |
204 | 204 | //$this->export_TypeFields_array[$r]=array( |
205 | 205 | // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
@@ -209,47 +209,47 @@ discard block |
||
209 | 209 | // 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric", |
210 | 210 | // 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text' |
211 | 211 | //); |
212 | - $this->export_TypeFields_array[$r]=array( |
|
213 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', |
|
214 | - 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date", |
|
215 | - 'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
216 | - 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text', |
|
217 | - 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric", |
|
218 | - 'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text' |
|
212 | + $this->export_TypeFields_array[$r] = array( |
|
213 | + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', |
|
214 | + 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date", |
|
215 | + 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", |
|
216 | + 'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', |
|
217 | + 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", |
|
218 | + 'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text' |
|
219 | 219 | ); |
220 | - $this->export_entities_array[$r]=array( |
|
221 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', |
|
222 | - 'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order", |
|
223 | - 'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order", |
|
224 | - 'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order", |
|
225 | - 'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line", |
|
226 | - 'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line", |
|
227 | - 'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
220 | + $this->export_entities_array[$r] = array( |
|
221 | + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', |
|
222 | + 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"order", |
|
223 | + 'c.ref'=>"order", 'c.ref_client'=>"order", 'c.fk_soc'=>"order", 'c.date_creation'=>"order", 'c.date_commande'=>"order", 'c.amount_ht'=>"order", |
|
224 | + 'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order", |
|
225 | + 'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line", |
|
226 | + 'cd.product_type'=>'order_line', 'cd.tva_tx'=>"order_line", 'cd.qty'=>"order_line", 'cd.total_ht'=>"order_line", 'cd.total_tva'=>"order_line", |
|
227 | + 'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' |
|
228 | 228 | ); |
229 | - $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
230 | - $keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra'; |
|
229 | + $this->export_dependencies_array[$r] = array('order_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
230 | + $keyforselect = 'commande'; $keyforelement = 'order'; $keyforaliasextra = 'extra'; |
|
231 | 231 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
232 | - $keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2'; |
|
232 | + $keyforselect = 'commandedet'; $keyforelement = 'order_line'; $keyforaliasextra = 'extra2'; |
|
233 | 233 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
234 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
234 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3'; |
|
235 | 235 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
236 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
237 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
238 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
239 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
240 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
241 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; |
|
242 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
243 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
244 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
245 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object'; |
|
246 | - $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
247 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
248 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
249 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
250 | - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; |
|
251 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')'; |
|
252 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); |
|
236 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
237 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
238 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
239 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
240 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
241 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande as c'; |
|
242 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
243 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
244 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
245 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object'; |
|
246 | + $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
247 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
248 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
249 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
250 | + $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; |
|
251 | + $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('commande').')'; |
|
252 | + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -261,27 +261,27 @@ discard block |
||
261 | 261 | * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
262 | 262 | * @return int 1 if OK, 0 if KO |
263 | 263 | */ |
264 | - function init($options='') |
|
264 | + function init($options = '') |
|
265 | 265 | { |
266 | - global $conf,$langs; |
|
266 | + global $conf, $langs; |
|
267 | 267 | |
268 | 268 | // Permissions |
269 | 269 | $this->remove($options); |
270 | 270 | |
271 | 271 | //ODT template |
272 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; |
|
273 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; |
|
274 | - $dest=$dirodt.'/template_order.odt'; |
|
272 | + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; |
|
273 | + $dirodt = DOL_DATA_ROOT.'/doctemplates/orders'; |
|
274 | + $dest = $dirodt.'/template_order.odt'; |
|
275 | 275 | |
276 | - if (file_exists($src) && ! file_exists($dest)) |
|
276 | + if (file_exists($src) && !file_exists($dest)) |
|
277 | 277 | { |
278 | 278 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
279 | 279 | dol_mkdir($dirodt); |
280 | - $result=dol_copy($src,$dest,0,0); |
|
280 | + $result = dol_copy($src, $dest, 0, 0); |
|
281 | 281 | if ($result < 0) |
282 | 282 | { |
283 | 283 | $langs->load("errors"); |
284 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
284 | + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
285 | 285 | return 0; |
286 | 286 | } |
287 | 287 | } |
@@ -291,6 +291,6 @@ discard block |
||
291 | 291 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")" |
292 | 292 | ); |
293 | 293 | |
294 | - return $this->_init($sql,$options); |
|
294 | + return $this->_init($sql, $options); |
|
295 | 295 | } |
296 | 296 | } |
@@ -235,7 +235,9 @@ discard block |
||
235 | 235 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
236 | 236 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
237 | 237 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
238 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
238 | + if (empty($user->rights->societe->client->voir)) { |
|
239 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
240 | + } |
|
239 | 241 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
240 | 242 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
241 | 243 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; |
@@ -249,7 +251,9 @@ discard block |
||
249 | 251 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
250 | 252 | $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; |
251 | 253 | $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')'; |
252 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); |
|
254 | + if (empty($user->rights->societe->client->voir)) { |
|
255 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); |
|
256 | + } |
|
253 | 257 | } |
254 | 258 | |
255 | 259 |
@@ -31,235 +31,235 @@ |
||
31 | 31 | */ |
32 | 32 | class modTcpdfbarcode extends ModeleBarCode |
33 | 33 | { |
34 | - /** |
|
34 | + /** |
|
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - public $is2d = false; |
|
45 | + public $is2d = false; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Return description of numbering model |
|
49 | - * |
|
50 | - * @return string Text with description |
|
51 | - */ |
|
52 | - function info() |
|
53 | - { |
|
54 | - global $langs; |
|
47 | + /** |
|
48 | + * Return description of numbering model |
|
49 | + * |
|
50 | + * @return string Text with description |
|
51 | + */ |
|
52 | + function info() |
|
53 | + { |
|
54 | + global $langs; |
|
55 | 55 | |
56 | - return 'TCPDF-barcode'; |
|
57 | - } |
|
56 | + return 'TCPDF-barcode'; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Return if a module can be used or not |
|
61 | - * |
|
62 | - * @return boolean true if module can be used |
|
63 | - */ |
|
64 | - function isEnabled() |
|
65 | - { |
|
66 | - return true; |
|
67 | - } |
|
59 | + /** |
|
60 | + * Return if a module can be used or not |
|
61 | + * |
|
62 | + * @return boolean true if module can be used |
|
63 | + */ |
|
64 | + function isEnabled() |
|
65 | + { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
71 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
72 | - * |
|
73 | - * @return boolean false si conflit, true si ok |
|
74 | - */ |
|
75 | - function canBeActivated() |
|
76 | - { |
|
77 | - global $langs; |
|
69 | + /** |
|
70 | + * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
71 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
72 | + * |
|
73 | + * @return boolean false si conflit, true si ok |
|
74 | + */ |
|
75 | + function canBeActivated() |
|
76 | + { |
|
77 | + global $langs; |
|
78 | 78 | |
79 | - return true; |
|
80 | - } |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Return true if encoding is supported |
|
84 | - * |
|
85 | - * @param string $encoding Encoding norm |
|
86 | - * @return int >0 if supported, 0 if not |
|
87 | - */ |
|
88 | - function encodingIsSupported($encoding) |
|
89 | - { |
|
90 | - $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
91 | - if (empty($tcpdfEncoding)) { |
|
92 | - return 0; |
|
93 | - } else { |
|
94 | - return 1; |
|
95 | - } |
|
96 | - } |
|
82 | + /** |
|
83 | + * Return true if encoding is supported |
|
84 | + * |
|
85 | + * @param string $encoding Encoding norm |
|
86 | + * @return int >0 if supported, 0 if not |
|
87 | + */ |
|
88 | + function encodingIsSupported($encoding) |
|
89 | + { |
|
90 | + $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
91 | + if (empty($tcpdfEncoding)) { |
|
92 | + return 0; |
|
93 | + } else { |
|
94 | + return 1; |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Return an image file on the fly (no need to write on disk) |
|
100 | - * |
|
101 | - * @param string $code Value to encode |
|
102 | - * @param string $encoding Mode of encoding |
|
103 | - * @param string $readable Code can be read |
|
104 | - * @param integer $scale Scale (not used with this engine) |
|
105 | - * @param integer $nooutputiferror No output if error (not used with this engine) |
|
106 | - * @return int <0 if KO, >0 if OK |
|
107 | - */ |
|
108 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
109 | - { |
|
110 | - global $_GET; |
|
98 | + /** |
|
99 | + * Return an image file on the fly (no need to write on disk) |
|
100 | + * |
|
101 | + * @param string $code Value to encode |
|
102 | + * @param string $encoding Mode of encoding |
|
103 | + * @param string $readable Code can be read |
|
104 | + * @param integer $scale Scale (not used with this engine) |
|
105 | + * @param integer $nooutputiferror No output if error (not used with this engine) |
|
106 | + * @return int <0 if KO, >0 if OK |
|
107 | + */ |
|
108 | + function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
109 | + { |
|
110 | + global $_GET; |
|
111 | 111 | |
112 | - $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
113 | - if (empty($tcpdfEncoding)) return -1; |
|
112 | + $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
113 | + if (empty($tcpdfEncoding)) return -1; |
|
114 | 114 | |
115 | - $color = array(0,0,0); |
|
115 | + $color = array(0,0,0); |
|
116 | 116 | |
117 | - $_GET["code"]=$code; |
|
118 | - $_GET["type"]=$encoding; |
|
119 | - $_GET["height"]=$height; |
|
120 | - $_GET["readable"]=$readable; |
|
117 | + $_GET["code"]=$code; |
|
118 | + $_GET["type"]=$encoding; |
|
119 | + $_GET["height"]=$height; |
|
120 | + $_GET["readable"]=$readable; |
|
121 | 121 | |
122 | - if ($code) { |
|
123 | - // Load the tcpdf barcode class |
|
124 | - if ($this->is2d) { |
|
125 | - $height = 3; |
|
126 | - $width = 3; |
|
127 | - require_once TCPDF_PATH.'tcpdf_barcodes_2d.php'; |
|
128 | - $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding); |
|
129 | - } else { |
|
130 | - $height = 50; |
|
131 | - $width = 1; |
|
132 | - require_once TCPDF_PATH.'tcpdf_barcodes_1d.php'; |
|
133 | - $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding); |
|
134 | - } |
|
122 | + if ($code) { |
|
123 | + // Load the tcpdf barcode class |
|
124 | + if ($this->is2d) { |
|
125 | + $height = 3; |
|
126 | + $width = 3; |
|
127 | + require_once TCPDF_PATH.'tcpdf_barcodes_2d.php'; |
|
128 | + $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding); |
|
129 | + } else { |
|
130 | + $height = 50; |
|
131 | + $width = 1; |
|
132 | + require_once TCPDF_PATH.'tcpdf_barcodes_1d.php'; |
|
133 | + $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding); |
|
134 | + } |
|
135 | 135 | |
136 | - dol_syslog("buildBarCode::TCPDF.getBarcodePNG"); |
|
137 | - $barcodeobj->getBarcodePNG($width, $height, $color); |
|
136 | + dol_syslog("buildBarCode::TCPDF.getBarcodePNG"); |
|
137 | + $barcodeobj->getBarcodePNG($width, $height, $color); |
|
138 | 138 | |
139 | - return 1; |
|
140 | - } else { |
|
141 | - return -2; |
|
142 | - } |
|
143 | - } |
|
139 | + return 1; |
|
140 | + } else { |
|
141 | + return -2; |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Save an image file on disk (with no output) |
|
147 | - * |
|
148 | - * @param string $code Value to encode |
|
149 | - * @param string $encoding Mode of encoding |
|
150 | - * @param string $readable Code can be read |
|
151 | - * @param integer $scale Scale (not used with this engine) |
|
152 | - * @param integer $nooutputiferror No output if error (not used with this engine) |
|
153 | - * @return int <0 if KO, >0 if OK |
|
154 | - */ |
|
155 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
156 | - { |
|
157 | - global $conf,$_GET; |
|
145 | + /** |
|
146 | + * Save an image file on disk (with no output) |
|
147 | + * |
|
148 | + * @param string $code Value to encode |
|
149 | + * @param string $encoding Mode of encoding |
|
150 | + * @param string $readable Code can be read |
|
151 | + * @param integer $scale Scale (not used with this engine) |
|
152 | + * @param integer $nooutputiferror No output if error (not used with this engine) |
|
153 | + * @return int <0 if KO, >0 if OK |
|
154 | + */ |
|
155 | + function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
156 | + { |
|
157 | + global $conf,$_GET; |
|
158 | 158 | |
159 | - dol_mkdir($conf->barcode->dir_temp); |
|
160 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
159 | + dol_mkdir($conf->barcode->dir_temp); |
|
160 | + $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
161 | 161 | |
162 | - $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
163 | - if (empty($tcpdfEncoding)) return -1; |
|
162 | + $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
|
163 | + if (empty($tcpdfEncoding)) return -1; |
|
164 | 164 | |
165 | - $color = array(0,0,0); |
|
165 | + $color = array(0,0,0); |
|
166 | 166 | |
167 | - $_GET["code"]=$code; |
|
168 | - $_GET["type"]=$encoding; |
|
169 | - $_GET["height"]=$height; |
|
170 | - $_GET["readable"]=$readable; |
|
167 | + $_GET["code"]=$code; |
|
168 | + $_GET["type"]=$encoding; |
|
169 | + $_GET["height"]=$height; |
|
170 | + $_GET["readable"]=$readable; |
|
171 | 171 | |
172 | - if ($code) { |
|
173 | - // Load the tcpdf barcode class |
|
174 | - if ($this->is2d) { |
|
175 | - $height = 1; |
|
176 | - $width = 1; |
|
177 | - require_once TCPDF_PATH.'tcpdf_barcodes_2d.php'; |
|
178 | - $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding); |
|
179 | - } else { |
|
180 | - $height = 50; |
|
181 | - $width = 1; |
|
182 | - require_once TCPDF_PATH.'tcpdf_barcodes_1d.php'; |
|
183 | - $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding); |
|
184 | - } |
|
172 | + if ($code) { |
|
173 | + // Load the tcpdf barcode class |
|
174 | + if ($this->is2d) { |
|
175 | + $height = 1; |
|
176 | + $width = 1; |
|
177 | + require_once TCPDF_PATH.'tcpdf_barcodes_2d.php'; |
|
178 | + $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding); |
|
179 | + } else { |
|
180 | + $height = 50; |
|
181 | + $width = 1; |
|
182 | + require_once TCPDF_PATH.'tcpdf_barcodes_1d.php'; |
|
183 | + $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding); |
|
184 | + } |
|
185 | 185 | |
186 | - dol_syslog("writeBarCode::TCPDF.getBarcodePngData"); |
|
187 | - if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) { |
|
188 | - if (function_exists('imagecreate')) { |
|
189 | - $imageData = imagecreatefromstring($imageData); |
|
190 | - } |
|
191 | - if (imagepng($imageData, $file)) { |
|
192 | - return 1; |
|
193 | - } else { |
|
194 | - return -3; |
|
195 | - } |
|
196 | - } else { |
|
197 | - return -4; |
|
198 | - } |
|
199 | - } else { |
|
200 | - return -2; |
|
201 | - } |
|
202 | - } |
|
186 | + dol_syslog("writeBarCode::TCPDF.getBarcodePngData"); |
|
187 | + if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) { |
|
188 | + if (function_exists('imagecreate')) { |
|
189 | + $imageData = imagecreatefromstring($imageData); |
|
190 | + } |
|
191 | + if (imagepng($imageData, $file)) { |
|
192 | + return 1; |
|
193 | + } else { |
|
194 | + return -3; |
|
195 | + } |
|
196 | + } else { |
|
197 | + return -4; |
|
198 | + } |
|
199 | + } else { |
|
200 | + return -2; |
|
201 | + } |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * get available output_modes for tcpdf class wth its translated description |
|
206 | - * |
|
207 | - * @param string $dolEncodingType dolibarr barcode encoding type |
|
208 | - * @return string tcpdf encoding type |
|
209 | - */ |
|
210 | - public function getTcpdfEncodingType($dolEncodingType) |
|
211 | - { |
|
212 | - $tcpdf1dEncodingTypes = array( |
|
213 | - 'C39' => 'C39', |
|
214 | - 'C39+' => 'C39+', |
|
215 | - 'C39E' => 'C39E', |
|
216 | - 'C39E+' => 'C39E+', |
|
217 | - 'S25' => 'S25', |
|
218 | - 'S25+' => 'S25+', |
|
219 | - 'I25' => 'I25', |
|
220 | - 'I25+' => 'I25+', |
|
221 | - 'C128' => 'C128', |
|
222 | - 'C128A' => 'C128A', |
|
223 | - 'C128B' => 'C128B', |
|
224 | - 'C128C' => 'C128C', |
|
225 | - 'EAN2' => 'EAN2', |
|
226 | - 'EAN5' => 'EAN5', |
|
227 | - 'EAN8' => 'EAN8', |
|
228 | - 'EAN13' => 'EAN13', |
|
229 | - 'ISBN' => 'EAN13', |
|
230 | - 'UPC' => 'UPCA', |
|
231 | - 'UPCE' => 'UPCE', |
|
232 | - 'MSI' => 'MSI', |
|
233 | - 'MSI+' => 'MSI+', |
|
234 | - 'POSTNET' => 'POSTNET', |
|
235 | - 'PLANET' => 'PLANET', |
|
236 | - 'RMS4CC' => 'RMS4CC', |
|
237 | - 'KIX' => 'KIX', |
|
238 | - 'IMB' => 'IMB', |
|
239 | - 'CODABAR' => 'CODABAR', |
|
240 | - 'CODE11' => 'CODE11', |
|
241 | - 'PHARMA' => 'PHARMA', |
|
242 | - 'PHARMA2T' => 'PHARMA2T' |
|
243 | - ); |
|
204 | + /** |
|
205 | + * get available output_modes for tcpdf class wth its translated description |
|
206 | + * |
|
207 | + * @param string $dolEncodingType dolibarr barcode encoding type |
|
208 | + * @return string tcpdf encoding type |
|
209 | + */ |
|
210 | + public function getTcpdfEncodingType($dolEncodingType) |
|
211 | + { |
|
212 | + $tcpdf1dEncodingTypes = array( |
|
213 | + 'C39' => 'C39', |
|
214 | + 'C39+' => 'C39+', |
|
215 | + 'C39E' => 'C39E', |
|
216 | + 'C39E+' => 'C39E+', |
|
217 | + 'S25' => 'S25', |
|
218 | + 'S25+' => 'S25+', |
|
219 | + 'I25' => 'I25', |
|
220 | + 'I25+' => 'I25+', |
|
221 | + 'C128' => 'C128', |
|
222 | + 'C128A' => 'C128A', |
|
223 | + 'C128B' => 'C128B', |
|
224 | + 'C128C' => 'C128C', |
|
225 | + 'EAN2' => 'EAN2', |
|
226 | + 'EAN5' => 'EAN5', |
|
227 | + 'EAN8' => 'EAN8', |
|
228 | + 'EAN13' => 'EAN13', |
|
229 | + 'ISBN' => 'EAN13', |
|
230 | + 'UPC' => 'UPCA', |
|
231 | + 'UPCE' => 'UPCE', |
|
232 | + 'MSI' => 'MSI', |
|
233 | + 'MSI+' => 'MSI+', |
|
234 | + 'POSTNET' => 'POSTNET', |
|
235 | + 'PLANET' => 'PLANET', |
|
236 | + 'RMS4CC' => 'RMS4CC', |
|
237 | + 'KIX' => 'KIX', |
|
238 | + 'IMB' => 'IMB', |
|
239 | + 'CODABAR' => 'CODABAR', |
|
240 | + 'CODE11' => 'CODE11', |
|
241 | + 'PHARMA' => 'PHARMA', |
|
242 | + 'PHARMA2T' => 'PHARMA2T' |
|
243 | + ); |
|
244 | 244 | |
245 | - $tcpdf2dEncodingTypes = array( |
|
246 | - 'DATAMATRIX' => 'DATAMATRIX', |
|
247 | - 'PDF417' => 'PDF417', |
|
248 | - 'QRCODE' => 'QRCODE,L', |
|
249 | - 'QRCODE,L' => 'QRCODE,L', |
|
250 | - 'QRCODE,M' => 'QRCODE,M', |
|
251 | - 'QRCODE,Q' => 'QRCODE,Q', |
|
252 | - 'QRCODE,H' => 'QRCODE,H' |
|
253 | - ); |
|
245 | + $tcpdf2dEncodingTypes = array( |
|
246 | + 'DATAMATRIX' => 'DATAMATRIX', |
|
247 | + 'PDF417' => 'PDF417', |
|
248 | + 'QRCODE' => 'QRCODE,L', |
|
249 | + 'QRCODE,L' => 'QRCODE,L', |
|
250 | + 'QRCODE,M' => 'QRCODE,M', |
|
251 | + 'QRCODE,Q' => 'QRCODE,Q', |
|
252 | + 'QRCODE,H' => 'QRCODE,H' |
|
253 | + ); |
|
254 | 254 | |
255 | - if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) { |
|
256 | - $this->is2d = false; |
|
257 | - return $tcpdf1dEncodingTypes[$dolEncodingType]; |
|
258 | - } else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) { |
|
259 | - $this->is2d = true; |
|
260 | - return $tcpdf2dEncodingTypes[$dolEncodingType]; |
|
261 | - } else { |
|
262 | - return ''; |
|
263 | - } |
|
264 | - } |
|
255 | + if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) { |
|
256 | + $this->is2d = false; |
|
257 | + return $tcpdf1dEncodingTypes[$dolEncodingType]; |
|
258 | + } else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) { |
|
259 | + $this->is2d = true; |
|
260 | + return $tcpdf2dEncodingTypes[$dolEncodingType]; |
|
261 | + } else { |
|
262 | + return ''; |
|
263 | + } |
|
264 | + } |
|
265 | 265 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; |
27 | -require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Class to generate barcode images using tcpdf barcode generator |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | public $is2d = false; |
46 | 46 | |
@@ -105,19 +105,19 @@ discard block |
||
105 | 105 | * @param integer $nooutputiferror No output if error (not used with this engine) |
106 | 106 | * @return int <0 if KO, >0 if OK |
107 | 107 | */ |
108 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
108 | + function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
109 | 109 | { |
110 | 110 | global $_GET; |
111 | 111 | |
112 | 112 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
113 | 113 | if (empty($tcpdfEncoding)) return -1; |
114 | 114 | |
115 | - $color = array(0,0,0); |
|
115 | + $color = array(0, 0, 0); |
|
116 | 116 | |
117 | - $_GET["code"]=$code; |
|
118 | - $_GET["type"]=$encoding; |
|
119 | - $_GET["height"]=$height; |
|
120 | - $_GET["readable"]=$readable; |
|
117 | + $_GET["code"] = $code; |
|
118 | + $_GET["type"] = $encoding; |
|
119 | + $_GET["height"] = $height; |
|
120 | + $_GET["readable"] = $readable; |
|
121 | 121 | |
122 | 122 | if ($code) { |
123 | 123 | // Load the tcpdf barcode class |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | * @param integer $nooutputiferror No output if error (not used with this engine) |
153 | 153 | * @return int <0 if KO, >0 if OK |
154 | 154 | */ |
155 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
155 | + function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
156 | 156 | { |
157 | - global $conf,$_GET; |
|
157 | + global $conf, $_GET; |
|
158 | 158 | |
159 | 159 | dol_mkdir($conf->barcode->dir_temp); |
160 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
160 | + $file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
161 | 161 | |
162 | 162 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
163 | 163 | if (empty($tcpdfEncoding)) return -1; |
164 | 164 | |
165 | - $color = array(0,0,0); |
|
165 | + $color = array(0, 0, 0); |
|
166 | 166 | |
167 | - $_GET["code"]=$code; |
|
168 | - $_GET["type"]=$encoding; |
|
169 | - $_GET["height"]=$height; |
|
170 | - $_GET["readable"]=$readable; |
|
167 | + $_GET["code"] = $code; |
|
168 | + $_GET["type"] = $encoding; |
|
169 | + $_GET["height"] = $height; |
|
170 | + $_GET["readable"] = $readable; |
|
171 | 171 | |
172 | 172 | if ($code) { |
173 | 173 | // Load the tcpdf barcode class |
@@ -110,7 +110,9 @@ discard block |
||
110 | 110 | global $_GET; |
111 | 111 | |
112 | 112 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
113 | - if (empty($tcpdfEncoding)) return -1; |
|
113 | + if (empty($tcpdfEncoding)) { |
|
114 | + return -1; |
|
115 | + } |
|
114 | 116 | |
115 | 117 | $color = array(0,0,0); |
116 | 118 | |
@@ -160,7 +162,9 @@ discard block |
||
160 | 162 | $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
161 | 163 | |
162 | 164 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
163 | - if (empty($tcpdfEncoding)) return -1; |
|
165 | + if (empty($tcpdfEncoding)) { |
|
166 | + return -1; |
|
167 | + } |
|
164 | 168 | |
165 | 169 | $color = array(0,0,0); |
166 | 170 |
@@ -32,147 +32,147 @@ |
||
32 | 32 | */ |
33 | 33 | class modPhpbarcode extends ModeleBarCode |
34 | 34 | { |
35 | - /** |
|
35 | + /** |
|
36 | 36 | * Dolibarr version of the loaded document |
37 | 37 | * @public string |
38 | 38 | */ |
39 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string Error code (or message) |
|
43 | - */ |
|
44 | - public $error=''; |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Return if a module can be used or not |
|
49 | - * |
|
50 | - * @return boolean true if module can be used |
|
51 | - */ |
|
52 | - function isEnabled() |
|
53 | - { |
|
54 | - return true; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Return description |
|
60 | - * |
|
61 | - * @return string Texte descripif |
|
62 | - */ |
|
63 | - function info() |
|
64 | - { |
|
65 | - global $langs; |
|
66 | - |
|
67 | - $key = 'BarcodeInternalEngine'; |
|
68 | - $trans = $langs->trans('BarcodeInternalEngine'); |
|
69 | - |
|
70 | - return ($trans != $key) ? $trans : 'Internal engine'; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
75 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
76 | - * |
|
77 | - * @return boolean false si conflit, true si ok |
|
78 | - */ |
|
79 | - function canBeActivated() |
|
80 | - { |
|
81 | - global $langs; |
|
82 | - |
|
83 | - return true; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Return true if encoding is supported |
|
89 | - * |
|
90 | - * @param string $encoding Encoding norm |
|
91 | - * @return int >0 if supported, 0 if not |
|
92 | - */ |
|
93 | - function encodingIsSupported($encoding) |
|
94 | - { |
|
95 | - global $genbarcode_loc; |
|
39 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string Error code (or message) |
|
43 | + */ |
|
44 | + public $error=''; |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Return if a module can be used or not |
|
49 | + * |
|
50 | + * @return boolean true if module can be used |
|
51 | + */ |
|
52 | + function isEnabled() |
|
53 | + { |
|
54 | + return true; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Return description |
|
60 | + * |
|
61 | + * @return string Texte descripif |
|
62 | + */ |
|
63 | + function info() |
|
64 | + { |
|
65 | + global $langs; |
|
66 | + |
|
67 | + $key = 'BarcodeInternalEngine'; |
|
68 | + $trans = $langs->trans('BarcodeInternalEngine'); |
|
69 | + |
|
70 | + return ($trans != $key) ? $trans : 'Internal engine'; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
75 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
76 | + * |
|
77 | + * @return boolean false si conflit, true si ok |
|
78 | + */ |
|
79 | + function canBeActivated() |
|
80 | + { |
|
81 | + global $langs; |
|
82 | + |
|
83 | + return true; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Return true if encoding is supported |
|
89 | + * |
|
90 | + * @param string $encoding Encoding norm |
|
91 | + * @return int >0 if supported, 0 if not |
|
92 | + */ |
|
93 | + function encodingIsSupported($encoding) |
|
94 | + { |
|
95 | + global $genbarcode_loc; |
|
96 | 96 | //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; |
97 | 97 | |
98 | - $supported=0; |
|
99 | - if ($encoding == 'EAN13') $supported=1; |
|
100 | - if ($encoding == 'ISBN') $supported=1; |
|
101 | - // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not |
|
102 | - // activated on Windows) |
|
103 | - if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) |
|
104 | - { |
|
105 | - if ($encoding == 'EAN8') $supported=1; |
|
106 | - if ($encoding == 'UPC') $supported=1; |
|
107 | - if ($encoding == 'C39') $supported=1; |
|
108 | - if ($encoding == 'C128') $supported=1; |
|
109 | - } |
|
110 | - return $supported; |
|
111 | - } |
|
98 | + $supported=0; |
|
99 | + if ($encoding == 'EAN13') $supported=1; |
|
100 | + if ($encoding == 'ISBN') $supported=1; |
|
101 | + // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not |
|
102 | + // activated on Windows) |
|
103 | + if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) |
|
104 | + { |
|
105 | + if ($encoding == 'EAN8') $supported=1; |
|
106 | + if ($encoding == 'UPC') $supported=1; |
|
107 | + if ($encoding == 'C39') $supported=1; |
|
108 | + if ($encoding == 'C128') $supported=1; |
|
109 | + } |
|
110 | + return $supported; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | /** |
114 | - * Return an image file on the fly (no need to write on disk) |
|
115 | - * |
|
116 | - * @param string $code Value to encode |
|
117 | - * @param string $encoding Mode of encoding |
|
118 | - * @param string $readable Code can be read |
|
119 | - * @param integer $scale Scale |
|
120 | - * @param integer $nooutputiferror No output if error |
|
121 | - * @return int <0 if KO, >0 if OK |
|
114 | + * Return an image file on the fly (no need to write on disk) |
|
115 | + * |
|
116 | + * @param string $code Value to encode |
|
117 | + * @param string $encoding Mode of encoding |
|
118 | + * @param string $readable Code can be read |
|
119 | + * @param integer $scale Scale |
|
120 | + * @param integer $nooutputiferror No output if error |
|
121 | + * @return int <0 if KO, >0 if OK |
|
122 | 122 | */ |
123 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
124 | - { |
|
125 | - global $_GET,$_SERVER; |
|
126 | - global $conf; |
|
127 | - global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; |
|
123 | + function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
124 | + { |
|
125 | + global $_GET,$_SERVER; |
|
126 | + global $conf; |
|
127 | + global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; |
|
128 | 128 | |
129 | - if (! $this->encodingIsSupported($encoding)) return -1; |
|
129 | + if (! $this->encodingIsSupported($encoding)) return -1; |
|
130 | 130 | |
131 | - if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; |
|
132 | - if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); |
|
131 | + if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; |
|
132 | + if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); |
|
133 | 133 | |
134 | - $mode='png'; |
|
134 | + $mode='png'; |
|
135 | 135 | |
136 | - $_GET["code"]=$code; |
|
137 | - $_GET["encoding"]=$encoding; |
|
138 | - $_GET["scale"]=$scale; |
|
139 | - $_GET["mode"]=$mode; |
|
136 | + $_GET["code"]=$code; |
|
137 | + $_GET["encoding"]=$encoding; |
|
138 | + $_GET["scale"]=$scale; |
|
139 | + $_GET["mode"]=$mode; |
|
140 | 140 | |
141 | - dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); |
|
142 | - if ($code) $result=barcode_print($code,$encoding,$scale,$mode); |
|
141 | + dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); |
|
142 | + if ($code) $result=barcode_print($code,$encoding,$scale,$mode); |
|
143 | 143 | |
144 | - if (! is_array($result)) |
|
145 | - { |
|
146 | - $this->error=$result; |
|
147 | - if (empty($nooutputiferror)) print $this->error; |
|
148 | - return -1; |
|
149 | - } |
|
144 | + if (! is_array($result)) |
|
145 | + { |
|
146 | + $this->error=$result; |
|
147 | + if (empty($nooutputiferror)) print $this->error; |
|
148 | + return -1; |
|
149 | + } |
|
150 | 150 | |
151 | - return 1; |
|
152 | - } |
|
151 | + return 1; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Save an image file on disk (with no output) |
|
156 | - * |
|
157 | - * @param string $code Value to encode |
|
158 | - * @param string $encoding Mode of encoding |
|
159 | - * @param string $readable Code can be read |
|
160 | - * @param integer $scale Scale |
|
161 | - * @param integer $nooutputiferror No output if error |
|
162 | - * @return int <0 if KO, >0 if OK |
|
163 | - */ |
|
164 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
165 | - { |
|
166 | - global $conf,$filebarcode; |
|
154 | + /** |
|
155 | + * Save an image file on disk (with no output) |
|
156 | + * |
|
157 | + * @param string $code Value to encode |
|
158 | + * @param string $encoding Mode of encoding |
|
159 | + * @param string $readable Code can be read |
|
160 | + * @param integer $scale Scale |
|
161 | + * @param integer $nooutputiferror No output if error |
|
162 | + * @return int <0 if KO, >0 if OK |
|
163 | + */ |
|
164 | + function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
165 | + { |
|
166 | + global $conf,$filebarcode; |
|
167 | 167 | |
168 | - dol_mkdir($conf->barcode->dir_temp); |
|
168 | + dol_mkdir($conf->barcode->dir_temp); |
|
169 | 169 | |
170 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
170 | + $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
171 | 171 | |
172 | - $filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
172 | + $filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
173 | 173 | |
174 | - $result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror); |
|
174 | + $result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror); |
|
175 | 175 | |
176 | - return $result; |
|
177 | - } |
|
176 | + return $result; |
|
177 | + } |
|
178 | 178 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; |
27 | -require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | * Dolibarr version of the loaded document |
37 | 37 | * @public string |
38 | 38 | */ |
39 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string Error code (or message) |
43 | 43 | */ |
44 | - public $error=''; |
|
44 | + public $error = ''; |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /** |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | global $genbarcode_loc; |
96 | 96 | //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; |
97 | 97 | |
98 | - $supported=0; |
|
99 | - if ($encoding == 'EAN13') $supported=1; |
|
100 | - if ($encoding == 'ISBN') $supported=1; |
|
98 | + $supported = 0; |
|
99 | + if ($encoding == 'EAN13') $supported = 1; |
|
100 | + if ($encoding == 'ISBN') $supported = 1; |
|
101 | 101 | // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not |
102 | 102 | // activated on Windows) |
103 | 103 | if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) |
104 | 104 | { |
105 | - if ($encoding == 'EAN8') $supported=1; |
|
106 | - if ($encoding == 'UPC') $supported=1; |
|
107 | - if ($encoding == 'C39') $supported=1; |
|
108 | - if ($encoding == 'C128') $supported=1; |
|
105 | + if ($encoding == 'EAN8') $supported = 1; |
|
106 | + if ($encoding == 'UPC') $supported = 1; |
|
107 | + if ($encoding == 'C39') $supported = 1; |
|
108 | + if ($encoding == 'C128') $supported = 1; |
|
109 | 109 | } |
110 | 110 | return $supported; |
111 | 111 | } |
@@ -120,30 +120,30 @@ discard block |
||
120 | 120 | * @param integer $nooutputiferror No output if error |
121 | 121 | * @return int <0 if KO, >0 if OK |
122 | 122 | */ |
123 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
123 | + function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
124 | 124 | { |
125 | - global $_GET,$_SERVER; |
|
125 | + global $_GET, $_SERVER; |
|
126 | 126 | global $conf; |
127 | 127 | global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; |
128 | 128 | |
129 | - if (! $this->encodingIsSupported($encoding)) return -1; |
|
129 | + if (!$this->encodingIsSupported($encoding)) return -1; |
|
130 | 130 | |
131 | 131 | if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; |
132 | - if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); |
|
132 | + if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding, 1); |
|
133 | 133 | |
134 | - $mode='png'; |
|
134 | + $mode = 'png'; |
|
135 | 135 | |
136 | - $_GET["code"]=$code; |
|
137 | - $_GET["encoding"]=$encoding; |
|
138 | - $_GET["scale"]=$scale; |
|
139 | - $_GET["mode"]=$mode; |
|
136 | + $_GET["code"] = $code; |
|
137 | + $_GET["encoding"] = $encoding; |
|
138 | + $_GET["scale"] = $scale; |
|
139 | + $_GET["mode"] = $mode; |
|
140 | 140 | |
141 | 141 | dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); |
142 | - if ($code) $result=barcode_print($code,$encoding,$scale,$mode); |
|
142 | + if ($code) $result = barcode_print($code, $encoding, $scale, $mode); |
|
143 | 143 | |
144 | - if (! is_array($result)) |
|
144 | + if (!is_array($result)) |
|
145 | 145 | { |
146 | - $this->error=$result; |
|
146 | + $this->error = $result; |
|
147 | 147 | if (empty($nooutputiferror)) print $this->error; |
148 | 148 | return -1; |
149 | 149 | } |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * @param integer $nooutputiferror No output if error |
162 | 162 | * @return int <0 if KO, >0 if OK |
163 | 163 | */ |
164 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
164 | + function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
165 | 165 | { |
166 | - global $conf,$filebarcode; |
|
166 | + global $conf, $filebarcode; |
|
167 | 167 | |
168 | 168 | dol_mkdir($conf->barcode->dir_temp); |
169 | 169 | |
170 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
170 | + $file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
171 | 171 | |
172 | - $filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
172 | + $filebarcode = $file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
173 | 173 | |
174 | - $result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror); |
|
174 | + $result = $this->buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror); |
|
175 | 175 | |
176 | 176 | return $result; |
177 | 177 | } |
@@ -96,16 +96,28 @@ discard block |
||
96 | 96 | //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; |
97 | 97 | |
98 | 98 | $supported=0; |
99 | - if ($encoding == 'EAN13') $supported=1; |
|
100 | - if ($encoding == 'ISBN') $supported=1; |
|
99 | + if ($encoding == 'EAN13') { |
|
100 | + $supported=1; |
|
101 | + } |
|
102 | + if ($encoding == 'ISBN') { |
|
103 | + $supported=1; |
|
104 | + } |
|
101 | 105 | // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not |
102 | 106 | // activated on Windows) |
103 | 107 | if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) |
104 | 108 | { |
105 | - if ($encoding == 'EAN8') $supported=1; |
|
106 | - if ($encoding == 'UPC') $supported=1; |
|
107 | - if ($encoding == 'C39') $supported=1; |
|
108 | - if ($encoding == 'C128') $supported=1; |
|
109 | + if ($encoding == 'EAN8') { |
|
110 | + $supported=1; |
|
111 | + } |
|
112 | + if ($encoding == 'UPC') { |
|
113 | + $supported=1; |
|
114 | + } |
|
115 | + if ($encoding == 'C39') { |
|
116 | + $supported=1; |
|
117 | + } |
|
118 | + if ($encoding == 'C128') { |
|
119 | + $supported=1; |
|
120 | + } |
|
109 | 121 | } |
110 | 122 | return $supported; |
111 | 123 | } |
@@ -126,10 +138,16 @@ discard block |
||
126 | 138 | global $conf; |
127 | 139 | global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; |
128 | 140 | |
129 | - if (! $this->encodingIsSupported($encoding)) return -1; |
|
141 | + if (! $this->encodingIsSupported($encoding)) { |
|
142 | + return -1; |
|
143 | + } |
|
130 | 144 | |
131 | - if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; |
|
132 | - if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); |
|
145 | + if ($encoding == 'EAN8' || $encoding == 'EAN13') { |
|
146 | + $encoding = 'EAN'; |
|
147 | + } |
|
148 | + if ($encoding == 'C39' || $encoding == 'C128') { |
|
149 | + $encoding = substr($encoding,1); |
|
150 | + } |
|
133 | 151 | |
134 | 152 | $mode='png'; |
135 | 153 | |
@@ -139,12 +157,16 @@ discard block |
||
139 | 157 | $_GET["mode"]=$mode; |
140 | 158 | |
141 | 159 | dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); |
142 | - if ($code) $result=barcode_print($code,$encoding,$scale,$mode); |
|
160 | + if ($code) { |
|
161 | + $result=barcode_print($code,$encoding,$scale,$mode); |
|
162 | + } |
|
143 | 163 | |
144 | 164 | if (! is_array($result)) |
145 | 165 | { |
146 | 166 | $this->error=$result; |
147 | - if (empty($nooutputiferror)) print $this->error; |
|
167 | + if (empty($nooutputiferror)) { |
|
168 | + print $this->error; |
|
169 | + } |
|
148 | 170 | return -1; |
149 | 171 | } |
150 | 172 |
@@ -33,286 +33,286 @@ |
||
33 | 33 | */ |
34 | 34 | class mod_barcode_product_standard extends ModeleNumRefBarCode |
35 | 35 | { |
36 | - public $name='Standard'; // Model Name |
|
36 | + public $name='Standard'; // Model Name |
|
37 | 37 | |
38 | - public $code_modifiable; // Editable code |
|
38 | + public $code_modifiable; // Editable code |
|
39 | 39 | |
40 | - public $code_modifiable_invalide; // Modified code if it is invalid |
|
40 | + public $code_modifiable_invalide; // Modified code if it is invalid |
|
41 | 41 | |
42 | - public $code_modifiable_null; // Modified code if it is null |
|
42 | + public $code_modifiable_null; // Modified code if it is null |
|
43 | 43 | |
44 | - public $code_null; // Optional code |
|
44 | + public $code_null; // Optional code |
|
45 | 45 | |
46 | - /** |
|
46 | + /** |
|
47 | 47 | * Dolibarr version of the loaded document |
48 | 48 | * @public string |
49 | 49 | */ |
50 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
51 | - |
|
52 | - public $code_auto; // Automatic Numbering |
|
53 | - |
|
54 | - public $searchcode; // Search string |
|
55 | - |
|
56 | - public $numbitcounter; // Number of digits the counter |
|
57 | - |
|
58 | - public $prefixIsRequired; // The prefix field of third party must be filled when using {pre} |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Constructor |
|
63 | - */ |
|
64 | - function __construct() |
|
65 | - { |
|
66 | - $this->code_null = 0; |
|
67 | - $this->code_modifiable = 1; |
|
68 | - $this->code_modifiable_invalide = 1; |
|
69 | - $this->code_modifiable_null = 1; |
|
70 | - $this->code_auto = 1; |
|
71 | - $this->prefixIsRequired = 0; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** Return description of module |
|
76 | - * |
|
77 | - * @param Translate $langs Object langs |
|
78 | - * @return string Description of module |
|
79 | - */ |
|
80 | - function info($langs) |
|
81 | - { |
|
82 | - global $conf, $mc; |
|
83 | - global $form; |
|
84 | - |
|
85 | - $langs->load("products"); |
|
86 | - |
|
87 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
88 | - |
|
89 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
90 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | - $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
95 | - |
|
96 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode")); |
|
97 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
98 | - $tooltip.=$langs->trans("GenericMaskCodes4c"); |
|
99 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
100 | - |
|
101 | - // Mask parameter |
|
102 | - //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; |
|
103 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
105 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | - $texte.= '</tr>'; |
|
107 | - |
|
108 | - $texte.= '</table>'; |
|
109 | - $texte.= '</form>'; |
|
110 | - |
|
111 | - return $texte; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Return an example of result returned by getNextValue |
|
117 | - * |
|
118 | - * @param Translate $langs Object langs |
|
119 | - * @param Product $objproduct Object product |
|
120 | - * @return string Return string example |
|
121 | - */ |
|
122 | - function getExample($langs,$objproduct=0) |
|
123 | - { |
|
124 | - $examplebarcode = $this->getNextValue($objproduct,''); |
|
125 | - if (! $examplebarcode) |
|
126 | - { |
|
127 | - $examplebarcode = $langs->trans('NotConfigured'); |
|
128 | - } |
|
129 | - if($examplebarcode=="ErrorBadMask") |
|
130 | - { |
|
131 | - $langs->load("errors"); |
|
132 | - $examplebarcode=$langs->trans($examplebarcode); |
|
133 | - } |
|
134 | - |
|
135 | - return $examplebarcode; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Return next value |
|
140 | - * |
|
141 | - * @param Product $objproduct Object product |
|
142 | - * @param string $type Type of barcode (EAN, ISBN, ...) |
|
143 | - * @return string Value if OK, '' if module not configured, <0 if KO |
|
144 | - */ |
|
145 | - function getNextValue($objproduct=null,$type='') |
|
146 | - { |
|
147 | - global $db,$conf; |
|
148 | - |
|
149 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
150 | - |
|
151 | - // TODO |
|
152 | - |
|
153 | - // Get Mask value |
|
154 | - $mask = ''; |
|
155 | - if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
156 | - |
|
157 | - if (empty($mask)) |
|
158 | - { |
|
159 | - $this->error='NotConfigured'; |
|
160 | - return ''; |
|
161 | - } |
|
162 | - |
|
163 | - $field='barcode';$where=''; |
|
164 | - |
|
165 | - $now=dol_now(); |
|
166 | - |
|
167 | - $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now); |
|
168 | - |
|
169 | - return $numFinal; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * Check validity of code according to its rules |
|
175 | - * |
|
176 | - * @param DoliDB $db Database handler |
|
177 | - * @param string $code Code to check/correct |
|
178 | - * @param Product $product Object product |
|
179 | - * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier |
|
180 | - * @param string $type type of barcode (EAN, ISBN, ...) |
|
181 | - * @return int 0 if OK |
|
182 | - * -1 ErrorBadCustomerCodeSyntax |
|
183 | - * -2 ErrorCustomerCodeRequired |
|
184 | - * -3 ErrorCustomerCodeAlreadyUsed |
|
185 | - * -4 ErrorPrefixRequired |
|
186 | - */ |
|
187 | - function verif($db, &$code, $product, $thirdparty_type, $type) |
|
188 | - { |
|
189 | - global $conf; |
|
190 | - |
|
191 | - //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; |
|
192 | - |
|
193 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
194 | - |
|
195 | - $result=0; |
|
196 | - $code = strtoupper(trim($code)); |
|
197 | - |
|
198 | - if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) |
|
199 | - { |
|
200 | - $result=0; |
|
201 | - } |
|
202 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
203 | - { |
|
204 | - $result=-2; |
|
205 | - } |
|
206 | - else |
|
207 | - { |
|
208 | - if ($this->verif_syntax($code, $type) >= 0) |
|
209 | - { |
|
210 | - $is_dispo = $this->verif_dispo($db, $code, $product); |
|
211 | - if ($is_dispo <> 0) |
|
212 | - { |
|
213 | - $result=-3; |
|
214 | - } |
|
215 | - else |
|
216 | - { |
|
217 | - $result=0; |
|
218 | - } |
|
219 | - } |
|
220 | - else |
|
221 | - { |
|
222 | - if (dol_strlen($code) == 0) |
|
223 | - { |
|
224 | - $result=-2; |
|
225 | - } |
|
226 | - else |
|
227 | - { |
|
228 | - $result=-1; |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result); |
|
234 | - return $result; |
|
235 | - } |
|
50 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
51 | + |
|
52 | + public $code_auto; // Automatic Numbering |
|
53 | + |
|
54 | + public $searchcode; // Search string |
|
55 | + |
|
56 | + public $numbitcounter; // Number of digits the counter |
|
57 | + |
|
58 | + public $prefixIsRequired; // The prefix field of third party must be filled when using {pre} |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Constructor |
|
63 | + */ |
|
64 | + function __construct() |
|
65 | + { |
|
66 | + $this->code_null = 0; |
|
67 | + $this->code_modifiable = 1; |
|
68 | + $this->code_modifiable_invalide = 1; |
|
69 | + $this->code_modifiable_null = 1; |
|
70 | + $this->code_auto = 1; |
|
71 | + $this->prefixIsRequired = 0; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** Return description of module |
|
76 | + * |
|
77 | + * @param Translate $langs Object langs |
|
78 | + * @return string Description of module |
|
79 | + */ |
|
80 | + function info($langs) |
|
81 | + { |
|
82 | + global $conf, $mc; |
|
83 | + global $form; |
|
84 | + |
|
85 | + $langs->load("products"); |
|
86 | + |
|
87 | + $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
88 | + |
|
89 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
90 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | + $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
95 | + |
|
96 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode")); |
|
97 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
98 | + $tooltip.=$langs->trans("GenericMaskCodes4c"); |
|
99 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
100 | + |
|
101 | + // Mask parameter |
|
102 | + //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; |
|
103 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
105 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | + $texte.= '</tr>'; |
|
107 | + |
|
108 | + $texte.= '</table>'; |
|
109 | + $texte.= '</form>'; |
|
110 | + |
|
111 | + return $texte; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Return an example of result returned by getNextValue |
|
117 | + * |
|
118 | + * @param Translate $langs Object langs |
|
119 | + * @param Product $objproduct Object product |
|
120 | + * @return string Return string example |
|
121 | + */ |
|
122 | + function getExample($langs,$objproduct=0) |
|
123 | + { |
|
124 | + $examplebarcode = $this->getNextValue($objproduct,''); |
|
125 | + if (! $examplebarcode) |
|
126 | + { |
|
127 | + $examplebarcode = $langs->trans('NotConfigured'); |
|
128 | + } |
|
129 | + if($examplebarcode=="ErrorBadMask") |
|
130 | + { |
|
131 | + $langs->load("errors"); |
|
132 | + $examplebarcode=$langs->trans($examplebarcode); |
|
133 | + } |
|
134 | + |
|
135 | + return $examplebarcode; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Return next value |
|
140 | + * |
|
141 | + * @param Product $objproduct Object product |
|
142 | + * @param string $type Type of barcode (EAN, ISBN, ...) |
|
143 | + * @return string Value if OK, '' if module not configured, <0 if KO |
|
144 | + */ |
|
145 | + function getNextValue($objproduct=null,$type='') |
|
146 | + { |
|
147 | + global $db,$conf; |
|
148 | + |
|
149 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
150 | + |
|
151 | + // TODO |
|
152 | + |
|
153 | + // Get Mask value |
|
154 | + $mask = ''; |
|
155 | + if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
156 | + |
|
157 | + if (empty($mask)) |
|
158 | + { |
|
159 | + $this->error='NotConfigured'; |
|
160 | + return ''; |
|
161 | + } |
|
162 | + |
|
163 | + $field='barcode';$where=''; |
|
164 | + |
|
165 | + $now=dol_now(); |
|
166 | + |
|
167 | + $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now); |
|
168 | + |
|
169 | + return $numFinal; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * Check validity of code according to its rules |
|
175 | + * |
|
176 | + * @param DoliDB $db Database handler |
|
177 | + * @param string $code Code to check/correct |
|
178 | + * @param Product $product Object product |
|
179 | + * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier |
|
180 | + * @param string $type type of barcode (EAN, ISBN, ...) |
|
181 | + * @return int 0 if OK |
|
182 | + * -1 ErrorBadCustomerCodeSyntax |
|
183 | + * -2 ErrorCustomerCodeRequired |
|
184 | + * -3 ErrorCustomerCodeAlreadyUsed |
|
185 | + * -4 ErrorPrefixRequired |
|
186 | + */ |
|
187 | + function verif($db, &$code, $product, $thirdparty_type, $type) |
|
188 | + { |
|
189 | + global $conf; |
|
190 | + |
|
191 | + //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; |
|
192 | + |
|
193 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
194 | + |
|
195 | + $result=0; |
|
196 | + $code = strtoupper(trim($code)); |
|
197 | + |
|
198 | + if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) |
|
199 | + { |
|
200 | + $result=0; |
|
201 | + } |
|
202 | + else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
203 | + { |
|
204 | + $result=-2; |
|
205 | + } |
|
206 | + else |
|
207 | + { |
|
208 | + if ($this->verif_syntax($code, $type) >= 0) |
|
209 | + { |
|
210 | + $is_dispo = $this->verif_dispo($db, $code, $product); |
|
211 | + if ($is_dispo <> 0) |
|
212 | + { |
|
213 | + $result=-3; |
|
214 | + } |
|
215 | + else |
|
216 | + { |
|
217 | + $result=0; |
|
218 | + } |
|
219 | + } |
|
220 | + else |
|
221 | + { |
|
222 | + if (dol_strlen($code) == 0) |
|
223 | + { |
|
224 | + $result=-2; |
|
225 | + } |
|
226 | + else |
|
227 | + { |
|
228 | + $result=-1; |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result); |
|
234 | + return $result; |
|
235 | + } |
|
236 | 236 | |
237 | 237 | |
238 | 238 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
239 | - /** |
|
240 | - * Return if a code is used (by other element) |
|
241 | - * |
|
242 | - * @param DoliDB $db Handler acces base |
|
243 | - * @param string $code Code to check |
|
244 | - * @param Product $product Objet product |
|
245 | - * @return int 0 if available, <0 if KO |
|
246 | - */ |
|
247 | - function verif_dispo($db, $code, $product) |
|
248 | - { |
|
239 | + /** |
|
240 | + * Return if a code is used (by other element) |
|
241 | + * |
|
242 | + * @param DoliDB $db Handler acces base |
|
243 | + * @param string $code Code to check |
|
244 | + * @param Product $product Objet product |
|
245 | + * @return int 0 if available, <0 if KO |
|
246 | + */ |
|
247 | + function verif_dispo($db, $code, $product) |
|
248 | + { |
|
249 | 249 | // phpcs:enable |
250 | - $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; |
|
251 | - $sql.= " WHERE barcode = '".$code."'"; |
|
252 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
253 | - |
|
254 | - $resql=$db->query($sql); |
|
255 | - if ($resql) |
|
256 | - { |
|
257 | - if ($db->num_rows($resql) == 0) |
|
258 | - { |
|
259 | - return 0; |
|
260 | - } |
|
261 | - else |
|
262 | - { |
|
263 | - return -1; |
|
264 | - } |
|
265 | - } |
|
266 | - else |
|
267 | - { |
|
268 | - return -2; |
|
269 | - } |
|
270 | - } |
|
250 | + $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; |
|
251 | + $sql.= " WHERE barcode = '".$code."'"; |
|
252 | + if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
253 | + |
|
254 | + $resql=$db->query($sql); |
|
255 | + if ($resql) |
|
256 | + { |
|
257 | + if ($db->num_rows($resql) == 0) |
|
258 | + { |
|
259 | + return 0; |
|
260 | + } |
|
261 | + else |
|
262 | + { |
|
263 | + return -1; |
|
264 | + } |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
268 | + return -2; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | 272 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
273 | - /** |
|
274 | - * Return if a barcode value match syntax |
|
275 | - * |
|
276 | - * @param string $codefortest Code to check syntax |
|
273 | + /** |
|
274 | + * Return if a barcode value match syntax |
|
275 | + * |
|
276 | + * @param string $codefortest Code to check syntax |
|
277 | 277 | * @param string $typefortest Type of barcode (ISBN, EAN, ...) |
278 | - * @return int 0 if OK, <0 if KO |
|
279 | - */ |
|
280 | - function verif_syntax($codefortest, $typefortest) |
|
281 | - { |
|
278 | + * @return int 0 if OK, <0 if KO |
|
279 | + */ |
|
280 | + function verif_syntax($codefortest, $typefortest) |
|
281 | + { |
|
282 | 282 | // phpcs:enable |
283 | - global $conf; |
|
284 | - |
|
285 | - $result = 0; |
|
286 | - |
|
287 | - // Get Mask value |
|
288 | - $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | - if (! $mask) |
|
290 | - { |
|
291 | - $this->error='NotConfigured'; |
|
292 | - return -1; |
|
293 | - } |
|
294 | - |
|
295 | - dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); |
|
296 | - |
|
297 | - $newcodefortest=$codefortest; |
|
298 | - |
|
299 | - // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test |
|
300 | - if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask |
|
301 | - { |
|
302 | - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
|
303 | - { |
|
304 | - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); |
|
305 | - dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - $result=check_value($mask,$newcodefortest); |
|
310 | - if (is_string($result)) |
|
311 | - { |
|
312 | - $this->error = $result; |
|
313 | - return -1; |
|
314 | - } |
|
315 | - |
|
316 | - return $result; |
|
317 | - } |
|
283 | + global $conf; |
|
284 | + |
|
285 | + $result = 0; |
|
286 | + |
|
287 | + // Get Mask value |
|
288 | + $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | + if (! $mask) |
|
290 | + { |
|
291 | + $this->error='NotConfigured'; |
|
292 | + return -1; |
|
293 | + } |
|
294 | + |
|
295 | + dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); |
|
296 | + |
|
297 | + $newcodefortest=$codefortest; |
|
298 | + |
|
299 | + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test |
|
300 | + if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask |
|
301 | + { |
|
302 | + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
|
303 | + { |
|
304 | + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); |
|
305 | + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + $result=check_value($mask,$newcodefortest); |
|
310 | + if (is_string($result)) |
|
311 | + { |
|
312 | + $this->error = $result; |
|
313 | + return -1; |
|
314 | + } |
|
315 | + |
|
316 | + return $result; |
|
317 | + } |
|
318 | 318 | } |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class mod_barcode_product_standard extends ModeleNumRefBarCode |
35 | 35 | { |
36 | - public $name='Standard'; // Model Name |
|
36 | + public $name = 'Standard'; // Model Name |
|
37 | 37 | |
38 | - public $code_modifiable; // Editable code |
|
38 | + public $code_modifiable; // Editable code |
|
39 | 39 | |
40 | - public $code_modifiable_invalide; // Modified code if it is invalid |
|
40 | + public $code_modifiable_invalide; // Modified code if it is invalid |
|
41 | 41 | |
42 | - public $code_modifiable_null; // Modified code if it is null |
|
42 | + public $code_modifiable_null; // Modified code if it is null |
|
43 | 43 | |
44 | - public $code_null; // Optional code |
|
44 | + public $code_null; // Optional code |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Dolibarr version of the loaded document |
48 | 48 | * @public string |
49 | 49 | */ |
50 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
50 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
51 | 51 | |
52 | - public $code_auto; // Automatic Numbering |
|
52 | + public $code_auto; // Automatic Numbering |
|
53 | 53 | |
54 | 54 | public $searchcode; // Search string |
55 | 55 | |
@@ -84,29 +84,29 @@ discard block |
||
84 | 84 | |
85 | 85 | $langs->load("products"); |
86 | 86 | |
87 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
87 | + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
88 | 88 | |
89 | 89 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
90 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | - $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
90 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | + $texte .= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
95 | 95 | |
96 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode")); |
|
97 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
98 | - $tooltip.=$langs->trans("GenericMaskCodes4c"); |
|
99 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
96 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode")); |
|
97 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
98 | + $tooltip .= $langs->trans("GenericMaskCodes4c"); |
|
99 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
100 | 100 | |
101 | 101 | // Mask parameter |
102 | 102 | //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; |
103 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
105 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | - $texte.= '</tr>'; |
|
103 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
105 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | + $texte .= '</tr>'; |
|
107 | 107 | |
108 | - $texte.= '</table>'; |
|
109 | - $texte.= '</form>'; |
|
108 | + $texte .= '</table>'; |
|
109 | + $texte .= '</form>'; |
|
110 | 110 | |
111 | 111 | return $texte; |
112 | 112 | } |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | * @param Product $objproduct Object product |
120 | 120 | * @return string Return string example |
121 | 121 | */ |
122 | - function getExample($langs,$objproduct=0) |
|
122 | + function getExample($langs, $objproduct = 0) |
|
123 | 123 | { |
124 | - $examplebarcode = $this->getNextValue($objproduct,''); |
|
125 | - if (! $examplebarcode) |
|
124 | + $examplebarcode = $this->getNextValue($objproduct, ''); |
|
125 | + if (!$examplebarcode) |
|
126 | 126 | { |
127 | 127 | $examplebarcode = $langs->trans('NotConfigured'); |
128 | 128 | } |
129 | - if($examplebarcode=="ErrorBadMask") |
|
129 | + if ($examplebarcode == "ErrorBadMask") |
|
130 | 130 | { |
131 | 131 | $langs->load("errors"); |
132 | - $examplebarcode=$langs->trans($examplebarcode); |
|
132 | + $examplebarcode = $langs->trans($examplebarcode); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return $examplebarcode; |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | * @param string $type Type of barcode (EAN, ISBN, ...) |
143 | 143 | * @return string Value if OK, '' if module not configured, <0 if KO |
144 | 144 | */ |
145 | - function getNextValue($objproduct=null,$type='') |
|
145 | + function getNextValue($objproduct = null, $type = '') |
|
146 | 146 | { |
147 | - global $db,$conf; |
|
147 | + global $db, $conf; |
|
148 | 148 | |
149 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
149 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
150 | 150 | |
151 | 151 | // TODO |
152 | 152 | |
153 | 153 | // Get Mask value |
154 | 154 | $mask = ''; |
155 | - if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
155 | + if (!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
156 | 156 | |
157 | 157 | if (empty($mask)) |
158 | 158 | { |
159 | - $this->error='NotConfigured'; |
|
159 | + $this->error = 'NotConfigured'; |
|
160 | 160 | return ''; |
161 | 161 | } |
162 | 162 | |
163 | - $field='barcode';$where=''; |
|
163 | + $field = 'barcode'; $where = ''; |
|
164 | 164 | |
165 | - $now=dol_now(); |
|
165 | + $now = dol_now(); |
|
166 | 166 | |
167 | - $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now); |
|
167 | + $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now); |
|
168 | 168 | |
169 | 169 | return $numFinal; |
170 | 170 | } |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | |
191 | 191 | //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; |
192 | 192 | |
193 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
193 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
194 | 194 | |
195 | - $result=0; |
|
195 | + $result = 0; |
|
196 | 196 | $code = strtoupper(trim($code)); |
197 | 197 | |
198 | 198 | if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) |
199 | 199 | { |
200 | - $result=0; |
|
200 | + $result = 0; |
|
201 | 201 | } |
202 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
202 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))) |
|
203 | 203 | { |
204 | - $result=-2; |
|
204 | + $result = -2; |
|
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | $is_dispo = $this->verif_dispo($db, $code, $product); |
211 | 211 | if ($is_dispo <> 0) |
212 | 212 | { |
213 | - $result=-3; |
|
213 | + $result = -3; |
|
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
217 | - $result=0; |
|
217 | + $result = 0; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
222 | 222 | if (dol_strlen($code) == 0) |
223 | 223 | { |
224 | - $result=-2; |
|
224 | + $result = -2; |
|
225 | 225 | } |
226 | 226 | else |
227 | 227 | { |
228 | - $result=-1; |
|
228 | + $result = -1; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | { |
249 | 249 | // phpcs:enable |
250 | 250 | $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; |
251 | - $sql.= " WHERE barcode = '".$code."'"; |
|
252 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
251 | + $sql .= " WHERE barcode = '".$code."'"; |
|
252 | + if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; |
|
253 | 253 | |
254 | - $resql=$db->query($sql); |
|
254 | + $resql = $db->query($sql); |
|
255 | 255 | if ($resql) |
256 | 256 | { |
257 | 257 | if ($db->num_rows($resql) == 0) |
@@ -285,28 +285,28 @@ discard block |
||
285 | 285 | $result = 0; |
286 | 286 | |
287 | 287 | // Get Mask value |
288 | - $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | - if (! $mask) |
|
288 | + $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? '' : $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | + if (!$mask) |
|
290 | 290 | { |
291 | - $this->error='NotConfigured'; |
|
291 | + $this->error = 'NotConfigured'; |
|
292 | 292 | return -1; |
293 | 293 | } |
294 | 294 | |
295 | 295 | dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); |
296 | 296 | |
297 | - $newcodefortest=$codefortest; |
|
297 | + $newcodefortest = $codefortest; |
|
298 | 298 | |
299 | 299 | // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test |
300 | - if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask |
|
300 | + if (in_array($typefortest, array('EAN13', 'ISBN'))) // We remove the CRC char not included into mask |
|
301 | 301 | { |
302 | - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
|
302 | + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) |
|
303 | 303 | { |
304 | - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); |
|
304 | + if (strlen($reg[1]) == 12) $newcodefortest = substr($newcodefortest, 0, 12); |
|
305 | 305 | dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - $result=check_value($mask,$newcodefortest); |
|
309 | + $result = check_value($mask, $newcodefortest); |
|
310 | 310 | if (is_string($result)) |
311 | 311 | { |
312 | 312 | $this->error = $result; |
@@ -152,7 +152,9 @@ discard block |
||
152 | 152 | |
153 | 153 | // Get Mask value |
154 | 154 | $mask = ''; |
155 | - if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
155 | + if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { |
|
156 | + $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | if (empty($mask)) |
158 | 160 | { |
@@ -198,12 +200,10 @@ discard block |
||
198 | 200 | if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) |
199 | 201 | { |
200 | 202 | $result=0; |
201 | - } |
|
202 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
203 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
203 | 204 | { |
204 | 205 | $result=-2; |
205 | - } |
|
206 | - else |
|
206 | + } else |
|
207 | 207 | { |
208 | 208 | if ($this->verif_syntax($code, $type) >= 0) |
209 | 209 | { |
@@ -211,19 +211,16 @@ discard block |
||
211 | 211 | if ($is_dispo <> 0) |
212 | 212 | { |
213 | 213 | $result=-3; |
214 | - } |
|
215 | - else |
|
214 | + } else |
|
216 | 215 | { |
217 | 216 | $result=0; |
218 | 217 | } |
219 | - } |
|
220 | - else |
|
218 | + } else |
|
221 | 219 | { |
222 | 220 | if (dol_strlen($code) == 0) |
223 | 221 | { |
224 | 222 | $result=-2; |
225 | - } |
|
226 | - else |
|
223 | + } else |
|
227 | 224 | { |
228 | 225 | $result=-1; |
229 | 226 | } |
@@ -249,7 +246,9 @@ discard block |
||
249 | 246 | // phpcs:enable |
250 | 247 | $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; |
251 | 248 | $sql.= " WHERE barcode = '".$code."'"; |
252 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
249 | + if ($product->id > 0) { |
|
250 | + $sql.= " AND rowid <> ".$product->id; |
|
251 | + } |
|
253 | 252 | |
254 | 253 | $resql=$db->query($sql); |
255 | 254 | if ($resql) |
@@ -257,13 +256,11 @@ discard block |
||
257 | 256 | if ($db->num_rows($resql) == 0) |
258 | 257 | { |
259 | 258 | return 0; |
260 | - } |
|
261 | - else |
|
259 | + } else |
|
262 | 260 | { |
263 | 261 | return -1; |
264 | 262 | } |
265 | - } |
|
266 | - else |
|
263 | + } else |
|
267 | 264 | { |
268 | 265 | return -2; |
269 | 266 | } |
@@ -297,11 +294,13 @@ discard block |
||
297 | 294 | $newcodefortest=$codefortest; |
298 | 295 | |
299 | 296 | // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test |
300 | - if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask |
|
297 | + if (in_array($typefortest,array('EAN13','ISBN'))) { |
|
298 | + // We remove the CRC char not included into mask |
|
301 | 299 | { |
302 | 300 | if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
303 | 301 | { |
304 | 302 | if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); |
303 | + } |
|
305 | 304 | dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); |
306 | 305 | } |
307 | 306 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | */ |
30 | 30 | abstract class ModeleBarCode |
31 | 31 | { |
32 | - /** |
|
33 | - * @var string Error code (or message) |
|
34 | - */ |
|
35 | - public $error=''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Return if a model can be used or not |
|
40 | - * |
|
41 | - * @return boolean true if model can be used |
|
42 | - */ |
|
43 | - function isEnabled() |
|
44 | - { |
|
45 | - return true; |
|
46 | - } |
|
32 | + /** |
|
33 | + * @var string Error code (or message) |
|
34 | + */ |
|
35 | + public $error=''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * Return if a model can be used or not |
|
40 | + * |
|
41 | + * @return boolean true if model can be used |
|
42 | + */ |
|
43 | + function isEnabled() |
|
44 | + { |
|
45 | + return true; |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | abstract class ModeleNumRefBarCode |
54 | 54 | { |
55 | - /** |
|
56 | - * @var string Error code (or message) |
|
57 | - */ |
|
58 | - public $error=''; |
|
55 | + /** |
|
56 | + * @var string Error code (or message) |
|
57 | + */ |
|
58 | + public $error=''; |
|
59 | 59 | |
60 | 60 | /** Return default description of numbering model |
61 | 61 | * |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
103 | 103 | } |
104 | 104 | |
105 | - /** Return version of module |
|
105 | + /** Return version of module |
|
106 | 106 | * |
107 | 107 | * @return string Version |
108 | 108 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var string Error code (or message) |
34 | 34 | */ |
35 | - public $error=''; |
|
35 | + public $error = ''; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @var string Error code (or message) |
57 | 57 | */ |
58 | - public $error=''; |
|
58 | + public $error = ''; |
|
59 | 59 | |
60 | 60 | /** Return default description of numbering model |
61 | 61 | * |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function getNom($langs) |
77 | 77 | { |
78 | - return empty($this->name)?$this->nom:$this->name; |
|
78 | + return empty($this->name) ? $this->nom : $this->name; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** Return a numbering example |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string $type Type of barcode (EAN, ISBN, ...) |
97 | 97 | * @return string Value |
98 | 98 | */ |
99 | - function getNextValue($objproduct,$type='') |
|
99 | + function getNextValue($objproduct, $type = '') |
|
100 | 100 | { |
101 | 101 | global $langs; |
102 | 102 | return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
@@ -126,53 +126,53 @@ discard block |
||
126 | 126 | * @param int $type -1=Nothing, 0=Product, 1=Service |
127 | 127 | * @return string HTML translated description |
128 | 128 | */ |
129 | - function getToolTip($langs,$soc,$type) |
|
129 | + function getToolTip($langs, $soc, $type) |
|
130 | 130 | { |
131 | 131 | global $conf; |
132 | 132 | |
133 | 133 | $langs->load("admin"); |
134 | 134 | |
135 | - $s=''; |
|
136 | - $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>'; |
|
137 | - $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
138 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
139 | - $s.='<br>'; |
|
140 | - $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
135 | + $s = ''; |
|
136 | + $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>'; |
|
137 | + $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
138 | + if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
139 | + $s .= '<br>'; |
|
140 | + $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
141 | 141 | if ($type == 0) |
142 | 142 | { |
143 | - $s.=$langs->trans("RequiredIfProduct").': '; |
|
144 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
145 | - $s.=yn(!$this->code_null,1,2); |
|
146 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
147 | - $s.='<br>'; |
|
143 | + $s .= $langs->trans("RequiredIfProduct").': '; |
|
144 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
145 | + $s .= yn(!$this->code_null, 1, 2); |
|
146 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
147 | + $s .= '<br>'; |
|
148 | 148 | } |
149 | 149 | if ($type == 1) |
150 | 150 | { |
151 | - $s.=$langs->trans("RequiredIfService").': '; |
|
152 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
153 | - $s.=yn(!$this->code_null,1,2); |
|
154 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
155 | - $s.='<br>'; |
|
151 | + $s .= $langs->trans("RequiredIfService").': '; |
|
152 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
153 | + $s .= yn(!$this->code_null, 1, 2); |
|
154 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
155 | + $s .= '<br>'; |
|
156 | 156 | } |
157 | 157 | if ($type == -1) |
158 | 158 | { |
159 | - $s.=$langs->trans("Required").': '; |
|
160 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
161 | - $s.=yn(!$this->code_null,1,2); |
|
162 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
163 | - $s.='<br>'; |
|
159 | + $s .= $langs->trans("Required").': '; |
|
160 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
161 | + $s .= yn(!$this->code_null, 1, 2); |
|
162 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
163 | + $s .= '<br>'; |
|
164 | 164 | } |
165 | 165 | /*$s.=$langs->trans("CanBeModifiedIfOk").': '; |
166 | 166 | $s.=yn($this->code_modifiable,1,2); |
167 | 167 | $s.='<br>'; |
168 | 168 | $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
169 | 169 | */ |
170 | - $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
171 | - $s.='<br>'; |
|
170 | + $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>'; |
|
171 | + $s .= '<br>'; |
|
172 | 172 | |
173 | - $nextval=$this->getNextValue($soc,''); |
|
174 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
175 | - $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; |
|
173 | + $nextval = $this->getNextValue($soc, ''); |
|
174 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
175 | + $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; |
|
176 | 176 | |
177 | 177 | return $s; |
178 | 178 | } |
@@ -111,10 +111,18 @@ discard block |
||
111 | 111 | global $langs; |
112 | 112 | $langs->load("admin"); |
113 | 113 | |
114 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
115 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
116 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
117 | - if ($this->version) return $this->version; |
|
114 | + if ($this->version == 'development') { |
|
115 | + return $langs->trans("VersionDevelopment"); |
|
116 | + } |
|
117 | + if ($this->version == 'experimental') { |
|
118 | + return $langs->trans("VersionExperimental"); |
|
119 | + } |
|
120 | + if ($this->version == 'dolibarr') { |
|
121 | + return DOL_VERSION; |
|
122 | + } |
|
123 | + if ($this->version) { |
|
124 | + return $this->version; |
|
125 | + } |
|
118 | 126 | return $langs->trans("NotAvailable"); |
119 | 127 | } |
120 | 128 | |
@@ -135,31 +143,45 @@ discard block |
||
135 | 143 | $s=''; |
136 | 144 | $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>'; |
137 | 145 | $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
138 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
146 | + if ($type != -1) { |
|
147 | + $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
148 | + } |
|
139 | 149 | $s.='<br>'; |
140 | 150 | $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
141 | 151 | if ($type == 0) |
142 | 152 | { |
143 | 153 | $s.=$langs->trans("RequiredIfProduct").': '; |
144 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
154 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
155 | + $s.='<strike>'; |
|
156 | + } |
|
145 | 157 | $s.=yn(!$this->code_null,1,2); |
146 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
158 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
159 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
160 | + } |
|
147 | 161 | $s.='<br>'; |
148 | 162 | } |
149 | 163 | if ($type == 1) |
150 | 164 | { |
151 | 165 | $s.=$langs->trans("RequiredIfService").': '; |
152 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
166 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
167 | + $s.='<strike>'; |
|
168 | + } |
|
153 | 169 | $s.=yn(!$this->code_null,1,2); |
154 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
170 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
171 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
172 | + } |
|
155 | 173 | $s.='<br>'; |
156 | 174 | } |
157 | 175 | if ($type == -1) |
158 | 176 | { |
159 | 177 | $s.=$langs->trans("Required").': '; |
160 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
178 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
179 | + $s.='<strike>'; |
|
180 | + } |
|
161 | 181 | $s.=yn(!$this->code_null,1,2); |
162 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
182 | + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
183 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
184 | + } |
|
163 | 185 | $s.='<br>'; |
164 | 186 | } |
165 | 187 | /*$s.=$langs->trans("CanBeModifiedIfOk").': '; |
@@ -171,7 +193,9 @@ discard block |
||
171 | 193 | $s.='<br>'; |
172 | 194 | |
173 | 195 | $nextval=$this->getNextValue($soc,''); |
174 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
196 | + if (empty($nextval)) { |
|
197 | + $nextval=$langs->trans("Undefined"); |
|
198 | + } |
|
175 | 199 | $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; |
176 | 200 | |
177 | 201 | return $s; |