59 public $errors = array();
69 public $extrafieldsCache;
74 public $update_main_doc_field;
104 public $page_largeur;
109 public $marge_gauche;
114 public $marge_droite;
129 public $corner_radius;
142 public $option_multilang;
146 public $option_freetext;
150 public $option_draft_watermark;
159 public $option_modereg;
163 public $option_condreg;
167 public $option_escompte;
171 public $option_credit_note;
198 public $tabTitleHeight;
203 public $defaultTitlesFieldsStyle;
208 public $defaultContentsFieldsStyle;
219 public $phpmin = array(7, 1);
229 public $afterColsLinePositions;
283 public $posxdiscount;
287 public $posxworkload;
291 public $posxtimespent;
295 public $posxprogress;
299 public $atleastonephoto;
303 public $atleastoneratenotnull;
307 public $atleastonediscount;
331 global
$conf, $extrafields;
336 'myuser_lastname' => $user->lastname,
337 'myuser_firstname' => $user->firstname,
338 'myuser_fullname' => $user->getFullName($outputlangs, 1),
339 'myuser_login' => $user->login,
340 'myuser_phone' => $user->office_phone,
341 'myuser_address' => $user->address,
342 'myuser_zip' => $user->zip,
343 'myuser_town' => $user->town,
344 'myuser_country' => $user->country,
345 'myuser_country_code' => $user->country_code,
346 'myuser_state' => $user->state,
347 'myuser_state_code' => $user->state_code,
348 'myuser_fax' => $user->office_fax,
349 'myuser_mobile' => $user->user_mobile,
350 'myuser_email' => $user->email,
351 'myuser_logo' => $logotouse,
352 'myuser_job' => $user->job,
355 'myuser_dateemployment' =>
dol_print_date($user->dateemployment,
'day',
'tzuser'),
356 'myuser_dateemploymentend' =>
dol_print_date($user->dateemploymentend,
'day',
'tzuser'),
357 'myuser_gender' => $user->gender,
360 if (is_array($user->array_options) && count($user->array_options)) {
361 if (empty($extrafields->attributes[$user->table_element])) {
362 $extrafields->fetch_name_optionals_label($user->table_element);
379 global
$conf, $extrafields;
381 if ($member->photo) {
382 $logotouse =
$conf->member->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $member,
'user').
'/photos/'.$member->photo;
384 $logotouse = DOL_DOCUMENT_ROOT.
'/public/theme/common/nophoto.png';
387 $array_member = array(
388 'mymember_lastname' => $member->lastname,
389 'mymember_firstname' => $member->firstname,
390 'mymember_fullname' => $member->getFullName($outputlangs, 1),
391 'mymember_login' => $member->login,
392 'mymember_address' => $member->address,
393 'mymember_zip' => $member->zip,
394 'mymember_town' => $member->town,
395 'mymember_country_code' => $member->country_code,
396 'mymember_country' => $member->country,
397 'mymember_state_code' => $member->state_code,
398 'mymember_state' => $member->state,
399 'mymember_phone_perso' => $member->phone_perso,
400 'mymember_phone_pro' => $member->phone,
401 'mymember_phone_mobile' => $member->phone_mobile,
402 'mymember_email' => $member->email,
403 'mymember_logo' => $logotouse,
404 'mymember_gender' => $member->gender,
405 'mymember_birth_locale' =>
dol_print_date($member->birth,
'day',
'tzuser', $outputlangs),
406 'mymember_birth' =>
dol_print_date($member->birth,
'day',
'tzuser'),
409 if (is_array($member->array_options) && count($member->array_options)) {
412 return $array_member;
429 if (empty($mysoc->forme_juridique) && !empty($mysoc->forme_juridique_code)) {
432 if (empty($mysoc->country) && !empty($mysoc->country_code)) {
433 $mysoc->country = $outputlangs->transnoentitiesnoconv(
"Country".$mysoc->country_code);
435 if (empty($mysoc->state) && !empty($mysoc->state_code)) {
436 $state_id =
dol_getIdFromCode($this->db, $mysoc->state_code,
'c_departements',
'code_departement',
'rowid');
437 $mysoc->state =
getState($state_id,
'0');
440 $logotouse =
$conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small;
443 'mycompany_logo' => $logotouse,
444 'mycompany_name' => $mysoc->name,
445 'mycompany_email' => $mysoc->email,
446 'mycompany_phone' => $mysoc->phone,
447 'mycompany_fax' => $mysoc->fax,
448 'mycompany_address' => $mysoc->address,
449 'mycompany_zip' => $mysoc->zip,
450 'mycompany_town' => $mysoc->town,
451 'mycompany_country' => $mysoc->country,
452 'mycompany_country_code' => $mysoc->country_code,
453 'mycompany_state' => $mysoc->state,
454 'mycompany_state_code' => $mysoc->state_code,
455 'mycompany_web' => $mysoc->url,
456 'mycompany_juridicalstatus' => $mysoc->forme_juridique,
457 'mycompany_managers' => $mysoc->managers,
458 'mycompany_capital' => $mysoc->capital,
459 'mycompany_barcode' => $mysoc->barcode,
460 'mycompany_idprof1' => $mysoc->idprof1,
461 'mycompany_idprof2' => $mysoc->idprof2,
462 'mycompany_idprof3' => $mysoc->idprof3,
463 'mycompany_idprof4' => $mysoc->idprof4,
464 'mycompany_idprof5' => $mysoc->idprof5,
465 'mycompany_idprof6' => $mysoc->idprof6,
466 'mycompany_vatnumber' => $mysoc->tva_intra,
467 'mycompany_socialobject' => $mysoc->socialobject,
468 'mycompany_note_private' => $mysoc->note_private,
494 $object->country = $outputlangs->transnoentitiesnoconv(
"Country".
$object->country_code);
501 $array_thirdparty = array(
502 'company_name' =>
$object->name,
503 'company_name_alias' =>
$object->name_alias,
504 'company_email' =>
$object->email,
505 'company_phone' =>
$object->phone,
507 'company_address' =>
$object->address,
509 'company_town' =>
$object->town,
510 'company_country' =>
$object->country,
511 'company_country_code' =>
$object->country_code,
512 'company_state' =>
$object->state,
513 'company_state_code' =>
$object->state_code,
515 'company_barcode' =>
$object->barcode,
516 'company_vatnumber' =>
$object->tva_intra,
517 'company_customercode' =>
$object->code_client,
518 'company_suppliercode' =>
$object->code_fournisseur,
519 'company_customeraccountancycode' =>
$object->code_compta_client,
520 'company_supplieraccountancycode' =>
$object->code_compta_fournisseur,
521 'company_juridicalstatus' =>
$object->forme_juridique,
522 'company_outstanding_limit' =>
$object->outstanding_limit,
523 'company_capital' =>
$object->capital,
524 'company_capital_formated' =>
price(
$object->capital, 0,
'', 1, -1),
525 'company_idprof1' =>
$object->idprof1,
526 'company_idprof2' =>
$object->idprof2,
527 'company_idprof3' =>
$object->idprof3,
528 'company_idprof4' =>
$object->idprof4,
529 'company_idprof5' =>
$object->idprof5,
530 'company_idprof6' =>
$object->idprof6,
531 'company_note_public' =>
$object->note_public,
532 'company_note_private' =>
$object->note_private,
533 'company_default_bank_iban' => (is_object(
$object->bank_account) ?
$object->bank_account->iban :
''),
534 'company_default_bank_bic' => (is_object(
$object->bank_account) ?
$object->bank_account->bic :
'')
538 if (is_array(
$object->array_options) && count(
$object->array_options)) {
543 return $array_thirdparty;
558 global
$conf, $extrafields;
561 $object->country = $outputlangs->transnoentitiesnoconv(
"Country".
$object->country_code);
568 $array_contact = array(
569 $array_key.
'_fullname' =>
$object->getFullName($outputlangs, 1),
570 $array_key.
'_lastname' =>
$object->lastname,
571 $array_key.
'_firstname' =>
$object->firstname,
572 $array_key.
'_address' =>
$object->address,
573 $array_key.
'_zip' =>
$object->zip,
574 $array_key.
'_town' =>
$object->town,
575 $array_key.
'_state_id' =>
$object->state_id,
576 $array_key.
'_state_code' =>
$object->state_code,
577 $array_key.
'_state' =>
$object->state,
578 $array_key.
'_country_id' =>
$object->country_id,
579 $array_key.
'_country_code' =>
$object->country_code,
580 $array_key.
'_country' =>
$object->country,
581 $array_key.
'_poste' =>
$object->poste,
582 $array_key.
'_socid' =>
$object->socid,
583 $array_key.
'_statut' =>
$object->statut,
584 $array_key.
'_code' =>
$object->code,
585 $array_key.
'_email' =>
$object->email,
586 $array_key.
'_phone_pro' =>
$object->phone_pro,
587 $array_key.
'_phone_perso' =>
$object->phone_perso,
588 $array_key.
'_phone_mobile' =>
$object->phone_mobile,
589 $array_key.
'_fax' =>
$object->fax,
590 $array_key.
'_birthday' =>
$object->birthday,
591 $array_key.
'_default_lang' =>
$object->default_lang,
592 $array_key.
'_note_public' =>
$object->note_public,
593 $array_key.
'_note_private' =>
$object->note_private,
594 $array_key.
'_civility' =>
$object->civility,
598 if (is_array(
$object->array_options) && count(
$object->array_options)) {
603 return $array_contact;
620 $array_other = array(
625 'current_server_datehour' =>
dol_print_date($now,
'dayhour',
'tzserver'),
627 'current_date_locale' =>
dol_print_date($now,
'day',
'tzuser', $outputlangs),
628 'current_datehour_locale' =>
dol_print_date($now,
'dayhour',
'tzuser', $outputlangs),
629 'current_server_date_locale' =>
dol_print_date($now,
'day',
'tzserver', $outputlangs),
630 'current_server_datehour_locale' =>
dol_print_date($now,
'dayhour',
'tzserver', $outputlangs),
634 foreach (
$conf->global as $key => $val) {
636 $newval =
'*****forbidden*****';
640 $array_other[
'__['.$key.
']__'] = $newval;
657 public function get_substitutionarray_object(
$object, $outputlangs, $array_key =
'object')
662 $sumpayed = $sumdeposit = $sumcreditnote =
'';
663 $already_payed_all = 0;
665 if (
$object->element ==
'facture') {
667 '@phan-var-force Facture $object';
668 $invoice_source =
new Facture($this->db);
669 if (
$object->fk_facture_source > 0) {
670 $invoice_source->fetch(
$object->fk_facture_source);
672 $sumpayed =
$object->getSommePaiement();
673 $sumdeposit =
$object->getSumDepositsUsed();
674 $sumcreditnote =
$object->getSumCreditNotesUsed();
675 $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
686 $array_key.
'_id' =>
$object->id,
687 $array_key.
'_ref' => (property_exists(
$object,
'ref') ?
$object->ref :
''),
688 $array_key.
'_label' => (property_exists(
$object,
'label') ?
$object->label :
''),
689 $array_key.
'_ref_ext' => (property_exists(
$object,
'ref_ext') ?
$object->ref_ext :
''),
690 $array_key.
'_ref_customer' => (!empty(
$object->ref_client) ?
$object->ref_client : (empty(
$object->ref_customer) ?
'' :
$object->ref_customer)),
691 $array_key.
'_ref_supplier' => (!empty(
$object->ref_fournisseur) ?
$object->ref_fournisseur : (empty(
$object->ref_supplier) ?
'' :
$object->ref_supplier)),
692 $array_key.
'_source_invoice_ref' => ((empty($invoice_source) || empty($invoice_source->
ref)) ?
'' : $invoice_source->
ref),
707 $array_key.
'_payment_mode_code' =>
$object->mode_reglement_code,
708 $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),
709 $array_key.
'_payment_term_code' =>
$object->cond_reglement_code,
710 $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),
714 $array_key.
'_total_ht_locale' =>
price(
$object->total_ht, 0, $outputlangs),
715 $array_key.
'_total_vat_locale' => (!empty(
$object->total_vat) ?
price(
$object->total_vat, 0, $outputlangs) :
price(
$object->total_tva, 0, $outputlangs)),
716 $array_key.
'_total_localtax1_locale' =>
price(
$object->total_localtax1, 0, $outputlangs),
717 $array_key.
'_total_localtax2_locale' =>
price(
$object->total_localtax2, 0, $outputlangs),
718 $array_key.
'_total_ttc_locale' =>
price(
$object->total_ttc, 0, $outputlangs),
726 $array_key.
'_multicurrency_code' =>
$object->multicurrency_code,
728 $array_key.
'_multicurrency_total_ht' =>
price2num(
$object->multicurrency_total_ht),
729 $array_key.
'_multicurrency_total_tva' =>
price2num(
$object->multicurrency_total_tva),
730 $array_key.
'_multicurrency_total_ttc' =>
price2num(
$object->multicurrency_total_ttc),
731 $array_key.
'_multicurrency_total_ht_locale' =>
price(
$object->multicurrency_total_ht, 0, $outputlangs),
732 $array_key.
'_multicurrency_total_tva_locale' =>
price(
$object->multicurrency_total_tva, 0, $outputlangs),
733 $array_key.
'_multicurrency_total_ttc_locale' =>
price(
$object->multicurrency_total_ttc, 0, $outputlangs),
735 $array_key.
'_note_private' =>
$object->note_private,
736 $array_key.
'_note_public' =>
$object->note_public,
737 $array_key.
'_note' =>
$object->note_public,
740 $array_key.
'_already_payed_locale' =>
price($sumpayed, 0, $outputlangs),
741 $array_key.
'_already_payed' =>
price2num($sumpayed),
742 $array_key.
'_already_deposit_locale' =>
price($sumdeposit, 0, $outputlangs),
743 $array_key.
'_already_deposit' =>
price2num($sumdeposit),
744 $array_key.
'_already_creditnote_locale' =>
price($sumcreditnote, 0, $outputlangs),
745 $array_key.
'_already_creditnote' =>
price2num($sumcreditnote),
747 $array_key.
'_already_payed_all_locale' =>
price(
price2num($already_payed_all,
'MT'), 0, $outputlangs),
748 $array_key.
'_already_payed_all' =>
price2num($already_payed_all,
'MT'),
751 $array_key.
'_remain_to_pay_locale' =>
price(
price2num(
$object->total_ttc - $already_payed_all,
'MT'), 0, $outputlangs),
752 $array_key.
'_remain_to_pay' =>
price2num(
$object->total_ttc - $already_payed_all,
'MT')
755 if (in_array(
$object->element, array(
'facture',
'invoice',
'supplier_invoice',
'facture_fournisseur'))) {
756 $bank_account =
null;
758 if (property_exists(
$object,
'fk_account') &&
$object->fk_account > 0) {
759 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
760 $bank_account =
new Account($this->db);
761 $bank_account->fetch(
$object->fk_account);
764 $resarray[$array_key.
'_bank_iban'] = (empty($bank_account) ?
'' : $bank_account->iban);
765 $resarray[$array_key.
'_bank_bic'] = (empty($bank_account) ?
'' : $bank_account->bic);
766 $resarray[$array_key.
'_bank_label'] = (empty($bank_account) ?
'' : $bank_account->label);
767 $resarray[$array_key.
'_bank_number'] = (empty($bank_account) ?
'' : $bank_account->number);
768 $resarray[$array_key.
'_bank_proprio'] = (empty($bank_account) ?
'' : $bank_account->owner_name);
769 $resarray[$array_key.
'_bank_address'] = (empty($bank_account) ?
'' : $bank_account->address);
770 $resarray[$array_key.
'_bank_state'] = (empty($bank_account) ?
'' : $bank_account->state);
771 $resarray[$array_key.
'_bank_country'] = (empty($bank_account) ?
'' : $bank_account->country);
774 if (method_exists(
$object,
'getTotalDiscount') && in_array(get_class(
$object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
775 $resarray[$array_key.
'_total_discount_ht_locale'] =
price(
$object->getTotalDiscount(), 0, $outputlangs);
776 $resarray[$array_key.
'_total_discount_ht'] =
price2num(
$object->getTotalDiscount());
778 $resarray[$array_key.
'_total_discount_ht_locale'] =
'';
779 $resarray[$array_key.
'_total_discount_ht'] =
'';
782 if (
$object->element ==
'facture' ||
$object->element ==
'invoice_supplier') {
784 $resarray[$array_key.
'_type_label'] = $outputlangs->transnoentities(
"PdfInvoiceTitle");
786 $resarray[$array_key.
'_type_label'] = (empty(
$object)) ?
'' :
$object->getLibType(0);
792 if (!is_object(
$object->project)) {
796 $resarray[$array_key.
'_project_ref'] =
$object->project->ref;
797 $resarray[$array_key.
'_project_title'] =
$object->project->title;
798 $resarray[$array_key.
'_project_description'] =
$object->project->description;
802 $resarray[$array_key.
'_project_ref'] =
'';
803 $resarray[$array_key.
'_project_title'] =
'';
804 $resarray[$array_key.
'_project_description'] =
'';
805 $resarray[$array_key.
'_project_date_start'] =
'';
806 $resarray[$array_key.
'_project_date_end'] =
'';
813 foreach (
$object->lines as $line) {
815 if (empty($resarray[$array_key.
'_total_vat_'.$line->tva_tx])) {
816 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
818 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
819 $resarray[$array_key.
'_total_vat_locale_'.$line->tva_tx] =
price($resarray[$array_key.
'_total_vat_'.$line->tva_tx]);
821 $vatformated =
vatrate($line->tva_tx);
822 if (empty($resarray[$array_key.
'_total_vat_'.$vatformated])) {
823 $resarray[$array_key.
'_total_vat_'.$vatformated] = 0;
825 $resarray[$array_key.
'_total_vat_'.$vatformated] += $line->total_tva;
826 $resarray[$array_key.
'_total_vat_locale_'.$vatformated] =
price($resarray[$array_key.
'_total_vat_'.$vatformated]);
828 $totalUp += $line->subprice * $line->qty;
833 $resarray[
'object_total_up'] = $totalUp;
834 $resarray[
'object_total_up_locale'] =
price($resarray[
'object_total_up'], 0, $outputlangs);
835 if (method_exists(
$object,
'getTotalDiscount') && in_array(get_class(
$object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
836 $totalDiscount =
$object->getTotalDiscount();
840 if (!empty($totalUp) && !empty($totalDiscount)) {
841 $resarray[
'object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2);
842 $resarray[
'object_total_discount_locale'] =
price($resarray[
'object_total_discount'], 0, $outputlangs);
844 $resarray[
'object_total_discount'] =
'';
845 $resarray[
'object_total_discount_locale'] =
'';
850 if (is_array(
$object->array_options) && count(
$object->array_options)) {
873 'line_pos' => $linenumber,
876 'line_product_ref' => (empty($line->product_ref) ?
'' : $line->product_ref),
877 'line_product_label' => (empty($line->product_label) ?
'' : $line->product_label),
878 'line_product_type' => (empty($line->product_type) ?
'' : $line->product_type),
879 'line_product_barcode' => (empty($line->product_barcode) ?
'' : $line->product_barcode),
880 'line_product_desc' => (empty($line->product_desc) ?
'' : $line->product_desc),
882 'line_desc' => $line->desc,
883 'line_vatrate' =>
vatrate($line->tva_tx,
true, $line->info_bits),
885 'line_up_locale' =>
price($line->subprice, 0, $outputlangs),
886 'line_total_up' =>
price2num($line->subprice * (
float) $line->qty),
887 'line_total_up_locale' =>
price($line->subprice * (
float) $line->qty, 0, $outputlangs),
888 'line_qty' => $line->qty,
889 'line_discount_percent' => ($line->remise_percent ? $line->remise_percent.
'%' :
''),
890 'line_price_ht' =>
price2num($line->total_ht),
891 'line_price_ttc' =>
price2num($line->total_ttc),
892 'line_price_vat' =>
price2num($line->total_tva),
893 'line_price_ht_locale' =>
price($line->total_ht, 0, $outputlangs),
894 'line_price_ttc_locale' =>
price($line->total_ttc, 0, $outputlangs),
895 'line_price_vat_locale' =>
price($line->total_tva, 0, $outputlangs),
897 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
898 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
899 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
900 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
901 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
902 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
903 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
904 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
905 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
908 if (property_exists($line,
'ref_fourn')) {
909 $resarray[
'line_product_ref_fourn'] = $line->ref_fourn;
911 $resarray[
'line_product_ref_fourn'] =
'';
914 'line_localtax1_rate' =>
'localtax1_tx',
915 'line_localtax2_rate' =>
'localtax2_tx',
917 foreach ($vat_specs as $vat_key => $vat_spec) {
918 if (property_exists($line, $vat_spec)) {
920 $resarray[$vat_key] =
vatrate($line->$vat_spec);
926 array(
'line_date_start',
'date_start',
'day',
'auto',
null),
927 array(
'line_date_start_locale',
'date_start',
'day',
'tzserver', $outputlangs),
928 array(
'line_date_start_rfc',
'date_start',
'dayrfc',
'auto',
null),
929 array(
'line_date_start_real',
'date_start_real',
'day',
'auto',
null),
930 array(
'line_date_start_real_locale',
'date_start_real',
'day',
'tzserver', $outputlangs),
931 array(
'line_date_start_real_rfc',
'date_start_real',
'dayrfc',
'auto',
null),
932 array(
'line_date_end',
'date_end',
'day',
'auto',
null),
933 array(
'line_date_end_locale',
'date_end',
'day',
'tzserver', $outputlangs),
934 array(
'line_date_end_rfc',
'date_end',
'dayrfc',
'auto',
null)
936 foreach ($date_specs as $date_spec) {
937 $propertyname = $date_spec[1];
938 if (property_exists($line, $propertyname)) {
940 $resarray[$date_spec[0]] =
dol_print_date($line->$propertyname, $date_spec[2], $date_spec[3], $date_spec[4]);
946 $resarray[
'line_unit'] = $line->getLabelOfUnit(
'long', $outputlangs);
947 $resarray[
'line_unit_short'] = $line->getLabelOfUnit(
'short', $outputlangs);
952 $extrafieldkey = $line->table_element;
954 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
956 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
957 $line->fetch_optionals();
962 if (get_class($line) ==
'CommandeFournisseurLigne') {
964 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
965 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
967 if (!empty($extralabels) && is_array($extralabels)) {
970 foreach ($extralabels as $key => $label) {
971 $columns .=
"$key, ";
974 if ($columns !=
"") {
975 $columns = substr($columns, 0, strlen($columns) - 2);
976 $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).
"'");
978 if ($this->db->num_rows($resql) > 0) {
979 $resql = $this->db->fetch_object($resql);
981 foreach ($extralabels as $key => $label) {
982 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
990 if (get_class($line) ==
'ExpeditionLigne') {
991 $resarray[
'line_qty_shipped'] = $line->qty_shipped;
992 $resarray[
'line_qty_asked'] = $line->qty_asked;
993 $resarray[
'line_weight'] = empty($line->weight) ?
'' : $line->weight * $line->qty_shipped.
' '.
measuringUnitString(0,
'weight', $line->weight_units);
994 $resarray[
'line_length'] = empty($line->length) ?
'' : $line->length * $line->qty_shipped.
' '.
measuringUnitString(0,
'size', $line->length_units);
995 $resarray[
'line_surface'] = empty($line->surface) ?
'' : $line->surface * $line->qty_shipped.
' '.
measuringUnitString(0,
'surface', $line->surface_units);
996 $resarray[
'line_volume'] = empty($line->volume) ?
'' : $line->volume * $line->qty_shipped.
' '.
measuringUnitString(0,
'volume', $line->volume_units);
1000 if (isset($line->fk_product) && $line->fk_product > 0) {
1001 $tmpproduct =
new Product($this->db);
1002 $result = $tmpproduct->fetch($line->fk_product);
1003 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
1004 foreach ($tmpproduct->array_options as $key => $label) {
1005 $resarray[
"line_product_".$key] = $label;
1010 $extrafields->fetch_name_optionals_label(
"product");
1011 if ($extrafields->attributes[
"product"][
'count'] > 0) {
1012 $extralabels = $extrafields->attributes[
"product"][
'label'];
1014 foreach ($extralabels as $key => $label) {
1015 $resarray[
'line_product_options_'.$key] =
'';
1036 global $extrafields;
1038 include_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
1041 $calculatedVolume = ((float)
$object->trueWidth * (
float)
$object->trueHeight * (float)
$object->trueDepth);
1043 $array_shipment = array(
1044 $array_key.
'_id' =>
$object->id,
1045 $array_key.
'_ref' =>
$object->ref,
1046 $array_key.
'_ref_ext' =>
$object->ref_ext,
1047 $array_key.
'_ref_customer' =>
$object->ref_customer,
1054 $array_key.
'_total_discount_ht' =>
price(
$object->getTotalDiscount()),
1055 $array_key.
'_note_private' =>
$object->note_private,
1056 $array_key.
'_note' =>
$object->note_public,
1057 $array_key.
'_tracking_number' =>
$object->tracking_number,
1058 $array_key.
'_tracking_url' =>
$object->tracking_url,
1059 $array_key.
'_shipping_method' =>
$object->listmeths[0][
'libelle'],
1068 foreach (
$object->lines as $line) {
1069 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
1070 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
1072 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
1076 if (is_array(
$object->array_options) && count(
$object->array_options)) {
1083 if (is_object(
$object->commande) && !empty(
$object->commande->ref)) {
1084 $array_shipment[
'order_ref'] =
$object->commande->ref;
1085 $array_shipment[
'order_ref_customer'] =
$object->commande->ref_customer;
1089 $tmparray =
$object->getTotalWeightVolume();
1090 $totalWeight = $tmparray[
'weight'];
1091 $totalVolume = $tmparray[
'volume'];
1092 $totalOrdered = $tmparray[
'ordered'];
1093 $totalToShip = $tmparray[
'toship'];
1101 $array_shipment[$array_key.
'_total_ordered'] = (string) $totalOrdered;
1102 $array_shipment[$array_key.
'_total_toship'] = (string) $totalToShip;
1106 } elseif (!empty($totalWeight)) {
1107 $array_shipment[$array_key.
'_total_weight'] =
showDimensionInBestUnit($totalWeight, 0,
"weight", $outputlangs, -1,
'no', 1);
1109 $array_shipment[$array_key.
'_total_weight'] =
"";
1112 if (!empty(
$object->trueVolume)) {
1113 if (
$object->volume_units < 50) {
1116 $array_shipment[$array_key.
'_total_volume'] = (empty($totalVolume)) ?
'' :
price(
$object->trueVolume, 0, $outputlangs, 0, 0).
' '.
measuringUnitString(0,
"volume",
$object->volume_units);
1118 } elseif (!empty($totalVolume)) {
1119 $array_shipment[$array_key.
'_total_volume'] =
showDimensionInBestUnit($totalVolume, 0,
"volume", $outputlangs, -1,
'no', 1);
1121 $array_shipment[$array_key.
'_total_volume'] =
"";
1124 return $array_shipment;
1140 $array_other = array();
1144 foreach (
$object as $key => $value) {
1145 if (in_array($key, array(
'db',
'fields',
'lines',
'modelpdf',
'model_pdf'))) {
1148 if (!empty($value)) {
1149 if (!is_array($value) && !is_object($value)) {
1150 $array_other[
'object_'.$key] = $value;
1151 } elseif (is_array($value) && $recursive) {
1153 if (!empty($tmparray) && is_array($tmparray)) {
1154 foreach ($tmparray as $key2 => $value2) {
1155 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1158 } elseif (is_object($value) && $recursive) {
1160 if (!empty($tmparray) && is_array($tmparray)) {
1161 foreach ($tmparray as $key2 => $value2) {
1162 $array_other[
'object_'.$key.
'_'.preg_replace(
'/^object_/',
'', $key2)] = $value2;
1170 return $array_other;
1191 if ($extrafields->attributes[
$object->table_element][
'count'] > 0) {
1192 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1193 $formatedarrayoption =
$object->array_options;
1195 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
1196 $formatedarrayoption[
'options_'.$key] =
price2num($formatedarrayoption[
'options_'.$key]);
1197 $formatedarrayoption[
'options_'.$key.
'_currency'] =
price($formatedarrayoption[
'options_'.$key], 0, $outputlangs, 0, 0, -1,
$conf->currency);
1199 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_currency' => $formatedarrayoption[
'options_'.$key.
'_currency']));
1200 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'select') {
1201 $valueofselectkey = $formatedarrayoption[
'options_'.$key];
1202 if (array_key_exists($valueofselectkey, $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'])) {
1203 $formatedarrayoption[
'options_'.$key] = $extrafields->attributes[
$object->table_element][
'param'][$key][
'options'][$valueofselectkey];
1205 $formatedarrayoption[
'options_'.$key] =
'';
1207 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'checkbox') {
1208 $valArray = explode(
',', $formatedarrayoption[
'options_'.$key]);
1210 foreach ($extrafields->attributes[
$object->table_element][
'param'][$key][
'options'] as $keyopt => $valopt) {
1211 if (in_array($keyopt, $valArray)) {
1212 $output[] = $valopt;
1215 $formatedarrayoption[
'options_'.$key] = implode(
', ', $output);
1216 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
1217 if (strlen($formatedarrayoption[
'options_'.$key]) > 0) {
1218 $date = $formatedarrayoption[
'options_'.$key];
1219 $formatedarrayoption[
'options_'.$key] =
dol_print_date($date,
'day');
1220 $formatedarrayoption[
'options_'.$key.
'_locale'] =
dol_print_date($date,
'day',
'tzserver', $outputlangs);
1221 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
dol_print_date($date,
'dayrfc');
1223 $formatedarrayoption[
'options_'.$key] =
'';
1224 $formatedarrayoption[
'options_'.$key.
'_locale'] =
'';
1225 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
'';
1227 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1228 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1229 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
1230 $datetime = $formatedarrayoption[
'options_'.$key];
1231 $formatedarrayoption[
'options_'.$key] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
1232 $formatedarrayoption[
'options_'.$key.
'_locale'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
1233 $formatedarrayoption[
'options_'.$key.
'_rfc'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
1234 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1235 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1236 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'link') {
1237 $id = $formatedarrayoption[
'options_'.$key];
1239 $param = $extrafields->attributes[
$object->table_element][
'param'][$key];
1240 $param_list = array_keys($param[
'options']);
1241 $InfoFieldList = explode(
":", $param_list[0]);
1242 $classname = $InfoFieldList[0];
1243 $classpath = $InfoFieldList[1];
1244 if (!empty($classpath)) {
1246 if ($classname && class_exists($classname)) {
1247 $tmpobject =
new $classname($this->db);
1248 '@phan-var-force CommonObject $tmpobject';
1249 $tmpobject->fetch(
$id);
1251 $formatedarrayoption[
'options_'.$key] = $tmpobject->name;
1257 if (array_key_exists(
'options_'.$key, $formatedarrayoption)) {
1258 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key => $formatedarrayoption[
'options_'.$key]));
1260 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key =>
''));
1265 return $array_to_fill;
1281 public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1283 if (empty($hidetop) || $hidetop == -1) {
1284 $pdf->line($x, $y, $x + $l, $y);
1286 $pdf->line($x + $l, $y, $x + $l, $y + $h);
1287 if (empty($hidebottom)) {
1288 $pdf->line($x + $l, $y + $h, $x, $y + $h);
1290 $pdf->line($x, $y + $h, $x, $y);
1307 public function printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebottom = 0, $style =
'D')
1310 if (empty($hidetop) || $hidetop == -1) {
1311 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1111', $style);
1314 $pdf->RoundedRect($x, $y, $w, $h, $r,
'0111', $style);
1316 if (!empty($hidebottom)) {
1317 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1101', $style);
1327 if (empty($this->afterColsLinePositions) || !is_array($this->afterColsLinePositions)) {
1332 $maxPage = $maxY = 0;
1333 foreach ($this->afterColsLinePositions as $colKey => $value) {
1334 if ($value[
'page'] > $maxPage) {
1336 $maxPage = $value[
'page'];
1337 $maxY = $value[
'y'];
1338 } elseif ($value[
'page'] == $maxPage) {
1339 $maxY = max($value[
'y'], $maxY);
1359 $this->afterColsLinePositions = [];
1372 $this->afterColsLinePositions[$colId] = [
1373 'page' => $pageNumb,
1388 if (empty($a[
'rank'])) {
1391 if (empty($b[
'rank'])) {
1394 if ($a[
'rank'] == $b[
'rank']) {
1397 return ($a[
'rank'] > $b[
'rank']) ? -1 : 1;
1416 uasort($this->cols, array($this,
'columnSort'));
1419 $curX = $this->page_largeur - $this->marge_droite;
1422 $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche;
1425 $totalDefinedColWidth = 0;
1427 foreach ($this->cols as $colKey => & $colDef) {
1432 if (!empty($colDef[
'scale'])) {
1434 $colDef[
'width'] = abs($arrayWidth * $colDef[
'scale'] / 100);
1437 if (empty($colDef[
'width'])) {
1440 $totalDefinedColWidth += $colDef[
'width'];
1444 foreach ($this->cols as $colKey => & $colDef) {
1446 if (!empty($colDef[
'title'])) {
1447 $colDef[
'title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef[
'title']);
1449 $colDef[
'title'] = $this->defaultTitlesFieldsStyle;
1453 if (!empty($colDef[
'content'])) {
1454 $colDef[
'content'] = array_replace($this->defaultContentsFieldsStyle, $colDef[
'content']);
1456 $colDef[
'content'] = $this->defaultContentsFieldsStyle;
1461 if (empty($colDef[
'width'])) {
1462 $colDef[
'width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
1467 $curX = $lastX - $colDef[
'width'];
1468 $colDef[
'xStartPos'] = $curX;
1469 $colDef[
'xEndPos'] = $lastX;
1482 $colDef = $this->cols[$colKey];
1483 return $colDef[
'width'] - $colDef[
'content'][
'padding'][3] - $colDef[
'content'][
'padding'][1];
1495 $colDef = (isset($this->cols[$colKey]) ? $this->cols[$colKey] :
null);
1496 return (is_array($colDef) ? ((isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0) + $colDef[
'content'][
'padding'][3]) : 0);
1507 if (!isset($this->cols[$colKey][
'rank'])) {
1510 return $this->cols[$colKey][
'rank'];
1528 if (!empty($targetCol)) {
1530 if ($rank >= 0 && $insertAfterTarget) {
1536 if ($rank < 0 && !empty($defArray[
'rank'])) {
1537 $rank = $defArray[
'rank'];
1545 foreach ($this->cols as $colKey => & $colDef) {
1546 if ($rank <= $colDef[
'rank']) {
1547 $colDef[
'rank'] += 1;
1551 $defArray[
'rank'] = $rank;
1552 $this->cols[$newColKey] = $defArray;
1569 global $hookmanager;
1571 $parameters = array(
1573 'columnText' => $columnText,
1574 'colKey' => $colKey,
1577 $reshook = $hookmanager->executeHooks(
'printStdColumnContent', $parameters, $this);
1582 if (empty($columnText)) {
1586 $colDef = $this->cols[$colKey];
1588 $curentCellPaddinds = $pdf->getCellPaddings();
1590 $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);
1591 $pdf->writeHTMLCell($colDef[
'width'], 2, isset($colDef[
'xStartPos']) ? $colDef[
'xStartPos'] : 0, $curY, $columnText, 0, 1,
false,
true, $colDef[
'content'][
'align']);
1595 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1619 $colDef = $this->cols[$colKey];
1621 $curentCellPaddinds = $pdf->getCellPaddings();
1623 $pdf->setCellPaddings($colDef[
'content'][
'padding'][3], $colDef[
'content'][
'padding'][0], $colDef[
'content'][
'padding'][1], $colDef[
'content'][
'padding'][2]);
1626 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $colDef[
'width'], 3, $colDef[
'xStartPos'], $curY, $hideref, $hidedesc, $issupplierline, empty($colDef[
'content'][
'align']) ?
'J' : $colDef[
'content'][
'align']);
1627 $posYAfterDescription = $pdf->GetY() - $colDef[
'content'][
'padding'][0];
1630 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1634 'display' =>
'list',
1635 'printableEnable' => array(3),
1636 'printableEnableNotEmpty' => array(4)
1638 $extrafieldDesc = $this->getExtrafieldsInHtml(
$object->lines[$i], $outputlangs, $params);
1639 if (!empty($extrafieldDesc)) {
1655 global $hookmanager;
1657 if (empty(
$object->table_element)) {
1661 $extrafieldsKeyPrefix =
"options_";
1664 $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
1666 $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
1669 $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
1673 if (is_null($this->extrafieldsCache)) {
1674 $this->extrafieldsCache =
new ExtraFields($this->db);
1676 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1677 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1679 $extrafields = $this->extrafieldsCache;
1681 $extrafieldOutputContent =
'';
1682 if (isset(
$object->array_options[$extrafieldOptionsKey])) {
1683 $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey,
$object->array_options[$extrafieldOptionsKey],
'',
$object->table_element, $outputlangs);
1687 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'link') {
1693 if ($extrafields->attributes[
$object->table_element][
'type'][$extrafieldKey] ==
'stars') {
1694 $extrafieldOutputContent =
'';
1695 for ($i = 0; $i <
$object->array_options[$extrafieldOptionsKey]; $i++) {
1696 $extrafieldOutputContent .=
' *';
1700 $parameters = array(
1702 'extrafields' => $extrafields,
1703 'extrafieldKey' => $extrafieldKey,
1704 'extrafieldOutputContent' => & $extrafieldOutputContent
1706 $reshook = $hookmanager->executeHooks(
'getPDFExtrafieldContent', $parameters, $this);
1711 $extrafieldOutputContent = $hookmanager->resPrint;
1714 return $extrafieldOutputContent;
1726 public function getExtrafieldsInHtml(
$object, $outputlangs, $params = array())
1728 global $hookmanager;
1730 if (empty(
$object->table_element)) {
1735 if (is_null($this->extrafieldsCache)) {
1736 $this->extrafieldsCache =
new ExtraFields($this->db);
1738 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
1739 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
1741 $extrafields = $this->extrafieldsCache;
1743 $defaultParams = array(
1745 'display' =>
'auto',
1746 'printableEnable' => array(1),
1747 'printableEnableNotEmpty' => array(2),
1750 'maxItemsInRow' => 2,
1754 'labelcolwidth' =>
'25%',
1755 'arrayOfLineBreakType' => array(
'text',
'html')
1759 'separator' =>
'<br>'
1768 $params += $defaultParams;
1777 if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
1778 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
1781 if (!empty($extrafields->attributes[
$object->table_element][
'enabled'][$key])) {
1782 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'2');
1791 $disableOnEmpty = 0;
1793 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
1794 $printable = (int) $extrafields->attributes[
$object->table_element][
'printable'][$key];
1795 if (in_array($printable, $params[
'printableEnable']) || in_array($printable, $params[
'printableEnableNotEmpty'])) {
1799 if (in_array($printable, $params[
'printableEnableNotEmpty'])) {
1800 $disableOnEmpty = 1;
1804 if (empty($enabled) || empty($printable)) {
1809 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1810 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1814 $field->rank = intval($extrafields->attributes[
$object->table_element][
'pos'][$key]);
1816 if (isset($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
1817 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
1819 $field->label = $outputlangs->transnoentities($label);
1820 $field->type = $extrafields->attributes[
$object->table_element][
'type'][$key];
1823 if ($disableOnEmpty && empty($field->content)) {
1831 if (!empty($fields)) {
1840 static function ($a, $b) {
1841 return ($a->rank > $b->rank) ? 1 : -1;
1846 $html .= !empty($params[
'style']) ?
'<style>'.$params[
'style'].
'</style>' :
'';
1849 if ($params[
'display'] ==
'auto') {
1850 $lastNnumbItems = 0;
1851 foreach ($params[
'auto'] as $display => $numbItems) {
1852 if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) {
1853 $lastNnumbItems = $numbItems;
1854 $params[
'display'] = $display;
1859 if ($params[
'display'] ==
'list') {
1862 foreach ($fields as $field) {
1863 $html .= !empty($i) ? $params[
'list'][
'separator'] :
'';
1864 $html .=
'<strong>'.$field->label.
' : </strong>';
1865 $html .= $field->content;
1868 } elseif ($params[
'display'] ==
'table') {
1870 $html .=
'<table class="extrafield-table" cellspacing="'.$params[
'table'][
'cellspacing'].
'" cellpadding="'.$params[
'table'][
'cellpadding'].
'" border="'.$params[
'table'][
'border'].
'">';
1874 $maxItemsInRow = $params[
'table'][
'maxItemsInRow'];
1875 foreach ($fields as $field) {
1877 if ($itemsInRow >= $maxItemsInRow) {
1879 $html .=
"</tr><tr>";
1884 if (in_array($field->type, $params[
'table'][
'arrayOfLineBreakType'])) {
1885 if ($itemsInRow > 0) {
1887 for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) {
1888 $html .=
"<td></td><td></td>";
1896 $itemsInRow = $maxItemsInRow;
1897 $html .=
'<td colspan="'.($maxItemsInRow * 2 - 1).
'">';
1898 $html .=
'<strong>'.$field->label.
' :</strong> ';
1899 $html .= $field->content;
1903 $html .=
'<td width="'.$params[
'table'][
'labelcolwidth'].
'" class="extrafield-label">';
1904 $html .=
'<strong>'.$field->label.
' :</strong>';
1908 $html .=
'<td class="extrafield-content">';
1909 $html .= $field->content;
1915 $html .=
'</table>';
1931 if (!empty($this->cols[$colKey][
'status'])) {
1948 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1950 global $hookmanager,
$conf;
1952 foreach ($this->cols as $colKey => $colDef) {
1953 $parameters = array(
1954 'colKey' => $colKey,
1956 'outputlangs' => $outputlangs,
1957 'tab_top' => $tab_top,
1958 'tab_height' => $tab_height,
1959 'hidetop' => $hidetop
1962 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
1965 } elseif (empty($reshook)) {
1971 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1974 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
1975 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1978 if (empty($hidetop)) {
1980 $curentCellPaddinds = $pdf->getCellPaddings();
1983 global $outputlangsbis;
1984 if (is_object($outputlangsbis)) {
1986 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
1989 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1991 if (isset($colDef[
'title'][
'align'])) {
1992 $align = $colDef[
'title'][
'align'];
1996 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
1997 $textWidth = $colDef[
'width'];
1998 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
2001 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
2002 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
2003 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
2004 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
2005 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
2008 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
2011 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
2016 return $this->tabTitleHeight;
2031 if (!empty($hidedetails)) {
2035 if (empty(
$object->table_element)) {
2040 if (is_null($this->extrafieldsCache)) {
2041 $this->extrafieldsCache =
new ExtraFields($this->db);
2043 if (empty($this->extrafieldsCache->attributes[
$object->table_element])) {
2044 $this->extrafieldsCache->fetch_name_optionals_label(
$object->table_element);
2046 $extrafields = $this->extrafieldsCache;
2049 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'])) {
2050 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
2052 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'separate') {
2058 if (!empty($extrafields->attributes[
$object->table_element][
'printable'][$key])) {
2059 $printable = intval($extrafields->attributes[
$object->table_element][
'printable'][$key]);
2060 if ($printable === 1 || $printable === 2) {
2071 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$key])) {
2072 $outputlangs->load($extrafields->attributes[
$object->table_element][
'langfile'][$key]);
2079 'rank' => intval($extrafields->attributes[
$object->table_element][
'pos'][$key]),
2081 'status' => (
bool) $enabled,
2083 'label' => $outputlangs->transnoentities($label)
2088 'border-left' =>
true,
2091 $alignTypeRight = array(
'double',
'int',
'price');
2092 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeRight)) {
2093 $def[
'content'][
'align'] =
'R';
2096 $alignTypeLeft = array(
'text',
'html');
2097 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$key], $alignTypeLeft)) {
2098 $def[
'content'][
'align'] =
'L';
2124 $this->defaultContentsFieldsStyle = array(
2126 'padding' => array(1, 0.5, 1, 0.5),
2130 $this->defaultTitlesFieldsStyle = array(
2132 'padding' => array(0.5, 0, 0.5, 0),
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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_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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.