Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/modUser.class.php 1 patch
Indentation   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -33,284 +33,284 @@
 block discarded – undo
33 33
 class modUser extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		global $conf;
44
-
45
-		$this->db = $db;
46
-		$this->numero = 0;
47
-
48
-		$this->family = "hr";		// Family for module (or "base" if core module)
49
-		$this->module_position = '10';
50
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->name = preg_replace('/^mod/i','',get_class($this));
52
-		$this->description = "Gestion des utilisateurs (requis)";
53
-
54
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55
-		$this->version = 'dolibarr';
56
-
57
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58
-		$this->picto='group';
59
-
60
-		// Data directories to create when module is enabled
61
-		$this->dirs = array("/users/temp");
62
-
63
-		// Config pages
64
-		$this->config_page_url = array("user.php");
65
-
66
-		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
-		$this->langfiles = array("main","users","companies","members",'salaries');
73
-		$this->always_enabled = true;	// Can't be disabled
74
-
75
-		// Constants
76
-		$this->const = array();
77
-
78
-		// Boxes
79
-		$this->boxes = array(
80
-		    0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
81
-		);
82
-
83
-		// Permissions
84
-		$this->rights = array();
85
-		$this->rights_class = 'user';
86
-		$this->rights_admin_allowed = 1;	// Admin is always granted of permission (even when module is disabled)
87
-		$r=0;
88
-
89
-		$r++;
90
-		$this->rights[$r][0] = 251;
91
-		$this->rights[$r][1] = 'Consulter les autres utilisateurs';
92
-		$this->rights[$r][2] = 'r';
93
-		$this->rights[$r][3] = 0;
94
-		$this->rights[$r][4] = 'user';
95
-		$this->rights[$r][5] = 'lire';
96
-
97
-		$r++;
98
-		$this->rights[$r][0] = 252;
99
-		$this->rights[$r][1] = 'Consulter les permissions des autres utilisateurs';
100
-		$this->rights[$r][2] = 'r';
101
-		$this->rights[$r][3] = 0;
102
-		$this->rights[$r][4] = 'user_advance';
103
-		$this->rights[$r][5] = 'readperms';
104
-
105
-		$r++;
106
-		$this->rights[$r][0] = 253;
107
-		$this->rights[$r][1] = 'Creer/modifier utilisateurs internes et externes';
108
-		$this->rights[$r][2] = 'w';
109
-		$this->rights[$r][3] = 0;
110
-		$this->rights[$r][4] = 'user';
111
-		$this->rights[$r][5] = 'creer';
112
-
113
-		$r++;
114
-		$this->rights[$r][0] = 254;
115
-		$this->rights[$r][1] = 'Creer/modifier utilisateurs externes seulement';
116
-		$this->rights[$r][2] = 'w';
117
-		$this->rights[$r][3] = 0;
118
-		$this->rights[$r][4] = 'user_advance';
119
-		$this->rights[$r][5] = 'write';
120
-
121
-		$r++;
122
-		$this->rights[$r][0] = 255;
123
-		$this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';
124
-		$this->rights[$r][2] = 'w';
125
-		$this->rights[$r][3] = 0;
126
-		$this->rights[$r][4] = 'user';
127
-		$this->rights[$r][5] = 'password';
128
-
129
-		$r++;
130
-		$this->rights[$r][0] = 256;
131
-		$this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';
132
-		$this->rights[$r][2] = 'd';
133
-		$this->rights[$r][3] = 0;
134
-		$this->rights[$r][4] = 'user';
135
-		$this->rights[$r][5] = 'supprimer';
136
-
137
-		$r++;
138
-		$this->rights[$r][0] = 341;
139
-		$this->rights[$r][1] = 'Consulter ses propres permissions';
140
-		$this->rights[$r][2] = 'r';
141
-		$this->rights[$r][3] = 0;
142
-		$this->rights[$r][4] = 'self_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
143
-		$this->rights[$r][5] = 'readperms';
144
-
145
-		$r++;
146
-		$this->rights[$r][0] = 342;
147
-		$this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';
148
-		$this->rights[$r][2] = 'w';
149
-		$this->rights[$r][3] = 0;
150
-		$this->rights[$r][4] = 'self';
151
-		$this->rights[$r][5] = 'creer';
152
-
153
-		$r++;
154
-		$this->rights[$r][0] = 343;
155
-		$this->rights[$r][1] = 'Modifier son propre mot de passe';
156
-		$this->rights[$r][2] = 'w';
157
-		$this->rights[$r][3] = 0;
158
-		$this->rights[$r][4] = 'self';
159
-		$this->rights[$r][5] = 'password';
160
-
161
-		$r++;
162
-		$this->rights[$r][0] = 344;
163
-		$this->rights[$r][1] = 'Modifier ses propres permissions';
164
-		$this->rights[$r][2] = 'w';
165
-		$this->rights[$r][3] = 0;
166
-		$this->rights[$r][4] = 'self_advance';          // Visible if option MAIN_USE_ADVANCED_PERMS is on
167
-		$this->rights[$r][5] = 'writeperms';
168
-
169
-		$r++;
170
-		$this->rights[$r][0] = 351;
171
-		$this->rights[$r][1] = 'Consulter les groupes';
172
-		$this->rights[$r][2] = 'r';
173
-		$this->rights[$r][3] = 0;
174
-		$this->rights[$r][4] = 'group_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
175
-		$this->rights[$r][5] = 'read';
176
-
177
-		$r++;
178
-		$this->rights[$r][0] = 352;
179
-		$this->rights[$r][1] = 'Consulter les permissions des groupes';
180
-		$this->rights[$r][2] = 'r';
181
-		$this->rights[$r][3] = 0;
182
-		$this->rights[$r][4] = 'group_advance';       // Visible if option MAIN_USE_ADVANCED_PERMS is on
183
-		$this->rights[$r][5] = 'readperms';
184
-
185
-		$r++;
186
-		$this->rights[$r][0] = 353;
187
-		$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
188
-		$this->rights[$r][2] = 'w';
189
-		$this->rights[$r][3] = 0;
190
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
191
-		$this->rights[$r][5] = 'write';
192
-
193
-		$r++;
194
-		$this->rights[$r][0] = 354;
195
-		$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
196
-		$this->rights[$r][2] = 'd';
197
-		$this->rights[$r][3] = 0;
198
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
199
-		$this->rights[$r][5] = 'delete';
200
-
201
-		$r++;
202
-		$this->rights[$r][0] = 358;
203
-		$this->rights[$r][1] = 'Exporter les utilisateurs';
204
-		$this->rights[$r][2] = 'r';
205
-		$this->rights[$r][3] = 0;
206
-		$this->rights[$r][4] = 'user';
207
-		$this->rights[$r][5] = 'export';
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        global $conf;
44
+
45
+        $this->db = $db;
46
+        $this->numero = 0;
47
+
48
+        $this->family = "hr";		// Family for module (or "base" if core module)
49
+        $this->module_position = '10';
50
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
+        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        $this->description = "Gestion des utilisateurs (requis)";
53
+
54
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55
+        $this->version = 'dolibarr';
56
+
57
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58
+        $this->picto='group';
59
+
60
+        // Data directories to create when module is enabled
61
+        $this->dirs = array("/users/temp");
62
+
63
+        // Config pages
64
+        $this->config_page_url = array("user.php");
65
+
66
+        // Dependencies
67
+        $this->hidden = false;			// A condition to hide module
68
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
70
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
+        $this->langfiles = array("main","users","companies","members",'salaries');
73
+        $this->always_enabled = true;	// Can't be disabled
74
+
75
+        // Constants
76
+        $this->const = array();
77
+
78
+        // Boxes
79
+        $this->boxes = array(
80
+            0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
81
+        );
82
+
83
+        // Permissions
84
+        $this->rights = array();
85
+        $this->rights_class = 'user';
86
+        $this->rights_admin_allowed = 1;	// Admin is always granted of permission (even when module is disabled)
87
+        $r=0;
88
+
89
+        $r++;
90
+        $this->rights[$r][0] = 251;
91
+        $this->rights[$r][1] = 'Consulter les autres utilisateurs';
92
+        $this->rights[$r][2] = 'r';
93
+        $this->rights[$r][3] = 0;
94
+        $this->rights[$r][4] = 'user';
95
+        $this->rights[$r][5] = 'lire';
96
+
97
+        $r++;
98
+        $this->rights[$r][0] = 252;
99
+        $this->rights[$r][1] = 'Consulter les permissions des autres utilisateurs';
100
+        $this->rights[$r][2] = 'r';
101
+        $this->rights[$r][3] = 0;
102
+        $this->rights[$r][4] = 'user_advance';
103
+        $this->rights[$r][5] = 'readperms';
104
+
105
+        $r++;
106
+        $this->rights[$r][0] = 253;
107
+        $this->rights[$r][1] = 'Creer/modifier utilisateurs internes et externes';
108
+        $this->rights[$r][2] = 'w';
109
+        $this->rights[$r][3] = 0;
110
+        $this->rights[$r][4] = 'user';
111
+        $this->rights[$r][5] = 'creer';
112
+
113
+        $r++;
114
+        $this->rights[$r][0] = 254;
115
+        $this->rights[$r][1] = 'Creer/modifier utilisateurs externes seulement';
116
+        $this->rights[$r][2] = 'w';
117
+        $this->rights[$r][3] = 0;
118
+        $this->rights[$r][4] = 'user_advance';
119
+        $this->rights[$r][5] = 'write';
120
+
121
+        $r++;
122
+        $this->rights[$r][0] = 255;
123
+        $this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';
124
+        $this->rights[$r][2] = 'w';
125
+        $this->rights[$r][3] = 0;
126
+        $this->rights[$r][4] = 'user';
127
+        $this->rights[$r][5] = 'password';
128
+
129
+        $r++;
130
+        $this->rights[$r][0] = 256;
131
+        $this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';
132
+        $this->rights[$r][2] = 'd';
133
+        $this->rights[$r][3] = 0;
134
+        $this->rights[$r][4] = 'user';
135
+        $this->rights[$r][5] = 'supprimer';
136
+
137
+        $r++;
138
+        $this->rights[$r][0] = 341;
139
+        $this->rights[$r][1] = 'Consulter ses propres permissions';
140
+        $this->rights[$r][2] = 'r';
141
+        $this->rights[$r][3] = 0;
142
+        $this->rights[$r][4] = 'self_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
143
+        $this->rights[$r][5] = 'readperms';
144
+
145
+        $r++;
146
+        $this->rights[$r][0] = 342;
147
+        $this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';
148
+        $this->rights[$r][2] = 'w';
149
+        $this->rights[$r][3] = 0;
150
+        $this->rights[$r][4] = 'self';
151
+        $this->rights[$r][5] = 'creer';
152
+
153
+        $r++;
154
+        $this->rights[$r][0] = 343;
155
+        $this->rights[$r][1] = 'Modifier son propre mot de passe';
156
+        $this->rights[$r][2] = 'w';
157
+        $this->rights[$r][3] = 0;
158
+        $this->rights[$r][4] = 'self';
159
+        $this->rights[$r][5] = 'password';
160
+
161
+        $r++;
162
+        $this->rights[$r][0] = 344;
163
+        $this->rights[$r][1] = 'Modifier ses propres permissions';
164
+        $this->rights[$r][2] = 'w';
165
+        $this->rights[$r][3] = 0;
166
+        $this->rights[$r][4] = 'self_advance';          // Visible if option MAIN_USE_ADVANCED_PERMS is on
167
+        $this->rights[$r][5] = 'writeperms';
168
+
169
+        $r++;
170
+        $this->rights[$r][0] = 351;
171
+        $this->rights[$r][1] = 'Consulter les groupes';
172
+        $this->rights[$r][2] = 'r';
173
+        $this->rights[$r][3] = 0;
174
+        $this->rights[$r][4] = 'group_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
175
+        $this->rights[$r][5] = 'read';
176
+
177
+        $r++;
178
+        $this->rights[$r][0] = 352;
179
+        $this->rights[$r][1] = 'Consulter les permissions des groupes';
180
+        $this->rights[$r][2] = 'r';
181
+        $this->rights[$r][3] = 0;
182
+        $this->rights[$r][4] = 'group_advance';       // Visible if option MAIN_USE_ADVANCED_PERMS is on
183
+        $this->rights[$r][5] = 'readperms';
184
+
185
+        $r++;
186
+        $this->rights[$r][0] = 353;
187
+        $this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
188
+        $this->rights[$r][2] = 'w';
189
+        $this->rights[$r][3] = 0;
190
+        $this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
191
+        $this->rights[$r][5] = 'write';
192
+
193
+        $r++;
194
+        $this->rights[$r][0] = 354;
195
+        $this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
196
+        $this->rights[$r][2] = 'd';
197
+        $this->rights[$r][3] = 0;
198
+        $this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
199
+        $this->rights[$r][5] = 'delete';
200
+
201
+        $r++;
202
+        $this->rights[$r][0] = 358;
203
+        $this->rights[$r][1] = 'Exporter les utilisateurs';
204
+        $this->rights[$r][2] = 'r';
205
+        $this->rights[$r][3] = 0;
206
+        $this->rights[$r][4] = 'user';
207
+        $this->rights[$r][5] = 'export';
208 208
 
209 209
 
210 210
         // Menus
211 211
         $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
212 212
 
213 213
 
214
-		// Exports
215
-		$r=0;
216
-
217
-		$r++;
218
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
219
-		$this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
220
-		$this->export_permission[$r]=array(array("user","user","export"));
221
-		$this->export_fields_array[$r]=array(
222
-			'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",
223
-			'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",
224
-			'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion',
225
-			'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"
226
-		);
227
-		$this->export_TypeFields_array[$r]=array(
228
-			'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text',
229
-			'u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date',
230
-			'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"
231
-		);
232
-		$this->export_entities_array[$r]=array(
233
-			'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user',
234
-			'u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",
235
-			'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"
236
-		);
214
+        // Exports
215
+        $r=0;
216
+
217
+        $r++;
218
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
219
+        $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
220
+        $this->export_permission[$r]=array(array("user","user","export"));
221
+        $this->export_fields_array[$r]=array(
222
+            'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",
223
+            'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",
224
+            'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion',
225
+            'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"
226
+        );
227
+        $this->export_TypeFields_array[$r]=array(
228
+            'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text',
229
+            'u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date',
230
+            'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"
231
+        );
232
+        $this->export_entities_array[$r]=array(
233
+            'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user',
234
+            'u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",
235
+            'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"
236
+        );
237 237
         if (empty($conf->adherent->enabled))
238 238
         {
239 239
             unset($this->export_fields_array[$r]['u.fk_member']);
240 240
             unset($this->export_entities_array[$r]['u.fk_member']);
241 241
         }
242
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
243
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
244
-		$this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
245
-
246
-		// Imports
247
-		$r=0;
248
-
249
-		// Import list of users attributes
250
-		$r++;
251
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
252
-		$this->import_label[$r]='ImportDataset_user_1';
253
-		$this->import_icon[$r]='user';
254
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
255
-		$this->import_tables_array[$r]=array('u'=>MAIN_DB_PREFIX.'user','extra'=>MAIN_DB_PREFIX.'user_extrafields');	// List of tables to insert into (insert done in same order)
256
-		$this->import_fields_array[$r]=array(
257
-			'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"Job",'u.gender'=>"Gender",'u.login'=>"Login*",
258
-			'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
259
-			'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",
260
-			'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature','u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM',
261
-			'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey','u.datec'=>"DateCreation"
262
-		);
263
-		// Add extra fields
264
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
265
-		$resql=$this->db->query($sql);
266
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
267
-		{
268
-		    while ($obj=$this->db->fetch_object($resql))
269
-		    {
270
-		        $fieldname='extra.'.$obj->name;
271
-		        $fieldlabel=ucfirst($obj->label);
272
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
273
-		    }
274
-		}
275
-		// End add extra fields
276
-		$this->import_fieldshidden_array[$r]=array('u.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
277
-		$this->import_convertvalue_array[$r]=array(
278
-			'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
279
-		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
280
-		    'u.salary'=>array('rule'=>'numeric')
281
-		);
282
-		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
283
-		$this->import_regex_array[$r]=array(
284
-			'u.employee'=>'^[0|1]',
285
-			'u.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])?$'
286
-		);
287
-		$this->import_examplevalues_array[$r]=array(
288
-			'u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)",
289
-			'u.fk_soc'=>'0 (internal user) or company name (external user)','u.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'u.address'=>"61 jump street",
290
-			'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",
291
-			'u.email'=>"[email protected]",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00"
292
-		);
293
-		$this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login');
294
-	}
242
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
243
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
244
+        $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
245
+
246
+        // Imports
247
+        $r=0;
248
+
249
+        // Import list of users attributes
250
+        $r++;
251
+        $this->import_code[$r]=$this->rights_class.'_'.$r;
252
+        $this->import_label[$r]='ImportDataset_user_1';
253
+        $this->import_icon[$r]='user';
254
+        $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
255
+        $this->import_tables_array[$r]=array('u'=>MAIN_DB_PREFIX.'user','extra'=>MAIN_DB_PREFIX.'user_extrafields');	// List of tables to insert into (insert done in same order)
256
+        $this->import_fields_array[$r]=array(
257
+            'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"Job",'u.gender'=>"Gender",'u.login'=>"Login*",
258
+            'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
259
+            'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",
260
+            'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature','u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM',
261
+            'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey','u.datec'=>"DateCreation"
262
+        );
263
+        // Add extra fields
264
+        $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
265
+        $resql=$this->db->query($sql);
266
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
267
+        {
268
+            while ($obj=$this->db->fetch_object($resql))
269
+            {
270
+                $fieldname='extra.'.$obj->name;
271
+                $fieldlabel=ucfirst($obj->label);
272
+                $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
273
+            }
274
+        }
275
+        // End add extra fields
276
+        $this->import_fieldshidden_array[$r]=array('u.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
277
+        $this->import_convertvalue_array[$r]=array(
278
+            'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
279
+            'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
280
+            'u.salary'=>array('rule'=>'numeric')
281
+        );
282
+        //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
283
+        $this->import_regex_array[$r]=array(
284
+            'u.employee'=>'^[0|1]',
285
+            'u.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])?$'
286
+        );
287
+        $this->import_examplevalues_array[$r]=array(
288
+            'u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)",
289
+            'u.fk_soc'=>'0 (internal user) or company name (external user)','u.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'u.address'=>"61 jump street",
290
+            'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",
291
+            'u.email'=>"[email protected]",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00"
292
+        );
293
+        $this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login');
294
+    }
295 295
 
296 296
 
297 297
     /**
298
-	 *		Function called when module is enabled.
299
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
300
-	 *		It also creates data directories
301
-	 *
298
+     *		Function called when module is enabled.
299
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
300
+     *		It also creates data directories
301
+     *
302 302
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
303
-	 *      @return     int             	1 if OK, 0 if KO
303
+     *      @return     int             	1 if OK, 0 if KO
304 304
      */
305
-	function init($options='')
306
-	{
307
-		global $conf;
305
+    function init($options='')
306
+    {
307
+        global $conf;
308 308
 
309
-		// Permissions
310
-		$this->remove($options);
309
+        // Permissions
310
+        $this->remove($options);
311 311
 
312
-		$sql = array();
312
+        $sql = array();
313 313
 
314
-		return $this->_init($sql,$options);
315
-	}
314
+        return $this->_init($sql,$options);
315
+    }
316 316
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modWebServicesClient.class.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 {
32 32
 
33 33
     /**
34
-	 *   Constructor. Define names, constants, directories, boxes, permissions
35
-	 *
36
-	 *   @param      DoliDB		$db      Database handler
34
+     *   Constructor. Define names, constants, directories, boxes, permissions
35
+     *
36
+     *   @param      DoliDB		$db      Database handler
37 37
      */
38 38
     function __construct($db)
39 39
     {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
45 45
         $this->name = preg_replace('/^mod/i','',get_class($this));
46 46
         $this->description = "Enable the web service client to call external supplier web services";
47
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
47
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
48 48
         $this->version = 'experimental';
49 49
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
50 50
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 
60 60
         // Dependencies
61 61
         $this->hidden = false;			// A condition to hide module
62
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
63
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
64
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
65
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
62
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
63
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
64
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
65
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
66 66
         $this->langfiles = array("other");
67 67
 
68 68
         // Constants
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modCashDesk.class.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -30,115 +30,115 @@
 block discarded – undo
30 30
  */
31 31
 class modCashDesk extends DolibarrModules
32 32
 {
33
-	/**
34
-	 *   Constructor. Define names, constants, directories, boxes, permissions
35
-	 *
36
-	 *   @param      DoliDB		$db      Database handler
37
-	 */
38
-	function __construct($db)
39
-	{
40
-		$this->db = $db;
41
-
42
-		// Id for module (must be unique).
43
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).
44
-		$this->numero = 50100;
45
-		// Key text used to identify module (for permission, menus, etc...)
46
-		$this->rights_class = 'cashdesk';
47
-
48
-		$this->family = "portal";
49
-		$this->module_position = '55';
50
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->name = preg_replace('/^mod/i','',get_class($this));
52
-		$this->description = "CashDesk module";
53
-
54
-		$this->revision = '1.27';
55
-		$this->version = 'dolibarr';
56
-
57
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58
-		$this->picto = 'list';
59
-
60
-		// Data directories to create when module is enabled
61
-		$this->dirs = array();
62
-
63
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.
64
-		$this->config_page_url = array("cashdesk.php@cashdesk");
65
-
66
-		// Dependencies
67
-		$this->hidden = false;			            // A condition to hide module
68
-		$this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog');	// List of modules id that must be enabled if this module is enabled
69
-		$this->requiredby = array();			    // List of modules id to disable if this one is disabled
70
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
71
-		$this->need_dolibarr_version = array(2,4);	// Minimum version of Dolibarr required by module
72
-		$this->langfiles = array("cashdesk");
73
-		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
74
-		//$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw');  // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
75
-
76
-		// Constants
77
-		$this->const = array();
78
-
79
-		// Boxes
80
-		$this->boxes = array();
81
-
82
-		// Permissions
83
-		$this->rights = array();
84
-		$r=0;
85
-
86
-		$r++;
87
-		$this->rights[$r][0] = 50101;
88
-		$this->rights[$r][1] = 'Use point of sale';
89
-		$this->rights[$r][2] = 'a';
90
-		$this->rights[$r][3] = 0;
91
-		$this->rights[$r][4] = 'use';
92
-
93
-		// Main menu entries
94
-		$this->menus = array();			// List of menus to add
95
-		$r=0;
96
-
97
-		// This is to declare the Top Menu entry:
98
-		$this->menu[$r]=array(	    'fk_menu'=>0,			// Put 0 if this is a top menu
99
-									'type'=>'top',			// This is a Top menu entry
100
-									'titre'=>'PointOfSaleShort',
101
-									'mainmenu'=>'cashdesk',
102
-									'url'=>'/cashdesk/index.php?user=__LOGIN__',
103
-									'langs'=>'cashdesk',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
104
-									'position'=>900,
33
+    /**
34
+     *   Constructor. Define names, constants, directories, boxes, permissions
35
+     *
36
+     *   @param      DoliDB		$db      Database handler
37
+     */
38
+    function __construct($db)
39
+    {
40
+        $this->db = $db;
41
+
42
+        // Id for module (must be unique).
43
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).
44
+        $this->numero = 50100;
45
+        // Key text used to identify module (for permission, menus, etc...)
46
+        $this->rights_class = 'cashdesk';
47
+
48
+        $this->family = "portal";
49
+        $this->module_position = '55';
50
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
+        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        $this->description = "CashDesk module";
53
+
54
+        $this->revision = '1.27';
55
+        $this->version = 'dolibarr';
56
+
57
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58
+        $this->picto = 'list';
59
+
60
+        // Data directories to create when module is enabled
61
+        $this->dirs = array();
62
+
63
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.
64
+        $this->config_page_url = array("cashdesk.php@cashdesk");
65
+
66
+        // Dependencies
67
+        $this->hidden = false;			            // A condition to hide module
68
+        $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog');	// List of modules id that must be enabled if this module is enabled
69
+        $this->requiredby = array();			    // List of modules id to disable if this one is disabled
70
+        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
71
+        $this->need_dolibarr_version = array(2,4);	// Minimum version of Dolibarr required by module
72
+        $this->langfiles = array("cashdesk");
73
+        $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
74
+        //$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw');  // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
75
+
76
+        // Constants
77
+        $this->const = array();
78
+
79
+        // Boxes
80
+        $this->boxes = array();
81
+
82
+        // Permissions
83
+        $this->rights = array();
84
+        $r=0;
85
+
86
+        $r++;
87
+        $this->rights[$r][0] = 50101;
88
+        $this->rights[$r][1] = 'Use point of sale';
89
+        $this->rights[$r][2] = 'a';
90
+        $this->rights[$r][3] = 0;
91
+        $this->rights[$r][4] = 'use';
92
+
93
+        // Main menu entries
94
+        $this->menus = array();			// List of menus to add
95
+        $r=0;
96
+
97
+        // This is to declare the Top Menu entry:
98
+        $this->menu[$r]=array(	    'fk_menu'=>0,			// Put 0 if this is a top menu
99
+                                    'type'=>'top',			// This is a Top menu entry
100
+                                    'titre'=>'PointOfSaleShort',
101
+                                    'mainmenu'=>'cashdesk',
102
+                                    'url'=>'/cashdesk/index.php?user=__LOGIN__',
103
+                                    'langs'=>'cashdesk',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
104
+                                    'position'=>900,
105 105
                                     'enabled'=>'$conf->cashdesk->enabled',
106
-		                            'perms'=>'$user->rights->cashdesk->use',		// Use 'perms'=>'1' if you want your menu with no permission rules
107
-									'target'=>'pointofsale',
108
-									'user'=>0);				// 0=Menu for internal users, 1=external users, 2=both
109
-
110
-		$r++;
111
-
112
-		// This is to declare a Left Menu entry:
113
-		// $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the top menu entry
114
-		//							'type'=>'left',			// This is a Left menu entry
115
-		//							'titre'=>'Title left menu',
116
-		//							'mainmenu'=>'mymodule',
117
-		//							'url'=>'/comm/action/index2.php',
118
-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
119
-		//							'position'=>100,
120
-		//							'perms'=>'$user->rights->mymodule->level1->level2',		// Use 'perms'=>'1' if you want your menu with no permission rules
121
-		//							'target'=>'',
122
-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
123
-		// $r++;
124
-	}
106
+                                    'perms'=>'$user->rights->cashdesk->use',		// Use 'perms'=>'1' if you want your menu with no permission rules
107
+                                    'target'=>'pointofsale',
108
+                                    'user'=>0);				// 0=Menu for internal users, 1=external users, 2=both
109
+
110
+        $r++;
111
+
112
+        // This is to declare a Left Menu entry:
113
+        // $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the top menu entry
114
+        //							'type'=>'left',			// This is a Left menu entry
115
+        //							'titre'=>'Title left menu',
116
+        //							'mainmenu'=>'mymodule',
117
+        //							'url'=>'/comm/action/index2.php',
118
+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
119
+        //							'position'=>100,
120
+        //							'perms'=>'$user->rights->mymodule->level1->level2',		// Use 'perms'=>'1' if you want your menu with no permission rules
121
+        //							'target'=>'',
122
+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
123
+        // $r++;
124
+    }
125 125
 
126 126
 
127 127
     /**
128
-	 *		Function called when module is enabled.
129
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
130
-	 *		It also creates data directories
131
-	 *
128
+     *		Function called when module is enabled.
129
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
130
+     *		It also creates data directories
131
+     *
132 132
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
133
-	 *      @return     int             	1 if OK, 0 if KO
133
+     *      @return     int             	1 if OK, 0 if KO
134 134
      */
135
-	function init($options='')
136
-  	{
137
-    	$sql = array();
135
+    function init($options='')
136
+        {
137
+        $sql = array();
138 138
 
139
-		// Remove permissions and default values
140
-		$this->remove($options);
139
+        // Remove permissions and default values
140
+        $this->remove($options);
141 141
 
142
-    	return $this->_init($sql,$options);
143
-  	}
142
+        return $this->_init($sql,$options);
143
+        }
144 144
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modExport.class.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -33,66 +33,66 @@
 block discarded – undo
33 33
 class modExport extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-		$this->numero = 240;
45
-
46
-		$this->family = "technic";
47
-		$this->module_position = '72';
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+        $this->numero = 240;
45
+
46
+        $this->family = "technic";
47
+        $this->module_position = '72';
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));
50
-		$this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto = 'technic';
55
-
56
-		// Data directories to create when module is enabled
57
-		$this->dirs = array("/export/temp");
58
-
59
-		// Config pages
60
-		$this->config_page_url = array("export.php");
61
-
62
-		// Dependencies
63
-		$this->depends = array();
64
-		$this->requiredby = array();
65
-		$this->phpmin = array(4,2,0);
66
-		$this->phpmax = array();
67
-
68
-		// Constants
69
-		$this->const = array();
70
-
71
-		// Boxes
72
-		$this->boxes = array();
73
-
74
-		// Permissions
75
-		$this->rights = array();
76
-		$this->rights_class = 'export';
77
-		$r=0;
78
-
79
-		$r++;
80
-		$this->rights[$r][0] = 1201;
81
-		$this->rights[$r][1] = 'Lire les exports';
82
-		$this->rights[$r][2] = 'r';
83
-		$this->rights[$r][3] = 0;
84
-		$this->rights[$r][4] = 'lire';
85
-
86
-		$r++;
87
-		$this->rights[$r][0] = 1202;
88
-		$this->rights[$r][1] = 'Creer/modifier un export';
89
-		$this->rights[$r][2] = 'w';
90
-		$this->rights[$r][3] = 0;
91
-		$this->rights[$r][4] = 'creer';
92
-
93
-
94
-		// Menus
95
-		//-------
96
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
97
-	}
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto = 'technic';
55
+
56
+        // Data directories to create when module is enabled
57
+        $this->dirs = array("/export/temp");
58
+
59
+        // Config pages
60
+        $this->config_page_url = array("export.php");
61
+
62
+        // Dependencies
63
+        $this->depends = array();
64
+        $this->requiredby = array();
65
+        $this->phpmin = array(4,2,0);
66
+        $this->phpmax = array();
67
+
68
+        // Constants
69
+        $this->const = array();
70
+
71
+        // Boxes
72
+        $this->boxes = array();
73
+
74
+        // Permissions
75
+        $this->rights = array();
76
+        $this->rights_class = 'export';
77
+        $r=0;
78
+
79
+        $r++;
80
+        $this->rights[$r][0] = 1201;
81
+        $this->rights[$r][1] = 'Lire les exports';
82
+        $this->rights[$r][2] = 'r';
83
+        $this->rights[$r][3] = 0;
84
+        $this->rights[$r][4] = 'lire';
85
+
86
+        $r++;
87
+        $this->rights[$r][0] = 1202;
88
+        $this->rights[$r][1] = 'Creer/modifier un export';
89
+        $this->rights[$r][2] = 'w';
90
+        $this->rights[$r][3] = 0;
91
+        $this->rights[$r][4] = 'creer';
92
+
93
+
94
+        // Menus
95
+        //-------
96
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
97
+    }
98 98
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel2007.modules.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -33,104 +33,104 @@
 block discarded – undo
33 33
  */
34 34
 class ExportExcel2007 extends ExportExcel
35 35
 {
36
-	/**
37
-	 * @var int ID
38
-	 */
39
-	public $id;
36
+    /**
37
+     * @var int ID
38
+     */
39
+    public $id;
40 40
 
41
-	/**
41
+    /**
42 42
      * @var string label
43 43
      */
44 44
     public $label;
45 45
 
46
-	public $extension;
46
+    public $extension;
47 47
 
48
-	/**
48
+    /**
49 49
      * Dolibarr version of the loaded document
50 50
      * @public string
51 51
      */
52
-	public $version = 'dolibarr';
52
+    public $version = 'dolibarr';
53 53
 
54
-	public $label_lib;
54
+    public $label_lib;
55 55
 
56
-	public $version_lib;
56
+    public $version_lib;
57 57
 
58
-	public $workbook;      // Handle fichier
58
+    public $workbook;      // Handle fichier
59 59
 
60
-	public $worksheet;     // Handle onglet
60
+    public $worksheet;     // Handle onglet
61 61
 
62
-	public $row;
62
+    public $row;
63 63
 
64
-	public $col;
64
+    public $col;
65 65
 
66 66
     public $file;          // To save filename
67 67
 
68
-	/**
69
-	 *	Constructor
70
-	 *
71
-	 *	@param	    DoliDB	$db      Database handler
72
-	 */
73
-	function __construct($db)
74
-	{
75
-		global $conf, $langs;
76
-		$this->db = $db;
77
-
78
-		$this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 2007';               // Label of driver
80
-		$this->desc = $langs->trans('Excel2007FormatDesc');
81
-		$this->extension='xlsx';             // Extension for generated file by this driver
68
+    /**
69
+     *	Constructor
70
+     *
71
+     *	@param	    DoliDB	$db      Database handler
72
+     */
73
+    function __construct($db)
74
+    {
75
+        global $conf, $langs;
76
+        $this->db = $db;
77
+
78
+        $this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
+        $this->label='Excel 2007';               // Label of driver
80
+        $this->desc = $langs->trans('Excel2007FormatDesc');
81
+        $this->extension='xlsx';             // Extension for generated file by this driver
82 82
         $this->picto='mime/xls';			// Picto
83
-		$this->version='1.30';             // Driver version
83
+        $this->version='1.30';             // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+        $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
86 86
 
87
-		if (empty($this->disabled))
88
-		{
89
-    		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
-    		{
92
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
87
+        if (empty($this->disabled))
88
+        {
89
+            // If driver use an external library, put its name here
90
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
+            {
92
+                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
95
+                $this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
99
-    		{
97
+            }
98
+            else
99
+            {
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
102
+                $this->label_lib='PhpExcel';
103 103
                 $this->version_lib='1.8.0';		// No way to get info from library
104
-    		}
105
-		}
104
+            }
105
+        }
106 106
 
107
-		$this->row=0;
108
-	}
107
+        $this->row=0;
108
+    }
109 109
 
110 110
 
111 111
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
112 112
     /**
113 113
      *  Close Excel file
114 114
      *
115
-	 *  @return		int							<0 if KO, >0 if OK
115
+     *  @return		int							<0 if KO, >0 if OK
116 116
      */
117
-	function close_file()
118
-	{
117
+    function close_file()
118
+    {
119 119
         // phpcs:enable
120
-		global $conf;
121
-
122
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123
-    	{
124
-	        $this->workbook->close();
125
-    	}
126
-    	else
127
-    	{
120
+        global $conf;
121
+
122
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123
+        {
124
+            $this->workbook->close();
125
+        }
126
+        else
127
+        {
128 128
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
129
-    	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
129
+            $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
130 130
             $objWriter->save($this->file);
131 131
             $this->workbook->disconnectWorksheets();
132 132
             unset($this->workbook);
133
-    	}
134
-		return 1;
135
-	}
133
+        }
134
+        return 1;
135
+    }
136 136
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel.modules.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -32,208 +32,208 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class ExportExcel extends ModeleExports
34 34
 {
35
-	/**
36
-	 * @var int ID
37
-	 */
38
-	public $id;
35
+    /**
36
+     * @var int ID
37
+     */
38
+    public $id;
39 39
 
40 40
     /**
41 41
      * @var string Export Excel label
42 42
      */
43 43
     public $label;
44 44
 
45
-	public $extension;
45
+    public $extension;
46 46
 
47
-	/**
47
+    /**
48 48
      * Dolibarr version of the loaded document
49 49
      * @public string
50 50
      */
51
-	public $version = 'dolibarr';
51
+    public $version = 'dolibarr';
52 52
 
53
-	public $label_lib;
53
+    public $label_lib;
54 54
 
55
-	public $version_lib;
55
+    public $version_lib;
56 56
 
57
-	public $workbook;      // Handle file
57
+    public $workbook;      // Handle file
58 58
 
59
-	public $worksheet;     // Handle sheet
59
+    public $worksheet;     // Handle sheet
60 60
 
61
-	public $row;
61
+    public $row;
62 62
 
63
-	public $col;
63
+    public $col;
64 64
 
65 65
     public $file;          // To save filename
66 66
 
67 67
 
68
-	/**
69
-	 *	Constructor
70
-	 *
71
-	 *	@param	    DoliDB	$db      Database handler
72
-	 */
73
-	function __construct($db)
74
-	{
75
-		global $conf, $langs;
76
-		$this->db = $db;
77
-
78
-		$this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 95';             // Label of driver
80
-		$this->desc = $langs->trans('Excel95FormatDesc');
81
-		$this->extension='xls';             // Extension for generated file by this driver
68
+    /**
69
+     *	Constructor
70
+     *
71
+     *	@param	    DoliDB	$db      Database handler
72
+     */
73
+    function __construct($db)
74
+    {
75
+        global $conf, $langs;
76
+        $this->db = $db;
77
+
78
+        $this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
+        $this->label='Excel 95';             // Label of driver
80
+        $this->desc = $langs->trans('Excel95FormatDesc');
81
+        $this->extension='xls';             // Extension for generated file by this driver
82 82
         $this->picto='mime/xls';					// Picto
83
-		$this->version='1.30';             // Driver version
83
+        $this->version='1.30';             // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+        $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
86 86
 
87
-		if (empty($this->disabled))
88
-		{
89
-    		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
-    		{
92
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
87
+        if (empty($this->disabled))
88
+        {
89
+            // If driver use an external library, put its name here
90
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
+            {
92
+                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
95
+                $this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
99
-    		{
97
+            }
98
+            else
99
+            {
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
102
+                $this->label_lib='PhpExcel';
103 103
                 $this->version_lib='1.8.0';		// No way to get info from library
104
-    		}
105
-		}
106
-
107
-		$this->row=0;
108
-	}
109
-
110
-	/**
111
-	 * getDriverId
112
-	 *
113
-	 * @return string
114
-	 */
115
-	function getDriverId()
116
-	{
117
-		return $this->id;
118
-	}
119
-
120
-	/**
121
-	 * getDriverLabel
122
-	 *
123
-	 * @return 	string			Return driver label
124
-	 */
125
-	function getDriverLabel()
126
-	{
127
-		return $this->label;
128
-	}
129
-
130
-	/**
131
-	 * getDriverDesc
132
-	 *
133
-	 * @return string
134
-	 */
135
-	function getDriverDesc()
104
+            }
105
+        }
106
+
107
+        $this->row=0;
108
+    }
109
+
110
+    /**
111
+     * getDriverId
112
+     *
113
+     * @return string
114
+     */
115
+    function getDriverId()
116
+    {
117
+        return $this->id;
118
+    }
119
+
120
+    /**
121
+     * getDriverLabel
122
+     *
123
+     * @return 	string			Return driver label
124
+     */
125
+    function getDriverLabel()
126
+    {
127
+        return $this->label;
128
+    }
129
+
130
+    /**
131
+     * getDriverDesc
132
+     *
133
+     * @return string
134
+     */
135
+    function getDriverDesc()
136 136
     {
137 137
         return $this->desc;
138 138
     }
139 139
 
140
-	/**
141
-	 * getDriverExtension
142
-	 *
143
-	 * @return string
144
-	 */
140
+    /**
141
+     * getDriverExtension
142
+     *
143
+     * @return string
144
+     */
145 145
     function getDriverExtension()
146
-	{
147
-		return $this->extension;
148
-	}
149
-
150
-	/**
151
-	 * getDriverVersion
152
-	 *
153
-	 * @return string
154
-	 */
155
-	function getDriverVersion()
156
-	{
157
-		return $this->version;
158
-	}
159
-
160
-	/**
161
-	 * getLibLabel
162
-	 *
163
-	 * @return string
164
-	 */
165
-	function getLibLabel()
166
-	{
167
-		return $this->label_lib;
168
-	}
169
-
170
-	/**
171
-	 * getLibVersion
172
-	 *
173
-	 * @return string
174
-	 */
175
-	function getLibVersion()
176
-	{
177
-		return $this->version_lib;
178
-	}
146
+    {
147
+        return $this->extension;
148
+    }
149
+
150
+    /**
151
+     * getDriverVersion
152
+     *
153
+     * @return string
154
+     */
155
+    function getDriverVersion()
156
+    {
157
+        return $this->version;
158
+    }
159
+
160
+    /**
161
+     * getLibLabel
162
+     *
163
+     * @return string
164
+     */
165
+    function getLibLabel()
166
+    {
167
+        return $this->label_lib;
168
+    }
169
+
170
+    /**
171
+     * getLibVersion
172
+     *
173
+     * @return string
174
+     */
175
+    function getLibVersion()
176
+    {
177
+        return $this->version_lib;
178
+    }
179 179
 
180 180
 
181 181
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
182
-	/**
183
-	 *	Open output file
184
-	 *
185
-	 * 	@param		string		$file			File name to generate
186
-	 *  @param		Translate	$outputlangs	Output language object
187
-	 *	@return		int							<0 if KO, >=0 if OK
188
-	 */
189
-	function open_file($file,$outputlangs)
190
-	{
182
+    /**
183
+     *	Open output file
184
+     *
185
+     * 	@param		string		$file			File name to generate
186
+     *  @param		Translate	$outputlangs	Output language object
187
+     *	@return		int							<0 if KO, >=0 if OK
188
+     */
189
+    function open_file($file,$outputlangs)
190
+    {
191 191
         // phpcs:enable
192
-		global $user,$conf,$langs;
192
+        global $user,$conf,$langs;
193 193
 
194
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195
-		{
196
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
197
-		}
194
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195
+        {
196
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
197
+        }
198 198
 
199
-		dol_syslog(get_class($this)."::open_file file=".$file);
199
+        dol_syslog(get_class($this)."::open_file file=".$file);
200 200
         $this->file=$file;
201 201
 
202
-		$ret=1;
202
+        $ret=1;
203 203
 
204
-    	$outputlangs->load("exports");
205
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206
-		{
204
+        $outputlangs->load("exports");
205
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206
+        {
207 207
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
208 208
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
209 209
             require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
210
-		    $this->workbook = new writeexcel_workbookbig($file);
211
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212
-    		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213
-    		$this->worksheet = &$this->workbook->addworksheet();
214
-		}
215
-		else
216
-		{
210
+            $this->workbook = new writeexcel_workbookbig($file);
211
+            $this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212
+            $this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213
+            $this->worksheet = &$this->workbook->addworksheet();
214
+        }
215
+        else
216
+        {
217 217
             require_once PHPEXCEL_PATH.'PHPExcel.php';
218 218
             require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
219 219
 
220
-		    if ($this->id == 'excel2007')
221
-		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223
-	            {
224
-	            	$langs->load("errors");
225
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
226
-	            	return -1;
227
-	            }
228
-		    }
229
-
230
-		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231
-			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
-			    $cacheSettings = array (
233
-			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234
-			    );
235
-			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
236
-		    }
220
+            if ($this->id == 'excel2007')
221
+            {
222
+                if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223
+                {
224
+                    $langs->load("errors");
225
+                    $this->error=$langs->trans('ErrorPHPNeedModule','zip');
226
+                    return -1;
227
+                }
228
+            }
229
+
230
+            if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231
+                $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
+                $cacheSettings = array (
233
+                        'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234
+                );
235
+                PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
236
+            }
237 237
 
238 238
             $this->workbook = new PHPExcel();
239 239
             $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
@@ -245,242 +245,242 @@  discard block
 block discarded – undo
245 245
             $this->workbook->setActiveSheetIndex(0);
246 246
             $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
247 247
             $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
248
-		}
249
-		return $ret;
250
-	}
248
+        }
249
+        return $ret;
250
+    }
251 251
 
252 252
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
253
-	/**
254
-	 *  Write header
255
-	 *
253
+    /**
254
+     *  Write header
255
+     *
256 256
      *  @param      Translate	$outputlangs        Object lang to translate values
257
-	 * 	@return		int								<0 if KO, >0 if OK
258
-	 */
259
-	function write_header($outputlangs)
260
-	{
257
+     * 	@return		int								<0 if KO, >0 if OK
258
+     */
259
+    function write_header($outputlangs)
260
+    {
261 261
         // phpcs:enable
262
-		//$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
262
+        //$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
263 263
 
264
-		return 0;
265
-	}
264
+        return 0;
265
+    }
266 266
 
267 267
 
268 268
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
269
-	/**
269
+    /**
270 270
      *  Output title line into file
271 271
      *
272 272
      *  @param      array		$array_export_fields_label   	Array with list of label of fields
273 273
      *  @param      array		$array_selected_sorted       	Array with list of field to export
274 274
      *  @param      Translate	$outputlangs    				Object lang to translate values
275 275
      *  @param		array		$array_types					Array with types of fields
276
-	 * 	@return		int											<0 if KO, >0 if OK
277
-	 */
278
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
279
-	{
276
+     * 	@return		int											<0 if KO, >0 if OK
277
+     */
278
+    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
279
+    {
280 280
         // phpcs:enable
281
-		global $conf;
282
-
283
-		// Create a format for the column headings
284
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285
-		{
286
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
287
-
288
-		    $formatheader =$this->workbook->addformat();
289
-    		$formatheader->set_bold();
290
-    		$formatheader->set_color('blue');
291
-    		//$formatheader->set_size(12);
292
-    		//$formatheader->set_font("Courier New");
293
-    		//$formatheader->set_align('center');
294
-		}
295
-		else
296
-		{
281
+        global $conf;
282
+
283
+        // Create a format for the column headings
284
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285
+        {
286
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
287
+
288
+            $formatheader =$this->workbook->addformat();
289
+            $formatheader->set_bold();
290
+            $formatheader->set_color('blue');
291
+            //$formatheader->set_size(12);
292
+            //$formatheader->set_font("Courier New");
293
+            //$formatheader->set_align('center');
294
+        }
295
+        else
296
+        {
297 297
             $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
298
-		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299
-		}
298
+            $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299
+        }
300 300
 
301
-		$this->col=0;
302
-		foreach($array_selected_sorted as $code => $value)
303
-		{
301
+        $this->col=0;
302
+        foreach($array_selected_sorted as $code => $value)
303
+        {
304 304
             $alias=$array_export_fields_label[$code];
305
-			//print "dd".$alias;
306
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308
-    		{
309
-    			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
-    		}
311
-    		else
312
-    		{
305
+            //print "dd".$alias;
306
+            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308
+            {
309
+                $this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
+            }
311
+            else
312
+            {
313 313
                 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
314
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
314
+                if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
315 315
                 {
316
-                	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
316
+                    $this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
317 317
                 }
318
-    		}
319
-			$this->col++;
320
-		}
321
-		$this->row++;
322
-		return 0;
323
-	}
318
+            }
319
+            $this->col++;
320
+        }
321
+        $this->row++;
322
+        return 0;
323
+    }
324 324
 
325 325
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
326
-	/**
326
+    /**
327 327
      *  Output record line into file
328 328
      *
329 329
      *  @param      array		$array_selected_sorted      Array with list of field to export
330 330
      *  @param      resource	$objp                       A record from a fetch with all fields from select
331 331
      *  @param      Translate	$outputlangs                Object lang to translate values
332 332
      *  @param		array		$array_types				Array with types of fields
333
-	 * 	@return		int										<0 if KO, >0 if OK
334
-	 */
335
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
336
-	{
333
+     * 	@return		int										<0 if KO, >0 if OK
334
+     */
335
+    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
336
+    {
337 337
         // phpcs:enable
338
-		global $conf;
338
+        global $conf;
339 339
 
340
-		// Create a format for the column headings
341
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342
-		{
343
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
344
-		}
340
+        // Create a format for the column headings
341
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342
+        {
343
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
344
+        }
345 345
 
346
-		// Define first row
347
-		$this->col=0;
346
+        // Define first row
347
+        $this->col=0;
348 348
 
349
-		foreach($array_selected_sorted as $code => $value)
350
-		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
349
+        foreach($array_selected_sorted as $code => $value)
350
+        {
351
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
+            else $alias=substr($code, strpos($code, ' as ') + 4);
353 353
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
354 354
             $newvalue=$objp->$alias;
355 355
 
356
-			$newvalue=$this->excel_clean($newvalue);
357
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
358
-
359
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360
-			{
361
-				$array = unserialize($typefield);
362
-				$array = $array['options'];
363
-				$newvalue = $array[$newvalue];
364
-			}
365
-
366
-			// Traduction newvalue
367
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368
-			{
369
-				$newvalue=$outputlangs->transnoentities($reg[1]);
370
-			}
371
-			else
372
-			{
373
-				$newvalue=$outputlangs->convToOutputCharset($newvalue);
374
-			}
375
-
376
-			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
377
-			{
378
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379
-        		{
380
-            		$formatdate=$this->workbook->addformat();
381
-            		$formatdate->set_num_format('yyyy-mm-dd');
382
-            		//$formatdate->set_num_format(0x0f);
383
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
384
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386
-        		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
-        		}
388
-        		else
389
-        		{
390
-        		    $newvalue=dol_stringtotime($newvalue);
391
-        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394
-        		}
395
-			}
396
-			elseif (preg_match('/^[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]$/i',$newvalue))
397
-			{
398
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399
-    		    {
400
-            		$formatdatehour=$this->workbook->addformat();
401
-            		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402
-            		//$formatdatehour->set_num_format(0x0f);
403
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
404
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406
-    		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
-    		    }
408
-    		    else
409
-    		    {
410
-        		    $newvalue=dol_stringtotime($newvalue);
411
-    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414
-    		    }
415
-			}
416
-			else
417
-			{
418
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419
-    		    {
420
-			        $this->worksheet->write($this->row, $this->col, $newvalue);
421
-    		    }
422
-    		    else
423
-				{
424
-    		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425
-    		    	{
426
-    		    		//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
427
-						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
428
-    		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
-    		    	}
432
-    		    	else
433
-    		    	{
434
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435
-    		    	}
436
-    		    }
437
-			}
438
-			$this->col++;
439
-		}
440
-		$this->row++;
441
-		return 0;
442
-	}
356
+            $newvalue=$this->excel_clean($newvalue);
357
+            $typefield=isset($array_types[$code])?$array_types[$code]:'';
358
+
359
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360
+            {
361
+                $array = unserialize($typefield);
362
+                $array = $array['options'];
363
+                $newvalue = $array[$newvalue];
364
+            }
365
+
366
+            // Traduction newvalue
367
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368
+            {
369
+                $newvalue=$outputlangs->transnoentities($reg[1]);
370
+            }
371
+            else
372
+            {
373
+                $newvalue=$outputlangs->convToOutputCharset($newvalue);
374
+            }
375
+
376
+            if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
377
+            {
378
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379
+                {
380
+                    $formatdate=$this->workbook->addformat();
381
+                    $formatdate->set_num_format('yyyy-mm-dd');
382
+                    //$formatdate->set_num_format(0x0f);
383
+                    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
384
+                    //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385
+                    $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386
+                    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
+                }
388
+                else
389
+                {
390
+                    $newvalue=dol_stringtotime($newvalue);
391
+                    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
+                    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393
+                    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394
+                }
395
+            }
396
+            elseif (preg_match('/^[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]$/i',$newvalue))
397
+            {
398
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399
+                {
400
+                    $formatdatehour=$this->workbook->addformat();
401
+                    $formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402
+                    //$formatdatehour->set_num_format(0x0f);
403
+                    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
404
+                    //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405
+                    $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406
+                    $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
+                }
408
+                else
409
+                {
410
+                    $newvalue=dol_stringtotime($newvalue);
411
+                    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
+                    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413
+                    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414
+                }
415
+            }
416
+            else
417
+            {
418
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419
+                {
420
+                    $this->worksheet->write($this->row, $this->col, $newvalue);
421
+                }
422
+                else
423
+                {
424
+                    if ($typefield == 'Text' || $typefield == 'TextAuto')
425
+                    {
426
+                        //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
427
+                        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
428
+                        $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429
+                        $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430
+                        $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
+                    }
432
+                    else
433
+                    {
434
+                        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435
+                    }
436
+                }
437
+            }
438
+            $this->col++;
439
+        }
440
+        $this->row++;
441
+        return 0;
442
+    }
443 443
 
444 444
 
445 445
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
446
-	/**
446
+    /**
447 447
      *	Write footer
448 448
      *
449
-	 * 	@param		Translate	$outputlangs	Output language object
450
-	 * 	@return		int							<0 if KO, >0 if OK
449
+     * 	@param		Translate	$outputlangs	Output language object
450
+     * 	@return		int							<0 if KO, >0 if OK
451 451
      */
452
-	function write_footer($outputlangs)
453
-	{
452
+    function write_footer($outputlangs)
453
+    {
454 454
         // phpcs:enable
455
-		return 0;
456
-	}
455
+        return 0;
456
+    }
457 457
 
458 458
 
459 459
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
460 460
     /**
461 461
      *	Close Excel file
462 462
      *
463
-	 * 	@return		int							<0 if KO, >0 if OK
463
+     * 	@return		int							<0 if KO, >0 if OK
464 464
      */
465
-	function close_file()
466
-	{
465
+    function close_file()
466
+    {
467 467
         // phpcs:enable
468
-		global $conf;
469
-
470
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471
-    	{
472
-	        $this->workbook->close();
473
-    	}
474
-    	else
475
-    	{
468
+        global $conf;
469
+
470
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471
+        {
472
+            $this->workbook->close();
473
+        }
474
+        else
475
+        {
476 476
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
477
-    	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
477
+            $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
478 478
             $objWriter->save($this->file);
479 479
             $this->workbook->disconnectWorksheets();
480 480
             unset($this->workbook);
481
-    	}
482
-		return 1;
483
-	}
481
+        }
482
+        return 1;
483
+    }
484 484
 
485 485
 
486 486
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
     function excel_clean($newvalue)
494 494
     {
495 495
         // phpcs:enable
496
-		// Rule Dolibarr: No HTML
497
-    	$newvalue=dol_string_nohtmltag($newvalue);
496
+        // Rule Dolibarr: No HTML
497
+        $newvalue=dol_string_nohtmltag($newvalue);
498 498
 
499
-    	return $newvalue;
499
+        return $newvalue;
500 500
     }
501 501
 
502 502
 
@@ -509,16 +509,16 @@  discard block
 block discarded – undo
509 509
     function column2Letter($c)
510 510
     {
511 511
 
512
-    	$c = intval($c);
513
-    	if ($c <= 0) return '';
512
+        $c = intval($c);
513
+        if ($c <= 0) return '';
514 514
 
515
-    	while ($c != 0)
516
-    	{
517
-    		$p = ($c - 1) % 26;
518
-    		$c = intval(($c - $p) / 26);
519
-    		$letter = chr(65 + $p) . $letter;
520
-    	}
515
+        while ($c != 0)
516
+        {
517
+            $p = ($c - 1) % 26;
518
+            $c = intval(($c - $p) / 26);
519
+            $letter = chr(65 + $p) . $letter;
520
+        }
521 521
 
522
-    	return $letter;
522
+        return $letter;
523 523
     }
524 524
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_csv.modules.php 1 patch
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -30,208 +30,208 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class ExportCsv extends ModeleExports
32 32
 {
33
-	/**
34
-	 * @var int ID
35
-	 */
36
-	public $id;
33
+    /**
34
+     * @var int ID
35
+     */
36
+    public $id;
37 37
 
38
-	/**
38
+    /**
39 39
      * @var string export files label
40 40
      */
41 41
     public $label;
42 42
 
43
-	public $extension;
43
+    public $extension;
44 44
 
45
-	/**
45
+    /**
46 46
      * Dolibarr version of the loaded document
47 47
      * @public string
48 48
      */
49
-	public $version = 'dolibarr';
50
-
51
-	public $label_lib;
52
-
53
-	public $version_lib;
54
-
55
-	public $separator;
56
-
57
-	public $handle;    // Handle fichier
58
-
59
-
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *	@param	    DoliDB	$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs;
68
-		$this->db = $db;
69
-
70
-		$this->separator=',';
71
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
-		$this->escape='"';
73
-		$this->enclosure='"';
74
-
75
-		$this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
76
-		$this->label = 'CSV';             // Label of driver
77
-		$this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
78
-		$this->extension='csv';         // Extension for generated file by this driver
79
-		$this->picto='mime/other';		// Picto
80
-		$this->version='1.32';         // Driver version
81
-
82
-		// If driver use an external library, put its name here
83
-		$this->label_lib='Dolibarr';
84
-		$this->version_lib=DOL_VERSION;
85
-	}
86
-
87
-	/**
88
-	 * getDriverId
89
-	 *
90
-	 * @return string
91
-	 */
92
-	function getDriverId()
93
-	{
94
-		return $this->id;
95
-	}
96
-
97
-	/**
98
-	 * getDriverLabel
99
-	 *
100
-	 * @return 	string			Return driver label
101
-	 */
102
-	function getDriverLabel()
103
-	{
104
-		return $this->label;
105
-	}
106
-
107
-	/**
108
-	 * getDriverDesc
109
-	 *
110
-	 * @return string
111
-	 */
112
-	function getDriverDesc()
113
-	{
114
-		return $this->desc;
115
-	}
116
-
117
-	/**
118
-	 * getDriverExtension
119
-	 *
120
-	 * @return string
121
-	 */
122
-	function getDriverExtension()
123
-	{
124
-		return $this->extension;
125
-	}
126
-
127
-	/**
128
-	 * getDriverVersion
129
-	 *
130
-	 * @return string
131
-	 */
132
-	function getDriverVersion()
133
-	{
134
-		return $this->version;
135
-	}
136
-
137
-	/**
138
-	 * getLabelLabel
139
-	 *
140
-	 * @return string
141
-	 */
142
-	function getLibLabel()
143
-	{
144
-		return $this->label_lib;
145
-	}
146
-
147
-	/**
148
-	 * getLibVersion
149
-	 *
150
-	 * @return string
151
-	 */
152
-	function getLibVersion()
153
-	{
154
-		return $this->version_lib;
155
-	}
49
+    public $version = 'dolibarr';
50
+
51
+    public $label_lib;
52
+
53
+    public $version_lib;
54
+
55
+    public $separator;
56
+
57
+    public $handle;    // Handle fichier
58
+
59
+
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *	@param	    DoliDB	$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs;
68
+        $this->db = $db;
69
+
70
+        $this->separator=',';
71
+        if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
+        $this->escape='"';
73
+        $this->enclosure='"';
74
+
75
+        $this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
76
+        $this->label = 'CSV';             // Label of driver
77
+        $this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
78
+        $this->extension='csv';         // Extension for generated file by this driver
79
+        $this->picto='mime/other';		// Picto
80
+        $this->version='1.32';         // Driver version
81
+
82
+        // If driver use an external library, put its name here
83
+        $this->label_lib='Dolibarr';
84
+        $this->version_lib=DOL_VERSION;
85
+    }
86
+
87
+    /**
88
+     * getDriverId
89
+     *
90
+     * @return string
91
+     */
92
+    function getDriverId()
93
+    {
94
+        return $this->id;
95
+    }
96
+
97
+    /**
98
+     * getDriverLabel
99
+     *
100
+     * @return 	string			Return driver label
101
+     */
102
+    function getDriverLabel()
103
+    {
104
+        return $this->label;
105
+    }
106
+
107
+    /**
108
+     * getDriverDesc
109
+     *
110
+     * @return string
111
+     */
112
+    function getDriverDesc()
113
+    {
114
+        return $this->desc;
115
+    }
116
+
117
+    /**
118
+     * getDriverExtension
119
+     *
120
+     * @return string
121
+     */
122
+    function getDriverExtension()
123
+    {
124
+        return $this->extension;
125
+    }
126
+
127
+    /**
128
+     * getDriverVersion
129
+     *
130
+     * @return string
131
+     */
132
+    function getDriverVersion()
133
+    {
134
+        return $this->version;
135
+    }
136
+
137
+    /**
138
+     * getLabelLabel
139
+     *
140
+     * @return string
141
+     */
142
+    function getLibLabel()
143
+    {
144
+        return $this->label_lib;
145
+    }
146
+
147
+    /**
148
+     * getLibVersion
149
+     *
150
+     * @return string
151
+     */
152
+    function getLibVersion()
153
+    {
154
+        return $this->version_lib;
155
+    }
156 156
 
157 157
 
158 158
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
159
-	/**
160
-	 *	Open output file
161
-	 *
162
-	 *	@param		string		$file			Path of filename to generate
163
-	 * 	@param		Translate	$outputlangs	Output language object
164
-	 *	@return		int							<0 if KO, >=0 if OK
165
-	 */
166
-	function open_file($file,$outputlangs)
167
-	{
159
+    /**
160
+     *	Open output file
161
+     *
162
+     *	@param		string		$file			Path of filename to generate
163
+     * 	@param		Translate	$outputlangs	Output language object
164
+     *	@return		int							<0 if KO, >=0 if OK
165
+     */
166
+    function open_file($file,$outputlangs)
167
+    {
168 168
         // phpcs:enable
169
-		global $langs;
169
+        global $langs;
170 170
 
171
-		dol_syslog("ExportCsv::open_file file=".$file);
171
+        dol_syslog("ExportCsv::open_file file=".$file);
172 172
 
173
-		$ret=1;
173
+        $ret=1;
174 174
 
175
-		$outputlangs->load("exports");
176
-		$this->handle = fopen($file, "wt");
177
-		if (! $this->handle)
178
-		{
179
-			$langs->load("errors");
180
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
-			$ret=-1;
182
-		}
175
+        $outputlangs->load("exports");
176
+        $this->handle = fopen($file, "wt");
177
+        if (! $this->handle)
178
+        {
179
+            $langs->load("errors");
180
+            $this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
+            $ret=-1;
182
+        }
183 183
 
184
-		return $ret;
185
-	}
184
+        return $ret;
185
+    }
186 186
 
187 187
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
188
-	/**
189
-	 * 	Output header into file
190
-	 *
191
-	 * 	@param		Translate	$outputlangs	Output language object
192
-	 * 	@return		int							<0 if KO, >0 if OK
193
-	 */
194
-	function write_header($outputlangs)
195
-	{
188
+    /**
189
+     * 	Output header into file
190
+     *
191
+     * 	@param		Translate	$outputlangs	Output language object
192
+     * 	@return		int							<0 if KO, >0 if OK
193
+     */
194
+    function write_header($outputlangs)
195
+    {
196 196
         // phpcs:enable
197
-		return 0;
198
-	}
197
+        return 0;
198
+    }
199 199
 
200 200
 
201 201
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
202
-	/**
203
-	 * 	Output title line into file
204
-	 *
202
+    /**
203
+     * 	Output title line into file
204
+     *
205 205
      *  @param      array		$array_export_fields_label   	Array with list of label of fields
206 206
      *  @param      array		$array_selected_sorted       	Array with list of field to export
207 207
      *  @param      Translate	$outputlangs    				Object lang to translate values
208 208
      *  @param		array		$array_types					Array with types of fields
209
-	 * 	@return		int											<0 if KO, >0 if OK
210
-	 */
211
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
212
-	{
209
+     * 	@return		int											<0 if KO, >0 if OK
210
+     */
211
+    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
212
+    {
213 213
         // phpcs:enable
214
-		global $conf;
214
+        global $conf;
215 215
 
216
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217
-		{
218
-			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
-		}
220
-		else
221
-		{
222
-			$outputlangs->charset_output = 'ISO-8859-1';
223
-		}
216
+        if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217
+        {
218
+            $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
+        }
220
+        else
221
+        {
222
+            $outputlangs->charset_output = 'ISO-8859-1';
223
+        }
224 224
 
225
-		foreach($array_selected_sorted as $code => $value)
226
-		{
227
-			$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
228
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
225
+        foreach($array_selected_sorted as $code => $value)
226
+        {
227
+            $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
228
+            $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
229 229
 
230
-			fwrite($this->handle,$newvalue.$this->separator);
231
-		}
232
-		fwrite($this->handle,"\n");
233
-		return 0;
234
-	}
230
+            fwrite($this->handle,$newvalue.$this->separator);
231
+        }
232
+        fwrite($this->handle,"\n");
233
+        return 0;
234
+    }
235 235
 
236 236
 
237 237
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -242,124 +242,124 @@  discard block
 block discarded – undo
242 242
      *  @param     	resource	$objp                       A record from a fetch with all fields from select
243 243
      *  @param     	Translate	$outputlangs    			Object lang to translate values
244 244
      *  @param		array		$array_types				Array with types of fields
245
-	 * 	@return		int										<0 if KO, >0 if OK
246
-	 */
247
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
248
-	{
245
+     * 	@return		int										<0 if KO, >0 if OK
246
+     */
247
+    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
248
+    {
249 249
         // phpcs:enable
250
-		global $conf;
251
-
252
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253
-		{
254
-			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
-		}
256
-		else
257
-		{
258
-			$outputlangs->charset_output = 'ISO-8859-1';
259
-		}
260
-
261
-		$this->col=0;
262
-		foreach($array_selected_sorted as $code => $value)
263
-		{
264
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
-			else $alias=substr($code, strpos($code, ' as ') + 4);
266
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
267
-
268
-			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
270
-
271
-			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
273
-
274
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275
-
276
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277
-			{
278
-				$array = unserialize($typefield);
279
-				$array = $array['options'];
280
-				$newvalue = $array[$newvalue];
281
-			}
282
-
283
-			fwrite($this->handle,$newvalue.$this->separator);
284
-			$this->col++;
285
-		}
286
-
287
-		fwrite($this->handle,"\n");
288
-		return 0;
289
-	}
250
+        global $conf;
251
+
252
+        if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253
+        {
254
+            $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
+        }
256
+        else
257
+        {
258
+            $outputlangs->charset_output = 'ISO-8859-1';
259
+        }
260
+
261
+        $this->col=0;
262
+        foreach($array_selected_sorted as $code => $value)
263
+        {
264
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
+            else $alias=substr($code, strpos($code, ' as ') + 4);
266
+            if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
267
+
268
+            $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
+            $typefield=isset($array_types[$code])?$array_types[$code]:'';
270
+
271
+            // Translation newvalue
272
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
273
+
274
+            $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275
+
276
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277
+            {
278
+                $array = unserialize($typefield);
279
+                $array = $array['options'];
280
+                $newvalue = $array[$newvalue];
281
+            }
282
+
283
+            fwrite($this->handle,$newvalue.$this->separator);
284
+            $this->col++;
285
+        }
286
+
287
+        fwrite($this->handle,"\n");
288
+        return 0;
289
+    }
290 290
 
291 291
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
292
-	/**
293
-	 * 	Output footer into file
294
-	 *
295
-	 * 	@param		Translate	$outputlangs	Output language object
296
-	 * 	@return		int							<0 if KO, >0 if OK
297
-	 */
298
-	function write_footer($outputlangs)
299
-	{
292
+    /**
293
+     * 	Output footer into file
294
+     *
295
+     * 	@param		Translate	$outputlangs	Output language object
296
+     * 	@return		int							<0 if KO, >0 if OK
297
+     */
298
+    function write_footer($outputlangs)
299
+    {
300 300
         // phpcs:enable
301
-		return 0;
302
-	}
301
+        return 0;
302
+    }
303 303
 
304 304
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
305
-	/**
306
-	 * 	Close file handle
307
-	 *
308
-	 * 	@return		int							<0 if KO, >0 if OK
309
-	 */
310
-	function close_file()
311
-	{
305
+    /**
306
+     * 	Close file handle
307
+     *
308
+     * 	@return		int							<0 if KO, >0 if OK
309
+     */
310
+    function close_file()
311
+    {
312 312
         // phpcs:enable
313
-		fclose($this->handle);
314
-		return 0;
315
-	}
316
-
317
-
318
-	/**
319
-	 * Clean a cell to respect rules of CSV file cells
320
-	 * Note: It uses $this->separator
321
-	 * Note: We keep this function public to be able to test
322
-	 *
323
-	 * @param 	string	$newvalue	String to clean
324
-	 * @param	string	$charset	Input AND Output character set
325
-	 * @return 	string				Value cleaned
326
-	 */
327
-	public function csvClean($newvalue, $charset)
328
-	{
329
-		global $conf;
330
-		$addquote=0;
331
-
332
-
333
-		// Rule Dolibarr: No HTML
334
-   		//print $charset.' '.$newvalue."\n";
335
-   		//$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
-   		$newvalue=dol_htmlcleanlastbr($newvalue);
337
-   		//print $charset.' '.$newvalue."\n";
338
-
339
-		// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
340
-		$oldvalue=$newvalue;
341
-		$newvalue=str_replace("\r",'',$newvalue);
342
-		$newvalue=str_replace("\n",'\n',$newvalue);
343
-		if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
344
-		{
345
-			// If strict use of CSV rules, we just add quote
346
-			$newvalue=$oldvalue;
347
-			$addquote=1;
348
-		}
349
-
350
-		// Rule 2 CSV: If value contains ", we must escape with ", and add "
351
-		if (preg_match('/"/',$newvalue))
352
-		{
353
-			$addquote=1;
354
-			$newvalue=str_replace('"','""',$newvalue);
355
-		}
356
-
357
-		// Rule 3 CSV: If value contains separator, we must add "
358
-		if (preg_match('/'.$this->separator.'/',$newvalue))
359
-		{
360
-			$addquote=1;
361
-		}
362
-
363
-		return ($addquote?'"':'').$newvalue.($addquote?'"':'');
364
-	}
313
+        fclose($this->handle);
314
+        return 0;
315
+    }
316
+
317
+
318
+    /**
319
+     * Clean a cell to respect rules of CSV file cells
320
+     * Note: It uses $this->separator
321
+     * Note: We keep this function public to be able to test
322
+     *
323
+     * @param 	string	$newvalue	String to clean
324
+     * @param	string	$charset	Input AND Output character set
325
+     * @return 	string				Value cleaned
326
+     */
327
+    public function csvClean($newvalue, $charset)
328
+    {
329
+        global $conf;
330
+        $addquote=0;
331
+
332
+
333
+        // Rule Dolibarr: No HTML
334
+            //print $charset.' '.$newvalue."\n";
335
+            //$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
+            $newvalue=dol_htmlcleanlastbr($newvalue);
337
+            //print $charset.' '.$newvalue."\n";
338
+
339
+        // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
340
+        $oldvalue=$newvalue;
341
+        $newvalue=str_replace("\r",'',$newvalue);
342
+        $newvalue=str_replace("\n",'\n',$newvalue);
343
+        if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
344
+        {
345
+            // If strict use of CSV rules, we just add quote
346
+            $newvalue=$oldvalue;
347
+            $addquote=1;
348
+        }
349
+
350
+        // Rule 2 CSV: If value contains ", we must escape with ", and add "
351
+        if (preg_match('/"/',$newvalue))
352
+        {
353
+            $addquote=1;
354
+            $newvalue=str_replace('"','""',$newvalue);
355
+        }
356
+
357
+        // Rule 3 CSV: If value contains separator, we must add "
358
+        if (preg_match('/'.$this->separator.'/',$newvalue))
359
+        {
360
+            $addquote=1;
361
+        }
362
+
363
+        return ($addquote?'"':'').$newvalue.($addquote?'"':'');
364
+    }
365 365
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_tsv.modules.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 class ExportTsv extends ModeleExports
33 33
 {
34 34
     /**
35
-	 * @var int ID
36
-	 */
37
-	public $id;
35
+     * @var int ID
36
+     */
37
+    public $id;
38 38
 
39 39
     /**
40 40
      * @var string label
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';
50
+    public $version = 'dolibarr';
51 51
 
52 52
     public $label_lib;
53 53
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
     /**
62
-	 *	Constructor
63
-	 *
64
-	 *	@param	    DoliDB	$db      Database handler
62
+     *	Constructor
63
+     *
64
+     *	@param	    DoliDB	$db      Database handler
65 65
      */
66 66
     function __construct($db)
67 67
     {
@@ -80,71 +80,71 @@  discard block
 block discarded – undo
80 80
         $this->version_lib=DOL_VERSION;
81 81
     }
82 82
 
83
-	/**
84
-	 * getDriverId
85
-	 *
86
-	 * @return string
87
-	 */
83
+    /**
84
+     * getDriverId
85
+     *
86
+     * @return string
87
+     */
88 88
     function getDriverId()
89 89
     {
90 90
         return $this->id;
91 91
     }
92 92
 
93
-	/**
94
-	 * getDriverLabel
95
-	 *
96
-	 * @return 	string			Return driver label
97
-	 */
93
+    /**
94
+     * getDriverLabel
95
+     *
96
+     * @return 	string			Return driver label
97
+     */
98 98
     function getDriverLabel()
99 99
     {
100 100
         return $this->label;
101 101
     }
102 102
 
103
-	/**
104
-	 * getDriverDesc
105
-	 *
106
-	 * @return string
107
-	 */
103
+    /**
104
+     * getDriverDesc
105
+     *
106
+     * @return string
107
+     */
108 108
     function getDriverDesc()
109 109
     {
110 110
         return $this->desc;
111 111
     }
112 112
 
113
-	/**
114
-	 * getDriverExtension
115
-	 *
116
-	 * @return string
117
-	 */
113
+    /**
114
+     * getDriverExtension
115
+     *
116
+     * @return string
117
+     */
118 118
     function getDriverExtension()
119 119
     {
120 120
         return $this->extension;
121 121
     }
122 122
 
123
-	/**
124
-	 * getDriverVersion
125
-	 *
126
-	 * @return string
127
-	 */
123
+    /**
124
+     * getDriverVersion
125
+     *
126
+     * @return string
127
+     */
128 128
     function getDriverVersion()
129 129
     {
130 130
         return $this->version;
131 131
     }
132 132
 
133
-	/**
134
-	 * getLibLabel
135
-	 *
136
-	 * @return string
137
-	 */
133
+    /**
134
+     * getLibLabel
135
+     *
136
+     * @return string
137
+     */
138 138
     function getLibLabel()
139 139
     {
140 140
         return $this->label_lib;
141 141
     }
142 142
 
143
-	/**
144
-	 * getLibVersion
145
-	 *
146
-	 * @return string
147
-	 */
143
+    /**
144
+     * getLibVersion
145
+     *
146
+     * @return string
147
+     */
148 148
     function getLibVersion()
149 149
     {
150 150
         return $this->version_lib;
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 
154 154
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155 155
     /**
156
-	*	Open output file
157
-	*
158
-	 *	@param		string		$file			Path of filename to generate
159
-	*	@param		Translate	$outputlangs	Output language object
160
-	*	@return		int							<0 if KO, >=0 if OK
161
-    */
156
+     *	Open output file
157
+     *
158
+     *	@param		string		$file			Path of filename to generate
159
+     *	@param		Translate	$outputlangs	Output language object
160
+     *	@return		int							<0 if KO, >=0 if OK
161
+     */
162 162
     function open_file($file,$outputlangs)
163 163
     {
164 164
         // phpcs:enable
@@ -169,24 +169,24 @@  discard block
 block discarded – undo
169 169
         $ret=1;
170 170
 
171 171
         $outputlangs->load("exports");
172
-		$this->handle = fopen($file, "wt");
172
+        $this->handle = fopen($file, "wt");
173 173
         if (! $this->handle)
174
-		{
175
-			$langs->load("errors");
176
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
-			$ret=-1;
178
-		}
174
+        {
175
+            $langs->load("errors");
176
+            $this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
+            $ret=-1;
178
+        }
179 179
 
180
-		return $ret;
180
+        return $ret;
181 181
     }
182 182
 
183 183
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
184
-	/**
185
-	 * 	Output header into file
186
-	 *
187
-	 * 	@param		Translate	$outputlangs		Output language object
188
-	 * 	@return		int								<0 if KO, >0 if OK
189
-	 */
184
+    /**
185
+     * 	Output header into file
186
+     *
187
+     * 	@param		Translate	$outputlangs		Output language object
188
+     * 	@return		int								<0 if KO, >0 if OK
189
+     */
190 190
     function write_header($outputlangs)
191 191
     {
192 192
         // phpcs:enable
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
      *  @param      array		$array_selected_sorted       	Array with list of field to export
203 203
      *  @param      Translate	$outputlangs    				Object lang to translate values
204 204
      *  @param		array		$array_types					Array with types of fields
205
-	 * 	@return		int											<0 if KO, >0 if OK
206
-	 */
205
+     * 	@return		int											<0 if KO, >0 if OK
206
+     */
207 207
     function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
208 208
     {
209 209
         // phpcs:enable
210 210
         foreach($array_selected_sorted as $code => $value)
211 211
         {
212 212
             $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
213
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
213
+            $newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
214 214
 
215
-			fwrite($this->handle,$newvalue.$this->separator);
215
+            fwrite($this->handle,$newvalue.$this->separator);
216 216
         }
217 217
         fwrite($this->handle,"\n");
218 218
         return 0;
@@ -220,68 +220,68 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
223
-	/**
224
-	 * 	Output record line into file
225
-	 *
226
-	 *  @param      array		$array_selected_sorted      Array with list of field to export
227
-	 *  @param      resource	$objp                       A record from a fetch with all fields from select
228
-	 *  @param      Translate	$outputlangs                Object lang to translate values
223
+    /**
224
+     * 	Output record line into file
225
+     *
226
+     *  @param      array		$array_selected_sorted      Array with list of field to export
227
+     *  @param      resource	$objp                       A record from a fetch with all fields from select
228
+     *  @param      Translate	$outputlangs                Object lang to translate values
229 229
      *  @param		array		$array_types				Array with types of fields
230
-	 * 	@return		int										<0 if KO, >0 if OK
231
-	 */
230
+     * 	@return		int										<0 if KO, >0 if OK
231
+     */
232 232
     function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
233 233
     {
234 234
         // phpcs:enable
235
-    	global $conf;
235
+        global $conf;
236 236
 
237
-		$this->col=0;
238
- 		foreach($array_selected_sorted as $code => $value)
237
+        $this->col=0;
238
+            foreach($array_selected_sorted as $code => $value)
239 239
         {
240
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
-			else $alias=substr($code, strpos($code, ' as ') + 4);
240
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
+            else $alias=substr($code, strpos($code, ' as ') + 4);
242 242
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
243 243
 
244 244
             $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245 245
             $typefield=isset($array_types[$code])?$array_types[$code]:'';
246 246
 
247 247
             // Translation newvalue
248
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
248
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
249 249
 
250
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
250
+            $newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
251 251
 
252
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253
-			{
254
-				$array = unserialize($typefield);
255
-				$array = $array['options'];
256
-				$newvalue = $array[$newvalue];
257
-			}
252
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253
+            {
254
+                $array = unserialize($typefield);
255
+                $array = $array['options'];
256
+                $newvalue = $array[$newvalue];
257
+            }
258 258
 
259
-			fwrite($this->handle,$newvalue.$this->separator);
259
+            fwrite($this->handle,$newvalue.$this->separator);
260 260
             $this->col++;
261
-		}
261
+        }
262 262
         fwrite($this->handle,"\n");
263 263
         return 0;
264 264
     }
265 265
 
266 266
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
267
-	/**
268
-	 * 	Output footer into file
269
-	 *
270
-	 * 	@param		Translate	$outputlangs		Output language object
271
-	 * 	@return		int								<0 if KO, >0 if OK
272
-	 */
267
+    /**
268
+     * 	Output footer into file
269
+     *
270
+     * 	@param		Translate	$outputlangs		Output language object
271
+     * 	@return		int								<0 if KO, >0 if OK
272
+     */
273 273
     function write_footer($outputlangs)
274 274
     {
275 275
         // phpcs:enable
276
-		return 0;
276
+        return 0;
277 277
     }
278 278
 
279 279
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
280
-	/**
281
-	 * 	Close file handle
282
-	 *
283
-	 * 	@return		int							<0 if KO, >0 if OK
284
-	 */
280
+    /**
281
+     * 	Close file handle
282
+     *
283
+     * 	@return		int							<0 if KO, >0 if OK
284
+     */
285 285
     function close_file()
286 286
     {
287 287
         // phpcs:enable
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
     function tsv_clean($newvalue, $charset)
301 301
     {
302 302
         // phpcs:enable
303
-		// Rule Dolibarr: No HTML
304
-		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
303
+        // Rule Dolibarr: No HTML
304
+        $newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
305 305
 
306
-		// Rule 1 TSV: No CR, LF in cells
307
-    	$newvalue=str_replace("\r",'',$newvalue);
306
+        // Rule 1 TSV: No CR, LF in cells
307
+        $newvalue=str_replace("\r",'',$newvalue);
308 308
         $newvalue=str_replace("\n",'\n',$newvalue);
309 309
 
310 310
         // Rule 2 TSV: If value contains tab, we must replace by space
311
-		if (preg_match('/'.$this->separator.'/',$newvalue))
312
-		{
313
-			$newvalue=str_replace("\t"," ",$newvalue);
314
-		}
311
+        if (preg_match('/'.$this->separator.'/',$newvalue))
312
+        {
313
+            $newvalue=str_replace("\t"," ",$newvalue);
314
+        }
315 315
 
316 316
         return $newvalue;
317 317
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/modules_export.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -30,140 +30,140 @@
 block discarded – undo
30 30
  */
31 31
 class ModeleExports extends CommonDocGenerator    // This class can't be abstract as there is instance propreties loaded by liste_modeles
32 32
 {
33
-	/**
34
-	 * @var string Error code (or message)
35
-	 */
36
-	public $error='';
33
+    /**
34
+     * @var string Error code (or message)
35
+     */
36
+    public $error='';
37 37
 
38
-	public $driverlabel=array();
38
+    public $driverlabel=array();
39 39
 
40
-	public $driverversion=array();
40
+    public $driverversion=array();
41 41
 
42
-	public $liblabel=array();
42
+    public $liblabel=array();
43 43
 
44
-	public $libversion=array();
44
+    public $libversion=array();
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
48
-	/**
49
-	 *  Load into memory list of available export format
50
-	 *
48
+    /**
49
+     *  Load into memory list of available export format
50
+     *
51 51
      *  @param	DoliDB	$db     			Database handler
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates (same content than array this->driverlabel)
54
-	 */
55
-	function liste_modeles($db,$maxfilenamelength=0)
56
-	{
54
+     */
55
+    function liste_modeles($db,$maxfilenamelength=0)
56
+    {
57 57
         // phpcs:enable
58
-		dol_syslog(get_class($this)."::liste_modeles");
58
+        dol_syslog(get_class($this)."::liste_modeles");
59 59
 
60
-		$dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
61
-		$handle=opendir($dir);
60
+        $dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
61
+        $handle=opendir($dir);
62 62
 
63
-		// Recherche des fichiers drivers exports disponibles
64
-		$i=0;
63
+        // Recherche des fichiers drivers exports disponibles
64
+        $i=0;
65 65
         if (is_resource($handle))
66 66
         {
67
-    		while (($file = readdir($handle))!==false)
68
-    		{
69
-    			if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
70
-    			{
71
-    				$moduleid=$reg[1];
72
-
73
-    				// Loading Class
74
-    				$file = $dir."export_".$moduleid.".modules.php";
75
-    				$classname = "Export".ucfirst($moduleid);
76
-
77
-    				require_once $file;
78
-    				if (class_exists($classname))
79
-    				{
80
-        				$module = new $classname($db);
81
-
82
-        				// Picto
83
-        				$this->picto[$module->id]=$module->picto;
84
-        				// Driver properties
85
-        				$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
86
-        				$this->driverdesc[$module->id]=$module->getDriverDesc();
87
-        				$this->driverversion[$module->id]=$module->getDriverVersion();
88
-        				// If use an external lib
89
-        				$this->liblabel[$module->id]=$module->getLibLabel();
90
-        				$this->libversion[$module->id]=$module->getLibVersion();
91
-    				}
92
-    				$i++;
93
-    			}
94
-    		}
95
-    		closedir($handle);
67
+            while (($file = readdir($handle))!==false)
68
+            {
69
+                if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
70
+                {
71
+                    $moduleid=$reg[1];
72
+
73
+                    // Loading Class
74
+                    $file = $dir."export_".$moduleid.".modules.php";
75
+                    $classname = "Export".ucfirst($moduleid);
76
+
77
+                    require_once $file;
78
+                    if (class_exists($classname))
79
+                    {
80
+                        $module = new $classname($db);
81
+
82
+                        // Picto
83
+                        $this->picto[$module->id]=$module->picto;
84
+                        // Driver properties
85
+                        $this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
86
+                        $this->driverdesc[$module->id]=$module->getDriverDesc();
87
+                        $this->driverversion[$module->id]=$module->getDriverVersion();
88
+                        // If use an external lib
89
+                        $this->liblabel[$module->id]=$module->getLibLabel();
90
+                        $this->libversion[$module->id]=$module->getLibVersion();
91
+                    }
92
+                    $i++;
93
+                }
94
+            }
95
+            closedir($handle);
96 96
         }
97 97
 
98 98
         asort($this->driverlabel);
99 99
 
100
-		return $this->driverlabel;
101
-	}
102
-
103
-
104
-	/**
105
-	 *  Return picto of export driver
106
-	 *
107
-	 *  @param	string	$key	Key of driver
108
-	 *  @return	string			Picto string
109
-	 */
110
-	function getPictoForKey($key)
111
-	{
112
-		return $this->picto[$key];
113
-	}
114
-
115
-	/**
116
-	 *  Renvoi libelle d'un driver export
117
-	 *
118
-	 *  @param	string	$key	Key of driver
119
-	 *  @return	string			Label
120
-	 */
121
-	function getDriverLabelForKey($key)
122
-	{
123
-		return $this->driverlabel[$key];
124
-	}
125
-
126
-	/**
127
-	 *  Renvoi le descriptif d'un driver export
128
-	 *
129
-	 *  @param	string	$key	Key of driver
130
-	 *  @return	string			Description
131
-	 */
132
-	function getDriverDescForKey($key)
133
-	{
134
-		return $this->driverdesc[$key];
135
-	}
136
-
137
-	/**
138
-	 *  Renvoi version d'un driver export
139
-	 *
140
-	 *  @param	string	$key	Key of driver
141
-	 *  @return	string			Driver version
142
-	 */
143
-	function getDriverVersionForKey($key)
144
-	{
145
-		return $this->driverversion[$key];
146
-	}
147
-
148
-	/**
149
-	 *  Renvoi libelle de librairie externe du driver
150
-	 *
151
-	 *  @param	string	$key	Key of driver
152
-	 *  @return	string			Label of library
153
-	 */
154
-	function getLibLabelForKey($key)
155
-	{
156
-		return $this->liblabel[$key];
157
-	}
158
-
159
-	/**
160
-	 *  Renvoi version de librairie externe du driver
161
-	 *
162
-	 *  @param	string	$key	Key of driver
163
-	 *  @return	string			Version of library
164
-	 */
165
-	function getLibVersionForKey($key)
166
-	{
167
-		return $this->libversion[$key];
168
-	}
100
+        return $this->driverlabel;
101
+    }
102
+
103
+
104
+    /**
105
+     *  Return picto of export driver
106
+     *
107
+     *  @param	string	$key	Key of driver
108
+     *  @return	string			Picto string
109
+     */
110
+    function getPictoForKey($key)
111
+    {
112
+        return $this->picto[$key];
113
+    }
114
+
115
+    /**
116
+     *  Renvoi libelle d'un driver export
117
+     *
118
+     *  @param	string	$key	Key of driver
119
+     *  @return	string			Label
120
+     */
121
+    function getDriverLabelForKey($key)
122
+    {
123
+        return $this->driverlabel[$key];
124
+    }
125
+
126
+    /**
127
+     *  Renvoi le descriptif d'un driver export
128
+     *
129
+     *  @param	string	$key	Key of driver
130
+     *  @return	string			Description
131
+     */
132
+    function getDriverDescForKey($key)
133
+    {
134
+        return $this->driverdesc[$key];
135
+    }
136
+
137
+    /**
138
+     *  Renvoi version d'un driver export
139
+     *
140
+     *  @param	string	$key	Key of driver
141
+     *  @return	string			Driver version
142
+     */
143
+    function getDriverVersionForKey($key)
144
+    {
145
+        return $this->driverversion[$key];
146
+    }
147
+
148
+    /**
149
+     *  Renvoi libelle de librairie externe du driver
150
+     *
151
+     *  @param	string	$key	Key of driver
152
+     *  @return	string			Label of library
153
+     */
154
+    function getLibLabelForKey($key)
155
+    {
156
+        return $this->liblabel[$key];
157
+    }
158
+
159
+    /**
160
+     *  Renvoi version de librairie externe du driver
161
+     *
162
+     *  @param	string	$key	Key of driver
163
+     *  @return	string			Version of library
164
+     */
165
+    function getLibVersionForKey($key)
166
+    {
167
+        return $this->libversion[$key];
168
+    }
169 169
 }
Please login to merge, or discard this patch.