462 global $conf, $extrafields;
464 $sumpayed = $sumdeposit = $sumcreditnote =
'';
465 $already_payed_all = 0;
467 if ($object->element ==
'facture') {
468 $invoice_source =
new Facture($this->db);
469 if ($object->fk_facture_source > 0) {
470 $invoice_source->fetch($object->fk_facture_source);
472 $sumpayed = $object->getSommePaiement();
473 $sumdeposit = $object->getSumDepositsUsed();
474 $sumcreditnote = $object->getSumCreditNotesUsed();
475 $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
477 if ($object->fk_account > 0) {
478 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
479 $bank_account =
new Account($this->db);
480 $bank_account->fetch($object->fk_account);
484 $date = (isset($object->element) && $object->element ==
'contrat' && isset($object->date_contrat)) ? $object->date_contrat : (isset($object->date) ? $object->date :
null);
486 if (get_class($object) ==
'CommandeFournisseur') {
488 $object->date_validation = $object->date_valid;
489 $object->date_commande = $object->date;
492 $array_key.
'_id'=>$object->id,
493 $array_key.
'_ref' => (property_exists($object,
'ref') ? $object->ref :
''),
494 $array_key.
'_label' => (property_exists($object,
'label') ? $object->label :
''),
495 $array_key.
'_ref_ext' => (property_exists($object,
'ref_ext') ? $object->ref_ext :
''),
496 $array_key.
'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ?
'' : $object->ref_customer)),
497 $array_key.
'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ?
'' : $object->ref_supplier)),
498 $array_key.
'_source_invoice_ref'=>((empty($invoice_source) || empty($invoice_source->ref)) ?
'' : $invoice_source->ref),
503 $array_key.
'_date_limit'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day') :
''),
504 $array_key.
'_date_limit_rfc'=>(!empty($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'dayrfc') :
''),
505 $array_key.
'_date_end'=>(!empty($object->fin_validite) ?
dol_print_date($object->fin_validite,
'day') :
''),
506 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
507 $array_key.
'_date_modification'=>(!empty($object->date_modification) ?
dol_print_date($object->date_modification,
'day') :
''),
508 $array_key.
'_date_validation'=>(!empty($object->date_validation) ?
dol_print_date($object->date_validation,
'dayhour') :
''),
509 $array_key.
'_date_approve'=>(!empty($object->date_approve) ?
dol_print_date($object->date_approve,
'day') :
''),
510 $array_key.
'_date_delivery_planed'=>(!empty($object->delivery_date) ?
dol_print_date($object->delivery_date,
'day') :
''),
511 $array_key.
'_date_close'=>(!empty($object->date_cloture) ?
dol_print_date($object->date_cloture,
'dayhour') :
''),
513 $array_key.
'_payment_mode_code'=>$object->mode_reglement_code,
514 $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),
515 $array_key.
'_payment_term_code'=>$object->cond_reglement_code,
516 $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)),
518 $array_key.
'_incoterms' => (method_exists($object,
'display_incoterms') ? $object->display_incoterms() :
''),
520 $array_key.
'_bank_iban' => (!empty($bank_account) ? $bank_account->iban :
''),
521 $array_key.
'_bank_bic' => (!empty($bank_account) ? $bank_account->bic :
''),
522 $array_key.
'_bank_label' => (!empty($bank_account) ? $bank_account->label :
''),
523 $array_key.
'_bank_number' => (!empty($bank_account) ? $bank_account->number :
''),
524 $array_key.
'_bank_proprio' => (!empty($bank_account) ? $bank_account->proprio :
''),
526 $array_key.
'_total_ht_locale'=>
price($object->total_ht, 0, $outputlangs),
527 $array_key.
'_total_vat_locale'=>(!empty($object->total_vat) ?
price($object->total_vat, 0, $outputlangs) :
price($object->total_tva, 0, $outputlangs)),
528 $array_key.
'_total_localtax1_locale'=>
price($object->total_localtax1, 0, $outputlangs),
529 $array_key.
'_total_localtax2_locale'=>
price($object->total_localtax2, 0, $outputlangs),
530 $array_key.
'_total_ttc_locale'=>
price($object->total_ttc, 0, $outputlangs),
532 $array_key.
'_total_ht'=>
price2num($object->total_ht),
533 $array_key.
'_total_vat'=>(!empty($object->total_vat) ?
price2num($object->total_vat) :
price2num($object->total_tva)),
534 $array_key.
'_total_localtax1'=>
price2num($object->total_localtax1),
535 $array_key.
'_total_localtax2'=>
price2num($object->total_localtax2),
536 $array_key.
'_total_ttc'=>
price2num($object->total_ttc),
538 $array_key.
'_multicurrency_code' => $object->multicurrency_code,
539 $array_key.
'_multicurrency_tx' =>
price2num($object->multicurrency_tx),
540 $array_key.
'_multicurrency_total_ht' =>
price2num($object->multicurrency_total_ht),
541 $array_key.
'_multicurrency_total_tva' =>
price2num($object->multicurrency_total_tva),
542 $array_key.
'_multicurrency_total_ttc' =>
price2num($object->multicurrency_total_ttc),
543 $array_key.
'_multicurrency_total_ht_locale' =>
price($object->multicurrency_total_ht, 0, $outputlangs),
544 $array_key.
'_multicurrency_total_tva_locale' =>
price($object->multicurrency_total_tva, 0, $outputlangs),
545 $array_key.
'_multicurrency_total_ttc_locale' =>
price($object->multicurrency_total_ttc, 0, $outputlangs),
547 $array_key.
'_note_private'=>$object->note,
548 $array_key.
'_note_public'=>$object->note_public,
549 $array_key.
'_note'=>$object->note_public,
552 $array_key.
'_already_payed_locale'=>
price($sumpayed, 0, $outputlangs),
553 $array_key.
'_already_payed'=>
price2num($sumpayed),
554 $array_key.
'_already_deposit_locale'=>
price($sumdeposit, 0, $outputlangs),
555 $array_key.
'_already_deposit'=>
price2num($sumdeposit),
556 $array_key.
'_already_creditnote_locale'=>
price($sumcreditnote, 0, $outputlangs),
557 $array_key.
'_already_creditnote'=>
price2num($sumcreditnote),
559 $array_key.
'_already_payed_all_locale'=>
price(
price2num($already_payed_all,
'MT'), 0, $outputlangs),
560 $array_key.
'_already_payed_all'=>
price2num($already_payed_all,
'MT'),
563 $array_key.
'_remain_to_pay_locale'=>
price(
price2num($object->total_ttc - $already_payed_all,
'MT'), 0, $outputlangs),
564 $array_key.
'_remain_to_pay'=>
price2num($object->total_ttc - $already_payed_all,
'MT')
567 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
568 $resarray[$array_key.
'_total_discount_ht_locale'] =
price($object->getTotalDiscount(), 0, $outputlangs);
569 $resarray[$array_key.
'_total_discount_ht'] =
price2num($object->getTotalDiscount());
571 $resarray[$array_key.
'_total_discount_ht_locale'] =
'';
572 $resarray[$array_key.
'_total_discount_ht'] =
'';
576 if ($object->element !=
"project" && !empty($object->fk_project) && $object->fk_project > 0) {
577 if (!is_object($object->project)) {
578 $object->fetch_projet();
581 $resarray[$array_key.
'_project_ref'] = $object->project->ref;
582 $resarray[$array_key.
'_project_title'] = $object->project->title;
583 $resarray[$array_key.
'_project_description'] = $object->project->description;
584 $resarray[$array_key.
'_project_date_start'] =
dol_print_date($object->project->date_start,
'day');
585 $resarray[$array_key.
'_project_date_end'] =
dol_print_date($object->project->date_end,
'day');
587 $resarray[$array_key.
'_project_ref'] =
'';
588 $resarray[$array_key.
'_project_title'] =
'';
589 $resarray[$array_key.
'_project_description'] =
'';
590 $resarray[$array_key.
'_project_date_start'] =
'';
591 $resarray[$array_key.
'_project_date_end'] =
'';
595 if (is_array($object->lines) && count($object->lines) > 0) {
598 foreach ($object->lines as $line) {
600 if (empty($resarray[$array_key.
'_total_vat_'.$line->tva_tx])) {
601 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
603 $resarray[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
604 $resarray[$array_key.
'_total_vat_locale_'.$line->tva_tx] =
price($resarray[$array_key.
'_total_vat_'.$line->tva_tx]);
606 $vatformated =
vatrate($line->tva_tx);
607 if (empty($resarray[$array_key.
'_total_vat_'.$vatformated])) {
608 $resarray[$array_key.
'_total_vat_'.$vatformated] = 0;
610 $resarray[$array_key.
'_total_vat_'.$vatformated] += $line->total_tva;
611 $resarray[$array_key.
'_total_vat_locale_'.$vatformated] =
price($resarray[$array_key.
'_total_vat_'.$vatformated]);
613 $totalUp += $line->subprice * $line->qty;
618 $resarray[
'object_total_up'] = $totalUp;
619 $resarray[
'object_total_up_locale'] =
price($resarray[
'object_total_up'], 0, $outputlangs);
620 if (method_exists($object,
'getTotalDiscount') && in_array(get_class($object), array(
'Propal',
'Proposal',
'Commande',
'Facture',
'SupplierProposal',
'CommandeFournisseur',
'FactureFournisseur'))) {
621 $totalDiscount = $object->getTotalDiscount();
625 if (!empty($totalUp) && !empty($totalDiscount)) {
626 $resarray[
'object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2);
627 $resarray[
'object_total_discount_locale'] =
price($resarray[
'object_total_discount'], 0, $outputlangs);
629 $resarray[
'object_total_discount'] =
'';
630 $resarray[
'object_total_discount_locale'] =
'';
635 if (is_array($object->array_options) && count($object->array_options)) {
636 $object->fetch_optionals();
658 'line_pos' => $linenumber,
661 'line_product_ref'=>(empty($line->product_ref) ?
'' : $line->product_ref),
662 'line_product_ref_fourn'=>(empty($line->ref_fourn) ?
'' : $line->ref_fourn),
663 'line_product_label'=>(empty($line->product_label) ?
'' : $line->product_label),
664 'line_product_type'=>(empty($line->product_type) ?
'' : $line->product_type),
665 'line_product_barcode'=>(empty($line->product_barcode) ?
'' : $line->product_barcode),
666 'line_product_desc'=>(empty($line->product_desc) ?
'' : $line->product_desc),
668 'line_desc'=>$line->desc,
669 'line_vatrate'=>
vatrate($line->tva_tx,
true, $line->info_bits),
670 'line_localtax1_rate'=>
vatrate($line->localtax1_tx),
671 'line_localtax2_rate'=>
vatrate($line->localtax1_tx),
673 'line_up_locale'=>
price($line->subprice, 0, $outputlangs),
674 'line_total_up'=>
price2num($line->subprice * $line->qty),
675 'line_total_up_locale'=>
price($line->subprice * $line->qty, 0, $outputlangs),
676 'line_qty'=>$line->qty,
677 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.
'%' :
''),
678 'line_price_ht'=>
price2num($line->total_ht),
679 'line_price_ttc'=>
price2num($line->total_ttc),
680 'line_price_vat'=>
price2num($line->total_tva),
681 'line_price_ht_locale'=>
price($line->total_ht, 0, $outputlangs),
682 'line_price_ttc_locale'=>
price($line->total_ttc, 0, $outputlangs),
683 'line_price_vat_locale'=>
price($line->total_tva, 0, $outputlangs),
686 'line_date_start_locale'=>
dol_print_date($line->date_start,
'day',
'tzserver', $outputlangs),
687 'line_date_start_rfc'=>
dol_print_date($line->date_start,
'dayrfc'),
689 'line_date_end_locale'=>
dol_print_date($line->date_end,
'day',
'tzserver', $outputlangs),
692 'line_multicurrency_code' =>
price2num($line->multicurrency_code),
693 'line_multicurrency_subprice' =>
price2num($line->multicurrency_subprice),
694 'line_multicurrency_total_ht' =>
price2num($line->multicurrency_total_ht),
695 'line_multicurrency_total_tva' =>
price2num($line->multicurrency_total_tva),
696 'line_multicurrency_total_ttc' =>
price2num($line->multicurrency_total_ttc),
697 'line_multicurrency_subprice_locale' =>
price($line->multicurrency_subprice, 0, $outputlangs),
698 'line_multicurrency_total_ht_locale' =>
price($line->multicurrency_total_ht, 0, $outputlangs),
699 'line_multicurrency_total_tva_locale' =>
price($line->multicurrency_total_tva, 0, $outputlangs),
700 'line_multicurrency_total_ttc_locale' =>
price($line->multicurrency_total_ttc, 0, $outputlangs),
705 $resarray[
'line_unit'] = $outputlangs->trans($line->getLabelOfUnit(
'long'));
706 $resarray[
'line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit(
'short'));
710 $extrafieldkey = $line->table_element;
712 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
714 $extrafields->fetch_name_optionals_label($extrafieldkey,
true);
715 $line->fetch_optionals();
720 if (get_class($line) ==
'CommandeFournisseurLigne') {
722 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
723 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
725 if (!empty($extralabels) && is_array($extralabels)) {
728 foreach ($extralabels as $key => $label) {
729 $columns .=
"$key, ";
732 if ($columns !=
"") {
733 $columns = substr($columns, 0, strlen($columns) - 2);
734 $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).
"'");
736 if ($this->db->num_rows($resql) > 0) {
737 $resql = $this->db->fetch_object($resql);
739 foreach ($extralabels as $key => $label) {
740 $resarray[
'line_product_supplier_'.$key] = $resql->$key;
748 if (isset($line->fk_product) && $line->fk_product > 0) {
749 $tmpproduct =
new Product($this->db);
750 $result = $tmpproduct->fetch($line->fk_product);
751 if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) {
752 foreach ($tmpproduct->array_options as $key => $label) {
753 $resarray[
"line_product_".$key] = $label;
758 $extrafields->fetch_name_optionals_label(
"product");
759 $extralabels = $extrafields->attributes[
"product"][
'label'];
761 if (!empty($extralabels) && is_array($extralabels)) {
762 foreach ($extralabels as $key => $label) {
763 $resarray[
'line_product_options_'.$key] =
'';
784 global $conf, $extrafields;
786 $object->list_delivery_methods($object->shipping_method_id);
787 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
789 $array_shipment = array(
790 $array_key.
'_id'=>$object->id,
791 $array_key.
'_ref'=>$object->ref,
792 $array_key.
'_ref_ext'=>$object->ref_ext,
793 $array_key.
'_ref_customer'=>$object->ref_customer,
794 $array_key.
'_date_delivery'=>
dol_print_date($object->date_delivery,
'day'),
795 $array_key.
'_hour_delivery'=>
dol_print_date($object->date_delivery,
'hour'),
796 $array_key.
'_date_creation'=>
dol_print_date($object->date_creation,
'day'),
797 $array_key.
'_total_ht'=>
price($object->total_ht),
798 $array_key.
'_total_vat'=>
price($object->total_tva),
799 $array_key.
'_total_ttc'=>
price($object->total_ttc),
800 $array_key.
'_total_discount_ht' =>
price($object->getTotalDiscount()),
801 $array_key.
'_note_private'=>$object->note_private,
802 $array_key.
'_note'=>$object->note_public,
803 $array_key.
'_tracking_number'=>$object->tracking_number,
804 $array_key.
'_tracking_url'=>$object->tracking_url,
805 $array_key.
'_shipping_method'=>$object->listmeths[0][
'libelle'],
806 $array_key.
'_weight'=>$object->trueWeight.
' '.
measuringUnitString(0,
'weight', $object->weight_units),
807 $array_key.
'_width'=>$object->trueWidth.
' '.
measuringUnitString(0,
'size', $object->width_units),
808 $array_key.
'_height'=>$object->trueHeight.
' '.
measuringUnitString(0,
'size', $object->height_units),
809 $array_key.
'_depth'=>$object->trueDepth.
' '.
measuringUnitString(0,
'size', $object->depth_units),
814 foreach ($object->lines as $line) {
815 if (empty($array_shipment[$array_key.
'_total_vat_'.$line->tva_tx])) {
816 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] = 0;
818 $array_shipment[$array_key.
'_total_vat_'.$line->tva_tx] += $line->total_tva;
822 if (is_array($object->array_options) && count($object->array_options)) {
823 $object->fetch_optionals();
829 if (!empty($object->commande) && is_object($object->commande)) {
830 $array_shipment[
'order_ref'] = $object->commande->ref;
831 $array_shipment[
'order_ref_customer'] = $object->commande->ref_customer;
834 return $array_shipment;
961 if (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;
1599 public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
1601 global $hookmanager, $conf;
1603 foreach ($this->cols as $colKey => $colDef) {
1604 $parameters = array(
1605 'colKey' => $colKey,
1607 'outputlangs' => $outputlangs,
1608 'tab_top' => $tab_top,
1609 'tab_height' => $tab_height,
1610 'hidetop' => $hidetop
1613 $reshook = $hookmanager->executeHooks(
'pdfTabTitles', $parameters, $this);
1616 } elseif (empty($reshook)) {
1622 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1625 if (!empty($colDef[
'border-left']) && isset($colDef[
'xStartPos'])) {
1626 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1629 if (empty($hidetop)) {
1631 $curentCellPaddinds = $pdf->getCellPaddings();
1634 global $outputlangsbis;
1635 if (is_object($outputlangsbis)) {
1637 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], 0.5);
1640 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], $colDef[
'title'][
'padding'][0], $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1642 if (isset($colDef[
'title'][
'align'])) {
1643 $align = $colDef[
'title'][
'align'];
1647 $pdf->SetXY($colDef[
'xStartPos'], $tab_top);
1648 $textWidth = $colDef[
'width'];
1649 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $align);
1652 if (is_object($outputlangsbis) && trim($colDef[
'title'][
'label'])) {
1653 $pdf->setCellPaddings($colDef[
'title'][
'padding'][3], 0, $colDef[
'title'][
'padding'][1], $colDef[
'title'][
'padding'][2]);
1654 $pdf->SetXY($colDef[
'xStartPos'], $pdf->GetY());
1655 $textbis = $outputlangsbis->transnoentities($colDef[
'title'][
'textkey']);
1656 $pdf->MultiCell($textWidth, 2, $textbis,
'', $align);
1659 $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight);
1662 $pdf->setCellPaddings($curentCellPaddinds[
'L'], $curentCellPaddinds[
'T'], $curentCellPaddinds[
'R'], $curentCellPaddinds[
'B']);
1667 return $this->tabTitleHeight;
1682 if (!empty($hidedetails)) {
1686 if (empty($object->table_element)) {
1691 if (empty($this->extrafieldsCache)) {
1692 $this->extrafieldsCache =
new ExtraFields($this->db);
1694 if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
1695 $this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
1697 $extrafields = $this->extrafieldsCache;
1700 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'])) {
1701 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
1703 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'separate') {
1709 if (!empty($extrafields->attributes[$object->table_element][
'printable'][$key])) {
1710 $printable = intval($extrafields->attributes[$object->table_element][
'printable'][$key]);
1711 if ($printable === 1 || $printable === 2) {
1722 if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$key])) {
1723 $outputlangs->load($extrafields->attributes[$object->table_element][
'langfile'][$key]);
1730 'rank' => intval($extrafields->attributes[$object->table_element][
'pos'][$key]),
1732 'status' => boolval($enabled),
1734 'label' => $outputlangs->transnoentities($label)
1739 'border-left' =>
true,
1742 $alignTypeRight = array(
'double',
'int',
'price');
1743 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeRight)) {
1744 $def[
'content'][
'align'] =
'R';
1747 $alignTypeLeft = array(
'text',
'html');
1748 if (in_array($extrafields->attributes[$object->table_element][
'type'][$key], $alignTypeLeft)) {
1749 $def[
'content'][
'align'] =
'L';