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;
338 $logotouse =
$conf->user->dir_output .
'/' .
get_exdir(0, 0, 0, 0, $user,
'user') .
'photos/' . getImageFileNameForSize($user->photo,
'_small');
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),
894 'line_qty' => $line->qty,
895 'line_qty_locale' =>
price($line->qty),
896 'line_discount_percent' => ($line->remise_percent ? $line->remise_percent.
'%' :
''),
897 'line_price_ht' =>
price2num($line->total_ht),
898 'line_price_ttc' =>
price2num($line->total_ttc),
899 'line_price_vat' =>
price2num($line->total_tva),
900 'line_price_ht_locale' =>
price($line->total_ht, 0, $outputlangs),
901 'line_price_ttc_locale' =>
price($line->total_ttc, 0, $outputlangs),
902 'line_price_vat_locale' =>
price($line->total_tva, 0, $outputlangs),
904 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
905 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
906 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
907 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
908 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
909 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
910 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
911 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
912 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
915 if (property_exists($line,
'ref_fourn')) {
916 $resarray[
'line_product_ref_fourn'] = $line->ref_fourn;
918 $resarray[
'line_product_ref_fourn'] =
'';
921 'line_localtax1_rate' =>
'localtax1_tx',
922 'line_localtax2_rate' =>
'localtax2_tx',
924 foreach ($vat_specs as $vat_key => $vat_spec) {
925 if (property_exists($line, $vat_spec)) {
927 $resarray[$vat_key] =
vatrate($line->$vat_spec);
933 array(
'line_date_start',
'date_start',
'day',
'auto',
null),
934 array(
'line_date_start_locale',
'date_start',
'day',
'tzserver', $outputlangs),
935 array(
'line_date_start_rfc',
'date_start',
'dayrfc',
'auto',
null),
936 array(
'line_date_start_real',
'date_start_real',
'day',
'auto',
null),
937 array(
'line_date_start_real_locale',
'date_start_real',
'day',
'tzserver', $outputlangs),
938 array(
'line_date_start_real_rfc',
'date_start_real',
'dayrfc',
'auto',
null),
939 array(
'line_date_end',
'date_end',
'day',
'auto',
null),
940 array(
'line_date_end_locale',
'date_end',
'day',
'tzserver', $outputlangs),
941 array(
'line_date_end_rfc',
'date_end',
'dayrfc',
'auto',
null)
943 foreach ($date_specs as $date_spec) {
944 $propertyname = $date_spec[1];
945 if (property_exists($line, $propertyname)) {
947 $resarray[$date_spec[0]] =
dol_print_date($line->$propertyname, $date_spec[2], $date_spec[3], $date_spec[4]);
953 $resarray[
'line_unit'] = $line->getLabelOfUnit(
'long', $outputlangs);
954 $resarray[
'line_unit_short'] = $line->getLabelOfUnit(
'short', $outputlangs);
959 $extrafieldkey = $line->table_element;
961 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
963 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
964 $line->fetch_optionals();
969 if (get_class($line) ==
'CommandeFournisseurLigne') {
971 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
972 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
974 if (!empty($extralabels) && is_array($extralabels)) {
977 foreach ($extralabels as $key => $label) {
978 $columns .=
"$key, ";
981 if ($columns !=
"") {
982 $columns = substr($columns, 0, strlen($columns) - 2);
983 $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).
"'");
985 if ($this->db->num_rows($resql) > 0) {
986 $resql = $this->db->fetch_object($resql);
988 foreach ($extralabels as $key => $label) {
989 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
997 if (get_class($line) ==
'ExpeditionLigne') {
998 $resarray[
'line_qty_shipped'] = $line->qty_shipped;
999 $resarray[
'line_qty_asked'] = $line->qty_asked;
1000 $resarray[
'line_weight'] = empty($line->weight) ?
'' : $line->weight * $line->qty_shipped.
' '.
measuringUnitString(0,
'weight', $line->weight_units);
1001 $resarray[
'line_length'] = empty($line->length) ?
'' : $line->length * $line->qty_shipped.
' '.
measuringUnitString(0,
'size', $line->length_units);
1002 $resarray[
'line_surface'] = empty($line->surface) ?
'' : $line->surface * $line->qty_shipped.
' '.
measuringUnitString(0,
'surface', $line->surface_units);
1003 $resarray[
'line_volume'] = empty($line->volume) ?
'' : $line->volume * $line->qty_shipped.
' '.
measuringUnitString(0,
'volume', $line->volume_units);
1007 if (isset($line->fk_product) && $line->fk_product > 0) {
1008 $tmpproduct =
new Product($this->db);
1009 $result = $tmpproduct->fetch($line->fk_product);
1010 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
1011 foreach ($tmpproduct->array_options as $key => $label) {
1012 $resarray[
"line_product_".$key] = $label;
1017 $extrafields->fetch_name_optionals_label(
"product");
1018 if ($extrafields->attributes[
"product"][
'count'] > 0) {
1019 $extralabels = $extrafields->attributes[
"product"][
'label'];
1021 foreach ($extralabels as $key => $label) {
1022 $resarray[
'line_product_options_'.$key] =
'';
1043 global $extrafields;
1045 include_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
1047 $object->list_delivery_methods((
int)
$object->shipping_method_id);
1049 $calculatedVolume = ((float)
$object->trueWidth * (
float)
$object->trueHeight * (float)
$object->trueDepth);
1051 $array_shipment = array(
1052 $array_key.
'_id' =>
$object->id,
1053 $array_key.
'_ref' =>
$object->ref,
1054 $array_key.
'_ref_ext' =>
$object->ref_ext,
1055 $array_key.
'_ref_customer' =>
$object->ref_customer,
1062 $array_key.
'_total_discount_ht' =>
price(
$object->getTotalDiscount()),
1063 $array_key.
'_note_private' =>
$object->note_private,
1064 $array_key.
'_note' =>
$object->note_public,
1065 $array_key.
'_tracking_number' =>
$object->tracking_number,
1066 $array_key.
'_tracking_url' =>
$object->tracking_url,
1067 $array_key.
'_shipping_method' =>
$object->listmeths[0][
'libelle'],
1076 foreach (
$object->lines as $line) {
1077 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
1078 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
1080 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
1084 if (is_array(
$object->array_options) && count(
$object->array_options)) {
1091 if (
$object->origin_type ==
'commande' && is_object(
$object->origin_object) && !empty(
$object->origin_object->ref)) {
1092 $originOrder =
$object->origin_object;
1093 '@phan-var-force Commande $originOrder';
1094 $array_shipment[
'order_ref'] = $originOrder->ref;
1095 $array_shipment[
'order_ref_customer'] = $originOrder->ref_customer;
1099 $tmparray =
$object->getTotalWeightVolume();
1100 $totalWeight = $tmparray[
'weight'];
1101 $totalVolume = $tmparray[
'volume'];
1102 $totalOrdered = $tmparray[
'ordered'];
1103 $totalToShip = $tmparray[
'toship'];
1111 $array_shipment[$array_key.
'_total_ordered'] = (
string) $totalOrdered;
1112 $array_shipment[$array_key.
'_total_toship'] = (
string) $totalToShip;
1116 } elseif (!empty($totalWeight)) {
1117 $array_shipment[$array_key.
'_total_weight'] =
showDimensionInBestUnit($totalWeight, 0,
"weight", $outputlangs, -1,
'no', 1);
1119 $array_shipment[$array_key.
'_total_weight'] =
"";
1122 if (!empty(
$object->trueVolume)) {
1123 if (
$object->volume_units < 50) {
1126 $array_shipment[$array_key.
'_total_volume'] = (empty($totalVolume)) ?
'' :
price(
$object->trueVolume, 0, $outputlangs, 0, 0).
' '.
measuringUnitString(0,
"volume",
$object->volume_units);
1128 } elseif (!empty($totalVolume)) {
1129 $array_shipment[$array_key.
'_total_volume'] =
showDimensionInBestUnit($totalVolume, 0,
"volume", $outputlangs, -1,
'no', 1);
1131 $array_shipment[$array_key.
'_total_volume'] =
"";
1134 return $array_shipment;
1152 $array_other = array();
1156 foreach (
$object as $key => $value) {
1157 if (in_array($key, array(
'db',
'fields',
'lines',
'modelpdf',
'model_pdf'))) {
1160 if (!empty($value)) {
1161 if (!is_array($value) && !is_object($value)) {
1162 $array_other[
'object_'.$key] = $value;
1163 } elseif (is_array($value) && $recursive) {
1165 if (!empty($tmparray) && is_array($tmparray)) {
1166 foreach ($tmparray as $key2 => $value2) {
1167 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1170 } elseif (is_object($value) && $recursive) {
1172 if (!empty($tmparray) && is_array($tmparray)) {
1173 foreach ($tmparray as $key2 => $value2) {
1174 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1182 return $array_other;
1203 if ($extrafields->attributes[
$object->table_element][
'count'] > 0) {
1204 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1205 $formatedarrayoption =
$object->array_options;
1207 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
1208 $formatedarrayoption[
'options_'.$key] =
price2num($formatedarrayoption[
'options_'.$key]);
1209 $formatedarrayoption[
'options_'.$key.
'_currency'] =
price($formatedarrayoption[
'options_'.$key], 0, $outputlangs, 0, 0, -1,
$conf->currency);
1211 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_currency' => $formatedarrayoption[
'options_'.$key.
'_currency']));
1212 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'select') {
1213 $valueofselectkey = $formatedarrayoption[
'options_'.$key];
1214 if (array_key_exists($valueofselectkey, $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'])) {
1215 $formatedarrayoption[
'options_'.$key] = $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'][$valueofselectkey];
1217 $formatedarrayoption[
'options_'.$key] =
'';
1219 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'checkbox') {
1220 $valArray = explode(
',', $formatedarrayoption[
'options_'.$key]);
1222 foreach ($extrafields->attributes[
$object->table_element][
'param'][$key][
'options'] as $keyopt => $valopt) {
1223 if (in_array($keyopt, $valArray)) {
1224 $output[] = $valopt;
1227 $formatedarrayoption[
'options_'.$key] = implode(
', ', $output);
1228 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
1229 if (strlen($formatedarrayoption[
'options_'.$key]) > 0) {
1230 $date = $formatedarrayoption[
'options_'.$key];
1231 $formatedarrayoption[
'options_'.$key] =
dol_print_date($date,
'day');
1232 $formatedarrayoption[
'options_'.$key.
'_locale'] =
dol_print_date($date,
'day',
'tzserver', $outputlangs);
1233 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
dol_print_date($date,
'dayrfc');
1235 $formatedarrayoption[
'options_'.$key] =
'';
1236 $formatedarrayoption[
'options_'.$key.
'_locale'] =
'';
1237 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
'';
1239 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1240 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1241 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
1242 $datetime = $formatedarrayoption[
'options_'.$key];
1243 $formatedarrayoption[
'options_'.$key] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
1244 $formatedarrayoption[
'options_'.$key.
'_locale'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
1245 $formatedarrayoption[
'options_'.$key.
'_rfc'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
1246 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1247 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1248 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'link') {
1249 $id = $formatedarrayoption[
'options_'.$key];
1251 $param = $extrafields->attributes[
$object->table_element][
'param'][$key];
1252 $param_list = array_keys($param[
'options']);
1253 $InfoFieldList = explode(
":", $param_list[0]);
1254 $classname = $InfoFieldList[0];
1255 $classpath = $InfoFieldList[1];
1256 if (!empty($classpath)) {
1258 if ($classname && class_exists($classname)) {
1259 $tmpobject =
new $classname($this->db);
1260 '@phan-var-force CommonObject $tmpobject';
1261 $tmpobject->fetch(
$id);
1263 $formatedarrayoption[
'options_'.$key] = $tmpobject->name;
1269 if (array_key_exists(
'options_'.$key, $formatedarrayoption)) {
1270 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key => $formatedarrayoption[
'options_'.$key]));
1272 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key =>
''));
1277 return $array_to_fill;
1293 public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1295 if (empty($hidetop) || $hidetop == -1) {
1296 $pdf->line($x, $y, $x + $l, $y);
1298 $pdf->line($x + $l, $y, $x + $l, $y + $h);
1299 if (empty($hidebottom)) {
1300 $pdf->line($x + $l, $y + $h, $x, $y + $h);
1302 $pdf->line($x, $y + $h, $x, $y);
1319 public function printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebottom = 0, $style =
'D')
1322 if (empty($hidetop) || $hidetop == -1) {
1323 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1111', $style);
1326 $pdf->RoundedRect($x, $y, $w, $h, $r,
'0111', $style);
1328 if (!empty($hidebottom)) {
1329 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1101', $style);
1339 if (empty($this->afterColsLinePositions) || !is_array($this->afterColsLinePositions)) {
1344 $maxPage = $maxY = 0;
1345 foreach ($this->afterColsLinePositions as $colKey => $value) {
1346 if ($value[
'page'] > $maxPage) {
1348 $maxPage = $value[
'page'];
1349 $maxY = $value[
'y'];
1350 } elseif ($value[
'page'] == $maxPage) {
1351 $maxY = max($value[
'y'], $maxY);
1371 $this->afterColsLinePositions = [];
1384 $this->afterColsLinePositions[$colId] = [
1385 'page' => $pageNumb,
1400 if (empty($a[
'rank'])) {
1403 if (empty($b[
'rank'])) {
1406 if ($a[
'rank'] == $b[
'rank']) {
1409 return ($a[
'rank'] > $b[
'rank']) ? -1 : 1;
1428 uasort($this->cols, array($this,
'columnSort'));
1431 $curX = $this->page_largeur - $this->marge_droite;
1434 $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche;
1437 $totalDefinedColWidth = 0;
1439 foreach ($this->cols as $colKey => & $colDef) {
1444 if (!empty($colDef[
'scale'])) {
1446 $colDef[
'width'] = abs($arrayWidth * $colDef[
'scale'] / 100);
1449 if (empty($colDef[
'width'])) {
1452 $totalDefinedColWidth += $colDef[
'width'];
1456 foreach ($this->cols as $colKey => & $colDef) {
1458 if (!empty($colDef[
'title'])) {
1459 $colDef[
'title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef[
'title']);
1461 $colDef[
'title'] = $this->defaultTitlesFieldsStyle;
1465 if (!empty($colDef[
'content'])) {
1466 $colDef[
'content'] = array_replace($this->defaultContentsFieldsStyle, $colDef[
'content']);
1468 $colDef[
'content'] = $this->defaultContentsFieldsStyle;
1473 if (empty($colDef[
'width'])) {
1474 $colDef[
'width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
1479 $curX = $lastX - $colDef[
'width'];
1480 $colDef[
'xStartPos'] = $curX;
1481 $colDef[
'xEndPos'] = $lastX;
1494 $colDef = $this->cols[$colKey];
1495 return $colDef[
'width'] - $colDef[
'content'][
'padding'][3] - $colDef[
'content'][
'padding'][1];
1507 $colDef = (isset($this->cols[$colKey]) ? $this->cols[$colKey] :
null);
1508 return (is_array($colDef) ? ((isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0) + $colDef[
'content'][
'padding'][3]) : 0);
1519 if (!isset($this->cols[$colKey][
'rank'])) {
1522 return $this->cols[$colKey][
'rank'];
1540 if (!empty($targetCol)) {
1542 if ($rank >= 0 && $insertAfterTarget) {
1548 if ($rank < 0 && !empty($defArray[
'rank'])) {
1549 $rank = $defArray[
'rank'];
1557 foreach ($this->cols as $colKey => & $colDef) {
1558 if ($rank <= $colDef[
'rank']) {
1559 $colDef[
'rank'] += 1;
1563 $defArray[
'rank'] = $rank;
1564 $this->cols[$newColKey] = $defArray;
1581 global $hookmanager;
1583 $parameters = array(
1585 'columnText' => &$columnText,
1586 'colKey' => $colKey,
1589 $reshook = $hookmanager->executeHooks(
'printStdColumnContent', $parameters, $this);
1590 if ($reshook > 0 && isset($hookmanager->resArray[
'columnText'])) {
1591 $columnText = $hookmanager->resArray[
'columnText'];
1596 if (!$reshook || $reshook > 0) {
1597 if (empty($columnText)) {
1601 $colDef = $this->cols[$colKey];
1603 $curentCellPaddinds = $pdf->getCellPaddings();
1605 $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);
1606 $pdf->writeHTMLCell($colDef[
'width'], 2, isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0, $curY, $columnText, 0, 1,
false,
true, $colDef[
'content'][
'align']);
1610 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1633 global $hookmanager;
1636 $colDef = $this->cols[$colKey];
1638 $curentCellPaddinds = $pdf->getCellPaddings();
1640 $pdf->setCellPaddings($colDef[
'content'][
'padding'][3], $colDef[
'content'][
'padding'][0], $colDef[
'content'][
'padding'][1], $colDef[
'content'][
'padding'][2]);
1643 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $colDef[
'width'], 3, $colDef[
'xStartPos'], $curY, $hideref, $hidedesc, $issupplierline, empty($colDef[
'content'][
'align']) ?
'J' : $colDef[
'content'][
'align']);
1644 $posYAfterDescription = $pdf->GetY() - $colDef[
'content'][
'padding'][0];
1647 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1651 'display' =>
'list',
1652 'printableEnable' => array(3),
1653 'printableEnableNotEmpty' => array(4)
1655 $extrafieldDesc = $this->getExtrafieldsInHtml(
$object->lines[$i], $outputlangs, $params);
1656 if (!empty($extrafieldDesc)) {
1660 $parameters = array(
1662 'colKey' => $colKey,
1665 'outputlangs' => $outputlangs,
1668 $reshook = $hookmanager->executeHooks(
'printColDescContent', $parameters, $this);
1685 global $hookmanager;
1687 if (empty(
$object->table_element)) {
1691 $extrafieldsKeyPrefix =
"options_";
1694 $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
1696 $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
1699 $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
1703 if (is_null($this->extrafieldsCache)) {
1704 $this->extrafieldsCache =
new ExtraFields($this->db);
1706 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1707 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1709 $extrafields = $this->extrafieldsCache;
1711 $extrafieldOutputContent =
'';
1712 if (isset(
$object->array_options[$extrafieldOptionsKey])) {
1713 $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey,
$object->array_options[$extrafieldOptionsKey],
'',
$object->table_element, $outputlangs);
1717 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'link') {
1723 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'stars') {
1724 $extrafieldOutputContent =
'';
1725 for ($i = 0; $i <
$object->array_options[$extrafieldOptionsKey]; $i++) {
1726 $extrafieldOutputContent .=
' *';
1730 $parameters = array(
1732 'extrafields' => $extrafields,
1733 'extrafieldKey' => $extrafieldKey,
1734 'extrafieldOutputContent' => & $extrafieldOutputContent
1736 $reshook = $hookmanager->executeHooks(
'getPDFExtrafieldContent', $parameters, $this);
1741 $extrafieldOutputContent = $hookmanager->resPrint;
1744 return $extrafieldOutputContent;
1756 public function getExtrafieldsInHtml(
$object, $outputlangs, $params = array())
1758 global $hookmanager;
1760 if (empty(
$object->table_element)) {
1765 if (is_null($this->extrafieldsCache)) {
1766 $this->extrafieldsCache =
new ExtraFields($this->db);
1768 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1769 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1771 $extrafields = $this->extrafieldsCache;
1773 $defaultParams = array(
1775 'display' =>
'auto',
1776 'printableEnable' => array(1),
1777 'printableEnableNotEmpty' => array(2),
1780 'maxItemsInRow' => 2,
1784 'labelcolwidth' =>
'25%',
1785 'arrayOfLineBreakType' => array(
'text',
'html')
1789 'separator' =>
'<br>'
1798 $params += $defaultParams;
1807 if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
1808 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1811 if (!empty($extrafields->attributes[
$object->table_element][
'enabled'][$key])) {
1812 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'2');
1821 $disableOnEmpty = 0;
1823 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
1824 $printable = (int) $extrafields->attributes[
$object->table_element][
'printable'][$key];
1825 if (in_array($printable, $params[
'printableEnable']) || in_array($printable, $params[
'printableEnableNotEmpty'])) {
1829 if (in_array($printable, $params[
'printableEnableNotEmpty'])) {
1830 $disableOnEmpty = 1;
1834 if (empty($enabled) || empty($printable)) {
1839 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1840 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1844 $field->rank = intval($extrafields->attributes[
$object->table_element][
'pos'][$key]);
1846 if (isset($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1847 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1849 $field->label = $outputlangs->transnoentities($label);
1850 $field->type = $extrafields->attributes[
$object->table_element][
'type'][$key];
1853 if ($disableOnEmpty && empty($field->content)) {
1861 if (!empty($fields)) {
1870 static function ($a, $b) {
1871 return ($a->rank > $b->rank) ? 1 : -1;
1876 $html .= !empty($params[
'style']) ?
'<style>'.$params[
'style'].
'</style>' :
'';
1879 if ($params[
'display'] ==
'auto') {
1880 $lastNnumbItems = 0;
1881 foreach ($params[
'auto'] as $display => $numbItems) {
1882 if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) {
1883 $lastNnumbItems = $numbItems;
1884 $params[
'display'] = $display;
1889 if ($params[
'display'] ==
'list') {
1892 foreach ($fields as $field) {
1893 $html .= !empty($i) ? $params[
'list'][
'separator'] :
'';
1894 $html .=
'<strong>'.$field->label.
' : </strong>';
1895 $html .= $field->content;
1898 } elseif ($params[
'display'] ==
'table') {
1900 $html .=
'<table class="extrafield-table" cellspacing="'.$params[
'table'][
'cellspacing'].
'" cellpadding="'.$params[
'table'][
'cellpadding'].
'" border="'.$params[
'table'][
'border'].
'">';
1904 $maxItemsInRow = $params[
'table'][
'maxItemsInRow'];
1905 foreach ($fields as $field) {
1907 if ($itemsInRow >= $maxItemsInRow) {
1909 $html .=
"</tr><tr>";
1914 if (in_array($field->type, $params[
'table'][
'arrayOfLineBreakType'])) {
1915 if ($itemsInRow > 0) {
1917 for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) {
1918 $html .=
"<td></td><td></td>";
1926 $itemsInRow = $maxItemsInRow;
1927 $html .=
'<td colspan="'.($maxItemsInRow * 2 - 1).
'">';
1928 $html .=
'<strong>'.$field->label.
' :</strong> ';
1929 $html .= $field->content;
1933 $html .=
'<td width="'.$params[
'table'][
'labelcolwidth'].
'" class="extrafield-label">';
1934 $html .=
'<strong>'.$field->label.
' :</strong>';
1938 $html .=
'<td class="extrafield-content">';
1939 $html .= $field->content;
1945 $html .=
'</table>';
1961 if (!empty($this->cols[$colKey][
'status'])) {
1978 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1980 global $hookmanager,
$conf;
1982 foreach ($this->cols as $colKey => $colDef) {
1983 $parameters = array(
1984 'colKey' => $colKey,
1986 'outputlangs' => $outputlangs,
1987 'tab_top' => $tab_top,
1988 'tab_height' => $tab_height,
1989 'hidetop' => $hidetop
1992 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
1995 } elseif (empty($reshook)) {
2001 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
2004 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
2005 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
2008 if (empty($hidetop)) {
2010 $curentCellPaddinds = $pdf->getCellPaddings();
2013 global $outputlangsbis;
2014 if (is_object($outputlangsbis)) {
2016 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
2019 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
2021 if (isset($colDef[
'title'][
'align'])) {
2022 $align = $colDef[
'title'][
'align'];
2026 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
2027 $textWidth = $colDef[
'width'];
2028 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
2031 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
2032 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
2033 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
2034 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
2035 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
2038 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
2041 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
2046 return $this->tabTitleHeight;
2061 if (!empty($hidedetails)) {
2065 if (empty(
$object->table_element)) {
2070 if (is_null($this->extrafieldsCache)) {
2071 $this->extrafieldsCache =
new ExtraFields($this->db);
2073 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
2074 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
2076 $extrafields = $this->extrafieldsCache;
2079 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'])) {
2080 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
2082 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
2088 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
2089 $printable = intval($extrafields->attributes[
$object->table_element][
'printable'][$key]);
2090 if ($printable === 1 || $printable === 2) {
2101 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
2102 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
2109 'rank' => intval($extrafields->attributes[
$object->table_element][
'pos'][$key]),
2111 'status' => (
bool) $enabled,
2113 'label' => $outputlangs->transnoentities($label)
2118 'border-left' =>
true,
2121 $alignTypeRight = array(
'double',
'int',
'price');
2122 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeRight)) {
2123 $def[
'content'][
'align'] =
'R';
2126 $alignTypeLeft = array(
'text',
'html');
2127 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeLeft)) {
2128 $def[
'content'][
'align'] =
'L';
2154 $this->defaultContentsFieldsStyle = array(
2156 'padding' => array(1, 0.5, 1, 0.5),
2160 $this->defaultTitlesFieldsStyle = array(
2162 'padding' => array(0.5, 0, 0.5, 0),
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
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
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
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...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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