Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/modAsset.class.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -32,122 +32,122 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class modAsset extends DolibarrModules
34 34
 {
35
-	/**
36
-	 * Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 * @param DoliDB $db Database handler
39
-	 */
40
-	public function __construct($db)
41
-	{
42
-		global $langs,$conf;
43
-
44
-		$this->db = $db;
45
-
46
-		// Id for module (must be unique).
47
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
-		$this->numero = 51000;		// TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
49
-		// Key text used to identify module (for permissions, menus, etc...)
50
-		$this->rights_class = 'asset';
51
-
52
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
-		// It is used to group modules by family in module setup page
54
-		$this->family = "financial";
55
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
56
-		$this->module_position = '70';
57
-		// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
-
60
-		// Module label (no space allowed), used if translation string 'ModuleAssetsName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
62
-		// Module description, used if translation string 'ModuleAssetsDesc' not found (MyModue is name of module).
63
-		$this->description = "Assets module";
64
-		// Used only if file README.md and README-LL.md not found.
65
-		$this->descriptionlong = "Assets module to manage assets module and depreciation charge on Dolibarr";
66
-
67
-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
-		$this->version = 'development';
69
-		// Key used in llx_const table to save module status enabled/disabled (where ASSETS is value of property name of module in uppercase)
70
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
-		// Name of image file used for this module.
72
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='generic';
75
-
76
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
-		// for default path (eg: /asset/core/xxxxx) (0=disable, 1=enable)
78
-		// for specific path of parts (eg: /asset/core/modules/barcode)
79
-		// for specific css file (eg: /asset/css/assets.css.php)
80
-		$this->module_parts = array();
81
-
82
-		// Data directories to create when module is enabled.
83
-		// Example: this->dirs = array("/asset/temp","/asset/subdir");
84
-		$this->dirs = array();
85
-
86
-		// Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module.
87
-		$this->config_page_url = array("setup.php@asset");
88
-
89
-		// Dependencies
90
-		$this->hidden = false;			// A condition to hide module
91
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
92
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
93
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
94
-		$this->langfiles = array("assets");
95
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
96
-		$this->need_dolibarr_version = array(7,0);	// Minimum version of Dolibarr required by module
97
-		$this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
99
-		//$this->automatic_activation = array('FR'=>'AssetsWasAutomaticallyActivatedBecauseOfYourCountryChoice');
100
-		//$this->always_enabled = true;								// If true, can't be disabled
101
-
102
-		// Constants
103
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
104
-		// Example: $this->const=array(0=>array('ASSETS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
105
-		//                             1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
106
-		// );
107
-		$this->const = array(
108
-			1=>array('ASSET_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
109
-		);
110
-
111
-
112
-		if (! isset($conf->asset) || ! isset($conf->asset->enabled))
113
-		{
114
-			$conf->asset=new stdClass();
115
-			$conf->asset->enabled=0;
116
-		}
117
-
118
-
119
-		// Array to add new pages in new tabs
120
-		$this->tabs = array();
121
-		// Example:
122
-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
123
-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
124
-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
125
-		//
126
-		// Where objecttype can be
127
-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
128
-		// 'contact'          to add a tab in contact view
129
-		// 'contract'         to add a tab in contract view
130
-		// 'group'            to add a tab in group view
131
-		// 'intervention'     to add a tab in intervention view
132
-		// 'invoice'          to add a tab in customer invoice view
133
-		// 'invoice_supplier' to add a tab in supplier invoice view
134
-		// 'member'           to add a tab in fundation member view
135
-		// 'opensurveypoll'	  to add a tab in opensurvey poll view
136
-		// 'order'            to add a tab in customer order view
137
-		// 'order_supplier'   to add a tab in supplier order view
138
-		// 'payment'		  to add a tab in payment view
139
-		// 'payment_supplier' to add a tab in supplier payment view
140
-		// 'product'          to add a tab in product view
141
-		// 'propal'           to add a tab in propal view
142
-		// 'project'          to add a tab in project view
143
-		// 'stock'            to add a tab in stock view
144
-		// 'thirdparty'       to add a tab in third party view
145
-		// 'user'             to add a tab in user view
146
-
147
-
148
-		// Dictionaries
149
-		$this->dictionaries=array();
150
-		/* Example:
35
+    /**
36
+     * Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     * @param DoliDB $db Database handler
39
+     */
40
+    public function __construct($db)
41
+    {
42
+        global $langs,$conf;
43
+
44
+        $this->db = $db;
45
+
46
+        // Id for module (must be unique).
47
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
+        $this->numero = 51000;		// TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
49
+        // Key text used to identify module (for permissions, menus, etc...)
50
+        $this->rights_class = 'asset';
51
+
52
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
+        // It is used to group modules by family in module setup page
54
+        $this->family = "financial";
55
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
56
+        $this->module_position = '70';
57
+        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
+
60
+        // Module label (no space allowed), used if translation string 'ModuleAssetsName' not found (MyModue is name of module).
61
+        $this->name = preg_replace('/^mod/i','',get_class($this));
62
+        // Module description, used if translation string 'ModuleAssetsDesc' not found (MyModue is name of module).
63
+        $this->description = "Assets module";
64
+        // Used only if file README.md and README-LL.md not found.
65
+        $this->descriptionlong = "Assets module to manage assets module and depreciation charge on Dolibarr";
66
+
67
+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
+        $this->version = 'development';
69
+        // Key used in llx_const table to save module status enabled/disabled (where ASSETS is value of property name of module in uppercase)
70
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
+        // Name of image file used for this module.
72
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
+        $this->picto='generic';
75
+
76
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
+        // for default path (eg: /asset/core/xxxxx) (0=disable, 1=enable)
78
+        // for specific path of parts (eg: /asset/core/modules/barcode)
79
+        // for specific css file (eg: /asset/css/assets.css.php)
80
+        $this->module_parts = array();
81
+
82
+        // Data directories to create when module is enabled.
83
+        // Example: this->dirs = array("/asset/temp","/asset/subdir");
84
+        $this->dirs = array();
85
+
86
+        // Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module.
87
+        $this->config_page_url = array("setup.php@asset");
88
+
89
+        // Dependencies
90
+        $this->hidden = false;			// A condition to hide module
91
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
92
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
93
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
94
+        $this->langfiles = array("assets");
95
+        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
96
+        $this->need_dolibarr_version = array(7,0);	// Minimum version of Dolibarr required by module
97
+        $this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
+        $this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
99
+        //$this->automatic_activation = array('FR'=>'AssetsWasAutomaticallyActivatedBecauseOfYourCountryChoice');
100
+        //$this->always_enabled = true;								// If true, can't be disabled
101
+
102
+        // Constants
103
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
104
+        // Example: $this->const=array(0=>array('ASSETS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
105
+        //                             1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
106
+        // );
107
+        $this->const = array(
108
+            1=>array('ASSET_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
109
+        );
110
+
111
+
112
+        if (! isset($conf->asset) || ! isset($conf->asset->enabled))
113
+        {
114
+            $conf->asset=new stdClass();
115
+            $conf->asset->enabled=0;
116
+        }
117
+
118
+
119
+        // Array to add new pages in new tabs
120
+        $this->tabs = array();
121
+        // Example:
122
+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
123
+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
124
+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
125
+        //
126
+        // Where objecttype can be
127
+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
128
+        // 'contact'          to add a tab in contact view
129
+        // 'contract'         to add a tab in contract view
130
+        // 'group'            to add a tab in group view
131
+        // 'intervention'     to add a tab in intervention view
132
+        // 'invoice'          to add a tab in customer invoice view
133
+        // 'invoice_supplier' to add a tab in supplier invoice view
134
+        // 'member'           to add a tab in fundation member view
135
+        // 'opensurveypoll'	  to add a tab in opensurvey poll view
136
+        // 'order'            to add a tab in customer order view
137
+        // 'order_supplier'   to add a tab in supplier order view
138
+        // 'payment'		  to add a tab in payment view
139
+        // 'payment_supplier' to add a tab in supplier payment view
140
+        // 'product'          to add a tab in product view
141
+        // 'propal'           to add a tab in propal view
142
+        // 'project'          to add a tab in project view
143
+        // 'stock'            to add a tab in stock view
144
+        // 'thirdparty'       to add a tab in third party view
145
+        // 'user'             to add a tab in user view
146
+
147
+
148
+        // Dictionaries
149
+        $this->dictionaries=array();
150
+        /* Example:
151 151
 		$this->dictionaries=array(
152 152
 			'langs'=>'mylangfile@assets',
153 153
 			'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor
@@ -163,69 +163,69 @@  discard block
 block discarded – undo
163 163
 		*/
164 164
 
165 165
 
166
-		// Boxes/Widgets
167
-		// Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget.
168
-		$this->boxes = array(
169
-			//0=>array('file'=>'assetswidget1.php@asset','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'),
170
-			//1=>array('file'=>'assetswidget2.php@asset','note'=>'Widget provided by Assets'),
171
-			//2=>array('file'=>'assetswidget3.php@asset','note'=>'Widget provided by Assets')
172
-		);
173
-
174
-
175
-		// Cronjobs (List of cron jobs entries to add when module is enabled)
176
-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
177
-		//$this->cronjobs = array(
178
-		//	0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/asset/class/asset.class.php', 'objectname'=>'Asset', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
179
-		//);
180
-		// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
181
-		//                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
182
-		// );
183
-
184
-
185
-		// Permissions
186
-		$this->rights = array();		// Permission array used by this module
187
-
188
-		$r=0;
189
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
190
-		$this->rights[$r][1] = 'Read assets';		// Permission label
191
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
192
-		$this->rights[$r][4] = 'read';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
193
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
194
-
195
-		$r++;
196
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
197
-		$this->rights[$r][1] = 'Create/Update assets';	// Permission label
198
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
199
-		$this->rights[$r][4] = 'write';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
200
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
201
-
202
-		$r++;
203
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
204
-		$this->rights[$r][1] = 'Delete assets';		// Permission label
205
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
206
-		$this->rights[$r][4] = 'delete';			// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
207
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
208
-
209
-
210
-		// Main menu entries
211
-		$this->menu = array();			// List of menus to add
212
-		$r=0;
213
-
214
-		// Add here entries to declare new menus
215
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
216
-
217
-		// Exports
218
-		//--------
219
-		$r=1;
220
-
221
-		// $this->export_code[$r]          Code unique identifiant l'export (tous modules confondus)
222
-		// $this->export_label[$r]         Libelle par defaut si traduction de cle "ExportXXX" non trouvee (XXX = Code)
223
-		// $this->export_permission[$r]    Liste des codes permissions requis pour faire l'export
224
-		// $this->export_fields_sql[$r]    Liste des champs exportables en codif sql
225
-		// $this->export_fields_name[$r]   Liste des champs exportables en codif traduction
226
-		// $this->export_sql[$r]           Requete sql qui offre les donnees a l'export
227
-
228
-		/*
166
+        // Boxes/Widgets
167
+        // Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget.
168
+        $this->boxes = array(
169
+            //0=>array('file'=>'assetswidget1.php@asset','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'),
170
+            //1=>array('file'=>'assetswidget2.php@asset','note'=>'Widget provided by Assets'),
171
+            //2=>array('file'=>'assetswidget3.php@asset','note'=>'Widget provided by Assets')
172
+        );
173
+
174
+
175
+        // Cronjobs (List of cron jobs entries to add when module is enabled)
176
+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
177
+        //$this->cronjobs = array(
178
+        //	0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/asset/class/asset.class.php', 'objectname'=>'Asset', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
179
+        //);
180
+        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
181
+        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
182
+        // );
183
+
184
+
185
+        // Permissions
186
+        $this->rights = array();		// Permission array used by this module
187
+
188
+        $r=0;
189
+        $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
190
+        $this->rights[$r][1] = 'Read assets';		// Permission label
191
+        $this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
192
+        $this->rights[$r][4] = 'read';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
193
+        $this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
194
+
195
+        $r++;
196
+        $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
197
+        $this->rights[$r][1] = 'Create/Update assets';	// Permission label
198
+        $this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
199
+        $this->rights[$r][4] = 'write';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
200
+        $this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
201
+
202
+        $r++;
203
+        $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
204
+        $this->rights[$r][1] = 'Delete assets';		// Permission label
205
+        $this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
206
+        $this->rights[$r][4] = 'delete';			// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
207
+        $this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
208
+
209
+
210
+        // Main menu entries
211
+        $this->menu = array();			// List of menus to add
212
+        $r=0;
213
+
214
+        // Add here entries to declare new menus
215
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
216
+
217
+        // Exports
218
+        //--------
219
+        $r=1;
220
+
221
+        // $this->export_code[$r]          Code unique identifiant l'export (tous modules confondus)
222
+        // $this->export_label[$r]         Libelle par defaut si traduction de cle "ExportXXX" non trouvee (XXX = Code)
223
+        // $this->export_permission[$r]    Liste des codes permissions requis pour faire l'export
224
+        // $this->export_fields_sql[$r]    Liste des champs exportables en codif sql
225
+        // $this->export_fields_name[$r]   Liste des champs exportables en codif traduction
226
+        // $this->export_sql[$r]           Requete sql qui offre les donnees a l'export
227
+
228
+        /*
229 229
 		$r++;
230 230
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
231 231
 		$this->export_label[$r]='AssetsLines';
@@ -310,25 +310,25 @@  discard block
 block discarded – undo
310 310
 			'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')
311 311
 		);
312 312
 		*/
313
-	}
314
-
315
-	/**
316
-	 *	Function called when module is enabled.
317
-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
318
-	 *	It also creates data directories
319
-	 *
320
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')
321
-	 *	@return     int             	1 if OK, 0 if KO
322
-	 */
323
-	function init($options='')
324
-	{
325
-		global $conf;
326
-
327
-		// Permissions
328
-		$this->remove($options);
329
-
330
-		$sql = array();
331
-
332
-		return $this->_init($sql,$options);
333
-	}
313
+    }
314
+
315
+    /**
316
+     *	Function called when module is enabled.
317
+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
318
+     *	It also creates data directories
319
+     *
320
+     *	@param      string	$options    Options when enabling module ('', 'noboxes')
321
+     *	@return     int             	1 if OK, 0 if KO
322
+     */
323
+    function init($options='')
324
+    {
325
+        global $conf;
326
+
327
+        // Permissions
328
+        $this->remove($options);
329
+
330
+        $sql = array();
331
+
332
+        return $this->_init($sql,$options);
333
+    }
334 334
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *  \ingroup    asset
25 25
  *  \brief      Description and activation file for module Assets
26 26
  */
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct($db)
41 41
 	{
42
-		global $langs,$conf;
42
+		global $langs, $conf;
43 43
 
44 44
 		$this->db = $db;
45 45
 
46 46
 		// Id for module (must be unique).
47 47
 		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
-		$this->numero = 51000;		// TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
48
+		$this->numero = 51000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
49 49
 		// Key text used to identify module (for permissions, menus, etc...)
50 50
 		$this->rights_class = 'asset';
51 51
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59 59
 
60 60
 		// Module label (no space allowed), used if translation string 'ModuleAssetsName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
61
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
62 62
 		// Module description, used if translation string 'ModuleAssetsDesc' not found (MyModue is name of module).
63 63
 		$this->description = "Assets module";
64 64
 		// Used only if file README.md and README-LL.md not found.
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		// Name of image file used for this module.
72 72
 		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73 73
 		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='generic';
74
+		$this->picto = 'generic';
75 75
 
76 76
 		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77 77
 		// for default path (eg: /asset/core/xxxxx) (0=disable, 1=enable)
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 		$this->config_page_url = array("setup.php@asset");
88 88
 
89 89
 		// Dependencies
90
-		$this->hidden = false;			// A condition to hide module
91
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
92
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
93
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
90
+		$this->hidden = false; // A condition to hide module
91
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
92
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
93
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
94 94
 		$this->langfiles = array("assets");
95
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
96
-		$this->need_dolibarr_version = array(7,0);	// Minimum version of Dolibarr required by module
97
-		$this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
95
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
96
+		$this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module
97
+		$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
+		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
99 99
 		//$this->automatic_activation = array('FR'=>'AssetsWasAutomaticallyActivatedBecauseOfYourCountryChoice');
100 100
 		//$this->always_enabled = true;								// If true, can't be disabled
101 101
 
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 		);
110 110
 
111 111
 
112
-		if (! isset($conf->asset) || ! isset($conf->asset->enabled))
112
+		if (!isset($conf->asset) || !isset($conf->asset->enabled))
113 113
 		{
114
-			$conf->asset=new stdClass();
115
-			$conf->asset->enabled=0;
114
+			$conf->asset = new stdClass();
115
+			$conf->asset->enabled = 0;
116 116
 		}
117 117
 
118 118
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 
148 148
 		// Dictionaries
149
-		$this->dictionaries=array();
149
+		$this->dictionaries = array();
150 150
 		/* Example:
151 151
 		$this->dictionaries=array(
152 152
 			'langs'=>'mylangfile@assets',
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 
184 184
 
185 185
 		// Permissions
186
-		$this->rights = array();		// Permission array used by this module
186
+		$this->rights = array(); // Permission array used by this module
187 187
 
188
-		$r=0;
189
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
190
-		$this->rights[$r][1] = 'Read assets';		// Permission label
191
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
192
-		$this->rights[$r][4] = 'read';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
193
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
188
+		$r = 0;
189
+		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
190
+		$this->rights[$r][1] = 'Read assets'; // Permission label
191
+		$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
192
+		$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
193
+		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
194 194
 
195 195
 		$r++;
196
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
197
-		$this->rights[$r][1] = 'Create/Update assets';	// Permission label
198
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
199
-		$this->rights[$r][4] = 'write';				// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
200
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
196
+		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
197
+		$this->rights[$r][1] = 'Create/Update assets'; // Permission label
198
+		$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
199
+		$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
200
+		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
201 201
 
202 202
 		$r++;
203
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
204
-		$this->rights[$r][1] = 'Delete assets';		// Permission label
205
-		$this->rights[$r][3] = 1; 					// Permission by default for new user (0/1)
206
-		$this->rights[$r][4] = 'delete';			// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
207
-		$this->rights[$r][5] = '';					// In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
203
+		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
204
+		$this->rights[$r][1] = 'Delete assets'; // Permission label
205
+		$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
206
+		$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
207
+		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
208 208
 
209 209
 
210 210
 		// Main menu entries
211
-		$this->menu = array();			// List of menus to add
212
-		$r=0;
211
+		$this->menu = array(); // List of menus to add
212
+		$r = 0;
213 213
 
214 214
 		// Add here entries to declare new menus
215
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
215
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
216 216
 
217 217
 		// Exports
218 218
 		//--------
219
-		$r=1;
219
+		$r = 1;
220 220
 
221 221
 		// $this->export_code[$r]          Code unique identifiant l'export (tous modules confondus)
222 222
 		// $this->export_label[$r]         Libelle par defaut si traduction de cle "ExportXXX" non trouvee (XXX = Code)
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 *	@param      string	$options    Options when enabling module ('', 'noboxes')
321 321
 	 *	@return     int             	1 if OK, 0 if KO
322 322
 	 */
323
-	function init($options='')
323
+	function init($options = '')
324 324
 	{
325 325
 		global $conf;
326 326
 
@@ -329,6 +329,6 @@  discard block
 block discarded – undo
329 329
 
330 330
 		$sql = array();
331 331
 
332
-		return $this->_init($sql,$options);
332
+		return $this->_init($sql, $options);
333 333
 	}
334 334
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modUser.class.php 3 patches
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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -263,11 +263,13 @@
 block discarded – undo
263 263
 		// Add extra fields
264 264
 		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
265 265
 		$resql=$this->db->query($sql);
266
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
266
+		if ($resql) {
267
+		    // This can fail when class is used on old database (during migration for example)
267 268
 		{
268 269
 		    while ($obj=$this->db->fetch_object($resql))
269 270
 		    {
270 271
 		        $fieldname='extra.'.$obj->name;
272
+		}
271 273
 		        $fieldlabel=ucfirst($obj->label);
272 274
 		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
273 275
 		    }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 
29 29
 //include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
30
-include_once DOL_BASE_PATH . '/core/modules/DolibarrModules.class.php';
30
+include_once DOL_BASE_PATH.'/core/modules/DolibarrModules.class.php';
31 31
 
32 32
 /**
33 33
  *	Class to describe and enable module User
@@ -47,17 +47,17 @@  discard block
 block discarded – undo
47 47
 		$this->db = $db;
48 48
 		$this->numero = 0;
49 49
 
50
-		$this->family = "hr";		// Family for module (or "base" if core module)
50
+		$this->family = "hr"; // Family for module (or "base" if core module)
51 51
 		$this->module_position = '10';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Gestion des utilisateurs (requis)";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='group';
60
+		$this->picto = 'group';
61 61
 
62 62
 		// Data directories to create when module is enabled
63 63
 		$this->dirs = array("/users/temp");
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 		$this->config_page_url = array("user.php");
67 67
 
68 68
 		// Dependencies
69
-		$this->hidden = false;			// A condition to hide module
70
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
71
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
72
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
73
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
74
-		$this->langfiles = array("main","users","companies","members",'salaries');
75
-		$this->always_enabled = true;	// Can't be disabled
69
+		$this->hidden = false; // A condition to hide module
70
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
71
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
72
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
73
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
74
+		$this->langfiles = array("main", "users", "companies", "members", 'salaries');
75
+		$this->always_enabled = true; // Can't be disabled
76 76
 
77 77
 		// Constants
78 78
 		$this->const = array();
79 79
 
80 80
 		// Boxes
81 81
 		$this->boxes = array(
82
-		    0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
82
+		    0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'),
83 83
 		);
84 84
 
85 85
 		// Permissions
86 86
 		$this->rights = array();
87 87
 		$this->rights_class = 'user';
88
-		$this->rights_admin_allowed = 1;	// Admin is always granted of permission (even when module is disabled)
89
-		$r=0;
88
+		$this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
89
+		$r = 0;
90 90
 
91 91
 		$r++;
92 92
 		$this->rights[$r][0] = 251;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$this->rights[$r][1] = 'Consulter ses propres permissions';
142 142
 		$this->rights[$r][2] = 'r';
143 143
 		$this->rights[$r][3] = 0;
144
-		$this->rights[$r][4] = 'self_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
144
+		$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
145 145
 		$this->rights[$r][5] = 'readperms';
146 146
 
147 147
 		$r++;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		$this->rights[$r][1] = 'Modifier ses propres permissions';
166 166
 		$this->rights[$r][2] = 'w';
167 167
 		$this->rights[$r][3] = 0;
168
-		$this->rights[$r][4] = 'self_advance';          // Visible if option MAIN_USE_ADVANCED_PERMS is on
168
+		$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
169 169
 		$this->rights[$r][5] = 'writeperms';
170 170
 
171 171
 		$r++;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		$this->rights[$r][1] = 'Consulter les groupes';
174 174
 		$this->rights[$r][2] = 'r';
175 175
 		$this->rights[$r][3] = 0;
176
-		$this->rights[$r][4] = 'group_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
176
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
177 177
 		$this->rights[$r][5] = 'read';
178 178
 
179 179
 		$r++;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		$this->rights[$r][1] = 'Consulter les permissions des groupes';
182 182
 		$this->rights[$r][2] = 'r';
183 183
 		$this->rights[$r][3] = 0;
184
-		$this->rights[$r][4] = 'group_advance';       // Visible if option MAIN_USE_ADVANCED_PERMS is on
184
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
185 185
 		$this->rights[$r][5] = 'readperms';
186 186
 
187 187
 		$r++;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
190 190
 		$this->rights[$r][2] = 'w';
191 191
 		$this->rights[$r][3] = 0;
192
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
192
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
193 193
 		$this->rights[$r][5] = 'write';
194 194
 
195 195
 		$r++;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
198 198
 		$this->rights[$r][2] = 'd';
199 199
 		$this->rights[$r][3] = 0;
200
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
200
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
201 201
 		$this->rights[$r][5] = 'delete';
202 202
 
203 203
 		$r++;
@@ -210,89 +210,89 @@  discard block
 block discarded – undo
210 210
 
211 211
 
212 212
         // Menus
213
-        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
213
+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.
214 214
 
215 215
 
216 216
 		// Exports
217
-		$r=0;
217
+		$r = 0;
218 218
 
219 219
 		$r++;
220
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
221
-		$this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
222
-		$this->export_permission[$r]=array(array("user","user","export"));
223
-		$this->export_fields_array[$r]=array(
224
-			'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",
225
-			'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",
226
-			'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion',
227
-			'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"
220
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
221
+		$this->export_label[$r] = 'Liste des utilisateurs Dolibarr et attributs';
222
+		$this->export_permission[$r] = array(array("user", "user", "export"));
223
+		$this->export_fields_array[$r] = array(
224
+			'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.accountancy_code'=>"UserAccountancyCode",
225
+			'u.office_phone'=>'Phone', 'u.office_fax'=>'Fax', 'u.email'=>'EMail', 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification",
226
+			'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.note'=>"Note", 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion',
227
+			'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId"
228 228
 		);
229
-		$this->export_TypeFields_array[$r]=array(
230
-			'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text',
231
-			'u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date',
232
-			'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"
229
+		$this->export_TypeFields_array[$r] = array(
230
+			'u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.accountancy_code'=>'Text', 'u.office_phone'=>'Text', 'u.office_fax'=>'Text',
231
+			'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date',
232
+			'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname"
233 233
 		);
234
-		$this->export_entities_array[$r]=array(
235
-			'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user',
236
-			'u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",
237
-			'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"
234
+		$this->export_entities_array[$r] = array(
235
+			'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.accountancy_code'=>'user', 'u.office_phone'=>'user',
236
+			'u.office_fax'=>'user', 'u.email'=>'user', 'u.datec'=>"user", 'u.tms'=>"user", 'u.admin'=>"user", 'u.statut'=>'user', 'u.note'=>"user",
237
+			'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member"
238 238
 		);
239 239
         if (empty($conf->adherent->enabled))
240 240
         {
241 241
             unset($this->export_fields_array[$r]['u.fk_member']);
242 242
             unset($this->export_entities_array[$r]['u.fk_member']);
243 243
         }
244
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
245
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
246
-		$this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
244
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
245
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'user as u';
246
+		$this->export_sql_end[$r] .= ' WHERE u.entity IN ('.getEntity('user').')';
247 247
 
248 248
 		// Imports
249
-		$r=0;
249
+		$r = 0;
250 250
 
251 251
 		// Import list of users attributes
252 252
 		$r++;
253
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
254
-		$this->import_label[$r]='ImportDataset_user_1';
255
-		$this->import_icon[$r]='user';
256
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
257
-		$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)
258
-		$this->import_fields_array[$r]=array(
259
-			'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"Job",'u.gender'=>"Gender",'u.login'=>"Login*",
260
-			'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
261
-			'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",
262
-			'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature','u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM',
263
-			'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey','u.datec'=>"DateCreation"
253
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
254
+		$this->import_label[$r] = 'ImportDataset_user_1';
255
+		$this->import_icon[$r] = 'user';
256
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
257
+		$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)
258
+		$this->import_fields_array[$r] = array(
259
+			'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"Job", 'u.gender'=>"Gender", 'u.login'=>"Login*",
260
+			'u.pass_crypted'=>"Password", 'u.admin'=>"Administrator", 'u.fk_soc'=>"Company*", 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town",
261
+			'u.fk_state'=>"StateId", 'u.fk_country'=>"CountryCode", 'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax",
262
+			'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', 'u.fk_user'=>'Supervisor', 'u.thm'=>'THM', 'u.tjm'=>'TJM',
263
+			'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', 'u.datec'=>"DateCreation"
264 264
 		);
265 265
 		// Add extra fields
266
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
267
-		$resql=$this->db->query($sql);
266
+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
267
+		$resql = $this->db->query($sql);
268 268
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
269 269
 		{
270
-		    while ($obj=$this->db->fetch_object($resql))
270
+		    while ($obj = $this->db->fetch_object($resql))
271 271
 		    {
272
-		        $fieldname='extra.'.$obj->name;
273
-		        $fieldlabel=ucfirst($obj->label);
274
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
272
+		        $fieldname = 'extra.'.$obj->name;
273
+		        $fieldlabel = ucfirst($obj->label);
274
+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
275 275
 		    }
276 276
 		}
277 277
 		// End add extra fields
278
-		$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)
279
-		$this->import_convertvalue_array[$r]=array(
280
-			'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
281
-		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
278
+		$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)
279
+		$this->import_convertvalue_array[$r] = array(
280
+			'u.fk_state'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'),
281
+		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'),
282 282
 		    'u.salary'=>array('rule'=>'numeric')
283 283
 		);
284 284
 		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
285
-		$this->import_regex_array[$r]=array(
285
+		$this->import_regex_array[$r] = array(
286 286
 			'u.employee'=>'^[0|1]',
287 287
 			'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])?$'
288 288
 		);
289
-		$this->import_examplevalues_array[$r]=array(
290
-			'u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)",
291
-			'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",
292
-			'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",
293
-			'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"
289
+		$this->import_examplevalues_array[$r] = array(
290
+			'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.status'=>"0 (closed) or 1 (active)",
291
+			'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",
292
+			'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102",
293
+			'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"
294 294
 		);
295
-		$this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login');
295
+		$this->import_updatekeys_array[$r] = array('u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>'Login');
296 296
 	}
297 297
 
298 298
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
305 305
 	 *      @return     int             	1 if OK, 0 if KO
306 306
      */
307
-	function init($options='')
307
+	function init($options = '')
308 308
 	{
309 309
 		global $conf;
310 310
 
@@ -313,6 +313,6 @@  discard block
 block discarded – undo
313 313
 
314 314
 		$sql = array();
315 315
 
316
-		return $this->_init($sql,$options);
316
+		return $this->_init($sql, $options);
317 317
 	}
318 318
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modWebServicesClient.class.php 2 patches
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.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *       \ingroup    webservices
23 23
  *       \brief      File to describe client for supplier webservices module
24 24
  */
25
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
25
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
26 26
 
27 27
 /**
28 28
  *	Class to describe a sync supplier web services module
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
         $this->family = "interface";
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
-        $this->name = preg_replace('/^mod/i','',get_class($this));
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 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);
51 51
         // Name of image file used for this module.
52
-        $this->picto='technic';
52
+        $this->picto = 'technic';
53 53
 
54 54
         // Data directories to create when module is enabled
55 55
         $this->dirs = array();
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
         //$this->config_page_url = array();
59 59
 
60 60
         // Dependencies
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
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
66 66
         $this->langfiles = array("other");
67 67
 
68 68
         // Constants
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
         // Permissions
78 78
         $this->rights = array();
79 79
         $this->rights_class = 'syncsupplierwebservices';
80
-        $r=0;
80
+        $r = 0;
81 81
     }
82 82
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modCashDesk.class.php 2 patches
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.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *      \ingroup    pos
23 23
  *      \brief      File to enable/disable module Point Of Sales
24 24
  */
25
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
25
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
26 26
 
27 27
 
28 28
 /**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$this->family = "portal";
49 49
 		$this->module_position = '55';
50 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));
51
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
52 52
 		$this->description = "CashDesk module";
53 53
 
54 54
 		$this->revision = '1.27';
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
 		$this->config_page_url = array("cashdesk.php@cashdesk");
65 65
 
66 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
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 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')
73
+		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
74 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 75
 
76 76
 		// Constants
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 		// Permissions
83 83
 		$this->rights = array();
84
-		$r=0;
84
+		$r = 0;
85 85
 
86 86
 		$r++;
87 87
 		$this->rights[$r][0] = 50101;
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 		$this->rights[$r][4] = 'use';
92 92
 
93 93
 		// Main menu entries
94
-		$this->menus = array();			// List of menus to add
95
-		$r=0;
94
+		$this->menus = array(); // List of menus to add
95
+		$r = 0;
96 96
 
97 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
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 100
 									'titre'=>'PointOfSaleShort',
101 101
 									'mainmenu'=>'cashdesk',
102 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.
103
+									'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
104 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
106
+		                            'perms'=>'$user->rights->cashdesk->use', // Use 'perms'=>'1' if you want your menu with no permission rules
107 107
 									'target'=>'pointofsale',
108
-									'user'=>0);				// 0=Menu for internal users, 1=external users, 2=both
108
+									'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
109 109
 
110 110
 		$r++;
111 111
 
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
133 133
 	 *      @return     int             	1 if OK, 0 if KO
134 134
      */
135
-	function init($options='')
135
+	function init($options = '')
136 136
   	{
137 137
     	$sql = array();
138 138
 
139 139
 		// Remove permissions and default values
140 140
 		$this->remove($options);
141 141
 
142
-    	return $this->_init($sql,$options);
142
+    	return $this->_init($sql, $options);
143 143
   	}
144 144
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modExport.class.php 2 patches
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.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module export
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->family = "technic";
47 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));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		// Dependencies
63 63
 		$this->depends = array();
64 64
 		$this->requiredby = array();
65
-		$this->phpmin = array(4,2,0);
65
+		$this->phpmin = array(4, 2, 0);
66 66
 		$this->phpmax = array();
67 67
 
68 68
 		// Constants
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		// Permissions
75 75
 		$this->rights = array();
76 76
 		$this->rights_class = 'export';
77
-		$r=0;
77
+		$r = 0;
78 78
 
79 79
 		$r++;
80 80
 		$this->rights[$r][0] = 1201;
@@ -93,6 +93,6 @@  discard block
 block discarded – undo
93 93
 
94 94
 		// Menus
95 95
 		//-------
96
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
96
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
97 97
 	}
98 98
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel2007.modules.php 3 patches
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.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 
56 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 62
 	public $row;
63 63
 
64 64
 	public $col;
65 65
 
66
-    public $file;          // To save filename
66
+    public $file; // To save filename
67 67
 
68 68
 	/**
69 69
 	 *	Constructor
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
 		global $conf, $langs;
76 76
 		$this->db = $db;
77 77
 
78
-		$this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 2007';               // Label of driver
78
+		$this->id = 'excel2007'; // Same value then xxx in file name export_xxx.modules.php
79
+		$this->label = 'Excel 2007'; // Label of driver
80 80
 		$this->desc = $langs->trans('Excel2007FormatDesc');
81
-		$this->extension='xlsx';             // Extension for generated file by this driver
82
-        $this->picto='mime/xls';			// Picto
83
-		$this->version='1.30';             // Driver version
81
+		$this->extension = 'xlsx'; // Extension for generated file by this driver
82
+        $this->picto = 'mime/xls'; // Picto
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 87
 		if (empty($this->disabled))
88 88
 		{
89 89
     		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
90
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91 91
     		{
92 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';
96
-                $this->version_lib='unknown';
95
+    			$this->label_lib = 'PhpWriteExcel';
96
+                $this->version_lib = 'unknown';
97 97
     		}
98 98
     		else
99 99
     		{
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
103
-                $this->version_lib='1.8.0';		// No way to get info from library
102
+    			$this->label_lib = 'PhpExcel';
103
+                $this->version_lib = '1.8.0'; // No way to get info from library
104 104
     		}
105 105
 		}
106 106
 
107
-		$this->row=0;
107
+		$this->row = 0;
108 108
 	}
109 109
 
110 110
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         // phpcs:enable
120 120
 		global $conf;
121 121
 
122
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
122
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123 123
     	{
124 124
 	        $this->workbook->close();
125 125
     	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95 95
     			$this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
97
+    		} else
99 98
     		{
100 99
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 100
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -122,8 +121,7 @@  discard block
 block discarded – undo
122 121
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123 122
     	{
124 123
 	        $this->workbook->close();
125
-    	}
126
-    	else
124
+    	} else
127 125
     	{
128 126
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
129 127
     	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel.modules.php 3 patches
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.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 
55 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 61
 	public $row;
62 62
 
63 63
 	public $col;
64 64
 
65
-    public $file;          // To save filename
65
+    public $file; // To save filename
66 66
 
67 67
 
68 68
 	/**
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
 		global $conf, $langs;
76 76
 		$this->db = $db;
77 77
 
78
-		$this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 95';             // Label of driver
78
+		$this->id = 'excel'; // Same value then xxx in file name export_xxx.modules.php
79
+		$this->label = 'Excel 95'; // Label of driver
80 80
 		$this->desc = $langs->trans('Excel95FormatDesc');
81
-		$this->extension='xls';             // Extension for generated file by this driver
82
-        $this->picto='mime/xls';					// Picto
83
-		$this->version='1.30';             // Driver version
81
+		$this->extension = 'xls'; // Extension for generated file by this driver
82
+        $this->picto = 'mime/xls'; // Picto
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 87
 		if (empty($this->disabled))
88 88
 		{
89 89
     		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
90
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91 91
     		{
92 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';
96
-                $this->version_lib='unknown';
95
+    			$this->label_lib = 'PhpWriteExcel';
96
+                $this->version_lib = 'unknown';
97 97
     		}
98 98
     		else
99 99
     		{
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
103
-                $this->version_lib='1.8.0';		// No way to get info from library
102
+    			$this->label_lib = 'PhpExcel';
103
+                $this->version_lib = '1.8.0'; // No way to get info from library
104 104
     		}
105 105
 		}
106 106
 
107
-		$this->row=0;
107
+		$this->row = 0;
108 108
 	}
109 109
 
110 110
 	/**
@@ -186,29 +186,29 @@  discard block
 block discarded – undo
186 186
 	 *  @param		Translate	$outputlangs	Output language object
187 187
 	 *	@return		int							<0 if KO, >=0 if OK
188 188
 	 */
189
-	function open_file($file,$outputlangs)
189
+	function open_file($file, $outputlangs)
190 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))
194
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195 195
 		{
196
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
196
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
197 197
 		}
198 198
 
199 199
 		dol_syslog(get_class($this)."::open_file file=".$file);
200
-        $this->file=$file;
200
+        $this->file = $file;
201 201
 
202
-		$ret=1;
202
+		$ret = 1;
203 203
 
204 204
     	$outputlangs->load("exports");
205
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
205
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206 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 210
 		    $this->workbook = new writeexcel_workbookbig($file);
211
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
211
+    		$this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
212 212
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213 213
     		$this->worksheet = &$this->workbook->addworksheet();
214 214
 		}
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 
220 220
 		    if ($this->id == 'excel2007')
221 221
 		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
222
+	            if (!class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223 223
 	            {
224 224
 	            	$langs->load("errors");
225
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
225
+	            	$this->error = $langs->trans('ErrorPHPNeedModule', 'zip');
226 226
 	            	return -1;
227 227
 	            }
228 228
 		    }
229 229
 
230 230
 		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231 231
 			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
-			    $cacheSettings = array (
232
+			    $cacheSettings = array(
233 233
 			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234 234
 			    );
235 235
 			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
@@ -275,17 +275,17 @@  discard block
 block discarded – undo
275 275
      *  @param		array		$array_types					Array with types of fields
276 276
 	 * 	@return		int											<0 if KO, >0 if OK
277 277
 	 */
278
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
278
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
279 279
 	{
280 280
         // phpcs:enable
281 281
 		global $conf;
282 282
 
283 283
 		// Create a format for the column headings
284
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285 285
 		{
286
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
286
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
287 287
 
288
-		    $formatheader =$this->workbook->addformat();
288
+		    $formatheader = $this->workbook->addformat();
289 289
     		$formatheader->set_bold();
290 290
     		$formatheader->set_color('blue');
291 291
     		//$formatheader->set_size(12);
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299 299
 		}
300 300
 
301
-		$this->col=0;
302
-		foreach($array_selected_sorted as $code => $value)
301
+		$this->col = 0;
302
+		foreach ($array_selected_sorted as $code => $value)
303 303
 		{
304
-            $alias=$array_export_fields_label[$code];
304
+            $alias = $array_export_fields_label[$code];
305 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))
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 308
     		{
309 309
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310 310
     		}
311 311
     		else
312 312
     		{
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
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
315 315
                 {
316 316
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
317 317
                 }
@@ -332,29 +332,29 @@  discard block
 block discarded – undo
332 332
      *  @param		array		$array_types				Array with types of fields
333 333
 	 * 	@return		int										<0 if KO, >0 if OK
334 334
 	 */
335
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
335
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
336 336
 	{
337 337
         // phpcs:enable
338 338
 		global $conf;
339 339
 
340 340
 		// Create a format for the column headings
341
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
341
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342 342
 		{
343
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
343
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
344 344
 		}
345 345
 
346 346
 		// Define first row
347
-		$this->col=0;
347
+		$this->col = 0;
348 348
 
349
-		foreach($array_selected_sorted as $code => $value)
349
+		foreach ($array_selected_sorted as $code => $value)
350 350
 		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
353
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
354
-            $newvalue=$objp->$alias;
351
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
352
+			else $alias = substr($code, strpos($code, ' as ') + 4);
353
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
354
+            $newvalue = $objp->$alias;
355 355
 
356
-			$newvalue=$this->excel_clean($newvalue);
357
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
356
+			$newvalue = $this->excel_clean($newvalue);
357
+			$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
358 358
 
359 359
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360 360
 			{
@@ -364,58 +364,58 @@  discard block
 block discarded – undo
364 364
 			}
365 365
 
366 366
 			// Traduction newvalue
367
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
367
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg))
368 368
 			{
369
-				$newvalue=$outputlangs->transnoentities($reg[1]);
369
+				$newvalue = $outputlangs->transnoentities($reg[1]);
370 370
 			}
371 371
 			else
372 372
 			{
373
-				$newvalue=$outputlangs->convToOutputCharset($newvalue);
373
+				$newvalue = $outputlangs->convToOutputCharset($newvalue);
374 374
 			}
375 375
 
376
-			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
376
+			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue))
377 377
 			{
378
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
378
+        		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379 379
         		{
380
-            		$formatdate=$this->workbook->addformat();
380
+            		$formatdate = $this->workbook->addformat();
381 381
             		$formatdate->set_num_format('yyyy-mm-dd');
382 382
             		//$formatdate->set_num_format(0x0f);
383
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
383
+        		    $arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
384 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
385
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386 386
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387 387
         		}
388 388
         		else
389 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();
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 393
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394 394
         		}
395 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))
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 397
 			{
398
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
398
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399 399
     		    {
400
-            		$formatdatehour=$this->workbook->addformat();
400
+            		$formatdatehour = $this->workbook->addformat();
401 401
             		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402 402
             		//$formatdatehour->set_num_format(0x0f);
403
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
403
+            		$arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
404 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
405
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406 406
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407 407
     		    }
408 408
     		    else
409 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();
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 413
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414 414
     		    }
415 415
 			}
416 416
 			else
417 417
 			{
418
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
418
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419 419
     		    {
420 420
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
421 421
     		    }
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425 425
     		    	{
426 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();
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 429
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430 430
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431 431
     		    	}
432 432
     		    	else
433 433
     		    	{
434
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
434
+    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue);
435 435
     		    	}
436 436
     		    }
437 437
 			}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         // phpcs:enable
468 468
 		global $conf;
469 469
 
470
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
470
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471 471
     	{
472 472
 	        $this->workbook->close();
473 473
     	}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     {
495 495
         // phpcs:enable
496 496
 		// Rule Dolibarr: No HTML
497
-    	$newvalue=dol_string_nohtmltag($newvalue);
497
+    	$newvalue = dol_string_nohtmltag($newvalue);
498 498
 
499 499
     	return $newvalue;
500 500
     }
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
     	{
517 517
     		$p = ($c - 1) % 26;
518 518
     		$c = intval(($c - $p) / 26);
519
-    		$letter = chr(65 + $p) . $letter;
519
+    		$letter = chr(65 + $p).$letter;
520 520
     	}
521 521
 
522 522
     	return $letter;
Please login to merge, or discard this patch.
Braces   +32 added lines, -31 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95 95
     			$this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
97
+    		} else
99 98
     		{
100 99
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 100
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -211,17 +210,18 @@  discard block
 block discarded – undo
211 210
     		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212 211
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213 212
     		$this->worksheet = &$this->workbook->addworksheet();
214
-		}
215
-		else
213
+		} else
216 214
 		{
217 215
             require_once PHPEXCEL_PATH.'PHPExcel.php';
218 216
             require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
219 217
 
220 218
 		    if ($this->id == 'excel2007')
221 219
 		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
220
+	            if (! class_exists('ZipArchive')) {
221
+	                // For Excel2007, PHPExcel need ZipArchive
223 222
 	            {
224 223
 	            	$langs->load("errors");
224
+	            }
225 225
 	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
226 226
 	            	return -1;
227 227
 	            }
@@ -291,8 +291,7 @@  discard block
 block discarded – undo
291 291
     		//$formatheader->set_size(12);
292 292
     		//$formatheader->set_font("Courier New");
293 293
     		//$formatheader->set_align('center');
294
-		}
295
-		else
294
+		} else
296 295
 		{
297 296
             $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
298 297
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
@@ -303,17 +302,20 @@  discard block
 block discarded – undo
303 302
 		{
304 303
             $alias=$array_export_fields_label[$code];
305 304
 			//print "dd".$alias;
306
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
305
+			if (empty($alias)) {
306
+			    dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
+			}
307 308
     		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308 309
     		{
309 310
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
-    		}
311
-    		else
311
+    		} else
312 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'))) {
315
+    		        // Set autowidth for some types
315 316
                 {
316 317
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
318
+    		    }
317 319
                 }
318 320
     		}
319 321
 			$this->col++;
@@ -348,9 +350,14 @@  discard block
 block discarded – undo
348 350
 
349 351
 		foreach($array_selected_sorted as $code => $value)
350 352
 		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
353
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
353
+			if (strpos($code,' as ') == 0) {
354
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
355
+			} else {
356
+			    $alias=substr($code, strpos($code, ' as ') + 4);
357
+			}
358
+            if (empty($alias)) {
359
+                dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
360
+            }
354 361
             $newvalue=$objp->$alias;
355 362
 
356 363
 			$newvalue=$this->excel_clean($newvalue);
@@ -367,8 +374,7 @@  discard block
 block discarded – undo
367 374
 			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368 375
 			{
369 376
 				$newvalue=$outputlangs->transnoentities($reg[1]);
370
-			}
371
-			else
377
+			} else
372 378
 			{
373 379
 				$newvalue=$outputlangs->convToOutputCharset($newvalue);
374 380
 			}
@@ -384,16 +390,14 @@  discard block
 block discarded – undo
384 390
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385 391
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386 392
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
-        		}
388
-        		else
393
+        		} else
389 394
         		{
390 395
         		    $newvalue=dol_stringtotime($newvalue);
391 396
         		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392 397
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393 398
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394 399
         		}
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))
400
+			} 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 401
 			{
398 402
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399 403
     		    {
@@ -404,22 +408,19 @@  discard block
 block discarded – undo
404 408
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405 409
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406 410
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
-    		    }
408
-    		    else
411
+    		    } else
409 412
     		    {
410 413
         		    $newvalue=dol_stringtotime($newvalue);
411 414
     		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412 415
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413 416
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414 417
     		    }
415
-			}
416
-			else
418
+			} else
417 419
 			{
418 420
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419 421
     		    {
420 422
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
421
-    		    }
422
-    		    else
423
+    		    } else
423 424
 				{
424 425
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425 426
     		    	{
@@ -428,8 +429,7 @@  discard block
 block discarded – undo
428 429
     		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429 430
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430 431
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
-    		    	}
432
-    		    	else
432
+    		    	} else
433 433
     		    	{
434 434
     		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435 435
     		    	}
@@ -470,8 +470,7 @@  discard block
 block discarded – undo
470 470
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471 471
     	{
472 472
 	        $this->workbook->close();
473
-    	}
474
-    	else
473
+    	} else
475 474
     	{
476 475
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
477 476
     	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
@@ -510,7 +509,9 @@  discard block
 block discarded – undo
510 509
     {
511 510
 
512 511
     	$c = intval($c);
513
-    	if ($c <= 0) return '';
512
+    	if ($c <= 0) {
513
+    	    return '';
514
+    	}
514 515
 
515 516
     	while ($c != 0)
516 517
     	{
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_csv.modules.php 3 patches
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.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *		\author	    Laurent Destailleur
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
26 26
 
27 27
 
28 28
 /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	public $separator;
56 56
 
57
-	public $handle;    // Handle fichier
57
+	public $handle; // Handle fichier
58 58
 
59 59
 
60 60
 	/**
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
 		global $conf, $langs;
68 68
 		$this->db = $db;
69 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='"';
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 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
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 81
 
82 82
 		// If driver use an external library, put its name here
83
-		$this->label_lib='Dolibarr';
84
-		$this->version_lib=DOL_VERSION;
83
+		$this->label_lib = 'Dolibarr';
84
+		$this->version_lib = DOL_VERSION;
85 85
 	}
86 86
 
87 87
 	/**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
 	 * 	@param		Translate	$outputlangs	Output language object
164 164
 	 *	@return		int							<0 if KO, >=0 if OK
165 165
 	 */
166
-	function open_file($file,$outputlangs)
166
+	function open_file($file, $outputlangs)
167 167
 	{
168 168
         // phpcs:enable
169 169
 		global $langs;
170 170
 
171 171
 		dol_syslog("ExportCsv::open_file file=".$file);
172 172
 
173
-		$ret=1;
173
+		$ret = 1;
174 174
 
175 175
 		$outputlangs->load("exports");
176 176
 		$this->handle = fopen($file, "wt");
177
-		if (! $this->handle)
177
+		if (!$this->handle)
178 178
 		{
179 179
 			$langs->load("errors");
180
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
-			$ret=-1;
180
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
181
+			$ret = -1;
182 182
 		}
183 183
 
184 184
 		return $ret;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
      *  @param		array		$array_types					Array with types of fields
209 209
 	 * 	@return		int											<0 if KO, >0 if OK
210 210
 	 */
211
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
211
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
212 212
 	{
213 213
         // phpcs:enable
214 214
 		global $conf;
215 215
 
216
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
216
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217 217
 		{
218 218
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219 219
 		}
@@ -222,14 +222,14 @@  discard block
 block discarded – undo
222 222
 			$outputlangs->charset_output = 'ISO-8859-1';
223 223
 		}
224 224
 
225
-		foreach($array_selected_sorted as $code => $value)
225
+		foreach ($array_selected_sorted as $code => $value)
226 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);
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);
230
+			fwrite($this->handle, $newvalue.$this->separator);
231 231
 		}
232
-		fwrite($this->handle,"\n");
232
+		fwrite($this->handle, "\n");
233 233
 		return 0;
234 234
 	}
235 235
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
      *  @param		array		$array_types				Array with types of fields
245 245
 	 * 	@return		int										<0 if KO, >0 if OK
246 246
 	 */
247
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
247
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
248 248
 	{
249 249
         // phpcs:enable
250 250
 		global $conf;
251 251
 
252
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
252
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253 253
 		{
254 254
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255 255
 		}
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
 			$outputlangs->charset_output = 'ISO-8859-1';
259 259
 		}
260 260
 
261
-		$this->col=0;
262
-		foreach($array_selected_sorted as $code => $value)
261
+		$this->col = 0;
262
+		foreach ($array_selected_sorted as $code => $value)
263 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.');
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 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]:'';
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 270
 
271 271
 			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
272
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) $newvalue = $outputlangs->transnoentities($reg[1]);
273 273
 
274
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
274
+			$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
275 275
 
276 276
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277 277
 			{
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 				$newvalue = $array[$newvalue];
281 281
 			}
282 282
 
283
-			fwrite($this->handle,$newvalue.$this->separator);
283
+			fwrite($this->handle, $newvalue.$this->separator);
284 284
 			$this->col++;
285 285
 		}
286 286
 
287
-		fwrite($this->handle,"\n");
287
+		fwrite($this->handle, "\n");
288 288
 		return 0;
289 289
 	}
290 290
 
@@ -327,39 +327,39 @@  discard block
 block discarded – undo
327 327
 	public function csvClean($newvalue, $charset)
328 328
 	{
329 329
 		global $conf;
330
-		$addquote=0;
330
+		$addquote = 0;
331 331
 
332 332
 
333 333
 		// Rule Dolibarr: No HTML
334 334
    		//print $charset.' '.$newvalue."\n";
335 335
    		//$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
-   		$newvalue=dol_htmlcleanlastbr($newvalue);
336
+   		$newvalue = dol_htmlcleanlastbr($newvalue);
337 337
    		//print $charset.' '.$newvalue."\n";
338 338
 
339 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)
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 344
 		{
345 345
 			// If strict use of CSV rules, we just add quote
346
-			$newvalue=$oldvalue;
347
-			$addquote=1;
346
+			$newvalue = $oldvalue;
347
+			$addquote = 1;
348 348
 		}
349 349
 
350 350
 		// Rule 2 CSV: If value contains ", we must escape with ", and add "
351
-		if (preg_match('/"/',$newvalue))
351
+		if (preg_match('/"/', $newvalue))
352 352
 		{
353
-			$addquote=1;
354
-			$newvalue=str_replace('"','""',$newvalue);
353
+			$addquote = 1;
354
+			$newvalue = str_replace('"', '""', $newvalue);
355 355
 		}
356 356
 
357 357
 		// Rule 3 CSV: If value contains separator, we must add "
358
-		if (preg_match('/'.$this->separator.'/',$newvalue))
358
+		if (preg_match('/'.$this->separator.'/', $newvalue))
359 359
 		{
360
-			$addquote=1;
360
+			$addquote = 1;
361 361
 		}
362 362
 
363
-		return ($addquote?'"':'').$newvalue.($addquote?'"':'');
363
+		return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : '');
364 364
 	}
365 365
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
 		$this->db = $db;
69 69
 
70 70
 		$this->separator=',';
71
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
71
+		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) {
72
+		    $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
73
+		}
72 74
 		$this->escape='"';
73 75
 		$this->enclosure='"';
74 76
 
@@ -216,8 +218,7 @@  discard block
 block discarded – undo
216 218
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217 219
 		{
218 220
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
-		}
220
-		else
221
+		} else
221 222
 		{
222 223
 			$outputlangs->charset_output = 'ISO-8859-1';
223 224
 		}
@@ -252,8 +253,7 @@  discard block
 block discarded – undo
252 253
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253 254
 		{
254 255
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
-		}
256
-		else
256
+		} else
257 257
 		{
258 258
 			$outputlangs->charset_output = 'ISO-8859-1';
259 259
 		}
@@ -261,15 +261,22 @@  discard block
 block discarded – undo
261 261
 		$this->col=0;
262 262
 		foreach($array_selected_sorted as $code => $value)
263 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.');
264
+			if (strpos($code,' as ') == 0) {
265
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
266
+			} else {
267
+			    $alias=substr($code, strpos($code, ' as ') + 4);
268
+			}
269
+			if (empty($alias)) {
270
+			    dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
271
+			}
267 272
 
268 273
 			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269 274
 			$typefield=isset($array_types[$code])?$array_types[$code]:'';
270 275
 
271 276
 			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
277
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
278
+			    $newvalue=$outputlangs->transnoentities($reg[1]);
279
+			}
273 280
 
274 281
 			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275 282
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_tsv.modules.php 3 patches
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.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\author	    Laurent Destailleur
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
27 27
 
28 28
 
29 29
 /**
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public $version_lib;
55 55
 
56
-    public $separator="\t";
56
+    public $separator = "\t";
57 57
 
58
-    public $handle;    // Handle fichier
58
+    public $handle; // Handle fichier
59 59
 
60 60
 
61 61
     /**
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
         global $conf, $langs;
69 69
         $this->db = $db;
70 70
 
71
-        $this->id='tsv';                // Same value then xxx in file name export_xxx.modules.php
72
-        $this->label = 'TSV';             // Label of driver
71
+        $this->id = 'tsv'; // Same value then xxx in file name export_xxx.modules.php
72
+        $this->label = 'TSV'; // Label of driver
73 73
         $this->desc = $langs->trans('TsvFormatDesc');
74
-        $this->extension='tsv';         // Extension for generated file by this driver
75
-        $this->picto='mime/other';		// Picto
76
-        $this->version='1.15';         // Driver version
74
+        $this->extension = 'tsv'; // Extension for generated file by this driver
75
+        $this->picto = 'mime/other'; // Picto
76
+        $this->version = '1.15'; // Driver version
77 77
 
78 78
         // If driver use an external library, put its name here
79
-        $this->label_lib='Dolibarr';
80
-        $this->version_lib=DOL_VERSION;
79
+        $this->label_lib = 'Dolibarr';
80
+        $this->version_lib = DOL_VERSION;
81 81
     }
82 82
 
83 83
 	/**
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
 	*	@param		Translate	$outputlangs	Output language object
160 160
 	*	@return		int							<0 if KO, >=0 if OK
161 161
     */
162
-    function open_file($file,$outputlangs)
162
+    function open_file($file, $outputlangs)
163 163
     {
164 164
         // phpcs:enable
165 165
         global $langs;
166 166
 
167 167
         dol_syslog("ExportTsv::open_file file=".$file);
168 168
 
169
-        $ret=1;
169
+        $ret = 1;
170 170
 
171 171
         $outputlangs->load("exports");
172 172
 		$this->handle = fopen($file, "wt");
173
-        if (! $this->handle)
173
+        if (!$this->handle)
174 174
 		{
175 175
 			$langs->load("errors");
176
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
-			$ret=-1;
176
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
177
+			$ret = -1;
178 178
 		}
179 179
 
180 180
 		return $ret;
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
      *  @param		array		$array_types					Array with types of fields
205 205
 	 * 	@return		int											<0 if KO, >0 if OK
206 206
 	 */
207
-    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
207
+    function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
208 208
     {
209 209
         // phpcs:enable
210
-        foreach($array_selected_sorted as $code => $value)
210
+        foreach ($array_selected_sorted as $code => $value)
211 211
         {
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);
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);
214 214
 
215
-			fwrite($this->handle,$newvalue.$this->separator);
215
+			fwrite($this->handle, $newvalue.$this->separator);
216 216
         }
217
-        fwrite($this->handle,"\n");
217
+        fwrite($this->handle, "\n");
218 218
         return 0;
219 219
     }
220 220
 
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
      *  @param		array		$array_types				Array with types of fields
230 230
 	 * 	@return		int										<0 if KO, >0 if OK
231 231
 	 */
232
-    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
232
+    function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
233 233
     {
234 234
         // phpcs:enable
235 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);
242
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
240
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
241
+			else $alias = substr($code, strpos($code, ' as ') + 4);
242
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
243 243
 
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
-            $typefield=isset($array_types[$code])?$array_types[$code]:'';
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
+            $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 252
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253 253
 			{
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 				$newvalue = $array[$newvalue];
257 257
 			}
258 258
 
259
-			fwrite($this->handle,$newvalue.$this->separator);
259
+			fwrite($this->handle, $newvalue.$this->separator);
260 260
             $this->col++;
261 261
 		}
262
-        fwrite($this->handle,"\n");
262
+        fwrite($this->handle, "\n");
263 263
         return 0;
264 264
     }
265 265
 
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
     {
302 302
         // phpcs:enable
303 303
 		// Rule Dolibarr: No HTML
304
-		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
304
+		$newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
305 305
 
306 306
 		// Rule 1 TSV: No CR, LF in cells
307
-    	$newvalue=str_replace("\r",'',$newvalue);
308
-        $newvalue=str_replace("\n",'\n',$newvalue);
307
+    	$newvalue = str_replace("\r", '', $newvalue);
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))
311
+		if (preg_match('/'.$this->separator.'/', $newvalue))
312 312
 		{
313
-			$newvalue=str_replace("\t"," ",$newvalue);
313
+			$newvalue = str_replace("\t", " ", $newvalue);
314 314
 		}
315 315
 
316 316
         return $newvalue;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,15 +237,22 @@
 block discarded – undo
237 237
 		$this->col=0;
238 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);
242
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
240
+			if (strpos($code,' as ') == 0) {
241
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
242
+			} else {
243
+			    $alias=substr($code, strpos($code, ' as ') + 4);
244
+			}
245
+            if (empty($alias)) {
246
+                dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
247
+            }
243 248
 
244 249
             $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245 250
             $typefield=isset($array_types[$code])?$array_types[$code]:'';
246 251
 
247 252
             // Translation newvalue
248
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
253
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
254
+			    $newvalue=$outputlangs->transnoentities($reg[1]);
255
+			}
249 256
 
250 257
 			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
251 258
 
Please login to merge, or discard this patch.