Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -59,28 +59,28 @@  discard block
 block discarded – undo
59 59
 		global $conf, $langs, $mysoc;
60 60
 
61 61
 		// Load translation files required by the page
62
-        $langs->loadLangs(array("main","companies"));
62
+        $langs->loadLangs(array("main", "companies"));
63 63
 
64 64
 		$this->db = $db;
65 65
 		$this->name = "ODT templates";
66 66
 		$this->description = $langs->trans("DocumentModelOdt");
67
-		$this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
67
+		$this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
68 68
 
69 69
 		// Dimension page pour format A4
70 70
 		$this->type = 'odt';
71 71
 		$this->page_largeur = 0;
72 72
 		$this->page_hauteur = 0;
73
-		$this->format = array($this->page_largeur,$this->page_hauteur);
74
-		$this->marge_gauche=0;
75
-		$this->marge_droite=0;
76
-		$this->marge_haute=0;
77
-		$this->marge_basse=0;
73
+		$this->format = array($this->page_largeur, $this->page_hauteur);
74
+		$this->marge_gauche = 0;
75
+		$this->marge_droite = 0;
76
+		$this->marge_haute = 0;
77
+		$this->marge_basse = 0;
78 78
 
79
-		$this->option_logo = 1;                    // Affiche logo
79
+		$this->option_logo = 1; // Affiche logo
80 80
 
81 81
 		// Recupere emmetteur
82
-		$this->emetteur=$mysoc;
83
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
82
+		$this->emetteur = $mysoc;
83
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
84 84
 	}
85 85
 
86 86
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	function info($langs)
94 94
 	{
95
-		global $conf,$langs;
95
+		global $conf, $langs;
96 96
 
97 97
 		// Load traductions files requiredby by page
98 98
 		$langs->loadLangs(array("companies", "errors"));
@@ -100,76 +100,76 @@  discard block
 block discarded – undo
100 100
 		$form = new Form($this->db);
101 101
 
102 102
 		$texte = $this->description.".<br>\n";
103
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
104
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
105
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
106
-		$texte.= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">';
107
-		$texte.= '<table class="nobordernopadding" width="100%">';
103
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
104
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
105
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
106
+		$texte .= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">';
107
+		$texte .= '<table class="nobordernopadding" width="100%">';
108 108
 
109 109
 		// List of directories area
110
-		$texte.= '<tr><td>';
111
-		$texttitle=$langs->trans("ListOfDirectories");
112
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH)));
113
-		$listoffiles=array();
114
-		foreach($listofdir as $key=>$tmpdir)
110
+		$texte .= '<tr><td>';
111
+		$texttitle = $langs->trans("ListOfDirectories");
112
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH)));
113
+		$listoffiles = array();
114
+		foreach ($listofdir as $key=>$tmpdir)
115 115
 		{
116
-			$tmpdir=trim($tmpdir);
117
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
118
-			if (! $tmpdir) { unset($listofdir[$key]); continue; }
119
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
116
+			$tmpdir = trim($tmpdir);
117
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
118
+			if (!$tmpdir) { unset($listofdir[$key]); continue; }
119
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
120 120
 			else
121 121
 			{
122
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment
123
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
122
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment
123
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
124 124
 			}
125 125
 		}
126
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
126
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
127 127
 		// Add list of substitution keys
128
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
129
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
130
-
131
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
132
-        $texte.= '<table><tr><td>';
133
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
134
-		$texte.=$conf->global->COMPANY_ADDON_PDF_ODT_PATH;
135
-		$texte.= '</textarea>';
136
-        $texte.= '</td>';
137
-        $texte.= '<td align="center">&nbsp; ';
138
-        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
139
-        $texte.= '</td>';
140
-        $texte.= '</tr>';
141
-        $texte.= '</table>';
128
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
129
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
130
+
131
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
132
+        $texte .= '<table><tr><td>';
133
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
134
+		$texte .= $conf->global->COMPANY_ADDON_PDF_ODT_PATH;
135
+		$texte .= '</textarea>';
136
+        $texte .= '</td>';
137
+        $texte .= '<td align="center">&nbsp; ';
138
+        $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
139
+        $texte .= '</td>';
140
+        $texte .= '</tr>';
141
+        $texte .= '</table>';
142 142
 
143 143
 		// Scan directories
144
-		$nbofiles=count($listoffiles);
145
-		if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH))
144
+		$nbofiles = count($listoffiles);
145
+		if (!empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH))
146 146
 		{
147
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
147
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
148 148
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
149
-			$texte.=$nbofiles;
149
+			$texte .= $nbofiles;
150 150
 			//$texte.=$nbofiles?'</a>':'';
151
-			$texte.='</b>';
151
+			$texte .= '</b>';
152 152
 		}
153 153
 
154 154
 		if ($nbofiles)
155 155
 		{
156
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
157
-   			foreach($listoffiles as $file)
156
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
157
+   			foreach ($listoffiles as $file)
158 158
    			{
159
-                $texte.=$file['name'].'<br>';
159
+                $texte .= $file['name'].'<br>';
160 160
    			}
161
-   			$texte.='<div id="div_'.get_class($this).'">';
161
+   			$texte .= '<div id="div_'.get_class($this).'">';
162 162
 		}
163 163
 
164
-		$texte.= '</td>';
164
+		$texte .= '</td>';
165 165
 
166
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
167
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
168
-		$texte.= '</td>';
169
-		$texte.= '</tr>';
166
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
167
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
168
+		$texte .= '</td>';
169
+		$texte .= '</tr>';
170 170
 
171
-		$texte.= '</table>';
172
-		$texte.= '</form>';
171
+		$texte .= '</table>';
172
+		$texte .= '</form>';
173 173
 
174 174
 		return $texte;
175 175
 	}
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
      *  @param		int			$hideref			Do not show ref
187 187
 	 *	@return		int         					1 if OK, <=0 if KO
188 188
 	 */
189
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
189
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
190 190
 	{
191 191
         // phpcs:enable
192
-		global $user,$langs,$conf,$mysoc,$hookmanager;
192
+		global $user, $langs, $conf, $mysoc, $hookmanager;
193 193
 
194 194
 		if (empty($srctemplatepath))
195 195
 		{
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 		}
199 199
 
200 200
                 // Add odtgeneration hook
201
-                if (! is_object($hookmanager))
201
+                if (!is_object($hookmanager))
202 202
                 {
203 203
                         include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
204
-                        $hookmanager=new HookManager($this->db);
204
+                        $hookmanager = new HookManager($this->db);
205 205
                 }
206 206
                 $hookmanager->initHooks(array('odtgeneration'));
207 207
                 global $action;
208 208
 
209
-		if (! is_object($outputlangs)) $outputlangs=$langs;
210
-		$sav_charset_output=$outputlangs->charset_output;
211
-		$outputlangs->charset_output='UTF-8';
209
+		if (!is_object($outputlangs)) $outputlangs = $langs;
210
+		$sav_charset_output = $outputlangs->charset_output;
211
+		$outputlangs->charset_output = 'UTF-8';
212 212
 
213 213
 		// Load translation files required by the page
214 214
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 		{
218 218
 			$dir = $conf->societe->multidir_output[$object->entity];
219 219
 			$objectref = dol_sanitizeFileName($object->id);
220
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
220
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
221 221
 
222
-			if (! file_exists($dir))
222
+			if (!file_exists($dir))
223 223
 			{
224 224
 				if (dol_mkdir($dir) < 0)
225 225
 				{
226
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
226
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
227 227
 					return -1;
228 228
 				}
229 229
 			}
@@ -231,28 +231,28 @@  discard block
 block discarded – undo
231 231
 			if (file_exists($dir))
232 232
 			{
233 233
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
234
-				$newfile=basename($srctemplatepath);
235
-				$newfiletmp=preg_replace('/\.od(s|t)/i','',$newfile);
236
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
237
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
234
+				$newfile = basename($srctemplatepath);
235
+				$newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile);
236
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
237
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
238 238
 				// Get extension (ods or odt)
239
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
240
-				if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME))
239
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
240
+				if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME))
241 241
 				{
242 242
 				    $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp;
243 243
 				}
244
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
244
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
245 245
 				{
246
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
247
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
248
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
246
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
247
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
248
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
249 249
 				}
250 250
 				else
251 251
 				{
252
-					$filename=$newfiletmp.'.'.$newfileformat;
252
+					$filename = $newfiletmp.'.'.$newfileformat;
253 253
 				}
254
-				$file=$dir.'/'.$filename;
255
-				$object->builddoc_filename=$filename; // For triggers
254
+				$file = $dir.'/'.$filename;
255
+				$object->builddoc_filename = $filename; // For triggers
256 256
 				//print "newfileformat=".$newfileformat;
257 257
 				//print "newdir=".$dir;
258 258
 				//print "newfile=".$newfile;
@@ -269,22 +269,22 @@  discard block
 block discarded – undo
269 269
 					    $srctemplatepath,
270 270
 					    array(
271 271
 	    					'PATH_TO_TMP'	  => $conf->societe->multidir_temp[$object->entity],
272
-	    					'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
272
+	    					'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
273 273
 	    					'DELIMITER_LEFT'  => '{',
274 274
 	    					'DELIMITER_RIGHT' => '}'
275 275
 						)
276 276
 					);
277 277
 				}
278
-				catch(Exception $e)
278
+				catch (Exception $e)
279 279
 				{
280
-					$this->error=$e->getMessage();
280
+					$this->error = $e->getMessage();
281 281
 					dol_syslog($e->getMessage(), LOG_INFO);
282 282
 					return -1;
283 283
 				}
284 284
 				//print $odfHandler->__toString()."\n";
285 285
 
286 286
                 // Replace tags of lines for contacts
287
-                $contact_arrray=array();
287
+                $contact_arrray = array();
288 288
 
289 289
                 $sql = "SELECT p.rowid";
290 290
                 $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                 {
298 298
                     require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
299 299
 
300
-                	$i=0;
300
+                	$i = 0;
301 301
                 	$contactstatic = new Contact($this->db);
302 302
 
303
-                	while($i < $num)
303
+                	while ($i < $num)
304 304
                 	{
305 305
                 		$obj = $this->db->fetch_object($result);
306 306
 
@@ -308,27 +308,27 @@  discard block
 block discarded – undo
308 308
                 		$i++;
309 309
                 	}
310 310
                 }
311
-                if((is_array($contact_arrray) && count($contact_arrray) > 0))
311
+                if ((is_array($contact_arrray) && count($contact_arrray) > 0))
312 312
                 {
313 313
                 	try
314 314
                 	{
315 315
                 		$listlines = $odfHandler->setSegment('companycontacts');
316 316
 
317
-                		foreach($contact_arrray as $array_key => $contact_id)
317
+                		foreach ($contact_arrray as $array_key => $contact_id)
318 318
                 		{
319 319
                 			$res_contact = $contactstatic->fetch($contact_id);
320
-                			$tmparray=$this->get_substitutionarray_contact($contactstatic,$outputlangs,'contact');
321
-                			foreach($tmparray as $key => $val)
320
+                			$tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact');
321
+                			foreach ($tmparray as $key => $val)
322 322
                 			{
323 323
                 				try
324 324
                 				{
325 325
                 					$listlines->setVars($key, $val, true, 'UTF-8');
326 326
                 				}
327
-                				catch(OdfException $e)
327
+                				catch (OdfException $e)
328 328
                 				{
329 329
 									dol_syslog($e->getMessage(), LOG_INFO);
330 330
                 				}
331
-                				catch(SegmentException $e)
331
+                				catch (SegmentException $e)
332 332
                 				{
333 333
 									dol_syslog($e->getMessage(), LOG_INFO);
334 334
                 				}
@@ -337,32 +337,32 @@  discard block
 block discarded – undo
337 337
                 		}
338 338
                 		$odfHandler->mergeSegment($listlines);
339 339
                 	}
340
-                	catch(OdfException $e)
340
+                	catch (OdfException $e)
341 341
                 	{
342
-                		$this->error=$e->getMessage();
342
+                		$this->error = $e->getMessage();
343 343
                 		dol_syslog($this->error, LOG_WARNING);
344 344
                 		//return -1;
345 345
                 	}
346 346
                 }
347 347
 
348 348
                 // Make substitutions into odt
349
-                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
350
-                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
351
-                $array_thirdparty=$this->get_substitutionarray_thirdparty($object,$outputlangs);
352
-                $array_other=$this->get_substitutionarray_other($outputlangs);
349
+                $array_user = $this->get_substitutionarray_user($user, $outputlangs);
350
+                $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
351
+                $array_thirdparty = $this->get_substitutionarray_thirdparty($object, $outputlangs);
352
+                $array_other = $this->get_substitutionarray_other($outputlangs);
353 353
 
354
-                $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other);
354
+                $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other);
355 355
                 complete_substitutions_array($tmparray, $outputlangs, $object);
356 356
 
357 357
                 // Call the ODTSubstitution hook
358
-                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
359
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
358
+                $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
359
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
360 360
 
361 361
                 // Replace variables into document
362
-				foreach($tmparray as $key=>$value)
362
+				foreach ($tmparray as $key=>$value)
363 363
 				{
364 364
 					try {
365
-						if (preg_match('/logo$/',$key))	// Image
365
+						if (preg_match('/logo$/', $key))	// Image
366 366
 						{
367 367
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
368 368
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 				}
381 381
 
382 382
 				// Replace labels translated
383
-				$tmparray=$outputlangs->get_translations_for_substitutions();
384
-				foreach($tmparray as $key=>$value)
383
+				$tmparray = $outputlangs->get_translations_for_substitutions();
384
+				foreach ($tmparray as $key=>$value)
385 385
 				{
386 386
 					try {
387 387
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -393,15 +393,15 @@  discard block
 block discarded – undo
393 393
 				}
394 394
 
395 395
 				// Call the beforeODTSave hook
396
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
397
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
396
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
397
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
398 398
 
399 399
 				// Write new file
400 400
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
401 401
 					try {
402 402
 						$odfHandler->exportAsAttachedPDF($file);
403 403
 					} catch (Exception $e) {
404
-						$this->error=$e->getMessage();
404
+						$this->error = $e->getMessage();
405 405
                         dol_syslog($e->getMessage(), LOG_INFO);
406 406
 						return -1;
407 407
 					}
@@ -412,39 +412,39 @@  discard block
 block discarded – undo
412 412
 					   $odfHandler->title = $object->builddoc_filename;
413 413
 					   $odfHandler->subject = $object->builddoc_filename;
414 414
 
415
-					   if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
415
+					   if (!empty($conf->global->ODT_ADD_DOLIBARR_ID))
416 416
 					   {
417 417
     					  $odfHandler->userdefined['dol_id'] = $object->id;
418 418
 	   		  		      $odfHandler->userdefined['dol_element'] = $object->element;
419 419
 					   }
420 420
 
421 421
 					   $odfHandler->saveToDisk($file);
422
-					}catch (Exception $e){
423
-						$this->error=$e->getMessage();
422
+					} catch (Exception $e) {
423
+						$this->error = $e->getMessage();
424 424
                         dol_syslog($e->getMessage(), LOG_INFO);
425 425
 						return -1;
426 426
 					}
427 427
 				}
428
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
429
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
428
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
429
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
430 430
 
431
-				if (! empty($conf->global->MAIN_UMASK))
431
+				if (!empty($conf->global->MAIN_UMASK))
432 432
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
433 433
 
434
-				$odfHandler=null;	// Destroy object
434
+				$odfHandler = null; // Destroy object
435 435
 
436 436
 				$this->result = array('fullpath'=>$file);
437 437
 
438
-				return 1;   // Success
438
+				return 1; // Success
439 439
 			}
440 440
 			else
441 441
 			{
442
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
442
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
443 443
 				return -1;
444 444
 			}
445 445
 		}
446 446
 
447
-		$this->error='UnknownError';
447
+		$this->error = 'UnknownError';
448 448
 		return -1;
449 449
 	}
450 450
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/modules_societe.class.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     /**
37 37
 	 * @var string Error code (or message)
38 38
 	 */
39
-	public $error='';
39
+	public $error = '';
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
42 42
     /**
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
      *  @param	integer		$maxfilenamelength  Max length of value to show
47 47
      * 	@return	array							List of templates
48 48
      */
49
-    static function liste_modeles($db,$maxfilenamelength=0)
49
+    static function liste_modeles($db, $maxfilenamelength = 0)
50 50
     {
51 51
         // phpcs:enable
52 52
         global $conf;
53 53
 
54
-        $type='company';
55
-        $liste=array();
54
+        $type = 'company';
55
+        $liste = array();
56 56
 
57 57
         include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
-        $liste = getListOfModels($db,$type,$maxfilenamelength);
58
+        $liste = getListOfModels($db, $type, $maxfilenamelength);
59 59
 
60 60
         return $liste;
61 61
     }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     /**
71 71
      * @var string Error code (or message)
72 72
 	 */
73
-	public $error='';
73
+	public $error = '';
74 74
 
75 75
     /**     Renvoi la description par defaut du modele de numerotation
76 76
      *
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      *	@param	int			$type		Type
123 123
      *  @return string      			Value
124 124
      */
125
-    function getNextValue($objsoc=0,$type=-1)
125
+    function getNextValue($objsoc = 0, $type = -1)
126 126
     {
127 127
         global $langs;
128 128
         return $langs->trans("Function_getNextValue_InModuleNotWorking");
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
      *  @param  integer	$maxfilenamelength  Max length of value to show
154 154
      *  @return	array						List of numbers
155 155
      */
156
-    static function liste_modeles($db,$maxfilenamelength=0)
156
+    static function liste_modeles($db, $maxfilenamelength = 0)
157 157
     {
158 158
         // phpcs:enable
159
-        $liste=array();
160
-        $sql ="";
159
+        $liste = array();
160
+        $sql = "";
161 161
 
162 162
         $resql = $db->query($sql);
163 163
         if ($resql)
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             while ($i < $num)
168 168
             {
169 169
                 $row = $db->fetch_row($resql);
170
-                $liste[$row[0]]=$row[1];
170
+                $liste[$row[0]] = $row[1];
171 171
                 $i++;
172 172
             }
173 173
         }
@@ -186,61 +186,61 @@  discard block
 block discarded – undo
186 186
      *  @param	int			$type		-1=Nothing, 0=Customer, 1=Supplier
187 187
      *  @return	string					HTML translated description
188 188
      */
189
-    function getToolTip($langs,$soc,$type)
189
+    function getToolTip($langs, $soc, $type)
190 190
     {
191 191
         global $conf;
192 192
 
193 193
         $langs->load("admin");
194 194
 
195
-        $s='';
196
-        if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
197
-        if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
198
-        if ($type == 0)  $s.=$langs->trans("CustomerCodeDesc").'<br>';
199
-        if ($type == 1)  $s.=$langs->trans("SupplierCodeDesc").'<br>';
200
-        if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
201
-        $s.='<br>';
202
-        $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
195
+        $s = '';
196
+        if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
197
+        if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
198
+        if ($type == 0)  $s .= $langs->trans("CustomerCodeDesc").'<br>';
199
+        if ($type == 1)  $s .= $langs->trans("SupplierCodeDesc").'<br>';
200
+        if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
201
+        $s .= '<br>';
202
+        $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
203 203
         if ($type == 0)
204 204
         {
205
-            $s.=$langs->trans("RequiredIfCustomer").': ';
206
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
207
-            $s.=yn(!$this->code_null,1,2);
208
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
209
-            $s.='<br>';
205
+            $s .= $langs->trans("RequiredIfCustomer").': ';
206
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
207
+            $s .= yn(!$this->code_null, 1, 2);
208
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
209
+            $s .= '<br>';
210 210
         }
211 211
         if ($type == 1)
212 212
         {
213
-            $s.=$langs->trans("RequiredIfSupplier").': ';
214
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
215
-            $s.=yn(!$this->code_null,1,2);
216
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
217
-            $s.='<br>';
213
+            $s .= $langs->trans("RequiredIfSupplier").': ';
214
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
215
+            $s .= yn(!$this->code_null, 1, 2);
216
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
217
+            $s .= '<br>';
218 218
         }
219 219
         if ($type == -1)
220 220
         {
221
-            $s.=$langs->trans("Required").': ';
222
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
223
-            $s.=yn(!$this->code_null,1,2);
224
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
225
-            $s.='<br>';
221
+            $s .= $langs->trans("Required").': ';
222
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
223
+            $s .= yn(!$this->code_null, 1, 2);
224
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
225
+            $s .= '<br>';
226 226
         }
227
-        $s.=$langs->trans("CanBeModifiedIfOk").': ';
228
-        $s.=yn($this->code_modifiable,1,2);
229
-        $s.='<br>';
230
-        $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
231
-        $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
232
-        $s.='<br>';
227
+        $s .= $langs->trans("CanBeModifiedIfOk").': ';
228
+        $s .= yn($this->code_modifiable, 1, 2);
229
+        $s .= '<br>';
230
+        $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
231
+        $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
232
+        $s .= '<br>';
233 233
         if ($type == 0 || $type == -1)
234 234
         {
235
-            $nextval=$this->getNextValue($soc,0);
236
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
237
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
235
+            $nextval = $this->getNextValue($soc, 0);
236
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
237
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
238 238
         }
239 239
         if ($type == 1 || $type == -1)
240 240
         {
241
-            $nextval=$this->getNextValue($soc,1);
242
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
243
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
241
+            $nextval = $this->getNextValue($soc, 1);
242
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
243
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
244 244
         }
245 245
         return $s;
246 246
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     /**
269 269
 	 * @var string Error code (or message)
270 270
 	 */
271
-	public $error='';
271
+	public $error = '';
272 272
 
273 273
 
274 274
     /**		Return description of module
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      *      @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
290 290
      *      @return	string					Example
291 291
      */
292
-    function getExample($langs,$objsoc=0,$type=-1)
292
+    function getExample($langs, $objsoc = 0, $type = -1)
293 293
     {
294 294
         $langs->load("bills");
295 295
         return $langs->trans("NoExample");
@@ -329,31 +329,31 @@  discard block
 block discarded – undo
329 329
      *		@param	int			$type		-1=Nothing, 0=Customer, 1=Supplier
330 330
      *		@return	string					HTML translated description
331 331
      */
332
-    function getToolTip($langs,$soc,$type)
332
+    function getToolTip($langs, $soc, $type)
333 333
     {
334
-        global $conf,$db;
334
+        global $conf, $db;
335 335
 
336 336
         $langs->load("admin");
337 337
 
338
-        $s='';
339
-        if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
340
-        if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
338
+        $s = '';
339
+        if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->nom.'</b><br>';
340
+        if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
341 341
         //$s.='<br>';
342 342
         //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
343
-        $s.='<br>';
343
+        $s .= '<br>';
344 344
         if ($type == 0 || $type == -1)
345 345
         {
346
-            $result=$this->get_code($db,$soc,'customer');
347
-            $nextval=$this->code;
348
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
349
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
346
+            $result = $this->get_code($db, $soc, 'customer');
347
+            $nextval = $this->code;
348
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
349
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
350 350
         }
351 351
         if ($type == 1 || $type == -1)
352 352
         {
353
-            $result=$this->get_code($db,$soc,'supplier');
354
-            $nextval=$this->code;
355
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
356
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
353
+            $result = $this->get_code($db, $soc, 'supplier');
354
+            $nextval = $this->code;
355
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
356
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
357 357
         }
358 358
         return $s;
359 359
     }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      *  @param  int		$type			'customer' or 'supplier'
368 368
      *  @return	int						>=0 if OK, <0 if KO
369 369
      */
370
-    function get_code($db, $societe, $type='')
370
+    function get_code($db, $societe, $type = '')
371 371
     {
372 372
         // phpcs:enable
373 373
         global $langs;
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
  *  @deprecated Use the new function generateDocument of Facture class
395 395
  *  @see Societe::generateDocument()
396 396
  */
397
-function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
397
+function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
398 398
 {
399 399
     // phpcs:enable
400
-	dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
400
+	dol_syslog(__METHOD__." is deprecated", LOG_WARNING);
401 401
 
402 402
 	return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
403 403
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_elephant.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
 	 * @deprecated
40 40
 	 * @see name
41 41
 	 */
42
-	public $nom='Elephant';
42
+	public $nom = 'Elephant';
43 43
 
44 44
 	/**
45 45
 	 * @var string model name
46 46
 	 */
47
-	public $name='Elephant';
47
+	public $name = 'Elephant';
48 48
 
49
-	public $code_modifiable;				// Code modifiable
49
+	public $code_modifiable; // Code modifiable
50 50
 
51
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
51
+	public $code_modifiable_invalide; // Code modifiable si il est invalide
52 52
 
53
-	public $code_modifiable_null;			// Code modifiables si il est null
53
+	public $code_modifiable_null; // Code modifiables si il est null
54 54
 
55
-	public $code_null;						// Code facultatif
55
+	public $code_null; // Code facultatif
56 56
 
57 57
 	/**
58 58
      * Dolibarr version of the loaded document
59 59
      * @public string
60 60
      */
61
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
61
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
62 62
 
63
-	public $code_auto;                     // Numerotation automatique
63
+	public $code_auto; // Numerotation automatique
64 64
 
65 65
 	public $searchcode; // String de recherche
66 66
 
@@ -95,37 +95,37 @@  discard block
 block discarded – undo
95 95
 
96 96
 		$langs->load("companies");
97 97
 
98
-		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
98
+		$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
99 99
 
100 100
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
101
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
102
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
103
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
104
-		$texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
105
-		$texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
106
-		$texte.= '<table class="nobordernopadding" width="100%">';
107
-
108
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty"));
101
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
102
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
103
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
104
+		$texte .= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
105
+		$texte .= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
106
+		$texte .= '<table class="nobordernopadding" width="100%">';
107
+
108
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty"));
109 109
 		//$tooltip.=$langs->trans("GenericMaskCodes2");	Not required for third party numbering
110
-		$tooltip.=$langs->trans("GenericMaskCodes3");
111
-		$tooltip.=$langs->trans("GenericMaskCodes4b");
112
-		$tooltip.=$langs->trans("GenericMaskCodes5");
110
+		$tooltip .= $langs->trans("GenericMaskCodes3");
111
+		$tooltip .= $langs->trans("GenericMaskCodes4b");
112
+		$tooltip .= $langs->trans("GenericMaskCodes5");
113 113
 
114 114
 		// Parametrage du prefix customers
115
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
116
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
115
+		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
116
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
117 117
 
118
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
118
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
119 119
 
120
-		$texte.= '</tr>';
120
+		$texte .= '</tr>';
121 121
 
122 122
 		// Parametrage du prefix suppliers
123
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
124
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
125
-		$texte.= '</tr>';
123
+		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
124
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
125
+		$texte .= '</tr>';
126 126
 
127
-		$texte.= '</table>';
128
-		$texte.= '</form>';
127
+		$texte .= '</table>';
128
+		$texte .= '</form>';
129 129
 
130 130
 		return $texte;
131 131
 	}
@@ -139,52 +139,52 @@  discard block
 block discarded – undo
139 139
 	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
140 140
 	 * @return	string					Return string example
141 141
 	 */
142
-	function getExample($langs,$objsoc=0,$type=-1)
142
+	function getExample($langs, $objsoc = 0, $type = -1)
143 143
 	{
144 144
 		if ($type == 0 || $type == -1)
145 145
 		{
146
-			$examplecust = $this->getNextValue($objsoc,0);
147
-			if (! $examplecust)
146
+			$examplecust = $this->getNextValue($objsoc, 0);
147
+			if (!$examplecust)
148 148
 			{
149 149
 				$examplecust = $langs->trans('NotConfigured');
150 150
 			}
151
-			if($examplecust=="ErrorBadMask")
151
+			if ($examplecust == "ErrorBadMask")
152 152
 			{
153 153
 				$langs->load("errors");
154
-				$examplecust=$langs->trans($examplecust);
154
+				$examplecust = $langs->trans($examplecust);
155 155
 			}
156
-			if($examplecust=="ErrorCantUseRazIfNoYearInMask")
156
+			if ($examplecust == "ErrorCantUseRazIfNoYearInMask")
157 157
 			{
158 158
 				$langs->load("errors");
159
-				$examplecust=$langs->trans($examplecust);
159
+				$examplecust = $langs->trans($examplecust);
160 160
 			}
161
-			if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
161
+			if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
162 162
 			{
163 163
 				$langs->load("errors");
164
-				$examplecust=$langs->trans($examplecust);
164
+				$examplecust = $langs->trans($examplecust);
165 165
 			}
166 166
 		}
167 167
 		if ($type == 1 || $type == -1)
168 168
 		{
169
-			$examplesup = $this->getNextValue($objsoc,1);
170
-			if (! $examplesup)
169
+			$examplesup = $this->getNextValue($objsoc, 1);
170
+			if (!$examplesup)
171 171
 			{
172 172
 				$examplesup = $langs->trans('NotConfigured');
173 173
 			}
174
-			if($examplesup=="ErrorBadMask")
174
+			if ($examplesup == "ErrorBadMask")
175 175
 			{
176 176
 				$langs->load("errors");
177
-				$examplesup=$langs->trans($examplesup);
177
+				$examplesup = $langs->trans($examplesup);
178 178
 			}
179
-			if($examplesup=="ErrorCantUseRazIfNoYearInMask")
179
+			if ($examplesup == "ErrorCantUseRazIfNoYearInMask")
180 180
 			{
181 181
 				$langs->load("errors");
182
-				$examplesup=$langs->trans($examplesup);
182
+				$examplesup = $langs->trans($examplesup);
183 183
 			}
184
-			if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
184
+			if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
185 185
 			{
186 186
 				$langs->load("errors");
187
-				$examplesup=$langs->trans($examplesup);
187
+				$examplesup = $langs->trans($examplesup);
188 188
 			}
189 189
 		}
190 190
 
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 * @param  	int		    $type       Client ou fournisseur (0:customer, 1:supplier)
201 201
 	 * @return 	string      			Value if OK, '' if module not configured, <0 if KO
202 202
 	 */
203
-	function getNextValue($objsoc=0,$type=-1)
203
+	function getNextValue($objsoc = 0, $type = -1)
204 204
 	{
205
-		global $db,$conf;
205
+		global $db, $conf;
206 206
 
207
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
207
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
208 208
 
209 209
 		// Get Mask value
210 210
 		$mask = '';
211
-		if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
212
-		if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
213
-		if (! $mask)
211
+		if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
212
+		if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
213
+		if (!$mask)
214 214
 		{
215
-			$this->error='NotConfigured';
215
+			$this->error = 'NotConfigured';
216 216
 			return '';
217 217
 		}
218 218
 
219
-		$field='';$where='';
219
+		$field = ''; $where = '';
220 220
 		if ($type == 0)
221 221
 		{
222 222
 			$field = 'code_client';
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 		}
230 230
 		else return -1;
231 231
 
232
-		$now=dol_now();
232
+		$now = dol_now();
233 233
 
234
-		$numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now);
234
+		$numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now);
235 235
 
236 236
 		return  $numFinal;
237 237
 	}
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 		global $conf;
250 250
 
251 251
 		$mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
252
-		if (preg_match('/\{pre\}/i',$mask)) return 1;
252
+		if (preg_match('/\{pre\}/i', $mask)) return 1;
253 253
 
254 254
 		$mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
255
-		if (preg_match('/\{pre\}/i',$mask)) return 1;
255
+		if (preg_match('/\{pre\}/i', $mask)) return 1;
256 256
 
257 257
 		return 0;
258 258
 	}
@@ -276,32 +276,32 @@  discard block
 block discarded – undo
276 276
 	{
277 277
 		global $conf;
278 278
 
279
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
279
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
280 280
 
281
-		$result=0;
281
+		$result = 0;
282 282
 		$code = strtoupper(trim($code));
283 283
 
284 284
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
285 285
 		{
286
-			$result=0;
286
+			$result = 0;
287 287
 		}
288
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
288
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
289 289
 		{
290
-			$result=-2;
290
+			$result = -2;
291 291
 		}
292 292
 		else
293 293
 		{
294 294
 			// Get Mask value
295 295
 			$mask = '';
296
-			if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
297
-			if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
298
-			if (! $mask)
296
+			if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
297
+			if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
298
+			if (!$mask)
299 299
 			{
300
-				$this->error='NotConfigured';
300
+				$this->error = 'NotConfigured';
301 301
 				return -5;
302 302
 			}
303 303
 
304
-			$result=check_value($mask,$code);
304
+			$result = check_value($mask, $code);
305 305
 			if (is_string($result))
306 306
 			{
307 307
 				$this->error = $result;
@@ -324,15 +324,15 @@  discard block
 block discarded – undo
324 324
 	 *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
325 325
 	 *		@return	int						0 if available, <0 if KO
326 326
 	 */
327
-	function verif_dispo($db, $code, $soc, $type=0)
327
+	function verif_dispo($db, $code, $soc, $type = 0)
328 328
 	{
329 329
         // phpcs:enable
330 330
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
331
-		if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
332
-		else $sql.= " WHERE code_client = '".$code."'";
333
-		if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
331
+		if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'";
332
+		else $sql .= " WHERE code_client = '".$code."'";
333
+		if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id;
334 334
 
335
-		$resql=$db->query($sql);
335
+		$resql = $db->query($sql);
336 336
 		if ($resql)
337 337
 		{
338 338
 			if ($db->num_rows($resql) == 0)
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_monkey.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,32 +37,32 @@  discard block
 block discarded – undo
37 37
 	 * @deprecated
38 38
 	 * @see name
39 39
 	 */
40
-	public $nom='Monkey';
40
+	public $nom = 'Monkey';
41 41
 
42 42
 	/**
43 43
 	 * @var string model name
44 44
 	 */
45
-	public $name='Monkey';
45
+	public $name = 'Monkey';
46 46
 
47
-	public $code_modifiable;				// Code modifiable
47
+	public $code_modifiable; // Code modifiable
48 48
 
49
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
49
+	public $code_modifiable_invalide; // Code modifiable si il est invalide
50 50
 
51
-	public $code_modifiable_null;			// Code modifiables si il est null
51
+	public $code_modifiable_null; // Code modifiables si il est null
52 52
 
53
-	public $code_null;						// Code facultatif
53
+	public $code_null; // Code facultatif
54 54
 
55 55
 	/**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';	    	// 'development', 'experimental', 'dolibarr'
59
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
60 60
 
61
-	public $code_auto;                     // Numerotation automatique
61
+	public $code_auto; // Numerotation automatique
62 62
 
63
-	public $prefixcustomer='CU';
63
+	public $prefixcustomer = 'CU';
64 64
 
65
-	public $prefixsupplier='SU';
65
+	public $prefixsupplier = 'SU';
66 66
 
67 67
 	public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
68 68
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	function info($langs)
93 93
 	{
94
-		return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier);
94
+		return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier);
95 95
 	}
96 96
 
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
104 104
 	 * @return	string					Return string example
105 105
 	 */
106
-	function getExample($langs,$objsoc=0,$type=-1)
106
+	function getExample($langs, $objsoc = 0, $type = -1)
107 107
 	{
108 108
 		return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001';
109 109
 	}
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 *	@param  int			$type       Client ou fournisseur (1:client, 2:fournisseur)
117 117
 	 *  @return string      			Value if OK, '' if module not configured, <0 if KO
118 118
 	 */
119
-	function getNextValue($objsoc=0,$type=-1)
119
+	function getNextValue($objsoc = 0, $type = -1)
120 120
 	{
121 121
 		global $db, $conf, $mc;
122 122
 
123
-		$field='';
123
+		$field = '';
124 124
         $prefix = '';
125 125
 		if ($type == 0) {
126 126
 			$field = 'code_client';
@@ -133,20 +133,20 @@  discard block
 block discarded – undo
133 133
         }
134 134
 
135 135
         // D'abord on recupere la valeur max (reponse immediate car champ indexe)
136
-		$posindice=8;
137
-        $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max";   // This is standard SQL
138
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe";
139
-		$sql.= " WHERE ".$field." LIKE '".$prefix."____-%'";
140
-		$sql.= " AND entity IN (".getEntity('societe').")";
136
+		$posindice = 8;
137
+        $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
138
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
139
+		$sql .= " WHERE ".$field." LIKE '".$prefix."____-%'";
140
+		$sql .= " AND entity IN (".getEntity('societe').")";
141 141
 
142 142
 		dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
143 143
 
144
-		$resql=$db->query($sql);
144
+		$resql = $db->query($sql);
145 145
 		if ($resql)
146 146
 		{
147 147
 			$obj = $db->fetch_object($resql);
148 148
 			if ($obj) $max = intval($obj->max);
149
-			else $max=0;
149
+			else $max = 0;
150 150
 		}
151 151
 		else
152 152
 		{
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		}
155 155
 
156 156
 		$date	= dol_now();
157
-		$yymm	= strftime("%y%m",$date);
157
+		$yymm	= strftime("%y%m", $date);
158 158
 
159
-		if ($max >= (pow(10, 5) - 1)) $num=$max+1;	// If counter > 99999, we do not format on 5 chars, we take number as it is
160
-		else $num = sprintf("%05s",$max+1);
159
+		if ($max >= (pow(10, 5) - 1)) $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is
160
+		else $num = sprintf("%05s", $max + 1);
161 161
 
162 162
 		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
163 163
 		return $prefix.$yymm."-".$num;
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 	{
182 182
 		global $conf;
183 183
 
184
-		$result=0;
184
+		$result = 0;
185 185
 		$code = strtoupper(trim($code));
186 186
 
187 187
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
188 188
 		{
189
-			$result=0;
189
+			$result = 0;
190 190
 		}
191
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
191
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
192 192
 		{
193
-			$result=-2;
193
+			$result = -2;
194 194
 		}
195 195
 		else
196 196
 		{
@@ -199,22 +199,22 @@  discard block
 block discarded – undo
199 199
 				$is_dispo = $this->verif_dispo($db, $code, $soc, $type);
200 200
 				if ($is_dispo <> 0)
201 201
 				{
202
-					$result=-3;
202
+					$result = -3;
203 203
 				}
204 204
 				else
205 205
 				{
206
-					$result=0;
206
+					$result = 0;
207 207
 				}
208 208
 			}
209 209
 			else
210 210
 			{
211 211
 				if (dol_strlen($code) == 0)
212 212
 				{
213
-					$result=-2;
213
+					$result = -2;
214 214
 				}
215 215
 				else
216 216
 				{
217
-					$result=-1;
217
+					$result = -1;
218 218
 				}
219 219
 			}
220 220
 		}
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 	 *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
235 235
 	 *		@return	int						0 if available, <0 if KO
236 236
 	 */
237
-	function verif_dispo($db, $code, $soc, $type=0)
237
+	function verif_dispo($db, $code, $soc, $type = 0)
238 238
 	{
239 239
         // phpcs:enable
240 240
 		global $conf, $mc;
241 241
 
242 242
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
243
-		if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
244
-		else $sql.= " WHERE code_client = '".$code."'";
245
-		$sql.= " AND entity IN (".getEntity('societe').")";
246
-		if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
243
+		if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'";
244
+		else $sql .= " WHERE code_client = '".$code."'";
245
+		$sql .= " AND entity IN (".getEntity('societe').")";
246
+		if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id;
247 247
 
248 248
 		dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG);
249
-		$resql=$db->query($sql);
249
+		$resql = $db->query($sql);
250 250
 		if ($resql)
251 251
 		{
252 252
 			if ($db->num_rows($resql) == 0)
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codecompta_panicum.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
 	 * @deprecated
36 36
 	 * @see name
37 37
 	 */
38
-	public $nom='Panicum';
38
+	public $nom = 'Panicum';
39 39
 
40 40
 	/**
41 41
 	 * @var string model name
42 42
 	 */
43
-	public $name='Panicum';
43
+	public $name = 'Panicum';
44 44
 
45 45
 	/**
46 46
      * Dolibarr version of the loaded document
47 47
      * @public string
48 48
      */
49
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
49
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
50 50
 
51 51
 
52 52
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 *  @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
77 77
 	 *  @return	string					Example
78 78
 	 */
79
-	function getExample($langs,$objsoc=0,$type=-1)
79
+	function getExample($langs, $objsoc = 0, $type = -1)
80 80
 	{
81 81
 		return '';
82 82
 	}
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	 *  @param  int		$type			'customer' or 'supplier'
91 91
 	 *  @return	int						>=0 if OK, <0 if KO
92 92
 	 */
93
-	function get_code($db, $societe, $type='')
93
+	function get_code($db, $societe, $type = '')
94 94
 	{
95 95
         // phpcs:enable
96
-		$this->code='';
96
+		$this->code = '';
97 97
 
98 98
 		if (is_object($societe)) {
99
-			if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
100
-			else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
99
+			if ($type == 'supplier') $this->code = (!empty($societe->code_compta_fournisseur) ? $societe->code_compta_fournisseur : '');
100
+			else $this->code = (!empty($societe->code_compta) ? $societe->code_compta : '');
101 101
 		}
102 102
 
103 103
 		return 0; // return ok
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_leopard.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
 	 * @deprecated
44 44
 	 * @see name
45 45
 	 */
46
-	public $nom='Leopard';
46
+	public $nom = 'Leopard';
47 47
 
48 48
 	/**
49 49
 	 * @var string model name
50 50
 	 */
51
-	public $name='Leopard';
51
+	public $name = 'Leopard';
52 52
 
53
-	public $code_modifiable;				// Code modifiable
53
+	public $code_modifiable; // Code modifiable
54 54
 
55
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
55
+	public $code_modifiable_invalide; // Code modifiable si il est invalide
56 56
 
57
-	public $code_modifiable_null;			// Code modifiables si il est null
57
+	public $code_modifiable_null; // Code modifiables si il est null
58 58
 
59
-	public $code_null;						// Code facultatif
59
+	public $code_null; // Code facultatif
60 60
 
61 61
 	/**
62 62
      * Dolibarr version of the loaded document
63 63
      * @public string
64 64
      */
65
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
65
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
66 66
 
67
-	public $code_auto; 	                // Numerotation automatique
67
+	public $code_auto; // Numerotation automatique
68 68
 
69 69
 
70 70
 	/**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
100 100
 	 * @return	string					Return next value
101 101
 	 */
102
-	function getNextValue($objsoc=0,$type=-1)
102
+	function getNextValue($objsoc = 0, $type = -1)
103 103
 	{
104 104
 		global $langs;
105 105
 		return '';
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 	{
124 124
 		global $conf;
125 125
 
126
-		$result=0;
126
+		$result = 0;
127 127
 		$code = trim($code);
128 128
 
129 129
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
130 130
 		{
131
-			$result=0;
131
+			$result = 0;
132 132
 		}
133
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
133
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
134 134
 		{
135
-			$result=-2;
135
+			$result = -2;
136 136
 		}
137 137
 
138 138
 		dol_syslog(get_class($this)."::verif type=".$type." result=".$result);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codecompta_aquarium.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
 	 * @deprecated
37 37
 	 * @see name
38 38
 	 */
39
-	public $nom='Aquarium';
39
+	public $nom = 'Aquarium';
40 40
 
41 41
 	/**
42 42
 	 * @var string model name
43 43
 	 */
44
-	public $name='Aquarium';
44
+	public $name = 'Aquarium';
45 45
 
46 46
 	/**
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
50
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
51 51
 
52 52
 	public	$prefixcustomeraccountancycode;
53 53
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 	function __construct()
61 61
 	{
62 62
 	    global $conf;
63
-		if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
64
-        if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401';
65
-		$this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
66
-	    $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
63
+		if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411';
64
+        if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401';
65
+		$this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
66
+	    $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
67 67
 	}
68 68
 
69 69
 
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$langs->load("companies");
82 82
 
83
-        $tooltip='';
83
+        $tooltip = '';
84 84
 		$texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
85
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
86
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
87
-		$texte.= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
88
-		$texte.= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
89
-		$texte.= '<table class="nobordernopadding" width="100%">';
90
-		$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1);
91
-		$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1);
92
-		$texte.= '<tr><td>';
93
-		$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
94
-		$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
95
-		$texte.="<br>\n";
96
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
85
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
86
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
87
+		$texte .= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
88
+		$texte .= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
89
+		$texte .= '<table class="nobordernopadding" width="100%">';
90
+		$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">', $tooltip, 1, 1);
91
+		$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">', $tooltip, 1, 1);
92
+		$texte .= '<tr><td>';
93
+		$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."<br>\n";
94
+		$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."<br>\n";
95
+		$texte .= "<br>\n";
96
+		if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
97 97
 		//if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";
98
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))  $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
99
-		$texte.= '</td>';
100
-		$texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
101
-        $texte.= '</tr></table>';
102
-        $texte.= '</form>';
98
+		if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))  $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
99
+		$texte .= '</td>';
100
+		$texte .= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
101
+        $texte .= '</tr></table>';
102
+        $texte .= '</form>';
103 103
 
104 104
 		return $texte;
105 105
 	}
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
113 113
 	 * @return	string					Return string example
114 114
 	 */
115
-	function getExample($langs,$objsoc=0,$type=-1)
115
+	function getExample($langs, $objsoc = 0, $type = -1)
116 116
 	{
117
-		$s='';
118
-		$s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
119
-	    $s.="<br>\n";
120
-	    $s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
117
+		$s = '';
118
+		$s .= $this->prefixcustomeraccountancycode.'CUSTCODE';
119
+	    $s .= "<br>\n";
120
+	    $s .= $this->prefixsupplieraccountancycode.'SUPPCODE';
121 121
 	    return $s;
122 122
 	}
123 123
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 *  @param  string		$type			'customer' or 'supplier'
132 132
 	 *  @return	int							>=0 if OK, <0 if KO
133 133
 	 */
134
-	function get_code($db, $societe, $type='')
134
+	function get_code($db, $societe, $type = '')
135 135
 	{
136 136
         // phpcs:enable
137 137
 		global $conf;
@@ -139,17 +139,17 @@  discard block
 block discarded – undo
139 139
 		$i = 0;
140 140
 		$this->db = $db;
141 141
 
142
-		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
142
+		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : ''));
143 143
 
144 144
 		// Regle gestion compte compta
145 145
 		if ($type == 'customer')
146 146
 		{
147
-			$codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
147
+			$codetouse = (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE');
148 148
 			$prefix = $this->prefixcustomeraccountancycode;
149 149
 		}
150 150
 		else if ($type == 'supplier')
151 151
 		{
152
-			$codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
152
+			$codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE');
153 153
 			$prefix = $this->prefixsupplieraccountancycode;
154 154
 		}
155 155
 		else
@@ -161,26 +161,26 @@  discard block
 block discarded – undo
161 161
 		//$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
162 162
 
163 163
 		// Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
164
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
164
+		if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse);
165 165
 		// Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
166
-		if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse=preg_replace('/([a-z])/i','',$codetouse);
166
+		if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse = preg_replace('/([a-z])/i', '', $codetouse);
167 167
 		// Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
168
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
168
+		if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
169 169
 		{
170
-			$codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse);
170
+			$codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse);
171 171
 		}
172 172
 
173
-		$codetouse=$prefix.strtoupper($codetouse);
173
+		$codetouse = $prefix.strtoupper($codetouse);
174 174
 
175 175
 		$is_dispo = $this->verif($db, $codetouse, $societe, $type);
176
-		if (! $is_dispo)
176
+		if (!$is_dispo)
177 177
 		{
178
-			$this->code=$codetouse;
178
+			$this->code = $codetouse;
179 179
 		}
180 180
 		else
181 181
 		{
182 182
 			// Pour retour
183
-			$this->code=$codetouse;
183
+			$this->code = $codetouse;
184 184
 		}
185 185
 		dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code);
186 186
 		return $is_dispo;
@@ -199,33 +199,33 @@  discard block
 block discarded – undo
199 199
 	function verif($db, $code, $societe, $type)
200 200
 	{
201 201
 		$sql = "SELECT ";
202
-		if ($type == 'customer') $sql.= "code_compta";
203
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
204
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe";
205
-		$sql.= " WHERE ";
206
-		if ($type == 'customer') $sql.= "code_compta";
207
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
208
-		$sql.= " = '".$db->escape($code)."'";
209
-		if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
210
-
211
-		$resql=$db->query($sql);
202
+		if ($type == 'customer') $sql .= "code_compta";
203
+		else if ($type == 'supplier') $sql .= "code_compta_fournisseur";
204
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
205
+		$sql .= " WHERE ";
206
+		if ($type == 'customer') $sql .= "code_compta";
207
+		else if ($type == 'supplier') $sql .= "code_compta_fournisseur";
208
+		$sql .= " = '".$db->escape($code)."'";
209
+		if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id;
210
+
211
+		$resql = $db->query($sql);
212 212
 		if ($resql)
213 213
 		{
214 214
 			if ($db->num_rows($resql) == 0)
215 215
 			{
216 216
 				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available");
217
-				return 1;	// Dispo
217
+				return 1; // Dispo
218 218
 			}
219 219
 			else
220 220
 			{
221 221
 				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available");
222
-				return 0;	// Non dispo
222
+				return 0; // Non dispo
223 223
 			}
224 224
 		}
225 225
 		else
226 226
 		{
227
-			$this->error=$db->error()." sql=".$sql;
228
-			return -1;		// Erreur
227
+			$this->error = $db->error()." sql=".$sql;
228
+			return -1; // Erreur
229 229
 		}
230 230
 	}
231 231
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modSupplierProposal.class.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  *	\ingroup    supplier_proposal
29 29
  *	\brief      File to describe and activate module SupplierProposal
30 30
  */
31
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
31
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32 32
 
33 33
 
34 34
 /**
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		$this->numero = 1120;
51 51
 
52 52
 		$this->family = "srm";
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "supplier_proposalDESC";
55 55
 
56 56
 		$this->version = 'dolibarr';
57 57
 
58 58
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
-		$this->picto='supplier_proposal';
59
+		$this->picto = 'supplier_proposal';
60 60
         
61 61
 		// Data directories to create when module is enabled.
62 62
 		$this->dirs = array();
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
         $this->config_page_url = array("supplier_proposal.php");
66 66
 
67 67
 		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array('modFournisseur');		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
68
+		$this->hidden = false; // A condition to hide module
69
+		$this->depends = array('modFournisseur'); // List of module class names as string that must be enabled if this module is enabled
70
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
71
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
72
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
73 73
 		$this->langfiles = array("supplier_proposal");
74 74
 
75 75
 		// Constants
76 76
 		$this->const = array();
77
-		$r=0;
77
+		$r = 0;
78 78
 
79 79
 		$this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF";
80 80
 		$this->const[$r][1] = "chaine";
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		// Permissions
103 103
 		$this->rights = array();
104 104
 		$this->rights_class = 'supplier_proposal';
105
-		$r=0;
105
+		$r = 0;
106 106
 
107 107
 		$r++;
108 108
 		$this->rights[$r][0] = $this->numero + $r; // id de la permission
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
 		$this->rights[$r][4] = 'cloturer';
142 142
 
143 143
  		// Main menu entries
144
-		$this->menu = array();			// List of menus to add
145
-		$r=0;
146
-		$this->menu[$r]=array(
147
-			'fk_menu'=>'fk_mainmenu=commercial',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
148
-			'type'=>'left',			                // This is a Left menu entry
144
+		$this->menu = array(); // List of menus to add
145
+		$r = 0;
146
+		$this->menu[$r] = array(
147
+			'fk_menu'=>'fk_mainmenu=commercial', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
148
+			'type'=>'left', // This is a Left menu entry
149 149
 			'titre'=>'SupplierProposalsShort',
150 150
 			'leftmenu'=>'supplier_proposalsubmenu',
151 151
 			'url'=>'/supplier_proposal/index.php',
152
-			'langs'=>'supplier_proposal',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
153
-			'enabled'=>'$conf->supplier_proposal->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
154
-			'perms'=>'$user->rights->supplier_proposal->lire',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
152
+			'langs'=>'supplier_proposal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
153
+			'enabled'=>'$conf->supplier_proposal->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
154
+			'perms'=>'$user->rights->supplier_proposal->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
155 155
 			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
156 156
             'position'=>300
157 157
 		);
158 158
 		$r++;
159 159
 
160
-		$this->menu[$r]=array(
160
+		$this->menu[$r] = array(
161 161
 			'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
162 162
 			'type'=>'left',
163 163
 			'titre'=>'SupplierProposalNew',
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		);
171 171
 		$r++;
172 172
 
173
-		$this->menu[$r]=array(
173
+		$this->menu[$r] = array(
174 174
 			'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
175 175
 			'type'=>'left',
176 176
 			'titre'=>'List',
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		);
184 184
 		$r++;
185 185
 
186
-		$this->menu[$r]=array(
186
+		$this->menu[$r] = array(
187 187
 		    'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
188 188
 		    'type'=>'left',
189 189
 		    'titre'=>'Statistics',
@@ -206,27 +206,27 @@  discard block
 block discarded – undo
206 206
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
207 207
 	 *      @return     int             	1 if OK, 0 if KO
208 208
 	 */
209
-	function init($options='')
209
+	function init($options = '')
210 210
 	{
211
-		global $conf,$langs;
211
+		global $conf, $langs;
212 212
 
213 213
 		// Remove permissions and default values
214 214
 		$this->remove($options);
215 215
 
216 216
 		//ODT template
217
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt';
218
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal';
219
-		$dest=$dirodt.'/template_supplier_proposal.odt';
217
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt';
218
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_proposal';
219
+		$dest = $dirodt.'/template_supplier_proposal.odt';
220 220
 
221
-		if (file_exists($src) && ! file_exists($dest))
221
+		if (file_exists($src) && !file_exists($dest))
222 222
 		{
223 223
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
224 224
 			dol_mkdir($dirodt);
225
-			$result=dol_copy($src,$dest,0,0);
225
+			$result = dol_copy($src, $dest, 0, 0);
226 226
 			if ($result < 0)
227 227
 			{
228 228
 				$langs->load("errors");
229
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
229
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
230 230
 				return 0;
231 231
 			}
232 232
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modExpenseReport.class.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \ingroup    expensereport
24 24
  *      \brief      Description and activation file for module ExpenseReport
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php";
26
+include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27 27
 
28 28
 
29 29
 /**
@@ -46,32 +46,32 @@  discard block
 block discarded – undo
46 46
 		$this->family = "hr";
47 47
 		$this->module_position = '40';
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51 51
 		$this->description = "Manage and claim expense reports (transportation, meal, ...)";
52 52
 		$this->version = 'dolibarr';
53 53
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto='trip';
54
+		$this->picto = 'trip';
55 55
 
56 56
 		// Data directories to create when module is enabled.
57 57
 		$this->dirs = array("/expensereport/temp");
58
-		$r=0;
58
+		$r = 0;
59 59
 
60 60
 		// Config pages. Put here list of php page names stored in admmin directory used to setup module.
61 61
 		$this->config_page_url = array('expensereport.php');
62 62
 
63 63
 		// Dependencies
64
-		$this->hidden = false;			// A condition to hide module
65
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
64
+		$this->hidden = false; // A condition to hide module
65
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
66 66
 		// $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information
67
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
68
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
69
-		$this->need_dolibarr_version = array(3,7);	// Minimum version of Dolibarr required by module
70
-		$this->langfiles = array("companies","trips");
67
+		$this->requiredby = array(); // List of modules id to disable if this one is disabled
68
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
69
+		$this->need_dolibarr_version = array(3, 7); // Minimum version of Dolibarr required by module
70
+		$this->langfiles = array("companies", "trips");
71 71
 
72 72
 		// Constants
73
-		$this->const = array();			// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
74
-		$r=0;
73
+		$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
74
+		$r = 0;
75 75
 
76 76
 		$this->const[$r][0] = "EXPENSEREPORT_ADDON_PDF";
77 77
 		$this->const[$r][1] = "chaine";
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 		$this->tabs[] = array('data'=>'user:+expensereport:ExpenseReport:expensereport:$user->rights->expensereport->lire:/expensereport/list.php?mainmenu=hrm&id=__ID__');
106 106
 
107 107
 		// Boxes
108
-		$this->boxes = array();			// List of boxes
109
-		$r=0;
108
+		$this->boxes = array(); // List of boxes
109
+		$r = 0;
110 110
 
111 111
 		// Permissions
112
-		$this->rights = array();		// Permission array used by this module
112
+		$this->rights = array(); // Permission array used by this module
113 113
 		$this->rights_class = 'expensereport';
114 114
 
115 115
 		$this->rights[$r][0] = 771;
@@ -170,36 +170,36 @@  discard block
 block discarded – undo
170 170
 
171 171
 		// Menus
172 172
 		//-------
173
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
173
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
174 174
 
175 175
 		// Exports
176
-		$r=0;
176
+		$r = 0;
177 177
 
178 178
 		$r++;
179
-		$this->export_code[$r]='expensereport_'.$r;
180
-		$this->export_label[$r]='ListTripsAndExpenses';
181
-		$this->export_icon[$r]='trip';
182
-		$this->export_permission[$r]=array(array("expensereport","export"));
183
-        $this->export_fields_array[$r]=array(
184
-			'd.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove',
185
-			'd.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic',
186
-			'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.tva_tx'=>'VATRate',
187
-			'ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref'
179
+		$this->export_code[$r] = 'expensereport_'.$r;
180
+		$this->export_label[$r] = 'ListTripsAndExpenses';
181
+		$this->export_icon[$r] = 'trip';
182
+		$this->export_permission[$r] = array(array("expensereport", "export"));
183
+        $this->export_fields_array[$r] = array(
184
+			'd.rowid'=>"TripId", 'd.ref'=>'Ref', 'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.date_create'=>'DateCreation', 'd.date_approve'=>'DateApprove',
185
+			'd.total_ht'=>"TotalHT", 'd.total_tva'=>'TotalVAT', 'd.total_ttc'=>'TotalTTC', 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic',
186
+			'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'ed.rowid'=>'LineId', 'tf.code'=>'Type', 'ed.date'=>'Date', 'ed.tva_tx'=>'VATRate',
187
+			'ed.total_ht'=>'TotalHT', 'ed.total_tva'=>'TotalVAT', 'ed.total_ttc'=>'TotalTTC', 'ed.comments'=>'Comment', 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref'
188 188
 		);
189
-		$this->export_entities_array[$r]=array(
190
-			'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line',
191
-			'ed.tva_tx'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line',
192
-			'ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project'
189
+		$this->export_entities_array[$r] = array(
190
+			'u.lastname'=>'user', 'u.firstname'=>'user', 'u.login'=>'user', 'ed.rowid'=>'expensereport_line', 'ed.date'=>'expensereport_line',
191
+			'ed.tva_tx'=>'expensereport_line', 'ed.total_ht'=>'expensereport_line', 'ed.total_tva'=>'expensereport_line', 'ed.total_ttc'=>'expensereport_line',
192
+			'ed.comments'=>'expensereport_line', 'tf.code'=>'expensereport_line', 'p.project_ref'=>'expensereport_line', 'p.rowid'=>'project', 'p.ref'=>'project'
193 193
 		);
194
-        $this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login');
195
-		$this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
196
-
197
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
198
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,';
199
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id';
200
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid';
201
-		$this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid';
202
-		$this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport').')';
194
+        $this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login');
195
+		$this->export_dependencies_array[$r] = array('expensereport_line'=>'ed.rowid', 'type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
196
+
197
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
198
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,';
199
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id';
200
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid';
201
+		$this->export_sql_end[$r] .= ' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid';
202
+		$this->export_sql_end[$r] .= ' AND d.entity IN ('.getEntity('expensereport').')';
203 203
 	}
204 204
 
205 205
 	/**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 *	@param		string	$options	Options
211 211
 	 *	@return     int             	1 if OK, 0 if KO
212 212
 	 */
213
-	function init($options='')
213
+	function init($options = '')
214 214
 	{
215 215
 		global $conf;
216 216
 
@@ -222,6 +222,6 @@  discard block
 block discarded – undo
222 222
 				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".$conf->entity.")"
223 223
 		);
224 224
 
225
-		return $this->_init($sql,$options);
225
+		return $this->_init($sql, $options);
226 226
 	}
227 227
 }
Please login to merge, or discard this patch.