| Total Complexity | 151 |
| Total Lines | 1190 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like pdf_espadon often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use pdf_espadon, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 37 | class pdf_espadon extends ModelePdfExpedition |
||
| 38 | { |
||
| 39 | /** |
||
| 40 | * @var DoliDb Database handler |
||
| 41 | */ |
||
| 42 | public $db; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string model name |
||
| 46 | */ |
||
| 47 | public $name; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string model description (short text) |
||
| 51 | */ |
||
| 52 | public $description; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var string document type |
||
| 56 | */ |
||
| 57 | public $type; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var array Minimum version of PHP required by module. |
||
| 61 | * e.g.: PHP ≥ 5.5 = array(5, 5) |
||
| 62 | */ |
||
| 63 | public $phpmin = array(5, 5); |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Dolibarr version of the loaded document |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | public $version = 'dolibarr'; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var int page_largeur |
||
| 73 | */ |
||
| 74 | public $page_largeur; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var int page_hauteur |
||
| 78 | */ |
||
| 79 | public $page_hauteur; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @var array format |
||
| 83 | */ |
||
| 84 | public $format; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @var int marge_gauche |
||
| 88 | */ |
||
| 89 | public $marge_gauche; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var int marge_droite |
||
| 93 | */ |
||
| 94 | public $marge_droite; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var int marge_haute |
||
| 98 | */ |
||
| 99 | public $marge_haute; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @var int marge_basse |
||
| 103 | */ |
||
| 104 | public $marge_basse; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Issuer |
||
| 108 | * @var Societe object that emits |
||
| 109 | */ |
||
| 110 | public $emetteur; |
||
| 111 | |||
| 112 | |||
| 113 | /** |
||
| 114 | * Constructor |
||
| 115 | * |
||
| 116 | * @param DoliDB $db Database handler |
||
| 117 | */ |
||
| 118 | public function __construct($db = 0) |
||
| 119 | { |
||
| 120 | global $conf,$langs,$mysoc; |
||
| 121 | |||
| 122 | $this->db = $db; |
||
| 123 | $this->name = "espadon"; |
||
| 124 | $this->description = $langs->trans("DocumentModelStandardPDF"); |
||
| 125 | |||
| 126 | $this->type = 'pdf'; |
||
| 127 | $formatarray=pdf_getFormat(); |
||
| 128 | $this->page_largeur = $formatarray['width']; |
||
| 129 | $this->page_hauteur = $formatarray['height']; |
||
| 130 | $this->format = array($this->page_largeur, $this->page_hauteur); |
||
| 131 | $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
||
| 132 | $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
||
| 133 | $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
||
| 134 | $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
||
| 135 | |||
| 136 | $this->option_logo = 1; |
||
| 137 | |||
| 138 | // Get source company |
||
| 139 | $this->emetteur=$mysoc; |
||
| 140 | if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined |
||
| 141 | |||
| 142 | $this->tabTitleHeight = 5; // default height |
||
| 143 | } |
||
| 144 | |||
| 145 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 146 | /** |
||
| 147 | * Function to build pdf onto disk |
||
| 148 | * |
||
| 149 | * @param Object $object Object expedition to generate (or id if old method) |
||
| 150 | * @param Translate $outputlangs Lang output object |
||
| 151 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
||
| 152 | * @param int $hidedetails Do not show line details |
||
| 153 | * @param int $hidedesc Do not show desc |
||
| 154 | * @param int $hideref Do not show ref |
||
| 155 | * @return int 1=OK, 0=KO |
||
| 156 | */ |
||
| 157 | public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
||
| 648 | } |
||
| 649 | } |
||
| 650 | |||
| 651 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 652 | /** |
||
| 653 | * Show total to pay |
||
| 654 | * |
||
| 655 | * @param PDF $pdf Object PDF |
||
| 656 | * @param Facture $object Object invoice |
||
| 657 | * @param int $deja_regle Montant deja regle |
||
| 658 | * @param int $posy Position depart |
||
| 659 | * @param Translate $outputlangs Objet langs |
||
| 660 | * @return int Position pour suite |
||
| 661 | */ |
||
| 662 | private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
||
| 663 | { |
||
| 664 | // phpcs:enable |
||
| 665 | global $conf,$mysoc; |
||
| 666 | |||
| 667 | $sign=1; |
||
| 668 | |||
| 669 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 670 | |||
| 671 | $tab2_top = $posy; |
||
| 672 | $tab2_hl = 4; |
||
| 673 | $pdf->SetFont('', 'B', $default_font_size - 1); |
||
| 674 | |||
| 675 | // Tableau total |
||
| 676 | $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
||
| 677 | /*if ($this->page_largeur < 210) // To work with US executive format |
||
| 678 | { |
||
| 679 | $col2x-=20; |
||
| 680 | }*/ |
||
| 681 | if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
||
| 682 | else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
||
| 683 | |||
| 684 | $useborder=0; |
||
| 685 | $index = 0; |
||
| 686 | |||
| 687 | $totalWeighttoshow=''; |
||
| 688 | $totalVolumetoshow=''; |
||
| 689 | |||
| 690 | // Load dim data |
||
| 691 | $tmparray=$object->getTotalWeightVolume(); |
||
| 692 | $totalWeight=$tmparray['weight']; |
||
| 693 | $totalVolume=$tmparray['volume']; |
||
| 694 | $totalOrdered=$tmparray['ordered']; |
||
| 695 | $totalToShip=$tmparray['toship']; |
||
| 696 | // Set trueVolume and volume_units not currently stored into database |
||
| 697 | if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
||
| 698 | { |
||
| 699 | $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); |
||
| 700 | $object->volume_units=$object->size_units * 3; |
||
| 701 | } |
||
| 702 | |||
| 703 | if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
||
| 704 | if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
||
| 705 | if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
||
| 706 | if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
||
| 707 | |||
| 708 | |||
| 709 | |||
| 710 | |||
| 711 | if ($this->getColumnStatus('desc')) |
||
| 712 | { |
||
| 713 | $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total")); |
||
| 714 | } |
||
| 715 | |||
| 716 | |||
| 717 | if ($this->getColumnStatus('weight')) |
||
| 718 | { |
||
| 719 | if ($totalWeighttoshow) |
||
| 720 | { |
||
| 721 | $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow); |
||
| 722 | $index++; |
||
| 723 | } |
||
| 724 | |||
| 725 | if ($totalVolumetoshow) |
||
| 726 | { |
||
| 727 | $y = $tab2_top + ($tab2_hl * $index); |
||
| 728 | $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow); |
||
| 729 | } |
||
| 730 | } |
||
| 731 | |||
| 732 | if ($this->getColumnStatus('qty_asked') && $totalOrdered) |
||
| 733 | { |
||
| 734 | $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered); |
||
| 735 | } |
||
| 736 | |||
| 737 | if ($this->getColumnStatus('qty_shipped') && $totalToShip) |
||
| 738 | { |
||
| 739 | $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip); |
||
| 740 | } |
||
| 741 | |||
| 742 | if ($this->getColumnStatus('subprice')) |
||
| 743 | { |
||
| 744 | $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs)); |
||
| 745 | } |
||
| 746 | |||
| 747 | $pdf->SetTextColor(0, 0, 0); |
||
| 748 | |||
| 749 | return ($tab2_top + ($tab2_hl * $index)); |
||
| 750 | } |
||
| 751 | |||
| 752 | /** |
||
| 753 | * Show table for lines |
||
| 754 | * |
||
| 755 | * @param PDF $pdf Object PDF |
||
| 756 | * @param string $tab_top Top position of table |
||
| 757 | * @param string $tab_height Height of table (rectangle) |
||
| 758 | * @param int $nexY Y |
||
| 759 | * @param Translate $outputlangs Langs object |
||
| 760 | * @param int $hidetop Hide top bar of array |
||
| 761 | * @param int $hidebottom Hide bottom bar of array |
||
| 762 | * @return void |
||
| 763 | */ |
||
| 764 | private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
||
| 765 | { |
||
| 766 | global $conf; |
||
| 767 | |||
| 768 | // Force to disable hidetop and hidebottom |
||
| 769 | $hidebottom=0; |
||
| 770 | if ($hidetop) $hidetop=-1; |
||
| 771 | |||
| 772 | $currency = !empty($currency) ? $currency : $conf->currency; |
||
| 773 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 774 | |||
| 775 | // Amount in (at tab_top - 1) |
||
| 776 | $pdf->SetTextColor(0, 0, 0); |
||
| 777 | $pdf->SetFont('', '', $default_font_size - 2); |
||
| 778 | |||
| 779 | if (empty($hidetop)) |
||
| 780 | { |
||
| 781 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
||
| 782 | if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
||
| 783 | } |
||
| 784 | |||
| 785 | $pdf->SetDrawColor(128, 128, 128); |
||
| 786 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 787 | |||
| 788 | // Output Rect |
||
| 789 | $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
||
| 790 | |||
| 791 | |||
| 792 | $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); |
||
| 793 | |||
| 794 | if (empty($hidetop)){ |
||
| 795 | $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param |
||
| 796 | } |
||
| 797 | } |
||
| 798 | |||
| 799 | /** |
||
| 800 | * Show top header of page. |
||
| 801 | * |
||
| 802 | * @param PDF $pdf Object PDF |
||
| 803 | * @param Object $object Object to show |
||
| 804 | * @param int $showaddress 0=no, 1=yes |
||
| 805 | * @param Translate $outputlangs Object lang for output |
||
| 806 | * @return void |
||
| 807 | */ |
||
| 808 | private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
||
| 809 | { |
||
| 810 | global $conf,$langs,$mysoc; |
||
| 811 | |||
| 812 | $langs->load("orders"); |
||
| 813 | |||
| 814 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 815 | |||
| 816 | pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
||
| 817 | |||
| 818 | // Show Draft Watermark |
||
| 819 | if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) ) |
||
| 820 | { |
||
| 821 | pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); |
||
| 822 | } |
||
| 823 | |||
| 824 | //Prepare la suite |
||
| 825 | $pdf->SetTextColor(0, 0, 60); |
||
| 826 | $pdf->SetFont('', 'B', $default_font_size + 3); |
||
| 827 | |||
| 828 | $w = 110; |
||
| 829 | |||
| 830 | $posy=$this->marge_haute; |
||
| 831 | $posx=$this->page_largeur-$this->marge_droite-$w; |
||
| 832 | |||
| 833 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 834 | |||
| 835 | // Logo |
||
| 836 | $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
||
| 837 | if ($this->emetteur->logo) |
||
| 838 | { |
||
| 839 | if (is_readable($logo)) |
||
| 840 | { |
||
| 841 | $height=pdf_getHeightForLogo($logo); |
||
| 842 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
||
| 843 | } |
||
| 844 | else |
||
| 845 | { |
||
| 846 | $pdf->SetTextColor(200, 0, 0); |
||
| 847 | $pdf->SetFont('', 'B', $default_font_size - 2); |
||
| 848 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
||
| 849 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
||
| 850 | } |
||
| 851 | } |
||
| 852 | else |
||
| 853 | { |
||
| 854 | $text=$this->emetteur->name; |
||
| 855 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
||
| 856 | } |
||
| 857 | |||
| 858 | // Show barcode |
||
| 859 | if (! empty($conf->barcode->enabled)) |
||
| 860 | { |
||
| 861 | $posx=105; |
||
| 862 | } |
||
| 863 | else |
||
| 864 | { |
||
| 865 | $posx=$this->marge_gauche+3; |
||
| 866 | } |
||
| 867 | //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
||
| 868 | if (! empty($conf->barcode->enabled)) |
||
| 869 | { |
||
| 870 | // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref |
||
| 871 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
||
| 872 | //$pdf->Image($logo,10, 5, 0, 24); |
||
| 873 | } |
||
| 874 | |||
| 875 | $pdf->SetDrawColor(128, 128, 128); |
||
| 876 | if (! empty($conf->barcode->enabled)) |
||
| 877 | { |
||
| 878 | // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref |
||
| 879 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
||
| 880 | //$pdf->Image($logo,10, 5, 0, 24); |
||
| 881 | } |
||
| 882 | |||
| 883 | |||
| 884 | $posx=$this->page_largeur - $w - $this->marge_droite; |
||
| 885 | $posy=$this->marge_haute; |
||
| 886 | |||
| 887 | $pdf->SetFont('', 'B', $default_font_size + 2); |
||
| 888 | $pdf->SetXY($posx, $posy); |
||
| 889 | $pdf->SetTextColor(0, 0, 60); |
||
| 890 | $title=$outputlangs->transnoentities("SendingSheet"); |
||
| 891 | $pdf->MultiCell($w, 4, $title, '', 'R'); |
||
| 892 | |||
| 893 | $pdf->SetFont('', '', $default_font_size + 1); |
||
| 894 | |||
| 895 | $posy+=5; |
||
| 896 | |||
| 897 | $pdf->SetXY($posx, $posy); |
||
| 898 | $pdf->SetTextColor(0, 0, 60); |
||
| 899 | $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); |
||
| 900 | |||
| 901 | // Date planned delivery |
||
| 902 | if (! empty($object->date_delivery)) |
||
| 903 | { |
||
| 904 | $posy+=4; |
||
| 905 | $pdf->SetXY($posx, $posy); |
||
| 906 | $pdf->SetTextColor(0, 0, 60); |
||
| 907 | $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); |
||
| 908 | } |
||
| 909 | |||
| 910 | if (! empty($object->thirdparty->code_client)) |
||
| 911 | { |
||
| 912 | $posy+=4; |
||
| 913 | $pdf->SetXY($posx, $posy); |
||
| 914 | $pdf->SetTextColor(0, 0, 60); |
||
| 915 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
||
| 916 | } |
||
| 917 | |||
| 918 | |||
| 919 | $pdf->SetFont('', '', $default_font_size + 3); |
||
| 920 | $Yoff=25; |
||
| 921 | |||
| 922 | // Add list of linked orders |
||
| 923 | $origin = $object->origin; |
||
| 924 | $origin_id = $object->origin_id; |
||
| 925 | |||
| 926 | // TODO move to external function |
||
| 927 | if (! empty($conf->$origin->enabled)) // commonly $origin='commande' |
||
| 928 | { |
||
| 929 | $outputlangs->load('orders'); |
||
| 930 | |||
| 931 | $classname = ucfirst($origin); |
||
| 932 | $linkedobject = new $classname($this->db); |
||
| 933 | $result=$linkedobject->fetch($origin_id); |
||
| 934 | if ($result >= 0) |
||
| 935 | { |
||
| 936 | //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
||
| 937 | |||
| 938 | $pdf->SetFont('', '', $default_font_size - 2); |
||
| 939 | $text=$linkedobject->ref; |
||
| 940 | if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
||
| 941 | $Yoff = $Yoff+8; |
||
| 942 | $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
||
| 943 | $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
||
| 944 | $Yoff = $Yoff+3; |
||
| 945 | $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
||
| 946 | $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); |
||
| 947 | } |
||
| 948 | } |
||
| 949 | |||
| 950 | if ($showaddress) |
||
| 951 | { |
||
| 952 | // Sender properties |
||
| 953 | $carac_emetteur=''; |
||
| 954 | // Add internal contact of origin element if defined |
||
| 955 | $arrayidcontact=array(); |
||
| 956 | if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SALESREPFOLL'); |
||
| 957 | if (is_array($arrayidcontact) && count($arrayidcontact) > 0) |
||
| 958 | { |
||
| 959 | $object->fetch_user(reset($arrayidcontact)); |
||
| 960 | $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
||
| 961 | } |
||
| 962 | |||
| 963 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
||
| 964 | |||
| 965 | // Show sender |
||
| 966 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
||
| 967 | $posx=$this->marge_gauche; |
||
| 968 | if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
||
| 969 | |||
| 970 | $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
||
| 971 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
||
| 972 | |||
| 973 | // Show sender frame |
||
| 974 | $pdf->SetTextColor(0, 0, 0); |
||
| 975 | $pdf->SetFont('', '', $default_font_size - 2); |
||
| 976 | $pdf->SetXY($posx, $posy-5); |
||
| 977 | $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
||
| 978 | $pdf->SetXY($posx, $posy); |
||
| 979 | $pdf->SetFillColor(230, 230, 230); |
||
| 980 | $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
||
| 981 | $pdf->SetTextColor(0, 0, 60); |
||
| 982 | $pdf->SetFillColor(255, 255, 255); |
||
| 983 | |||
| 984 | // Show sender name |
||
| 985 | $pdf->SetXY($posx+2, $posy+3); |
||
| 986 | $pdf->SetFont('', 'B', $default_font_size); |
||
| 987 | $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
||
| 988 | $posy=$pdf->getY(); |
||
| 989 | |||
| 990 | // Show sender information |
||
| 991 | $pdf->SetXY($posx+2, $posy); |
||
| 992 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 993 | $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); |
||
| 994 | |||
| 995 | |||
| 996 | // If SHIPPING contact defined, we use it |
||
| 997 | $usecontact=false; |
||
| 998 | $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); |
||
| 999 | if (count($arrayidcontact) > 0) |
||
| 1000 | { |
||
| 1001 | $usecontact=true; |
||
| 1002 | $result=$object->fetch_contact($arrayidcontact[0]); |
||
| 1003 | } |
||
| 1004 | |||
| 1005 | //Recipient name |
||
| 1006 | // On peut utiliser le nom de la societe du contact |
||
| 1007 | if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
||
| 1008 | $thirdparty = $object->contact; |
||
| 1009 | } else { |
||
| 1010 | $thirdparty = $object->thirdparty; |
||
| 1011 | } |
||
| 1012 | |||
| 1013 | $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
||
| 1014 | |||
| 1015 | $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object); |
||
| 1016 | |||
| 1017 | // Show recipient |
||
| 1018 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
||
| 1019 | if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
||
| 1020 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
||
| 1021 | $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
||
| 1022 | if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
||
| 1023 | |||
| 1024 | // Show recipient frame |
||
| 1025 | $pdf->SetTextColor(0, 0, 0); |
||
| 1026 | $pdf->SetFont('', '', $default_font_size - 2); |
||
| 1027 | $pdf->SetXY($posx+2, $posy-5); |
||
| 1028 | $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
||
| 1029 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
||
| 1030 | |||
| 1031 | // Show recipient name |
||
| 1032 | $pdf->SetXY($posx+2, $posy+3); |
||
| 1033 | $pdf->SetFont('', 'B', $default_font_size); |
||
| 1034 | $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); |
||
| 1035 | |||
| 1036 | $posy = $pdf->getY(); |
||
| 1037 | |||
| 1038 | // Show recipient information |
||
| 1039 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 1040 | $pdf->SetXY($posx+2, $posy); |
||
| 1041 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
||
| 1042 | } |
||
| 1043 | |||
| 1044 | $pdf->SetTextColor(0, 0, 0); |
||
| 1045 | } |
||
| 1046 | |||
| 1047 | /** |
||
| 1048 | * Show footer of page. Need this->emetteur object |
||
| 1049 | * |
||
| 1050 | * @param PDF $pdf PDF |
||
| 1051 | * @param Object $object Object to show |
||
| 1052 | * @param Translate $outputlangs Object lang for output |
||
| 1053 | * @param int $hidefreetext 1=Hide free text |
||
| 1054 | * @return int Return height of bottom margin including footer text |
||
| 1055 | */ |
||
| 1056 | private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
||
| 1057 | { |
||
| 1058 | global $conf; |
||
| 1059 | $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
||
| 1060 | return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
||
| 1061 | } |
||
| 1062 | |||
| 1063 | /** |
||
| 1064 | * Define Array Column Field |
||
| 1065 | * |
||
| 1066 | * @param object $object common object |
||
| 1067 | * @param Translate $outputlangs langs |
||
| 1068 | * @param int $hidedetails Do not show line details |
||
| 1069 | * @param int $hidedesc Do not show desc |
||
| 1070 | * @param int $hideref Do not show ref |
||
| 1071 | * @return null |
||
| 1072 | */ |
||
| 1073 | public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
||
| 1227 | } |
||
| 1228 | } |
||
| 1229 | } |
||
| 1230 |