@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module Bookmarks |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $this->family = "technic"; |
47 | 47 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
48 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
48 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
49 | 49 | $this->description = "Gestion des Bookmarks"; |
50 | 50 | |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
55 | 55 | $this->special = 2; |
56 | - $this->picto='bookmark'; |
|
56 | + $this->picto = 'bookmark'; |
|
57 | 57 | |
58 | 58 | // Data directories to create when module is enabled |
59 | 59 | $this->dirs = array(); |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | $this->const = array(); |
71 | 71 | |
72 | 72 | // Boxes |
73 | - $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home')); |
|
73 | + $this->boxes = array(0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home')); |
|
74 | 74 | |
75 | 75 | // Permissions |
76 | 76 | $this->rights = array(); |
77 | 77 | $this->rights_class = 'bookmark'; |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $r++; |
81 | 81 | $this->rights[$r][0] = 331; // id de la permission |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | // Menus |
103 | 103 | //------- |
104 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
104 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | /** |
39 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
40 | - * |
|
41 | - * @param DoliDB $db Database handler |
|
39 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
40 | + * |
|
41 | + * @param DoliDB $db Database handler |
|
42 | 42 | */ |
43 | 43 | function __construct($db) |
44 | 44 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
60 | 60 | $this->special = 0; |
61 | - $this->picto='accounting'; |
|
61 | + $this->picto='accounting'; |
|
62 | 62 | |
63 | 63 | // Config pages |
64 | 64 | $this->config_page_url = array("compta.php"); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | |
75 | 75 | // Data directories to create when module is enabled |
76 | 76 | $this->dirs = array("/comptabilite/temp", |
77 | - "/comptabilite/rapport", |
|
78 | - "/comptabilite/export", |
|
79 | - "/comptabilite/bordereau" |
|
80 | - ); |
|
77 | + "/comptabilite/rapport", |
|
78 | + "/comptabilite/export", |
|
79 | + "/comptabilite/bordereau" |
|
80 | + ); |
|
81 | 81 | |
82 | 82 | // Boxes |
83 | 83 | $this->boxes = array(); |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | |
105 | 105 | |
106 | 106 | /** |
107 | - * Function called when module is enabled. |
|
108 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
109 | - * It also creates data directories |
|
110 | - * |
|
111 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
112 | - * @return int 1 if OK, 0 if KO |
|
107 | + * Function called when module is enabled. |
|
108 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
109 | + * It also creates data directories |
|
110 | + * |
|
111 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
112 | + * @return int 1 if OK, 0 if KO |
|
113 | 113 | */ |
114 | 114 | function init($options='') |
115 | 115 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * \brief Fichier de description et activation du module Comptabilite |
27 | 27 | */ |
28 | 28 | |
29 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
29 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->family = "financial"; |
51 | 51 | $this->module_position = 600; |
52 | 52 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
53 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
54 | 54 | $this->description = "Gestion sommaire de comptabilite"; |
55 | 55 | |
56 | 56 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | |
59 | 59 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
60 | 60 | $this->special = 0; |
61 | - $this->picto='accounting'; |
|
61 | + $this->picto = 'accounting'; |
|
62 | 62 | |
63 | 63 | // Config pages |
64 | 64 | $this->config_page_url = array("compta.php"); |
65 | 65 | |
66 | 66 | // Dependencies |
67 | - $this->depends = array("modFacture","modBanque"); |
|
67 | + $this->depends = array("modFacture", "modBanque"); |
|
68 | 68 | $this->requiredby = array(); |
69 | 69 | $this->conflictwith = array("modAccounting"); |
70 | 70 | $this->langfiles = array("compta"); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | // Permissions |
86 | 86 | $this->rights = array(); |
87 | 87 | $this->rights_class = 'compta'; |
88 | - $r=0; |
|
88 | + $r = 0; |
|
89 | 89 | |
90 | 90 | $r++; |
91 | 91 | $this->rights[$r][0] = 95; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | // Menus |
100 | 100 | //------- |
101 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
101 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $options Options when enabling module ('', 'noboxes') |
112 | 112 | * @return int 1 if OK, 0 if KO |
113 | 113 | */ |
114 | - function init($options='') |
|
114 | + function init($options = '') |
|
115 | 115 | { |
116 | 116 | global $conf; |
117 | 117 | |
@@ -120,6 +120,6 @@ discard block |
||
120 | 120 | |
121 | 121 | $sql = array(); |
122 | 122 | |
123 | - return $this->_init($sql,$options); |
|
123 | + return $this->_init($sql, $options); |
|
124 | 124 | } |
125 | 125 | } |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | class modExternalSite extends DolibarrModules |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
37 | + /** |
|
38 | 38 | * Constructor. Define names, constants, directories, boxes, permissions |
39 | 39 | * |
40 | 40 | * @param DoliDB $db Database handler |
41 | - */ |
|
41 | + */ |
|
42 | 42 | function __construct($db) |
43 | 43 | { |
44 | 44 | $this->db = $db; |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | |
89 | 89 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
90 | 90 | // Example: |
91 | - //$this->boxes[$r][1] = "myboxa.php"; |
|
92 | - //$r++; |
|
93 | - //$this->boxes[$r][1] = "myboxb.php"; |
|
94 | - //$r++; |
|
91 | + //$this->boxes[$r][1] = "myboxa.php"; |
|
92 | + //$r++; |
|
93 | + //$this->boxes[$r][1] = "myboxb.php"; |
|
94 | + //$r++; |
|
95 | 95 | |
96 | 96 | // Permissions |
97 | 97 | $this->rights_class = 'externalsite'; // Permission key |
98 | 98 | $this->rights = array(); // Permission array used by this module |
99 | 99 | |
100 | - // Menus |
|
100 | + // Menus |
|
101 | 101 | //------ |
102 | 102 | $r=0; |
103 | 103 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \brief Description and activation file for module ExternalSite |
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,7 +51,7 @@ discard block |
||
51 | 51 | // It is used to sort modules in module setup page |
52 | 52 | $this->family = "other"; |
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 | // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) |
56 | 56 | $this->description = "This module include an external web site or page into Dolibarr menus and view it into a Dolibarr frame."; |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Where to store the module in setup page (0=common,1=interface,2=other) |
62 | 62 | $this->special = 1; |
63 | 63 | // Name of png file (without png) used for this module |
64 | - $this->picto='bookmark'; |
|
64 | + $this->picto = 'bookmark'; |
|
65 | 65 | // Call to inside lang's file |
66 | 66 | $this->langfiles = array("externalsite"); |
67 | 67 | |
@@ -72,19 +72,19 @@ discard block |
||
72 | 72 | $this->config_page_url = array("externalsite.php@externalsite"); |
73 | 73 | |
74 | 74 | // Dependencies |
75 | - $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
76 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
75 | + $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
76 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
77 | 77 | |
78 | 78 | // Constants |
79 | 79 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
80 | 80 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), |
81 | 81 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) |
82 | 82 | // ); |
83 | - $this->const = array(0=>array('EXTERNALSITE_LABEL','chaine','ExternalSite','To declare label to use into external site menu entry', 0)); |
|
83 | + $this->const = array(0=>array('EXTERNALSITE_LABEL', 'chaine', 'ExternalSite', 'To declare label to use into external site menu entry', 0)); |
|
84 | 84 | |
85 | 85 | // Boxes |
86 | - $this->boxes = array(); // List of boxes |
|
87 | - $r=0; |
|
86 | + $this->boxes = array(); // List of boxes |
|
87 | + $r = 0; |
|
88 | 88 | |
89 | 89 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
90 | 90 | // Example: |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | //$r++; |
95 | 95 | |
96 | 96 | // Permissions |
97 | - $this->rights_class = 'externalsite'; // Permission key |
|
98 | - $this->rights = array(); // Permission array used by this module |
|
97 | + $this->rights_class = 'externalsite'; // Permission key |
|
98 | + $this->rights = array(); // Permission array used by this module |
|
99 | 99 | |
100 | 100 | // Menus |
101 | 101 | //------ |
102 | - $r=0; |
|
102 | + $r = 0; |
|
103 | 103 | |
104 | - $this->menu[$r]=array( |
|
104 | + $this->menu[$r] = array( |
|
105 | 105 | 'fk_menu'=>0, |
106 | 106 | 'type'=>'top', |
107 | 107 | 'titre'=>'$conf->global->EXTERNALSITE_LABEL', |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup loan |
24 | 24 | * \brief File to activate module loan |
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 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | $this->family = "financial"; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
51 | 51 | $this->description = "Loans management"; |
52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
57 | 57 | $this->special = 0; |
58 | - $this->picto='bill'; |
|
58 | + $this->picto = 'bill'; |
|
59 | 59 | |
60 | 60 | // Data directories to create when module is enabled |
61 | 61 | $this->dirs = array("/loan/temp"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | // Permissions |
94 | 94 | $this->rights = array(); |
95 | 95 | $this->rights_class = 'loan'; |
96 | - $r=0; |
|
96 | + $r = 0; |
|
97 | 97 | |
98 | 98 | $r++; |
99 | 99 | $this->rights[$r][0] = 520; |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | |
139 | 139 | // Menus |
140 | 140 | //------- |
141 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
141 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
142 | 142 | |
143 | 143 | |
144 | 144 | // Exports |
145 | 145 | //-------- |
146 | - $r=0; |
|
146 | + $r = 0; |
|
147 | 147 | |
148 | 148 | } |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param string $options Options when enabling module ('', 'noboxes') |
157 | 157 | * @return int 1 if OK, 0 if KO |
158 | 158 | */ |
159 | - function init($options='') |
|
159 | + function init($options = '') |
|
160 | 160 | { |
161 | 161 | global $conf; |
162 | 162 | |
@@ -165,6 +165,6 @@ discard block |
||
165 | 165 | |
166 | 166 | $sql = array(); |
167 | 167 | |
168 | - return $this->_init($sql,$options); |
|
168 | + return $this->_init($sql, $options); |
|
169 | 169 | } |
170 | 170 | } |
@@ -101,7 +101,7 @@ |
||
101 | 101 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
102 | 102 | * It also creates data directories |
103 | 103 | * |
104 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
104 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
105 | 105 | * @return int 1 if OK, 0 if KO |
106 | 106 | */ |
107 | 107 | function init($options='') |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \ingroup resource |
26 | 26 | * \brief Description and activation file for module Resource |
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 | * Description and activation class for module Resource |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->version = 'dolibarr'; |
69 | 69 | // Key used in llx_const table to save module status enabled/disabled |
70 | 70 | // (where MYMODULE is value of property name of module in uppercase) |
71 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
71 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
72 | 72 | // Where to store the module in setup page |
73 | 73 | // (0=common,1=interface,2=others,3=very specific) |
74 | 74 | $this->special = 2; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | // Menus |
200 | 200 | //------- |
201 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
201 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
202 | 202 | |
203 | 203 | |
204 | 204 | // Main menu entries |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $r = 0; |
207 | 207 | |
208 | 208 | // Menus declaration |
209 | - $this->menu[$r]=array( |
|
209 | + $this->menu[$r] = array( |
|
210 | 210 | 'fk_menu'=>'fk_mainmenu=tools', |
211 | 211 | 'type'=>'left', |
212 | 212 | 'titre'=> 'MenuResourceIndex', |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | ); |
222 | 222 | $r++; |
223 | 223 | |
224 | - $this->menu[$r++]=array( |
|
224 | + $this->menu[$r++] = array( |
|
225 | 225 | 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
226 | 226 | 'type'=> 'left', // Toujours un menu gauche |
227 | 227 | 'titre'=> 'MenuResourceAdd', |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'user'=> 0 |
237 | 237 | ); |
238 | 238 | |
239 | - $this->menu[$r++]=array( |
|
239 | + $this->menu[$r++] = array( |
|
240 | 240 | 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus |
241 | 241 | 'type'=> 'left', // Toujours un menu gauche |
242 | 242 | 'titre'=> 'List', |
@@ -254,59 +254,59 @@ discard block |
||
254 | 254 | |
255 | 255 | // Exports |
256 | 256 | //-------- |
257 | - $r=0; |
|
257 | + $r = 0; |
|
258 | 258 | |
259 | 259 | $r++; |
260 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
261 | - $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
262 | - $this->export_permission[$r]=array(array("resource","read")); |
|
263 | - $this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification"); |
|
264 | - $this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text'); |
|
265 | - $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); |
|
266 | - $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; |
|
260 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
261 | + $this->export_label[$r] = "ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
262 | + $this->export_permission[$r] = array(array("resource", "read")); |
|
263 | + $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification"); |
|
264 | + $this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text'); |
|
265 | + $this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource"); |
|
266 | + $keyforselect = 'resource'; $keyforelement = 'resource'; $keyforaliasextra = 'extra'; |
|
267 | 267 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
268 | 268 | |
269 | - $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
270 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
271 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
272 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
273 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
274 | - $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; |
|
269 | + $this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. |
|
270 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
271 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r '; |
|
272 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; |
|
273 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; |
|
274 | + $this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')'; |
|
275 | 275 | |
276 | 276 | |
277 | 277 | // Imports |
278 | 278 | //-------- |
279 | - $r=0; |
|
279 | + $r = 0; |
|
280 | 280 | |
281 | 281 | // Import list of third parties and attributes |
282 | 282 | $r++; |
283 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
284 | - $this->import_label[$r]='ImportDataset_resource_1'; |
|
285 | - $this->import_icon[$r]='resource'; |
|
286 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
287 | - $this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
288 | - $this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation'); |
|
283 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
284 | + $this->import_label[$r] = 'ImportDataset_resource_1'; |
|
285 | + $this->import_icon[$r] = 'resource'; |
|
286 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
287 | + $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) |
|
288 | + $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); |
|
289 | 289 | // Add extra fields |
290 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity = ".$conf->entity; |
|
291 | - $resql=$this->db->query($sql); |
|
290 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity = ".$conf->entity; |
|
291 | + $resql = $this->db->query($sql); |
|
292 | 292 | if ($resql) // This can fail when class is used on old database (during migration for example) |
293 | 293 | { |
294 | - while ($obj=$this->db->fetch_object($resql)) |
|
294 | + while ($obj = $this->db->fetch_object($resql)) |
|
295 | 295 | { |
296 | - $fieldname='extra.'.$obj->name; |
|
297 | - $fieldlabel=ucfirst($obj->label); |
|
298 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
296 | + $fieldname = 'extra.'.$obj->name; |
|
297 | + $fieldlabel = ucfirst($obj->label); |
|
298 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | // End add extra fields |
302 | - $this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
303 | - $this->import_convertvalue_array[$r]=array( |
|
304 | - 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'), |
|
302 | + $this->import_fieldshidden_array[$r] = array('r.fk_user_author'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
303 | + $this->import_convertvalue_array[$r] = array( |
|
304 | + 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/core/class/ctyperesource.class.php', 'class'=>'Ctyperesource', 'method'=>'fetch', 'dict'=>'DictionaryResourceType'), |
|
305 | 305 | ); |
306 | 306 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
307 | - $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
308 | - $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
309 | - $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); |
|
307 | + $this->import_regex_array[$r] = array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
308 | + $this->import_examplevalues_array[$r] = array('r.ref'=>"REF1", 'r.fk_code_type_resource'=>"Code from dictionary resource type", 'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); |
|
309 | + $this->import_updatekeys_array[$r] = array('r.rf'=>'ResourceFormLabel_ref'); |
|
310 | 310 | |
311 | 311 | } |
312 | 312 |
@@ -289,11 +289,13 @@ |
||
289 | 289 | // Add extra fields |
290 | 290 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity = ".$conf->entity; |
291 | 291 | $resql=$this->db->query($sql); |
292 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
292 | + if ($resql) { |
|
293 | + // This can fail when class is used on old database (during migration for example) |
|
293 | 294 | { |
294 | 295 | while ($obj=$this->db->fetch_object($resql)) |
295 | 296 | { |
296 | 297 | $fieldname='extra.'.$obj->name; |
298 | + } |
|
297 | 299 | $fieldlabel=ucfirst($obj->label); |
298 | 300 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
299 | 301 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | abstract class ModeleNumRefPayments |
25 | 25 | { |
26 | - var $error=''; |
|
26 | + var $error = ''; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Return if a module can be used or not |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param Object $object Object we need next value for |
77 | 77 | * @return string Valeur |
78 | 78 | */ |
79 | - function getNextValue($objsoc,$object) |
|
79 | + function getNextValue($objsoc, $object) |
|
80 | 80 | { |
81 | 81 | global $langs; |
82 | 82 | return $langs->trans("NotAvailable"); |
@@ -92,10 +92,18 @@ |
||
92 | 92 | global $langs; |
93 | 93 | $langs->load("admin"); |
94 | 94 | |
95 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
96 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
97 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
98 | - if ($this->version) return $this->version; |
|
95 | + if ($this->version == 'development') { |
|
96 | + return $langs->trans("VersionDevelopment"); |
|
97 | + } |
|
98 | + if ($this->version == 'experimental') { |
|
99 | + return $langs->trans("VersionExperimental"); |
|
100 | + } |
|
101 | + if ($this->version == 'dolibarr') { |
|
102 | + return DOL_VERSION; |
|
103 | + } |
|
104 | + if ($this->version) { |
|
105 | + return $this->version; |
|
106 | + } |
|
99 | 107 | return $langs->trans("NotAvailable"); |
100 | 108 | } |
101 | 109 | } |
@@ -95,8 +95,8 @@ |
||
95 | 95 | |
96 | 96 | // Array to add new pages in new tabs |
97 | 97 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 |
98 | - // 'objecttype:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 |
|
99 | - // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname |
|
98 | + // 'objecttype:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 |
|
99 | + // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname |
|
100 | 100 | // where objecttype can be |
101 | 101 | // 'thirdparty' to add a tab in third party view |
102 | 102 | // 'intervention' to add a tab in intervention view |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \ingroup holiday |
28 | 28 | * \brief Description and activation file for module holiday |
29 | 29 | */ |
30 | -include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"); |
|
30 | +include_once(DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $this->family = "hr"; |
56 | 56 | $this->module_position = 30; |
57 | 57 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
58 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
58 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
59 | 59 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
60 | 60 | $this->description = "Leave management"; |
61 | 61 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -67,28 +67,28 @@ discard block |
||
67 | 67 | // Name of image file used for this module. |
68 | 68 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
69 | 69 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
70 | - $this->picto='holiday'; |
|
70 | + $this->picto = 'holiday'; |
|
71 | 71 | |
72 | 72 | // Data directories to create when module is enabled. |
73 | 73 | // Example: this->dirs = array("/mymodule/temp"); |
74 | 74 | $this->dirs = array(); |
75 | - $r=0; |
|
75 | + $r = 0; |
|
76 | 76 | |
77 | 77 | // Config pages. Put here list of php page names stored in admmin directory used to setup module. |
78 | 78 | // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); |
79 | 79 | |
80 | 80 | // Dependencies |
81 | - $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
82 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
83 | - $this->phpmin = array(4,3); // Minimum version of PHP required by module |
|
84 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
81 | + $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
82 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
83 | + $this->phpmin = array(4, 3); // Minimum version of PHP required by module |
|
84 | + $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module |
|
85 | 85 | $this->langfiles = array("holiday"); |
86 | 86 | |
87 | 87 | // Constants |
88 | 88 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
89 | 89 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
90 | 90 | // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) |
91 | - $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
91 | + $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') |
|
92 | 92 | |
93 | 93 | // Array to add new pages in new tabs |
94 | 94 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | $this->tabs = array('user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); |
114 | 114 | |
115 | 115 | // Boxes |
116 | - $this->boxes = array(); // List of boxes |
|
117 | - $r=0; |
|
116 | + $this->boxes = array(); // List of boxes |
|
117 | + $r = 0; |
|
118 | 118 | |
119 | 119 | // Add here list of php file(s) stored in includes/boxes that contains class to show a box. |
120 | 120 | // Example: |
@@ -125,59 +125,59 @@ discard block |
||
125 | 125 | |
126 | 126 | |
127 | 127 | // Permissions |
128 | - $this->rights = array(); // Permission array used by this module |
|
129 | - $r=0; |
|
130 | - |
|
131 | - $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
132 | - $this->rights[$r][1] = 'Read your own holidays'; // Permission label |
|
133 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
134 | - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
135 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
128 | + $this->rights = array(); // Permission array used by this module |
|
129 | + $r = 0; |
|
130 | + |
|
131 | + $this->rights[$r][0] = 20001; // Permission id (must not be already used) |
|
132 | + $this->rights[$r][1] = 'Read your own holidays'; // Permission label |
|
133 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
134 | + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
135 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
136 | 136 | $r++; |
137 | 137 | |
138 | - $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
139 | - $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label |
|
140 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
141 | - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
142 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
138 | + $this->rights[$r][0] = 20002; // Permission id (must not be already used) |
|
139 | + $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label |
|
140 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
141 | + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
142 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
143 | 143 | $r++; |
144 | 144 | |
145 | - $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
146 | - $this->rights[$r][1] = 'Delete holidays'; // Permission label |
|
147 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
148 | - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
149 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
145 | + $this->rights[$r][0] = 20003; // Permission id (must not be already used) |
|
146 | + $this->rights[$r][1] = 'Delete holidays'; // Permission label |
|
147 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
148 | + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
149 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
150 | 150 | $r++; |
151 | 151 | |
152 | - $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
153 | - $this->rights[$r][1] = 'Read holidays for everybody'; // Permission label |
|
154 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
155 | - $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
156 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
152 | + $this->rights[$r][0] = 20004; // Permission id (must not be already used) |
|
153 | + $this->rights[$r][1] = 'Read holidays for everybody'; // Permission label |
|
154 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
155 | + $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
156 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
157 | 157 | $r++; |
158 | 158 | |
159 | - $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
160 | - $this->rights[$r][1] = 'Create/modify holidays for everybody'; // Permission label |
|
161 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
162 | - $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
163 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
159 | + $this->rights[$r][0] = 20005; // Permission id (must not be already used) |
|
160 | + $this->rights[$r][1] = 'Create/modify holidays for everybody'; // Permission label |
|
161 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
162 | + $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
163 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
164 | 164 | $r++; |
165 | 165 | |
166 | - $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
167 | - $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label |
|
168 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
169 | - $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
170 | - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
166 | + $this->rights[$r][0] = 20006; // Permission id (must not be already used) |
|
167 | + $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label |
|
168 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
169 | + $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
170 | + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) |
|
171 | 171 | $r++; |
172 | 172 | |
173 | 173 | |
174 | 174 | // Menus |
175 | 175 | //------- |
176 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
176 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
177 | 177 | |
178 | 178 | |
179 | 179 | // Exports |
180 | - $r=1; |
|
180 | + $r = 1; |
|
181 | 181 | |
182 | 182 | // Example: |
183 | 183 | // $this->export_code[$r]=$this->rights_class.'_'.$r; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
123 | 123 | $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
124 | 124 | $this->rights[$r][4] = 'supprimer'; |
125 | - $r++; |
|
125 | + $r++; |
|
126 | 126 | |
127 | 127 | $this->rights[$r][0] = 38; // Must be same permission than in service module |
128 | 128 | $this->rights[$r][1] = 'Exporter les produits'; |
129 | 129 | $this->rights[$r][2] = 'r'; |
130 | 130 | $this->rights[$r][3] = 0; |
131 | 131 | $this->rights[$r][4] = 'export'; |
132 | - $r++; |
|
132 | + $r++; |
|
133 | 133 | |
134 | - // Menus |
|
135 | - //------- |
|
134 | + // Menus |
|
135 | + //------- |
|
136 | 136 | |
137 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
137 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
138 | 138 | /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert |
139 | 139 | $r=0; |
140 | 140 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
@@ -220,32 +220,32 @@ discard block |
||
220 | 220 | |
221 | 221 | if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
222 | 222 | { |
223 | - $r++; |
|
224 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
225 | - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
226 | - $this->export_permission[$r]=array(array("produit","export")); |
|
227 | - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
|
228 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
229 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
230 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); |
|
231 | - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
|
232 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
233 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
234 | - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); |
|
235 | - $this->export_entities_array[$r]=array('p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct",'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct",'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct','p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct",'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct"); |
|
236 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
237 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
238 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); |
|
239 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
240 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
241 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); |
|
242 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); |
|
243 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
244 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
245 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
246 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
247 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
248 | - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
223 | + $r++; |
|
224 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
225 | + $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
226 | + $this->export_permission[$r]=array(array("produit","export")); |
|
227 | + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
|
228 | + if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
229 | + if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
230 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); |
|
231 | + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
|
232 | + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
233 | + if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
234 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); |
|
235 | + $this->export_entities_array[$r]=array('p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct",'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct",'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct','p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct",'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct"); |
|
236 | + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
237 | + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
238 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); |
|
239 | + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
240 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
241 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); |
|
242 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); |
|
243 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
244 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
245 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
246 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
247 | + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
248 | + $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | // Imports |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | $resql=$this->db->query($sql); |
271 | 271 | if ($resql) // This can fail when class is used on old database (during migration for example) |
272 | 272 | { |
273 | - while ($obj=$this->db->fetch_object($resql)) |
|
274 | - { |
|
275 | - $fieldname='extra.'.$obj->name; |
|
276 | - $fieldlabel=ucfirst($obj->label); |
|
277 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
278 | - $import_extrafield_sample[$fieldname]=$fieldlabel; |
|
279 | - } |
|
273 | + while ($obj=$this->db->fetch_object($resql)) |
|
274 | + { |
|
275 | + $fieldname='extra.'.$obj->name; |
|
276 | + $fieldlabel=ucfirst($obj->label); |
|
277 | + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
278 | + $import_extrafield_sample[$fieldname]=$fieldlabel; |
|
279 | + } |
|
280 | 280 | } |
281 | 281 | // End add extra fields |
282 | 282 | $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | 'pr.price'=>"100",'pr.price_ttc'=>"110", |
339 | 339 | 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", |
340 | 340 | 'pr.tva_tx'=>'20', |
341 | - 'pr.recuperableonly'=>'0', |
|
341 | + 'pr.recuperableonly'=>'0', |
|
342 | 342 | 'pr.date_price'=>'2013-04-10'); |
343 | 343 | } |
344 | 344 | |
345 | 345 | if (! empty($conf->global->MAIN_MULTILANGS)) |
346 | 346 | { |
347 | - $r++; |
|
347 | + $r++; |
|
348 | 348 | /* FIXME Must be a dedicated import profil. Not working yet |
349 | 349 | $this->import_code[$r]=$this->rights_class.'_multiprice'; |
350 | 350 | $this->import_label[$r]="ProductTranslations"; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
379 | 379 | * It also creates data directories |
380 | 380 | * |
381 | - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
|
381 | + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
|
382 | 382 | * @return int 1 if OK, 0 if KO |
383 | 383 | */ |
384 | 384 | function init($options='') |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * \ingroup produit |
30 | 30 | * \brief File to describe module to manage catalog of predefined products |
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 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->family = "products"; |
53 | 53 | $this->module_position = 20; |
54 | 54 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
55 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
56 | 56 | $this->description = "Product management"; |
57 | 57 | |
58 | 58 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | |
61 | 61 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
62 | 62 | $this->special = 0; |
63 | - $this->picto='product'; |
|
63 | + $this->picto = 'product'; |
|
64 | 64 | |
65 | 65 | // Data directories to create when module is enabled |
66 | 66 | $this->dirs = array("/product/temp"); |
67 | 67 | |
68 | 68 | // Dependencies |
69 | 69 | $this->depends = array(); |
70 | - $this->requiredby = array("modStock","modBarcode","modProductBatch"); |
|
70 | + $this->requiredby = array("modStock", "modBarcode", "modProductBatch"); |
|
71 | 71 | |
72 | 72 | // Config pages |
73 | 73 | $this->config_page_url = array("product.php@product"); |
74 | - $this->langfiles = array("products","companies","stocks","bills"); |
|
74 | + $this->langfiles = array("products", "companies", "stocks", "bills"); |
|
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON"; |
81 | 81 | $this->const[$r][1] = "chaine"; |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | // Boxes |
95 | 95 | $this->boxes = array( |
96 | - 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), |
|
97 | - 1=>array('file'=>'box_produits_alerte_stock.php','enabledbydefaulton'=>''), |
|
98 | - 2=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') |
|
96 | + 0=>array('file'=>'box_produits.php', 'enabledbydefaulton'=>'Home'), |
|
97 | + 1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''), |
|
98 | + 2=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | // Permissions |
102 | 102 | $this->rights = array(); |
103 | 103 | $this->rights_class = 'produit'; |
104 | - $r=0; |
|
104 | + $r = 0; |
|
105 | 105 | |
106 | 106 | $this->rights[$r][0] = 31; // id de la permission |
107 | 107 | $this->rights[$r][1] = 'Lire les produits'; // libelle de la permission |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->rights[$r][4] = 'supprimer'; |
125 | 125 | $r++; |
126 | 126 | |
127 | - $this->rights[$r][0] = 38; // Must be same permission than in service module |
|
127 | + $this->rights[$r][0] = 38; // Must be same permission than in service module |
|
128 | 128 | $this->rights[$r][1] = 'Exporter les produits'; |
129 | 129 | $this->rights[$r][2] = 'r'; |
130 | 130 | $this->rights[$r][3] = 0; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // Menus |
135 | 135 | //------- |
136 | 136 | |
137 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
137 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
138 | 138 | /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert |
139 | 139 | $r=0; |
140 | 140 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
@@ -152,204 +152,204 @@ discard block |
||
152 | 152 | |
153 | 153 | // Exports |
154 | 154 | //-------- |
155 | - $r=0; |
|
155 | + $r = 0; |
|
156 | 156 | |
157 | 157 | $r++; |
158 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
159 | - $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
160 | - $this->export_permission[$r]=array(array("produit","export")); |
|
161 | - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
|
162 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; |
|
163 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
164 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
165 | - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin')); |
|
166 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
167 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); |
|
168 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); |
|
169 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
170 | - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
|
171 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
172 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
173 | - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric')); |
|
174 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); |
|
175 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); |
|
176 | - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
177 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); |
|
178 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); |
|
179 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); |
|
180 | - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'company','pf.ref_fourn'=>'product','pf.unitprice'=>'product')); |
|
181 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); |
|
182 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
158 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
159 | + $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
160 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
161 | + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.weight'=>"Weight", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'); |
|
162 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; |
|
163 | + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
164 | + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
165 | + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.unitprice'=>'BuyingPrice', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin')); |
|
166 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); |
|
167 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); |
|
168 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); |
|
169 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
170 | + $this->export_TypeFields_array[$r] = array('p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.note'=>"Text", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.weight'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.datec'=>'Date', 'p.tms'=>'Date'); |
|
171 | + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); |
|
172 | + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); |
|
173 | + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric')); |
|
174 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); |
|
175 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); |
|
176 | + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
177 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); |
|
178 | + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); |
|
179 | + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); |
|
180 | + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'company', 'pf.ref_fourn'=>'product', 'pf.unitprice'=>'product')); |
|
181 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); |
|
182 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; |
|
183 | 183 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
184 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); |
|
185 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
186 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
187 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
188 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
189 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
|
190 | - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
191 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
192 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
193 | - |
|
194 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
184 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); |
|
185 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
186 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
187 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
188 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
189 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
|
190 | + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
191 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
192 | + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
193 | + |
|
194 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
195 | 195 | { |
196 | 196 | // Exports product multiprice |
197 | 197 | $r++; |
198 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
199 | - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
200 | - $this->export_permission[$r]=array(array("produit","export")); |
|
201 | - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", |
|
202 | - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", |
|
203 | - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
204 | - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
198 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
199 | + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
200 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
201 | + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", |
|
202 | + 'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel", |
|
203 | + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
204 | + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
205 | 205 | 'pr.tva_tx'=>'PriceLevelVATRate', |
206 | 206 | 'pr.date_price'=>'DateCreation'); |
207 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; |
|
207 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; |
|
208 | 208 | //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
209 | - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", |
|
210 | - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", |
|
209 | + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", |
|
210 | + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", |
|
211 | 211 | 'pr.price_ttc'=>"product", |
212 | - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", |
|
212 | + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", |
|
213 | 213 | 'pr.tva_tx'=>'product', |
214 | 214 | 'pr.recuperableonly'=>'product', |
215 | 215 | 'pr.date_price'=>"product"); |
216 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
217 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
218 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; |
|
219 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
216 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
217 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
218 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; |
|
219 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
220 | 220 | } |
221 | 221 | |
222 | - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
222 | + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
223 | 223 | { |
224 | 224 | $r++; |
225 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
226 | - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
227 | - $this->export_permission[$r]=array(array("produit","export")); |
|
228 | - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
|
229 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
230 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
231 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); |
|
232 | - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
|
233 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
234 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
235 | - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); |
|
236 | - $this->export_entities_array[$r]=array('p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct",'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct",'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct','p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct",'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct"); |
|
237 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
238 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
239 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); |
|
240 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
|
225 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
226 | + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
227 | + $this->export_permission[$r] = array(array("produit", "export")); |
|
228 | + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.weight'=>"Weight", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'); |
|
229 | + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
230 | + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
231 | + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); |
|
232 | + $this->export_TypeFields_array[$r] = array('p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.note'=>"Text", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.weight'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.datec'=>'Date', 'p.tms'=>'Date'); |
|
233 | + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); |
|
234 | + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); |
|
235 | + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); |
|
236 | + $this->export_entities_array[$r] = array('p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_buy'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct"); |
|
237 | + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); |
|
238 | + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); |
|
239 | + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); |
|
240 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; |
|
241 | 241 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
242 | - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); |
|
243 | - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); |
|
244 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
245 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
246 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
247 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
248 | - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
249 | - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
242 | + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); |
|
243 | + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); |
|
244 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
245 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; |
|
246 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; |
|
247 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; |
|
248 | + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
|
249 | + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | // Imports |
253 | 253 | //-------- |
254 | - $r=0; |
|
254 | + $r = 0; |
|
255 | 255 | |
256 | 256 | $r++; |
257 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
258 | - $this->import_label[$r]="Products"; // Translation key |
|
259 | - $this->import_icon[$r]=$this->picto; |
|
260 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
261 | - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); |
|
262 | - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id |
|
263 | - $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); |
|
264 | - if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
265 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
266 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); |
|
267 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
268 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
269 | - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
270 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
257 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
258 | + $this->import_label[$r] = "Products"; // Translation key |
|
259 | + $this->import_icon[$r] = $this->picto; |
|
260 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
261 | + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); |
|
262 | + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id |
|
263 | + $this->import_fields_array[$r] = array('p.ref'=>"Ref*", 'p.label'=>"Label*", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.weight'=>"Weight", 'p.duration'=>"Duration", 'p.customcode'=>'CustomCode', 'p.price'=>"SellingPriceHT", 'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*", 'p.tobuy'=>"OnBuy*", 'p.fk_product_type'=>"Type*", 'p.finished'=>'Nature', 'p.datec'=>'DateCreation'); |
|
264 | + if (!empty($conf->stock->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); |
|
265 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); |
|
266 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); |
|
267 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
268 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
269 | + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); |
|
270 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
271 | 271 | // Add extra fields |
272 | - $import_extrafield_sample=array(); |
|
273 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.')'; |
|
274 | - $resql=$this->db->query($sql); |
|
272 | + $import_extrafield_sample = array(); |
|
273 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.')'; |
|
274 | + $resql = $this->db->query($sql); |
|
275 | 275 | if ($resql) // This can fail when class is used on old database (during migration for example) |
276 | 276 | { |
277 | - while ($obj=$this->db->fetch_object($resql)) |
|
277 | + while ($obj = $this->db->fetch_object($resql)) |
|
278 | 278 | { |
279 | - $fieldname='extra.'.$obj->name; |
|
280 | - $fieldlabel=ucfirst($obj->label); |
|
281 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
282 | - $import_extrafield_sample[$fieldname]=$fieldlabel; |
|
279 | + $fieldname = 'extra.'.$obj->name; |
|
280 | + $fieldlabel = ucfirst($obj->label); |
|
281 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
282 | + $import_extrafield_sample[$fieldname] = $fieldlabel; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | // End add extra fields |
286 | - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
287 | - $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','p.recuperableonly'=>'^[0|1]$'); |
|
288 | - $import_sample=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); |
|
289 | - $this->import_examplevalues_array[$r]=array_merge($import_sample,$import_extrafield_sample); |
|
290 | - $this->import_updatekeys_array[$r]=array('p.ref'=>'Ref','p.barcode'=>'BarCode'); |
|
286 | + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
287 | + $this->import_regex_array[$r] = array('p.ref'=>'[^ ]', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'p.recuperableonly'=>'^[0|1]$'); |
|
288 | + $import_sample = array('p.ref'=>"PREF123456", 'p.label'=>"My product", 'p.description'=>"This is a description example for record", 'p.note'=>"Some note", 'p.price'=>"100", 'p.price_ttc'=>"110", 'p.tva_tx'=>'10', 'p.tosell'=>"0 or 1", 'p.tobuy'=>"0 or 1", 'p.fk_product_type'=>"0 for product/1 for service", 'p.finished'=>'', 'p.duration'=>"1y", 'p.datec'=>'2008-12-31', 'p.recuperableonly'=>'0 or 1'); |
|
289 | + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); |
|
290 | + $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref', 'p.barcode'=>'BarCode'); |
|
291 | 291 | |
292 | - if (! empty($conf->fournisseur->enabled)) |
|
292 | + if (!empty($conf->fournisseur->enabled)) |
|
293 | 293 | { |
294 | 294 | // Import suppliers prices (note: this code is duplicated into module service) |
295 | 295 | $r++; |
296 | - $this->import_code[$r]=$this->rights_class.'_supplierprices'; |
|
297 | - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key |
|
298 | - $this->import_icon[$r]=$this->picto; |
|
299 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
300 | - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); |
|
301 | - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); |
|
302 | - $this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*", |
|
296 | + $this->import_code[$r] = $this->rights_class.'_supplierprices'; |
|
297 | + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key |
|
298 | + $this->import_icon[$r] = $this->picto; |
|
299 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
300 | + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); |
|
301 | + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); |
|
302 | + $this->import_fields_array[$r] = array('sp.fk_product'=>"ProductOrService*", |
|
303 | 303 | 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', |
304 | 304 | 'sp.price'=>"PriceQtyMinHT*", |
305 | - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
|
305 | + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
|
306 | 306 | 'sp.remise_percent'=>'DiscountQtyMin' |
307 | 307 | ); |
308 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); |
|
309 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
310 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
308 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'NPR')); |
|
309 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
310 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
311 | 311 | |
312 | - $this->import_convertvalue_array[$r]=array( |
|
313 | - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
314 | - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') |
|
312 | + $this->import_convertvalue_array[$r] = array( |
|
313 | + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), |
|
314 | + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') |
|
315 | 315 | ); |
316 | - $this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456", |
|
317 | - 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', |
|
316 | + $this->import_examplevalues_array[$r] = array('sp.fk_product'=>"PREF123456", |
|
317 | + 'sp.fk_soc'=>"My Supplier", 'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', |
|
318 | 318 | 'sp.price'=>"50", |
319 | 319 | 'sp.unitprice'=>'50', |
320 | 320 | 'sp.remise_percent'=>'0' |
321 | 321 | ); |
322 | - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef'); |
|
322 | + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef'); |
|
323 | 323 | } |
324 | 324 | |
325 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
325 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
326 | 326 | { |
327 | 327 | // Import product multiprice |
328 | 328 | $r++; |
329 | - $this->import_code[$r]=$this->rights_class.'_multiprice'; |
|
330 | - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key |
|
331 | - $this->import_icon[$r]=$this->picto; |
|
332 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
333 | - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); |
|
334 | - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id |
|
335 | - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*", |
|
336 | - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", |
|
337 | - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
338 | - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
329 | + $this->import_code[$r] = $this->rights_class.'_multiprice'; |
|
330 | + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key |
|
331 | + $this->import_icon[$r] = $this->picto; |
|
332 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
333 | + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); |
|
334 | + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id |
|
335 | + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductRowid*", |
|
336 | + 'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel", |
|
337 | + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", |
|
338 | + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
|
339 | 339 | 'pr.tva_tx'=>'PriceLevelVATRate', |
340 | 340 | 'pr.date_price'=>'DateCreation*'); |
341 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); |
|
342 | - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); |
|
343 | - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", |
|
344 | - 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", |
|
345 | - 'pr.price'=>"100",'pr.price_ttc'=>"110", |
|
346 | - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", |
|
341 | + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); |
|
342 | + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); |
|
343 | + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"1", |
|
344 | + 'pr.price_base_type'=>"HT", 'pr.price_level'=>"1", |
|
345 | + 'pr.price'=>"100", 'pr.price_ttc'=>"110", |
|
346 | + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", |
|
347 | 347 | 'pr.tva_tx'=>'20', |
348 | 348 | 'pr.recuperableonly'=>'0', |
349 | 349 | 'pr.date_price'=>'2013-04-10'); |
350 | 350 | } |
351 | 351 | |
352 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
352 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
353 | 353 | { |
354 | 354 | $r++; |
355 | 355 | /* FIXME Must be a dedicated import profil. Not working yet |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
389 | 389 | * @return int 1 if OK, 0 if KO |
390 | 390 | */ |
391 | - function init($options='') |
|
391 | + function init($options = '') |
|
392 | 392 | { |
393 | 393 | $this->remove($options); |
394 | 394 | |
395 | 395 | $sql = array(); |
396 | 396 | |
397 | - return $this->_init($sql,$options); |
|
397 | + return $this->_init($sql, $options); |
|
398 | 398 | } |
399 | 399 | } |
@@ -159,37 +159,84 @@ discard block |
||
159 | 159 | $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) |
160 | 160 | $this->export_permission[$r]=array(array("produit","export")); |
161 | 161 | $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
162 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; |
|
163 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
164 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
165 | - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin')); |
|
166 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
167 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); |
|
168 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); |
|
169 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
162 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
163 | + $this->export_fields_array[$r]['p.recuperableonly']='NPR'; |
|
164 | + } |
|
165 | + if (! empty($conf->stock->enabled)) { |
|
166 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
167 | + } |
|
168 | + if (! empty($conf->barcode->enabled)) { |
|
169 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
170 | + } |
|
171 | + if (! empty($conf->fournisseur->enabled)) { |
|
172 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin')); |
|
173 | + } |
|
174 | + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) { |
|
175 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
176 | + } |
|
177 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
178 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); |
|
179 | + } |
|
180 | + if (! empty($conf->global->MAIN_MULTILANGS)) { |
|
181 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); |
|
182 | + } |
|
183 | + if (! empty($conf->global->PRODUCT_USE_UNITS)) { |
|
184 | + $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
185 | + } |
|
170 | 186 | $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
171 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
172 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
173 | - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric')); |
|
174 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); |
|
175 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); |
|
187 | + if (! empty($conf->stock->enabled)) { |
|
188 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
189 | + } |
|
190 | + if (! empty($conf->barcode->enabled)) { |
|
191 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
192 | + } |
|
193 | + if (! empty($conf->fournisseur->enabled)) { |
|
194 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric')); |
|
195 | + } |
|
196 | + if (! empty($conf->global->MAIN_MULTILANGS)) { |
|
197 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); |
|
198 | + } |
|
199 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
200 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); |
|
201 | + } |
|
176 | 202 | $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
177 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); |
|
178 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); |
|
179 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); |
|
180 | - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'company','pf.ref_fourn'=>'product','pf.unitprice'=>'product')); |
|
181 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); |
|
203 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
204 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); |
|
205 | + } |
|
206 | + if (! empty($conf->stock->enabled)) { |
|
207 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); |
|
208 | + } |
|
209 | + if (! empty($conf->barcode->enabled)) { |
|
210 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); |
|
211 | + } |
|
212 | + if (! empty($conf->fournisseur->enabled)) { |
|
213 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'company','pf.ref_fourn'=>'product','pf.unitprice'=>'product')); |
|
214 | + } |
|
215 | + if (! empty($conf->global->MAIN_MULTILANGS)) { |
|
216 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); |
|
217 | + } |
|
182 | 218 | $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
183 | 219 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
184 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); |
|
220 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
221 | + $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); |
|
222 | + } |
|
185 | 223 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
186 | 224 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
187 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
188 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
225 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
226 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; |
|
227 | + } |
|
228 | + if (! empty($conf->global->MAIN_MULTILANGS)) { |
|
229 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; |
|
230 | + } |
|
189 | 231 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
190 | - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
232 | + if (! empty($conf->fournisseur->enabled)) { |
|
233 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
234 | + } |
|
191 | 235 | $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; |
192 | - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
236 | + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) { |
|
237 | + $this->export_sql_order[$r] =' GROUP BY p.rowid'; |
|
238 | + } |
|
239 | + // FIXME The group by used a generic value to say "all fields in select except function fields" |
|
193 | 240 | |
194 | 241 | if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
195 | 242 | { |
@@ -204,7 +251,9 @@ discard block |
||
204 | 251 | 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
205 | 252 | 'pr.tva_tx'=>'PriceLevelVATRate', |
206 | 253 | 'pr.date_price'=>'DateCreation'); |
207 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; |
|
254 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
255 | + $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; |
|
256 | + } |
|
208 | 257 | //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
209 | 258 | $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", |
210 | 259 | 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", |
@@ -226,16 +275,28 @@ discard block |
||
226 | 275 | $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) |
227 | 276 | $this->export_permission[$r]=array(array("produit","export")); |
228 | 277 | $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
229 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
230 | - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
278 | + if (! empty($conf->stock->enabled)) { |
|
279 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
280 | + } |
|
281 | + if (! empty($conf->barcode->enabled)) { |
|
282 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
283 | + } |
|
231 | 284 | $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); |
232 | 285 | $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); |
233 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
234 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
286 | + if (! empty($conf->stock->enabled)) { |
|
287 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); |
|
288 | + } |
|
289 | + if (! empty($conf->barcode->enabled)) { |
|
290 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
291 | + } |
|
235 | 292 | $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); |
236 | 293 | $this->export_entities_array[$r]=array('p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct",'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct",'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct','p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct",'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct"); |
237 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
238 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
294 | + if (! empty($conf->stock->enabled)) { |
|
295 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); |
|
296 | + } |
|
297 | + if (! empty($conf->barcode->enabled)) { |
|
298 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); |
|
299 | + } |
|
239 | 300 | $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); |
240 | 301 | $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; |
241 | 302 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
@@ -261,22 +322,38 @@ discard block |
||
261 | 322 | $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); |
262 | 323 | $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id |
263 | 324 | $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); |
264 | - if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
265 | - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
266 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); |
|
267 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
268 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
269 | - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
270 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
325 | + if (! empty($conf->stock->enabled)) { |
|
326 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); |
|
327 | + } |
|
328 | + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) { |
|
329 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); |
|
330 | + } |
|
331 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
332 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); |
|
333 | + } |
|
334 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) { |
|
335 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); |
|
336 | + } |
|
337 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) { |
|
338 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); |
|
339 | + } |
|
340 | + if (! empty($conf->barcode->enabled)) { |
|
341 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
342 | + } |
|
343 | + if (! empty($conf->global->PRODUCT_USE_UNITS)) { |
|
344 | + $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
345 | + } |
|
271 | 346 | // Add extra fields |
272 | 347 | $import_extrafield_sample=array(); |
273 | 348 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.')'; |
274 | 349 | $resql=$this->db->query($sql); |
275 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
350 | + if ($resql) { |
|
351 | + // This can fail when class is used on old database (during migration for example) |
|
276 | 352 | { |
277 | 353 | while ($obj=$this->db->fetch_object($resql)) |
278 | 354 | { |
279 | 355 | $fieldname='extra.'.$obj->name; |
356 | + } |
|
280 | 357 | $fieldlabel=ucfirst($obj->label); |
281 | 358 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
282 | 359 | $import_extrafield_sample[$fieldname]=$fieldlabel; |
@@ -305,9 +382,15 @@ discard block |
||
305 | 382 | 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
306 | 383 | 'sp.remise_percent'=>'DiscountQtyMin' |
307 | 384 | ); |
308 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); |
|
309 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
310 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
385 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
386 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); |
|
387 | + } |
|
388 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) { |
|
389 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
390 | + } |
|
391 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) { |
|
392 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
393 | + } |
|
311 | 394 | |
312 | 395 | $this->import_convertvalue_array[$r]=array( |
313 | 396 | 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
@@ -338,7 +421,9 @@ discard block |
||
338 | 421 | 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", |
339 | 422 | 'pr.tva_tx'=>'PriceLevelVATRate', |
340 | 423 | 'pr.date_price'=>'DateCreation*'); |
341 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); |
|
424 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
425 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); |
|
426 | + } |
|
342 | 427 | $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); |
343 | 428 | $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", |
344 | 429 | 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of geoipmaxmind module descriptor |
24 | 24 | */ |
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 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // It is used to group modules in module setup page |
47 | 47 | $this->family = "technic"; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
51 | 51 | $this->description = "GeoIP Maxmind conversions capabilities"; |
52 | 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | // Dependencies |
70 | 70 | $this->depends = array(); |
71 | 71 | $this->requiredby = array(); |
72 | - $this->phpmin = array(4,2,0); |
|
72 | + $this->phpmin = array(4, 2, 0); |
|
73 | 73 | $this->phpmax = array(); |
74 | - $this->need_dolibarr_version = array(2,7,-1); // Minimum version of Dolibarr required by module |
|
74 | + $this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module |
|
75 | 75 | $this->need_javascript_ajax = 1; |
76 | 76 | |
77 | 77 | // Constants |
@@ -83,6 +83,6 @@ discard block |
||
83 | 83 | // Permissions |
84 | 84 | $this->rights = array(); |
85 | 85 | $this->rights_class = 'geoipmaxmind'; |
86 | - $r=0; |
|
86 | + $r = 0; |
|
87 | 87 | } |
88 | 88 | } |