@@ -80,7 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | 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 |
|
83 | + if (! $this->emetteur->country_code) { |
|
84 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
85 | + } |
|
86 | + // Par defaut, si n'etait pas defini |
|
84 | 87 | } |
85 | 88 | |
86 | 89 | |
@@ -116,11 +119,14 @@ discard block |
||
116 | 119 | $tmpdir=trim($tmpdir); |
117 | 120 | $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
118 | 121 | if (! $tmpdir) { unset($listofdir[$key]); continue; } |
119 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
120 | - else |
|
122 | + if (! is_dir($tmpdir)) { |
|
123 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
124 | + } else |
|
121 | 125 | { |
122 | 126 | $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); |
|
127 | + if (count($tmpfiles)) { |
|
128 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
129 | + } |
|
124 | 130 | } |
125 | 131 | } |
126 | 132 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -206,7 +212,9 @@ discard block |
||
206 | 212 | $hookmanager->initHooks(array('odtgeneration')); |
207 | 213 | global $action; |
208 | 214 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
215 | + if (! is_object($outputlangs)) { |
|
216 | + $outputlangs=$langs; |
|
217 | + } |
|
210 | 218 | $sav_charset_output=$outputlangs->charset_output; |
211 | 219 | $outputlangs->charset_output='UTF-8'; |
212 | 220 | |
@@ -217,7 +225,9 @@ discard block |
||
217 | 225 | { |
218 | 226 | $dir = $conf->societe->multidir_output[$object->entity]; |
219 | 227 | $objectref = dol_sanitizeFileName($object->id); |
220 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
228 | + if (! preg_match('/specimen/i',$objectref)) { |
|
229 | + $dir.= "/" . $objectref; |
|
230 | + } |
|
221 | 231 | |
222 | 232 | if (! file_exists($dir)) |
223 | 233 | { |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
245 | 255 | { |
246 | 256 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
247 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
257 | + if ($format == '1') { |
|
258 | + $format='%Y%m%d%H%M%S'; |
|
259 | + } |
|
248 | 260 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
249 | - } |
|
250 | - else |
|
261 | + } else |
|
251 | 262 | { |
252 | 263 | $filename=$newfiletmp.'.'.$newfileformat; |
253 | 264 | } |
@@ -274,8 +285,7 @@ discard block |
||
274 | 285 | 'DELIMITER_RIGHT' => '}' |
275 | 286 | ) |
276 | 287 | ); |
277 | - } |
|
278 | - catch(Exception $e) |
|
288 | + } catch(Exception $e) |
|
279 | 289 | { |
280 | 290 | $this->error=$e->getMessage(); |
281 | 291 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -323,12 +333,10 @@ discard block |
||
323 | 333 | try |
324 | 334 | { |
325 | 335 | $listlines->setVars($key, $val, true, 'UTF-8'); |
326 | - } |
|
327 | - catch(OdfException $e) |
|
336 | + } catch(OdfException $e) |
|
328 | 337 | { |
329 | 338 | dol_syslog($e->getMessage(), LOG_INFO); |
330 | - } |
|
331 | - catch(SegmentException $e) |
|
339 | + } catch(SegmentException $e) |
|
332 | 340 | { |
333 | 341 | dol_syslog($e->getMessage(), LOG_INFO); |
334 | 342 | } |
@@ -336,8 +344,7 @@ discard block |
||
336 | 344 | $listlines->merge(); |
337 | 345 | } |
338 | 346 | $odfHandler->mergeSegment($listlines); |
339 | - } |
|
340 | - catch(OdfException $e) |
|
347 | + } catch(OdfException $e) |
|
341 | 348 | { |
342 | 349 | $this->error=$e->getMessage(); |
343 | 350 | dol_syslog($this->error, LOG_WARNING); |
@@ -362,17 +369,18 @@ discard block |
||
362 | 369 | foreach($tmparray as $key=>$value) |
363 | 370 | { |
364 | 371 | try { |
365 | - if (preg_match('/logo$/',$key)) // Image |
|
372 | + if (preg_match('/logo$/',$key)) { |
|
373 | + // Image |
|
366 | 374 | { |
367 | 375 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
368 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
369 | - } |
|
370 | - else // Text |
|
376 | + } else { |
|
377 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
378 | + } |
|
379 | + } else // Text |
|
371 | 380 | { |
372 | 381 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
373 | 382 | } |
374 | - } |
|
375 | - catch (OdfException $e) |
|
383 | + } catch (OdfException $e) |
|
376 | 384 | { |
377 | 385 | // setVars failed, probably because key not found |
378 | 386 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -385,8 +393,7 @@ discard block |
||
385 | 393 | { |
386 | 394 | try { |
387 | 395 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
388 | - } |
|
389 | - catch (OdfException $e) |
|
396 | + } catch (OdfException $e) |
|
390 | 397 | { |
391 | 398 | dol_syslog($e->getMessage(), LOG_INFO); |
392 | 399 | } |
@@ -405,8 +412,7 @@ discard block |
||
405 | 412 | dol_syslog($e->getMessage(), LOG_INFO); |
406 | 413 | return -1; |
407 | 414 | } |
408 | - } |
|
409 | - else { |
|
415 | + } else { |
|
410 | 416 | try { |
411 | 417 | $odfHandler->creator = $user->getFullName($outputlangs); |
412 | 418 | $odfHandler->title = $object->builddoc_filename; |
@@ -419,7 +425,7 @@ discard block |
||
419 | 425 | } |
420 | 426 | |
421 | 427 | $odfHandler->saveToDisk($file); |
422 | - }catch (Exception $e){ |
|
428 | + } catch (Exception $e){ |
|
423 | 429 | $this->error=$e->getMessage(); |
424 | 430 | dol_syslog($e->getMessage(), LOG_INFO); |
425 | 431 | return -1; |
@@ -428,16 +434,16 @@ discard block |
||
428 | 434 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
429 | 435 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
430 | 436 | |
431 | - if (! empty($conf->global->MAIN_UMASK)) |
|
432 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
437 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
438 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
439 | + } |
|
433 | 440 | |
434 | 441 | $odfHandler=null; // Destroy object |
435 | 442 | |
436 | 443 | $this->result = array('fullpath'=>$file); |
437 | 444 | |
438 | 445 | return 1; // Success |
439 | - } |
|
440 | - else |
|
446 | + } else |
|
441 | 447 | { |
442 | 448 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
443 | 449 | return -1; |
@@ -138,10 +138,18 @@ discard block |
||
138 | 138 | global $langs; |
139 | 139 | $langs->load("admin"); |
140 | 140 | |
141 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
142 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
143 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
144 | - if ($this->version) return $this->version; |
|
141 | + if ($this->version == 'development') { |
|
142 | + return $langs->trans("VersionDevelopment"); |
|
143 | + } |
|
144 | + if ($this->version == 'experimental') { |
|
145 | + return $langs->trans("VersionExperimental"); |
|
146 | + } |
|
147 | + if ($this->version == 'dolibarr') { |
|
148 | + return DOL_VERSION; |
|
149 | + } |
|
150 | + if ($this->version) { |
|
151 | + return $this->version; |
|
152 | + } |
|
145 | 153 | return $langs->trans("NotAvailable"); |
146 | 154 | } |
147 | 155 | |
@@ -170,8 +178,7 @@ discard block |
||
170 | 178 | $liste[$row[0]]=$row[1]; |
171 | 179 | $i++; |
172 | 180 | } |
173 | - } |
|
174 | - else |
|
181 | + } else |
|
175 | 182 | { |
176 | 183 | return -1; |
177 | 184 | } |
@@ -193,35 +200,57 @@ discard block |
||
193 | 200 | $langs->load("admin"); |
194 | 201 | |
195 | 202 | $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>'; |
|
203 | + if ($type == -1) { |
|
204 | + $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
205 | + } |
|
206 | + if ($type == -1) { |
|
207 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
208 | + } |
|
209 | + if ($type == 0) { |
|
210 | + $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
211 | + } |
|
212 | + if ($type == 1) { |
|
213 | + $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
214 | + } |
|
215 | + if ($type != -1) { |
|
216 | + $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
217 | + } |
|
201 | 218 | $s.='<br>'; |
202 | 219 | $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
203 | 220 | if ($type == 0) |
204 | 221 | { |
205 | 222 | $s.=$langs->trans("RequiredIfCustomer").': '; |
206 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
223 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
224 | + $s.='<strike>'; |
|
225 | + } |
|
207 | 226 | $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")).')'; |
|
227 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
228 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
229 | + } |
|
209 | 230 | $s.='<br>'; |
210 | 231 | } |
211 | 232 | if ($type == 1) |
212 | 233 | { |
213 | 234 | $s.=$langs->trans("RequiredIfSupplier").': '; |
214 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
235 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
236 | + $s.='<strike>'; |
|
237 | + } |
|
215 | 238 | $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")).')'; |
|
239 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
240 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
241 | + } |
|
217 | 242 | $s.='<br>'; |
218 | 243 | } |
219 | 244 | if ($type == -1) |
220 | 245 | { |
221 | 246 | $s.=$langs->trans("Required").': '; |
222 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
247 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
248 | + $s.='<strike>'; |
|
249 | + } |
|
223 | 250 | $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")).')'; |
|
251 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
252 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
253 | + } |
|
225 | 254 | $s.='<br>'; |
226 | 255 | } |
227 | 256 | $s.=$langs->trans("CanBeModifiedIfOk").': '; |
@@ -233,13 +262,17 @@ discard block |
||
233 | 262 | if ($type == 0 || $type == -1) |
234 | 263 | { |
235 | 264 | $nextval=$this->getNextValue($soc,0); |
236 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
265 | + if (empty($nextval)) { |
|
266 | + $nextval=$langs->trans("Undefined"); |
|
267 | + } |
|
237 | 268 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
238 | 269 | } |
239 | 270 | if ($type == 1 || $type == -1) |
240 | 271 | { |
241 | 272 | $nextval=$this->getNextValue($soc,1); |
242 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
273 | + if (empty($nextval)) { |
|
274 | + $nextval=$langs->trans("Undefined"); |
|
275 | + } |
|
243 | 276 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
244 | 277 | } |
245 | 278 | return $s; |
@@ -314,10 +347,18 @@ discard block |
||
314 | 347 | global $langs; |
315 | 348 | $langs->load("admin"); |
316 | 349 | |
317 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
318 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
319 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
320 | - if ($this->version) return $this->version; |
|
350 | + if ($this->version == 'development') { |
|
351 | + return $langs->trans("VersionDevelopment"); |
|
352 | + } |
|
353 | + if ($this->version == 'experimental') { |
|
354 | + return $langs->trans("VersionExperimental"); |
|
355 | + } |
|
356 | + if ($this->version == 'dolibarr') { |
|
357 | + return DOL_VERSION; |
|
358 | + } |
|
359 | + if ($this->version) { |
|
360 | + return $this->version; |
|
361 | + } |
|
321 | 362 | return $langs->trans("NotAvailable"); |
322 | 363 | } |
323 | 364 | |
@@ -336,8 +377,12 @@ discard block |
||
336 | 377 | $langs->load("admin"); |
337 | 378 | |
338 | 379 | $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>'; |
|
380 | + if ($type == -1) { |
|
381 | + $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
382 | + } |
|
383 | + if ($type == -1) { |
|
384 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
385 | + } |
|
341 | 386 | //$s.='<br>'; |
342 | 387 | //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
343 | 388 | $s.='<br>'; |
@@ -345,14 +390,18 @@ discard block |
||
345 | 390 | { |
346 | 391 | $result=$this->get_code($db,$soc,'customer'); |
347 | 392 | $nextval=$this->code; |
348 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
393 | + if (empty($nextval)) { |
|
394 | + $nextval=$langs->trans("Undefined"); |
|
395 | + } |
|
349 | 396 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
350 | 397 | } |
351 | 398 | if ($type == 1 || $type == -1) |
352 | 399 | { |
353 | 400 | $result=$this->get_code($db,$soc,'supplier'); |
354 | 401 | $nextval=$this->code; |
355 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
402 | + if (empty($nextval)) { |
|
403 | + $nextval=$langs->trans("Undefined"); |
|
404 | + } |
|
356 | 405 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
357 | 406 | } |
358 | 407 | return $s; |
@@ -188,8 +188,12 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if ($type == 0) return $examplecust; |
|
192 | - if ($type == 1) return $examplesup; |
|
191 | + if ($type == 0) { |
|
192 | + return $examplecust; |
|
193 | + } |
|
194 | + if ($type == 1) { |
|
195 | + return $examplesup; |
|
196 | + } |
|
193 | 197 | return $examplecust.'<br>'.$examplesup; |
194 | 198 | } |
195 | 199 | |
@@ -208,8 +212,12 @@ discard block |
||
208 | 212 | |
209 | 213 | // Get Mask value |
210 | 214 | $mask = ''; |
211 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
215 | + if ($type==0) { |
|
216 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
217 | + } |
|
218 | + if ($type==1) { |
|
219 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
220 | + } |
|
213 | 221 | if (! $mask) |
214 | 222 | { |
215 | 223 | $this->error='NotConfigured'; |
@@ -221,13 +229,13 @@ discard block |
||
221 | 229 | { |
222 | 230 | $field = 'code_client'; |
223 | 231 | //$where = ' AND client in (1,2)'; |
224 | - } |
|
225 | - else if ($type == 1) |
|
232 | + } else if ($type == 1) |
|
226 | 233 | { |
227 | 234 | $field = 'code_fournisseur'; |
228 | 235 | //$where = ' AND fournisseur = 1'; |
236 | + } else { |
|
237 | + return -1; |
|
229 | 238 | } |
230 | - else return -1; |
|
231 | 239 | |
232 | 240 | $now=dol_now(); |
233 | 241 | |
@@ -249,10 +257,14 @@ discard block |
||
249 | 257 | global $conf; |
250 | 258 | |
251 | 259 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
252 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
260 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
261 | + return 1; |
|
262 | + } |
|
253 | 263 | |
254 | 264 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
255 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
265 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
266 | + return 1; |
|
267 | + } |
|
256 | 268 | |
257 | 269 | return 0; |
258 | 270 | } |
@@ -284,17 +296,19 @@ discard block |
||
284 | 296 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
285 | 297 | { |
286 | 298 | $result=0; |
287 | - } |
|
288 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
299 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
289 | 300 | { |
290 | 301 | $result=-2; |
291 | - } |
|
292 | - else |
|
302 | + } else |
|
293 | 303 | { |
294 | 304 | // Get Mask value |
295 | 305 | $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; |
|
306 | + if ($type==0) { |
|
307 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
308 | + } |
|
309 | + if ($type==1) { |
|
310 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
311 | + } |
|
298 | 312 | if (! $mask) |
299 | 313 | { |
300 | 314 | $this->error='NotConfigured'; |
@@ -328,9 +342,14 @@ discard block |
||
328 | 342 | { |
329 | 343 | // phpcs:enable |
330 | 344 | $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; |
|
345 | + if ($type == 1) { |
|
346 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
347 | + } else { |
|
348 | + $sql.= " WHERE code_client = '".$code."'"; |
|
349 | + } |
|
350 | + if ($soc->id > 0) { |
|
351 | + $sql.= " AND rowid <> ".$soc->id; |
|
352 | + } |
|
334 | 353 | |
335 | 354 | $resql=$db->query($sql); |
336 | 355 | if ($resql) |
@@ -338,13 +357,11 @@ discard block |
||
338 | 357 | if ($db->num_rows($resql) == 0) |
339 | 358 | { |
340 | 359 | return 0; |
341 | - } |
|
342 | - else |
|
360 | + } else |
|
343 | 361 | { |
344 | 362 | return -1; |
345 | 363 | } |
346 | - } |
|
347 | - else |
|
364 | + } else |
|
348 | 365 | { |
349 | 366 | return -2; |
350 | 367 | } |
@@ -145,10 +145,12 @@ discard block |
||
145 | 145 | if ($resql) |
146 | 146 | { |
147 | 147 | $obj = $db->fetch_object($resql); |
148 | - if ($obj) $max = intval($obj->max); |
|
149 | - else $max=0; |
|
150 | - } |
|
151 | - else |
|
148 | + if ($obj) { |
|
149 | + $max = intval($obj->max); |
|
150 | + } else { |
|
151 | + $max=0; |
|
152 | + } |
|
153 | + } else |
|
152 | 154 | { |
153 | 155 | return -1; |
154 | 156 | } |
@@ -156,8 +158,13 @@ discard block |
||
156 | 158 | $date = dol_now(); |
157 | 159 | $yymm = strftime("%y%m",$date); |
158 | 160 | |
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 | + if ($max >= (pow(10, 5) - 1)) { |
|
162 | + $num=$max+1; |
|
163 | + } |
|
164 | + // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
165 | + else { |
|
166 | + $num = sprintf("%05s",$max+1); |
|
167 | + } |
|
161 | 168 | |
162 | 169 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
163 | 170 | return $prefix.$yymm."-".$num; |
@@ -187,12 +194,10 @@ discard block |
||
187 | 194 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
188 | 195 | { |
189 | 196 | $result=0; |
190 | - } |
|
191 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
197 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
192 | 198 | { |
193 | 199 | $result=-2; |
194 | - } |
|
195 | - else |
|
200 | + } else |
|
196 | 201 | { |
197 | 202 | if ($this->verif_syntax($code) >= 0) |
198 | 203 | { |
@@ -200,19 +205,16 @@ discard block |
||
200 | 205 | if ($is_dispo <> 0) |
201 | 206 | { |
202 | 207 | $result=-3; |
203 | - } |
|
204 | - else |
|
208 | + } else |
|
205 | 209 | { |
206 | 210 | $result=0; |
207 | 211 | } |
208 | - } |
|
209 | - else |
|
212 | + } else |
|
210 | 213 | { |
211 | 214 | if (dol_strlen($code) == 0) |
212 | 215 | { |
213 | 216 | $result=-2; |
214 | - } |
|
215 | - else |
|
217 | + } else |
|
216 | 218 | { |
217 | 219 | $result=-1; |
218 | 220 | } |
@@ -240,10 +242,15 @@ discard block |
||
240 | 242 | global $conf, $mc; |
241 | 243 | |
242 | 244 | $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 | + if ($type == 1) { |
|
246 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
247 | + } else { |
|
248 | + $sql.= " WHERE code_client = '".$code."'"; |
|
249 | + } |
|
245 | 250 | $sql.= " AND entity IN (".getEntity('societe').")"; |
246 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
251 | + if ($soc->id > 0) { |
|
252 | + $sql.= " AND rowid <> ".$soc->id; |
|
253 | + } |
|
247 | 254 | |
248 | 255 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
249 | 256 | $resql=$db->query($sql); |
@@ -252,13 +259,11 @@ discard block |
||
252 | 259 | if ($db->num_rows($resql) == 0) |
253 | 260 | { |
254 | 261 | return 0; |
255 | - } |
|
256 | - else |
|
262 | + } else |
|
257 | 263 | { |
258 | 264 | return -1; |
259 | 265 | } |
260 | - } |
|
261 | - else |
|
266 | + } else |
|
262 | 267 | { |
263 | 268 | return -2; |
264 | 269 | } |
@@ -280,8 +285,7 @@ discard block |
||
280 | 285 | if (dol_strlen($code) < 11) |
281 | 286 | { |
282 | 287 | $res = -1; |
283 | - } |
|
284 | - else |
|
288 | + } else |
|
285 | 289 | { |
286 | 290 | $res = 0; |
287 | 291 | } |
@@ -96,8 +96,11 @@ |
||
96 | 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') { |
|
100 | + $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:''); |
|
101 | + } else { |
|
102 | + $this->code = (! empty($societe->code_compta)?$societe->code_compta:''); |
|
103 | + } |
|
101 | 104 | } |
102 | 105 | |
103 | 106 | return 0; // return ok |
@@ -129,8 +129,7 @@ |
||
129 | 129 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
130 | 130 | { |
131 | 131 | $result=0; |
132 | - } |
|
133 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
132 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
134 | 133 | { |
135 | 134 | $result=-2; |
136 | 135 | } |
@@ -60,8 +60,12 @@ discard block |
||
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'; |
|
63 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') { |
|
64 | + $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
|
65 | + } |
|
66 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { |
|
67 | + $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
68 | + } |
|
65 | 69 | $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
66 | 70 | $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
67 | 71 | } |
@@ -93,9 +97,13 @@ discard block |
||
93 | 97 | $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n"; |
94 | 98 | $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n"; |
95 | 99 | $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"; |
|
100 | + if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) { |
|
101 | + $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n"; |
|
102 | + } |
|
97 | 103 | //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"; |
|
104 | + if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { |
|
105 | + $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n"; |
|
106 | + } |
|
99 | 107 | $texte.= '</td>'; |
100 | 108 | $texte.= '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
101 | 109 | $texte.= '</tr></table>'; |
@@ -146,13 +154,11 @@ discard block |
||
146 | 154 | { |
147 | 155 | $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); |
148 | 156 | $prefix = $this->prefixcustomeraccountancycode; |
149 | - } |
|
150 | - else if ($type == 'supplier') |
|
157 | + } else if ($type == 'supplier') |
|
151 | 158 | { |
152 | 159 | $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); |
153 | 160 | $prefix = $this->prefixsupplieraccountancycode; |
154 | - } |
|
155 | - else |
|
161 | + } else |
|
156 | 162 | { |
157 | 163 | $this->error = 'Bad value for parameter type'; |
158 | 164 | return -1; |
@@ -161,14 +167,20 @@ discard block |
||
161 | 167 | //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
162 | 168 | |
163 | 169 | // 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); |
|
170 | + if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) { |
|
171 | + $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse); |
|
172 | + } |
|
165 | 173 | // 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); |
|
174 | + if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) { |
|
175 | + $codetouse=preg_replace('/([a-z])/i','',$codetouse); |
|
176 | + } |
|
167 | 177 | // 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='^..(..)..'; |
|
178 | + if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { |
|
179 | + // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
|
169 | 180 | { |
170 | 181 | $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse); |
171 | 182 | } |
183 | + } |
|
172 | 184 | |
173 | 185 | $codetouse=$prefix.strtoupper($codetouse); |
174 | 186 | |
@@ -176,8 +188,7 @@ discard block |
||
176 | 188 | if (! $is_dispo) |
177 | 189 | { |
178 | 190 | $this->code=$codetouse; |
179 | - } |
|
180 | - else |
|
191 | + } else |
|
181 | 192 | { |
182 | 193 | // Pour retour |
183 | 194 | $this->code=$codetouse; |
@@ -199,14 +210,22 @@ discard block |
||
199 | 210 | function verif($db, $code, $societe, $type) |
200 | 211 | { |
201 | 212 | $sql = "SELECT "; |
202 | - if ($type == 'customer') $sql.= "code_compta"; |
|
203 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
213 | + if ($type == 'customer') { |
|
214 | + $sql.= "code_compta"; |
|
215 | + } else if ($type == 'supplier') { |
|
216 | + $sql.= "code_compta_fournisseur"; |
|
217 | + } |
|
204 | 218 | $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
205 | 219 | $sql.= " WHERE "; |
206 | - if ($type == 'customer') $sql.= "code_compta"; |
|
207 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
220 | + if ($type == 'customer') { |
|
221 | + $sql.= "code_compta"; |
|
222 | + } else if ($type == 'supplier') { |
|
223 | + $sql.= "code_compta_fournisseur"; |
|
224 | + } |
|
208 | 225 | $sql.= " = '".$db->escape($code)."'"; |
209 | - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; |
|
226 | + if (! empty($societe->id)) { |
|
227 | + $sql.= " AND rowid <> ".$societe->id; |
|
228 | + } |
|
210 | 229 | |
211 | 230 | $resql=$db->query($sql); |
212 | 231 | if ($resql) |
@@ -215,14 +234,12 @@ discard block |
||
215 | 234 | { |
216 | 235 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); |
217 | 236 | return 1; // Dispo |
218 | - } |
|
219 | - else |
|
237 | + } else |
|
220 | 238 | { |
221 | 239 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); |
222 | 240 | return 0; // Non dispo |
223 | 241 | } |
224 | - } |
|
225 | - else |
|
242 | + } else |
|
226 | 243 | { |
227 | 244 | $this->error=$db->error()." sql=".$sql; |
228 | 245 | return -1; // Erreur |
@@ -131,7 +131,9 @@ |
||
131 | 131 | */ |
132 | 132 | function validatePassword($password) |
133 | 133 | { |
134 | - if (dol_strlen($password) < $this->length) return 0; |
|
134 | + if (dol_strlen($password) < $this->length) { |
|
135 | + return 0; |
|
136 | + } |
|
135 | 137 | return 1; |
136 | 138 | } |
137 | 139 | } |
@@ -217,7 +217,7 @@ |
||
217 | 217 | if($c != $last){ |
218 | 218 | $last = $c; |
219 | 219 | $count = 0; |
220 | - }else{ |
|
220 | + } else{ |
|
221 | 221 | $count++; |
222 | 222 | } |
223 | 223 |