59 public $errors = array();
64 public $warnings = array();
74 public $extrafieldsCache;
79 public $update_main_doc_field;
104 public $page_hauteur;
109 public $page_largeur;
114 public $marge_gauche;
119 public $marge_droite;
134 public $corner_radius;
147 public $option_multilang;
151 public $option_freetext;
155 public $option_draft_watermark;
164 public $option_modereg;
168 public $option_condreg;
172 public $option_escompte;
176 public $option_credit_note;
203 public $tabTitleHeight;
208 public $defaultTitlesFieldsStyle;
213 public $defaultContentsFieldsStyle;
224 public $phpmin = array(7, 1);
234 public $afterColsLinePositions;
288 public $posxdiscount;
292 public $posxworkload;
296 public $posxtimespent;
300 public $posxprogress;
304 public $atleastonephoto;
308 public $atleastoneratenotnull;
312 public $atleastonediscount;
336 global
$conf, $extrafields;
341 'myuser_lastname' => (
string) $user->lastname,
342 'myuser_firstname' => (
string) $user->firstname,
343 'myuser_fullname' => $user->getFullName($outputlangs, 1),
344 'myuser_login' => (
string) $user->login,
345 'myuser_phone' => (
string) $user->office_phone,
346 'myuser_address' => (
string) $user->address,
347 'myuser_zip' => (
string) $user->zip,
348 'myuser_town' => (
string) $user->town,
349 'myuser_country' => (
string) $user->country,
350 'myuser_country_code' => (
string) $user->country_code,
351 'myuser_state' => (
string) $user->state,
352 'myuser_state_code' => (
string) $user->state_code,
353 'myuser_fax' => (
string) $user->office_fax,
354 'myuser_mobile' => (
string) $user->user_mobile,
355 'myuser_email' => (
string) $user->email,
356 'myuser_logo' => (
string) $logotouse,
357 'myuser_job' => (
string) $user->job,
360 'myuser_dateemployment' =>
dol_print_date($user->dateemployment,
'day',
'tzuser'),
361 'myuser_dateemploymentend' =>
dol_print_date($user->dateemploymentend,
'day',
'tzuser'),
362 'myuser_gender' => (
string) $user->gender,
365 if (is_array($user->array_options) && count($user->array_options)) {
366 if (empty($extrafields->attributes[$user->table_element])) {
367 $extrafields->fetch_name_optionals_label($user->table_element);
384 global
$conf, $extrafields;
386 if ($member->photo) {
387 $logotouse =
$conf->member->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $member,
'user').
'/photos/'.$member->photo;
389 $logotouse = DOL_DOCUMENT_ROOT.
'/public/theme/common/nophoto.png';
392 $array_member = array(
393 'mymember_lastname' => (
string) $member->lastname,
394 'mymember_firstname' => (
string) $member->firstname,
395 'mymember_fullname' => $member->getFullName($outputlangs, 1),
396 'mymember_login' => (
string) $member->login,
397 'mymember_address' => (
string) $member->address,
398 'mymember_zip' => (
string) $member->zip,
399 'mymember_town' => (
string) $member->town,
400 'mymember_country_code' => (
string) $member->country_code,
401 'mymember_country' => (
string) $member->country,
402 'mymember_state_code' => (
string) $member->state_code,
403 'mymember_state' => (
string) $member->state,
404 'mymember_phone_perso' => (
string) $member->phone_perso,
405 'mymember_phone_pro' => (
string) $member->phone,
406 'mymember_phone_mobile' => (
string) $member->phone_mobile,
407 'mymember_email' => (
string) $member->email,
408 'mymember_logo' => $logotouse,
409 'mymember_gender' => (
string) $member->gender,
410 'mymember_birth_locale' =>
dol_print_date($member->birth,
'day',
'tzuser', $outputlangs),
411 'mymember_birth' =>
dol_print_date($member->birth,
'day',
'tzuser'),
414 if (is_array($member->array_options) && count($member->array_options)) {
417 return $array_member;
434 if (empty(
$mysoc->forme_juridique) && !empty(
$mysoc->forme_juridique_code)) {
437 if (empty(
$mysoc->country) && !empty(
$mysoc->country_code)) {
438 $mysoc->country = $outputlangs->transnoentitiesnoconv(
"Country".
$mysoc->country_code);
440 if (empty(
$mysoc->state) && !empty(
$mysoc->state_code)) {
445 $logotouse =
$conf->mycompany->dir_output.
'/logos/thumbs/'.
$mysoc->logo_small;
448 'mycompany_logo' => $logotouse,
449 'mycompany_name' =>
$mysoc->name,
450 'mycompany_email' =>
$mysoc->email,
451 'mycompany_phone' =>
$mysoc->phone,
452 'mycompany_fax' =>
$mysoc->fax,
453 'mycompany_address' =>
$mysoc->address,
454 'mycompany_zip' =>
$mysoc->zip,
455 'mycompany_town' =>
$mysoc->town,
456 'mycompany_country' =>
$mysoc->country,
457 'mycompany_country_code' =>
$mysoc->country_code,
458 'mycompany_state' =>
$mysoc->state,
459 'mycompany_state_code' =>
$mysoc->state_code,
460 'mycompany_web' =>
$mysoc->url,
461 'mycompany_juridicalstatus' =>
$mysoc->forme_juridique,
462 'mycompany_managers' =>
$mysoc->managers,
463 'mycompany_capital' =>
$mysoc->capital,
464 'mycompany_barcode' =>
$mysoc->barcode,
465 'mycompany_idprof1' =>
$mysoc->idprof1,
466 'mycompany_idprof2' =>
$mysoc->idprof2,
467 'mycompany_idprof3' =>
$mysoc->idprof3,
468 'mycompany_idprof4' =>
$mysoc->idprof4,
469 'mycompany_idprof5' =>
$mysoc->idprof5,
470 'mycompany_idprof6' =>
$mysoc->idprof6,
471 'mycompany_vatnumber' =>
$mysoc->tva_intra,
472 'mycompany_socialobject' =>
$mysoc->socialobject,
473 'mycompany_note_private' =>
$mysoc->note_private,
499 $object->country = $outputlangs->transnoentitiesnoconv(
"Country".
$object->country_code);
506 $array_thirdparty = array(
507 'company_name' => (
string)
$object->name,
508 'company_name_alias' => (
string)
$object->name_alias,
509 'company_email' => (
string)
$object->email,
510 'company_phone' => (
string)
$object->phone,
511 'company_fax' => (
string)
$object->fax,
512 'company_address' => (
string)
$object->address,
513 'company_zip' => (
string)
$object->zip,
514 'company_town' => (
string)
$object->town,
515 'company_country' => (
string)
$object->country,
516 'company_country_code' => (
string)
$object->country_code,
517 'company_state' => (
string)
$object->state,
518 'company_state_code' => (
string)
$object->state_code,
519 'company_web' => (
string)
$object->url,
520 'company_barcode' => (
string)
$object->barcode,
521 'company_vatnumber' => (
string)
$object->tva_intra,
522 'company_customercode' => (
string)
$object->code_client,
523 'company_suppliercode' => (
string)
$object->code_fournisseur,
524 'company_customeraccountancycode' => (
string)
$object->code_compta_client,
525 'company_supplieraccountancycode' => (
string)
$object->code_compta_fournisseur,
526 'company_juridicalstatus' => (
string)
$object->forme_juridique,
527 'company_outstanding_limit' => (
string)
$object->outstanding_limit,
528 'company_capital' => (
string)
$object->capital,
529 'company_capital_formated' =>
price(
$object->capital, 0,
'', 1, -1),
530 'company_idprof1' => (
string)
$object->idprof1,
531 'company_idprof2' => (
string)
$object->idprof2,
532 'company_idprof3' => (
string)
$object->idprof3,
533 'company_idprof4' => (
string)
$object->idprof4,
534 'company_idprof5' => (
string)
$object->idprof5,
535 'company_idprof6' => (
string)
$object->idprof6,
536 'company_note_public' => (
string)
$object->note_public,
537 'company_note_private' => (
string)
$object->note_private,
538 'company_default_bank_iban' => (is_object(
$object->bank_account) ? (
string)
$object->bank_account->iban :
''),
539 'company_default_bank_bic' => (is_object(
$object->bank_account) ? (string)
$object->bank_account->bic :
'')
543 if (is_array(
$object->array_options) && count(
$object->array_options)) {
548 return $array_thirdparty;
566 $object->country = $outputlangs->transnoentitiesnoconv(
"Country".
$object->country_code);
573 $array_contact = array(
574 $array_key.
'_fullname' =>
$object->getFullName($outputlangs, 1),
575 $array_key.
'_lastname' =>
$object->lastname,
576 $array_key.
'_firstname' =>
$object->firstname,
577 $array_key.
'_address' =>
$object->address,
578 $array_key.
'_zip' =>
$object->zip,
579 $array_key.
'_town' =>
$object->town,
580 $array_key.
'_state_id' =>
$object->state_id,
581 $array_key.
'_state_code' =>
$object->state_code,
582 $array_key.
'_state' =>
$object->state,
583 $array_key.
'_country_id' =>
$object->country_id,
584 $array_key.
'_country_code' =>
$object->country_code,
585 $array_key.
'_country' =>
$object->country,
586 $array_key.
'_poste' =>
$object->poste,
587 $array_key.
'_socid' =>
$object->socid,
589 $array_key.
'_code' =>
$object->code,
590 $array_key.
'_email' =>
$object->email,
591 $array_key.
'_phone_pro' =>
$object->phone_pro,
592 $array_key.
'_phone_perso' =>
$object->phone_perso,
593 $array_key.
'_phone_mobile' =>
$object->phone_mobile,
594 $array_key.
'_fax' =>
$object->fax,
596 $array_key.
'_birthday' =>
$object->birthday,
597 $array_key.
'_default_lang' =>
$object->default_lang,
598 $array_key.
'_note_public' =>
$object->note_public,
599 $array_key.
'_note_private' =>
$object->note_private,
600 $array_key.
'_civility' =>
$object->civility,
604 if (is_array(
$object->array_options) && count(
$object->array_options)) {
609 return $array_contact;
626 $array_other = array(
631 'current_server_datehour' =>
dol_print_date($now,
'dayhour',
'tzserver'),
633 'current_date_locale' =>
dol_print_date($now,
'day',
'tzuser', $outputlangs),
634 'current_datehour_locale' =>
dol_print_date($now,
'dayhour',
'tzuser', $outputlangs),
635 'current_server_date_locale' =>
dol_print_date($now,
'day',
'tzserver', $outputlangs),
636 'current_server_datehour_locale' =>
dol_print_date($now,
'dayhour',
'tzserver', $outputlangs),
640 foreach (
$conf->global as $key => $val) {
642 $newval =
'*****forbidden*****';
646 $array_other[
'__['.$key.
']__'] = $newval;
663 public function get_substitutionarray_object(
$object, $outputlangs, $array_key =
'object')
668 $totalpaid = $totaldeposits = $totalcreditnotes =
'';
669 $already_payed_all = 0;
671 if (
$object->element ==
'facture') {
673 '@phan-var-force Facture $object';
674 $invoice_source =
new Facture($this->db);
675 if (
$object->fk_facture_source > 0) {
676 $invoice_source->fetch(
$object->fk_facture_source);
678 $totalpaid =
$object->getSommePaiement();
679 $totaldeposits =
$object->getSumDepositsUsed();
680 $totalcreditnotes =
$object->getSumCreditNotesUsed();
681 $already_payed_all = $totalpaid + $totaldeposits + $totalcreditnotes;
692 $array_key.
'_id' =>
$object->id,
693 $array_key.
'_ref' => (property_exists(
$object,
'ref') ?
$object->ref :
''),
694 $array_key.
'_label' => (property_exists(
$object,
'label') ?
$object->label :
''),
695 $array_key.
'_ref_ext' => (property_exists(
$object,
'ref_ext') ?
$object->ref_ext :
''),
696 $array_key.
'_ref_customer' => (!empty(
$object->ref_client) ?
$object->ref_client : (empty(
$object->ref_customer) ?
'' :
$object->ref_customer)),
697 $array_key.
'_ref_supplier' => (!empty(
$object->ref_fournisseur) ?
$object->ref_fournisseur : (empty(
$object->ref_supplier) ?
'' :
$object->ref_supplier)),
698 $array_key.
'_source_invoice_ref' => ((empty($invoice_source) || empty($invoice_source->
ref)) ?
'' : $invoice_source->
ref),
713 $array_key.
'_payment_mode_code' =>
$object->mode_reglement_code,
714 $array_key.
'_payment_mode' => ($outputlangs->transnoentitiesnoconv(
'PaymentType'.
$object->mode_reglement_code) !=
'PaymentType'.
$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv(
'PaymentType'.
$object->mode_reglement_code) :
$object->mode_reglement),
715 $array_key.
'_payment_term_code' =>
$object->cond_reglement_code,
716 $array_key.
'_payment_term' => ($outputlangs->transnoentitiesnoconv(
'PaymentCondition'.
$object->cond_reglement_code) !=
'PaymentCondition'.
$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv(
'PaymentCondition'.
$object->cond_reglement_code) :
$object->cond_reglement_doc),
720 $array_key.
'_total_ht_locale' =>
price(
$object->total_ht, 0, $outputlangs),
721 $array_key.
'_total_vat_locale' => (!empty(
$object->total_vat) ?
price(
$object->total_vat, 0, $outputlangs) :
price(
$object->total_tva, 0, $outputlangs)),
722 $array_key.
'_total_localtax1_locale' =>
price(
$object->total_localtax1, 0, $outputlangs),
723 $array_key.
'_total_localtax2_locale' =>
price(
$object->total_localtax2, 0, $outputlangs),
724 $array_key.
'_total_ttc_locale' =>
price(
$object->total_ttc, 0, $outputlangs),
732 $array_key.
'_multicurrency_code' =>
$object->multicurrency_code,
734 $array_key.
'_multicurrency_total_ht' =>
price2num(
$object->multicurrency_total_ht),
735 $array_key.
'_multicurrency_total_tva' =>
price2num(
$object->multicurrency_total_tva),
736 $array_key.
'_multicurrency_total_ttc' =>
price2num(
$object->multicurrency_total_ttc),
737 $array_key.
'_multicurrency_total_ht_locale' =>
price(
$object->multicurrency_total_ht, 0, $outputlangs),
738 $array_key.
'_multicurrency_total_tva_locale' =>
price(
$object->multicurrency_total_tva, 0, $outputlangs),
739 $array_key.
'_multicurrency_total_ttc_locale' =>
price(
$object->multicurrency_total_ttc, 0, $outputlangs),
741 $array_key.
'_note_private' =>
$object->note_private,
742 $array_key.
'_note_public' =>
$object->note_public,
743 $array_key.
'_note' =>
$object->note_public,
746 $array_key.
'_already_payed_locale' =>
price($totalpaid, 0, $outputlangs),
747 $array_key.
'_already_payed' =>
price2num($totalpaid),
748 $array_key.
'_already_deposit_locale' =>
price($totaldeposits, 0, $outputlangs),
749 $array_key.
'_already_deposit' =>
price2num($totaldeposits),
750 $array_key.
'_already_creditnote_locale' =>
price($totalcreditnotes, 0, $outputlangs),
751 $array_key.
'_already_creditnote' =>
price2num($totalcreditnotes),
753 $array_key.
'_already_payed_all_locale' =>
price(
price2num($already_payed_all,
'MT'), 0, $outputlangs),
754 $array_key.
'_already_payed_all' =>
price2num($already_payed_all,
'MT'),
757 $array_key.
'_remain_to_pay_locale' =>
price(
price2num(
$object->total_ttc - $already_payed_all,
'MT'), 0, $outputlangs),
758 $array_key.
'_remain_to_pay' =>
price2num(
$object->total_ttc - $already_payed_all,
'MT')
761 if (in_array(
$object->element, array(
'facture',
'invoice',
'supplier_invoice',
'facture_fournisseur',
'commande'))) {
762 $bank_account =
null;
764 if (property_exists(
$object,
'fk_account') &&
$object->fk_account > 0) {
765 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
766 $bank_account =
new Account($this->db);
767 $bank_account->fetch((
int)
$object->fk_account);
770 $resarray[$array_key.
'_bank_iban'] = (empty($bank_account) ?
'' : $bank_account->iban);
771 $resarray[$array_key.
'_bank_bic'] = (empty($bank_account) ?
'' : $bank_account->bic);
772 $resarray[$array_key.
'_bank_label'] = (empty($bank_account) ?
'' : $bank_account->label);
773 $resarray[$array_key.
'_bank_number'] = (empty($bank_account) ?
'' : $bank_account->number);
774 $resarray[$array_key.
'_bank_proprio'] = (empty($bank_account) ?
'' : $bank_account->owner_name);
775 $resarray[$array_key.
'_bank_address'] = (empty($bank_account) ?
'' : $bank_account->address);
776 $resarray[$array_key.
'_bank_state'] = (empty($bank_account) ?
'' : $bank_account->state);
777 $resarray[$array_key.
'_bank_country'] = (empty($bank_account) ?
'' : $bank_account->country);
780 if (method_exists(
$object,
'getTotalDiscount') && in_array(get_class(
$object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
781 $resarray[$array_key.
'_total_discount_ht_locale'] =
price(
$object->getTotalDiscount(), 0, $outputlangs);
782 $resarray[$array_key.
'_total_discount_ht'] =
price2num(
$object->getTotalDiscount());
784 $resarray[$array_key.
'_total_discount_ht_locale'] =
'';
785 $resarray[$array_key.
'_total_discount_ht'] =
'';
788 if (
$object->element ==
'facture' ||
$object->element ==
'invoice_supplier') {
790 $resarray[$array_key.
'_type_label'] = $outputlangs->transnoentities(
"PdfInvoiceTitle");
792 $resarray[$array_key.
'_type_label'] = (empty(
$object)) ?
'' :
$object->getLibType(0);
798 if (!is_object(
$object->project)) {
802 $resarray[$array_key.
'_project_ref'] =
$object->project->ref;
803 $resarray[$array_key.
'_project_title'] =
$object->project->title;
804 $resarray[$array_key.
'_project_description'] =
$object->project->description;
808 $resarray[$array_key.
'_project_ref'] =
'';
809 $resarray[$array_key.
'_project_title'] =
'';
810 $resarray[$array_key.
'_project_description'] =
'';
811 $resarray[$array_key.
'_project_date_start'] =
'';
812 $resarray[$array_key.
'_project_date_end'] =
'';
819 foreach (
$object->lines as $line) {
821 if (empty($resarray[$array_key.
'_total_vat_'.$line->tva_tx])) {
822 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
824 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
825 $resarray[$array_key.
'_total_vat_locale_'.$line->tva_tx] =
price($resarray[$array_key.
'_total_vat_'.$line->tva_tx]);
827 $vatformated =
vatrate($line->tva_tx);
828 if (empty($resarray[$array_key.
'_total_vat_'.$vatformated])) {
829 $resarray[$array_key.
'_total_vat_'.$vatformated] = 0;
831 $resarray[$array_key.
'_total_vat_'.$vatformated] += $line->total_tva;
832 $resarray[$array_key.
'_total_vat_locale_'.$vatformated] =
price($resarray[$array_key.
'_total_vat_'.$vatformated]);
834 $totalUp += $line->subprice * $line->qty;
839 $resarray[
'object_total_up'] = $totalUp;
840 $resarray[
'object_total_up_locale'] =
price($resarray[
'object_total_up'], 0, $outputlangs);
841 if (method_exists(
$object,
'getTotalDiscount') && in_array(get_class(
$object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
842 $totalDiscount =
$object->getTotalDiscount();
846 if (!empty($totalUp) && !empty($totalDiscount)) {
847 $resarray[
'object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2);
848 $resarray[
'object_total_discount_locale'] =
price($resarray[
'object_total_discount'], 0, $outputlangs);
850 $resarray[
'object_total_discount'] =
'';
851 $resarray[
'object_total_discount_locale'] =
'';
856 if (is_array(
$object->array_options) && count(
$object->array_options)) {
879 'line_pos' => $linenumber,
882 'line_product_ref' => (empty($line->product_ref) ?
'' : $line->product_ref),
883 'line_product_label' => (empty($line->product_label) ?
'' : $line->product_label),
884 'line_product_type' => (empty($line->product_type) ?
'' : $line->product_type),
885 'line_product_barcode' => (empty($line->product_barcode) ?
'' : $line->product_barcode),
886 'line_product_desc' => (empty($line->product_desc) ?
'' : $line->product_desc),
888 'line_desc' => $line->desc,
889 'line_vatrate' =>
vatrate($line->tva_tx,
true, (
int) $line->info_bits),
891 'line_up_locale' =>
price($line->subprice, 0, $outputlangs),
892 'line_total_up' =>
price2num($line->subprice * (
float) $line->qty),
893 'line_total_up_locale' =>
price($line->subprice * (
float) $line->qty, 0, $outputlangs),
895 'line_qty' => (empty($line->special_code) || $line->special_code != 3) ? $line->qty :
'',
896 'line_qty_locale' => (empty($line->special_code) || $line->special_code != 3) ?
price($line->qty) :
'',
897 'line_discount_percent' => ($line->remise_percent ? $line->remise_percent.
'%' :
''),
898 'line_price_ht' =>
price2num($line->total_ht),
899 'line_price_ttc' =>
price2num($line->total_ttc),
900 'line_price_vat' =>
price2num($line->total_tva),
901 'line_price_ht_locale' =>
price($line->total_ht, 0, $outputlangs),
902 'line_price_ttc_locale' =>
price($line->total_ttc, 0, $outputlangs),
903 'line_price_vat_locale' =>
price($line->total_tva, 0, $outputlangs),
905 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
906 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
907 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
908 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
909 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
910 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
911 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
912 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
913 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
916 if (property_exists($line,
'ref_fourn')) {
917 $resarray[
'line_product_ref_fourn'] = $line->ref_fourn;
919 $resarray[
'line_product_ref_fourn'] =
'';
922 'line_localtax1_rate' =>
'localtax1_tx',
923 'line_localtax2_rate' =>
'localtax2_tx',
925 foreach ($vat_specs as $vat_key => $vat_spec) {
926 if (property_exists($line, $vat_spec)) {
928 $resarray[$vat_key] =
vatrate($line->$vat_spec);
934 array(
'line_date_start',
'date_start',
'day',
'auto',
null),
935 array(
'line_date_start_locale',
'date_start',
'day',
'tzserver', $outputlangs),
936 array(
'line_date_start_rfc',
'date_start',
'dayrfc',
'auto',
null),
937 array(
'line_date_start_real',
'date_start_real',
'day',
'auto',
null),
938 array(
'line_date_start_real_locale',
'date_start_real',
'day',
'tzserver', $outputlangs),
939 array(
'line_date_start_real_rfc',
'date_start_real',
'dayrfc',
'auto',
null),
940 array(
'line_date_end',
'date_end',
'day',
'auto',
null),
941 array(
'line_date_end_locale',
'date_end',
'day',
'tzserver', $outputlangs),
942 array(
'line_date_end_rfc',
'date_end',
'dayrfc',
'auto',
null)
944 foreach ($date_specs as $date_spec) {
945 $propertyname = $date_spec[1];
946 if (property_exists($line, $propertyname)) {
948 $resarray[$date_spec[0]] =
dol_print_date($line->$propertyname, $date_spec[2], $date_spec[3], $date_spec[4]);
954 $resarray[
'line_unit'] = $line->getLabelOfUnit(
'long', $outputlangs);
955 $resarray[
'line_unit_short'] = $line->getLabelOfUnit(
'short', $outputlangs);
960 $extrafieldkey = $line->table_element;
962 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
964 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
965 $line->fetch_optionals();
970 if (get_class($line) ==
'CommandeFournisseurLigne') {
972 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
973 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
975 if (!empty($extralabels) && is_array($extralabels)) {
978 foreach ($extralabels as $key => $label) {
979 $columns .=
"$key, ";
982 if ($columns !=
"") {
983 $columns = substr($columns, 0, strlen($columns) - 2);
984 $resql = $this->db->query(
"SELECT ".$columns.
" FROM ".$this->db->prefix().
"product_fournisseur_price_extrafields AS ex INNER JOIN ".$this->db->prefix().
"product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$this->db->escape($line->ref_supplier).
"'");
986 if ($this->db->num_rows($resql) > 0) {
987 $resql = $this->db->fetch_object($resql);
989 foreach ($extralabels as $key => $label) {
990 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
998 if (get_class($line) ==
'ExpeditionLigne') {
999 $resarray[
'line_qty_shipped'] = $line->qty_shipped;
1000 $resarray[
'line_qty_asked'] = $line->qty_asked;
1001 $resarray[
'line_weight'] = empty($line->weight) ?
'' : $line->weight * $line->qty_shipped.
' '.
measuringUnitString(0,
'weight', $line->weight_units);
1002 $resarray[
'line_length'] = empty($line->length) ?
'' : $line->length * $line->qty_shipped.
' '.
measuringUnitString(0,
'size', $line->length_units);
1003 $resarray[
'line_surface'] = empty($line->surface) ?
'' : $line->surface * $line->qty_shipped.
' '.
measuringUnitString(0,
'surface', $line->surface_units);
1004 $resarray[
'line_volume'] = empty($line->volume) ?
'' : $line->volume * $line->qty_shipped.
' '.
measuringUnitString(0,
'volume', $line->volume_units);
1008 if (isset($line->fk_product) && $line->fk_product > 0) {
1009 $tmpproduct =
new Product($this->db);
1010 $result = $tmpproduct->fetch($line->fk_product);
1011 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
1012 foreach ($tmpproduct->array_options as $key => $label) {
1013 $resarray[
"line_product_".$key] = $label;
1018 $extrafields->fetch_name_optionals_label(
"product");
1019 if ($extrafields->attributes[
"product"][
'count'] > 0) {
1020 $extralabels = $extrafields->attributes[
"product"][
'label'];
1022 foreach ($extralabels as $key => $label) {
1023 $resarray[
'line_product_options_'.$key] =
'';
1044 global $extrafields;
1046 include_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
1048 $object->list_delivery_methods((
int)
$object->shipping_method_id);
1050 $calculatedVolume = ((float)
$object->trueWidth * (
float)
$object->trueHeight * (float)
$object->trueDepth);
1052 $array_shipment = array(
1053 $array_key.
'_id' =>
$object->id,
1054 $array_key.
'_ref' =>
$object->ref,
1055 $array_key.
'_ref_ext' =>
$object->ref_ext,
1056 $array_key.
'_ref_customer' =>
$object->ref_customer,
1063 $array_key.
'_total_discount_ht' =>
price(
$object->getTotalDiscount()),
1064 $array_key.
'_note_private' =>
$object->note_private,
1065 $array_key.
'_note' =>
$object->note_public,
1066 $array_key.
'_tracking_number' =>
$object->tracking_number,
1067 $array_key.
'_tracking_url' =>
$object->tracking_url,
1068 $array_key.
'_shipping_method' =>
$object->listmeths[0][
'libelle'],
1077 foreach (
$object->lines as $line) {
1078 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
1079 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
1081 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
1085 if (is_array(
$object->array_options) && count(
$object->array_options)) {
1092 if (
$object->origin_type ==
'commande' && is_object(
$object->origin_object) && !empty(
$object->origin_object->ref)) {
1093 $originOrder =
$object->origin_object;
1094 '@phan-var-force Commande $originOrder';
1095 $array_shipment[
'order_ref'] = $originOrder->ref;
1096 $array_shipment[
'order_ref_customer'] = $originOrder->ref_customer;
1100 $tmparray =
$object->getTotalWeightVolume();
1101 $totalWeight = $tmparray[
'weight'];
1102 $totalVolume = $tmparray[
'volume'];
1103 $totalOrdered = $tmparray[
'ordered'];
1104 $totalToShip = $tmparray[
'toship'];
1112 $array_shipment[$array_key.
'_total_ordered'] = (string) $totalOrdered;
1113 $array_shipment[$array_key.
'_total_toship'] = (string) $totalToShip;
1117 } elseif (!empty($totalWeight)) {
1118 $array_shipment[$array_key.
'_total_weight'] =
showDimensionInBestUnit($totalWeight, 0,
"weight", $outputlangs, -1,
'no', 1);
1120 $array_shipment[$array_key.
'_total_weight'] =
"";
1123 if (!empty(
$object->trueVolume)) {
1124 if (
$object->volume_units < 50) {
1127 $array_shipment[$array_key.
'_total_volume'] = (empty($totalVolume)) ?
'' :
price(
$object->trueVolume, 0, $outputlangs, 0, 0).
' '.
measuringUnitString(0,
"volume",
$object->volume_units);
1129 } elseif (!empty($totalVolume)) {
1130 $array_shipment[$array_key.
'_total_volume'] =
showDimensionInBestUnit($totalVolume, 0,
"volume", $outputlangs, -1,
'no', 1);
1132 $array_shipment[$array_key.
'_total_volume'] =
"";
1135 return $array_shipment;
1153 $array_other = array();
1157 foreach (
$object as $key => $value) {
1158 if (in_array($key, array(
'db',
'fields',
'lines',
'modelpdf',
'model_pdf'))) {
1161 if (!empty($value)) {
1162 if (!is_array($value) && !is_object($value)) {
1163 $array_other[
'object_'.$key] = $value;
1164 } elseif (is_array($value) && $recursive) {
1166 if (!empty($tmparray) && is_array($tmparray)) {
1167 foreach ($tmparray as $key2 => $value2) {
1168 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1171 } elseif (is_object($value) && $recursive) {
1173 if (!empty($tmparray) && is_array($tmparray)) {
1174 foreach ($tmparray as $key2 => $value2) {
1175 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1183 return $array_other;
1204 if ($extrafields->attributes[
$object->table_element][
'count'] > 0) {
1205 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1206 $formatedarrayoption =
$object->array_options;
1208 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
1209 $formatedarrayoption[
'options_'.$key] =
price2num($formatedarrayoption[
'options_'.$key]);
1210 $formatedarrayoption[
'options_'.$key.
'_currency'] =
price($formatedarrayoption[
'options_'.$key], 0, $outputlangs, 0, 0, -1,
$conf->currency);
1212 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_currency' => $formatedarrayoption[
'options_'.$key.
'_currency']));
1213 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'select') {
1214 $valueofselectkey = $formatedarrayoption[
'options_'.$key];
1215 if (array_key_exists($valueofselectkey, $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'])) {
1216 $formatedarrayoption[
'options_'.$key] = $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'][$valueofselectkey];
1218 $formatedarrayoption[
'options_'.$key] =
'';
1220 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'checkbox') {
1221 $valArray = explode(
',', $formatedarrayoption[
'options_'.$key]);
1223 foreach ($extrafields->attributes[
$object->table_element][
'param'][$key][
'options'] as $keyopt => $valopt) {
1224 if (in_array($keyopt, $valArray)) {
1225 $output[] = $valopt;
1228 $formatedarrayoption[
'options_'.$key] = implode(
', ', $output);
1229 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
1230 if (strlen($formatedarrayoption[
'options_'.$key]) > 0) {
1231 $date = $formatedarrayoption[
'options_'.$key];
1232 $formatedarrayoption[
'options_'.$key] =
dol_print_date($date,
'day');
1233 $formatedarrayoption[
'options_'.$key.
'_locale'] =
dol_print_date($date,
'day',
'tzserver', $outputlangs);
1234 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
dol_print_date($date,
'dayrfc');
1236 $formatedarrayoption[
'options_'.$key] =
'';
1237 $formatedarrayoption[
'options_'.$key.
'_locale'] =
'';
1238 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
'';
1240 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1241 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1242 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
1243 $datetime = $formatedarrayoption[
'options_'.$key];
1244 $formatedarrayoption[
'options_'.$key] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
1245 $formatedarrayoption[
'options_'.$key.
'_locale'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
1246 $formatedarrayoption[
'options_'.$key.
'_rfc'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
1247 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1248 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1249 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'link') {
1250 $id = $formatedarrayoption[
'options_'.$key];
1252 $param = $extrafields->attributes[
$object->table_element][
'param'][$key];
1253 $param_list = array_keys($param[
'options']);
1254 $InfoFieldList = explode(
":", $param_list[0]);
1255 $classname = $InfoFieldList[0];
1256 $classpath = $InfoFieldList[1];
1257 if (!empty($classpath)) {
1259 if ($classname && class_exists($classname)) {
1260 $tmpobject =
new $classname($this->db);
1261 '@phan-var-force CommonObject $tmpobject';
1262 $tmpobject->fetch(
$id);
1264 $formatedarrayoption[
'options_'.$key] = $tmpobject->name;
1270 if (array_key_exists(
'options_'.$key, $formatedarrayoption)) {
1271 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key => $formatedarrayoption[
'options_'.$key]));
1273 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key =>
''));
1278 return $array_to_fill;
1294 public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1296 if (empty($hidetop) || $hidetop == -1) {
1297 $pdf->line($x, $y, $x + $l, $y);
1299 $pdf->line($x + $l, $y, $x + $l, $y + $h);
1300 if (empty($hidebottom)) {
1301 $pdf->line($x + $l, $y + $h, $x, $y + $h);
1303 $pdf->line($x, $y + $h, $x, $y);
1320 public function printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebottom = 0, $style =
'D')
1323 if (empty($hidetop) || $hidetop == -1) {
1324 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1111', $style);
1327 $pdf->RoundedRect($x, $y, $w, $h, $r,
'0111', $style);
1329 if (!empty($hidebottom)) {
1330 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1101', $style);
1340 if (empty($this->afterColsLinePositions) || !is_array($this->afterColsLinePositions)) {
1345 $maxPage = $maxY = 0;
1346 foreach ($this->afterColsLinePositions as $colKey => $value) {
1347 if ($value[
'page'] > $maxPage) {
1349 $maxPage = $value[
'page'];
1350 $maxY = $value[
'y'];
1351 } elseif ($value[
'page'] == $maxPage) {
1352 $maxY = max($value[
'y'], $maxY);
1372 $this->afterColsLinePositions = [];
1385 $this->afterColsLinePositions[$colId] = [
1386 'page' => $pageNumb,
1401 if (empty($a[
'rank'])) {
1404 if (empty($b[
'rank'])) {
1407 if ($a[
'rank'] == $b[
'rank']) {
1410 return ($a[
'rank'] > $b[
'rank']) ? -1 : 1;
1429 uasort($this->cols, array($this,
'columnSort'));
1432 $curX = $this->page_largeur - $this->marge_droite;
1435 $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche;
1438 $totalDefinedColWidth = 0;
1440 foreach ($this->cols as $colKey => & $colDef) {
1445 if (!empty($colDef[
'scale'])) {
1447 $colDef[
'width'] = abs($arrayWidth * $colDef[
'scale'] / 100);
1450 if (empty($colDef[
'width'])) {
1453 $totalDefinedColWidth += $colDef[
'width'];
1457 foreach ($this->cols as $colKey => & $colDef) {
1459 if (!empty($colDef[
'title'])) {
1460 $colDef[
'title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef[
'title']);
1462 $colDef[
'title'] = $this->defaultTitlesFieldsStyle;
1466 if (!empty($colDef[
'content'])) {
1467 $colDef[
'content'] = array_replace($this->defaultContentsFieldsStyle, $colDef[
'content']);
1469 $colDef[
'content'] = $this->defaultContentsFieldsStyle;
1474 if (empty($colDef[
'width'])) {
1475 $colDef[
'width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
1480 $curX = $lastX - $colDef[
'width'];
1481 $colDef[
'xStartPos'] = $curX;
1482 $colDef[
'xEndPos'] = $lastX;
1495 $colDef = $this->cols[$colKey];
1496 return $colDef[
'width'] - $colDef[
'content'][
'padding'][3] - $colDef[
'content'][
'padding'][1];
1508 $colDef = (isset($this->cols[$colKey]) ? $this->cols[$colKey] :
null);
1509 return (is_array($colDef) ? ((isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0) + $colDef[
'content'][
'padding'][3]) : 0);
1520 if (!isset($this->cols[$colKey][
'rank'])) {
1523 return $this->cols[$colKey][
'rank'];
1541 if (!empty($targetCol)) {
1543 if ($rank >= 0 && $insertAfterTarget) {
1549 if ($rank < 0 && !empty($defArray[
'rank'])) {
1550 $rank = $defArray[
'rank'];
1558 foreach ($this->cols as $colKey => & $colDef) {
1559 if ($rank <= $colDef[
'rank']) {
1560 $colDef[
'rank'] += 1;
1564 $defArray[
'rank'] = $rank;
1565 $this->cols[$newColKey] = $defArray;
1582 global $hookmanager;
1584 $parameters = array(
1586 'columnText' => &$columnText,
1587 'colKey' => $colKey,
1590 $reshook = $hookmanager->executeHooks(
'printStdColumnContent', $parameters, $this);
1591 if ($reshook > 0 && isset($hookmanager->resArray[
'columnText'])) {
1592 $columnText = $hookmanager->resArray[
'columnText'];
1595 $this->error = $hookmanager->error;
1596 $this->errors = $hookmanager->errors;
1597 dol_syslog(__METHOD__.
' '.$this->error, LOG_ERR);
1599 if (!$reshook || $reshook > 0) {
1600 if (empty($columnText)) {
1604 $colDef = $this->cols[$colKey];
1606 $curentCellPaddinds = $pdf->getCellPaddings();
1608 $pdf->setCellPaddings(isset($colDef[
'content'][
'padding'][3]) ? $colDef[
'content'][
'padding'][3] : 0, isset($colDef[
'content'][
'padding'][0]) ? $colDef[
'content'][
'padding'][0] : 0, isset($colDef[
'content'][
'padding'][1]) ? $colDef[
'content'][
'padding'][1] : 0, isset($colDef[
'content'][
'padding'][2]) ? $colDef[
'content'][
'padding'][2] : 0);
1609 $pdf->writeHTMLCell($colDef[
'width'], 2, isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0, $curY, $columnText, 0, 1,
false,
true, $colDef[
'content'][
'align']);
1613 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1636 global $hookmanager;
1639 $colDef = $this->cols[$colKey];
1641 $curentCellPaddinds = $pdf->getCellPaddings();
1643 $pdf->setCellPaddings($colDef[
'content'][
'padding'][3], $colDef[
'content'][
'padding'][0], $colDef[
'content'][
'padding'][1], $colDef[
'content'][
'padding'][2]);
1646 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $colDef[
'width'], 3, $colDef[
'xStartPos'], $curY, $hideref, $hidedesc, $issupplierline, empty($colDef[
'content'][
'align']) ?
'J' : $colDef[
'content'][
'align']);
1647 $posYAfterDescription = $pdf->GetY() - $colDef[
'content'][
'padding'][0];
1650 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1654 'display' =>
'list',
1655 'printableEnable' => array(3),
1656 'printableEnableNotEmpty' => array(4)
1658 $extrafieldDesc = $this->getExtrafieldsInHtml(
$object->lines[$i], $outputlangs, $params);
1659 if (!empty($extrafieldDesc)) {
1663 $parameters = array(
1665 'colKey' => $colKey,
1668 'outputlangs' => $outputlangs,
1671 $reshook = $hookmanager->executeHooks(
'printColDescContent', $parameters, $this);
1673 $this->error = $hookmanager->error;
1674 $this->errors = $hookmanager->errors;
1675 dol_syslog(__METHOD__.
' '.$this->error, LOG_ERR);
1690 global $hookmanager;
1692 if (empty(
$object->table_element)) {
1696 $extrafieldsKeyPrefix =
"options_";
1699 $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
1701 $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
1704 $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
1708 if (is_null($this->extrafieldsCache)) {
1709 $this->extrafieldsCache =
new ExtraFields($this->db);
1711 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1712 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1714 $extrafields = $this->extrafieldsCache;
1716 $extrafieldOutputContent =
'';
1717 if (isset(
$object->array_options[$extrafieldOptionsKey])) {
1718 $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey,
$object->array_options[$extrafieldOptionsKey],
'',
$object->table_element, $outputlangs);
1722 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'link') {
1728 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'stars') {
1729 $extrafieldOutputContent =
'';
1730 for ($i = 0; $i <
$object->array_options[$extrafieldOptionsKey]; $i++) {
1731 $extrafieldOutputContent .=
' *';
1735 $parameters = array(
1737 'extrafields' => $extrafields,
1738 'extrafieldKey' => $extrafieldKey,
1739 'extrafieldOutputContent' => & $extrafieldOutputContent
1741 $reshook = $hookmanager->executeHooks(
'getPDFExtrafieldContent', $parameters, $this);
1743 $this->error = $hookmanager->error;
1744 $this->errors = $hookmanager->errors;
1745 dol_syslog(__METHOD__.
' '.$this->error, LOG_ERR);
1748 $extrafieldOutputContent = $hookmanager->resPrint;
1751 return $extrafieldOutputContent;
1763 public function getExtrafieldsInHtml(
$object, $outputlangs, $params = array())
1765 global $hookmanager;
1767 if (empty(
$object->table_element)) {
1772 if (is_null($this->extrafieldsCache)) {
1773 include_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
1774 $this->extrafieldsCache =
new ExtraFields($this->db);
1776 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1777 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1779 $extrafields = $this->extrafieldsCache;
1781 $defaultParams = array(
1783 'display' =>
'auto',
1784 'printableEnable' => array(1),
1785 'printableEnableNotEmpty' => array(2),
1788 'maxItemsInRow' => 2,
1792 'labelcolwidth' =>
'25%',
1793 'arrayOfLineBreakType' => array(
'text',
'html')
1797 'separator' =>
'<br>'
1806 $params += $defaultParams;
1815 if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
1816 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1819 if (!empty($extrafields->attributes[
$object->table_element][
'enabled'][$key])) {
1820 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'2');
1829 $disableOnEmpty = 0;
1831 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
1832 $printable = (int) $extrafields->attributes[
$object->table_element][
'printable'][$key];
1833 if (in_array($printable, $params[
'printableEnable']) || in_array($printable, $params[
'printableEnableNotEmpty'])) {
1837 if (in_array($printable, $params[
'printableEnableNotEmpty'])) {
1838 $disableOnEmpty = 1;
1842 if (empty($enabled) || empty($printable)) {
1847 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1848 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1852 $field->rank = intval($extrafields->attributes[
$object->table_element][
'pos'][$key]);
1854 if (isset($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1855 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1857 $field->label = $outputlangs->transnoentities($label);
1858 $field->type = $extrafields->attributes[
$object->table_element][
'type'][$key];
1861 if ($disableOnEmpty && empty($field->content)) {
1869 if (!empty($fields)) {
1878 static function ($a, $b) {
1879 return ($a->rank > $b->rank) ? 1 : -1;
1884 $html .= !empty($params[
'style']) ?
'<style>'.$params[
'style'].
'</style>' :
'';
1887 if ($params[
'display'] ==
'auto') {
1888 $lastNnumbItems = 0;
1889 foreach ($params[
'auto'] as $display => $numbItems) {
1890 if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) {
1891 $lastNnumbItems = $numbItems;
1892 $params[
'display'] = $display;
1897 if ($params[
'display'] ==
'list') {
1900 foreach ($fields as $field) {
1901 $html .= !empty($i) ? $params[
'list'][
'separator'] :
'';
1902 $html .=
'<strong>'.$field->label.
' : </strong>';
1903 $html .= $field->content;
1906 } elseif ($params[
'display'] ==
'table') {
1908 $html .=
'<table class="extrafield-table" cellspacing="'.$params[
'table'][
'cellspacing'].
'" cellpadding="'.$params[
'table'][
'cellpadding'].
'" border="'.$params[
'table'][
'border'].
'">';
1912 $maxItemsInRow = $params[
'table'][
'maxItemsInRow'];
1913 foreach ($fields as $field) {
1915 if ($itemsInRow >= $maxItemsInRow) {
1917 $html .=
"</tr><tr>";
1922 if (in_array($field->type, $params[
'table'][
'arrayOfLineBreakType'])) {
1923 if ($itemsInRow > 0) {
1925 for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) {
1926 $html .=
"<td></td><td></td>";
1934 $itemsInRow = $maxItemsInRow;
1935 $html .=
'<td colspan="'.($maxItemsInRow * 2 - 1).
'">';
1936 $html .=
'<strong>'.$field->label.
' :</strong> ';
1937 $html .= $field->content;
1941 $html .=
'<td width="'.$params[
'table'][
'labelcolwidth'].
'" class="extrafield-label">';
1942 $html .=
'<strong>'.$field->label.
' :</strong>';
1946 $html .=
'<td class="extrafield-content">';
1947 $html .= $field->content;
1953 $html .=
'</table>';
1969 if (!empty($this->cols[$colKey][
'status'])) {
1986 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1988 global $hookmanager,
$conf;
1990 foreach ($this->cols as $colKey => $colDef) {
1991 $parameters = array(
1992 'colKey' => $colKey,
1994 'outputlangs' => $outputlangs,
1995 'tab_top' => $tab_top,
1996 'tab_height' => $tab_height,
1997 'hidetop' => $hidetop
2000 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
2002 $this->error = $hookmanager->error;
2003 $this->errors = $hookmanager->errors;
2004 dol_syslog(__METHOD__.
' '.$this->error, LOG_ERR);
2005 } elseif (empty($reshook)) {
2011 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
2014 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
2015 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
2018 if (empty($hidetop)) {
2020 $curentCellPaddinds = $pdf->getCellPaddings();
2023 global $outputlangsbis;
2025 '@phan-var-force Translate $outputlangsbis';
2027 if (is_object($outputlangsbis)) {
2029 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
2032 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
2034 if (isset($colDef[
'title'][
'align'])) {
2035 $align = $colDef[
'title'][
'align'];
2039 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
2040 $textWidth = $colDef[
'width'];
2041 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
2044 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
2045 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
2046 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
2047 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
2048 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
2051 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
2054 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
2059 return $this->tabTitleHeight;
2074 if (!empty($hidedetails)) {
2078 if (empty(
$object->table_element)) {
2083 if (is_null($this->extrafieldsCache)) {
2084 $this->extrafieldsCache =
new ExtraFields($this->db);
2086 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
2087 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
2089 $extrafields = $this->extrafieldsCache;
2092 if (!empty($extrafields->attributes[
$object->table_element]) && is_array($extrafields->attributes[
$object->table_element]) && array_key_exists(
'label', $extrafields->attributes[
$object->table_element]) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
2093 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
2095 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
2101 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
2102 $printable = intval($extrafields->attributes[
$object->table_element][
'printable'][$key]);
2103 if ($printable === 1 || $printable === 2) {
2114 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
2115 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
2122 'rank' => intval($extrafields->attributes[
$object->table_element][
'pos'][$key]),
2124 'status' => (
bool) $enabled,
2126 'label' => $outputlangs->transnoentities($label)
2131 'border-left' =>
true,
2134 $alignTypeRight = array(
'double',
'int',
'price');
2135 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeRight)) {
2136 $def[
'content'][
'align'] =
'R';
2139 $alignTypeLeft = array(
'text',
'html');
2140 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeLeft)) {
2141 $def[
'content'][
'align'] =
'L';
2167 $this->defaultContentsFieldsStyle = array(
2169 'padding' => array(1, 0.5, 1, 0.5),
2173 $this->defaultTitlesFieldsStyle = array(
2175 'padding' => array(0.5, 0, 0.5, 0),
2212 if (empty($option)) {
2215 if (isset(
$object->context[
'moreparams'][
'addtermsofsale'])) {
2216 return !empty(
$object->context[
'moreparams'][
'addtermsofsale']);
2218 return ($option == 1);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank accounts.
Class to manage predefined suppliers products.
Parent class for documents (PDF, ODT, ...) generators.
get_substitutionarray_shipment($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value Note that vars into substitutions arr...
insertNewColumnDef($newColKey, $defArray, $targetCol='', $insertAfterTarget=false)
get column position rank from column key
getSubstitutionarrayMember($member, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=1)
Define array with couple substitution key => substitution value @phpstan-template T.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple substitution key => substitution value.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
get_substitutionarray_contact($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
getMaxAfterColsLinePositionsData()
Get position in PDF after col display.
get_substitutionarray_other($outputlangs)
Define array with couple substitution key => substitution value.
columnSort($a, $b)
uasort callback function to Sort columns fields
fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
Fill array with couple extrafield key => extrafield value Note that vars into substitutions array are...
mustAddTermsOfSale($object, $type)
Return if the terms of sale file must be concatenated to the generated document.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)
Used for to set afterColsLinePositions var in a pdf draw line loop.
__construct($db)
Constructor.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
getColumnContentWidth($colKey)
get column content width from column key
getColumnRank($colKey)
get column position rank from column key
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
resetAfterColsLinePositionsData(float $y, int $pageNumb)
Used for reset afterColsLinePositions var in start of a new pdf draw line loop.
get_substitutionarray_lines($line, $outputlangs, $linenumber=0)
Define array with couple substitution key => substitution value Note that vars into substitutions arr...
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field into $this->cols This method must be implemented by the module that generat...
get_substitutionarray_thirdparty($object, $outputlangs, $array_key='company')
Define array with couple substitution key => substitution value For example {company_name}...
get_substitutionarray_user($user, $outputlangs)
Define array with couple substitution key => substitution value.
Class to manage invoices.
Class to manage products or services.
display_incoterms()
Return incoterms information TODO Use a cache for label get.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
getFormeJuridiqueLabel($code)
Return the name translated of juridical status.
doc_getlinedesc($line, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
Return line description translated in outputlangs and encoded into UTF8.
dol_now($mode='gmt')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date