518 global $conf, $extrafields;
520 $sumpayed = $sumdeposit = $sumcreditnote =
'';
521 $already_payed_all = 0;
523 if ($object->element ==
'facture') {
524 $invoice_source =
new Facture($this->db);
525 if ($object->fk_facture_source > 0) {
526 $invoice_source->fetch($object->fk_facture_source);
528 $sumpayed = $object->getSommePaiement();
529 $sumdeposit = $object->getSumDepositsUsed();
530 $sumcreditnote = $object->getSumCreditNotesUsed();
531 $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
534 $date = (isset($object->element) && $object->element ==
'contrat' && isset($object->date_contrat)) ? $object->date_contrat : (isset($object->date) ? $object->date :
null);
536 if (get_class($object) ==
'CommandeFournisseur') {
538 $object->date_validation = $object->date_valid;
539 $object->date_commande = $object->date;
542 $array_key.
'_id'=>$object->id,
543 $array_key.
'_ref' => (property_exists($object,
'ref') ? $object->ref :
''),
544 $array_key.
'_label' => (property_exists($object,
'label') ? $object->label :
''),
545 $array_key.
'_ref_ext' => (property_exists($object,
'ref_ext') ? $object->ref_ext :
''),
546 $array_key.
'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ?
'' : $object->ref_customer)),
547 $array_key.
'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ?
'' : $object->ref_supplier)),
548 $array_key.
'_source_invoice_ref'=>((empty($invoice_source) || empty($invoice_source->ref)) ?
'' : $invoice_source->ref),
553 $array_key.
'_date_limit'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day') :
''),
554 $array_key.
'_date_limit_rfc'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'dayrfc') :
''),
555 $array_key.
'_date_end'=>(!empty($object->fin_validite) ?
dol_print_date($object->fin_validite,
'day') :
''),
556 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
557 $array_key.
'_date_modification'=>(!empty($object->date_modification) ?
dol_print_date($object->date_modification,
'day') :
''),
558 $array_key.
'_date_validation'=>(!empty($object->date_validation) ?
dol_print_date($object->date_validation,
'dayhour') :
''),
559 $array_key.
'_date_approve'=>(!empty($object->date_approve) ?
dol_print_date($object->date_approve,
'day') :
''),
560 $array_key.
'_date_delivery_planed'=>(!empty($object->delivery_date) ?
dol_print_date($object->delivery_date,
'day') :
''),
561 $array_key.
'_date_close'=>(!empty($object->date_cloture) ?
dol_print_date($object->date_cloture,
'dayhour') :
''),
563 $array_key.
'_payment_mode_code'=>$object->mode_reglement_code,
564 $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),
565 $array_key.
'_payment_term_code'=>$object->cond_reglement_code,
566 $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)),
568 $array_key.
'_incoterms' => (method_exists($object,
'display_incoterms') ? $object->display_incoterms() :
''),
570 $array_key.
'_total_ht_locale'=>
price($object->total_ht, 0, $outputlangs),
571 $array_key.
'_total_vat_locale'=>(!empty($object->total_vat) ?
price($object->total_vat, 0, $outputlangs) :
price($object->total_tva, 0, $outputlangs)),
572 $array_key.
'_total_localtax1_locale'=>
price($object->total_localtax1, 0, $outputlangs),
573 $array_key.
'_total_localtax2_locale'=>
price($object->total_localtax2, 0, $outputlangs),
574 $array_key.
'_total_ttc_locale'=>
price($object->total_ttc, 0, $outputlangs),
576 $array_key.
'_total_ht'=>
price2num($object->total_ht),
577 $array_key.
'_total_vat'=>(!empty($object->total_vat) ?
price2num($object->total_vat) :
price2num($object->total_tva)),
578 $array_key.
'_total_localtax1'=>
price2num($object->total_localtax1),
579 $array_key.
'_total_localtax2'=>
price2num($object->total_localtax2),
580 $array_key.
'_total_ttc'=>
price2num($object->total_ttc),
582 $array_key.
'_multicurrency_code' => $object->multicurrency_code,
583 $array_key.
'_multicurrency_tx' =>
price2num($object->multicurrency_tx),
584 $array_key.
'_multicurrency_total_ht' =>
price2num($object->multicurrency_total_ht),
585 $array_key.
'_multicurrency_total_tva' =>
price2num($object->multicurrency_total_tva),
586 $array_key.
'_multicurrency_total_ttc' =>
price2num($object->multicurrency_total_ttc),
587 $array_key.
'_multicurrency_total_ht_locale' =>
price($object->multicurrency_total_ht, 0, $outputlangs),
588 $array_key.
'_multicurrency_total_tva_locale' =>
price($object->multicurrency_total_tva, 0, $outputlangs),
589 $array_key.
'_multicurrency_total_ttc_locale' =>
price($object->multicurrency_total_ttc, 0, $outputlangs),
591 $array_key.
'_note_private'=>$object->note_private,
592 $array_key.
'_note_public'=>$object->note_public,
593 $array_key.
'_note'=>$object->note_public,
596 $array_key.
'_already_payed_locale'=>
price($sumpayed, 0, $outputlangs),
597 $array_key.
'_already_payed'=>
price2num($sumpayed),
598 $array_key.
'_already_deposit_locale'=>
price($sumdeposit, 0, $outputlangs),
599 $array_key.
'_already_deposit'=>
price2num($sumdeposit),
600 $array_key.
'_already_creditnote_locale'=>
price($sumcreditnote, 0, $outputlangs),
601 $array_key.
'_already_creditnote'=>
price2num($sumcreditnote),
603 $array_key.
'_already_payed_all_locale'=>
price(
price2num($already_payed_all,
'MT'), 0, $outputlangs),
604 $array_key.
'_already_payed_all'=>
price2num($already_payed_all,
'MT'),
607 $array_key.
'_remain_to_pay_locale'=>
price(
price2num($object->total_ttc - $already_payed_all,
'MT'), 0, $outputlangs),
608 $array_key.
'_remain_to_pay'=>
price2num($object->total_ttc - $already_payed_all,
'MT')
611 if (in_array($object->element, array(
'facture',
'invoice',
'supplier_invoice',
'facture_fournisseur'))) {
612 $bank_account =
null;
614 if (property_exists($object,
'fk_account') && $object->fk_account > 0) {
615 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
616 $bank_account =
new Account($this->db);
617 $bank_account->fetch($object->fk_account);
620 $resarray[$array_key.
'_bank_iban'] = (empty($bank_account) ?
'' : $bank_account->iban);
621 $resarray[$array_key.
'_bank_bic'] = (empty($bank_account) ?
'' : $bank_account->bic);
622 $resarray[$array_key.
'_bank_label'] = (empty($bank_account) ?
'' : $bank_account->label);
623 $resarray[$array_key.
'_bank_number'] = (empty($bank_account) ?
'' : $bank_account->number);
624 $resarray[$array_key.
'_bank_proprio'] =(empty($bank_account) ?
'' : $bank_account->proprio);
627 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
628 $resarray[$array_key.
'_total_discount_ht_locale'] =
price($object->getTotalDiscount(), 0, $outputlangs);
629 $resarray[$array_key.
'_total_discount_ht'] =
price2num($object->getTotalDiscount());
631 $resarray[$array_key.
'_total_discount_ht_locale'] =
'';
632 $resarray[$array_key.
'_total_discount_ht'] =
'';
636 if ($object->element !=
"project" && !empty($object->fk_project) && $object->fk_project > 0) {
637 if (!is_object($object->project)) {
638 $object->fetch_projet();
641 $resarray[$array_key.
'_project_ref'] = $object->project->ref;
642 $resarray[$array_key.
'_project_title'] = $object->project->title;
643 $resarray[$array_key.
'_project_description'] = $object->project->description;
644 $resarray[$array_key.
'_project_date_start'] =
dol_print_date($object->project->date_start,
'day');
645 $resarray[$array_key.
'_project_date_end'] =
dol_print_date($object->project->date_end,
'day');
647 $resarray[$array_key.
'_project_ref'] =
'';
648 $resarray[$array_key.
'_project_title'] =
'';
649 $resarray[$array_key.
'_project_description'] =
'';
650 $resarray[$array_key.
'_project_date_start'] =
'';
651 $resarray[$array_key.
'_project_date_end'] =
'';
655 if (is_array($object->lines) && count($object->lines) > 0) {
658 foreach ($object->lines as $line) {
660 if (empty($resarray[$array_key.
'_total_vat_'.$line->tva_tx])) {
661 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
663 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
664 $resarray[$array_key.
'_total_vat_locale_'.$line->tva_tx] =
price($resarray[$array_key.
'_total_vat_'.$line->tva_tx]);
666 $vatformated =
vatrate($line->tva_tx);
667 if (empty($resarray[$array_key.
'_total_vat_'.$vatformated])) {
668 $resarray[$array_key.
'_total_vat_'.$vatformated] = 0;
670 $resarray[$array_key.
'_total_vat_'.$vatformated] += $line->total_tva;
671 $resarray[$array_key.
'_total_vat_locale_'.$vatformated] =
price($resarray[$array_key.
'_total_vat_'.$vatformated]);
673 $totalUp += $line->subprice * $line->qty;
678 $resarray[
'object_total_up'] = $totalUp;
679 $resarray[
'object_total_up_locale'] =
price($resarray[
'object_total_up'], 0, $outputlangs);
680 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
681 $totalDiscount = $object->getTotalDiscount();
685 if (!empty($totalUp) && !empty($totalDiscount)) {
686 $resarray[
'object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2);
687 $resarray[
'object_total_discount_locale'] =
price($resarray[
'object_total_discount'], 0, $outputlangs);
689 $resarray[
'object_total_discount'] =
'';
690 $resarray[
'object_total_discount_locale'] =
'';
695 if (is_array($object->array_options) && count($object->array_options)) {
696 $object->fetch_optionals();
718 'line_pos' => $linenumber,
721 'line_product_ref'=>(empty($line->product_ref) ?
'' : $line->product_ref),
722 'line_product_ref_fourn'=>(empty($line->ref_fourn) ?
'' : $line->ref_fourn),
723 'line_product_label'=>(empty($line->product_label) ?
'' : $line->product_label),
724 'line_product_type'=>(empty($line->product_type) ?
'' : $line->product_type),
725 'line_product_barcode'=>(empty($line->product_barcode) ?
'' : $line->product_barcode),
726 'line_product_desc'=>(empty($line->product_desc) ?
'' : $line->product_desc),
728 'line_desc'=>$line->desc,
729 'line_vatrate'=>
vatrate($line->tva_tx,
true, $line->info_bits),
730 'line_localtax1_rate'=>
vatrate($line->localtax1_tx),
731 'line_localtax2_rate'=>
vatrate($line->localtax1_tx),
733 'line_up_locale'=>
price($line->subprice, 0, $outputlangs),
734 'line_total_up'=>
price2num($line->subprice * $line->qty),
735 'line_total_up_locale'=>
price($line->subprice * $line->qty, 0, $outputlangs),
736 'line_qty'=>$line->qty,
737 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.
'%' :
''),
738 'line_price_ht'=>
price2num($line->total_ht),
739 'line_price_ttc'=>
price2num($line->total_ttc),
740 'line_price_vat'=>
price2num($line->total_tva),
741 'line_price_ht_locale'=>
price($line->total_ht, 0, $outputlangs),
742 'line_price_ttc_locale'=>
price($line->total_ttc, 0, $outputlangs),
743 'line_price_vat_locale'=>
price($line->total_tva, 0, $outputlangs),
746 'line_date_start_locale'=>
dol_print_date($line->date_start,
'day',
'tzserver', $outputlangs),
747 'line_date_start_rfc'=>
dol_print_date($line->date_start,
'dayrfc'),
749 'line_date_end_locale'=>
dol_print_date($line->date_end,
'day',
'tzserver', $outputlangs),
752 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
753 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
754 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
755 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
756 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
757 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
758 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
759 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
760 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
765 $resarray[
'line_unit'] = $outputlangs->trans($line->getLabelOfUnit(
'long'));
766 $resarray[
'line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit(
'short'));
770 $extrafieldkey = $line->table_element;
772 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
774 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
775 $line->fetch_optionals();
780 if (get_class($line) ==
'CommandeFournisseurLigne') {
782 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
783 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
785 if (!empty($extralabels) && is_array($extralabels)) {
788 foreach ($extralabels as $key => $label) {
789 $columns .=
"$key, ";
792 if ($columns !=
"") {
793 $columns = substr($columns, 0, strlen($columns) - 2);
794 $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).
"'");
796 if ($this->db->num_rows($resql) > 0) {
797 $resql = $this->db->fetch_object($resql);
799 foreach ($extralabels as $key => $label) {
800 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
808 if (isset($line->fk_product) && $line->fk_product > 0) {
809 $tmpproduct =
new Product($this->db);
810 $result = $tmpproduct->fetch($line->fk_product);
811 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
812 foreach ($tmpproduct->array_options as $key => $label) {
813 $resarray[
"line_product_".$key] = $label;
818 $extrafields->fetch_name_optionals_label(
"product");
819 $extralabels = $extrafields->attributes[
"product"][
'label'];
821 if (!empty($extralabels) && is_array($extralabels)) {
822 foreach ($extralabels as $key => $label) {
823 $resarray[
'line_product_options_'.$key] =
'';
844 global $conf, $extrafields;
846 $object->list_delivery_methods($object->shipping_method_id);
847 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
849 $array_shipment = array(
850 $array_key.
'_id'=>$object->id,
851 $array_key.
'_ref'=>$object->ref,
852 $array_key.
'_ref_ext'=>$object->ref_ext,
853 $array_key.
'_ref_customer'=>$object->ref_customer,
854 $array_key.
'_date_delivery'=>
dol_print_date($object->date_delivery,
'day'),
855 $array_key.
'_hour_delivery'=>
dol_print_date($object->date_delivery,
'hour'),
856 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
857 $array_key.
'_total_ht'=>
price($object->total_ht),
858 $array_key.
'_total_vat'=>
price($object->total_tva),
859 $array_key.
'_total_ttc'=>
price($object->total_ttc),
860 $array_key.
'_total_discount_ht' =>
price($object->getTotalDiscount()),
861 $array_key.
'_note_private'=>$object->note_private,
862 $array_key.
'_note'=>$object->note_public,
863 $array_key.
'_tracking_number'=>$object->tracking_number,
864 $array_key.
'_tracking_url'=>$object->tracking_url,
865 $array_key.
'_shipping_method'=>$object->listmeths[0][
'libelle'],
866 $array_key.
'_weight'=>$object->trueWeight.
' '.
measuringUnitString(0,
'weight', $object->weight_units),
867 $array_key.
'_width'=>$object->trueWidth.
' '.
measuringUnitString(0,
'size', $object->width_units),
868 $array_key.
'_height'=>$object->trueHeight.
' '.
measuringUnitString(0,
'size', $object->height_units),
869 $array_key.
'_depth'=>$object->trueDepth.
' '.
measuringUnitString(0,
'size', $object->depth_units),
874 foreach ($object->lines as $line) {
875 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
876 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
878 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
882 if (is_array($object->array_options) && count($object->array_options)) {
883 $object->fetch_optionals();
889 if (!empty($object->commande) && is_object($object->commande)) {
890 $array_shipment[
'order_ref'] = $object->commande->ref;
891 $array_shipment[
'order_ref_customer'] = $object->commande->ref_customer;
894 return $array_shipment;
961 if (isset($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element][
'label'])) {
962 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
963 $formatedarrayoption = $object->array_options;
965 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
966 $formatedarrayoption[
'options_'.$key] =
price2num($formatedarrayoption[
'options_'.$key]);
967 $formatedarrayoption[
'options_'.$key.
'_currency'] =
price($formatedarrayoption[
'options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
969 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_currency' => $formatedarrayoption[
'options_'.$key.
'_currency']));
970 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'select') {
971 $valueofselectkey = $formatedarrayoption[
'options_'.$key];
972 if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element][
'param'][$key][
'options'])) {
973 $formatedarrayoption[
'options_'.$key] = $extrafields->attributes[$object->table_element][
'param'][$key][
'options'][$valueofselectkey];
975 $formatedarrayoption[
'options_'.$key] =
'';
977 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'checkbox') {
978 $valArray = explode(
',', $formatedarrayoption[
'options_'.$key]);
980 foreach ($extrafields->attributes[$object->table_element][
'param'][$key][
'options'] as $keyopt => $valopt) {
981 if (in_array($keyopt, $valArray)) {
985 $formatedarrayoption[
'options_'.$key] = implode(
', ', $output);
986 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
987 if (strlen($formatedarrayoption[
'options_'.$key]) > 0) {
988 $date = $formatedarrayoption[
'options_'.$key];
989 $formatedarrayoption[
'options_'.$key] =
dol_print_date($date,
'day');
990 $formatedarrayoption[
'options_'.$key.
'_locale'] =
dol_print_date($date,
'day',
'tzserver', $outputlangs);
991 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
dol_print_date($date,
'dayrfc');
993 $formatedarrayoption[
'options_'.$key] =
'';
994 $formatedarrayoption[
'options_'.$key.
'_locale'] =
'';
995 $formatedarrayoption[
'options_'.$key.
'_rfc'] =
'';
997 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
998 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
999 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
1000 $datetime = $formatedarrayoption[
'options_'.$key];
1001 $formatedarrayoption[
'options_'.$key] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
1002 $formatedarrayoption[
'options_'.$key.
'_locale'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
1003 $formatedarrayoption[
'options_'.$key.
'_rfc'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
1004 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_locale' => $formatedarrayoption[
'options_'.$key.
'_locale']));
1005 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key.
'_rfc' => $formatedarrayoption[
'options_'.$key.
'_rfc']));
1006 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'link') {
1007 $id = $formatedarrayoption[
'options_'.$key];
1009 $param = $extrafields->attributes[$object->table_element][
'param'][$key];
1010 $param_list = array_keys($param[
'options']);
1011 $InfoFieldList = explode(
":", $param_list[0]);
1012 $classname = $InfoFieldList[0];
1013 $classpath = $InfoFieldList[1];
1014 if (!empty($classpath)) {
1016 if ($classname && class_exists($classname)) {
1017 $tmpobject =
new $classname($this->db);
1018 $tmpobject->fetch($id);
1020 $formatedarrayoption[
'options_'.$key] = $tmpobject->name;
1026 if (array_key_exists(
'options_'.$key, $formatedarrayoption)) {
1027 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key => $formatedarrayoption[
'options_'.$key]));
1029 $array_to_fill = array_merge($array_to_fill, array($array_key.
'_options_'.$key =>
''));
1034 return $array_to_fill;
1338 global $hookmanager;
1340 if (empty($object->table_element)) {
1344 $extrafieldsKeyPrefix =
"options_";
1347 $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix);
1349 $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix));
1352 $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
1356 if (empty($this->extrafieldsCache)) {
1357 $this->extrafieldsCache =
new ExtraFields($this->db);
1359 if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
1360 $this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
1362 $extrafields = $this->extrafieldsCache;
1364 $extrafieldOutputContent =
'';
1365 if (isset($object->array_options[$extrafieldOptionsKey])) {
1366 $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey],
'', $object->table_element, $outputlangs);
1370 if ($extrafields->attributes[$object->table_element][
'type'][$extrafieldKey] ==
'link') {
1375 $parameters = array(
1376 'object' => $object,
1377 'extrafields' => $extrafields,
1378 'extrafieldKey' => $extrafieldKey,
1379 'extrafieldOutputContent' =>& $extrafieldOutputContent
1381 $reshook = $hookmanager->executeHooks(
'getPDFExtrafieldContent', $parameters, $this);
1386 $extrafieldOutputContent = $hookmanager->resPrint;
1389 return $extrafieldOutputContent;
1604 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1606 global $hookmanager, $conf;
1608 foreach ($this->cols as $colKey => $colDef) {
1609 $parameters = array(
1610 'colKey' => $colKey,
1612 'outputlangs' => $outputlangs,
1613 'tab_top' => $tab_top,
1614 'tab_height' => $tab_height,
1615 'hidetop' => $hidetop
1618 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
1621 } elseif (empty($reshook)) {
1627 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1630 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
1631 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1634 if (empty($hidetop)) {
1636 $curentCellPaddinds = $pdf->getCellPaddings();
1639 global $outputlangsbis;
1640 if (is_object($outputlangsbis)) {
1642 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
1645 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1647 if (isset($colDef[
'title'][
'align'])) {
1648 $align = $colDef[
'title'][
'align'];
1652 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
1653 $textWidth = $colDef[
'width'];
1654 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
1657 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
1658 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1659 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
1660 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
1661 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
1664 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
1667 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1672 return $this->tabTitleHeight;
1687 if (!empty($hidedetails)) {
1691 if (empty($object->table_element)) {
1696 if (empty($this->extrafieldsCache)) {
1697 $this->extrafieldsCache =
new ExtraFields($this->db);
1699 if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
1700 $this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
1702 $extrafields = $this->extrafieldsCache;
1705 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'])) {
1706 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
1708 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'separate') {
1714 if (!empty($extrafields->attributes[$object->table_element][
'printable'][$key])) {
1715 $printable = intval($extrafields->attributes[$object->table_element][
'printable'][$key]);
1716 if ($printable === 1 || $printable === 2) {
1727 if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$key])) {
1728 $outputlangs->load($extrafields->attributes[$object->table_element][
'langfile'][$key]);
1735 'rank' => intval($extrafields->attributes[$object->table_element][
'pos'][$key]),
1737 'status' => (
bool) $enabled,
1739 'label' => $outputlangs->transnoentities($label)
1744 'border-left' =>
true,
1747 $alignTypeRight = array(
'double',
'int',
'price');
1748 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeRight)) {
1749 $def[
'content'][
'align'] =
'R';
1752 $alignTypeLeft = array(
'text',
'html');
1753 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeLeft)) {
1754 $def[
'content'][
'align'] =
'L';