| Total Complexity | 225 |
| Total Lines | 1494 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like pdf_azur_subtotal 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_azur_subtotal, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 38 | class pdf_azur_subtotal extends ModelePDFPropales |
||
| 39 | { |
||
| 40 | var $db; |
||
| 41 | var $name; |
||
| 42 | var $description; |
||
| 43 | var $type; |
||
| 44 | |||
| 45 | var $phpmin = array(4,3,0); // Minimum version of PHP required by module |
||
| 46 | var $version = 'dolibarr'; |
||
| 47 | |||
| 48 | var $page_largeur; |
||
| 49 | var $page_hauteur; |
||
| 50 | var $format; |
||
| 51 | var $marge_gauche; |
||
| 52 | var $marge_droite; |
||
| 53 | var $marge_haute; |
||
| 54 | var $marge_basse; |
||
| 55 | |||
| 56 | var $emetteur; // Objet societe qui emet |
||
| 57 | |||
| 58 | |||
| 59 | /** |
||
| 60 | * Constructor |
||
| 61 | * |
||
| 62 | * @param DoliDB $db Database handler |
||
| 63 | */ |
||
| 64 | function __construct($db) |
||
|
|
|||
| 65 | { |
||
| 66 | global $conf,$langs,$mysoc; |
||
| 67 | |||
| 68 | $langs->load("main"); |
||
| 69 | $langs->load("bills"); |
||
| 70 | |||
| 71 | $this->db = $db; |
||
| 72 | $this->name = "azur_subtotal"; |
||
| 73 | // J'ajoute l'annotation "déprécié" mais à garder... des fois qu'un client avec une vieille version utilise les modèles PDF custom |
||
| 74 | $this->description = 'Modèle de proposition commerciale incluant des spécificités du module sous-total. (déprécié)'; |
||
| 75 | |||
| 76 | // Dimension page pour format A4 |
||
| 77 | $this->type = 'pdf'; |
||
| 78 | $formatarray=pdf_getFormat(); |
||
| 79 | $this->page_largeur = $formatarray['width']; |
||
| 80 | $this->page_hauteur = $formatarray['height']; |
||
| 81 | $this->format = array($this->page_largeur,$this->page_hauteur); |
||
| 82 | $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
||
| 83 | $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
||
| 84 | $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
||
| 85 | $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
||
| 86 | |||
| 87 | $this->option_logo = 1; // Affiche logo |
||
| 88 | $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
||
| 89 | $this->option_modereg = 1; // Affiche mode reglement |
||
| 90 | $this->option_condreg = 1; // Affiche conditions reglement |
||
| 91 | $this->option_codeproduitservice = 1; // Affiche code produit-service |
||
| 92 | $this->option_multilang = 1; // Dispo en plusieurs langues |
||
| 93 | $this->option_escompte = 1; // Affiche si il y a eu escompte |
||
| 94 | $this->option_credit_note = 1; // Support credit notes |
||
| 95 | $this->option_freetext = 1; // Support add of a personalised text |
||
| 96 | $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
||
| 97 | |||
| 98 | $this->franchise=!$mysoc->tva_assuj; |
||
| 99 | |||
| 100 | // Get source company |
||
| 101 | $this->emetteur=$mysoc; |
||
| 102 | if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
||
| 103 | |||
| 104 | // Define position of columns |
||
| 105 | $this->posxdesc=$this->marge_gauche+1; |
||
| 106 | $this->posxtva=112; |
||
| 107 | $this->posxup=126; |
||
| 108 | $this->posxqty=145; |
||
| 109 | $this->posxdiscount=162; |
||
| 110 | $this->postotalht=174; |
||
| 111 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
||
| 112 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
||
| 113 | if ($this->page_largeur < 210) // To work with US executive format |
||
| 114 | { |
||
| 115 | $this->posxpicture-=20; |
||
| 116 | $this->posxtva-=20; |
||
| 117 | $this->posxup-=20; |
||
| 118 | $this->posxqty-=20; |
||
| 119 | $this->posxdiscount-=20; |
||
| 120 | $this->postotalht-=20; |
||
| 121 | } |
||
| 122 | |||
| 123 | $this->tva=array(); |
||
| 124 | $this->localtax1=array(); |
||
| 125 | $this->localtax2=array(); |
||
| 126 | $this->atleastoneratenotnull=0; |
||
| 127 | $this->atleastonediscount=0; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Function to build pdf onto disk |
||
| 132 | * |
||
| 133 | * @param Object $object Object to generate |
||
| 134 | * @param Translate $outputlangs Lang output object |
||
| 135 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
||
| 136 | * @param int $hidedetails Do not show line details |
||
| 137 | * @param int $hidedesc Do not show desc |
||
| 138 | * @param int $hideref Do not show ref |
||
| 139 | * @return int 1=OK, 0=KO |
||
| 140 | */ |
||
| 141 | function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
||
| 748 | } |
||
| 749 | |||
| 750 | /** |
||
| 751 | * Show payments table |
||
| 752 | * |
||
| 753 | * @param PDF $pdf Object PDF |
||
| 754 | * @param Object $object Object proposal |
||
| 755 | * @param int $posy Position y in PDF |
||
| 756 | * @param Translate $outputlangs Object langs for output |
||
| 757 | * @return int <0 if KO, >0 if OK |
||
| 758 | */ |
||
| 759 | function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
||
| 760 | { |
||
| 761 | |||
| 762 | } |
||
| 763 | |||
| 764 | |||
| 765 | /** |
||
| 766 | * Show miscellaneous information (payment mode, payment term, ...) |
||
| 767 | * |
||
| 768 | * @param PDF $pdf Object PDF |
||
| 769 | * @param Object $object Object to show |
||
| 770 | * @param int $posy Y |
||
| 771 | * @param Translate $outputlangs Langs object |
||
| 772 | * @return void |
||
| 773 | */ |
||
| 774 | function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
||
| 775 | { |
||
| 776 | global $conf; |
||
| 777 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 778 | |||
| 779 | $pdf->SetFont('','', $default_font_size - 1); |
||
| 780 | |||
| 781 | // If France, show VAT mention if not applicable |
||
| 782 | if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
||
| 783 | { |
||
| 784 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 785 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 786 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
||
| 787 | |||
| 788 | $posy=$pdf->GetY()+4; |
||
| 789 | } |
||
| 790 | |||
| 791 | $posxval=52; |
||
| 792 | |||
| 793 | // Show shipping date |
||
| 794 | if (! empty($object->date_livraison)) |
||
| 795 | { |
||
| 796 | $outputlangs->load("sendings"); |
||
| 797 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 798 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 799 | $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; |
||
| 800 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
||
| 801 | $pdf->SetFont('','', $default_font_size - 2); |
||
| 802 | $pdf->SetXY($posxval, $posy); |
||
| 803 | $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); |
||
| 804 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
||
| 805 | |||
| 806 | $posy=$pdf->GetY()+1; |
||
| 807 | } |
||
| 808 | elseif ($object->availability_code || $object->availability) // Show availability conditions |
||
| 809 | { |
||
| 810 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 811 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 812 | $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
||
| 813 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
||
| 814 | $pdf->SetTextColor(0,0,0); |
||
| 815 | $pdf->SetFont('','', $default_font_size - 2); |
||
| 816 | $pdf->SetXY($posxval, $posy); |
||
| 817 | $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability); |
||
| 818 | $lib_availability=str_replace('\n',"\n",$lib_availability); |
||
| 819 | $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); |
||
| 820 | |||
| 821 | $posy=$pdf->GetY()+1; |
||
| 822 | } |
||
| 823 | |||
| 824 | // Show payments conditions |
||
| 825 | if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) |
||
| 826 | { |
||
| 827 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 828 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 829 | $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
||
| 830 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
||
| 831 | |||
| 832 | $pdf->SetFont('','', $default_font_size - 2); |
||
| 833 | $pdf->SetXY($posxval, $posy); |
||
| 834 | $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); |
||
| 835 | $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
||
| 836 | $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); |
||
| 837 | |||
| 838 | $posy=$pdf->GetY()+3; |
||
| 839 | } |
||
| 840 | |||
| 841 | if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND)) |
||
| 842 | { |
||
| 843 | // Check a payment mode is defined |
||
| 844 | /* Not required on a proposal |
||
| 845 | if (empty($object->mode_reglement_code) |
||
| 846 | && ! $conf->global->FACTURE_CHQ_NUMBER |
||
| 847 | && ! $conf->global->FACTURE_RIB_NUMBER) |
||
| 848 | { |
||
| 849 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 850 | $pdf->SetTextColor(200,0,0); |
||
| 851 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 852 | $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); |
||
| 853 | $pdf->SetTextColor(0,0,0); |
||
| 854 | |||
| 855 | $posy=$pdf->GetY()+1; |
||
| 856 | } |
||
| 857 | */ |
||
| 858 | |||
| 859 | // Show payment mode |
||
| 860 | if ($object->mode_reglement_code |
||
| 861 | && $object->mode_reglement_code != 'CHQ' |
||
| 862 | && $object->mode_reglement_code != 'VIR') |
||
| 863 | { |
||
| 864 | $pdf->SetFont('','B', $default_font_size - 2); |
||
| 865 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 866 | $titre = $outputlangs->transnoentities("PaymentMode").':'; |
||
| 867 | $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
||
| 868 | $pdf->SetFont('','', $default_font_size - 2); |
||
| 869 | $pdf->SetXY($posxval, $posy); |
||
| 870 | $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); |
||
| 871 | $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
||
| 872 | |||
| 873 | $posy=$pdf->GetY()+2; |
||
| 874 | } |
||
| 875 | |||
| 876 | // Show payment mode CHQ |
||
| 877 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') |
||
| 878 | { |
||
| 879 | // Si mode reglement non force ou si force a CHQ |
||
| 880 | if (! empty($conf->global->FACTURE_CHQ_NUMBER)) |
||
| 881 | { |
||
| 882 | $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); |
||
| 883 | |||
| 884 | if ($conf->global->FACTURE_CHQ_NUMBER > 0) |
||
| 885 | { |
||
| 886 | $account = new Account($this->db); |
||
| 887 | $account->fetch($conf->global->FACTURE_CHQ_NUMBER); |
||
| 888 | |||
| 889 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 890 | $pdf->SetFont('','B', $default_font_size - $diffsizetitle); |
||
| 891 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); |
||
| 892 | $posy=$pdf->GetY()+1; |
||
| 893 | |||
| 894 | if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
||
| 895 | { |
||
| 896 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 897 | $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
||
| 898 | $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); |
||
| 899 | $posy=$pdf->GetY()+2; |
||
| 900 | } |
||
| 901 | } |
||
| 902 | if ($conf->global->FACTURE_CHQ_NUMBER == -1) |
||
| 903 | { |
||
| 904 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 905 | $pdf->SetFont('','B', $default_font_size - $diffsizetitle); |
||
| 906 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); |
||
| 907 | $posy=$pdf->GetY()+1; |
||
| 908 | |||
| 909 | if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
||
| 910 | { |
||
| 911 | $pdf->SetXY($this->marge_gauche, $posy); |
||
| 912 | $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
||
| 913 | $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); |
||
| 914 | $posy=$pdf->GetY()+2; |
||
| 915 | } |
||
| 916 | } |
||
| 917 | } |
||
| 918 | } |
||
| 919 | |||
| 920 | // If payment mode not forced or forced to VIR, show payment with BAN |
||
| 921 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') |
||
| 922 | { |
||
| 923 | if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
||
| 924 | { |
||
| 925 | $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank); |
||
| 926 | $account = new Account($this->db); |
||
| 927 | $account->fetch($bankid); |
||
| 928 | |||
| 929 | $curx=$this->marge_gauche; |
||
| 930 | $cury=$posy; |
||
| 931 | |||
| 932 | $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); |
||
| 933 | |||
| 934 | $posy+=2; |
||
| 935 | } |
||
| 936 | } |
||
| 937 | } |
||
| 938 | |||
| 939 | return $posy; |
||
| 940 | } |
||
| 941 | |||
| 942 | |||
| 943 | /** |
||
| 944 | * Show total to pay |
||
| 945 | * |
||
| 946 | * @param PDF $pdf Object PDF |
||
| 947 | * @param Facture $object Object invoice |
||
| 948 | * @param int $deja_regle Montant deja regle |
||
| 949 | * @param int $posy Position depart |
||
| 950 | * @param Translate $outputlangs Objet langs |
||
| 951 | * @return int Position pour suite |
||
| 952 | */ |
||
| 953 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
||
| 954 | { |
||
| 955 | global $conf,$mysoc; |
||
| 956 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 957 | |||
| 958 | $tab2_top = $posy; |
||
| 959 | $tab2_hl = 4; |
||
| 960 | $pdf->SetFont('','', $default_font_size - 1); |
||
| 961 | |||
| 962 | // Tableau total |
||
| 963 | $col1x = 120; $col2x = 170; |
||
| 964 | if ($this->page_largeur < 210) // To work with US executive format |
||
| 965 | { |
||
| 966 | $col2x-=20; |
||
| 967 | } |
||
| 968 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
||
| 969 | |||
| 970 | $useborder=0; |
||
| 971 | $index = 0; |
||
| 972 | |||
| 973 | // Total HT |
||
| 974 | $pdf->SetFillColor(255,255,255); |
||
| 975 | $pdf->SetXY($col1x, $tab2_top + 0); |
||
| 976 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
||
| 977 | |||
| 978 | $pdf->SetXY($col2x, $tab2_top + 0); |
||
| 979 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); |
||
| 980 | |||
| 981 | // Show VAT by rates and total |
||
| 982 | $pdf->SetFillColor(248,248,248); |
||
| 983 | |||
| 984 | $this->atleastoneratenotnull=0; |
||
| 985 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
||
| 986 | { |
||
| 987 | $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); |
||
| 988 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) |
||
| 989 | { |
||
| 990 | // Nothing to do |
||
| 991 | } |
||
| 992 | else |
||
| 993 | { |
||
| 994 | //Local tax 1 before VAT |
||
| 995 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
||
| 996 | //{ |
||
| 997 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
||
| 998 | { |
||
| 999 | if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
||
| 1000 | |||
| 1001 | foreach( $localtax_rate as $tvakey => $tvaval ) |
||
| 1002 | { |
||
| 1003 | if ($tvakey!=0) // On affiche pas taux 0 |
||
| 1004 | { |
||
| 1005 | //$this->atleastoneratenotnull++; |
||
| 1006 | |||
| 1007 | $index++; |
||
| 1008 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1009 | |||
| 1010 | $tvacompl=''; |
||
| 1011 | if (preg_match('/\*/',$tvakey)) |
||
| 1012 | { |
||
| 1013 | $tvakey=str_replace('*','',$tvakey); |
||
| 1014 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
||
| 1015 | } |
||
| 1016 | $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
||
| 1017 | $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
||
| 1018 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
||
| 1019 | |||
| 1020 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1021 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
||
| 1022 | } |
||
| 1023 | } |
||
| 1024 | } |
||
| 1025 | //} |
||
| 1026 | //Local tax 2 before VAT |
||
| 1027 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
||
| 1028 | //{ |
||
| 1029 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
||
| 1030 | { |
||
| 1031 | if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
||
| 1032 | |||
| 1033 | foreach( $localtax_rate as $tvakey => $tvaval ) |
||
| 1034 | { |
||
| 1035 | if ($tvakey!=0) // On affiche pas taux 0 |
||
| 1036 | { |
||
| 1037 | //$this->atleastoneratenotnull++; |
||
| 1038 | |||
| 1039 | |||
| 1040 | |||
| 1041 | $index++; |
||
| 1042 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1043 | |||
| 1044 | $tvacompl=''; |
||
| 1045 | if (preg_match('/\*/',$tvakey)) |
||
| 1046 | { |
||
| 1047 | $tvakey=str_replace('*','',$tvakey); |
||
| 1048 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
||
| 1049 | } |
||
| 1050 | $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; |
||
| 1051 | $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
||
| 1052 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
||
| 1053 | |||
| 1054 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1055 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
||
| 1056 | |||
| 1057 | } |
||
| 1058 | } |
||
| 1059 | } |
||
| 1060 | //} |
||
| 1061 | // VAT |
||
| 1062 | foreach($this->tva as $tvakey => $tvaval) |
||
| 1063 | { |
||
| 1064 | if ($tvakey > 0) // On affiche pas taux 0 |
||
| 1065 | { |
||
| 1066 | $this->atleastoneratenotnull++; |
||
| 1067 | |||
| 1068 | $index++; |
||
| 1069 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1070 | |||
| 1071 | $tvacompl=''; |
||
| 1072 | if (preg_match('/\*/',$tvakey)) |
||
| 1073 | { |
||
| 1074 | $tvakey=str_replace('*','',$tvakey); |
||
| 1075 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
||
| 1076 | } |
||
| 1077 | $totalvat =$outputlangs->transnoentities("TotalVAT").' '; |
||
| 1078 | $totalvat.=vatrate($tvakey,1).$tvacompl; |
||
| 1079 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
||
| 1080 | |||
| 1081 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1082 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
||
| 1083 | } |
||
| 1084 | } |
||
| 1085 | |||
| 1086 | //Local tax 1 after VAT |
||
| 1087 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
||
| 1088 | //{ |
||
| 1089 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
||
| 1090 | { |
||
| 1091 | if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
||
| 1092 | |||
| 1093 | foreach( $localtax_rate as $tvakey => $tvaval ) |
||
| 1094 | { |
||
| 1095 | if ($tvakey != 0) // On affiche pas taux 0 |
||
| 1096 | { |
||
| 1097 | //$this->atleastoneratenotnull++; |
||
| 1098 | |||
| 1099 | $index++; |
||
| 1100 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1101 | |||
| 1102 | $tvacompl=''; |
||
| 1103 | if (preg_match('/\*/',$tvakey)) |
||
| 1104 | { |
||
| 1105 | $tvakey=str_replace('*','',$tvakey); |
||
| 1106 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
||
| 1107 | } |
||
| 1108 | $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
||
| 1109 | |||
| 1110 | $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
||
| 1111 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
||
| 1112 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1113 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
||
| 1114 | } |
||
| 1115 | } |
||
| 1116 | } |
||
| 1117 | //} |
||
| 1118 | //Local tax 2 after VAT |
||
| 1119 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
||
| 1120 | //{ |
||
| 1121 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
||
| 1122 | { |
||
| 1123 | if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
||
| 1124 | |||
| 1125 | foreach( $localtax_rate as $tvakey => $tvaval ) |
||
| 1126 | { |
||
| 1127 | // retrieve global local tax |
||
| 1128 | if ($tvakey != 0) // On affiche pas taux 0 |
||
| 1129 | { |
||
| 1130 | //$this->atleastoneratenotnull++; |
||
| 1131 | |||
| 1132 | $index++; |
||
| 1133 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1134 | |||
| 1135 | $tvacompl=''; |
||
| 1136 | if (preg_match('/\*/',$tvakey)) |
||
| 1137 | { |
||
| 1138 | $tvakey=str_replace('*','',$tvakey); |
||
| 1139 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
||
| 1140 | } |
||
| 1141 | $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
||
| 1142 | |||
| 1143 | $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
||
| 1144 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
||
| 1145 | |||
| 1146 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1147 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
||
| 1148 | } |
||
| 1149 | } |
||
| 1150 | } |
||
| 1151 | //} |
||
| 1152 | |||
| 1153 | // Total TTC |
||
| 1154 | $index++; |
||
| 1155 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1156 | $pdf->SetTextColor(0,0,60); |
||
| 1157 | $pdf->SetFillColor(224,224,224); |
||
| 1158 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
||
| 1159 | |||
| 1160 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1161 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
||
| 1162 | } |
||
| 1163 | } |
||
| 1164 | |||
| 1165 | $pdf->SetTextColor(0,0,0); |
||
| 1166 | |||
| 1167 | /* |
||
| 1168 | $resteapayer = $object->total_ttc - $deja_regle; |
||
| 1169 | if (! empty($object->paye)) $resteapayer=0; |
||
| 1170 | */ |
||
| 1171 | |||
| 1172 | if ($deja_regle > 0) |
||
| 1173 | { |
||
| 1174 | $index++; |
||
| 1175 | |||
| 1176 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1177 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
||
| 1178 | |||
| 1179 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1180 | $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); |
||
| 1181 | |||
| 1182 | /* |
||
| 1183 | if ($object->close_code == 'discount_vat') |
||
| 1184 | { |
||
| 1185 | $index++; |
||
| 1186 | $pdf->SetFillColor(255,255,255); |
||
| 1187 | |||
| 1188 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1189 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); |
||
| 1190 | |||
| 1191 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1192 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); |
||
| 1193 | |||
| 1194 | $resteapayer=0; |
||
| 1195 | } |
||
| 1196 | */ |
||
| 1197 | |||
| 1198 | $index++; |
||
| 1199 | $pdf->SetTextColor(0,0,60); |
||
| 1200 | $pdf->SetFillColor(224,224,224); |
||
| 1201 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
||
| 1202 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
||
| 1203 | |||
| 1204 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
||
| 1205 | $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); |
||
| 1206 | |||
| 1207 | $pdf->SetFont('','', $default_font_size - 1); |
||
| 1208 | $pdf->SetTextColor(0,0,0); |
||
| 1209 | } |
||
| 1210 | |||
| 1211 | $index++; |
||
| 1212 | return ($tab2_top + ($tab2_hl * $index)); |
||
| 1213 | } |
||
| 1214 | |||
| 1215 | /** |
||
| 1216 | * Show table for lines |
||
| 1217 | * |
||
| 1218 | * @param PDF $pdf Object PDF |
||
| 1219 | * @param string $tab_top Top position of table |
||
| 1220 | * @param string $tab_height Height of table (rectangle) |
||
| 1221 | * @param int $nexY Y (not used) |
||
| 1222 | * @param Translate $outputlangs Langs object |
||
| 1223 | * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
||
| 1224 | * @param int $hidebottom Hide bottom bar of array |
||
| 1225 | * @return void |
||
| 1226 | */ |
||
| 1227 | function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
||
| 1316 | } |
||
| 1317 | } |
||
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Show top header of page. |
||
| 1321 | * |
||
| 1322 | * @param PDF $pdf Object PDF |
||
| 1323 | * @param Object $object Object to show |
||
| 1324 | * @param int $showaddress 0=no, 1=yes |
||
| 1325 | * @param Translate $outputlangs Object lang for output |
||
| 1326 | * @return void |
||
| 1327 | */ |
||
| 1328 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
||
| 1516 | } |
||
| 1517 | |||
| 1518 | /** |
||
| 1519 | * Show footer of page. Need this->emetteur object |
||
| 1520 | * |
||
| 1521 | * @param PDF $pdf PDF |
||
| 1522 | * @param Object $object Object to show |
||
| 1523 | * @param Translate $outputlangs Object lang for output |
||
| 1524 | * @param int $hidefreetext 1=Hide free text |
||
| 1525 | * @return int Return height of bottom margin including footer text |
||
| 1526 | */ |
||
| 1527 | function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
||
| 1536 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.