@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
233 | 233 | { |
234 | 234 | $nbofallowedentities=count(explode(',',getEntity('project'))); // If project are shared, nb will be > 1 |
235 | - if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity'); |
|
235 | + if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { |
|
236 | + $this->export_fields_array[$r]+=array('p.entity'=>'Entity'); |
|
237 | + } |
|
236 | 238 | } |
237 | 239 | if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
238 | 240 | { |
@@ -280,11 +282,13 @@ discard block |
||
280 | 282 | // Add extra fields |
281 | 283 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; |
282 | 284 | $resql=$this->db->query($sql); |
283 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
285 | + if ($resql) { |
|
286 | + // This can fail when class is used on old database (during migration for example) |
|
284 | 287 | { |
285 | 288 | while ($obj=$this->db->fetch_object($resql)) |
286 | 289 | { |
287 | 290 | $fieldname='extra.'.$obj->name; |
291 | + } |
|
288 | 292 | $fieldlabel=ucfirst($obj->label); |
289 | 293 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
290 | 294 | } |
@@ -314,11 +314,13 @@ discard block |
||
314 | 314 | // Add extra fields object |
315 | 315 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; |
316 | 316 | $resql=$this->db->query($sql); |
317 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
317 | + if ($resql) { |
|
318 | + // This can fail when class is used on old database (during migration for example) |
|
318 | 319 | { |
319 | 320 | while ($obj=$this->db->fetch_object($resql)) |
320 | 321 | { |
321 | 322 | $fieldname='extra.'.$obj->name; |
323 | + } |
|
322 | 324 | $fieldlabel=ucfirst($obj->label); |
323 | 325 | $typeFilter="Text"; |
324 | 326 | switch($obj->type) |
@@ -338,8 +340,12 @@ discard block |
||
338 | 340 | case 'sellist': |
339 | 341 | $tmp=''; |
340 | 342 | $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
341 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); |
|
342 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
343 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
344 | + $tmp=array_shift(array_keys($tmpparam['options'])); |
|
345 | + } |
|
346 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
347 | + $typeFilter="List:".$tmp; |
|
348 | + } |
|
343 | 349 | break; |
344 | 350 | } |
345 | 351 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -351,11 +357,13 @@ discard block |
||
351 | 357 | // Add extra fields line |
352 | 358 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'"; |
353 | 359 | $resql=$this->db->query($sql); |
354 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
360 | + if ($resql) { |
|
361 | + // This can fail when class is used on old database (during migration for example) |
|
355 | 362 | { |
356 | 363 | while ($obj=$this->db->fetch_object($resql)) |
357 | 364 | { |
358 | 365 | $fieldname='extraline.'.$obj->name; |
366 | + } |
|
359 | 367 | $fieldlabel=ucfirst($obj->label); |
360 | 368 | $typeFilter="Text"; |
361 | 369 | switch($obj->type) |
@@ -375,8 +383,12 @@ discard block |
||
375 | 383 | case 'sellist': |
376 | 384 | $tmp=''; |
377 | 385 | $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
378 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); |
|
379 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
386 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
387 | + $tmp=array_shift(array_keys($tmpparam['options'])); |
|
388 | + } |
|
389 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
390 | + $typeFilter="List:".$tmp; |
|
391 | + } |
|
380 | 392 | break; |
381 | 393 | } |
382 | 394 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -387,7 +399,9 @@ discard block |
||
387 | 399 | // End add extra fields line |
388 | 400 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
389 | 401 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
390 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
402 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
403 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
404 | + } |
|
391 | 405 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
392 | 406 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; |
393 | 407 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -397,7 +411,9 @@ discard block |
||
397 | 411 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
398 | 412 | $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; |
399 | 413 | $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; |
400 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
414 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
415 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
416 | + } |
|
401 | 417 | |
402 | 418 | $r++; |
403 | 419 | $this->export_code[$r]=$this->rights_class.'_'.$r; |
@@ -434,11 +450,13 @@ discard block |
||
434 | 450 | // Add extra fields object |
435 | 451 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; |
436 | 452 | $resql=$this->db->query($sql); |
437 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
453 | + if ($resql) { |
|
454 | + // This can fail when class is used on old database (during migration for example) |
|
438 | 455 | { |
439 | 456 | while ($obj=$this->db->fetch_object($resql)) |
440 | 457 | { |
441 | 458 | $fieldname='extra.'.$obj->name; |
459 | + } |
|
442 | 460 | $fieldlabel=ucfirst($obj->label); |
443 | 461 | $typeFilter="Text"; |
444 | 462 | switch($obj->type) |
@@ -458,8 +476,12 @@ discard block |
||
458 | 476 | case 'sellist': |
459 | 477 | $tmp=''; |
460 | 478 | $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
461 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); |
|
462 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
479 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
480 | + $tmp=array_shift(array_keys($tmpparam['options'])); |
|
481 | + } |
|
482 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
483 | + $typeFilter="List:".$tmp; |
|
484 | + } |
|
463 | 485 | break; |
464 | 486 | } |
465 | 487 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -470,7 +492,9 @@ discard block |
||
470 | 492 | // End add extra fields object |
471 | 493 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
472 | 494 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
473 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
495 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
496 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
497 | + } |
|
474 | 498 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
475 | 499 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; |
476 | 500 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -479,7 +503,9 @@ discard block |
||
479 | 503 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; |
480 | 504 | $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; |
481 | 505 | $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; |
482 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
506 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
507 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
508 | + } |
|
483 | 509 | |
484 | 510 | // Order |
485 | 511 | $r++; |
@@ -521,11 +547,13 @@ discard block |
||
521 | 547 | // Add extra fields object |
522 | 548 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'"; |
523 | 549 | $resql=$this->db->query($sql); |
524 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
550 | + if ($resql) { |
|
551 | + // This can fail when class is used on old database (during migration for example) |
|
525 | 552 | { |
526 | 553 | while ($obj=$this->db->fetch_object($resql)) |
527 | 554 | { |
528 | 555 | $fieldname='extra.'.$obj->name; |
556 | + } |
|
529 | 557 | $fieldlabel=ucfirst($obj->label); |
530 | 558 | $typeFilter="Text"; |
531 | 559 | switch($obj->type) |
@@ -546,8 +574,12 @@ discard block |
||
546 | 574 | $tmp=''; |
547 | 575 | $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
548 | 576 | $tmpkey=array_keys($tmpparam['options']); |
549 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey); |
|
550 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
577 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
578 | + $tmp=array_shift($tmpkey); |
|
579 | + } |
|
580 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
581 | + $typeFilter="List:".$tmp; |
|
582 | + } |
|
551 | 583 | break; |
552 | 584 | } |
553 | 585 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -559,11 +591,13 @@ discard block |
||
559 | 591 | // Add extra fields line |
560 | 592 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'"; |
561 | 593 | $resql=$this->db->query($sql); |
562 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
594 | + if ($resql) { |
|
595 | + // This can fail when class is used on old database (during migration for example) |
|
563 | 596 | { |
564 | 597 | while ($obj=$this->db->fetch_object($resql)) |
565 | 598 | { |
566 | 599 | $fieldname='extraline.'.$obj->name; |
600 | + } |
|
567 | 601 | $fieldlabel=ucfirst($obj->label); |
568 | 602 | $typeFilter="Text"; |
569 | 603 | switch($obj->type) |
@@ -588,7 +622,9 @@ discard block |
||
588 | 622 | $tmpparam_param_key=array_keys($tmpparam['options']); |
589 | 623 | $tmp=array_shift($tmpparam_param_key); |
590 | 624 | } |
591 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
625 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
626 | + $typeFilter="List:".$tmp; |
|
627 | + } |
|
592 | 628 | break; |
593 | 629 | } |
594 | 630 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -599,7 +635,9 @@ discard block |
||
599 | 635 | // End add extra fields line |
600 | 636 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
601 | 637 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
602 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
638 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
639 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
640 | + } |
|
603 | 641 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
604 | 642 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; |
605 | 643 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -611,7 +649,9 @@ discard block |
||
611 | 649 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
612 | 650 | $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; |
613 | 651 | $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')'; |
614 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
652 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
653 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
654 | + } |
|
615 | 655 | } |
616 | 656 | |
617 | 657 |
@@ -146,23 +146,37 @@ discard block |
||
146 | 146 | $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) |
147 | 147 | $this->export_permission[$r]=array(array("service","export")); |
148 | 148 | $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); |
149 | - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock')); |
|
150 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
149 | + if (! empty($conf->stock->enabled)) { |
|
150 | + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock')); |
|
151 | + } |
|
152 | + if (! empty($conf->global->PRODUCT_USE_UNITS)) { |
|
153 | + $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
154 | + } |
|
151 | 155 | //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); |
152 | 156 | $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); |
153 | - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric')); |
|
154 | - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
157 | + if (! empty($conf->stock->enabled)) { |
|
158 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric')); |
|
159 | + } |
|
160 | + if (! empty($conf->barcode->enabled)) { |
|
161 | + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); |
|
162 | + } |
|
155 | 163 | $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); |
156 | - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service')); |
|
157 | - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service')); |
|
164 | + if (! empty($conf->stock->enabled)) { |
|
165 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service')); |
|
166 | + } |
|
167 | + if (! empty($conf->barcode->enabled)) { |
|
168 | + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service')); |
|
169 | + } |
|
158 | 170 | // Add extra fields |
159 | 171 | $sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; |
160 | 172 | $resql=$this->db->query($sql); |
161 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
173 | + if ($resql) { |
|
174 | + // This can fail when class is used on old database (during migration for example) |
|
162 | 175 | { |
163 | 176 | while ($obj=$this->db->fetch_object($resql)) |
164 | 177 | { |
165 | 178 | $fieldname='extra.'.$obj->name; |
179 | + } |
|
166 | 180 | $fieldlabel=ucfirst($obj->label); |
167 | 181 | $typeFilter="Text"; |
168 | 182 | switch($obj->type) |
@@ -182,8 +196,12 @@ discard block |
||
182 | 196 | case 'sellist': |
183 | 197 | $tmp=''; |
184 | 198 | $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
185 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); |
|
186 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
199 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
200 | + $tmp=array_shift(array_keys($tmpparam['options'])); |
|
201 | + } |
|
202 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
203 | + $typeFilter="List:".$tmp; |
|
204 | + } |
|
187 | 205 | break; |
188 | 206 | } |
189 | 207 | $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
@@ -196,16 +214,20 @@ discard block |
||
196 | 214 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
197 | 215 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; |
198 | 216 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; |
199 | - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
217 | + if (! empty($conf->fournisseur->enabled)) { |
|
218 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; |
|
219 | + } |
|
200 | 220 | $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; |
201 | 221 | |
202 | 222 | |
203 | - if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) |
|
223 | + if (empty($conf->product->enabled)) { |
|
224 | + // We enable next import templates only if module product not already enabled (to avoid duplicate entries) |
|
204 | 225 | { |
205 | 226 | if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
206 | 227 | { |
207 | 228 | // Exports product multiprice |
208 | 229 | $r++; |
230 | + } |
|
209 | 231 | $this->export_code[$r]=$this->rights_class.'_'.$r; |
210 | 232 | $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) |
211 | 233 | $this->export_permission[$r]=array(array("produit","export")); |
@@ -252,16 +274,22 @@ discard block |
||
252 | 274 | 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", |
253 | 275 | 'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' |
254 | 276 | ); |
255 | - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
256 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
277 | + if (! empty($conf->barcode->enabled)) { |
|
278 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); |
|
279 | + } |
|
280 | + if (! empty($conf->global->PRODUCT_USE_UNITS)) { |
|
281 | + $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; |
|
282 | + } |
|
257 | 283 | // Add extra fields |
258 | 284 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; |
259 | 285 | $resql=$this->db->query($sql); |
260 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
286 | + if ($resql) { |
|
287 | + // This can fail when class is used on old database (during migration for example) |
|
261 | 288 | { |
262 | 289 | while ($obj=$this->db->fetch_object($resql)) |
263 | 290 | { |
264 | 291 | $fieldname='extra.'.$obj->name; |
292 | + } |
|
265 | 293 | $fieldlabel=ucfirst($obj->label); |
266 | 294 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
267 | 295 | } |
@@ -272,12 +300,14 @@ discard block |
||
272 | 300 | $this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31'); |
273 | 301 | |
274 | 302 | |
275 | - if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) |
|
303 | + if (empty($conf->product->enabled)) { |
|
304 | + // We enable next import templates only if module product not already enabled (to avoid duplicate entries) |
|
276 | 305 | { |
277 | 306 | if (! empty($conf->fournisseur->enabled)) |
278 | 307 | { |
279 | 308 | // Import suppliers prices (note: this code is duplicated into module product) |
280 | 309 | $r++; |
310 | + } |
|
281 | 311 | $this->import_code[$r]=$this->rights_class.'_supplierprices'; |
282 | 312 | $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key |
283 | 313 | $this->import_icon[$r]=$this->picto; |
@@ -288,9 +318,15 @@ discard block |
||
288 | 318 | 'sp.fk_product'=>"ProductOrService*", |
289 | 319 | 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode' |
290 | 320 | ); |
291 | - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR')); |
|
292 | - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
293 | - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
321 | + if (is_object($mysoc) && $mysoc->useNPR()) { |
|
322 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR')); |
|
323 | + } |
|
324 | + if (is_object($mysoc) && $mysoc->useLocalTax(1)) { |
|
325 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); |
|
326 | + } |
|
327 | + if (is_object($mysoc) && $mysoc->useLocalTax(2)) { |
|
328 | + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); |
|
329 | + } |
|
294 | 330 | $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array( |
295 | 331 | 'sp.price'=>"PriceQtyMinHT*", |
296 | 332 | 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty |
@@ -62,7 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | // Get source company |
64 | 64 | $this->emetteur=$mysoc; |
65 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
65 | + if (! $this->emetteur->country_code) { |
|
66 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
67 | + } |
|
68 | + // By default if not defined |
|
66 | 69 | |
67 | 70 | // Define position of columns |
68 | 71 | $this->posxdesc=$this->marge_gauche+1; |
@@ -82,9 +85,11 @@ discard block |
||
82 | 85 | |
83 | 86 | $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
84 | 87 | |
85 | - if ($this->page_largeur < 210) // To work with US executive format |
|
88 | + if ($this->page_largeur < 210) { |
|
89 | + // To work with US executive format |
|
86 | 90 | { |
87 | 91 | $this->posxweightvol-=20; |
92 | + } |
|
88 | 93 | $this->posxpicture-=20; |
89 | 94 | $this->posxqtyordered-=20; |
90 | 95 | $this->posxqtytoship-=20; |
@@ -117,9 +122,13 @@ discard block |
||
117 | 122 | |
118 | 123 | $object->fetch_thirdparty(); |
119 | 124 | |
120 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
125 | + if (! is_object($outputlangs)) { |
|
126 | + $outputlangs=$langs; |
|
127 | + } |
|
121 | 128 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
122 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
129 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
130 | + $outputlangs->charset_output='ISO-8859-1'; |
|
131 | + } |
|
123 | 132 | |
124 | 133 | $outputlangs->load("main"); |
125 | 134 | $outputlangs->load("dict"); |
@@ -141,7 +150,9 @@ discard block |
||
141 | 150 | |
142 | 151 | for ($i = 0 ; $i < $nblignes ; $i++) |
143 | 152 | { |
144 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
153 | + if (empty($object->lines[$i]->fk_product)) { |
|
154 | + continue; |
|
155 | + } |
|
145 | 156 | |
146 | 157 | $objphoto = new Product($this->db); |
147 | 158 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -153,18 +164,18 @@ discard block |
||
153 | 164 | |
154 | 165 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
155 | 166 | { |
156 | - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
167 | + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { |
|
168 | + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
157 | 169 | { |
158 | 170 | if ($obj['photo_vignette']) |
159 | 171 | { |
160 | 172 | $filename= $obj['photo_vignette']; |
161 | - } |
|
162 | - else |
|
173 | + } |
|
174 | + } else |
|
163 | 175 | { |
164 | 176 | $filename=$obj['photo']; |
165 | 177 | } |
166 | - } |
|
167 | - else |
|
178 | + } else |
|
168 | 179 | { |
169 | 180 | $filename=$obj['photo']; |
170 | 181 | } |
@@ -173,11 +184,15 @@ discard block |
||
173 | 184 | break; |
174 | 185 | } |
175 | 186 | |
176 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
187 | + if ($realpath) { |
|
188 | + $realpatharray[$i]=$realpath; |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | } |
179 | 192 | |
180 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
|
193 | + if (count($realpatharray) == 0) { |
|
194 | + $this->posxpicture=$this->posxweightvol; |
|
195 | + } |
|
181 | 196 | |
182 | 197 | if ($conf->reception->dir_output) |
183 | 198 | { |
@@ -186,8 +201,7 @@ discard block |
||
186 | 201 | { |
187 | 202 | $dir = $conf->reception->dir_output; |
188 | 203 | $file = $dir . "/SPECIMEN.pdf"; |
189 | - } |
|
190 | - else |
|
204 | + } else |
|
191 | 205 | { |
192 | 206 | $rcpref = dol_sanitizeFileName($object->ref); |
193 | 207 | $dir = $conf->reception->dir_output."/" . $rcpref; |
@@ -243,20 +257,26 @@ discard block |
||
243 | 257 | $pagenb=0; |
244 | 258 | $pdf->SetDrawColor(128,128,128); |
245 | 259 | |
246 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
260 | + if (method_exists($pdf,'AliasNbPages')) { |
|
261 | + $pdf->AliasNbPages(); |
|
262 | + } |
|
247 | 263 | |
248 | 264 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
249 | 265 | $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
250 | 266 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
251 | 267 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
252 | 268 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
253 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
269 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
270 | + $pdf->SetCompression(false); |
|
271 | + } |
|
254 | 272 | |
255 | 273 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
256 | 274 | |
257 | 275 | // New page |
258 | 276 | $pdf->AddPage(); |
259 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
277 | + if (! empty($tplidx)) { |
|
278 | + $pdf->useTemplate($tplidx); |
|
279 | + } |
|
260 | 280 | $pagenb++; |
261 | 281 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
262 | 282 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -313,7 +333,9 @@ discard block |
||
313 | 333 | // Get code using getLabelFromKey |
314 | 334 | $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
315 | 335 | $label=''; |
316 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
336 | + if ($object->tracking_url != $object->tracking_number) { |
|
337 | + $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
338 | + } |
|
317 | 339 | $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
318 | 340 | //var_dump($object->tracking_url != $object->tracking_number);exit; |
319 | 341 | if ($object->tracking_url != $object->tracking_number) |
@@ -345,8 +367,7 @@ discard block |
||
345 | 367 | |
346 | 368 | $tab_height = $tab_height - $height_note; |
347 | 369 | $tab_top = $nexY+6; |
348 | - } |
|
349 | - else |
|
370 | + } else |
|
350 | 371 | { |
351 | 372 | $height_note=0; |
352 | 373 | } |
@@ -365,7 +386,9 @@ discard block |
||
365 | 386 | |
366 | 387 | // Define size of image if we need it |
367 | 388 | $imglinesize=array(); |
368 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
389 | + if (! empty($realpatharray[$i])) { |
|
390 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
391 | + } |
|
369 | 392 | |
370 | 393 | $pdf->setTopMargin($tab_top_newpage); |
371 | 394 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -376,11 +399,17 @@ discard block |
||
376 | 399 | $posYAfterDescription=0; |
377 | 400 | |
378 | 401 | // We start with Photo of product line |
379 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
402 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
403 | + // If photo too high, we moved completely on new page |
|
380 | 404 | { |
381 | 405 | $pdf->AddPage('','',true); |
382 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
406 | + } |
|
407 | + if (! empty($tplidx)) { |
|
408 | + $pdf->useTemplate($tplidx); |
|
409 | + } |
|
410 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
411 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
412 | + } |
|
384 | 413 | $pdf->setPage($pageposbefore+1); |
385 | 414 | |
386 | 415 | $curY = $tab_top_newpage; |
@@ -402,9 +431,11 @@ discard block |
||
402 | 431 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
403 | 432 | |
404 | 433 | $pageposafter=$pdf->getPage(); |
405 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
434 | + if ($pageposafter > $pageposbefore) { |
|
435 | + // There is a pagebreak |
|
406 | 436 | { |
407 | 437 | $pdf->rollbackTransaction(true); |
438 | + } |
|
408 | 439 | $pageposafter=$pageposbefore; |
409 | 440 | //print $pageposafter.'-'.$pageposbefore;exit; |
410 | 441 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -414,23 +445,27 @@ discard block |
||
414 | 445 | $pageposafter=$pdf->getPage(); |
415 | 446 | $posyafter=$pdf->GetY(); |
416 | 447 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
448 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
449 | + // There is no space left for total+free text |
|
418 | 450 | { |
419 | 451 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
420 | 452 | { |
421 | 453 | $pdf->AddPage('','',true); |
422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
454 | + } |
|
455 | + if (! empty($tplidx)) { |
|
456 | + $pdf->useTemplate($tplidx); |
|
457 | + } |
|
458 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
459 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
460 | + } |
|
424 | 461 | $pdf->setPage($pageposafter+1); |
425 | 462 | } |
426 | - } |
|
427 | - else |
|
463 | + } else |
|
428 | 464 | { |
429 | 465 | // We found a page break |
430 | 466 | $showpricebeforepagebreak=0; |
431 | 467 | } |
432 | - } |
|
433 | - else // No pagebreak |
|
468 | + } else // No pagebreak |
|
434 | 469 | { |
435 | 470 | $pdf->commitTransaction(); |
436 | 471 | } |
@@ -493,7 +528,9 @@ discard block |
||
493 | 528 | } |
494 | 529 | |
495 | 530 | $nexY+=3; |
496 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
531 | + if ($weighttxt && $voltxt) { |
|
532 | + $nexY+=2; |
|
533 | + } |
|
497 | 534 | |
498 | 535 | // Add line |
499 | 536 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -512,8 +549,7 @@ discard block |
||
512 | 549 | if ($pagenb == 1) |
513 | 550 | { |
514 | 551 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
515 | - } |
|
516 | - else |
|
552 | + } else |
|
517 | 553 | { |
518 | 554 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
519 | 555 | } |
@@ -527,15 +563,16 @@ discard block |
||
527 | 563 | if ($pagenb == 1) |
528 | 564 | { |
529 | 565 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
530 | - } |
|
531 | - else |
|
566 | + } else |
|
532 | 567 | { |
533 | 568 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
534 | 569 | } |
535 | 570 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
536 | 571 | // New page |
537 | 572 | $pdf->AddPage(); |
538 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
573 | + if (! empty($tplidx)) { |
|
574 | + $pdf->useTemplate($tplidx); |
|
575 | + } |
|
539 | 576 | $pagenb++; |
540 | 577 | } |
541 | 578 | } |
@@ -545,8 +582,7 @@ discard block |
||
545 | 582 | { |
546 | 583 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
547 | 584 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
548 | - } |
|
549 | - else |
|
585 | + } else |
|
550 | 586 | { |
551 | 587 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
552 | 588 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -557,7 +593,9 @@ discard block |
||
557 | 593 | |
558 | 594 | // Pied de page |
559 | 595 | $this->_pagefoot($pdf,$object,$outputlangs); |
560 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
596 | + if (method_exists($pdf,'AliasNbPages')) { |
|
597 | + $pdf->AliasNbPages(); |
|
598 | + } |
|
561 | 599 | |
562 | 600 | $pdf->Close(); |
563 | 601 | |
@@ -569,18 +607,17 @@ discard block |
||
569 | 607 | global $action; |
570 | 608 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
571 | 609 | |
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
610 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
611 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
612 | + } |
|
574 | 613 | |
575 | 614 | return 1; // No error |
576 | - } |
|
577 | - else |
|
615 | + } else |
|
578 | 616 | { |
579 | 617 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
580 | 618 | return 0; |
581 | 619 | } |
582 | - } |
|
583 | - else |
|
620 | + } else |
|
584 | 621 | { |
585 | 622 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
586 | 623 | return 0; |
@@ -618,8 +655,11 @@ discard block |
||
618 | 655 | { |
619 | 656 | $col2x-=20; |
620 | 657 | }*/ |
621 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | - else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
658 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { |
|
659 | + $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
660 | + } else { |
|
661 | + $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
662 | + } |
|
623 | 663 | |
624 | 664 | $useborder=0; |
625 | 665 | $index = 0; |
@@ -641,10 +681,18 @@ discard block |
||
641 | 681 | $object->volume_units=$object->size_units * 3; |
642 | 682 | } |
643 | 683 | |
644 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
684 | + if ($totalWeight!='') { |
|
685 | + $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
686 | + } |
|
687 | + if ($totalVolume!='') { |
|
688 | + $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
689 | + } |
|
690 | + if ($object->trueWeight) { |
|
691 | + $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
692 | + } |
|
693 | + if ($object->trueVolume) { |
|
694 | + $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
695 | + } |
|
648 | 696 | |
649 | 697 | $pdf->SetFillColor(255,255,255); |
650 | 698 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -683,7 +731,9 @@ discard block |
||
683 | 731 | |
684 | 732 | $index++; |
685 | 733 | } |
686 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
734 | + if (! $totalWeighttoshow && ! $totalVolumetoshow) { |
|
735 | + $index++; |
|
736 | + } |
|
687 | 737 | |
688 | 738 | $pdf->SetTextColor(0,0,0); |
689 | 739 | |
@@ -708,7 +758,9 @@ discard block |
||
708 | 758 | |
709 | 759 | // Force to disable hidetop and hidebottom |
710 | 760 | $hidebottom=0; |
711 | - if ($hidetop) $hidetop=-1; |
|
761 | + if ($hidetop) { |
|
762 | + $hidetop=-1; |
|
763 | + } |
|
712 | 764 | |
713 | 765 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
714 | 766 | |
@@ -816,16 +868,14 @@ discard block |
||
816 | 868 | { |
817 | 869 | $height=pdf_getHeightForLogo($logo); |
818 | 870 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
819 | - } |
|
820 | - else |
|
871 | + } else |
|
821 | 872 | { |
822 | 873 | $pdf->SetTextColor(200,0,0); |
823 | 874 | $pdf->SetFont('','B', $default_font_size - 2); |
824 | 875 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
825 | 876 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
826 | 877 | } |
827 | - } |
|
828 | - else |
|
878 | + } else |
|
829 | 879 | { |
830 | 880 | $text=$this->emetteur->name; |
831 | 881 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -835,8 +885,7 @@ discard block |
||
835 | 885 | if (! empty($conf->barcode->enabled)) |
836 | 886 | { |
837 | 887 | $posx=105; |
838 | - } |
|
839 | - else |
|
888 | + } else |
|
840 | 889 | { |
841 | 890 | $posx=$this->marge_gauche+3; |
842 | 891 | } |
@@ -900,9 +949,11 @@ discard block |
||
900 | 949 | $origin_id = $object->origin_id; |
901 | 950 | |
902 | 951 | // TODO move to external function |
903 | - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
952 | + if (! empty($conf->fournisseur->enabled)) { |
|
953 | + // commonly $origin='commande' |
|
904 | 954 | { |
905 | 955 | $outputlangs->load('orders'); |
956 | + } |
|
906 | 957 | |
907 | 958 | $classname = 'CommandeFournisseur'; |
908 | 959 | $linkedobject = new $classname($this->db); |
@@ -913,7 +964,9 @@ discard block |
||
913 | 964 | |
914 | 965 | $pdf->SetFont('','', $default_font_size - 2); |
915 | 966 | $text=$linkedobject->ref; |
916 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
967 | + if ($linkedobject->ref_client) { |
|
968 | + $text.=' ('.$linkedobject->ref_client.')'; |
|
969 | + } |
|
917 | 970 | $Yoff = $Yoff+8; |
918 | 971 | $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
919 | 972 | $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
@@ -929,8 +982,12 @@ discard block |
||
929 | 982 | $carac_emetteur=''; |
930 | 983 | // Add internal contact of origin element if defined |
931 | 984 | $arrayidcontact=array(); |
932 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
985 | + if (! empty($origin) && is_object($object->$origin)) { |
|
986 | + $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
987 | + } |
|
988 | + if(empty($arrayidcontact)) { |
|
989 | + $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
990 | + } |
|
934 | 991 | if (count($arrayidcontact) > 0) |
935 | 992 | { |
936 | 993 | $object->fetch_user(reset($arrayidcontact)); |
@@ -942,7 +999,9 @@ discard block |
||
942 | 999 | // Show sender |
943 | 1000 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
944 | 1001 | $posx=$this->marge_gauche; |
945 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1002 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1003 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1004 | + } |
|
946 | 1005 | |
947 | 1006 | $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
948 | 1007 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
@@ -994,10 +1053,15 @@ discard block |
||
994 | 1053 | |
995 | 1054 | // Show recipient |
996 | 1055 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
997 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1056 | + if ($this->page_largeur < 210) { |
|
1057 | + $widthrecbox=84; |
|
1058 | + } |
|
1059 | + // To work with US executive format |
|
998 | 1060 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
999 | 1061 | $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
1000 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1062 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1063 | + $posx=$this->marge_gauche; |
|
1064 | + } |
|
1001 | 1065 | |
1002 | 1066 | // Show recipient frame |
1003 | 1067 | $pdf->SetTextColor(0,0,0); |
@@ -81,7 +81,10 @@ discard block |
||
81 | 81 | |
82 | 82 | // Recupere emetteur |
83 | 83 | $this->emetteur=$mysoc; |
84 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | + if (! $this->emetteur->country_code) { |
|
85 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
86 | + } |
|
87 | + // By default if not defined |
|
85 | 88 | } |
86 | 89 | |
87 | 90 | |
@@ -119,11 +122,14 @@ discard block |
||
119 | 122 | if (! $tmpdir) { |
120 | 123 | unset($listofdir[$key]); continue; |
121 | 124 | } |
122 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | - else |
|
125 | + if (! is_dir($tmpdir)) { |
|
126 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
127 | + } else |
|
124 | 128 | { |
125 | 129 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
126 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
130 | + if (count($tmpfiles)) { |
|
131 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
132 | + } |
|
127 | 133 | } |
128 | 134 | } |
129 | 135 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -205,7 +211,9 @@ discard block |
||
205 | 211 | $hookmanager->initHooks(array('odtgeneration')); |
206 | 212 | global $action; |
207 | 213 | |
208 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
214 | + if (! is_object($outputlangs)) { |
|
215 | + $outputlangs=$langs; |
|
216 | + } |
|
209 | 217 | $sav_charset_output=$outputlangs->charset_output; |
210 | 218 | $outputlangs->charset_output='UTF-8'; |
211 | 219 | |
@@ -231,7 +239,9 @@ discard block |
||
231 | 239 | |
232 | 240 | $dir = $conf->reception->dir_output."/reception"; |
233 | 241 | $objectref = dol_sanitizeFileName($object->ref); |
234 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
242 | + if (! preg_match('/specimen/i',$objectref)) { |
|
243 | + $dir.= "/" . $objectref; |
|
244 | + } |
|
235 | 245 | $file = $dir . "/" . $objectref . ".odt"; |
236 | 246 | |
237 | 247 | if (! file_exists($dir)) |
@@ -257,10 +267,11 @@ discard block |
||
257 | 267 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
258 | 268 | { |
259 | 269 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
260 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
270 | + if ($format == '1') { |
|
271 | + $format='%Y%m%d%H%M%S'; |
|
272 | + } |
|
261 | 273 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
262 | - } |
|
263 | - else |
|
274 | + } else |
|
264 | 275 | { |
265 | 276 | $filename=$newfiletmp.'.'.$newfileformat; |
266 | 277 | } |
@@ -286,10 +297,12 @@ discard block |
||
286 | 297 | if (! empty($usecontact)) |
287 | 298 | { |
288 | 299 | // On peut utiliser le nom de la societe du contact |
289 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | - else $socobject = $object->thirdparty; |
|
291 | - } |
|
292 | - else |
|
300 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
301 | + $socobject = $object->contact; |
|
302 | + } else { |
|
303 | + $socobject = $object->thirdparty; |
|
304 | + } |
|
305 | + } else |
|
293 | 306 | { |
294 | 307 | $socobject=$object->thirdparty; |
295 | 308 | } |
@@ -327,8 +340,7 @@ discard block |
||
327 | 340 | 'DELIMITER_RIGHT' => '}' |
328 | 341 | ) |
329 | 342 | ); |
330 | - } |
|
331 | - catch(Exception $e) |
|
343 | + } catch(Exception $e) |
|
332 | 344 | { |
333 | 345 | $this->error=$e->getMessage(); |
334 | 346 | return -1; |
@@ -343,8 +355,7 @@ discard block |
||
343 | 355 | // Make substitutions into odt of freetext |
344 | 356 | try { |
345 | 357 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
346 | - } |
|
347 | - catch(OdfException $e) |
|
358 | + } catch(OdfException $e) |
|
348 | 359 | { |
349 | 360 | } |
350 | 361 | |
@@ -354,18 +365,19 @@ discard block |
||
354 | 365 | foreach($tmparray as $key=>$value) |
355 | 366 | { |
356 | 367 | try { |
357 | - if (preg_match('/logo$/',$key)) // Image |
|
368 | + if (preg_match('/logo$/',$key)) { |
|
369 | + // Image |
|
358 | 370 | { |
359 | 371 | //var_dump($value);exit; |
360 | 372 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
361 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | - } |
|
363 | - else // Text |
|
373 | + } else { |
|
374 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
375 | + } |
|
376 | + } else // Text |
|
364 | 377 | { |
365 | 378 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
366 | 379 | } |
367 | - } |
|
368 | - catch(OdfException $e) |
|
380 | + } catch(OdfException $e) |
|
369 | 381 | { |
370 | 382 | } |
371 | 383 | } |
@@ -375,18 +387,19 @@ discard block |
||
375 | 387 | foreach($tmparray as $key=>$value) |
376 | 388 | { |
377 | 389 | try { |
378 | - if (preg_match('/logo$/',$key)) // Image |
|
390 | + if (preg_match('/logo$/',$key)) { |
|
391 | + // Image |
|
379 | 392 | { |
380 | 393 | //var_dump($value);exit; |
381 | 394 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | - } |
|
384 | - else // Text |
|
395 | + } else { |
|
396 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
397 | + } |
|
398 | + } else // Text |
|
385 | 399 | { |
386 | 400 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
387 | 401 | } |
388 | - } |
|
389 | - catch(OdfException $e) |
|
402 | + } catch(OdfException $e) |
|
390 | 403 | { |
391 | 404 | } |
392 | 405 | } |
@@ -395,17 +408,18 @@ discard block |
||
395 | 408 | foreach($tmparray as $key=>$value) |
396 | 409 | { |
397 | 410 | try { |
398 | - if (preg_match('/logo$/',$key)) // Image |
|
411 | + if (preg_match('/logo$/',$key)) { |
|
412 | + // Image |
|
399 | 413 | { |
400 | 414 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
401 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | - } |
|
403 | - else // Text |
|
415 | + } else { |
|
416 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
417 | + } |
|
418 | + } else // Text |
|
404 | 419 | { |
405 | 420 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
406 | 421 | } |
407 | - } |
|
408 | - catch(OdfException $e) |
|
422 | + } catch(OdfException $e) |
|
409 | 423 | { |
410 | 424 | } |
411 | 425 | } |
@@ -418,17 +432,18 @@ discard block |
||
418 | 432 | foreach($tmparray as $key=>$value) |
419 | 433 | { |
420 | 434 | try { |
421 | - if (preg_match('/logo$/',$key)) // Image |
|
435 | + if (preg_match('/logo$/',$key)) { |
|
436 | + // Image |
|
422 | 437 | { |
423 | 438 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
424 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | - } |
|
426 | - else // Text |
|
439 | + } else { |
|
440 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
441 | + } |
|
442 | + } else // Text |
|
427 | 443 | { |
428 | 444 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
429 | 445 | } |
430 | - } |
|
431 | - catch(OdfException $e) |
|
446 | + } catch(OdfException $e) |
|
432 | 447 | { |
433 | 448 | } |
434 | 449 | } |
@@ -448,19 +463,16 @@ discard block |
||
448 | 463 | try |
449 | 464 | { |
450 | 465 | $listlines->setVars($key, $val, true, 'UTF-8'); |
451 | - } |
|
452 | - catch(OdfException $e) |
|
466 | + } catch(OdfException $e) |
|
453 | 467 | { |
454 | - } |
|
455 | - catch(SegmentException $e) |
|
468 | + } catch(SegmentException $e) |
|
456 | 469 | { |
457 | 470 | } |
458 | 471 | } |
459 | 472 | $listlines->merge(); |
460 | 473 | } |
461 | 474 | $odfHandler->mergeSegment($listlines); |
462 | - } |
|
463 | - catch(OdfException $e) |
|
475 | + } catch(OdfException $e) |
|
464 | 476 | { |
465 | 477 | $this->error=$e->getMessage(); |
466 | 478 | dol_syslog($this->error, LOG_WARNING); |
@@ -473,8 +485,7 @@ discard block |
||
473 | 485 | { |
474 | 486 | try { |
475 | 487 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
476 | - } |
|
477 | - catch(OdfException $e) |
|
488 | + } catch(OdfException $e) |
|
478 | 489 | { |
479 | 490 | } |
480 | 491 | } |
@@ -487,15 +498,14 @@ discard block |
||
487 | 498 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
488 | 499 | try { |
489 | 500 | $odfHandler->exportAsAttachedPDF($file); |
490 | - }catch (Exception $e){ |
|
501 | + } catch (Exception $e){ |
|
491 | 502 | $this->error=$e->getMessage(); |
492 | 503 | return -1; |
493 | 504 | } |
494 | - } |
|
495 | - else { |
|
505 | + } else { |
|
496 | 506 | try { |
497 | 507 | $odfHandler->saveToDisk($file); |
498 | - }catch (Exception $e){ |
|
508 | + } catch (Exception $e){ |
|
499 | 509 | $this->error=$e->getMessage(); |
500 | 510 | return -1; |
501 | 511 | } |
@@ -503,14 +513,14 @@ discard block |
||
503 | 513 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
504 | 514 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
505 | 515 | |
506 | - if (! empty($conf->global->MAIN_UMASK)) |
|
507 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
517 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
518 | + } |
|
508 | 519 | |
509 | 520 | $odfHandler=null; // Destroy object |
510 | 521 | |
511 | 522 | return 1; // Success |
512 | - } |
|
513 | - else |
|
523 | + } else |
|
514 | 524 | { |
515 | 525 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
516 | 526 | return -1; |
@@ -111,10 +111,12 @@ discard block |
||
111 | 111 | if ($resql) |
112 | 112 | { |
113 | 113 | $obj = $db->fetch_object($resql); |
114 | - if ($obj) $max = intval($obj->max); |
|
115 | - else $max=0; |
|
116 | - } |
|
117 | - else |
|
114 | + if ($obj) { |
|
115 | + $max = intval($obj->max); |
|
116 | + } else { |
|
117 | + $max=0; |
|
118 | + } |
|
119 | + } else |
|
118 | 120 | { |
119 | 121 | dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
120 | 122 | return -1; |
@@ -123,8 +125,13 @@ discard block |
||
123 | 125 | $date=time(); |
124 | 126 | $yymm = strftime("%y%m",$date); |
125 | 127 | |
126 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | - else $num = sprintf("%04s",$max+1); |
|
128 | + if ($max >= (pow(10, 4) - 1)) { |
|
129 | + $num=$max+1; |
|
130 | + } |
|
131 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
132 | + else { |
|
133 | + $num = sprintf("%04s",$max+1); |
|
134 | + } |
|
128 | 135 | |
129 | 136 | dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
130 | 137 | return $this->prefix.$yymm."-".$num; |
@@ -134,10 +134,12 @@ discard block |
||
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max=0; |
|
141 | + } |
|
142 | + } else |
|
141 | 143 | { |
142 | 144 | dol_syslog(__METHOD__, LOG_DEBUG); |
143 | 145 | return -1; |
@@ -147,8 +149,13 @@ discard block |
||
147 | 149 | $date=$object->datepaye; |
148 | 150 | $yymm = strftime("%y%m",$date); |
149 | 151 | |
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | + if ($max >= (pow(10, 4) - 1)) { |
|
153 | + $num=$max+1; |
|
154 | + } |
|
155 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
156 | + else { |
|
157 | + $num = sprintf("%04s",$max+1); |
|
158 | + } |
|
152 | 159 | |
153 | 160 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
154 | 161 | return $this->prefix.$yymm."-".$num; |
@@ -263,11 +263,13 @@ |
||
263 | 263 | // Add extra fields |
264 | 264 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; |
265 | 265 | $resql=$this->db->query($sql); |
266 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
266 | + if ($resql) { |
|
267 | + // This can fail when class is used on old database (during migration for example) |
|
267 | 268 | { |
268 | 269 | while ($obj=$this->db->fetch_object($resql)) |
269 | 270 | { |
270 | 271 | $fieldname='extra.'.$obj->name; |
272 | + } |
|
271 | 273 | $fieldlabel=ucfirst($obj->label); |
272 | 274 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
273 | 275 | } |
@@ -94,8 +94,7 @@ discard block |
||
94 | 94 | require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; |
95 | 95 | $this->label_lib='PhpWriteExcel'; |
96 | 96 | $this->version_lib='unknown'; |
97 | - } |
|
98 | - else |
|
97 | + } else |
|
99 | 98 | { |
100 | 99 | require_once PHPEXCEL_PATH.'PHPExcel.php'; |
101 | 100 | require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; |
@@ -122,8 +121,7 @@ discard block |
||
122 | 121 | if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) |
123 | 122 | { |
124 | 123 | $this->workbook->close(); |
125 | - } |
|
126 | - else |
|
124 | + } else |
|
127 | 125 | { |
128 | 126 | require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php'; |
129 | 127 | $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); |