514 global $conf, $extrafields;
516 $sumpayed = $sumdeposit = $sumcreditnote =
'';
517 $already_payed_all = 0;
519 if ($object->element ==
'facture') {
520 $invoice_source =
new Facture($this->db);
521 if ($object->fk_facture_source > 0) {
522 $invoice_source->fetch($object->fk_facture_source);
524 $sumpayed = $object->getSommePaiement();
525 $sumdeposit = $object->getSumDepositsUsed();
526 $sumcreditnote = $object->getSumCreditNotesUsed();
527 $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
530 $date = (isset($object->element) && $object->element ==
'contrat' && isset($object->date_contrat)) ? $object->date_contrat : (isset($object->date) ? $object->date :
null);
532 if (get_class($object) ==
'CommandeFournisseur') {
534 $object->date_validation = $object->date_valid;
535 $object->date_commande = $object->date;
538 $array_key.
'_id'=>$object->id,
539 $array_key.
'_ref' => (property_exists($object,
'ref') ? $object->ref :
''),
540 $array_key.
'_label' => (property_exists($object,
'label') ? $object->label :
''),
541 $array_key.
'_ref_ext' => (property_exists($object,
'ref_ext') ? $object->ref_ext :
''),
542 $array_key.
'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ?
'' : $object->ref_customer)),
543 $array_key.
'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ?
'' : $object->ref_supplier)),
544 $array_key.
'_source_invoice_ref'=>((empty($invoice_source) || empty($invoice_source->ref)) ?
'' : $invoice_source->ref),
549 $array_key.
'_date_limit'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day') :
''),
550 $array_key.
'_date_limit_rfc'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'dayrfc') :
''),
551 $array_key.
'_date_end'=>(!empty($object->fin_validite) ?
dol_print_date($object->fin_validite,
'day') :
''),
552 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
553 $array_key.
'_date_modification'=>(!empty($object->date_modification) ?
dol_print_date($object->date_modification,
'day') :
''),
554 $array_key.
'_date_validation'=>(!empty($object->date_validation) ?
dol_print_date($object->date_validation,
'dayhour') :
''),
555 $array_key.
'_date_approve'=>(!empty($object->date_approve) ?
dol_print_date($object->date_approve,
'day') :
''),
556 $array_key.
'_date_delivery_planed'=>(!empty($object->delivery_date) ?
dol_print_date($object->delivery_date,
'day') :
''),
557 $array_key.
'_date_close'=>(!empty($object->date_cloture) ?
dol_print_date($object->date_cloture,
'dayhour') :
''),
559 $array_key.
'_payment_mode_code'=>$object->mode_reglement_code,
560 $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),
561 $array_key.
'_payment_term_code'=>$object->cond_reglement_code,
562 $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 ? $object->cond_reglement_doc : $object->cond_reglement)),
564 $array_key.
'_incoterms' => (method_exists($object,
'display_incoterms') ? $object->display_incoterms() :
''),
566 $array_key.
'_total_ht_locale'=>
price($object->total_ht, 0, $outputlangs),
567 $array_key.
'_total_vat_locale'=>(!empty($object->total_vat) ?
price($object->total_vat, 0, $outputlangs) :
price($object->total_tva, 0, $outputlangs)),
568 $array_key.
'_total_localtax1_locale'=>
price($object->total_localtax1, 0, $outputlangs),
569 $array_key.
'_total_localtax2_locale'=>
price($object->total_localtax2, 0, $outputlangs),
570 $array_key.
'_total_ttc_locale'=>
price($object->total_ttc, 0, $outputlangs),
572 $array_key.
'_total_ht'=>
price2num($object->total_ht),
573 $array_key.
'_total_vat'=>(!empty($object->total_vat) ?
price2num($object->total_vat) :
price2num($object->total_tva)),
574 $array_key.
'_total_localtax1'=>
price2num($object->total_localtax1),
575 $array_key.
'_total_localtax2'=>
price2num($object->total_localtax2),
576 $array_key.
'_total_ttc'=>
price2num($object->total_ttc),
578 $array_key.
'_multicurrency_code' => $object->multicurrency_code,
579 $array_key.
'_multicurrency_tx' =>
price2num($object->multicurrency_tx),
580 $array_key.
'_multicurrency_total_ht' =>
price2num($object->multicurrency_total_ht),
581 $array_key.
'_multicurrency_total_tva' =>
price2num($object->multicurrency_total_tva),
582 $array_key.
'_multicurrency_total_ttc' =>
price2num($object->multicurrency_total_ttc),
583 $array_key.
'_multicurrency_total_ht_locale' =>
price($object->multicurrency_total_ht, 0, $outputlangs),
584 $array_key.
'_multicurrency_total_tva_locale' =>
price($object->multicurrency_total_tva, 0, $outputlangs),
585 $array_key.
'_multicurrency_total_ttc_locale' =>
price($object->multicurrency_total_ttc, 0, $outputlangs),
587 $array_key.
'_note_private'=>$object->note_private,
588 $array_key.
'_note_public'=>$object->note_public,
589 $array_key.
'_note'=>$object->note_public,
592 $array_key.
'_already_payed_locale'=>
price($sumpayed, 0, $outputlangs),
593 $array_key.
'_already_payed'=>
price2num($sumpayed),
594 $array_key.
'_already_deposit_locale'=>
price($sumdeposit, 0, $outputlangs),
595 $array_key.
'_already_deposit'=>
price2num($sumdeposit),
596 $array_key.
'_already_creditnote_locale'=>
price($sumcreditnote, 0, $outputlangs),
597 $array_key.
'_already_creditnote'=>
price2num($sumcreditnote),
599 $array_key.
'_already_payed_all_locale'=>
price(
price2num($already_payed_all,
'MT'), 0, $outputlangs),
600 $array_key.
'_already_payed_all'=>
price2num($already_payed_all,
'MT'),
603 $array_key.
'_remain_to_pay_locale'=>
price(
price2num($object->total_ttc - $already_payed_all,
'MT'), 0, $outputlangs),
604 $array_key.
'_remain_to_pay'=>
price2num($object->total_ttc - $already_payed_all,
'MT')
607 if (in_array($object->element, array(
'facture',
'invoice',
'supplier_invoice',
'facture_fournisseur'))) {
608 $bank_account =
null;
610 if (property_exists($object,
'fk_account') && $object->fk_account > 0) {
611 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
612 $bank_account =
new Account($this->db);
613 $bank_account->fetch($object->fk_account);
616 $resarray[$array_key.
'_bank_iban'] = (empty($bank_account) ?
'' : $bank_account->iban);
617 $resarray[$array_key.
'_bank_bic'] = (empty($bank_account) ?
'' : $bank_account->bic);
618 $resarray[$array_key.
'_bank_label'] = (empty($bank_account) ?
'' : $bank_account->label);
619 $resarray[$array_key.
'_bank_number'] = (empty($bank_account) ?
'' : $bank_account->number);
620 $resarray[$array_key.
'_bank_proprio'] =(empty($bank_account) ?
'' : $bank_account->proprio);
623 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
624 $resarray[$array_key.
'_total_discount_ht_locale'] =
price($object->getTotalDiscount(), 0, $outputlangs);
625 $resarray[$array_key.
'_total_discount_ht'] =
price2num($object->getTotalDiscount());
627 $resarray[$array_key.
'_total_discount_ht_locale'] =
'';
628 $resarray[$array_key.
'_total_discount_ht'] =
'';
632 if ($object->element !=
"project" && !empty($object->fk_project) && $object->fk_project > 0) {
633 if (!is_object($object->project)) {
634 $object->fetch_projet();
637 $resarray[$array_key.
'_project_ref'] = $object->project->ref;
638 $resarray[$array_key.
'_project_title'] = $object->project->title;
639 $resarray[$array_key.
'_project_description'] = $object->project->description;
640 $resarray[$array_key.
'_project_date_start'] =
dol_print_date($object->project->date_start,
'day');
641 $resarray[$array_key.
'_project_date_end'] =
dol_print_date($object->project->date_end,
'day');
643 $resarray[$array_key.
'_project_ref'] =
'';
644 $resarray[$array_key.
'_project_title'] =
'';
645 $resarray[$array_key.
'_project_description'] =
'';
646 $resarray[$array_key.
'_project_date_start'] =
'';
647 $resarray[$array_key.
'_project_date_end'] =
'';
651 if (is_array($object->lines) && count($object->lines) > 0) {
654 foreach ($object->lines as $line) {
656 if (empty($resarray[$array_key.
'_total_vat_'.$line->tva_tx])) {
657 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
659 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
660 $resarray[$array_key.
'_total_vat_locale_'.$line->tva_tx] =
price($resarray[$array_key.
'_total_vat_'.$line->tva_tx]);
662 $vatformated =
vatrate($line->tva_tx);
663 if (empty($resarray[$array_key.
'_total_vat_'.$vatformated])) {
664 $resarray[$array_key.
'_total_vat_'.$vatformated] = 0;
666 $resarray[$array_key.
'_total_vat_'.$vatformated] += $line->total_tva;
667 $resarray[$array_key.
'_total_vat_locale_'.$vatformated] =
price($resarray[$array_key.
'_total_vat_'.$vatformated]);
669 $totalUp += $line->subprice * $line->qty;
674 $resarray[
'object_total_up'] = $totalUp;
675 $resarray[
'object_total_up_locale'] =
price($resarray[
'object_total_up'], 0, $outputlangs);
676 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
677 $totalDiscount = $object->getTotalDiscount();
681 if (!empty($totalUp) && !empty($totalDiscount)) {
682 $resarray[
'object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2);
683 $resarray[
'object_total_discount_locale'] =
price($resarray[
'object_total_discount'], 0, $outputlangs);
685 $resarray[
'object_total_discount'] =
'';
686 $resarray[
'object_total_discount_locale'] =
'';
691 if (is_array($object->array_options) && count($object->array_options)) {
692 $object->fetch_optionals();
714 'line_pos' => $linenumber,
717 'line_product_ref'=>(empty($line->product_ref) ?
'' : $line->product_ref),
718 'line_product_ref_fourn'=>(empty($line->ref_fourn) ?
'' : $line->ref_fourn),
719 'line_product_label'=>(empty($line->product_label) ?
'' : $line->product_label),
720 'line_product_type'=>(empty($line->product_type) ?
'' : $line->product_type),
721 'line_product_barcode'=>(empty($line->product_barcode) ?
'' : $line->product_barcode),
722 'line_product_desc'=>(empty($line->product_desc) ?
'' : $line->product_desc),
724 'line_desc'=>$line->desc,
725 'line_vatrate'=>
vatrate($line->tva_tx,
true, $line->info_bits),
726 'line_localtax1_rate'=>
vatrate($line->localtax1_tx),
727 'line_localtax2_rate'=>
vatrate($line->localtax1_tx),
729 'line_up_locale'=>
price($line->subprice, 0, $outputlangs),
730 'line_total_up'=>
price2num($line->subprice * $line->qty),
731 'line_total_up_locale'=>
price($line->subprice * $line->qty, 0, $outputlangs),
732 'line_qty'=>$line->qty,
733 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.
'%' :
''),
734 'line_price_ht'=>
price2num($line->total_ht),
735 'line_price_ttc'=>
price2num($line->total_ttc),
736 'line_price_vat'=>
price2num($line->total_tva),
737 'line_price_ht_locale'=>
price($line->total_ht, 0, $outputlangs),
738 'line_price_ttc_locale'=>
price($line->total_ttc, 0, $outputlangs),
739 'line_price_vat_locale'=>
price($line->total_tva, 0, $outputlangs),
742 'line_date_start_locale'=>
dol_print_date($line->date_start,
'day',
'tzserver', $outputlangs),
743 'line_date_start_rfc'=>
dol_print_date($line->date_start,
'dayrfc'),
745 'line_date_end_locale'=>
dol_print_date($line->date_end,
'day',
'tzserver', $outputlangs),
748 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
749 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
750 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
751 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
752 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
753 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
754 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
755 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
756 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
761 $resarray[
'line_unit'] = $outputlangs->trans($line->getLabelOfUnit(
'long'));
762 $resarray[
'line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit(
'short'));
766 $extrafieldkey = $line->table_element;
768 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
770 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
771 $line->fetch_optionals();
776 if (get_class($line) ==
'CommandeFournisseurLigne') {
778 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
779 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
781 if (!empty($extralabels) && is_array($extralabels)) {
784 foreach ($extralabels as $key => $label) {
785 $columns .=
"$key, ";
788 if ($columns !=
"") {
789 $columns = substr($columns, 0, strlen($columns) - 2);
790 $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).
"'");
792 if ($this->db->num_rows($resql) > 0) {
793 $resql = $this->db->fetch_object($resql);
795 foreach ($extralabels as $key => $label) {
796 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
804 if (isset($line->fk_product) && $line->fk_product > 0) {
805 $tmpproduct =
new Product($this->db);
806 $result = $tmpproduct->fetch($line->fk_product);
807 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
808 foreach ($tmpproduct->array_options as $key => $label) {
809 $resarray[
"line_product_".$key] = $label;
814 $extrafields->fetch_name_optionals_label(
"product");
815 $extralabels = $extrafields->attributes[
"product"][
'label'];
817 if (!empty($extralabels) && is_array($extralabels)) {
818 foreach ($extralabels as $key => $label) {
819 $resarray[
'line_product_options_'.$key] =
'';
840 global $conf, $extrafields;
842 $object->list_delivery_methods($object->shipping_method_id);
843 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
845 $array_shipment = array(
846 $array_key.
'_id'=>$object->id,
847 $array_key.
'_ref'=>$object->ref,
848 $array_key.
'_ref_ext'=>$object->ref_ext,
849 $array_key.
'_ref_customer'=>$object->ref_customer,
850 $array_key.
'_date_delivery'=>
dol_print_date($object->date_delivery,
'day'),
851 $array_key.
'_hour_delivery'=>
dol_print_date($object->date_delivery,
'hour'),
852 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
853 $array_key.
'_total_ht'=>
price($object->total_ht),
854 $array_key.
'_total_vat'=>
price($object->total_tva),
855 $array_key.
'_total_ttc'=>
price($object->total_ttc),
856 $array_key.
'_total_discount_ht' =>
price($object->getTotalDiscount()),
857 $array_key.
'_note_private'=>$object->note_private,
858 $array_key.
'_note'=>$object->note_public,
859 $array_key.
'_tracking_number'=>$object->tracking_number,
860 $array_key.
'_tracking_url'=>$object->tracking_url,
861 $array_key.
'_shipping_method'=>$object->listmeths[0][
'libelle'],
862 $array_key.
'_weight'=>$object->trueWeight.
' '.
measuringUnitString(0,
'weight', $object->weight_units),
863 $array_key.
'_width'=>$object->trueWidth.
' '.
measuringUnitString(0,
'size', $object->width_units),
864 $array_key.
'_height'=>$object->trueHeight.
' '.
measuringUnitString(0,
'size', $object->height_units),
865 $array_key.
'_depth'=>$object->trueDepth.
' '.
measuringUnitString(0,
'size', $object->depth_units),
870 foreach ($object->lines as $line) {
871 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
872 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
874 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
878 if (is_array($object->array_options) && count($object->array_options)) {
879 $object->fetch_optionals();
885 if (!empty($object->commande) && is_object($object->commande)) {
886 $array_shipment[
'order_ref'] = $object->commande->ref;
887 $array_shipment[
'order_ref_customer'] = $object->commande->ref_customer;
890 return $array_shipment;
957 if (is_array($extrafields->attributes[$object->table_element][
'label'])) {
958 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
959 $formatedarrayoption = $object->array_options;
961 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
962 $formatedarrayoption[
'options_'.$key] =
price2num($formatedarrayoption[
'options_'.$key]);
963 $formatedarrayoption[
'options_'.$key.
'_currency'] =
price($formatedarrayoption[
'options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
965 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_currency' => $formatedarrayoption[
'options_'.$key.
'_currency']));
966 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'select') {
967 $valueofselectkey = $formatedarrayoption[
'options_'.$key];
968 if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element][
'param'][$key][
'options'])) {
969 $formatedarrayoption[
'options_'.$key] = $extrafields->attributes[$object->table_element][
'param'][$key][
'options'][$valueofselectkey];
971 $formatedarrayoption[
'options_'.$key] =
'';
973 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'checkbox') {
974 $valArray = explode(
',', $formatedarrayoption[
'options_'.$key]);
976 foreach ($extrafields->attributes[$object->table_element][
'param'][$key][
'options'] as $keyopt => $valopt) {
977 if (in_array($keyopt, $valArray)) {
981 $formatedarrayoption[
'options_'.$key] = implode(
', ', $output);
982 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
983 if (strlen($formatedarrayoption[
'options_'.$key]) > 0) {
984 $date = $formatedarrayoption[
'options_'.$key];
985 $formatedarrayoption[
'options_'.$key] =
dol_print_date($date,
'day');
986 $formatedarrayoption[
'options_'.$key.
'_locale'] =
dol_print_date($date,
'day',
'tzserver', $outputlangs);
987 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
dol_print_date($date,
'dayrfc');
989 $formatedarrayoption[
'options_'.$key] =
'';
990 $formatedarrayoption[
'options_'.$key.
'_locale'] =
'';
991 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
'';
993 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
994 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
995 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
996 $datetime = $formatedarrayoption[
'options_'.$key];
997 $formatedarrayoption[
'options_'.$key] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
998 $formatedarrayoption[
'options_'.$key.
'_locale'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
999 $formatedarrayoption[
'options_'.$key.
'_rfc'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
1000 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1001 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1002 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'link') {
1003 $id = $formatedarrayoption[
'options_'.$key];
1005 $param = $extrafields->attributes[$object->table_element][
'param'][$key];
1006 $param_list = array_keys($param[
'options']);
1007 $InfoFieldList = explode(
":", $param_list[0]);
1008 $classname = $InfoFieldList[0];
1009 $classpath = $InfoFieldList[1];
1010 if (!empty($classpath)) {
1012 if ($classname && class_exists($classname)) {
1013 $tmpobject =
new $classname($this->db);
1014 $tmpobject->fetch($id);
1016 $formatedarrayoption[
'options_'.$key] = $tmpobject->name;
1022 if (array_key_exists(
'options_'.$key, $formatedarrayoption)) {
1023 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key => $formatedarrayoption[
'options_'.$key]));
1025 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key =>
''));
1030 return $array_to_fill;
1334 global $hookmanager;
1336 if (empty($object->table_element)) {
1340 $extrafieldsKeyPrefix =
"options_";
1343 $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
1345 $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
1348 $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
1352 if (empty($this->extrafieldsCache)) {
1353 $this->extrafieldsCache =
new ExtraFields($this->db);
1355 if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
1356 $this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
1358 $extrafields = $this->extrafieldsCache;
1360 $extrafieldOutputContent =
'';
1361 if (isset($object->array_options[$extrafieldOptionsKey])) {
1362 $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey],
'', $object->table_element, $outputlangs);
1366 if ($extrafields->attributes[$object->table_element][
'type'][$extrafieldKey] ==
'link') {
1371 $parameters = array(
1372 'object' => $object,
1373 'extrafields' => $extrafields,
1374 'extrafieldKey' => $extrafieldKey,
1375 'extrafieldOutputContent' =>& $extrafieldOutputContent
1377 $reshook = $hookmanager->executeHooks(
'getPDFExtrafieldContent', $parameters, $this);
1382 $extrafieldOutputContent = $hookmanager->resPrint;
1385 return $extrafieldOutputContent;
1600 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1602 global $hookmanager, $conf;
1604 foreach ($this->cols as $colKey => $colDef) {
1605 $parameters = array(
1606 'colKey' => $colKey,
1608 'outputlangs' => $outputlangs,
1609 'tab_top' => $tab_top,
1610 'tab_height' => $tab_height,
1611 'hidetop' => $hidetop
1614 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
1617 } elseif (empty($reshook)) {
1623 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1626 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
1627 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1630 if (empty($hidetop)) {
1632 $curentCellPaddinds = $pdf->getCellPaddings();
1635 global $outputlangsbis;
1636 if (is_object($outputlangsbis)) {
1638 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
1641 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1643 if (isset($colDef[
'title'][
'align'])) {
1644 $align = $colDef[
'title'][
'align'];
1648 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
1649 $textWidth = $colDef[
'width'];
1650 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
1653 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
1654 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1655 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
1656 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
1657 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
1660 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
1663 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1668 return $this->tabTitleHeight;
1683 if (!empty($hidedetails)) {
1687 if (empty($object->table_element)) {
1692 if (empty($this->extrafieldsCache)) {
1693 $this->extrafieldsCache =
new ExtraFields($this->db);
1695 if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
1696 $this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
1698 $extrafields = $this->extrafieldsCache;
1701 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'])) {
1702 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
1704 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'separate') {
1710 if (!empty($extrafields->attributes[$object->table_element][
'printable'][$key])) {
1711 $printable = intval($extrafields->attributes[$object->table_element][
'printable'][$key]);
1712 if ($printable === 1 || $printable === 2) {
1723 if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$key])) {
1724 $outputlangs->load($extrafields->attributes[$object->table_element][
'langfile'][$key]);
1731 'rank' => intval($extrafields->attributes[$object->table_element][
'pos'][$key]),
1733 'status' => (
bool) $enabled,
1735 'label' => $outputlangs->transnoentities($label)
1740 'border-left' =>
true,
1743 $alignTypeRight = array(
'double',
'int',
'price');
1744 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeRight)) {
1745 $def[
'content'][
'align'] =
'R';
1748 $alignTypeLeft = array(
'text',
'html');
1749 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeLeft)) {
1750 $def[
'content'][
'align'] =
'L';