@@ -33,220 +33,220 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class pdf_standardlabel extends CommonStickerGenerator |
35 | 35 | { |
36 | - /** |
|
37 | - * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
38 | - * |
|
39 | - * @param PDF $pdf PDF reference |
|
40 | - * @param Translate $outputlangs Output langs |
|
41 | - * @param array $param Associative array containing label content and optional parameters |
|
42 | - * @return void |
|
43 | - */ |
|
36 | + /** |
|
37 | + * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
38 | + * |
|
39 | + * @param PDF $pdf PDF reference |
|
40 | + * @param Translate $outputlangs Output langs |
|
41 | + * @param array $param Associative array containing label content and optional parameters |
|
42 | + * @return void |
|
43 | + */ |
|
44 | 44 | function addSticker(&$pdf,$outputlangs,$param) |
45 | 45 | { |
46 | - // use this method in future refactoring |
|
47 | - } |
|
46 | + // use this method in future refactoring |
|
47 | + } |
|
48 | 48 | |
49 | 49 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
50 | - /** |
|
51 | - * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
52 | - * - %LOGO% is replace with company logo |
|
53 | - * - %PHOTO% is replace with photo provided as parameter |
|
54 | - * |
|
55 | - * @param PDF $pdf PDF reference |
|
56 | - * @param string $textleft Text left |
|
57 | - * @param string $header Header |
|
58 | - * @param string $footer Footer |
|
59 | - * @param Translate $outputlangs Output langs |
|
60 | - * @param string $textright Text right |
|
61 | - * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='') |
|
65 | - { |
|
50 | + /** |
|
51 | + * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
52 | + * - %LOGO% is replace with company logo |
|
53 | + * - %PHOTO% is replace with photo provided as parameter |
|
54 | + * |
|
55 | + * @param PDF $pdf PDF reference |
|
56 | + * @param string $textleft Text left |
|
57 | + * @param string $header Header |
|
58 | + * @param string $footer Footer |
|
59 | + * @param Translate $outputlangs Output langs |
|
60 | + * @param string $textright Text right |
|
61 | + * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='') |
|
65 | + { |
|
66 | 66 | // phpcs:enable |
67 | - global $mysoc, $conf, $langs; |
|
68 | - global $forceimgscalewidth, $forceimgscaleheight; |
|
69 | - |
|
70 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
71 | - $imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight); // Scale of image for height (1=Full height of sticker) |
|
72 | - |
|
73 | - // We are in a new page, then we must add a page |
|
74 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
75 | - $pdf->AddPage(); |
|
76 | - } |
|
77 | - $this->_First=0; |
|
78 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
79 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
80 | - |
|
81 | - // Define logo |
|
82 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
83 | - if (! is_readable($logo)) |
|
84 | - { |
|
85 | - $logo=''; |
|
86 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | - { |
|
88 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
89 | - } |
|
90 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
91 | - { |
|
92 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - // Define photo |
|
97 | - if (! empty($photo)) |
|
98 | - { |
|
99 | - if (! is_readable($photo)) $photo=''; |
|
100 | - } |
|
101 | - |
|
102 | - // Define background image |
|
103 | - $backgroundimage=''; |
|
104 | - |
|
105 | - // Print lines |
|
106 | - if ($this->code == "CARD") |
|
107 | - { |
|
108 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
109 | - //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
|
110 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
111 | - } |
|
112 | - |
|
113 | - // Background |
|
114 | - if ($backgroundimage) |
|
115 | - { |
|
116 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
117 | - } |
|
118 | - |
|
119 | - $xleft=2; $ytop=2; |
|
120 | - |
|
121 | - // Top |
|
122 | - if ($header!='') |
|
123 | - { |
|
124 | - if ($this->code == "CARD") |
|
125 | - { |
|
126 | - $pdf->SetDrawColor(128,128,128); |
|
127 | - $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
128 | - $pdf->SetDrawColor(0,0,0); |
|
129 | - } |
|
130 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
131 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
136 | - |
|
137 | - // Define widthtouse and heighttouse |
|
138 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
139 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
140 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
141 | - $tmp=dol_getImageSize($photo, false); |
|
142 | - if ($tmp['height']) |
|
143 | - { |
|
144 | - $imgratio=$tmp['width']/$tmp['height']; |
|
145 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
146 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
147 | - } |
|
148 | - //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
|
149 | - |
|
150 | - // Center |
|
151 | - if ($textright=='') // Only a left part |
|
152 | - { |
|
153 | - // Output left area |
|
154 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
155 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
156 | - else |
|
157 | - { |
|
158 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
159 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
160 | - } |
|
161 | - } |
|
162 | - else if ($textleft!='' && $textright!='') // |
|
163 | - { |
|
164 | - if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
|
165 | - { |
|
166 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
167 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
169 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
170 | - } |
|
171 | - else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
172 | - { |
|
173 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
174 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
175 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
176 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
177 | - } |
|
178 | - else // text on halft left and text on half right |
|
179 | - { |
|
180 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
181 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
182 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
183 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
184 | - } |
|
185 | - } |
|
186 | - else // Only a right part |
|
187 | - { |
|
188 | - // Output right area |
|
189 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
190 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
191 | - else |
|
192 | - { |
|
193 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - // Bottom |
|
199 | - if ($footer!='') |
|
200 | - { |
|
201 | - if ($this->code == "CARD") |
|
202 | - { |
|
203 | - $pdf->SetDrawColor(128,128,128); |
|
204 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
205 | - $pdf->SetDrawColor(0,0,0); |
|
206 | - } |
|
207 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
208 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
209 | - } |
|
210 | - //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
|
211 | - |
|
212 | - $this->_COUNTY++; |
|
213 | - |
|
214 | - if ($this->_COUNTY == $this->_Y_Number) { |
|
215 | - // Si on est en bas de page, on remonte le 'curseur' de position |
|
216 | - $this->_COUNTX++; |
|
217 | - $this->_COUNTY=0; |
|
218 | - } |
|
219 | - |
|
220 | - if ($this->_COUNTX == $this->_X_Number) { |
|
221 | - // Si on est en bout de page, alors on repart sur une nouvelle page |
|
222 | - $this->_COUNTX=0; |
|
223 | - $this->_COUNTY=0; |
|
224 | - } |
|
225 | - } |
|
67 | + global $mysoc, $conf, $langs; |
|
68 | + global $forceimgscalewidth, $forceimgscaleheight; |
|
69 | + |
|
70 | + $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
71 | + $imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight); // Scale of image for height (1=Full height of sticker) |
|
72 | + |
|
73 | + // We are in a new page, then we must add a page |
|
74 | + if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
75 | + $pdf->AddPage(); |
|
76 | + } |
|
77 | + $this->_First=0; |
|
78 | + $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
79 | + $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
80 | + |
|
81 | + // Define logo |
|
82 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
83 | + if (! is_readable($logo)) |
|
84 | + { |
|
85 | + $logo=''; |
|
86 | + if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | + { |
|
88 | + $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
89 | + } |
|
90 | + elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
91 | + { |
|
92 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + // Define photo |
|
97 | + if (! empty($photo)) |
|
98 | + { |
|
99 | + if (! is_readable($photo)) $photo=''; |
|
100 | + } |
|
101 | + |
|
102 | + // Define background image |
|
103 | + $backgroundimage=''; |
|
104 | + |
|
105 | + // Print lines |
|
106 | + if ($this->code == "CARD") |
|
107 | + { |
|
108 | + $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
109 | + //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
|
110 | + $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
111 | + } |
|
112 | + |
|
113 | + // Background |
|
114 | + if ($backgroundimage) |
|
115 | + { |
|
116 | + $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
117 | + } |
|
118 | + |
|
119 | + $xleft=2; $ytop=2; |
|
120 | + |
|
121 | + // Top |
|
122 | + if ($header!='') |
|
123 | + { |
|
124 | + if ($this->code == "CARD") |
|
125 | + { |
|
126 | + $pdf->SetDrawColor(128,128,128); |
|
127 | + $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
128 | + $pdf->SetDrawColor(0,0,0); |
|
129 | + } |
|
130 | + $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
131 | + $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
136 | + |
|
137 | + // Define widthtouse and heighttouse |
|
138 | + $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
139 | + $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
140 | + $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
141 | + $tmp=dol_getImageSize($photo, false); |
|
142 | + if ($tmp['height']) |
|
143 | + { |
|
144 | + $imgratio=$tmp['width']/$tmp['height']; |
|
145 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
146 | + else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
147 | + } |
|
148 | + //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
|
149 | + |
|
150 | + // Center |
|
151 | + if ($textright=='') // Only a left part |
|
152 | + { |
|
153 | + // Output left area |
|
154 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
155 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
156 | + else |
|
157 | + { |
|
158 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
159 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
160 | + } |
|
161 | + } |
|
162 | + else if ($textleft!='' && $textright!='') // |
|
163 | + { |
|
164 | + if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
|
165 | + { |
|
166 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
167 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | + $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
169 | + $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
170 | + } |
|
171 | + else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
172 | + { |
|
173 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
174 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
175 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
176 | + $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
177 | + } |
|
178 | + else // text on halft left and text on half right |
|
179 | + { |
|
180 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
181 | + $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
182 | + $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
183 | + $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
184 | + } |
|
185 | + } |
|
186 | + else // Only a right part |
|
187 | + { |
|
188 | + // Output right area |
|
189 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
190 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
191 | + else |
|
192 | + { |
|
193 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | + $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + // Bottom |
|
199 | + if ($footer!='') |
|
200 | + { |
|
201 | + if ($this->code == "CARD") |
|
202 | + { |
|
203 | + $pdf->SetDrawColor(128,128,128); |
|
204 | + $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
205 | + $pdf->SetDrawColor(0,0,0); |
|
206 | + } |
|
207 | + $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
208 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
209 | + } |
|
210 | + //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
|
211 | + |
|
212 | + $this->_COUNTY++; |
|
213 | + |
|
214 | + if ($this->_COUNTY == $this->_Y_Number) { |
|
215 | + // Si on est en bas de page, on remonte le 'curseur' de position |
|
216 | + $this->_COUNTX++; |
|
217 | + $this->_COUNTY=0; |
|
218 | + } |
|
219 | + |
|
220 | + if ($this->_COUNTX == $this->_X_Number) { |
|
221 | + // Si on est en bout de page, alors on repart sur une nouvelle page |
|
222 | + $this->_COUNTX=0; |
|
223 | + $this->_COUNTY=0; |
|
224 | + } |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | 228 | |
229 | 229 | |
230 | 230 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
231 | - /** |
|
232 | - * Function to build PDF on disk, then output on HTTP strem. |
|
233 | - * |
|
234 | - * @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) |
|
235 | - * @param Translate $outputlangs Lang object for output language |
|
236 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
237 | - * @param string $outputdir Output directory for pdf file |
|
238 | - * @param string $filename Short file name of PDF output file |
|
239 | - * @return int 1=OK, 0=KO |
|
240 | - */ |
|
241 | - function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf') |
|
242 | - { |
|
231 | + /** |
|
232 | + * Function to build PDF on disk, then output on HTTP strem. |
|
233 | + * |
|
234 | + * @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) |
|
235 | + * @param Translate $outputlangs Lang object for output language |
|
236 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
237 | + * @param string $outputdir Output directory for pdf file |
|
238 | + * @param string $filename Short file name of PDF output file |
|
239 | + * @return int 1=OK, 0=KO |
|
240 | + */ |
|
241 | + function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf') |
|
242 | + { |
|
243 | 243 | // phpcs:enable |
244 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
244 | + global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
245 | 245 | |
246 | - $this->code=$srctemplatepath; |
|
247 | - $this->Tformat = $_Avery_Labels[$this->code]; |
|
248 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
249 | - $this->type = 'pdf'; |
|
246 | + $this->code=$srctemplatepath; |
|
247 | + $this->Tformat = $_Avery_Labels[$this->code]; |
|
248 | + if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
249 | + $this->type = 'pdf'; |
|
250 | 250 | // standard format or custom |
251 | 251 | if ($this->Tformat['paper-size']!='custom') { |
252 | 252 | $this->format = $this->Tformat['paper-size']; |
@@ -256,99 +256,99 @@ discard block |
||
256 | 256 | $this->format = $resolution; |
257 | 257 | } |
258 | 258 | |
259 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
260 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
261 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
262 | - |
|
263 | - // Load traductions files requiredby by page |
|
264 | - $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); |
|
259 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
260 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
261 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
265 | 262 | |
266 | - $title=$outputlangs->transnoentities('Labels'); |
|
267 | - $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
263 | + // Load traductions files requiredby by page |
|
264 | + $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); |
|
268 | 265 | |
269 | - $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir); |
|
270 | - $file = $dir."/".$filename; |
|
266 | + $title=$outputlangs->transnoentities('Labels'); |
|
267 | + $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
271 | 268 | |
272 | - if (! file_exists($dir)) |
|
273 | - { |
|
274 | - if (dol_mkdir($dir) < 0) |
|
275 | - { |
|
276 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
277 | - return 0; |
|
278 | - } |
|
279 | - } |
|
269 | + $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir); |
|
270 | + $file = $dir."/".$filename; |
|
280 | 271 | |
281 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
282 | - |
|
283 | - if (class_exists('TCPDF')) |
|
284 | - { |
|
285 | - $pdf->setPrintHeader(false); |
|
286 | - $pdf->setPrintFooter(false); |
|
287 | - } |
|
288 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
289 | - |
|
290 | - $pdf->SetTitle($title); |
|
291 | - $pdf->SetSubject($title); |
|
292 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
293 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
294 | - $pdf->SetKeyWords($keywords); |
|
295 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
296 | - |
|
297 | - $pdf->SetMargins(0,0); |
|
298 | - $pdf->SetAutoPageBreak(false); |
|
299 | - |
|
300 | - $this->_Metric_Doc = $this->Tformat['metric']; |
|
301 | - // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
|
302 | - $posX=1; |
|
303 | - $posY=1; |
|
304 | - if ($posX > 0) $posX--; else $posX=0; |
|
305 | - if ($posY > 0) $posY--; else $posY=0; |
|
306 | - $this->_COUNTX = $posX; |
|
307 | - $this->_COUNTY = $posY; |
|
308 | - $this->_Set_Format($pdf, $this->Tformat); |
|
309 | - |
|
310 | - |
|
311 | - $pdf->Open(); |
|
312 | - $pdf->AddPage(); |
|
272 | + if (! file_exists($dir)) |
|
273 | + { |
|
274 | + if (dol_mkdir($dir) < 0) |
|
275 | + { |
|
276 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
277 | + return 0; |
|
278 | + } |
|
279 | + } |
|
313 | 280 | |
281 | + $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
314 | 282 | |
315 | - // Add each record |
|
316 | - foreach($arrayofrecords as $val) |
|
317 | - { |
|
318 | - // imprime le texte specifique sur la carte |
|
319 | - $this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']); |
|
320 | - } |
|
283 | + if (class_exists('TCPDF')) |
|
284 | + { |
|
285 | + $pdf->setPrintHeader(false); |
|
286 | + $pdf->setPrintFooter(false); |
|
287 | + } |
|
288 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
289 | + |
|
290 | + $pdf->SetTitle($title); |
|
291 | + $pdf->SetSubject($title); |
|
292 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
293 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
294 | + $pdf->SetKeyWords($keywords); |
|
295 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
296 | + |
|
297 | + $pdf->SetMargins(0,0); |
|
298 | + $pdf->SetAutoPageBreak(false); |
|
299 | + |
|
300 | + $this->_Metric_Doc = $this->Tformat['metric']; |
|
301 | + // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
|
302 | + $posX=1; |
|
303 | + $posY=1; |
|
304 | + if ($posX > 0) $posX--; else $posX=0; |
|
305 | + if ($posY > 0) $posY--; else $posY=0; |
|
306 | + $this->_COUNTX = $posX; |
|
307 | + $this->_COUNTY = $posY; |
|
308 | + $this->_Set_Format($pdf, $this->Tformat); |
|
309 | + |
|
310 | + |
|
311 | + $pdf->Open(); |
|
312 | + $pdf->AddPage(); |
|
313 | + |
|
314 | + |
|
315 | + // Add each record |
|
316 | + foreach($arrayofrecords as $val) |
|
317 | + { |
|
318 | + // imprime le texte specifique sur la carte |
|
319 | + $this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']); |
|
320 | + } |
|
321 | 321 | |
322 | - //$pdf->SetXY(10, 295); |
|
323 | - //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C'); |
|
322 | + //$pdf->SetXY(10, 295); |
|
323 | + //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C'); |
|
324 | 324 | |
325 | 325 | |
326 | - // Output to file |
|
327 | - $pdf->Output($file,'F'); |
|
326 | + // Output to file |
|
327 | + $pdf->Output($file,'F'); |
|
328 | 328 | |
329 | - if (! empty($conf->global->MAIN_UMASK)) |
|
330 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
329 | + if (! empty($conf->global->MAIN_UMASK)) |
|
330 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
331 | 331 | |
332 | - // Output to http stream |
|
333 | - clearstatcache(); |
|
332 | + // Output to http stream |
|
333 | + clearstatcache(); |
|
334 | 334 | |
335 | - $attachment=true; |
|
336 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
337 | - $type=dol_mimetype($filename); |
|
335 | + $attachment=true; |
|
336 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
337 | + $type=dol_mimetype($filename); |
|
338 | 338 | |
339 | - //if ($encoding) header('Content-Encoding: '.$encoding); |
|
340 | - if ($type) header('Content-Type: '.$type); |
|
341 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
342 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
339 | + //if ($encoding) header('Content-Encoding: '.$encoding); |
|
340 | + if ($type) header('Content-Type: '.$type); |
|
341 | + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
342 | + else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
343 | 343 | |
344 | - // Ajout directives pour resoudre bug IE |
|
345 | - header('Cache-Control: Public, must-revalidate'); |
|
346 | - header('Pragma: public'); |
|
344 | + // Ajout directives pour resoudre bug IE |
|
345 | + header('Cache-Control: Public, must-revalidate'); |
|
346 | + header('Pragma: public'); |
|
347 | 347 | |
348 | - readfile($file); |
|
348 | + readfile($file); |
|
349 | 349 | |
350 | - $this->result = array('fullpath'=>$file); |
|
350 | + $this->result = array('fullpath'=>$file); |
|
351 | 351 | |
352 | - return 1; |
|
353 | - } |
|
352 | + return 1; |
|
353 | + } |
|
354 | 354 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array $param Associative array containing label content and optional parameters |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - function addSticker(&$pdf,$outputlangs,$param) |
|
44 | + function addSticker(&$pdf, $outputlangs, $param) |
|
45 | 45 | { |
46 | 46 | // use this method in future refactoring |
47 | 47 | } |
@@ -61,151 +61,151 @@ discard block |
||
61 | 61 | * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='') |
|
64 | + function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '') |
|
65 | 65 | { |
66 | 66 | // phpcs:enable |
67 | 67 | global $mysoc, $conf, $langs; |
68 | 68 | global $forceimgscalewidth, $forceimgscaleheight; |
69 | 69 | |
70 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
71 | - $imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight); // Scale of image for height (1=Full height of sticker) |
|
70 | + $imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
71 | + $imgscaleheight = (empty($forceimgscaleheight) ? 0.5 : $forceimgscaleheight); // Scale of image for height (1=Full height of sticker) |
|
72 | 72 | |
73 | 73 | // We are in a new page, then we must add a page |
74 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
74 | + if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) { |
|
75 | 75 | $pdf->AddPage(); |
76 | 76 | } |
77 | - $this->_First=0; |
|
78 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
79 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
77 | + $this->_First = 0; |
|
78 | + $_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space)); |
|
79 | + $_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space)); |
|
80 | 80 | |
81 | 81 | // Define logo |
82 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
83 | - if (! is_readable($logo)) |
|
82 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
83 | + if (!is_readable($logo)) |
|
84 | 84 | { |
85 | - $logo=''; |
|
86 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
85 | + $logo = ''; |
|
86 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | 87 | { |
88 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
88 | + $logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
89 | 89 | } |
90 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
90 | + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
91 | 91 | { |
92 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
92 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Define photo |
97 | - if (! empty($photo)) |
|
97 | + if (!empty($photo)) |
|
98 | 98 | { |
99 | - if (! is_readable($photo)) $photo=''; |
|
99 | + if (!is_readable($photo)) $photo = ''; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // Define background image |
103 | - $backgroundimage=''; |
|
103 | + $backgroundimage = ''; |
|
104 | 104 | |
105 | 105 | // Print lines |
106 | 106 | if ($this->code == "CARD") |
107 | 107 | { |
108 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
108 | + $this->Tformat = $this->_Avery_Labels["CARD"]; |
|
109 | 109 | //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
110 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
110 | + $this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Background |
114 | 114 | if ($backgroundimage) |
115 | 115 | { |
116 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
116 | + $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); |
|
117 | 117 | } |
118 | 118 | |
119 | - $xleft=2; $ytop=2; |
|
119 | + $xleft = 2; $ytop = 2; |
|
120 | 120 | |
121 | 121 | // Top |
122 | - if ($header!='') |
|
122 | + if ($header != '') |
|
123 | 123 | { |
124 | 124 | if ($this->code == "CARD") |
125 | 125 | { |
126 | - $pdf->SetDrawColor(128,128,128); |
|
127 | - $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
128 | - $pdf->SetDrawColor(0,0,0); |
|
126 | + $pdf->SetDrawColor(128, 128, 128); |
|
127 | + $pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text |
|
128 | + $pdf->SetDrawColor(0, 0, 0); |
|
129 | 129 | } |
130 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
131 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
130 | + $pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text |
|
131 | + $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
135 | + $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); |
|
136 | 136 | |
137 | 137 | // Define widthtouse and heighttouse |
138 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
139 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
140 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
141 | - $tmp=dol_getImageSize($photo, false); |
|
138 | + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); |
|
139 | + $defaultratio = ($maxwidthtouse / $maxheighttouse); |
|
140 | + $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image |
|
141 | + $tmp = dol_getImageSize($photo, false); |
|
142 | 142 | if ($tmp['height']) |
143 | 143 | { |
144 | - $imgratio=$tmp['width']/$tmp['height']; |
|
144 | + $imgratio = $tmp['width'] / $tmp['height']; |
|
145 | 145 | if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
146 | 146 | else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
147 | 147 | } |
148 | 148 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
149 | 149 | |
150 | 150 | // Center |
151 | - if ($textright=='') // Only a left part |
|
151 | + if ($textright == '') // Only a left part |
|
152 | 152 | { |
153 | 153 | // Output left area |
154 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
155 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
154 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
155 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
156 | 156 | else |
157 | 157 | { |
158 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
159 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
158 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
159 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
160 | 160 | } |
161 | 161 | } |
162 | - else if ($textleft!='' && $textright!='') // |
|
162 | + else if ($textleft != '' && $textright != '') // |
|
163 | 163 | { |
164 | 164 | if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
165 | 165 | { |
166 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
167 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
169 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
166 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
167 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
168 | + $pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop); |
|
169 | + $pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
170 | 170 | } |
171 | 171 | else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
172 | 172 | { |
173 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
174 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
175 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
176 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
173 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
174 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
175 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
176 | + $pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
177 | 177 | } |
178 | 178 | else // text on halft left and text on half right |
179 | 179 | { |
180 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
181 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
182 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
183 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
180 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
181 | + $pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
182 | + $pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop); |
|
183 | + $pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | else // Only a right part |
187 | 187 | { |
188 | 188 | // Output right area |
189 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
190 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
189 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
190 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
191 | 191 | else |
192 | 192 | { |
193 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
193 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
194 | + $pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Bottom |
199 | - if ($footer!='') |
|
199 | + if ($footer != '') |
|
200 | 200 | { |
201 | 201 | if ($this->code == "CARD") |
202 | 202 | { |
203 | - $pdf->SetDrawColor(128,128,128); |
|
204 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
205 | - $pdf->SetDrawColor(0,0,0); |
|
203 | + $pdf->SetDrawColor(128, 128, 128); |
|
204 | + $pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2); |
|
205 | + $pdf->SetDrawColor(0, 0, 0); |
|
206 | 206 | } |
207 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
208 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
207 | + $pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1); |
|
208 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C'); |
|
209 | 209 | } |
210 | 210 | //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
211 | 211 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | if ($this->_COUNTY == $this->_Y_Number) { |
215 | 215 | // Si on est en bas de page, on remonte le 'curseur' de position |
216 | 216 | $this->_COUNTX++; |
217 | - $this->_COUNTY=0; |
|
217 | + $this->_COUNTY = 0; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | if ($this->_COUNTX == $this->_X_Number) { |
221 | 221 | // Si on est en bout de page, alors on repart sur une nouvelle page |
222 | - $this->_COUNTX=0; |
|
223 | - $this->_COUNTY=0; |
|
222 | + $this->_COUNTX = 0; |
|
223 | + $this->_COUNTY = 0; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -238,47 +238,47 @@ discard block |
||
238 | 238 | * @param string $filename Short file name of PDF output file |
239 | 239 | * @return int 1=OK, 0=KO |
240 | 240 | */ |
241 | - function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf') |
|
241 | + function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') |
|
242 | 242 | { |
243 | 243 | // phpcs:enable |
244 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
244 | + global $user, $conf, $langs, $mysoc, $_Avery_Labels; |
|
245 | 245 | |
246 | - $this->code=$srctemplatepath; |
|
246 | + $this->code = $srctemplatepath; |
|
247 | 247 | $this->Tformat = $_Avery_Labels[$this->code]; |
248 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
248 | + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } |
|
249 | 249 | $this->type = 'pdf'; |
250 | 250 | // standard format or custom |
251 | - if ($this->Tformat['paper-size']!='custom') { |
|
251 | + if ($this->Tformat['paper-size'] != 'custom') { |
|
252 | 252 | $this->format = $this->Tformat['paper-size']; |
253 | 253 | } else { |
254 | 254 | //custom |
255 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
255 | + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
256 | 256 | $this->format = $resolution; |
257 | 257 | } |
258 | 258 | |
259 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
259 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
260 | 260 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
261 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
261 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
262 | 262 | |
263 | 263 | // Load traductions files requiredby by page |
264 | 264 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); |
265 | 265 | |
266 | - $title=$outputlangs->transnoentities('Labels'); |
|
267 | - $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
266 | + $title = $outputlangs->transnoentities('Labels'); |
|
267 | + $keywords = $title." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
268 | 268 | |
269 | - $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir); |
|
269 | + $dir = (empty($outputdir) ? $conf->adherent->dir_temp : $outputdir); |
|
270 | 270 | $file = $dir."/".$filename; |
271 | 271 | |
272 | - if (! file_exists($dir)) |
|
272 | + if (!file_exists($dir)) |
|
273 | 273 | { |
274 | 274 | if (dol_mkdir($dir) < 0) |
275 | 275 | { |
276 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
276 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
277 | 277 | return 0; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
281 | + $pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']); |
|
282 | 282 | |
283 | 283 | if (class_exists('TCPDF')) |
284 | 284 | { |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
293 | 293 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
294 | 294 | $pdf->SetKeyWords($keywords); |
295 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
295 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
296 | 296 | |
297 | - $pdf->SetMargins(0,0); |
|
297 | + $pdf->SetMargins(0, 0); |
|
298 | 298 | $pdf->SetAutoPageBreak(false); |
299 | 299 | |
300 | 300 | $this->_Metric_Doc = $this->Tformat['metric']; |
301 | 301 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
302 | - $posX=1; |
|
303 | - $posY=1; |
|
304 | - if ($posX > 0) $posX--; else $posX=0; |
|
305 | - if ($posY > 0) $posY--; else $posY=0; |
|
302 | + $posX = 1; |
|
303 | + $posY = 1; |
|
304 | + if ($posX > 0) $posX--; else $posX = 0; |
|
305 | + if ($posY > 0) $posY--; else $posY = 0; |
|
306 | 306 | $this->_COUNTX = $posX; |
307 | 307 | $this->_COUNTY = $posY; |
308 | 308 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | |
314 | 314 | |
315 | 315 | // Add each record |
316 | - foreach($arrayofrecords as $val) |
|
316 | + foreach ($arrayofrecords as $val) |
|
317 | 317 | { |
318 | 318 | // imprime le texte specifique sur la carte |
319 | - $this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']); |
|
319 | + $this->Add_PDF_label($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['photo']); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | //$pdf->SetXY(10, 295); |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | |
325 | 325 | |
326 | 326 | // Output to file |
327 | - $pdf->Output($file,'F'); |
|
327 | + $pdf->Output($file, 'F'); |
|
328 | 328 | |
329 | - if (! empty($conf->global->MAIN_UMASK)) |
|
329 | + if (!empty($conf->global->MAIN_UMASK)) |
|
330 | 330 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
331 | 331 | |
332 | 332 | // Output to http stream |
333 | 333 | clearstatcache(); |
334 | 334 | |
335 | - $attachment=true; |
|
336 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
337 | - $type=dol_mimetype($filename); |
|
335 | + $attachment = true; |
|
336 | + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; |
|
337 | + $type = dol_mimetype($filename); |
|
338 | 338 | |
339 | 339 | //if ($encoding) header('Content-Encoding: '.$encoding); |
340 | 340 | if ($type) header('Content-Type: '.$type); |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
87 | 87 | { |
88 | 88 | $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
89 | - } |
|
90 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
89 | + } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
91 | 90 | { |
92 | 91 | $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
93 | 92 | } |
@@ -96,7 +95,9 @@ discard block |
||
96 | 95 | // Define photo |
97 | 96 | if (! empty($photo)) |
98 | 97 | { |
99 | - if (! is_readable($photo)) $photo=''; |
|
98 | + if (! is_readable($photo)) { |
|
99 | + $photo=''; |
|
100 | + } |
|
100 | 101 | } |
101 | 102 | |
102 | 103 | // Define background image |
@@ -142,53 +143,58 @@ discard block |
||
142 | 143 | if ($tmp['height']) |
143 | 144 | { |
144 | 145 | $imgratio=$tmp['width']/$tmp['height']; |
145 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
146 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
146 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
147 | 147 | } |
148 | 148 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
149 | 149 | |
150 | 150 | // Center |
151 | - if ($textright=='') // Only a left part |
|
151 | + if ($textright=='') { |
|
152 | + // Only a left part |
|
152 | 153 | { |
153 | 154 | // Output left area |
154 | 155 | if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
155 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
156 | - else |
|
156 | + } else if ($textleft == '%PHOTO%' && $photo) { |
|
157 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
158 | + } else |
|
157 | 159 | { |
158 | 160 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
159 | 161 | $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
160 | 162 | } |
161 | - } |
|
162 | - else if ($textleft!='' && $textright!='') // |
|
163 | + } else if ($textleft!='' && $textright!='') { |
|
164 | + // |
|
163 | 165 | { |
164 | 166 | if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
165 | 167 | { |
166 | 168 | if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
167 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
169 | + } else if ($textleft == '%PHOTO%' && $photo) { |
|
170 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
171 | + } |
|
168 | 172 | $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
169 | 173 | $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
170 | - } |
|
171 | - else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
174 | + } else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
172 | 175 | { |
173 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
174 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
176 | + if ($textright == '%LOGO%' && $logo) { |
|
177 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
178 | + } else if ($textright == '%PHOTO%' && $photo) { |
|
179 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
180 | + } |
|
175 | 181 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
176 | 182 | $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
177 | - } |
|
178 | - else // text on halft left and text on half right |
|
183 | + } else // text on halft left and text on half right |
|
179 | 184 | { |
180 | 185 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
181 | 186 | $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
182 | 187 | $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
183 | 188 | $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
184 | 189 | } |
185 | - } |
|
186 | - else // Only a right part |
|
190 | + } else // Only a right part |
|
187 | 191 | { |
188 | 192 | // Output right area |
189 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
190 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
191 | - else |
|
193 | + if ($textright == '%LOGO%' && $logo) { |
|
194 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
195 | + } else if ($textright == '%PHOTO%' && $photo) { |
|
196 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
197 | + } else |
|
192 | 198 | { |
193 | 199 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
194 | 200 | $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
@@ -256,9 +262,13 @@ discard block |
||
256 | 262 | $this->format = $resolution; |
257 | 263 | } |
258 | 264 | |
259 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
265 | + if (! is_object($outputlangs)) { |
|
266 | + $outputlangs=$langs; |
|
267 | + } |
|
260 | 268 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
261 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
269 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
270 | + $outputlangs->charset_output='ISO-8859-1'; |
|
271 | + } |
|
262 | 272 | |
263 | 273 | // Load traductions files requiredby by page |
264 | 274 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); |
@@ -292,7 +302,9 @@ discard block |
||
292 | 302 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
293 | 303 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
294 | 304 | $pdf->SetKeyWords($keywords); |
295 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
305 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
306 | + $pdf->SetCompression(false); |
|
307 | + } |
|
296 | 308 | |
297 | 309 | $pdf->SetMargins(0,0); |
298 | 310 | $pdf->SetAutoPageBreak(false); |
@@ -301,8 +313,16 @@ discard block |
||
301 | 313 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
302 | 314 | $posX=1; |
303 | 315 | $posY=1; |
304 | - if ($posX > 0) $posX--; else $posX=0; |
|
305 | - if ($posY > 0) $posY--; else $posY=0; |
|
316 | + if ($posX > 0) { |
|
317 | + $posX--; |
|
318 | + } else { |
|
319 | + $posX=0; |
|
320 | + } |
|
321 | + if ($posY > 0) { |
|
322 | + $posY--; |
|
323 | + } else { |
|
324 | + $posY=0; |
|
325 | + } |
|
306 | 326 | $this->_COUNTX = $posX; |
307 | 327 | $this->_COUNTY = $posY; |
308 | 328 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -326,20 +346,28 @@ discard block |
||
326 | 346 | // Output to file |
327 | 347 | $pdf->Output($file,'F'); |
328 | 348 | |
329 | - if (! empty($conf->global->MAIN_UMASK)) |
|
330 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
349 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
350 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
351 | + } |
|
331 | 352 | |
332 | 353 | // Output to http stream |
333 | 354 | clearstatcache(); |
334 | 355 | |
335 | 356 | $attachment=true; |
336 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
357 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) { |
|
358 | + $attachment=false; |
|
359 | + } |
|
337 | 360 | $type=dol_mimetype($filename); |
338 | 361 | |
339 | 362 | //if ($encoding) header('Content-Encoding: '.$encoding); |
340 | - if ($type) header('Content-Type: '.$type); |
|
341 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
342 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
363 | + if ($type) { |
|
364 | + header('Content-Type: '.$type); |
|
365 | + } |
|
366 | + if ($attachment) { |
|
367 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
368 | + } else { |
|
369 | + header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
370 | + } |
|
343 | 371 | |
344 | 372 | // Ajout directives pour resoudre bug IE |
345 | 373 | header('Cache-Control: Public, must-revalidate'); |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class ModelePDFLabels |
36 | 36 | { |
37 | - /** |
|
38 | - * @var string Error code (or message) |
|
39 | - */ |
|
40 | - public $error=''; |
|
37 | + /** |
|
38 | + * @var string Error code (or message) |
|
39 | + */ |
|
40 | + public $error=''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
44 | - /** |
|
45 | - * Return list of active generation modules |
|
46 | - * |
|
44 | + /** |
|
45 | + * Return list of active generation modules |
|
46 | + * |
|
47 | 47 | * @param DoliDB $db Database handler |
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | - */ |
|
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
52 | - { |
|
50 | + */ |
|
51 | + function liste_modeles($db,$maxfilenamelength=0) |
|
52 | + { |
|
53 | 53 | // phpcs:enable |
54 | - global $conf; |
|
54 | + global $conf; |
|
55 | 55 | |
56 | - $type='members_labels'; |
|
57 | - $liste=array(); |
|
56 | + $type='members_labels'; |
|
57 | + $liste=array(); |
|
58 | 58 | |
59 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
59 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
61 | 61 | |
62 | - return $liste; |
|
63 | - } |
|
62 | + return $liste; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -80,92 +80,92 @@ discard block |
||
80 | 80 | function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf') |
81 | 81 | { |
82 | 82 | // phpcs:enable |
83 | - global $conf,$langs; |
|
84 | - $langs->load("members"); |
|
85 | - |
|
86 | - $error=0; |
|
87 | - |
|
88 | - // Increase limit for PDF build |
|
89 | - $err=error_reporting(); |
|
90 | - error_reporting(0); |
|
91 | - @set_time_limit(120); |
|
92 | - error_reporting($err); |
|
93 | - |
|
94 | - $code=''; |
|
95 | - $srctemplatepath=''; |
|
96 | - |
|
97 | - // Positionne le modele sur le nom du modele a utiliser |
|
98 | - if (! dol_strlen($modele)) |
|
99 | - { |
|
100 | - if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) |
|
101 | - { |
|
102 | - $code = $conf->global->ADHERENT_ETIQUETTE_TYPE; |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - $code = $modele; |
|
107 | - } |
|
108 | - } |
|
109 | - else $code=$modele; |
|
110 | - |
|
111 | - // If selected modele is a filename template (then $modele="modelname:filename") |
|
112 | - $tmp=explode(':',$template,2); |
|
113 | - if (! empty($tmp[1])) |
|
114 | - { |
|
115 | - $template=$tmp[0]; |
|
116 | - $srctemplatepath=$tmp[1]; |
|
117 | - } |
|
118 | - else $srctemplatepath=$code; |
|
119 | - |
|
120 | - dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG); |
|
121 | - |
|
122 | - // Search template files |
|
123 | - $file=''; $classname=''; $filefound=0; |
|
124 | - $dirmodels=array('/'); |
|
125 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
126 | - foreach($dirmodels as $reldir) |
|
127 | - { |
|
128 | - foreach(array('doc','pdf') as $prefix) |
|
129 | - { |
|
130 | - $file = $prefix."_".$template.".class.php"; |
|
131 | - |
|
132 | - // On verifie l'emplacement du modele |
|
133 | - $file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0); |
|
134 | - if (file_exists($file)) |
|
135 | - { |
|
136 | - $filefound=1; |
|
137 | - $classname=$prefix.'_'.$template; |
|
138 | - break; |
|
139 | - } |
|
140 | - } |
|
141 | - if ($filefound) break; |
|
142 | - } |
|
143 | - |
|
144 | - // Charge le modele |
|
145 | - if ($filefound) |
|
146 | - { |
|
147 | - require_once $file; |
|
148 | - |
|
149 | - $obj = new $classname($db); |
|
150 | - |
|
151 | - // We save charset_output to restore it because write_file can change it if needed for |
|
152 | - // output format that does not support UTF8. |
|
153 | - $sav_charset_output=$outputlangs->charset_output; |
|
154 | - if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0) |
|
155 | - { |
|
156 | - $outputlangs->charset_output=$sav_charset_output; |
|
157 | - return 1; |
|
158 | - } |
|
159 | - else |
|
160 | - { |
|
161 | - $outputlangs->charset_output=$sav_charset_output; |
|
162 | - dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error); |
|
163 | - return -1; |
|
164 | - } |
|
165 | - } |
|
166 | - else |
|
167 | - { |
|
168 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
169 | - return -1; |
|
170 | - } |
|
83 | + global $conf,$langs; |
|
84 | + $langs->load("members"); |
|
85 | + |
|
86 | + $error=0; |
|
87 | + |
|
88 | + // Increase limit for PDF build |
|
89 | + $err=error_reporting(); |
|
90 | + error_reporting(0); |
|
91 | + @set_time_limit(120); |
|
92 | + error_reporting($err); |
|
93 | + |
|
94 | + $code=''; |
|
95 | + $srctemplatepath=''; |
|
96 | + |
|
97 | + // Positionne le modele sur le nom du modele a utiliser |
|
98 | + if (! dol_strlen($modele)) |
|
99 | + { |
|
100 | + if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) |
|
101 | + { |
|
102 | + $code = $conf->global->ADHERENT_ETIQUETTE_TYPE; |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + $code = $modele; |
|
107 | + } |
|
108 | + } |
|
109 | + else $code=$modele; |
|
110 | + |
|
111 | + // If selected modele is a filename template (then $modele="modelname:filename") |
|
112 | + $tmp=explode(':',$template,2); |
|
113 | + if (! empty($tmp[1])) |
|
114 | + { |
|
115 | + $template=$tmp[0]; |
|
116 | + $srctemplatepath=$tmp[1]; |
|
117 | + } |
|
118 | + else $srctemplatepath=$code; |
|
119 | + |
|
120 | + dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG); |
|
121 | + |
|
122 | + // Search template files |
|
123 | + $file=''; $classname=''; $filefound=0; |
|
124 | + $dirmodels=array('/'); |
|
125 | + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
126 | + foreach($dirmodels as $reldir) |
|
127 | + { |
|
128 | + foreach(array('doc','pdf') as $prefix) |
|
129 | + { |
|
130 | + $file = $prefix."_".$template.".class.php"; |
|
131 | + |
|
132 | + // On verifie l'emplacement du modele |
|
133 | + $file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0); |
|
134 | + if (file_exists($file)) |
|
135 | + { |
|
136 | + $filefound=1; |
|
137 | + $classname=$prefix.'_'.$template; |
|
138 | + break; |
|
139 | + } |
|
140 | + } |
|
141 | + if ($filefound) break; |
|
142 | + } |
|
143 | + |
|
144 | + // Charge le modele |
|
145 | + if ($filefound) |
|
146 | + { |
|
147 | + require_once $file; |
|
148 | + |
|
149 | + $obj = new $classname($db); |
|
150 | + |
|
151 | + // We save charset_output to restore it because write_file can change it if needed for |
|
152 | + // output format that does not support UTF8. |
|
153 | + $sav_charset_output=$outputlangs->charset_output; |
|
154 | + if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0) |
|
155 | + { |
|
156 | + $outputlangs->charset_output=$sav_charset_output; |
|
157 | + return 1; |
|
158 | + } |
|
159 | + else |
|
160 | + { |
|
161 | + $outputlangs->charset_output=$sav_charset_output; |
|
162 | + dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error); |
|
163 | + return -1; |
|
164 | + } |
|
165 | + } |
|
166 | + else |
|
167 | + { |
|
168 | + dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
169 | + return -1; |
|
170 | + } |
|
171 | 171 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | 50 | */ |
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
51 | + function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | // phpcs:enable |
54 | 54 | global $conf; |
55 | 55 | |
56 | - $type='members_labels'; |
|
57 | - $liste=array(); |
|
56 | + $type = 'members_labels'; |
|
57 | + $liste = array(); |
|
58 | 58 | |
59 | 59 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
60 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
60 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | 62 | return $liste; |
63 | 63 | } |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | * @param string $filename Short file name of PDF output file |
78 | 78 | * @return int <0 if KO, >0 if OK |
79 | 79 | */ |
80 | -function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf') |
|
80 | +function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir = '', $template = 'standardlabel', $filename = 'tmp_address_sheet.pdf') |
|
81 | 81 | { |
82 | 82 | // phpcs:enable |
83 | - global $conf,$langs; |
|
83 | + global $conf, $langs; |
|
84 | 84 | $langs->load("members"); |
85 | 85 | |
86 | - $error=0; |
|
86 | + $error = 0; |
|
87 | 87 | |
88 | 88 | // Increase limit for PDF build |
89 | - $err=error_reporting(); |
|
89 | + $err = error_reporting(); |
|
90 | 90 | error_reporting(0); |
91 | 91 | @set_time_limit(120); |
92 | 92 | error_reporting($err); |
93 | 93 | |
94 | - $code=''; |
|
95 | - $srctemplatepath=''; |
|
94 | + $code = ''; |
|
95 | + $srctemplatepath = ''; |
|
96 | 96 | |
97 | 97 | // Positionne le modele sur le nom du modele a utiliser |
98 | - if (! dol_strlen($modele)) |
|
98 | + if (!dol_strlen($modele)) |
|
99 | 99 | { |
100 | - if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) |
|
100 | + if (!empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) |
|
101 | 101 | { |
102 | 102 | $code = $conf->global->ADHERENT_ETIQUETTE_TYPE; |
103 | 103 | } |
@@ -106,35 +106,35 @@ discard block |
||
106 | 106 | $code = $modele; |
107 | 107 | } |
108 | 108 | } |
109 | - else $code=$modele; |
|
109 | + else $code = $modele; |
|
110 | 110 | |
111 | 111 | // If selected modele is a filename template (then $modele="modelname:filename") |
112 | - $tmp=explode(':',$template,2); |
|
113 | - if (! empty($tmp[1])) |
|
112 | + $tmp = explode(':', $template, 2); |
|
113 | + if (!empty($tmp[1])) |
|
114 | 114 | { |
115 | - $template=$tmp[0]; |
|
116 | - $srctemplatepath=$tmp[1]; |
|
115 | + $template = $tmp[0]; |
|
116 | + $srctemplatepath = $tmp[1]; |
|
117 | 117 | } |
118 | - else $srctemplatepath=$code; |
|
118 | + else $srctemplatepath = $code; |
|
119 | 119 | |
120 | 120 | dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG); |
121 | 121 | |
122 | 122 | // Search template files |
123 | - $file=''; $classname=''; $filefound=0; |
|
124 | - $dirmodels=array('/'); |
|
125 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
126 | - foreach($dirmodels as $reldir) |
|
123 | + $file = ''; $classname = ''; $filefound = 0; |
|
124 | + $dirmodels = array('/'); |
|
125 | + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
126 | + foreach ($dirmodels as $reldir) |
|
127 | 127 | { |
128 | - foreach(array('doc','pdf') as $prefix) |
|
128 | + foreach (array('doc', 'pdf') as $prefix) |
|
129 | 129 | { |
130 | 130 | $file = $prefix."_".$template.".class.php"; |
131 | 131 | |
132 | 132 | // On verifie l'emplacement du modele |
133 | - $file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0); |
|
133 | + $file = dol_buildpath($reldir."core/modules/printsheet/doc/".$file, 0); |
|
134 | 134 | if (file_exists($file)) |
135 | 135 | { |
136 | - $filefound=1; |
|
137 | - $classname=$prefix.'_'.$template; |
|
136 | + $filefound = 1; |
|
137 | + $classname = $prefix.'_'.$template; |
|
138 | 138 | break; |
139 | 139 | } |
140 | 140 | } |
@@ -150,22 +150,22 @@ discard block |
||
150 | 150 | |
151 | 151 | // We save charset_output to restore it because write_file can change it if needed for |
152 | 152 | // output format that does not support UTF8. |
153 | - $sav_charset_output=$outputlangs->charset_output; |
|
153 | + $sav_charset_output = $outputlangs->charset_output; |
|
154 | 154 | if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0) |
155 | 155 | { |
156 | - $outputlangs->charset_output=$sav_charset_output; |
|
156 | + $outputlangs->charset_output = $sav_charset_output; |
|
157 | 157 | return 1; |
158 | 158 | } |
159 | 159 | else |
160 | 160 | { |
161 | - $outputlangs->charset_output=$sav_charset_output; |
|
162 | - dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error); |
|
161 | + $outputlangs->charset_output = $sav_charset_output; |
|
162 | + dol_print_error($db, "doc_label_pdf_create Error: ".$obj->error); |
|
163 | 163 | return -1; |
164 | 164 | } |
165 | 165 | } |
166 | 166 | else |
167 | 167 | { |
168 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
168 | + dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file)); |
|
169 | 169 | return -1; |
170 | 170 | } |
171 | 171 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) |
101 | 101 | { |
102 | 102 | $code = $conf->global->ADHERENT_ETIQUETTE_TYPE; |
103 | - } |
|
104 | - else |
|
103 | + } else |
|
105 | 104 | { |
106 | 105 | $code = $modele; |
107 | 106 | } |
107 | + } else { |
|
108 | + $code=$modele; |
|
108 | 109 | } |
109 | - else $code=$modele; |
|
110 | 110 | |
111 | 111 | // If selected modele is a filename template (then $modele="modelname:filename") |
112 | 112 | $tmp=explode(':',$template,2); |
@@ -114,15 +114,18 @@ discard block |
||
114 | 114 | { |
115 | 115 | $template=$tmp[0]; |
116 | 116 | $srctemplatepath=$tmp[1]; |
117 | + } else { |
|
118 | + $srctemplatepath=$code; |
|
117 | 119 | } |
118 | - else $srctemplatepath=$code; |
|
119 | 120 | |
120 | 121 | dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG); |
121 | 122 | |
122 | 123 | // Search template files |
123 | 124 | $file=''; $classname=''; $filefound=0; |
124 | 125 | $dirmodels=array('/'); |
125 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
126 | + if (is_array($conf->modules_parts['models'])) { |
|
127 | + $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
128 | + } |
|
126 | 129 | foreach($dirmodels as $reldir) |
127 | 130 | { |
128 | 131 | foreach(array('doc','pdf') as $prefix) |
@@ -138,7 +141,9 @@ discard block |
||
138 | 141 | break; |
139 | 142 | } |
140 | 143 | } |
141 | - if ($filefound) break; |
|
144 | + if ($filefound) { |
|
145 | + break; |
|
146 | + } |
|
142 | 147 | } |
143 | 148 | |
144 | 149 | // Charge le modele |
@@ -155,15 +160,13 @@ discard block |
||
155 | 160 | { |
156 | 161 | $outputlangs->charset_output=$sav_charset_output; |
157 | 162 | return 1; |
158 | - } |
|
159 | - else |
|
163 | + } else |
|
160 | 164 | { |
161 | 165 | $outputlangs->charset_output=$sav_charset_output; |
162 | 166 | dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error); |
163 | 167 | return -1; |
164 | 168 | } |
165 | - } |
|
166 | - else |
|
169 | + } else |
|
167 | 170 | { |
168 | 171 | dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
169 | 172 | return -1; |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | */ |
38 | 38 | abstract class ModelePDFSuppliersOrders extends CommonDocGenerator |
39 | 39 | { |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | 45 | |
46 | 46 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
47 | - /** |
|
48 | - * Return list of active generation models |
|
49 | - * |
|
47 | + /** |
|
48 | + * Return list of active generation models |
|
49 | + * |
|
50 | 50 | * @param DoliDB $db Database handler |
51 | 51 | * @param integer $maxfilenamelength Max length of value to show |
52 | 52 | * @return array List of templates |
53 | - */ |
|
54 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
55 | - { |
|
56 | - // phpcs:enable |
|
57 | - global $conf; |
|
53 | + */ |
|
54 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
55 | + { |
|
56 | + // phpcs:enable |
|
57 | + global $conf; |
|
58 | 58 | |
59 | - $type='order_supplier'; |
|
60 | - $liste=array(); |
|
59 | + $type='order_supplier'; |
|
60 | + $liste=array(); |
|
61 | 61 | |
62 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
63 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
62 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
63 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
64 | 64 | |
65 | - return $liste; |
|
66 | - } |
|
65 | + return $liste; |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -73,74 +73,74 @@ discard block |
||
73 | 73 | */ |
74 | 74 | abstract class ModeleNumRefSuppliersOrders |
75 | 75 | { |
76 | - /** |
|
77 | - * @var string Error code (or message) |
|
78 | - */ |
|
79 | - public $error=''; |
|
80 | - |
|
81 | - /** Return if a model can be used or not |
|
82 | - * |
|
83 | - * @return boolean true if model can be used |
|
84 | - */ |
|
85 | - function isEnabled() |
|
86 | - { |
|
87 | - return true; |
|
88 | - } |
|
89 | - |
|
90 | - /** Returns default description of numbering model |
|
91 | - * |
|
92 | - * @return string Description Text |
|
93 | - */ |
|
94 | - function info() |
|
95 | - { |
|
96 | - global $langs; |
|
97 | - $langs->load("orders"); |
|
98 | - return $langs->trans("NoDescription"); |
|
99 | - } |
|
100 | - |
|
101 | - /** Returns a numbering example |
|
102 | - * |
|
103 | - * @return string Example |
|
104 | - */ |
|
105 | - function getExample() |
|
106 | - { |
|
107 | - global $langs; |
|
108 | - $langs->load("orders"); |
|
109 | - return $langs->trans("NoExample"); |
|
110 | - } |
|
111 | - |
|
112 | - /** Tests if existing numbers make problems with numbering |
|
113 | - * |
|
114 | - * @return boolean false if conflict, true if ok |
|
115 | - */ |
|
116 | - function canBeActivated() |
|
117 | - { |
|
118 | - return true; |
|
119 | - } |
|
120 | - |
|
121 | - /** Returns next value assigned |
|
122 | - * |
|
123 | - * @return string Valeur |
|
124 | - */ |
|
125 | - function getNextValue() |
|
126 | - { |
|
127 | - global $langs; |
|
128 | - return $langs->trans("NotAvailable"); |
|
129 | - } |
|
130 | - |
|
131 | - /** Returns version of the numbering model |
|
132 | - * |
|
133 | - * @return string Value |
|
134 | - */ |
|
135 | - function getVersion() |
|
136 | - { |
|
137 | - global $langs; |
|
138 | - $langs->load("admin"); |
|
139 | - |
|
140 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
141 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
142 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
143 | - if ($this->version) return $this->version; |
|
144 | - return $langs->trans("NotAvailable"); |
|
145 | - } |
|
76 | + /** |
|
77 | + * @var string Error code (or message) |
|
78 | + */ |
|
79 | + public $error=''; |
|
80 | + |
|
81 | + /** Return if a model can be used or not |
|
82 | + * |
|
83 | + * @return boolean true if model can be used |
|
84 | + */ |
|
85 | + function isEnabled() |
|
86 | + { |
|
87 | + return true; |
|
88 | + } |
|
89 | + |
|
90 | + /** Returns default description of numbering model |
|
91 | + * |
|
92 | + * @return string Description Text |
|
93 | + */ |
|
94 | + function info() |
|
95 | + { |
|
96 | + global $langs; |
|
97 | + $langs->load("orders"); |
|
98 | + return $langs->trans("NoDescription"); |
|
99 | + } |
|
100 | + |
|
101 | + /** Returns a numbering example |
|
102 | + * |
|
103 | + * @return string Example |
|
104 | + */ |
|
105 | + function getExample() |
|
106 | + { |
|
107 | + global $langs; |
|
108 | + $langs->load("orders"); |
|
109 | + return $langs->trans("NoExample"); |
|
110 | + } |
|
111 | + |
|
112 | + /** Tests if existing numbers make problems with numbering |
|
113 | + * |
|
114 | + * @return boolean false if conflict, true if ok |
|
115 | + */ |
|
116 | + function canBeActivated() |
|
117 | + { |
|
118 | + return true; |
|
119 | + } |
|
120 | + |
|
121 | + /** Returns next value assigned |
|
122 | + * |
|
123 | + * @return string Valeur |
|
124 | + */ |
|
125 | + function getNextValue() |
|
126 | + { |
|
127 | + global $langs; |
|
128 | + return $langs->trans("NotAvailable"); |
|
129 | + } |
|
130 | + |
|
131 | + /** Returns version of the numbering model |
|
132 | + * |
|
133 | + * @return string Value |
|
134 | + */ |
|
135 | + function getVersion() |
|
136 | + { |
|
137 | + global $langs; |
|
138 | + $langs->load("admin"); |
|
139 | + |
|
140 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
141 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
142 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
143 | + if ($this->version) return $this->version; |
|
144 | + return $langs->trans("NotAvailable"); |
|
145 | + } |
|
146 | 146 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * and parent class for supplier orders numbering models |
30 | 30 | */ |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
32 | -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | |
46 | 46 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | * @param integer $maxfilenamelength Max length of value to show |
52 | 52 | * @return array List of templates |
53 | 53 | */ |
54 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
54 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
55 | 55 | { |
56 | 56 | // phpcs:enable |
57 | 57 | global $conf; |
58 | 58 | |
59 | - $type='order_supplier'; |
|
60 | - $liste=array(); |
|
59 | + $type = 'order_supplier'; |
|
60 | + $liste = array(); |
|
61 | 61 | |
62 | 62 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
63 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
63 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
64 | 64 | |
65 | 65 | return $liste; |
66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * @var string Error code (or message) |
78 | 78 | */ |
79 | - public $error=''; |
|
79 | + public $error = ''; |
|
80 | 80 | |
81 | 81 | /** Return if a model can be used or not |
82 | 82 | * |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders |
34 | 34 | { |
35 | - /** |
|
35 | + /** |
|
36 | 36 | * Dolibarr version of the loaded document |
37 | 37 | * @public string |
38 | 38 | */ |
39 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * @var string Error code (or message) |
43 | 43 | */ |
44 | 44 | public $error = ''; |
45 | 45 | |
46 | - /** |
|
47 | - * @var string Nom du modele |
|
48 | - * @deprecated |
|
49 | - * @see name |
|
50 | - */ |
|
51 | - public $nom='Orchidee'; |
|
46 | + /** |
|
47 | + * @var string Nom du modele |
|
48 | + * @deprecated |
|
49 | + * @see name |
|
50 | + */ |
|
51 | + public $nom='Orchidee'; |
|
52 | 52 | |
53 | - /** |
|
54 | - * @var string model name |
|
55 | - */ |
|
56 | - public $name='Orchidee'; |
|
53 | + /** |
|
54 | + * @var string model name |
|
55 | + */ |
|
56 | + public $name='Orchidee'; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string Texte descripif |
63 | 63 | */ |
64 | - function info() |
|
64 | + function info() |
|
65 | 65 | { |
66 | - global $conf, $langs; |
|
66 | + global $conf, $langs; |
|
67 | 67 | |
68 | - // Load translation files required by the page |
|
68 | + // Load translation files required by the page |
|
69 | 69 | $langs->loadLangs(array("bills","admin")); |
70 | 70 | |
71 | - $form = new Form($this->db); |
|
71 | + $form = new Form($this->db); |
|
72 | 72 | |
73 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
74 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | - $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">'; |
|
78 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
73 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
74 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | + $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">'; |
|
78 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
79 | 79 | |
80 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
83 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
84 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
80 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
82 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
83 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
84 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
85 | 85 | |
86 | - // Parametrage du prefix |
|
87 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | + // Parametrage du prefix |
|
87 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>'; |
|
89 | 89 | |
90 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
90 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
91 | 91 | |
92 | - $texte.= '</tr>'; |
|
92 | + $texte.= '</tr>'; |
|
93 | 93 | |
94 | - $texte.= '</table>'; |
|
95 | - $texte.= '</form>'; |
|
94 | + $texte.= '</table>'; |
|
95 | + $texte.= '</form>'; |
|
96 | 96 | |
97 | - return $texte; |
|
97 | + return $texte; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,54 +104,54 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function getExample() |
106 | 106 | { |
107 | - global $conf,$langs,$mysoc; |
|
108 | - |
|
109 | - $old_code_client=$mysoc->code_client; |
|
110 | - $mysoc->code_client='CCCCCCCCCC'; |
|
111 | - $numExample = $this->getNextValue($mysoc,''); |
|
112 | - $mysoc->code_client=$old_code_client; |
|
113 | - |
|
114 | - if (! $numExample) |
|
115 | - { |
|
116 | - $numExample = $langs->trans('NotConfigured'); |
|
117 | - } |
|
118 | - return $numExample; |
|
107 | + global $conf,$langs,$mysoc; |
|
108 | + |
|
109 | + $old_code_client=$mysoc->code_client; |
|
110 | + $mysoc->code_client='CCCCCCCCCC'; |
|
111 | + $numExample = $this->getNextValue($mysoc,''); |
|
112 | + $mysoc->code_client=$old_code_client; |
|
113 | + |
|
114 | + if (! $numExample) |
|
115 | + { |
|
116 | + $numExample = $langs->trans('NotConfigured'); |
|
117 | + } |
|
118 | + return $numExample; |
|
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Return next value |
|
123 | - * |
|
124 | - * @param Societe $objsoc Object third party |
|
125 | - * @param Object $object Object |
|
121 | + /** |
|
122 | + * Return next value |
|
123 | + * |
|
124 | + * @param Societe $objsoc Object third party |
|
125 | + * @param Object $object Object |
|
126 | 126 | * @return string Value if OK, 0 if KO |
127 | - */ |
|
127 | + */ |
|
128 | 128 | function getNextValue($objsoc=0,$object='') |
129 | 129 | { |
130 | - global $db,$conf; |
|
130 | + global $db,$conf; |
|
131 | 131 | |
132 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
132 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
133 | 133 | |
134 | - // On defini critere recherche compteur |
|
135 | - $mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK; |
|
134 | + // On defini critere recherche compteur |
|
135 | + $mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK; |
|
136 | 136 | |
137 | - if (! $mask) |
|
138 | - { |
|
139 | - $this->error='NotConfigured'; |
|
140 | - return 0; |
|
141 | - } |
|
137 | + if (! $mask) |
|
138 | + { |
|
139 | + $this->error='NotConfigured'; |
|
140 | + return 0; |
|
141 | + } |
|
142 | 142 | |
143 | - $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande); |
|
143 | + $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande); |
|
144 | 144 | |
145 | - return $numFinal; |
|
146 | - } |
|
145 | + return $numFinal; |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | 149 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
150 | 150 | /** |
151 | 151 | * Renvoie la reference de commande suivante non utilisee |
152 | 152 | * |
153 | - * @param Societe $objsoc Object third party |
|
154 | - * @param Object $object Object |
|
153 | + * @param Societe $objsoc Object third party |
|
154 | + * @param Object $object Object |
|
155 | 155 | * @return string Texte descripif |
156 | 156 | */ |
157 | 157 | function commande_get_num($objsoc=0,$object='') |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier contenant la classe du modele de numerotation de reference de commande fournisseur Orchidee |
25 | 25 | */ |
26 | 26 | |
27 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefournisseur.php'; |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * Dolibarr version of the loaded document |
37 | 37 | * @public string |
38 | 38 | */ |
39 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string Error code (or message) |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @deprecated |
49 | 49 | * @see name |
50 | 50 | */ |
51 | - public $nom='Orchidee'; |
|
51 | + public $nom = 'Orchidee'; |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @var string model name |
55 | 55 | */ |
56 | - public $name='Orchidee'; |
|
56 | + public $name = 'Orchidee'; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -66,33 +66,33 @@ discard block |
||
66 | 66 | global $conf, $langs; |
67 | 67 | |
68 | 68 | // Load translation files required by the page |
69 | - $langs->loadLangs(array("bills","admin")); |
|
69 | + $langs->loadLangs(array("bills", "admin")); |
|
70 | 70 | |
71 | 71 | $form = new Form($this->db); |
72 | 72 | |
73 | 73 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
74 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | - $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">'; |
|
78 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
79 | - |
|
80 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
83 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
84 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
74 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | + $texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">'; |
|
78 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
79 | + |
|
80 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
83 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
84 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
85 | 85 | |
86 | 86 | // Parametrage du prefix |
87 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>'; |
|
87 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
89 | 89 | |
90 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
90 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
91 | 91 | |
92 | - $texte.= '</tr>'; |
|
92 | + $texte .= '</tr>'; |
|
93 | 93 | |
94 | - $texte.= '</table>'; |
|
95 | - $texte.= '</form>'; |
|
94 | + $texte .= '</table>'; |
|
95 | + $texte .= '</form>'; |
|
96 | 96 | |
97 | 97 | return $texte; |
98 | 98 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function getExample() |
106 | 106 | { |
107 | - global $conf,$langs,$mysoc; |
|
107 | + global $conf, $langs, $mysoc; |
|
108 | 108 | |
109 | - $old_code_client=$mysoc->code_client; |
|
110 | - $mysoc->code_client='CCCCCCCCCC'; |
|
111 | - $numExample = $this->getNextValue($mysoc,''); |
|
112 | - $mysoc->code_client=$old_code_client; |
|
109 | + $old_code_client = $mysoc->code_client; |
|
110 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
111 | + $numExample = $this->getNextValue($mysoc, ''); |
|
112 | + $mysoc->code_client = $old_code_client; |
|
113 | 113 | |
114 | - if (! $numExample) |
|
114 | + if (!$numExample) |
|
115 | 115 | { |
116 | 116 | $numExample = $langs->trans('NotConfigured'); |
117 | 117 | } |
@@ -125,22 +125,22 @@ discard block |
||
125 | 125 | * @param Object $object Object |
126 | 126 | * @return string Value if OK, 0 if KO |
127 | 127 | */ |
128 | - function getNextValue($objsoc=0,$object='') |
|
128 | + function getNextValue($objsoc = 0, $object = '') |
|
129 | 129 | { |
130 | - global $db,$conf; |
|
130 | + global $db, $conf; |
|
131 | 131 | |
132 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
132 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
133 | 133 | |
134 | 134 | // On defini critere recherche compteur |
135 | - $mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK; |
|
135 | + $mask = $conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK; |
|
136 | 136 | |
137 | - if (! $mask) |
|
137 | + if (!$mask) |
|
138 | 138 | { |
139 | - $this->error='NotConfigured'; |
|
139 | + $this->error = 'NotConfigured'; |
|
140 | 140 | return 0; |
141 | 141 | } |
142 | 142 | |
143 | - $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande); |
|
143 | + $numFinal = get_next_value($db, $mask, 'commande_fournisseur', 'ref', '', $objsoc, $object->date_commande); |
|
144 | 144 | |
145 | 145 | return $numFinal; |
146 | 146 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * @param Object $object Object |
155 | 155 | * @return string Texte descripif |
156 | 156 | */ |
157 | - function commande_get_num($objsoc=0,$object='') |
|
157 | + function commande_get_num($objsoc = 0, $object = '') |
|
158 | 158 | { |
159 | 159 | // phpcs:enable |
160 | - return $this->getNextValue($objsoc,$object); |
|
160 | + return $this->getNextValue($objsoc, $object); |
|
161 | 161 | } |
162 | 162 | } |
@@ -31,41 +31,41 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders |
33 | 33 | { |
34 | - /** |
|
34 | + /** |
|
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | - /** |
|
40 | + /** |
|
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | 43 | public $error = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string Nom du modele |
|
47 | - * @deprecated |
|
48 | - * @see name |
|
49 | - */ |
|
50 | - public $nom='Muguet'; |
|
45 | + /** |
|
46 | + * @var string Nom du modele |
|
47 | + * @deprecated |
|
48 | + * @see name |
|
49 | + */ |
|
50 | + public $nom='Muguet'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string model name |
|
54 | - */ |
|
55 | - public $name='Muguet'; |
|
52 | + /** |
|
53 | + * @var string model name |
|
54 | + */ |
|
55 | + public $name='Muguet'; |
|
56 | 56 | |
57 | - public $prefix='CF'; |
|
57 | + public $prefix='CF'; |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Constructor |
|
62 | - */ |
|
63 | - function __construct() |
|
64 | - { |
|
65 | - global $conf; |
|
60 | + /** |
|
61 | + * Constructor |
|
62 | + */ |
|
63 | + function __construct() |
|
64 | + { |
|
65 | + global $conf; |
|
66 | 66 | |
67 | - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order" |
|
68 | - } |
|
67 | + if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order" |
|
68 | + } |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Return description of numbering module |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function info() |
76 | 76 | { |
77 | - global $langs; |
|
78 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
77 | + global $langs; |
|
78 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function canBeActivated() |
100 | 100 | { |
101 | - global $conf,$langs,$db; |
|
101 | + global $conf,$langs,$db; |
|
102 | 102 | |
103 | 103 | $coyymm=''; $max=''; |
104 | 104 | |
105 | - $posindice=8; |
|
106 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
105 | + $posindice=8; |
|
106 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
107 | 107 | $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
108 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
108 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
109 | 109 | $sql.= " AND entity = ".$conf->entity; |
110 | 110 | $resql=$db->query($sql); |
111 | 111 | if ($resql) |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | - $langs->load("errors"); |
|
123 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
122 | + $langs->load("errors"); |
|
123 | + $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Return next value |
130 | - * |
|
131 | - * @param Societe $objsoc Object third party |
|
132 | - * @param Object $object Object |
|
133 | - * @return string Value if OK, 0 if KO |
|
130 | + * |
|
131 | + * @param Societe $objsoc Object third party |
|
132 | + * @param Object $object Object |
|
133 | + * @return string Value if OK, 0 if KO |
|
134 | 134 | */ |
135 | 135 | function getNextValue($objsoc=0,$object='') |
136 | 136 | { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $posindice=8; |
141 | 141 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
142 | 142 | $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
143 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
143 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
144 | 144 | $sql.= " AND entity = ".$conf->entity; |
145 | 145 | |
146 | 146 | $resql=$db->query($sql); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | else $max=0; |
152 | 152 | } |
153 | 153 | |
154 | - //$date=time(); |
|
154 | + //$date=time(); |
|
155 | 155 | $date=$object->date_commande; // Not always defined |
156 | 156 | if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders |
157 | 157 | $yymm = strftime("%y%m",$date); |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | /** |
168 | 168 | * Renvoie la reference de commande suivante non utilisee |
169 | 169 | * |
170 | - * @param Societe $objsoc Object third party |
|
171 | - * @param Object $object Object |
|
170 | + * @param Societe $objsoc Object third party |
|
171 | + * @param Object $object Object |
|
172 | 172 | * @return string Texte descripif |
173 | 173 | */ |
174 | 174 | function commande_get_num($objsoc=0,$object='') |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief Fichier contenant la classe du modele de numerotation de reference de commande fournisseur Muguet |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefournisseur.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * @deprecated |
48 | 48 | * @see name |
49 | 49 | */ |
50 | - public $nom='Muguet'; |
|
50 | + public $nom = 'Muguet'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var string model name |
54 | 54 | */ |
55 | - public $name='Muguet'; |
|
55 | + public $name = 'Muguet'; |
|
56 | 56 | |
57 | - public $prefix='CF'; |
|
57 | + public $prefix = 'CF'; |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $conf; |
66 | 66 | |
67 | - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order" |
|
67 | + if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order" |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function info() |
76 | 76 | { |
77 | 77 | global $langs; |
78 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
78 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -98,29 +98,29 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function canBeActivated() |
100 | 100 | { |
101 | - global $conf,$langs,$db; |
|
101 | + global $conf, $langs, $db; |
|
102 | 102 | |
103 | - $coyymm=''; $max=''; |
|
103 | + $coyymm = ''; $max = ''; |
|
104 | 104 | |
105 | - $posindice=8; |
|
105 | + $posindice = 8; |
|
106 | 106 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
107 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
|
108 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
109 | - $sql.= " AND entity = ".$conf->entity; |
|
110 | - $resql=$db->query($sql); |
|
107 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
|
108 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
109 | + $sql .= " AND entity = ".$conf->entity; |
|
110 | + $resql = $db->query($sql); |
|
111 | 111 | if ($resql) |
112 | 112 | { |
113 | 113 | $row = $db->fetch_row($resql); |
114 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
114 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
115 | 115 | } |
116 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
116 | + if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
117 | 117 | { |
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | 122 | $langs->load("errors"); |
123 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
123 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | } |
@@ -132,32 +132,32 @@ discard block |
||
132 | 132 | * @param Object $object Object |
133 | 133 | * @return string Value if OK, 0 if KO |
134 | 134 | */ |
135 | - function getNextValue($objsoc=0,$object='') |
|
135 | + function getNextValue($objsoc = 0, $object = '') |
|
136 | 136 | { |
137 | - global $db,$conf; |
|
137 | + global $db, $conf; |
|
138 | 138 | |
139 | 139 | // D'abord on recupere la valeur max |
140 | - $posindice=8; |
|
140 | + $posindice = 8; |
|
141 | 141 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
142 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
|
143 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
144 | - $sql.= " AND entity = ".$conf->entity; |
|
142 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; |
|
143 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
144 | + $sql .= " AND entity = ".$conf->entity; |
|
145 | 145 | |
146 | - $resql=$db->query($sql); |
|
146 | + $resql = $db->query($sql); |
|
147 | 147 | if ($resql) |
148 | 148 | { |
149 | 149 | $obj = $db->fetch_object($resql); |
150 | 150 | if ($obj) $max = intval($obj->max); |
151 | - else $max=0; |
|
151 | + else $max = 0; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | //$date=time(); |
155 | - $date=$object->date_commande; // Not always defined |
|
156 | - if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders |
|
157 | - $yymm = strftime("%y%m",$date); |
|
155 | + $date = $object->date_commande; // Not always defined |
|
156 | + if (empty($date)) $date = $object->date; // Creation date is order date for suppliers orders |
|
157 | + $yymm = strftime("%y%m", $date); |
|
158 | 158 | |
159 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
160 | - else $num = sprintf("%04s",$max+1); |
|
159 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
160 | + else $num = sprintf("%04s", $max + 1); |
|
161 | 161 | |
162 | 162 | return $this->prefix.$yymm."-".$num; |
163 | 163 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * @param Object $object Object |
172 | 172 | * @return string Texte descripif |
173 | 173 | */ |
174 | - function commande_get_num($objsoc=0,$object='') |
|
174 | + function commande_get_num($objsoc = 0, $object = '') |
|
175 | 175 | { |
176 | 176 | // phpcs:enable |
177 | - return $this->getNextValue($objsoc,$object); |
|
177 | + return $this->getNextValue($objsoc, $object); |
|
178 | 178 | } |
179 | 179 | } |
@@ -64,7 +64,10 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $conf; |
66 | 66 | |
67 | - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order" |
|
67 | + if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) { |
|
68 | + $this->prefix = 'PO'; |
|
69 | + } |
|
70 | + // We use correct standard code "PO = Purchase Order" |
|
68 | 71 | } |
69 | 72 | |
70 | 73 | /** |
@@ -116,8 +119,7 @@ discard block |
||
116 | 119 | if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
117 | 120 | { |
118 | 121 | return true; |
119 | - } |
|
120 | - else |
|
122 | + } else |
|
121 | 123 | { |
122 | 124 | $langs->load("errors"); |
123 | 125 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -147,17 +149,28 @@ discard block |
||
147 | 149 | if ($resql) |
148 | 150 | { |
149 | 151 | $obj = $db->fetch_object($resql); |
150 | - if ($obj) $max = intval($obj->max); |
|
151 | - else $max=0; |
|
152 | + if ($obj) { |
|
153 | + $max = intval($obj->max); |
|
154 | + } else { |
|
155 | + $max=0; |
|
156 | + } |
|
152 | 157 | } |
153 | 158 | |
154 | 159 | //$date=time(); |
155 | 160 | $date=$object->date_commande; // Not always defined |
156 | - if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders |
|
161 | + if (empty($date)) { |
|
162 | + $date=$object->date; |
|
163 | + } |
|
164 | + // Creation date is order date for suppliers orders |
|
157 | 165 | $yymm = strftime("%y%m",$date); |
158 | 166 | |
159 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
160 | - else $num = sprintf("%04s",$max+1); |
|
167 | + if ($max >= (pow(10, 4) - 1)) { |
|
168 | + $num=$max+1; |
|
169 | + } |
|
170 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
171 | + else { |
|
172 | + $num = sprintf("%04s",$max+1); |
|
173 | + } |
|
161 | 174 | |
162 | 175 | return $this->prefix.$yymm."-".$num; |
163 | 176 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public $db; |
48 | 48 | |
49 | - /** |
|
49 | + /** |
|
50 | 50 | * @var string model name |
51 | 51 | */ |
52 | 52 | public $name; |
53 | 53 | |
54 | - /** |
|
54 | + /** |
|
55 | 55 | * @var string model description (short text) |
56 | 56 | */ |
57 | 57 | public $description; |
@@ -63,138 +63,138 @@ discard block |
||
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var array() Minimum version of PHP required by module. |
66 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
66 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
67 | 67 | */ |
68 | - public $phpmin = array(5, 4); |
|
68 | + public $phpmin = array(5, 4); |
|
69 | 69 | |
70 | - /** |
|
70 | + /** |
|
71 | 71 | * Dolibarr version of the loaded document |
72 | 72 | * @public string |
73 | 73 | */ |
74 | - public $version = 'dolibarr'; |
|
74 | + public $version = 'dolibarr'; |
|
75 | 75 | |
76 | - /** |
|
76 | + /** |
|
77 | 77 | * @var int page_largeur |
78 | 78 | */ |
79 | 79 | public $page_largeur; |
80 | 80 | |
81 | - /** |
|
81 | + /** |
|
82 | 82 | * @var int page_hauteur |
83 | 83 | */ |
84 | 84 | public $page_hauteur; |
85 | 85 | |
86 | - /** |
|
86 | + /** |
|
87 | 87 | * @var array format |
88 | 88 | */ |
89 | 89 | public $format; |
90 | 90 | |
91 | - /** |
|
91 | + /** |
|
92 | 92 | * @var int marge_gauche |
93 | 93 | */ |
94 | - public $marge_gauche; |
|
94 | + public $marge_gauche; |
|
95 | 95 | |
96 | - /** |
|
96 | + /** |
|
97 | 97 | * @var int marge_droite |
98 | 98 | */ |
99 | - public $marge_droite; |
|
99 | + public $marge_droite; |
|
100 | 100 | |
101 | - /** |
|
101 | + /** |
|
102 | 102 | * @var int marge_haute |
103 | 103 | */ |
104 | - public $marge_haute; |
|
104 | + public $marge_haute; |
|
105 | 105 | |
106 | - /** |
|
106 | + /** |
|
107 | 107 | * @var int marge_basse |
108 | 108 | */ |
109 | - public $marge_basse; |
|
110 | - |
|
111 | - /** |
|
112 | - * Issuer |
|
113 | - * @var Company object that emits |
|
114 | - */ |
|
115 | - public $emetteur; |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Constructor |
|
120 | - * |
|
121 | - * @param DoliDB $db Database handler |
|
122 | - */ |
|
123 | - function __construct($db) |
|
124 | - { |
|
125 | - global $conf, $langs, $mysoc; |
|
126 | - |
|
127 | - // Load translation files required by the page |
|
128 | - $langs->loadLangs(array("main", "bills")); |
|
129 | - |
|
130 | - $this->db = $db; |
|
131 | - $this->name = "muscadet"; |
|
132 | - $this->description = $langs->trans('SuppliersCommandModel'); |
|
133 | - |
|
134 | - // Dimension page pour format A4 |
|
135 | - $this->type = 'pdf'; |
|
136 | - $formatarray=pdf_getFormat(); |
|
137 | - $this->page_largeur = $formatarray['width']; |
|
138 | - $this->page_hauteur = $formatarray['height']; |
|
139 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
140 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
141 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
142 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
143 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
144 | - |
|
145 | - $this->option_logo = 1; // Affiche logo |
|
146 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
147 | - $this->option_modereg = 1; // Affiche mode reglement |
|
148 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
149 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
150 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
151 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
152 | - $this->option_credit_note = 0; // Support credit notes |
|
153 | - $this->option_freetext = 1; // Support add of a personalised text |
|
154 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
155 | - |
|
156 | - $this->franchise=!$mysoc->tva_assuj; |
|
109 | + public $marge_basse; |
|
110 | + |
|
111 | + /** |
|
112 | + * Issuer |
|
113 | + * @var Company object that emits |
|
114 | + */ |
|
115 | + public $emetteur; |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Constructor |
|
120 | + * |
|
121 | + * @param DoliDB $db Database handler |
|
122 | + */ |
|
123 | + function __construct($db) |
|
124 | + { |
|
125 | + global $conf, $langs, $mysoc; |
|
126 | + |
|
127 | + // Load translation files required by the page |
|
128 | + $langs->loadLangs(array("main", "bills")); |
|
129 | + |
|
130 | + $this->db = $db; |
|
131 | + $this->name = "muscadet"; |
|
132 | + $this->description = $langs->trans('SuppliersCommandModel'); |
|
133 | + |
|
134 | + // Dimension page pour format A4 |
|
135 | + $this->type = 'pdf'; |
|
136 | + $formatarray=pdf_getFormat(); |
|
137 | + $this->page_largeur = $formatarray['width']; |
|
138 | + $this->page_hauteur = $formatarray['height']; |
|
139 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
140 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
141 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
142 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
143 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
144 | + |
|
145 | + $this->option_logo = 1; // Affiche logo |
|
146 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
147 | + $this->option_modereg = 1; // Affiche mode reglement |
|
148 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
149 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
150 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
151 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
152 | + $this->option_credit_note = 0; // Support credit notes |
|
153 | + $this->option_freetext = 1; // Support add of a personalised text |
|
154 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
155 | + |
|
156 | + $this->franchise=!$mysoc->tva_assuj; |
|
157 | 157 | |
158 | 158 | // Get source company |
159 | - $this->emetteur=$mysoc; |
|
160 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
159 | + $this->emetteur=$mysoc; |
|
160 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
161 | 161 | |
162 | - // Defini position des colonnes |
|
163 | - $this->posxdesc=$this->marge_gauche+1; |
|
164 | - $this->posxdiscount=162; |
|
165 | - $this->postotalht=174; |
|
162 | + // Defini position des colonnes |
|
163 | + $this->posxdesc=$this->marge_gauche+1; |
|
164 | + $this->posxdiscount=162; |
|
165 | + $this->postotalht=174; |
|
166 | 166 | |
167 | - if ($conf->global->PRODUCT_USE_UNITS) |
|
168 | - { |
|
169 | - $this->posxtva=95; |
|
170 | - $this->posxup=114; |
|
171 | - $this->posxqty=132; |
|
172 | - $this->posxunit=147; |
|
173 | - } else { |
|
174 | - $this->posxtva=110; |
|
175 | - $this->posxup=126; |
|
176 | - $this->posxqty=145; |
|
177 | - } |
|
178 | - |
|
179 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference |
|
180 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
181 | - if ($this->page_largeur < 210) // To work with US executive format |
|
182 | - { |
|
183 | - $this->posxpicture-=20; |
|
184 | - $this->posxtva-=20; |
|
185 | - $this->posxup-=20; |
|
186 | - $this->posxqty-=20; |
|
187 | - $this->posxunit-=20; |
|
188 | - $this->posxdiscount-=20; |
|
189 | - $this->postotalht-=20; |
|
190 | - } |
|
191 | - |
|
192 | - $this->tva=array(); |
|
167 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
168 | + { |
|
169 | + $this->posxtva=95; |
|
170 | + $this->posxup=114; |
|
171 | + $this->posxqty=132; |
|
172 | + $this->posxunit=147; |
|
173 | + } else { |
|
174 | + $this->posxtva=110; |
|
175 | + $this->posxup=126; |
|
176 | + $this->posxqty=145; |
|
177 | + } |
|
178 | + |
|
179 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference |
|
180 | + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
181 | + if ($this->page_largeur < 210) // To work with US executive format |
|
182 | + { |
|
183 | + $this->posxpicture-=20; |
|
184 | + $this->posxtva-=20; |
|
185 | + $this->posxup-=20; |
|
186 | + $this->posxqty-=20; |
|
187 | + $this->posxunit-=20; |
|
188 | + $this->posxdiscount-=20; |
|
189 | + $this->postotalht-=20; |
|
190 | + } |
|
191 | + |
|
192 | + $this->tva=array(); |
|
193 | 193 | $this->localtax1=array(); |
194 | 194 | $this->localtax2=array(); |
195 | 195 | $this->atleastoneratenotnull=0; |
196 | - $this->atleastonediscount=0; |
|
197 | - } |
|
196 | + $this->atleastonediscount=0; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | 200 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -209,111 +209,111 @@ discard block |
||
209 | 209 | * @param int $hideref Do not show ref |
210 | 210 | * @return int 1=OK, 0=KO |
211 | 211 | */ |
212 | - function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
213 | - { |
|
212 | + function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
213 | + { |
|
214 | 214 | // phpcs:enable |
215 | - global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; |
|
215 | + global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; |
|
216 | 216 | |
217 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
218 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
219 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
217 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
218 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
219 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
220 | 220 | |
221 | - // Load translation files required by the page |
|
222 | - $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); |
|
221 | + // Load translation files required by the page |
|
222 | + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); |
|
223 | 223 | |
224 | - $nblignes = count($object->lines); |
|
224 | + $nblignes = count($object->lines); |
|
225 | 225 | |
226 | - // Loop on each lines to detect if there is at least one image to show |
|
227 | - $realpatharray=array(); |
|
228 | - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) |
|
229 | - { |
|
230 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
231 | - { |
|
232 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
233 | - |
|
234 | - $objphoto = new Product($this->db); |
|
235 | - $objphoto->fetch($object->lines[$i]->fk_product); |
|
236 | - |
|
237 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
238 | - { |
|
239 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
240 | - $dir = $conf->product->dir_output.'/'.$pdir; |
|
241 | - } |
|
242 | - else |
|
243 | - { |
|
244 | - $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; |
|
245 | - $dir = $conf->product->dir_output.'/'.$pdir; |
|
246 | - } |
|
247 | - |
|
248 | - $realpath=''; |
|
249 | - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
250 | - { |
|
251 | - $filename=$obj['photo']; |
|
252 | - //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; |
|
253 | - $realpath = $dir.$filename; |
|
254 | - break; |
|
255 | - } |
|
256 | - |
|
257 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
258 | - } |
|
259 | - } |
|
260 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
261 | - |
|
262 | - if ($conf->fournisseur->commande->dir_output) |
|
263 | - { |
|
264 | - $object->fetch_thirdparty(); |
|
226 | + // Loop on each lines to detect if there is at least one image to show |
|
227 | + $realpatharray=array(); |
|
228 | + if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) |
|
229 | + { |
|
230 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
231 | + { |
|
232 | + if (empty($object->lines[$i]->fk_product)) continue; |
|
233 | + |
|
234 | + $objphoto = new Product($this->db); |
|
235 | + $objphoto->fetch($object->lines[$i]->fk_product); |
|
236 | + |
|
237 | + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
238 | + { |
|
239 | + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
240 | + $dir = $conf->product->dir_output.'/'.$pdir; |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; |
|
245 | + $dir = $conf->product->dir_output.'/'.$pdir; |
|
246 | + } |
|
247 | + |
|
248 | + $realpath=''; |
|
249 | + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
250 | + { |
|
251 | + $filename=$obj['photo']; |
|
252 | + //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; |
|
253 | + $realpath = $dir.$filename; |
|
254 | + break; |
|
255 | + } |
|
265 | 256 | |
266 | - $deja_regle = 0; |
|
267 | - $amount_credit_notes_included = 0; |
|
268 | - $amount_deposits_included = 0; |
|
269 | - //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); |
|
257 | + if ($realpath) $realpatharray[$i]=$realpath; |
|
258 | + } |
|
259 | + } |
|
260 | + if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
261 | + |
|
262 | + if ($conf->fournisseur->commande->dir_output) |
|
263 | + { |
|
264 | + $object->fetch_thirdparty(); |
|
265 | + |
|
266 | + $deja_regle = 0; |
|
267 | + $amount_credit_notes_included = 0; |
|
268 | + $amount_deposits_included = 0; |
|
269 | + //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); |
|
270 | 270 | //$amount_deposits_included = $object->getSumDepositsUsed(); |
271 | 271 | |
272 | - // Definition of $dir and $file |
|
273 | - if ($object->specimen) |
|
274 | - { |
|
275 | - $dir = $conf->fournisseur->commande->dir_output; |
|
276 | - $file = $dir . "/SPECIMEN.pdf"; |
|
277 | - } |
|
278 | - else |
|
279 | - { |
|
280 | - $objectref = dol_sanitizeFileName($object->ref); |
|
281 | - $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
282 | - $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; |
|
283 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
284 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
285 | - } |
|
286 | - |
|
287 | - if (! file_exists($dir)) |
|
288 | - { |
|
289 | - if (dol_mkdir($dir) < 0) |
|
290 | - { |
|
291 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
292 | - return 0; |
|
293 | - } |
|
294 | - } |
|
295 | - |
|
296 | - if (file_exists($dir)) |
|
297 | - { |
|
298 | - // Add pdfgeneration hook |
|
299 | - if (! is_object($hookmanager)) |
|
300 | - { |
|
301 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
302 | - $hookmanager=new HookManager($this->db); |
|
303 | - } |
|
304 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
305 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
306 | - global $action; |
|
307 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
308 | - |
|
309 | - $nblignes = count($object->lines); |
|
272 | + // Definition of $dir and $file |
|
273 | + if ($object->specimen) |
|
274 | + { |
|
275 | + $dir = $conf->fournisseur->commande->dir_output; |
|
276 | + $file = $dir . "/SPECIMEN.pdf"; |
|
277 | + } |
|
278 | + else |
|
279 | + { |
|
280 | + $objectref = dol_sanitizeFileName($object->ref); |
|
281 | + $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
282 | + $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; |
|
283 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
284 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
285 | + } |
|
286 | + |
|
287 | + if (! file_exists($dir)) |
|
288 | + { |
|
289 | + if (dol_mkdir($dir) < 0) |
|
290 | + { |
|
291 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
292 | + return 0; |
|
293 | + } |
|
294 | + } |
|
295 | + |
|
296 | + if (file_exists($dir)) |
|
297 | + { |
|
298 | + // Add pdfgeneration hook |
|
299 | + if (! is_object($hookmanager)) |
|
300 | + { |
|
301 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
302 | + $hookmanager=new HookManager($this->db); |
|
303 | + } |
|
304 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
305 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
306 | + global $action; |
|
307 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
308 | + |
|
309 | + $nblignes = count($object->lines); |
|
310 | 310 | |
311 | 311 | $pdf=pdf_getInstance($this->format); |
312 | 312 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
313 | 313 | $heightforinfotot = 50; // Height reserved to output the info and total part |
314 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
315 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
316 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
314 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
315 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
316 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
317 | 317 | $pdf->SetAutoPageBreak(1,0); |
318 | 318 | |
319 | 319 | if (class_exists('TCPDF')) |
@@ -329,1047 +329,1047 @@ discard block |
||
329 | 329 | $tplidx = $pdf->importPage(1); |
330 | 330 | } |
331 | 331 | |
332 | - $pdf->Open(); |
|
333 | - $pagenb=0; |
|
334 | - $pdf->SetDrawColor(128,128,128); |
|
335 | - |
|
336 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
337 | - $pdf->SetSubject($outputlangs->transnoentities("Order")); |
|
338 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
339 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
340 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
341 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
342 | - |
|
343 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
344 | - |
|
345 | - // Positionne $this->atleastonediscount si on a au moins une remise |
|
346 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
347 | - { |
|
348 | - if ($object->lines[$i]->remise_percent) |
|
349 | - { |
|
350 | - $this->atleastonediscount++; |
|
351 | - } |
|
352 | - } |
|
353 | - if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
354 | - { |
|
355 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
356 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
357 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
358 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
359 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
360 | - //$this->postotalht; |
|
361 | - } |
|
362 | - |
|
363 | - // New page |
|
364 | - $pdf->AddPage(); |
|
365 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
366 | - $pagenb++; |
|
367 | - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
368 | - $pdf->SetFont('','', $default_font_size - 1); |
|
369 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
370 | - $pdf->SetTextColor(0,0,0); |
|
371 | - |
|
372 | - $tab_top = 90+$top_shift; |
|
373 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
374 | - |
|
375 | - // Incoterm |
|
376 | - if ($conf->incoterm->enabled) |
|
377 | - { |
|
378 | - $desc_incoterms = $object->getIncotermsForPDF(); |
|
379 | - if ($desc_incoterms) |
|
380 | - { |
|
381 | - $tab_top -= 2; |
|
382 | - |
|
383 | - $pdf->SetFont('','', $default_font_size - 1); |
|
384 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
385 | - $nexY = $pdf->GetY(); |
|
386 | - $height_incoterms=$nexY-$tab_top; |
|
387 | - |
|
388 | - // Rect prend une longueur en 3eme param |
|
389 | - $pdf->SetDrawColor(192,192,192); |
|
390 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
391 | - |
|
392 | - $tab_top = $nexY+6; |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - // Affiche notes |
|
397 | - if (! empty($object->note_public)) |
|
398 | - { |
|
399 | - $tab_top -= 2; |
|
400 | - |
|
401 | - $pdf->SetFont('','', $default_font_size - 1); |
|
402 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
403 | - $nexY = $pdf->GetY(); |
|
404 | - $height_note=$nexY-$tab_top; |
|
405 | - |
|
406 | - // Rect prend une longueur en 3eme param |
|
407 | - $pdf->SetDrawColor(192,192,192); |
|
408 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
409 | - |
|
410 | - $tab_top = $nexY+6; |
|
411 | - } |
|
412 | - |
|
413 | - $iniY = $tab_top + 7; |
|
414 | - $curY = $tab_top + 7; |
|
415 | - $nexY = $tab_top + 7; |
|
416 | - |
|
417 | - // Loop on each lines |
|
418 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
419 | - { |
|
420 | - $curY = $nexY; |
|
421 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
422 | - $pdf->SetTextColor(0,0,0); |
|
423 | - |
|
424 | - // Define size of image if we need it |
|
425 | - $imglinesize=array(); |
|
426 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
427 | - |
|
428 | - $pdf->setTopMargin($tab_top_newpage); |
|
429 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
430 | - $pageposbefore=$pdf->getPage(); |
|
431 | - |
|
432 | - $showpricebeforepagebreak=1; |
|
433 | - $posYAfterImage=0; |
|
434 | - $posYAfterDescription=0; |
|
435 | - |
|
436 | - // We start with Photo of product line |
|
437 | - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
438 | - { |
|
439 | - $pdf->AddPage('','',true); |
|
440 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
441 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
442 | - $pdf->setPage($pageposbefore+1); |
|
443 | - |
|
444 | - $curY = $tab_top_newpage; |
|
445 | - $showpricebeforepagebreak=0; |
|
446 | - } |
|
447 | - |
|
448 | - if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) |
|
449 | - { |
|
450 | - $curX = $this->posxpicture-1; |
|
451 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
452 | - // $pdf->Image does not increase value return by getY, so we save it manually |
|
453 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
454 | - } |
|
455 | - // Description of product line |
|
456 | - $curX = $this->posxdesc-1; |
|
457 | - $showpricebeforepagebreak=1; |
|
458 | - |
|
459 | - $pdf->startTransaction(); |
|
460 | - if ($posYAfterImage > 0) |
|
461 | - { |
|
462 | - $descWidth = $this->posxpicture-$curX; |
|
463 | - } |
|
464 | - else |
|
465 | - { |
|
466 | - $descWidth = $this->posxtva-$curX; |
|
467 | - } |
|
468 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
469 | - |
|
470 | - $pageposafter=$pdf->getPage(); |
|
471 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
472 | - { |
|
473 | - $pdf->rollbackTransaction(true); |
|
474 | - $pageposafter=$pageposbefore; |
|
475 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
476 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
477 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
478 | - $posyafter=$pdf->GetY(); |
|
479 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
480 | - { |
|
481 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
482 | - { |
|
483 | - $pdf->AddPage('','',true); |
|
484 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
486 | - $pdf->setPage($pageposafter+1); |
|
487 | - } |
|
488 | - } |
|
489 | - else |
|
490 | - { |
|
491 | - // We found a page break |
|
492 | - $showpricebeforepagebreak=0; |
|
493 | - } |
|
494 | - } |
|
495 | - else // No pagebreak |
|
496 | - { |
|
497 | - $pdf->commitTransaction(); |
|
498 | - } |
|
499 | - |
|
500 | - $nexY = $pdf->GetY(); |
|
332 | + $pdf->Open(); |
|
333 | + $pagenb=0; |
|
334 | + $pdf->SetDrawColor(128,128,128); |
|
335 | + |
|
336 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
337 | + $pdf->SetSubject($outputlangs->transnoentities("Order")); |
|
338 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
339 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
340 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
341 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
342 | + |
|
343 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
344 | + |
|
345 | + // Positionne $this->atleastonediscount si on a au moins une remise |
|
346 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
347 | + { |
|
348 | + if ($object->lines[$i]->remise_percent) |
|
349 | + { |
|
350 | + $this->atleastonediscount++; |
|
351 | + } |
|
352 | + } |
|
353 | + if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
354 | + { |
|
355 | + $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
356 | + $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
357 | + $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
358 | + $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
359 | + $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
360 | + //$this->postotalht; |
|
361 | + } |
|
362 | + |
|
363 | + // New page |
|
364 | + $pdf->AddPage(); |
|
365 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
366 | + $pagenb++; |
|
367 | + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
368 | + $pdf->SetFont('','', $default_font_size - 1); |
|
369 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
370 | + $pdf->SetTextColor(0,0,0); |
|
371 | + |
|
372 | + $tab_top = 90+$top_shift; |
|
373 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
374 | + |
|
375 | + // Incoterm |
|
376 | + if ($conf->incoterm->enabled) |
|
377 | + { |
|
378 | + $desc_incoterms = $object->getIncotermsForPDF(); |
|
379 | + if ($desc_incoterms) |
|
380 | + { |
|
381 | + $tab_top -= 2; |
|
382 | + |
|
383 | + $pdf->SetFont('','', $default_font_size - 1); |
|
384 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
385 | + $nexY = $pdf->GetY(); |
|
386 | + $height_incoterms=$nexY-$tab_top; |
|
387 | + |
|
388 | + // Rect prend une longueur en 3eme param |
|
389 | + $pdf->SetDrawColor(192,192,192); |
|
390 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
391 | + |
|
392 | + $tab_top = $nexY+6; |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + // Affiche notes |
|
397 | + if (! empty($object->note_public)) |
|
398 | + { |
|
399 | + $tab_top -= 2; |
|
400 | + |
|
401 | + $pdf->SetFont('','', $default_font_size - 1); |
|
402 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
403 | + $nexY = $pdf->GetY(); |
|
404 | + $height_note=$nexY-$tab_top; |
|
405 | + |
|
406 | + // Rect prend une longueur en 3eme param |
|
407 | + $pdf->SetDrawColor(192,192,192); |
|
408 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
409 | + |
|
410 | + $tab_top = $nexY+6; |
|
411 | + } |
|
412 | + |
|
413 | + $iniY = $tab_top + 7; |
|
414 | + $curY = $tab_top + 7; |
|
415 | + $nexY = $tab_top + 7; |
|
416 | + |
|
417 | + // Loop on each lines |
|
418 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
419 | + { |
|
420 | + $curY = $nexY; |
|
421 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
422 | + $pdf->SetTextColor(0,0,0); |
|
423 | + |
|
424 | + // Define size of image if we need it |
|
425 | + $imglinesize=array(); |
|
426 | + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
427 | + |
|
428 | + $pdf->setTopMargin($tab_top_newpage); |
|
429 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
430 | + $pageposbefore=$pdf->getPage(); |
|
431 | + |
|
432 | + $showpricebeforepagebreak=1; |
|
433 | + $posYAfterImage=0; |
|
434 | + $posYAfterDescription=0; |
|
435 | + |
|
436 | + // We start with Photo of product line |
|
437 | + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
438 | + { |
|
439 | + $pdf->AddPage('','',true); |
|
440 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
441 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
442 | + $pdf->setPage($pageposbefore+1); |
|
443 | + |
|
444 | + $curY = $tab_top_newpage; |
|
445 | + $showpricebeforepagebreak=0; |
|
446 | + } |
|
447 | + |
|
448 | + if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) |
|
449 | + { |
|
450 | + $curX = $this->posxpicture-1; |
|
451 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
452 | + // $pdf->Image does not increase value return by getY, so we save it manually |
|
453 | + $posYAfterImage=$curY+$imglinesize['height']; |
|
454 | + } |
|
455 | + // Description of product line |
|
456 | + $curX = $this->posxdesc-1; |
|
457 | + $showpricebeforepagebreak=1; |
|
458 | + |
|
459 | + $pdf->startTransaction(); |
|
460 | + if ($posYAfterImage > 0) |
|
461 | + { |
|
462 | + $descWidth = $this->posxpicture-$curX; |
|
463 | + } |
|
464 | + else |
|
465 | + { |
|
466 | + $descWidth = $this->posxtva-$curX; |
|
467 | + } |
|
468 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
469 | + |
|
501 | 470 | $pageposafter=$pdf->getPage(); |
502 | - $pdf->setPage($pageposbefore); |
|
503 | - $pdf->setTopMargin($this->marge_haute); |
|
504 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
505 | - |
|
506 | - // We suppose that a too long description is moved completely on next page |
|
507 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
508 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
509 | - } |
|
510 | - |
|
511 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
512 | - |
|
513 | - // VAT Rate |
|
514 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
515 | - { |
|
516 | - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
517 | - $pdf->SetXY($this->posxtva, $curY); |
|
518 | - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
519 | - } |
|
520 | - |
|
521 | - // Unit price before discount |
|
522 | - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
523 | - $pdf->SetXY($this->posxup, $curY); |
|
524 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
525 | - |
|
526 | - // Quantity |
|
527 | - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
528 | - $pdf->SetXY($this->posxqty, $curY); |
|
529 | - // Enough for 6 chars |
|
530 | - if($conf->global->PRODUCT_USE_UNITS) |
|
531 | - { |
|
532 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
533 | - } |
|
534 | - else |
|
535 | - { |
|
536 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
537 | - } |
|
538 | - |
|
539 | - // Unit |
|
540 | - if($conf->global->PRODUCT_USE_UNITS) |
|
541 | - { |
|
542 | - $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
543 | - $pdf->SetXY($this->posxunit, $curY); |
|
544 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
545 | - } |
|
546 | - |
|
547 | - // Discount on line |
|
548 | - $pdf->SetXY($this->posxdiscount, $curY); |
|
549 | - if ($object->lines[$i]->remise_percent) |
|
550 | - { |
|
551 | - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
552 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); |
|
553 | - } |
|
554 | - |
|
555 | - // Total HT line |
|
471 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
472 | + { |
|
473 | + $pdf->rollbackTransaction(true); |
|
474 | + $pageposafter=$pageposbefore; |
|
475 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
476 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
477 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
478 | + $posyafter=$pdf->GetY(); |
|
479 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
480 | + { |
|
481 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
482 | + { |
|
483 | + $pdf->AddPage('','',true); |
|
484 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
486 | + $pdf->setPage($pageposafter+1); |
|
487 | + } |
|
488 | + } |
|
489 | + else |
|
490 | + { |
|
491 | + // We found a page break |
|
492 | + $showpricebeforepagebreak=0; |
|
493 | + } |
|
494 | + } |
|
495 | + else // No pagebreak |
|
496 | + { |
|
497 | + $pdf->commitTransaction(); |
|
498 | + } |
|
499 | + |
|
500 | + $nexY = $pdf->GetY(); |
|
501 | + $pageposafter=$pdf->getPage(); |
|
502 | + $pdf->setPage($pageposbefore); |
|
503 | + $pdf->setTopMargin($this->marge_haute); |
|
504 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
505 | + |
|
506 | + // We suppose that a too long description is moved completely on next page |
|
507 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
508 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
509 | + } |
|
510 | + |
|
511 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
512 | + |
|
513 | + // VAT Rate |
|
514 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
515 | + { |
|
516 | + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
517 | + $pdf->SetXY($this->posxtva, $curY); |
|
518 | + $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
519 | + } |
|
520 | + |
|
521 | + // Unit price before discount |
|
522 | + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
523 | + $pdf->SetXY($this->posxup, $curY); |
|
524 | + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
525 | + |
|
526 | + // Quantity |
|
527 | + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
528 | + $pdf->SetXY($this->posxqty, $curY); |
|
529 | + // Enough for 6 chars |
|
530 | + if($conf->global->PRODUCT_USE_UNITS) |
|
531 | + { |
|
532 | + $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
533 | + } |
|
534 | + else |
|
535 | + { |
|
536 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
537 | + } |
|
538 | + |
|
539 | + // Unit |
|
540 | + if($conf->global->PRODUCT_USE_UNITS) |
|
541 | + { |
|
542 | + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
543 | + $pdf->SetXY($this->posxunit, $curY); |
|
544 | + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
545 | + } |
|
546 | + |
|
547 | + // Discount on line |
|
548 | + $pdf->SetXY($this->posxdiscount, $curY); |
|
549 | + if ($object->lines[$i]->remise_percent) |
|
550 | + { |
|
551 | + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
552 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); |
|
553 | + } |
|
554 | + |
|
555 | + // Total HT line |
|
556 | 556 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); |
557 | - $pdf->SetXY($this->postotalht, $curY); |
|
558 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
559 | - |
|
560 | - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
561 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
562 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
563 | - |
|
564 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
565 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
566 | - $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
567 | - $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
568 | - $localtax1_type=$object->lines[$i]->localtax1_type; |
|
569 | - $localtax2_type=$object->lines[$i]->localtax2_type; |
|
570 | - |
|
571 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
572 | - if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
573 | - if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
574 | - |
|
575 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
576 | - |
|
577 | - // Retrieve type from database for backward compatibility with old records |
|
578 | - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
579 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
580 | - { |
|
581 | - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty); |
|
582 | - $localtax1_type = $localtaxtmp_array[0]; |
|
583 | - $localtax2_type = $localtaxtmp_array[2]; |
|
584 | - } |
|
585 | - |
|
586 | - // retrieve global local tax |
|
587 | - if ($localtax1_type && $localtax1ligne != 0) |
|
588 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
589 | - if ($localtax2_type && $localtax2ligne != 0) |
|
590 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
591 | - |
|
592 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
593 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
594 | - $this->tva[$vatrate] += $tvaligne; |
|
595 | - |
|
596 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
597 | - |
|
598 | - // Add line |
|
599 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
600 | - { |
|
601 | - $pdf->setPage($pageposafter); |
|
602 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
603 | - //$pdf->SetDrawColor(190,190,200); |
|
604 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
605 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
606 | - } |
|
607 | - |
|
608 | - $nexY+=2; // Passe espace entre les lignes |
|
609 | - |
|
610 | - // Detect if some page were added automatically and output _tableau for past pages |
|
611 | - while ($pagenb < $pageposafter) |
|
612 | - { |
|
613 | - $pdf->setPage($pagenb); |
|
614 | - if ($pagenb == 1) |
|
615 | - { |
|
616 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
617 | - } |
|
618 | - else |
|
619 | - { |
|
620 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
621 | - } |
|
622 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
623 | - $pagenb++; |
|
624 | - $pdf->setPage($pagenb); |
|
625 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
626 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
627 | - } |
|
628 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
629 | - { |
|
630 | - if ($pagenb == 1) |
|
631 | - { |
|
632 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
633 | - } |
|
634 | - else |
|
635 | - { |
|
636 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
637 | - } |
|
638 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
639 | - // New page |
|
640 | - $pdf->AddPage(); |
|
641 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
642 | - $pagenb++; |
|
643 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
644 | - } |
|
645 | - } |
|
646 | - |
|
647 | - // Show square |
|
648 | - if ($pagenb == 1) |
|
649 | - { |
|
650 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
651 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
652 | - } |
|
653 | - else |
|
654 | - { |
|
655 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
656 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
657 | - } |
|
658 | - |
|
659 | - // Affiche zone infos |
|
660 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
661 | - |
|
662 | - // Affiche zone totaux |
|
663 | - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
664 | - |
|
665 | - // Affiche zone versements |
|
666 | - if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
|
667 | - { |
|
668 | - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
669 | - } |
|
557 | + $pdf->SetXY($this->postotalht, $curY); |
|
558 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
559 | + |
|
560 | + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
561 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
562 | + else $tvaligne=$object->lines[$i]->total_tva; |
|
563 | + |
|
564 | + $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
565 | + $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
566 | + $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
567 | + $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
568 | + $localtax1_type=$object->lines[$i]->localtax1_type; |
|
569 | + $localtax2_type=$object->lines[$i]->localtax2_type; |
|
570 | + |
|
571 | + if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
572 | + if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
573 | + if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
574 | + |
|
575 | + $vatrate=(string) $object->lines[$i]->tva_tx; |
|
576 | + |
|
577 | + // Retrieve type from database for backward compatibility with old records |
|
578 | + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
579 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
580 | + { |
|
581 | + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty); |
|
582 | + $localtax1_type = $localtaxtmp_array[0]; |
|
583 | + $localtax2_type = $localtaxtmp_array[2]; |
|
584 | + } |
|
585 | + |
|
586 | + // retrieve global local tax |
|
587 | + if ($localtax1_type && $localtax1ligne != 0) |
|
588 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
589 | + if ($localtax2_type && $localtax2ligne != 0) |
|
590 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
591 | + |
|
592 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
593 | + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
594 | + $this->tva[$vatrate] += $tvaligne; |
|
595 | + |
|
596 | + if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
597 | + |
|
598 | + // Add line |
|
599 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
600 | + { |
|
601 | + $pdf->setPage($pageposafter); |
|
602 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
603 | + //$pdf->SetDrawColor(190,190,200); |
|
604 | + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
605 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
606 | + } |
|
607 | + |
|
608 | + $nexY+=2; // Passe espace entre les lignes |
|
609 | + |
|
610 | + // Detect if some page were added automatically and output _tableau for past pages |
|
611 | + while ($pagenb < $pageposafter) |
|
612 | + { |
|
613 | + $pdf->setPage($pagenb); |
|
614 | + if ($pagenb == 1) |
|
615 | + { |
|
616 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
617 | + } |
|
618 | + else |
|
619 | + { |
|
620 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
621 | + } |
|
622 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
623 | + $pagenb++; |
|
624 | + $pdf->setPage($pagenb); |
|
625 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
626 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
627 | + } |
|
628 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
629 | + { |
|
630 | + if ($pagenb == 1) |
|
631 | + { |
|
632 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
633 | + } |
|
634 | + else |
|
635 | + { |
|
636 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
637 | + } |
|
638 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
639 | + // New page |
|
640 | + $pdf->AddPage(); |
|
641 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
642 | + $pagenb++; |
|
643 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
644 | + } |
|
645 | + } |
|
646 | + |
|
647 | + // Show square |
|
648 | + if ($pagenb == 1) |
|
649 | + { |
|
650 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
651 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
652 | + } |
|
653 | + else |
|
654 | + { |
|
655 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
656 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
657 | + } |
|
658 | + |
|
659 | + // Affiche zone infos |
|
660 | + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
661 | + |
|
662 | + // Affiche zone totaux |
|
663 | + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
664 | + |
|
665 | + // Affiche zone versements |
|
666 | + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
|
667 | + { |
|
668 | + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
669 | + } |
|
670 | 670 | |
671 | 671 | // Pied de page |
672 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
673 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
672 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
673 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
674 | 674 | |
675 | - $pdf->Close(); |
|
675 | + $pdf->Close(); |
|
676 | 676 | |
677 | - $pdf->Output($file,'F'); |
|
677 | + $pdf->Output($file,'F'); |
|
678 | 678 | |
679 | - // Add pdfgeneration hook |
|
680 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
681 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
682 | - global $action; |
|
683 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
679 | + // Add pdfgeneration hook |
|
680 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
681 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
682 | + global $action; |
|
683 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
684 | 684 | |
685 | - if (! empty($conf->global->MAIN_UMASK)) |
|
686 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
685 | + if (! empty($conf->global->MAIN_UMASK)) |
|
686 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
687 | 687 | |
688 | - $this->result = array('fullpath'=>$file); |
|
688 | + $this->result = array('fullpath'=>$file); |
|
689 | 689 | |
690 | - return 1; // Pas d'erreur |
|
691 | - } |
|
692 | - else |
|
693 | - { |
|
694 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
695 | - return 0; |
|
696 | - } |
|
697 | - } |
|
698 | - else |
|
699 | - { |
|
700 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
701 | - return 0; |
|
702 | - } |
|
703 | - } |
|
690 | + return 1; // Pas d'erreur |
|
691 | + } |
|
692 | + else |
|
693 | + { |
|
694 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
695 | + return 0; |
|
696 | + } |
|
697 | + } |
|
698 | + else |
|
699 | + { |
|
700 | + $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
701 | + return 0; |
|
702 | + } |
|
703 | + } |
|
704 | 704 | |
705 | 705 | |
706 | 706 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
707 | - /** |
|
708 | - * Show payments table |
|
709 | - * |
|
710 | - * @param PDF $pdf Object PDF |
|
711 | - * @param CommandeFournisseur $object Object order |
|
712 | - * @param int $posy Position y in PDF |
|
713 | - * @param Translate $outputlangs Object langs for output |
|
714 | - * @return int <0 if KO, >0 if OK |
|
715 | - */ |
|
716 | - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
717 | - { |
|
707 | + /** |
|
708 | + * Show payments table |
|
709 | + * |
|
710 | + * @param PDF $pdf Object PDF |
|
711 | + * @param CommandeFournisseur $object Object order |
|
712 | + * @param int $posy Position y in PDF |
|
713 | + * @param Translate $outputlangs Object langs for output |
|
714 | + * @return int <0 if KO, >0 if OK |
|
715 | + */ |
|
716 | + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
717 | + { |
|
718 | 718 | // phpcs:enable |
719 | - } |
|
719 | + } |
|
720 | 720 | |
721 | 721 | |
722 | 722 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
723 | - /** |
|
724 | - * Show miscellaneous information (payment mode, payment term, ...) |
|
725 | - * |
|
726 | - * @param PDF $pdf Object PDF |
|
727 | - * @param CommandeFournisseur $object Object to show |
|
728 | - * @param int $posy Y |
|
729 | - * @param Translate $outputlangs Langs object |
|
730 | - * @return integer |
|
731 | - */ |
|
732 | - function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
733 | - { |
|
723 | + /** |
|
724 | + * Show miscellaneous information (payment mode, payment term, ...) |
|
725 | + * |
|
726 | + * @param PDF $pdf Object PDF |
|
727 | + * @param CommandeFournisseur $object Object to show |
|
728 | + * @param int $posy Y |
|
729 | + * @param Translate $outputlangs Langs object |
|
730 | + * @return integer |
|
731 | + */ |
|
732 | + function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
733 | + { |
|
734 | 734 | // phpcs:enable |
735 | - global $conf; |
|
736 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
735 | + global $conf; |
|
736 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
737 | 737 | |
738 | 738 | // If France, show VAT mention if not applicable |
739 | - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
740 | - { |
|
741 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
742 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
743 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
744 | - |
|
745 | - $posy=$pdf->GetY()+4; |
|
746 | - } |
|
747 | - |
|
748 | - $posxval=52; |
|
739 | + if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
740 | + { |
|
741 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
742 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
743 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
749 | 744 | |
750 | - // Show payments conditions |
|
751 | - if (!empty($object->cond_reglement_code) || $object->cond_reglement) |
|
752 | - { |
|
753 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
754 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
755 | - $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
|
756 | - $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
745 | + $posy=$pdf->GetY()+4; |
|
746 | + } |
|
757 | 747 | |
758 | - $pdf->SetFont('','', $default_font_size - 2); |
|
759 | - $pdf->SetXY($posxval, $posy); |
|
760 | - $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); |
|
761 | - $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
762 | - $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); |
|
748 | + $posxval=52; |
|
763 | 749 | |
764 | - $posy=$pdf->GetY()+3; |
|
765 | - } |
|
750 | + // Show payments conditions |
|
751 | + if (!empty($object->cond_reglement_code) || $object->cond_reglement) |
|
752 | + { |
|
753 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
754 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
755 | + $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
|
756 | + $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
757 | + |
|
758 | + $pdf->SetFont('','', $default_font_size - 2); |
|
759 | + $pdf->SetXY($posxval, $posy); |
|
760 | + $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); |
|
761 | + $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
762 | + $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); |
|
763 | + |
|
764 | + $posy=$pdf->GetY()+3; |
|
765 | + } |
|
766 | 766 | |
767 | - // Show payment mode |
|
767 | + // Show payment mode |
|
768 | 768 | if (!empty($object->mode_reglement_code)) |
769 | 769 | { |
770 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
771 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
772 | - $titre = $outputlangs->transnoentities("PaymentMode").':'; |
|
773 | - $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
|
770 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
771 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
772 | + $titre = $outputlangs->transnoentities("PaymentMode").':'; |
|
773 | + $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
|
774 | 774 | |
775 | - $pdf->SetFont('','', $default_font_size - 2); |
|
776 | - $pdf->SetXY($posxval, $posy); |
|
777 | - $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); |
|
778 | - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
775 | + $pdf->SetFont('','', $default_font_size - 2); |
|
776 | + $pdf->SetXY($posxval, $posy); |
|
777 | + $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); |
|
778 | + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
779 | 779 | |
780 | - $posy=$pdf->GetY()+2; |
|
780 | + $posy=$pdf->GetY()+2; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | |
784 | - return $posy; |
|
785 | - } |
|
784 | + return $posy; |
|
785 | + } |
|
786 | 786 | |
787 | 787 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
788 | - /** |
|
789 | - * Show total to pay |
|
790 | - * |
|
791 | - * @param PDF $pdf Object PDF |
|
792 | - * @param Facture $object Object invoice |
|
793 | - * @param int $deja_regle Montant deja regle |
|
794 | - * @param int $posy Position depart |
|
795 | - * @param Translate $outputlangs Objet langs |
|
796 | - * @return int Position pour suite |
|
797 | - */ |
|
798 | - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
799 | - { |
|
788 | + /** |
|
789 | + * Show total to pay |
|
790 | + * |
|
791 | + * @param PDF $pdf Object PDF |
|
792 | + * @param Facture $object Object invoice |
|
793 | + * @param int $deja_regle Montant deja regle |
|
794 | + * @param int $posy Position depart |
|
795 | + * @param Translate $outputlangs Objet langs |
|
796 | + * @return int Position pour suite |
|
797 | + */ |
|
798 | + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
799 | + { |
|
800 | 800 | // phpcs:enable |
801 | - global $conf,$mysoc; |
|
801 | + global $conf,$mysoc; |
|
802 | 802 | |
803 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
803 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
804 | 804 | |
805 | 805 | $tab2_top = $posy; |
806 | - $tab2_hl = 4; |
|
807 | - $pdf->SetFont('','', $default_font_size - 1); |
|
806 | + $tab2_hl = 4; |
|
807 | + $pdf->SetFont('','', $default_font_size - 1); |
|
808 | 808 | |
809 | - // Tableau total |
|
810 | - $col1x = 120; $col2x = 170; |
|
811 | - if ($this->page_largeur < 210) // To work with US executive format |
|
812 | - { |
|
813 | - $col2x-=20; |
|
814 | - } |
|
815 | - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
809 | + // Tableau total |
|
810 | + $col1x = 120; $col2x = 170; |
|
811 | + if ($this->page_largeur < 210) // To work with US executive format |
|
812 | + { |
|
813 | + $col2x-=20; |
|
814 | + } |
|
815 | + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
816 | 816 | |
817 | - $useborder=0; |
|
818 | - $index = 0; |
|
817 | + $useborder=0; |
|
818 | + $index = 0; |
|
819 | 819 | |
820 | - // Total HT |
|
821 | - $pdf->SetFillColor(255,255,255); |
|
822 | - $pdf->SetXY($col1x, $tab2_top + 0); |
|
823 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
820 | + // Total HT |
|
821 | + $pdf->SetFillColor(255,255,255); |
|
822 | + $pdf->SetXY($col1x, $tab2_top + 0); |
|
823 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
824 | 824 | |
825 | - $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
826 | - $pdf->SetXY($col2x, $tab2_top + 0); |
|
827 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); |
|
825 | + $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
826 | + $pdf->SetXY($col2x, $tab2_top + 0); |
|
827 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); |
|
828 | 828 | |
829 | - // Show VAT by rates and total |
|
830 | - $pdf->SetFillColor(248,248,248); |
|
829 | + // Show VAT by rates and total |
|
830 | + $pdf->SetFillColor(248,248,248); |
|
831 | 831 | |
832 | - $this->atleastoneratenotnull=0; |
|
833 | - foreach( $this->tva as $tvakey => $tvaval ) |
|
834 | - { |
|
835 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
836 | - { |
|
837 | - $this->atleastoneratenotnull++; |
|
838 | - |
|
839 | - $index++; |
|
840 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
841 | - |
|
842 | - $tvacompl=''; |
|
843 | - |
|
844 | - if (preg_match('/\*/',$tvakey)) |
|
845 | - { |
|
846 | - $tvakey=str_replace('*','',$tvakey); |
|
847 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
848 | - } |
|
849 | - |
|
850 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
851 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
852 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
853 | - |
|
854 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
855 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
856 | - } |
|
857 | - } |
|
858 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
859 | - { |
|
860 | - $index++; |
|
861 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
862 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
863 | - |
|
864 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
865 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
|
866 | - |
|
867 | - // Total LocalTax1 |
|
868 | - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
869 | - { |
|
870 | - $index++; |
|
871 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
872 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
873 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
874 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); |
|
875 | - } |
|
876 | - |
|
877 | - // Total LocalTax2 |
|
878 | - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
879 | - { |
|
880 | - $index++; |
|
881 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
882 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
883 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
884 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); |
|
885 | - } |
|
886 | - } |
|
887 | - else |
|
888 | - { |
|
889 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
890 | - //{ |
|
891 | - //Local tax 1 |
|
892 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
893 | - { |
|
894 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
895 | - |
|
896 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
897 | - { |
|
898 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
899 | - { |
|
900 | - //$this->atleastoneratenotnull++; |
|
901 | - |
|
902 | - $index++; |
|
903 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
904 | - |
|
905 | - $tvacompl=''; |
|
906 | - if (preg_match('/\*/',$tvakey)) |
|
907 | - { |
|
908 | - $tvakey=str_replace('*','',$tvakey); |
|
909 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
910 | - } |
|
911 | - $totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
912 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
913 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
914 | - |
|
915 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
916 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
917 | - } |
|
918 | - } |
|
919 | - } |
|
920 | - |
|
921 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
922 | - //{ |
|
923 | - //Local tax 2 |
|
924 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
925 | - { |
|
926 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
927 | - |
|
928 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
929 | - { |
|
930 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
931 | - { |
|
932 | - //$this->atleastoneratenotnull++; |
|
933 | - |
|
934 | - $index++; |
|
935 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
936 | - |
|
937 | - $tvacompl=''; |
|
938 | - if (preg_match('/\*/',$tvakey)) |
|
939 | - { |
|
940 | - $tvakey=str_replace('*','',$tvakey); |
|
941 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
942 | - } |
|
943 | - $totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
944 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
945 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
946 | - |
|
947 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
948 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
949 | - } |
|
950 | - } |
|
951 | - } |
|
952 | - } |
|
953 | - |
|
954 | - // Total TTC |
|
955 | - $index++; |
|
956 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
957 | - $pdf->SetTextColor(0,0,60); |
|
958 | - $pdf->SetFillColor(224,224,224); |
|
959 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
960 | - |
|
961 | - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
962 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
963 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
|
964 | - $pdf->SetFont('','', $default_font_size - 1); |
|
965 | - $pdf->SetTextColor(0,0,0); |
|
832 | + $this->atleastoneratenotnull=0; |
|
833 | + foreach( $this->tva as $tvakey => $tvaval ) |
|
834 | + { |
|
835 | + if ($tvakey > 0) // On affiche pas taux 0 |
|
836 | + { |
|
837 | + $this->atleastoneratenotnull++; |
|
838 | + |
|
839 | + $index++; |
|
840 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
841 | + |
|
842 | + $tvacompl=''; |
|
843 | + |
|
844 | + if (preg_match('/\*/',$tvakey)) |
|
845 | + { |
|
846 | + $tvakey=str_replace('*','',$tvakey); |
|
847 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
848 | + } |
|
849 | + |
|
850 | + $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
851 | + $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
852 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
853 | + |
|
854 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
855 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
856 | + } |
|
857 | + } |
|
858 | + if (! $this->atleastoneratenotnull) // If no vat at all |
|
859 | + { |
|
860 | + $index++; |
|
861 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
862 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
863 | + |
|
864 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
865 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
|
866 | + |
|
867 | + // Total LocalTax1 |
|
868 | + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
869 | + { |
|
870 | + $index++; |
|
871 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
872 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
873 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
874 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); |
|
875 | + } |
|
876 | + |
|
877 | + // Total LocalTax2 |
|
878 | + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
879 | + { |
|
880 | + $index++; |
|
881 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
882 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
883 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
884 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); |
|
885 | + } |
|
886 | + } |
|
887 | + else |
|
888 | + { |
|
889 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
890 | + //{ |
|
891 | + //Local tax 1 |
|
892 | + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
893 | + { |
|
894 | + if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
895 | + |
|
896 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
897 | + { |
|
898 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
899 | + { |
|
900 | + //$this->atleastoneratenotnull++; |
|
901 | + |
|
902 | + $index++; |
|
903 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
904 | + |
|
905 | + $tvacompl=''; |
|
906 | + if (preg_match('/\*/',$tvakey)) |
|
907 | + { |
|
908 | + $tvakey=str_replace('*','',$tvakey); |
|
909 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
910 | + } |
|
911 | + $totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
912 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
913 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
914 | + |
|
915 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
916 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
917 | + } |
|
918 | + } |
|
919 | + } |
|
920 | + |
|
921 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
922 | + //{ |
|
923 | + //Local tax 2 |
|
924 | + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
925 | + { |
|
926 | + if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
927 | + |
|
928 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
929 | + { |
|
930 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
931 | + { |
|
932 | + //$this->atleastoneratenotnull++; |
|
933 | + |
|
934 | + $index++; |
|
935 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
936 | + |
|
937 | + $tvacompl=''; |
|
938 | + if (preg_match('/\*/',$tvakey)) |
|
939 | + { |
|
940 | + $tvakey=str_replace('*','',$tvakey); |
|
941 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
942 | + } |
|
943 | + $totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
944 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
945 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
946 | + |
|
947 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
948 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
949 | + } |
|
950 | + } |
|
951 | + } |
|
952 | + } |
|
953 | + |
|
954 | + // Total TTC |
|
955 | + $index++; |
|
956 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
957 | + $pdf->SetTextColor(0,0,60); |
|
958 | + $pdf->SetFillColor(224,224,224); |
|
959 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
960 | + |
|
961 | + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
962 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
963 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
|
964 | + $pdf->SetFont('','', $default_font_size - 1); |
|
965 | + $pdf->SetTextColor(0,0,0); |
|
966 | 966 | |
967 | 967 | $creditnoteamount=0; |
968 | 968 | $depositsamount=0; |
969 | - //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
970 | - //$depositsamount=$object->getSumDepositsUsed(); |
|
971 | - //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
972 | - $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
973 | - if (! empty($object->paye)) $resteapayer=0; |
|
969 | + //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
970 | + //$depositsamount=$object->getSumDepositsUsed(); |
|
971 | + //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
972 | + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
973 | + if (! empty($object->paye)) $resteapayer=0; |
|
974 | 974 | |
975 | - if ($deja_regle > 0) |
|
976 | - { |
|
977 | - // Already paid + Deposits |
|
978 | - $index++; |
|
975 | + if ($deja_regle > 0) |
|
976 | + { |
|
977 | + // Already paid + Deposits |
|
978 | + $index++; |
|
979 | 979 | |
980 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
981 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
982 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
983 | - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
|
980 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
981 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
982 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
983 | + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
|
984 | 984 | |
985 | - $index++; |
|
986 | - $pdf->SetTextColor(0,0,60); |
|
987 | - $pdf->SetFillColor(224,224,224); |
|
988 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
989 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
985 | + $index++; |
|
986 | + $pdf->SetTextColor(0,0,60); |
|
987 | + $pdf->SetFillColor(224,224,224); |
|
988 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
989 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
990 | 990 | |
991 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
992 | - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
|
991 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
992 | + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
|
993 | 993 | |
994 | - $pdf->SetFont('','', $default_font_size - 1); |
|
995 | - $pdf->SetTextColor(0,0,0); |
|
996 | - } |
|
994 | + $pdf->SetFont('','', $default_font_size - 1); |
|
995 | + $pdf->SetTextColor(0,0,0); |
|
996 | + } |
|
997 | 997 | |
998 | - $index++; |
|
999 | - return ($tab2_top + ($tab2_hl * $index)); |
|
1000 | - } |
|
998 | + $index++; |
|
999 | + return ($tab2_top + ($tab2_hl * $index)); |
|
1000 | + } |
|
1001 | 1001 | |
1002 | 1002 | /** |
1003 | - * Show table for lines |
|
1004 | - * |
|
1005 | - * @param PDF $pdf Object PDF |
|
1006 | - * @param string $tab_top Top position of table |
|
1007 | - * @param string $tab_height Height of table (rectangle) |
|
1008 | - * @param int $nexY Y (not used) |
|
1009 | - * @param Translate $outputlangs Langs object |
|
1010 | - * @param int $hidetop Hide top bar of array |
|
1011 | - * @param int $hidebottom Hide bottom bar of array |
|
1012 | - * @param string $currency Currency code |
|
1013 | - * @return void |
|
1014 | - */ |
|
1015 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1016 | - { |
|
1017 | - global $conf; |
|
1018 | - |
|
1019 | - // Force to disable hidetop and hidebottom |
|
1020 | - $hidebottom=0; |
|
1021 | - if ($hidetop) $hidetop=-1; |
|
1022 | - |
|
1023 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
1024 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1003 | + * Show table for lines |
|
1004 | + * |
|
1005 | + * @param PDF $pdf Object PDF |
|
1006 | + * @param string $tab_top Top position of table |
|
1007 | + * @param string $tab_height Height of table (rectangle) |
|
1008 | + * @param int $nexY Y (not used) |
|
1009 | + * @param Translate $outputlangs Langs object |
|
1010 | + * @param int $hidetop Hide top bar of array |
|
1011 | + * @param int $hidebottom Hide bottom bar of array |
|
1012 | + * @param string $currency Currency code |
|
1013 | + * @return void |
|
1014 | + */ |
|
1015 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1016 | + { |
|
1017 | + global $conf; |
|
1018 | + |
|
1019 | + // Force to disable hidetop and hidebottom |
|
1020 | + $hidebottom=0; |
|
1021 | + if ($hidetop) $hidetop=-1; |
|
1022 | + |
|
1023 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
1024 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1025 | 1025 | |
1026 | 1026 | // Amount in (at tab_top - 1) |
1027 | - $pdf->SetTextColor(0,0,0); |
|
1028 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1027 | + $pdf->SetTextColor(0,0,0); |
|
1028 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1029 | 1029 | |
1030 | - if (empty($hidetop)) |
|
1031 | - { |
|
1032 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1033 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1034 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
1030 | + if (empty($hidetop)) |
|
1031 | + { |
|
1032 | + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1033 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1034 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
1035 | 1035 | |
1036 | - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
1037 | - 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)); |
|
1038 | - } |
|
1036 | + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
1037 | + 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)); |
|
1038 | + } |
|
1039 | 1039 | |
1040 | - $pdf->SetDrawColor(128,128,128); |
|
1041 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1040 | + $pdf->SetDrawColor(128,128,128); |
|
1041 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1042 | 1042 | |
1043 | - // Output Rect |
|
1044 | - $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 |
|
1043 | + // Output Rect |
|
1044 | + $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 |
|
1045 | 1045 | |
1046 | - if (empty($hidetop)) |
|
1047 | - { |
|
1048 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1046 | + if (empty($hidetop)) |
|
1047 | + { |
|
1048 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1049 | 1049 | |
1050 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1051 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1052 | - } |
|
1050 | + $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1051 | + $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1052 | + } |
|
1053 | 1053 | |
1054 | 1054 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
1055 | 1055 | { |
1056 | - $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); |
|
1057 | - if (empty($hidetop)) |
|
1058 | - { |
|
1059 | - $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
1060 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1061 | - } |
|
1056 | + $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); |
|
1057 | + if (empty($hidetop)) |
|
1058 | + { |
|
1059 | + $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
1060 | + $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1061 | + } |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | - $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height); |
|
1065 | - if (empty($hidetop)) |
|
1066 | - { |
|
1067 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1068 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1069 | - } |
|
1064 | + $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height); |
|
1065 | + if (empty($hidetop)) |
|
1066 | + { |
|
1067 | + $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1068 | + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1069 | + } |
|
1070 | 1070 | |
1071 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1072 | - if (empty($hidetop)) |
|
1073 | - { |
|
1074 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1075 | - if($conf->global->PRODUCT_USE_UNITS) |
|
1076 | - { |
|
1077 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1078 | - } |
|
1079 | - else |
|
1080 | - { |
|
1081 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1082 | - } |
|
1083 | - } |
|
1084 | - |
|
1085 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
1086 | - $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
1087 | - if (empty($hidetop)) { |
|
1088 | - $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
1089 | - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
1090 | - 'C'); |
|
1091 | - } |
|
1092 | - } |
|
1093 | - |
|
1094 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1095 | - if (empty($hidetop)) |
|
1096 | - { |
|
1097 | - if ($this->atleastonediscount) |
|
1098 | - { |
|
1099 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1100 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1101 | - } |
|
1102 | - } |
|
1103 | - |
|
1104 | - if ($this->atleastonediscount) |
|
1105 | - { |
|
1106 | - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
1107 | - } |
|
1108 | - if (empty($hidetop)) |
|
1109 | - { |
|
1110 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1111 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
1112 | - } |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * Show top header of page. |
|
1117 | - * |
|
1118 | - * @param PDF $pdf Object PDF |
|
1119 | - * @param CommandeFournisseur $object Object to show |
|
1120 | - * @param int $showaddress 0=no, 1=yes |
|
1121 | - * @param Translate $outputlangs Object lang for output |
|
1122 | - * @return void |
|
1123 | - */ |
|
1124 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
1125 | - { |
|
1126 | - global $langs, $conf, $mysoc; |
|
1127 | - |
|
1128 | - // Load translation files required by the page |
|
1129 | - $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); |
|
1130 | - |
|
1131 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1132 | - |
|
1133 | - // Do not add the BACKGROUND as this is for suppliers |
|
1134 | - //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1135 | - |
|
1136 | - //Affiche le filigrane brouillon - Print Draft Watermark |
|
1137 | - /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) |
|
1071 | + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1072 | + if (empty($hidetop)) |
|
1073 | + { |
|
1074 | + $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1075 | + if($conf->global->PRODUCT_USE_UNITS) |
|
1076 | + { |
|
1077 | + $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1078 | + } |
|
1079 | + else |
|
1080 | + { |
|
1081 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1082 | + } |
|
1083 | + } |
|
1084 | + |
|
1085 | + if($conf->global->PRODUCT_USE_UNITS) { |
|
1086 | + $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
1087 | + if (empty($hidetop)) { |
|
1088 | + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
1089 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
1090 | + 'C'); |
|
1091 | + } |
|
1092 | + } |
|
1093 | + |
|
1094 | + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1095 | + if (empty($hidetop)) |
|
1096 | + { |
|
1097 | + if ($this->atleastonediscount) |
|
1098 | + { |
|
1099 | + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1100 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1101 | + } |
|
1102 | + } |
|
1103 | + |
|
1104 | + if ($this->atleastonediscount) |
|
1105 | + { |
|
1106 | + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
1107 | + } |
|
1108 | + if (empty($hidetop)) |
|
1109 | + { |
|
1110 | + $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1111 | + $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
1112 | + } |
|
1113 | + } |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * Show top header of page. |
|
1117 | + * |
|
1118 | + * @param PDF $pdf Object PDF |
|
1119 | + * @param CommandeFournisseur $object Object to show |
|
1120 | + * @param int $showaddress 0=no, 1=yes |
|
1121 | + * @param Translate $outputlangs Object lang for output |
|
1122 | + * @return void |
|
1123 | + */ |
|
1124 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
1125 | + { |
|
1126 | + global $langs, $conf, $mysoc; |
|
1127 | + |
|
1128 | + // Load translation files required by the page |
|
1129 | + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); |
|
1130 | + |
|
1131 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1132 | + |
|
1133 | + // Do not add the BACKGROUND as this is for suppliers |
|
1134 | + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1135 | + |
|
1136 | + //Affiche le filigrane brouillon - Print Draft Watermark |
|
1137 | + /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) |
|
1138 | 1138 | { |
1139 | 1139 | pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); |
1140 | 1140 | }*/ |
1141 | - //Print content |
|
1141 | + //Print content |
|
1142 | 1142 | |
1143 | - $pdf->SetTextColor(0,0,60); |
|
1144 | - $pdf->SetFont('','B',$default_font_size + 3); |
|
1143 | + $pdf->SetTextColor(0,0,60); |
|
1144 | + $pdf->SetFont('','B',$default_font_size + 3); |
|
1145 | 1145 | |
1146 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1147 | - $posy=$this->marge_haute; |
|
1146 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
1147 | + $posy=$this->marge_haute; |
|
1148 | 1148 | |
1149 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1149 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
1150 | 1150 | |
1151 | - // Logo |
|
1152 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1153 | - if ($this->emetteur->logo) |
|
1154 | - { |
|
1155 | - if (is_readable($logo)) |
|
1156 | - { |
|
1157 | - $height=pdf_getHeightForLogo($logo); |
|
1158 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1159 | - } |
|
1160 | - else |
|
1161 | - { |
|
1162 | - $pdf->SetTextColor(200,0,0); |
|
1163 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
1164 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1165 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
1166 | - } |
|
1167 | - } |
|
1168 | - else |
|
1169 | - { |
|
1170 | - $text=$this->emetteur->name; |
|
1171 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1172 | - } |
|
1173 | - |
|
1174 | - $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1175 | - $pdf->SetXY($posx,$posy); |
|
1176 | - $pdf->SetTextColor(0,0,60); |
|
1177 | - $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); |
|
1178 | - $pdf->MultiCell(100, 3, $title, '', 'R'); |
|
1179 | - $posy+=1; |
|
1180 | - |
|
1181 | - if ($object->ref_supplier) |
|
1182 | - { |
|
1183 | - $posy+=4; |
|
1184 | - $pdf->SetFont('','B', $default_font_size); |
|
1185 | - $pdf->SetXY($posx,$posy); |
|
1186 | - $pdf->SetTextColor(0,0,60); |
|
1187 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); |
|
1188 | - $posy+=1; |
|
1189 | - } |
|
1151 | + // Logo |
|
1152 | + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1153 | + if ($this->emetteur->logo) |
|
1154 | + { |
|
1155 | + if (is_readable($logo)) |
|
1156 | + { |
|
1157 | + $height=pdf_getHeightForLogo($logo); |
|
1158 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1159 | + } |
|
1160 | + else |
|
1161 | + { |
|
1162 | + $pdf->SetTextColor(200,0,0); |
|
1163 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
1164 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1165 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
1166 | + } |
|
1167 | + } |
|
1168 | + else |
|
1169 | + { |
|
1170 | + $text=$this->emetteur->name; |
|
1171 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1172 | + } |
|
1190 | 1173 | |
1191 | - $pdf->SetFont('','', $default_font_size -1); |
|
1174 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1175 | + $pdf->SetXY($posx,$posy); |
|
1176 | + $pdf->SetTextColor(0,0,60); |
|
1177 | + $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); |
|
1178 | + $pdf->MultiCell(100, 3, $title, '', 'R'); |
|
1179 | + $posy+=1; |
|
1192 | 1180 | |
1193 | - if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1194 | - { |
|
1195 | - $object->fetch_projet(); |
|
1196 | - if (! empty($object->project->ref)) |
|
1197 | - { |
|
1198 | - $posy+=4; |
|
1199 | - $pdf->SetXY($posx,$posy); |
|
1200 | - $langs->load("projects"); |
|
1201 | - $pdf->SetTextColor(0,0,60); |
|
1202 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1203 | - } |
|
1204 | - } |
|
1205 | - |
|
1206 | - if (! empty($object->date_commande)) |
|
1207 | - { |
|
1208 | - $posy+=5; |
|
1209 | - $pdf->SetXY($posx,$posy); |
|
1210 | - $pdf->SetTextColor(0,0,60); |
|
1211 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R'); |
|
1212 | - } |
|
1213 | - else |
|
1214 | - { |
|
1215 | - $posy+=5; |
|
1216 | - $pdf->SetXY($posx,$posy); |
|
1217 | - $pdf->SetTextColor(255,0,0); |
|
1218 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); |
|
1219 | - } |
|
1220 | - |
|
1221 | - $pdf->SetTextColor(0,0,60); |
|
1222 | - $usehourmin='day'; |
|
1223 | - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; |
|
1224 | - if (! empty($object->date_livraison)) |
|
1225 | - { |
|
1226 | - $posy+=4; |
|
1227 | - $pdf->SetXY($posx-90,$posy); |
|
1228 | - $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R'); |
|
1229 | - } |
|
1181 | + if ($object->ref_supplier) |
|
1182 | + { |
|
1183 | + $posy+=4; |
|
1184 | + $pdf->SetFont('','B', $default_font_size); |
|
1185 | + $pdf->SetXY($posx,$posy); |
|
1186 | + $pdf->SetTextColor(0,0,60); |
|
1187 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); |
|
1188 | + $posy+=1; |
|
1189 | + } |
|
1230 | 1190 | |
1231 | - if ($object->thirdparty->code_fournisseur) |
|
1232 | - { |
|
1233 | - $posy+=4; |
|
1234 | - $pdf->SetXY($posx,$posy); |
|
1235 | - $pdf->SetTextColor(0,0,60); |
|
1236 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1237 | - } |
|
1238 | - |
|
1239 | - // Get contact |
|
1240 | - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
|
1241 | - { |
|
1242 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1243 | - if (count($arrayidcontact) > 0) |
|
1244 | - { |
|
1245 | - $usertmp=new User($this->db); |
|
1246 | - $usertmp->fetch($arrayidcontact[0]); |
|
1191 | + $pdf->SetFont('','', $default_font_size -1); |
|
1192 | + |
|
1193 | + if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1194 | + { |
|
1195 | + $object->fetch_projet(); |
|
1196 | + if (! empty($object->project->ref)) |
|
1197 | + { |
|
1247 | 1198 | $posy+=4; |
1248 | 1199 | $pdf->SetXY($posx,$posy); |
1249 | - $pdf->SetTextColor(0,0,60); |
|
1250 | - $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); |
|
1251 | - } |
|
1252 | - } |
|
1253 | - |
|
1254 | - $posy+=1; |
|
1255 | - $pdf->SetTextColor(0,0,60); |
|
1256 | - |
|
1257 | - $top_shift = 0; |
|
1258 | - // Show list of linked objects |
|
1259 | - $current_y = $pdf->getY(); |
|
1260 | - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1261 | - if ($current_y < $pdf->getY()) |
|
1262 | - { |
|
1263 | - $top_shift = $pdf->getY() - $current_y; |
|
1264 | - } |
|
1200 | + $langs->load("projects"); |
|
1201 | + $pdf->SetTextColor(0,0,60); |
|
1202 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1203 | + } |
|
1204 | + } |
|
1265 | 1205 | |
1266 | - if ($showaddress) |
|
1267 | - { |
|
1268 | - // Sender properties |
|
1269 | - $carac_emetteur=''; |
|
1270 | - // Add internal contact of proposal if defined |
|
1271 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1272 | - if (count($arrayidcontact) > 0) |
|
1273 | - { |
|
1274 | - $object->fetch_user($arrayidcontact[0]); |
|
1275 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1276 | - } |
|
1277 | - |
|
1278 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1279 | - |
|
1280 | - // Show sender |
|
1281 | - $posy=42+$top_shift; |
|
1282 | - $posx=$this->marge_gauche; |
|
1283 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1284 | - $hautcadre=40; |
|
1285 | - |
|
1286 | - // Show sender frame |
|
1287 | - $pdf->SetTextColor(0,0,0); |
|
1288 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1289 | - $pdf->SetXY($posx,$posy-5); |
|
1290 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1291 | - $pdf->SetXY($posx,$posy); |
|
1292 | - $pdf->SetFillColor(230,230,230); |
|
1293 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1294 | - $pdf->SetTextColor(0,0,60); |
|
1295 | - |
|
1296 | - // Show sender name |
|
1297 | - $pdf->SetXY($posx+2,$posy+3); |
|
1298 | - $pdf->SetFont('','B', $default_font_size); |
|
1299 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1300 | - $posy=$pdf->getY(); |
|
1301 | - |
|
1302 | - // Show sender information |
|
1303 | - $pdf->SetXY($posx+2,$posy); |
|
1304 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1305 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1306 | - |
|
1307 | - |
|
1308 | - |
|
1309 | - // If BILLING contact defined on order, we use it |
|
1310 | - $usecontact=false; |
|
1311 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
1312 | - if (count($arrayidcontact) > 0) |
|
1313 | - { |
|
1314 | - $usecontact=true; |
|
1315 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1316 | - } |
|
1317 | - |
|
1318 | - //Recipient name |
|
1319 | - // On peut utiliser le nom de la societe du contact |
|
1320 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1321 | - $thirdparty = $object->contact; |
|
1322 | - } else { |
|
1323 | - $thirdparty = $object->thirdparty; |
|
1324 | - } |
|
1325 | - |
|
1326 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1327 | - |
|
1328 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); |
|
1329 | - |
|
1330 | - // Show recipient |
|
1331 | - $widthrecbox=100; |
|
1332 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1333 | - $posy=42+$top_shift; |
|
1334 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1335 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1336 | - |
|
1337 | - // Show recipient frame |
|
1338 | - $pdf->SetTextColor(0,0,0); |
|
1339 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1340 | - $pdf->SetXY($posx+2,$posy-5); |
|
1341 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1342 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1343 | - |
|
1344 | - // Show recipient name |
|
1345 | - $pdf->SetXY($posx+2,$posy+3); |
|
1346 | - $pdf->SetFont('','B', $default_font_size); |
|
1347 | - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1348 | - |
|
1349 | - $posy = $pdf->getY(); |
|
1350 | - |
|
1351 | - // Show recipient information |
|
1352 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1353 | - $pdf->SetXY($posx+2,$posy); |
|
1354 | - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1355 | - } |
|
1356 | - |
|
1357 | - return $top_shift; |
|
1358 | - } |
|
1359 | - |
|
1360 | - /** |
|
1361 | - * Show footer of page. Need this->emetteur object |
|
1206 | + if (! empty($object->date_commande)) |
|
1207 | + { |
|
1208 | + $posy+=5; |
|
1209 | + $pdf->SetXY($posx,$posy); |
|
1210 | + $pdf->SetTextColor(0,0,60); |
|
1211 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R'); |
|
1212 | + } |
|
1213 | + else |
|
1214 | + { |
|
1215 | + $posy+=5; |
|
1216 | + $pdf->SetXY($posx,$posy); |
|
1217 | + $pdf->SetTextColor(255,0,0); |
|
1218 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); |
|
1219 | + } |
|
1220 | + |
|
1221 | + $pdf->SetTextColor(0,0,60); |
|
1222 | + $usehourmin='day'; |
|
1223 | + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; |
|
1224 | + if (! empty($object->date_livraison)) |
|
1225 | + { |
|
1226 | + $posy+=4; |
|
1227 | + $pdf->SetXY($posx-90,$posy); |
|
1228 | + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R'); |
|
1229 | + } |
|
1230 | + |
|
1231 | + if ($object->thirdparty->code_fournisseur) |
|
1232 | + { |
|
1233 | + $posy+=4; |
|
1234 | + $pdf->SetXY($posx,$posy); |
|
1235 | + $pdf->SetTextColor(0,0,60); |
|
1236 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1237 | + } |
|
1238 | + |
|
1239 | + // Get contact |
|
1240 | + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
|
1241 | + { |
|
1242 | + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1243 | + if (count($arrayidcontact) > 0) |
|
1244 | + { |
|
1245 | + $usertmp=new User($this->db); |
|
1246 | + $usertmp->fetch($arrayidcontact[0]); |
|
1247 | + $posy+=4; |
|
1248 | + $pdf->SetXY($posx,$posy); |
|
1249 | + $pdf->SetTextColor(0,0,60); |
|
1250 | + $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); |
|
1251 | + } |
|
1252 | + } |
|
1253 | + |
|
1254 | + $posy+=1; |
|
1255 | + $pdf->SetTextColor(0,0,60); |
|
1256 | + |
|
1257 | + $top_shift = 0; |
|
1258 | + // Show list of linked objects |
|
1259 | + $current_y = $pdf->getY(); |
|
1260 | + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1261 | + if ($current_y < $pdf->getY()) |
|
1262 | + { |
|
1263 | + $top_shift = $pdf->getY() - $current_y; |
|
1264 | + } |
|
1265 | + |
|
1266 | + if ($showaddress) |
|
1267 | + { |
|
1268 | + // Sender properties |
|
1269 | + $carac_emetteur=''; |
|
1270 | + // Add internal contact of proposal if defined |
|
1271 | + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1272 | + if (count($arrayidcontact) > 0) |
|
1273 | + { |
|
1274 | + $object->fetch_user($arrayidcontact[0]); |
|
1275 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1276 | + } |
|
1277 | + |
|
1278 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1279 | + |
|
1280 | + // Show sender |
|
1281 | + $posy=42+$top_shift; |
|
1282 | + $posx=$this->marge_gauche; |
|
1283 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1284 | + $hautcadre=40; |
|
1285 | + |
|
1286 | + // Show sender frame |
|
1287 | + $pdf->SetTextColor(0,0,0); |
|
1288 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1289 | + $pdf->SetXY($posx,$posy-5); |
|
1290 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1291 | + $pdf->SetXY($posx,$posy); |
|
1292 | + $pdf->SetFillColor(230,230,230); |
|
1293 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1294 | + $pdf->SetTextColor(0,0,60); |
|
1295 | + |
|
1296 | + // Show sender name |
|
1297 | + $pdf->SetXY($posx+2,$posy+3); |
|
1298 | + $pdf->SetFont('','B', $default_font_size); |
|
1299 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1300 | + $posy=$pdf->getY(); |
|
1301 | + |
|
1302 | + // Show sender information |
|
1303 | + $pdf->SetXY($posx+2,$posy); |
|
1304 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1305 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1306 | + |
|
1307 | + |
|
1308 | + |
|
1309 | + // If BILLING contact defined on order, we use it |
|
1310 | + $usecontact=false; |
|
1311 | + $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
1312 | + if (count($arrayidcontact) > 0) |
|
1313 | + { |
|
1314 | + $usecontact=true; |
|
1315 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
1316 | + } |
|
1317 | + |
|
1318 | + //Recipient name |
|
1319 | + // On peut utiliser le nom de la societe du contact |
|
1320 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1321 | + $thirdparty = $object->contact; |
|
1322 | + } else { |
|
1323 | + $thirdparty = $object->thirdparty; |
|
1324 | + } |
|
1325 | + |
|
1326 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1327 | + |
|
1328 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); |
|
1329 | + |
|
1330 | + // Show recipient |
|
1331 | + $widthrecbox=100; |
|
1332 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1333 | + $posy=42+$top_shift; |
|
1334 | + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1335 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1336 | + |
|
1337 | + // Show recipient frame |
|
1338 | + $pdf->SetTextColor(0,0,0); |
|
1339 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1340 | + $pdf->SetXY($posx+2,$posy-5); |
|
1341 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1342 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1343 | + |
|
1344 | + // Show recipient name |
|
1345 | + $pdf->SetXY($posx+2,$posy+3); |
|
1346 | + $pdf->SetFont('','B', $default_font_size); |
|
1347 | + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1348 | + |
|
1349 | + $posy = $pdf->getY(); |
|
1350 | + |
|
1351 | + // Show recipient information |
|
1352 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1353 | + $pdf->SetXY($posx+2,$posy); |
|
1354 | + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1355 | + } |
|
1356 | + |
|
1357 | + return $top_shift; |
|
1358 | + } |
|
1359 | + |
|
1360 | + /** |
|
1361 | + * Show footer of page. Need this->emetteur object |
|
1362 | 1362 | * |
1363 | - * @param PDF $pdf PDF |
|
1364 | - * @param CommandeFournisseur $object Object to show |
|
1365 | - * @param Translate $outputlangs Object lang for output |
|
1366 | - * @param int $hidefreetext 1=Hide free text |
|
1367 | - * @return int Return height of bottom margin including footer text |
|
1368 | - */ |
|
1369 | - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0) |
|
1370 | - { |
|
1371 | - global $conf; |
|
1372 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1373 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1374 | - } |
|
1363 | + * @param PDF $pdf PDF |
|
1364 | + * @param CommandeFournisseur $object Object to show |
|
1365 | + * @param Translate $outputlangs Object lang for output |
|
1366 | + * @param int $hidefreetext 1=Hide free text |
|
1367 | + * @return int Return height of bottom margin including footer text |
|
1368 | + */ |
|
1369 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0) |
|
1370 | + { |
|
1371 | + global $conf; |
|
1372 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1373 | + return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1374 | + } |
|
1375 | 1375 | } |
@@ -133,67 +133,67 @@ discard block |
||
133 | 133 | |
134 | 134 | // Dimension page pour format A4 |
135 | 135 | $this->type = 'pdf'; |
136 | - $formatarray=pdf_getFormat(); |
|
136 | + $formatarray = pdf_getFormat(); |
|
137 | 137 | $this->page_largeur = $formatarray['width']; |
138 | 138 | $this->page_hauteur = $formatarray['height']; |
139 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
140 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
141 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
142 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
143 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
144 | - |
|
145 | - $this->option_logo = 1; // Affiche logo |
|
146 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
147 | - $this->option_modereg = 1; // Affiche mode reglement |
|
148 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
149 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
150 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
151 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
152 | - $this->option_credit_note = 0; // Support credit notes |
|
153 | - $this->option_freetext = 1; // Support add of a personalised text |
|
154 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
155 | - |
|
156 | - $this->franchise=!$mysoc->tva_assuj; |
|
139 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
140 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
141 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
142 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
143 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
144 | + |
|
145 | + $this->option_logo = 1; // Affiche logo |
|
146 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
147 | + $this->option_modereg = 1; // Affiche mode reglement |
|
148 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
149 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
150 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
151 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
152 | + $this->option_credit_note = 0; // Support credit notes |
|
153 | + $this->option_freetext = 1; // Support add of a personalised text |
|
154 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
155 | + |
|
156 | + $this->franchise = !$mysoc->tva_assuj; |
|
157 | 157 | |
158 | 158 | // Get source company |
159 | - $this->emetteur=$mysoc; |
|
160 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
159 | + $this->emetteur = $mysoc; |
|
160 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined |
|
161 | 161 | |
162 | 162 | // Defini position des colonnes |
163 | - $this->posxdesc=$this->marge_gauche+1; |
|
164 | - $this->posxdiscount=162; |
|
165 | - $this->postotalht=174; |
|
163 | + $this->posxdesc = $this->marge_gauche + 1; |
|
164 | + $this->posxdiscount = 162; |
|
165 | + $this->postotalht = 174; |
|
166 | 166 | |
167 | 167 | if ($conf->global->PRODUCT_USE_UNITS) |
168 | 168 | { |
169 | - $this->posxtva=95; |
|
170 | - $this->posxup=114; |
|
171 | - $this->posxqty=132; |
|
172 | - $this->posxunit=147; |
|
169 | + $this->posxtva = 95; |
|
170 | + $this->posxup = 114; |
|
171 | + $this->posxqty = 132; |
|
172 | + $this->posxunit = 147; |
|
173 | 173 | } else { |
174 | - $this->posxtva=110; |
|
175 | - $this->posxup=126; |
|
176 | - $this->posxqty=145; |
|
174 | + $this->posxtva = 110; |
|
175 | + $this->posxup = 126; |
|
176 | + $this->posxqty = 145; |
|
177 | 177 | } |
178 | 178 | |
179 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference |
|
180 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
179 | + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference |
|
180 | + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
181 | 181 | if ($this->page_largeur < 210) // To work with US executive format |
182 | 182 | { |
183 | - $this->posxpicture-=20; |
|
184 | - $this->posxtva-=20; |
|
185 | - $this->posxup-=20; |
|
186 | - $this->posxqty-=20; |
|
187 | - $this->posxunit-=20; |
|
188 | - $this->posxdiscount-=20; |
|
189 | - $this->postotalht-=20; |
|
183 | + $this->posxpicture -= 20; |
|
184 | + $this->posxtva -= 20; |
|
185 | + $this->posxup -= 20; |
|
186 | + $this->posxqty -= 20; |
|
187 | + $this->posxunit -= 20; |
|
188 | + $this->posxdiscount -= 20; |
|
189 | + $this->postotalht -= 20; |
|
190 | 190 | } |
191 | 191 | |
192 | - $this->tva=array(); |
|
193 | - $this->localtax1=array(); |
|
194 | - $this->localtax2=array(); |
|
195 | - $this->atleastoneratenotnull=0; |
|
196 | - $this->atleastonediscount=0; |
|
192 | + $this->tva = array(); |
|
193 | + $this->localtax1 = array(); |
|
194 | + $this->localtax2 = array(); |
|
195 | + $this->atleastoneratenotnull = 0; |
|
196 | + $this->atleastonediscount = 0; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | * @param int $hideref Do not show ref |
210 | 210 | * @return int 1=OK, 0=KO |
211 | 211 | */ |
212 | - function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
212 | + function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
213 | 213 | { |
214 | 214 | // phpcs:enable |
215 | - global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; |
|
215 | + global $user, $langs, $conf, $hookmanager, $mysoc, $nblignes; |
|
216 | 216 | |
217 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
218 | 218 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
219 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
219 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
220 | 220 | |
221 | 221 | // Load translation files required by the page |
222 | 222 | $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); |
@@ -224,40 +224,40 @@ discard block |
||
224 | 224 | $nblignes = count($object->lines); |
225 | 225 | |
226 | 226 | // Loop on each lines to detect if there is at least one image to show |
227 | - $realpatharray=array(); |
|
228 | - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) |
|
227 | + $realpatharray = array(); |
|
228 | + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) |
|
229 | 229 | { |
230 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
230 | + for ($i = 0; $i < $nblignes; $i++) |
|
231 | 231 | { |
232 | 232 | if (empty($object->lines[$i]->fk_product)) continue; |
233 | 233 | |
234 | 234 | $objphoto = new Product($this->db); |
235 | 235 | $objphoto->fetch($object->lines[$i]->fk_product); |
236 | 236 | |
237 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
237 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
238 | 238 | { |
239 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
239 | + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; |
|
240 | 240 | $dir = $conf->product->dir_output.'/'.$pdir; |
241 | 241 | } |
242 | 242 | else |
243 | 243 | { |
244 | - $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; |
|
244 | + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; |
|
245 | 245 | $dir = $conf->product->dir_output.'/'.$pdir; |
246 | 246 | } |
247 | 247 | |
248 | - $realpath=''; |
|
249 | - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
248 | + $realpath = ''; |
|
249 | + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) |
|
250 | 250 | { |
251 | - $filename=$obj['photo']; |
|
251 | + $filename = $obj['photo']; |
|
252 | 252 | //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; |
253 | 253 | $realpath = $dir.$filename; |
254 | 254 | break; |
255 | 255 | } |
256 | 256 | |
257 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
257 | + if ($realpath) $realpatharray[$i] = $realpath; |
|
258 | 258 | } |
259 | 259 | } |
260 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
260 | + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; |
|
261 | 261 | |
262 | 262 | if ($conf->fournisseur->commande->dir_output) |
263 | 263 | { |
@@ -273,22 +273,22 @@ discard block |
||
273 | 273 | if ($object->specimen) |
274 | 274 | { |
275 | 275 | $dir = $conf->fournisseur->commande->dir_output; |
276 | - $file = $dir . "/SPECIMEN.pdf"; |
|
276 | + $file = $dir."/SPECIMEN.pdf"; |
|
277 | 277 | } |
278 | 278 | else |
279 | 279 | { |
280 | 280 | $objectref = dol_sanitizeFileName($object->ref); |
281 | 281 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
282 | - $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; |
|
283 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
284 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
282 | + $dir = $conf->fournisseur->commande->dir_output.'/'.$objectref; |
|
283 | + $file = $dir."/".$objectref.".pdf"; |
|
284 | + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; |
|
285 | 285 | } |
286 | 286 | |
287 | - if (! file_exists($dir)) |
|
287 | + if (!file_exists($dir)) |
|
288 | 288 | { |
289 | 289 | if (dol_mkdir($dir) < 0) |
290 | 290 | { |
291 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
291 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
292 | 292 | return 0; |
293 | 293 | } |
294 | 294 | } |
@@ -296,25 +296,25 @@ discard block |
||
296 | 296 | if (file_exists($dir)) |
297 | 297 | { |
298 | 298 | // Add pdfgeneration hook |
299 | - if (! is_object($hookmanager)) |
|
299 | + if (!is_object($hookmanager)) |
|
300 | 300 | { |
301 | 301 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
302 | - $hookmanager=new HookManager($this->db); |
|
302 | + $hookmanager = new HookManager($this->db); |
|
303 | 303 | } |
304 | 304 | $hookmanager->initHooks(array('pdfgeneration')); |
305 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
305 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
306 | 306 | global $action; |
307 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
307 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
308 | 308 | |
309 | 309 | $nblignes = count($object->lines); |
310 | 310 | |
311 | - $pdf=pdf_getInstance($this->format); |
|
312 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
313 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
314 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
315 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
316 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
317 | - $pdf->SetAutoPageBreak(1,0); |
|
311 | + $pdf = pdf_getInstance($this->format); |
|
312 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
313 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
314 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
315 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
316 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
317 | + $pdf->SetAutoPageBreak(1, 0); |
|
318 | 318 | |
319 | 319 | if (class_exists('TCPDF')) |
320 | 320 | { |
@@ -323,27 +323,27 @@ discard block |
||
323 | 323 | } |
324 | 324 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
325 | 325 | // Set path to the background PDF File |
326 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
326 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
327 | 327 | { |
328 | 328 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
329 | 329 | $tplidx = $pdf->importPage(1); |
330 | 330 | } |
331 | 331 | |
332 | 332 | $pdf->Open(); |
333 | - $pagenb=0; |
|
334 | - $pdf->SetDrawColor(128,128,128); |
|
333 | + $pagenb = 0; |
|
334 | + $pdf->SetDrawColor(128, 128, 128); |
|
335 | 335 | |
336 | 336 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
337 | 337 | $pdf->SetSubject($outputlangs->transnoentities("Order")); |
338 | 338 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
339 | 339 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
340 | 340 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
341 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
341 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
342 | 342 | |
343 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
343 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
344 | 344 | |
345 | 345 | // Positionne $this->atleastonediscount si on a au moins une remise |
346 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
346 | + for ($i = 0; $i < $nblignes; $i++) |
|
347 | 347 | { |
348 | 348 | if ($object->lines[$i]->remise_percent) |
349 | 349 | { |
@@ -352,25 +352,25 @@ discard block |
||
352 | 352 | } |
353 | 353 | if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
354 | 354 | { |
355 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
356 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
357 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
358 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
359 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
355 | + $this->posxpicture += ($this->postotalht - $this->posxdiscount); |
|
356 | + $this->posxtva += ($this->postotalht - $this->posxdiscount); |
|
357 | + $this->posxup += ($this->postotalht - $this->posxdiscount); |
|
358 | + $this->posxqty += ($this->postotalht - $this->posxdiscount); |
|
359 | + $this->posxdiscount += ($this->postotalht - $this->posxdiscount); |
|
360 | 360 | //$this->postotalht; |
361 | 361 | } |
362 | 362 | |
363 | 363 | // New page |
364 | 364 | $pdf->AddPage(); |
365 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
365 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
366 | 366 | $pagenb++; |
367 | 367 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
368 | - $pdf->SetFont('','', $default_font_size - 1); |
|
369 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
370 | - $pdf->SetTextColor(0,0,0); |
|
368 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
369 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
370 | + $pdf->SetTextColor(0, 0, 0); |
|
371 | 371 | |
372 | - $tab_top = 90+$top_shift; |
|
373 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
372 | + $tab_top = 90 + $top_shift; |
|
373 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); |
|
374 | 374 | |
375 | 375 | // Incoterm |
376 | 376 | if ($conf->incoterm->enabled) |
@@ -380,34 +380,34 @@ discard block |
||
380 | 380 | { |
381 | 381 | $tab_top -= 2; |
382 | 382 | |
383 | - $pdf->SetFont('','', $default_font_size - 1); |
|
384 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
383 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
384 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
385 | 385 | $nexY = $pdf->GetY(); |
386 | - $height_incoterms=$nexY-$tab_top; |
|
386 | + $height_incoterms = $nexY - $tab_top; |
|
387 | 387 | |
388 | 388 | // Rect prend une longueur en 3eme param |
389 | - $pdf->SetDrawColor(192,192,192); |
|
390 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
389 | + $pdf->SetDrawColor(192, 192, 192); |
|
390 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); |
|
391 | 391 | |
392 | - $tab_top = $nexY+6; |
|
392 | + $tab_top = $nexY + 6; |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Affiche notes |
397 | - if (! empty($object->note_public)) |
|
397 | + if (!empty($object->note_public)) |
|
398 | 398 | { |
399 | 399 | $tab_top -= 2; |
400 | 400 | |
401 | - $pdf->SetFont('','', $default_font_size - 1); |
|
402 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
401 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
402 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
403 | 403 | $nexY = $pdf->GetY(); |
404 | - $height_note=$nexY-$tab_top; |
|
404 | + $height_note = $nexY - $tab_top; |
|
405 | 405 | |
406 | 406 | // Rect prend une longueur en 3eme param |
407 | - $pdf->SetDrawColor(192,192,192); |
|
408 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
407 | + $pdf->SetDrawColor(192, 192, 192); |
|
408 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
409 | 409 | |
410 | - $tab_top = $nexY+6; |
|
410 | + $tab_top = $nexY + 6; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | $iniY = $tab_top + 7; |
@@ -415,81 +415,81 @@ discard block |
||
415 | 415 | $nexY = $tab_top + 7; |
416 | 416 | |
417 | 417 | // Loop on each lines |
418 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
418 | + for ($i = 0; $i < $nblignes; $i++) |
|
419 | 419 | { |
420 | 420 | $curY = $nexY; |
421 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
422 | - $pdf->SetTextColor(0,0,0); |
|
421 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
422 | + $pdf->SetTextColor(0, 0, 0); |
|
423 | 423 | |
424 | 424 | // Define size of image if we need it |
425 | - $imglinesize=array(); |
|
426 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
425 | + $imglinesize = array(); |
|
426 | + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); |
|
427 | 427 | |
428 | 428 | $pdf->setTopMargin($tab_top_newpage); |
429 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
430 | - $pageposbefore=$pdf->getPage(); |
|
429 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
430 | + $pageposbefore = $pdf->getPage(); |
|
431 | 431 | |
432 | - $showpricebeforepagebreak=1; |
|
433 | - $posYAfterImage=0; |
|
434 | - $posYAfterDescription=0; |
|
432 | + $showpricebeforepagebreak = 1; |
|
433 | + $posYAfterImage = 0; |
|
434 | + $posYAfterDescription = 0; |
|
435 | 435 | |
436 | 436 | // We start with Photo of product line |
437 | - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
437 | + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page |
|
438 | 438 | { |
439 | - $pdf->AddPage('','',true); |
|
440 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
439 | + $pdf->AddPage('', '', true); |
|
440 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
441 | 441 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
442 | - $pdf->setPage($pageposbefore+1); |
|
442 | + $pdf->setPage($pageposbefore + 1); |
|
443 | 443 | |
444 | 444 | $curY = $tab_top_newpage; |
445 | - $showpricebeforepagebreak=0; |
|
445 | + $showpricebeforepagebreak = 0; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) |
449 | 449 | { |
450 | - $curX = $this->posxpicture-1; |
|
451 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
450 | + $curX = $this->posxpicture - 1; |
|
451 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
452 | 452 | // $pdf->Image does not increase value return by getY, so we save it manually |
453 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
453 | + $posYAfterImage = $curY + $imglinesize['height']; |
|
454 | 454 | } |
455 | 455 | // Description of product line |
456 | - $curX = $this->posxdesc-1; |
|
457 | - $showpricebeforepagebreak=1; |
|
456 | + $curX = $this->posxdesc - 1; |
|
457 | + $showpricebeforepagebreak = 1; |
|
458 | 458 | |
459 | 459 | $pdf->startTransaction(); |
460 | 460 | if ($posYAfterImage > 0) |
461 | 461 | { |
462 | - $descWidth = $this->posxpicture-$curX; |
|
462 | + $descWidth = $this->posxpicture - $curX; |
|
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - $descWidth = $this->posxtva-$curX; |
|
466 | + $descWidth = $this->posxtva - $curX; |
|
467 | 467 | } |
468 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
468 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); |
|
469 | 469 | |
470 | - $pageposafter=$pdf->getPage(); |
|
470 | + $pageposafter = $pdf->getPage(); |
|
471 | 471 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
472 | 472 | { |
473 | 473 | $pdf->rollbackTransaction(true); |
474 | - $pageposafter=$pageposbefore; |
|
474 | + $pageposafter = $pageposbefore; |
|
475 | 475 | //print $pageposafter.'-'.$pageposbefore;exit; |
476 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
477 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
478 | - $posyafter=$pdf->GetY(); |
|
479 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
476 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
477 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); |
|
478 | + $posyafter = $pdf->GetY(); |
|
479 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
480 | 480 | { |
481 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
481 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
482 | 482 | { |
483 | - $pdf->AddPage('','',true); |
|
484 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
483 | + $pdf->AddPage('', '', true); |
|
484 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | 485 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
486 | - $pdf->setPage($pageposafter+1); |
|
486 | + $pdf->setPage($pageposafter + 1); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | else |
490 | 490 | { |
491 | 491 | // We found a page break |
492 | - $showpricebeforepagebreak=0; |
|
492 | + $showpricebeforepagebreak = 0; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | else // No pagebreak |
@@ -498,50 +498,50 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | $nexY = $pdf->GetY(); |
501 | - $pageposafter=$pdf->getPage(); |
|
501 | + $pageposafter = $pdf->getPage(); |
|
502 | 502 | $pdf->setPage($pageposbefore); |
503 | 503 | $pdf->setTopMargin($this->marge_haute); |
504 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
504 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
505 | 505 | |
506 | 506 | // We suppose that a too long description is moved completely on next page |
507 | 507 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
508 | 508 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
509 | 509 | } |
510 | 510 | |
511 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
511 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
512 | 512 | |
513 | 513 | // VAT Rate |
514 | 514 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
515 | 515 | { |
516 | 516 | $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
517 | 517 | $pdf->SetXY($this->posxtva, $curY); |
518 | - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
518 | + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | // Unit price before discount |
522 | 522 | $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
523 | 523 | $pdf->SetXY($this->posxup, $curY); |
524 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
524 | + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
525 | 525 | |
526 | 526 | // Quantity |
527 | 527 | $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
528 | 528 | $pdf->SetXY($this->posxqty, $curY); |
529 | 529 | // Enough for 6 chars |
530 | - if($conf->global->PRODUCT_USE_UNITS) |
|
530 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
531 | 531 | { |
532 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
532 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); |
|
533 | 533 | } |
534 | 534 | else |
535 | 535 | { |
536 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
536 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R'); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | // Unit |
540 | - if($conf->global->PRODUCT_USE_UNITS) |
|
540 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
541 | 541 | { |
542 | 542 | $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
543 | 543 | $pdf->SetXY($this->posxunit, $curY); |
544 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
544 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | // Discount on line |
@@ -549,63 +549,63 @@ discard block |
||
549 | 549 | if ($object->lines[$i]->remise_percent) |
550 | 550 | { |
551 | 551 | $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
552 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); |
|
552 | + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R'); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Total HT line |
556 | 556 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); |
557 | 557 | $pdf->SetXY($this->postotalht, $curY); |
558 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
558 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
559 | 559 | |
560 | 560 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
561 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
562 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
561 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; |
|
562 | + else $tvaligne = $object->lines[$i]->total_tva; |
|
563 | 563 | |
564 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
565 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
566 | - $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
567 | - $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
568 | - $localtax1_type=$object->lines[$i]->localtax1_type; |
|
569 | - $localtax2_type=$object->lines[$i]->localtax2_type; |
|
564 | + $localtax1ligne = $object->lines[$i]->total_localtax1; |
|
565 | + $localtax2ligne = $object->lines[$i]->total_localtax2; |
|
566 | + $localtax1_rate = $object->lines[$i]->localtax1_tx; |
|
567 | + $localtax2_rate = $object->lines[$i]->localtax2_tx; |
|
568 | + $localtax1_type = $object->lines[$i]->localtax1_type; |
|
569 | + $localtax2_type = $object->lines[$i]->localtax2_type; |
|
570 | 570 | |
571 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
572 | - if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
573 | - if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
571 | + if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; |
|
572 | + if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; |
|
573 | + if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; |
|
574 | 574 | |
575 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
575 | + $vatrate = (string) $object->lines[$i]->tva_tx; |
|
576 | 576 | |
577 | 577 | // Retrieve type from database for backward compatibility with old records |
578 | - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
579 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
578 | + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined |
|
579 | + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax |
|
580 | 580 | { |
581 | - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty); |
|
581 | + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); |
|
582 | 582 | $localtax1_type = $localtaxtmp_array[0]; |
583 | 583 | $localtax2_type = $localtaxtmp_array[2]; |
584 | 584 | } |
585 | 585 | |
586 | 586 | // retrieve global local tax |
587 | 587 | if ($localtax1_type && $localtax1ligne != 0) |
588 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
588 | + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; |
|
589 | 589 | if ($localtax2_type && $localtax2ligne != 0) |
590 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
590 | + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; |
|
591 | 591 | |
592 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
593 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
592 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; |
|
593 | + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; |
|
594 | 594 | $this->tva[$vatrate] += $tvaligne; |
595 | 595 | |
596 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
596 | + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; |
|
597 | 597 | |
598 | 598 | // Add line |
599 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
599 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
600 | 600 | { |
601 | 601 | $pdf->setPage($pageposafter); |
602 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
602 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
603 | 603 | //$pdf->SetDrawColor(190,190,200); |
604 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
604 | + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); |
|
605 | 605 | $pdf->SetLineStyle(array('dash'=>0)); |
606 | 606 | } |
607 | 607 | |
608 | - $nexY+=2; // Passe espace entre les lignes |
|
608 | + $nexY += 2; // Passe espace entre les lignes |
|
609 | 609 | |
610 | 610 | // Detect if some page were added automatically and output _tableau for past pages |
611 | 611 | while ($pagenb < $pageposafter) |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | { |
620 | 620 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
621 | 621 | } |
622 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
622 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
623 | 623 | $pagenb++; |
624 | 624 | $pdf->setPage($pagenb); |
625 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
625 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
626 | 626 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
627 | 627 | } |
628 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
628 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
629 | 629 | { |
630 | 630 | if ($pagenb == 1) |
631 | 631 | { |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | { |
636 | 636 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
637 | 637 | } |
638 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
638 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
639 | 639 | // New page |
640 | 640 | $pdf->AddPage(); |
641 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
641 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
642 | 642 | $pagenb++; |
643 | 643 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
644 | 644 | } |
@@ -648,56 +648,56 @@ discard block |
||
648 | 648 | if ($pagenb == 1) |
649 | 649 | { |
650 | 650 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
651 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
651 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
652 | 652 | } |
653 | 653 | else |
654 | 654 | { |
655 | 655 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
656 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
656 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Affiche zone infos |
660 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
660 | + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
661 | 661 | |
662 | 662 | // Affiche zone totaux |
663 | - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
663 | + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
664 | 664 | |
665 | 665 | // Affiche zone versements |
666 | 666 | if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
667 | 667 | { |
668 | - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
668 | + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | // Pied de page |
672 | 672 | $this->_pagefoot($pdf, $object, $outputlangs); |
673 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
673 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
674 | 674 | |
675 | 675 | $pdf->Close(); |
676 | 676 | |
677 | - $pdf->Output($file,'F'); |
|
677 | + $pdf->Output($file, 'F'); |
|
678 | 678 | |
679 | 679 | // Add pdfgeneration hook |
680 | 680 | $hookmanager->initHooks(array('pdfgeneration')); |
681 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
681 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
682 | 682 | global $action; |
683 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
683 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
684 | 684 | |
685 | - if (! empty($conf->global->MAIN_UMASK)) |
|
685 | + if (!empty($conf->global->MAIN_UMASK)) |
|
686 | 686 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
687 | 687 | |
688 | 688 | $this->result = array('fullpath'=>$file); |
689 | 689 | |
690 | - return 1; // Pas d'erreur |
|
690 | + return 1; // Pas d'erreur |
|
691 | 691 | } |
692 | 692 | else |
693 | 693 | { |
694 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
694 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
695 | 695 | return 0; |
696 | 696 | } |
697 | 697 | } |
698 | 698 | else |
699 | 699 | { |
700 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
700 | + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); |
|
701 | 701 | return 0; |
702 | 702 | } |
703 | 703 | } |
@@ -738,46 +738,46 @@ discard block |
||
738 | 738 | // If France, show VAT mention if not applicable |
739 | 739 | if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
740 | 740 | { |
741 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
741 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
742 | 742 | $pdf->SetXY($this->marge_gauche, $posy); |
743 | 743 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
744 | 744 | |
745 | - $posy=$pdf->GetY()+4; |
|
745 | + $posy = $pdf->GetY() + 4; |
|
746 | 746 | } |
747 | 747 | |
748 | - $posxval=52; |
|
748 | + $posxval = 52; |
|
749 | 749 | |
750 | 750 | // Show payments conditions |
751 | 751 | if (!empty($object->cond_reglement_code) || $object->cond_reglement) |
752 | 752 | { |
753 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
753 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
754 | 754 | $pdf->SetXY($this->marge_gauche, $posy); |
755 | 755 | $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
756 | 756 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
757 | 757 | |
758 | - $pdf->SetFont('','', $default_font_size - 2); |
|
758 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
759 | 759 | $pdf->SetXY($posxval, $posy); |
760 | - $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); |
|
761 | - $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
762 | - $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); |
|
760 | + $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); |
|
761 | + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); |
|
762 | + $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); |
|
763 | 763 | |
764 | - $posy=$pdf->GetY()+3; |
|
764 | + $posy = $pdf->GetY() + 3; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | // Show payment mode |
768 | 768 | if (!empty($object->mode_reglement_code)) |
769 | 769 | { |
770 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
770 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
771 | 771 | $pdf->SetXY($this->marge_gauche, $posy); |
772 | 772 | $titre = $outputlangs->transnoentities("PaymentMode").':'; |
773 | 773 | $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
774 | 774 | |
775 | - $pdf->SetFont('','', $default_font_size - 2); |
|
775 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
776 | 776 | $pdf->SetXY($posxval, $posy); |
777 | - $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); |
|
778 | - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
777 | + $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); |
|
778 | + $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); |
|
779 | 779 | |
780 | - $posy=$pdf->GetY()+2; |
|
780 | + $posy = $pdf->GetY() + 2; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | |
@@ -798,39 +798,39 @@ discard block |
||
798 | 798 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
799 | 799 | { |
800 | 800 | // phpcs:enable |
801 | - global $conf,$mysoc; |
|
801 | + global $conf, $mysoc; |
|
802 | 802 | |
803 | 803 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
804 | 804 | |
805 | 805 | $tab2_top = $posy; |
806 | 806 | $tab2_hl = 4; |
807 | - $pdf->SetFont('','', $default_font_size - 1); |
|
807 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
808 | 808 | |
809 | 809 | // Tableau total |
810 | 810 | $col1x = 120; $col2x = 170; |
811 | 811 | if ($this->page_largeur < 210) // To work with US executive format |
812 | 812 | { |
813 | - $col2x-=20; |
|
813 | + $col2x -= 20; |
|
814 | 814 | } |
815 | 815 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
816 | 816 | |
817 | - $useborder=0; |
|
817 | + $useborder = 0; |
|
818 | 818 | $index = 0; |
819 | 819 | |
820 | 820 | // Total HT |
821 | - $pdf->SetFillColor(255,255,255); |
|
821 | + $pdf->SetFillColor(255, 255, 255); |
|
822 | 822 | $pdf->SetXY($col1x, $tab2_top + 0); |
823 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
823 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
824 | 824 | |
825 | 825 | $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
826 | 826 | $pdf->SetXY($col2x, $tab2_top + 0); |
827 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); |
|
827 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); |
|
828 | 828 | |
829 | 829 | // Show VAT by rates and total |
830 | - $pdf->SetFillColor(248,248,248); |
|
830 | + $pdf->SetFillColor(248, 248, 248); |
|
831 | 831 | |
832 | - $this->atleastoneratenotnull=0; |
|
833 | - foreach( $this->tva as $tvakey => $tvaval ) |
|
832 | + $this->atleastoneratenotnull = 0; |
|
833 | + foreach ($this->tva as $tvakey => $tvaval) |
|
834 | 834 | { |
835 | 835 | if ($tvakey > 0) // On affiche pas taux 0 |
836 | 836 | { |
@@ -839,47 +839,47 @@ discard block |
||
839 | 839 | $index++; |
840 | 840 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
841 | 841 | |
842 | - $tvacompl=''; |
|
842 | + $tvacompl = ''; |
|
843 | 843 | |
844 | - if (preg_match('/\*/',$tvakey)) |
|
844 | + if (preg_match('/\*/', $tvakey)) |
|
845 | 845 | { |
846 | - $tvakey=str_replace('*','',$tvakey); |
|
846 | + $tvakey = str_replace('*', '', $tvakey); |
|
847 | 847 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
848 | 848 | } |
849 | 849 | |
850 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
851 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
852 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
850 | + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; |
|
851 | + $totalvat .= vatrate($tvakey, 1).$tvacompl; |
|
852 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
853 | 853 | |
854 | 854 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
855 | 855 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
856 | 856 | } |
857 | 857 | } |
858 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
858 | + if (!$this->atleastoneratenotnull) // If no vat at all |
|
859 | 859 | { |
860 | 860 | $index++; |
861 | 861 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
862 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
862 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
863 | 863 | |
864 | 864 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
865 | 865 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
866 | 866 | |
867 | 867 | // Total LocalTax1 |
868 | - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
868 | + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) |
|
869 | 869 | { |
870 | 870 | $index++; |
871 | 871 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
872 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
872 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); |
|
873 | 873 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
874 | 874 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); |
875 | 875 | } |
876 | 876 | |
877 | 877 | // Total LocalTax2 |
878 | - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
878 | + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) |
|
879 | 879 | { |
880 | 880 | $index++; |
881 | 881 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
882 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
882 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); |
|
883 | 883 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
884 | 884 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); |
885 | 885 | } |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
890 | 890 | //{ |
891 | 891 | //Local tax 1 |
892 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
892 | + foreach ($this->localtax1 as $localtax_type => $localtax_rate) |
|
893 | 893 | { |
894 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
894 | + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; |
|
895 | 895 | |
896 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
896 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
897 | 897 | { |
898 | 898 | if ($tvakey != 0) // On affiche pas taux 0 |
899 | 899 | { |
@@ -902,15 +902,15 @@ discard block |
||
902 | 902 | $index++; |
903 | 903 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
904 | 904 | |
905 | - $tvacompl=''; |
|
906 | - if (preg_match('/\*/',$tvakey)) |
|
905 | + $tvacompl = ''; |
|
906 | + if (preg_match('/\*/', $tvakey)) |
|
907 | 907 | { |
908 | - $tvakey=str_replace('*','',$tvakey); |
|
908 | + $tvakey = str_replace('*', '', $tvakey); |
|
909 | 909 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
910 | 910 | } |
911 | - $totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
912 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
913 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
911 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; |
|
912 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
913 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
914 | 914 | |
915 | 915 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
916 | 916 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -921,11 +921,11 @@ discard block |
||
921 | 921 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
922 | 922 | //{ |
923 | 923 | //Local tax 2 |
924 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
924 | + foreach ($this->localtax2 as $localtax_type => $localtax_rate) |
|
925 | 925 | { |
926 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
926 | + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; |
|
927 | 927 | |
928 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
928 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
929 | 929 | { |
930 | 930 | if ($tvakey != 0) // On affiche pas taux 0 |
931 | 931 | { |
@@ -934,15 +934,15 @@ discard block |
||
934 | 934 | $index++; |
935 | 935 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
936 | 936 | |
937 | - $tvacompl=''; |
|
938 | - if (preg_match('/\*/',$tvakey)) |
|
937 | + $tvacompl = ''; |
|
938 | + if (preg_match('/\*/', $tvakey)) |
|
939 | 939 | { |
940 | - $tvakey=str_replace('*','',$tvakey); |
|
940 | + $tvakey = str_replace('*', '', $tvakey); |
|
941 | 941 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
942 | 942 | } |
943 | - $totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
944 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
945 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
943 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; |
|
944 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
945 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
946 | 946 | |
947 | 947 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
948 | 948 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
@@ -954,23 +954,23 @@ discard block |
||
954 | 954 | // Total TTC |
955 | 955 | $index++; |
956 | 956 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
957 | - $pdf->SetTextColor(0,0,60); |
|
958 | - $pdf->SetFillColor(224,224,224); |
|
959 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
957 | + $pdf->SetTextColor(0, 0, 60); |
|
958 | + $pdf->SetFillColor(224, 224, 224); |
|
959 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
960 | 960 | |
961 | 961 | $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
962 | 962 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
963 | 963 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
964 | - $pdf->SetFont('','', $default_font_size - 1); |
|
965 | - $pdf->SetTextColor(0,0,0); |
|
964 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
965 | + $pdf->SetTextColor(0, 0, 0); |
|
966 | 966 | |
967 | - $creditnoteamount=0; |
|
968 | - $depositsamount=0; |
|
967 | + $creditnoteamount = 0; |
|
968 | + $depositsamount = 0; |
|
969 | 969 | //$creditnoteamount=$object->getSumCreditNotesUsed(); |
970 | 970 | //$depositsamount=$object->getSumDepositsUsed(); |
971 | 971 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
972 | 972 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
973 | - if (! empty($object->paye)) $resteapayer=0; |
|
973 | + if (!empty($object->paye)) $resteapayer = 0; |
|
974 | 974 | |
975 | 975 | if ($deja_regle > 0) |
976 | 976 | { |
@@ -978,21 +978,21 @@ discard block |
||
978 | 978 | $index++; |
979 | 979 | |
980 | 980 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
981 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
981 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
982 | 982 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
983 | 983 | $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
984 | 984 | |
985 | 985 | $index++; |
986 | - $pdf->SetTextColor(0,0,60); |
|
987 | - $pdf->SetFillColor(224,224,224); |
|
986 | + $pdf->SetTextColor(0, 0, 60); |
|
987 | + $pdf->SetFillColor(224, 224, 224); |
|
988 | 988 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
989 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
989 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
990 | 990 | |
991 | 991 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
992 | 992 | $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
993 | 993 | |
994 | - $pdf->SetFont('','', $default_font_size - 1); |
|
995 | - $pdf->SetTextColor(0,0,0); |
|
994 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
995 | + $pdf->SetTextColor(0, 0, 0); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | $index++; |
@@ -1012,43 +1012,43 @@ discard block |
||
1012 | 1012 | * @param string $currency Currency code |
1013 | 1013 | * @return void |
1014 | 1014 | */ |
1015 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1015 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
1016 | 1016 | { |
1017 | 1017 | global $conf; |
1018 | 1018 | |
1019 | 1019 | // Force to disable hidetop and hidebottom |
1020 | - $hidebottom=0; |
|
1021 | - if ($hidetop) $hidetop=-1; |
|
1020 | + $hidebottom = 0; |
|
1021 | + if ($hidetop) $hidetop = -1; |
|
1022 | 1022 | |
1023 | 1023 | $currency = !empty($currency) ? $currency : $conf->currency; |
1024 | 1024 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1025 | 1025 | |
1026 | 1026 | // Amount in (at tab_top - 1) |
1027 | - $pdf->SetTextColor(0,0,0); |
|
1028 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1027 | + $pdf->SetTextColor(0, 0, 0); |
|
1028 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1029 | 1029 | |
1030 | 1030 | if (empty($hidetop)) |
1031 | 1031 | { |
1032 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1033 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1032 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1033 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); |
|
1034 | 1034 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1035 | 1035 | |
1036 | 1036 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1037 | - 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)); |
|
1037 | + 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)); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | - $pdf->SetDrawColor(128,128,128); |
|
1041 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1040 | + $pdf->SetDrawColor(128, 128, 128); |
|
1041 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1042 | 1042 | |
1043 | 1043 | // Output Rect |
1044 | - $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 |
|
1044 | + $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 |
|
1045 | 1045 | |
1046 | 1046 | if (empty($hidetop)) |
1047 | 1047 | { |
1048 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1048 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param |
|
1049 | 1049 | |
1050 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1051 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1050 | + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); |
|
1051 | + $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
@@ -1056,33 +1056,33 @@ discard block |
||
1056 | 1056 | $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); |
1057 | 1057 | if (empty($hidetop)) |
1058 | 1058 | { |
1059 | - $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
1060 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1059 | + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); |
|
1060 | + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height); |
1065 | 1065 | if (empty($hidetop)) |
1066 | 1066 | { |
1067 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1068 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1067 | + $pdf->SetXY($this->posxup - 1, $tab_top + 1); |
|
1068 | + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1071 | + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); |
|
1072 | 1072 | if (empty($hidetop)) |
1073 | 1073 | { |
1074 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1075 | - if($conf->global->PRODUCT_USE_UNITS) |
|
1074 | + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); |
|
1075 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
1076 | 1076 | { |
1077 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1077 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
1078 | 1078 | } |
1079 | 1079 | else |
1080 | 1080 | { |
1081 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1081 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
1085 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
1086 | 1086 | $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
1087 | 1087 | if (empty($hidetop)) { |
1088 | 1088 | $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
@@ -1091,13 +1091,13 @@ discard block |
||
1091 | 1091 | } |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1094 | + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); |
|
1095 | 1095 | if (empty($hidetop)) |
1096 | 1096 | { |
1097 | 1097 | if ($this->atleastonediscount) |
1098 | 1098 | { |
1099 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1100 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1099 | + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); |
|
1100 | + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); |
|
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | |
@@ -1107,8 +1107,8 @@ discard block |
||
1107 | 1107 | } |
1108 | 1108 | if (empty($hidetop)) |
1109 | 1109 | { |
1110 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1111 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
1110 | + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); |
|
1111 | + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); |
|
1112 | 1112 | } |
1113 | 1113 | } |
1114 | 1114 | |
@@ -1140,119 +1140,119 @@ discard block |
||
1140 | 1140 | }*/ |
1141 | 1141 | //Print content |
1142 | 1142 | |
1143 | - $pdf->SetTextColor(0,0,60); |
|
1144 | - $pdf->SetFont('','B',$default_font_size + 3); |
|
1143 | + $pdf->SetTextColor(0, 0, 60); |
|
1144 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1145 | 1145 | |
1146 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1147 | - $posy=$this->marge_haute; |
|
1146 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
1147 | + $posy = $this->marge_haute; |
|
1148 | 1148 | |
1149 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1149 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
1150 | 1150 | |
1151 | 1151 | // Logo |
1152 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1152 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1153 | 1153 | if ($this->emetteur->logo) |
1154 | 1154 | { |
1155 | 1155 | if (is_readable($logo)) |
1156 | 1156 | { |
1157 | - $height=pdf_getHeightForLogo($logo); |
|
1158 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1157 | + $height = pdf_getHeightForLogo($logo); |
|
1158 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1159 | 1159 | } |
1160 | 1160 | else |
1161 | 1161 | { |
1162 | - $pdf->SetTextColor(200,0,0); |
|
1163 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
1164 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1162 | + $pdf->SetTextColor(200, 0, 0); |
|
1163 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
1164 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
1165 | 1165 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
1166 | 1166 | } |
1167 | 1167 | } |
1168 | 1168 | else |
1169 | 1169 | { |
1170 | - $text=$this->emetteur->name; |
|
1170 | + $text = $this->emetteur->name; |
|
1171 | 1171 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | $pdf->SetFont('', 'B', $default_font_size + 3); |
1175 | - $pdf->SetXY($posx,$posy); |
|
1176 | - $pdf->SetTextColor(0,0,60); |
|
1177 | - $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); |
|
1175 | + $pdf->SetXY($posx, $posy); |
|
1176 | + $pdf->SetTextColor(0, 0, 60); |
|
1177 | + $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); |
|
1178 | 1178 | $pdf->MultiCell(100, 3, $title, '', 'R'); |
1179 | - $posy+=1; |
|
1179 | + $posy += 1; |
|
1180 | 1180 | |
1181 | 1181 | if ($object->ref_supplier) |
1182 | 1182 | { |
1183 | - $posy+=4; |
|
1184 | - $pdf->SetFont('','B', $default_font_size); |
|
1185 | - $pdf->SetXY($posx,$posy); |
|
1186 | - $pdf->SetTextColor(0,0,60); |
|
1187 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); |
|
1188 | - $posy+=1; |
|
1183 | + $posy += 4; |
|
1184 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1185 | + $pdf->SetXY($posx, $posy); |
|
1186 | + $pdf->SetTextColor(0, 0, 60); |
|
1187 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); |
|
1188 | + $posy += 1; |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | - $pdf->SetFont('','', $default_font_size -1); |
|
1191 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1192 | 1192 | |
1193 | - if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1193 | + if (!empty($conf->global->PDF_SHOW_PROJECT)) |
|
1194 | 1194 | { |
1195 | 1195 | $object->fetch_projet(); |
1196 | - if (! empty($object->project->ref)) |
|
1196 | + if (!empty($object->project->ref)) |
|
1197 | 1197 | { |
1198 | - $posy+=4; |
|
1199 | - $pdf->SetXY($posx,$posy); |
|
1198 | + $posy += 4; |
|
1199 | + $pdf->SetXY($posx, $posy); |
|
1200 | 1200 | $langs->load("projects"); |
1201 | - $pdf->SetTextColor(0,0,60); |
|
1202 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1201 | + $pdf->SetTextColor(0, 0, 60); |
|
1202 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); |
|
1203 | 1203 | } |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - if (! empty($object->date_commande)) |
|
1206 | + if (!empty($object->date_commande)) |
|
1207 | 1207 | { |
1208 | - $posy+=5; |
|
1209 | - $pdf->SetXY($posx,$posy); |
|
1210 | - $pdf->SetTextColor(0,0,60); |
|
1211 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R'); |
|
1208 | + $posy += 5; |
|
1209 | + $pdf->SetXY($posx, $posy); |
|
1210 | + $pdf->SetTextColor(0, 0, 60); |
|
1211 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); |
|
1212 | 1212 | } |
1213 | 1213 | else |
1214 | 1214 | { |
1215 | - $posy+=5; |
|
1216 | - $pdf->SetXY($posx,$posy); |
|
1217 | - $pdf->SetTextColor(255,0,0); |
|
1215 | + $posy += 5; |
|
1216 | + $pdf->SetXY($posx, $posy); |
|
1217 | + $pdf->SetTextColor(255, 0, 0); |
|
1218 | 1218 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - $pdf->SetTextColor(0,0,60); |
|
1222 | - $usehourmin='day'; |
|
1223 | - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; |
|
1224 | - if (! empty($object->date_livraison)) |
|
1221 | + $pdf->SetTextColor(0, 0, 60); |
|
1222 | + $usehourmin = 'day'; |
|
1223 | + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; |
|
1224 | + if (!empty($object->date_livraison)) |
|
1225 | 1225 | { |
1226 | - $posy+=4; |
|
1227 | - $pdf->SetXY($posx-90,$posy); |
|
1228 | - $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R'); |
|
1226 | + $posy += 4; |
|
1227 | + $pdf->SetXY($posx - 90, $posy); |
|
1228 | + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | if ($object->thirdparty->code_fournisseur) |
1232 | 1232 | { |
1233 | - $posy+=4; |
|
1234 | - $pdf->SetXY($posx,$posy); |
|
1235 | - $pdf->SetTextColor(0,0,60); |
|
1236 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1233 | + $posy += 4; |
|
1234 | + $pdf->SetXY($posx, $posy); |
|
1235 | + $pdf->SetTextColor(0, 0, 60); |
|
1236 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | // Get contact |
1240 | 1240 | if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
1241 | 1241 | { |
1242 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1242 | + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); |
|
1243 | 1243 | if (count($arrayidcontact) > 0) |
1244 | 1244 | { |
1245 | - $usertmp=new User($this->db); |
|
1245 | + $usertmp = new User($this->db); |
|
1246 | 1246 | $usertmp->fetch($arrayidcontact[0]); |
1247 | - $posy+=4; |
|
1248 | - $pdf->SetXY($posx,$posy); |
|
1249 | - $pdf->SetTextColor(0,0,60); |
|
1247 | + $posy += 4; |
|
1248 | + $pdf->SetXY($posx, $posy); |
|
1249 | + $pdf->SetTextColor(0, 0, 60); |
|
1250 | 1250 | $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - $posy+=1; |
|
1255 | - $pdf->SetTextColor(0,0,60); |
|
1254 | + $posy += 1; |
|
1255 | + $pdf->SetTextColor(0, 0, 60); |
|
1256 | 1256 | |
1257 | 1257 | $top_shift = 0; |
1258 | 1258 | // Show list of linked objects |
@@ -1266,53 +1266,53 @@ discard block |
||
1266 | 1266 | if ($showaddress) |
1267 | 1267 | { |
1268 | 1268 | // Sender properties |
1269 | - $carac_emetteur=''; |
|
1269 | + $carac_emetteur = ''; |
|
1270 | 1270 | // Add internal contact of proposal if defined |
1271 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1271 | + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); |
|
1272 | 1272 | if (count($arrayidcontact) > 0) |
1273 | 1273 | { |
1274 | 1274 | $object->fetch_user($arrayidcontact[0]); |
1275 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1275 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
1279 | 1279 | |
1280 | 1280 | // Show sender |
1281 | - $posy=42+$top_shift; |
|
1282 | - $posx=$this->marge_gauche; |
|
1283 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1284 | - $hautcadre=40; |
|
1281 | + $posy = 42 + $top_shift; |
|
1282 | + $posx = $this->marge_gauche; |
|
1283 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
1284 | + $hautcadre = 40; |
|
1285 | 1285 | |
1286 | 1286 | // Show sender frame |
1287 | - $pdf->SetTextColor(0,0,0); |
|
1288 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1289 | - $pdf->SetXY($posx,$posy-5); |
|
1290 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1291 | - $pdf->SetXY($posx,$posy); |
|
1292 | - $pdf->SetFillColor(230,230,230); |
|
1287 | + $pdf->SetTextColor(0, 0, 0); |
|
1288 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1289 | + $pdf->SetXY($posx, $posy - 5); |
|
1290 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1291 | + $pdf->SetXY($posx, $posy); |
|
1292 | + $pdf->SetFillColor(230, 230, 230); |
|
1293 | 1293 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
1294 | - $pdf->SetTextColor(0,0,60); |
|
1294 | + $pdf->SetTextColor(0, 0, 60); |
|
1295 | 1295 | |
1296 | 1296 | // Show sender name |
1297 | - $pdf->SetXY($posx+2,$posy+3); |
|
1298 | - $pdf->SetFont('','B', $default_font_size); |
|
1297 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1298 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1299 | 1299 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
1300 | - $posy=$pdf->getY(); |
|
1300 | + $posy = $pdf->getY(); |
|
1301 | 1301 | |
1302 | 1302 | // Show sender information |
1303 | - $pdf->SetXY($posx+2,$posy); |
|
1304 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1303 | + $pdf->SetXY($posx + 2, $posy); |
|
1304 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1305 | 1305 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
1306 | 1306 | |
1307 | 1307 | |
1308 | 1308 | |
1309 | 1309 | // If BILLING contact defined on order, we use it |
1310 | - $usecontact=false; |
|
1311 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
1310 | + $usecontact = false; |
|
1311 | + $arrayidcontact = $object->getIdContact('external', 'BILLING'); |
|
1312 | 1312 | if (count($arrayidcontact) > 0) |
1313 | 1313 | { |
1314 | - $usecontact=true; |
|
1315 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1314 | + $usecontact = true; |
|
1315 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | //Recipient name |
@@ -1323,34 +1323,34 @@ discard block |
||
1323 | 1323 | $thirdparty = $object->thirdparty; |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1326 | + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1327 | 1327 | |
1328 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); |
|
1328 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); |
|
1329 | 1329 | |
1330 | 1330 | // Show recipient |
1331 | - $widthrecbox=100; |
|
1332 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1333 | - $posy=42+$top_shift; |
|
1334 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1335 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1331 | + $widthrecbox = 100; |
|
1332 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
1333 | + $posy = 42 + $top_shift; |
|
1334 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1335 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
1336 | 1336 | |
1337 | 1337 | // Show recipient frame |
1338 | - $pdf->SetTextColor(0,0,0); |
|
1339 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1340 | - $pdf->SetXY($posx+2,$posy-5); |
|
1341 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1338 | + $pdf->SetTextColor(0, 0, 0); |
|
1339 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1340 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
1341 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); |
|
1342 | 1342 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
1343 | 1343 | |
1344 | 1344 | // Show recipient name |
1345 | - $pdf->SetXY($posx+2,$posy+3); |
|
1346 | - $pdf->SetFont('','B', $default_font_size); |
|
1345 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1346 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1347 | 1347 | $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
1348 | 1348 | |
1349 | 1349 | $posy = $pdf->getY(); |
1350 | 1350 | |
1351 | 1351 | // Show recipient information |
1352 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1353 | - $pdf->SetXY($posx+2,$posy); |
|
1352 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1353 | + $pdf->SetXY($posx + 2, $posy); |
|
1354 | 1354 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
1355 | 1355 | } |
1356 | 1356 | |
@@ -1366,10 +1366,10 @@ discard block |
||
1366 | 1366 | * @param int $hidefreetext 1=Hide free text |
1367 | 1367 | * @return int Return height of bottom margin including footer text |
1368 | 1368 | */ |
1369 | - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0) |
|
1369 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1370 | 1370 | { |
1371 | 1371 | global $conf; |
1372 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1373 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1372 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1373 | + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1374 | 1374 | } |
1375 | 1375 | } |
@@ -157,7 +157,10 @@ discard block |
||
157 | 157 | |
158 | 158 | // Get source company |
159 | 159 | $this->emetteur=$mysoc; |
160 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
160 | + if (empty($this->emetteur->country_code)) { |
|
161 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
162 | + } |
|
163 | + // By default, if was not defined |
|
161 | 164 | |
162 | 165 | // Defini position des colonnes |
163 | 166 | $this->posxdesc=$this->marge_gauche+1; |
@@ -176,11 +179,16 @@ discard block |
||
176 | 179 | $this->posxqty=145; |
177 | 180 | } |
178 | 181 | |
179 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference |
|
182 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
183 | + $this->posxup = $this->posxtva; |
|
184 | + } |
|
185 | + // posxtva is picture position reference |
|
180 | 186 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
181 | - if ($this->page_largeur < 210) // To work with US executive format |
|
187 | + if ($this->page_largeur < 210) { |
|
188 | + // To work with US executive format |
|
182 | 189 | { |
183 | 190 | $this->posxpicture-=20; |
191 | + } |
|
184 | 192 | $this->posxtva-=20; |
185 | 193 | $this->posxup-=20; |
186 | 194 | $this->posxqty-=20; |
@@ -214,9 +222,13 @@ discard block |
||
214 | 222 | // phpcs:enable |
215 | 223 | global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; |
216 | 224 | |
217 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
225 | + if (! is_object($outputlangs)) { |
|
226 | + $outputlangs=$langs; |
|
227 | + } |
|
218 | 228 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
219 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
229 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
230 | + $outputlangs->charset_output='ISO-8859-1'; |
|
231 | + } |
|
220 | 232 | |
221 | 233 | // Load translation files required by the page |
222 | 234 | $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); |
@@ -229,7 +241,9 @@ discard block |
||
229 | 241 | { |
230 | 242 | for ($i = 0 ; $i < $nblignes ; $i++) |
231 | 243 | { |
232 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
244 | + if (empty($object->lines[$i]->fk_product)) { |
|
245 | + continue; |
|
246 | + } |
|
233 | 247 | |
234 | 248 | $objphoto = new Product($this->db); |
235 | 249 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -238,8 +252,7 @@ discard block |
||
238 | 252 | { |
239 | 253 | $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
240 | 254 | $dir = $conf->product->dir_output.'/'.$pdir; |
241 | - } |
|
242 | - else |
|
255 | + } else |
|
243 | 256 | { |
244 | 257 | $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; |
245 | 258 | $dir = $conf->product->dir_output.'/'.$pdir; |
@@ -254,10 +267,14 @@ discard block |
||
254 | 267 | break; |
255 | 268 | } |
256 | 269 | |
257 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
270 | + if ($realpath) { |
|
271 | + $realpatharray[$i]=$realpath; |
|
272 | + } |
|
258 | 273 | } |
259 | 274 | } |
260 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
275 | + if (count($realpatharray) == 0) { |
|
276 | + $this->posxpicture=$this->posxtva; |
|
277 | + } |
|
261 | 278 | |
262 | 279 | if ($conf->fournisseur->commande->dir_output) |
263 | 280 | { |
@@ -274,14 +291,15 @@ discard block |
||
274 | 291 | { |
275 | 292 | $dir = $conf->fournisseur->commande->dir_output; |
276 | 293 | $file = $dir . "/SPECIMEN.pdf"; |
277 | - } |
|
278 | - else |
|
294 | + } else |
|
279 | 295 | { |
280 | 296 | $objectref = dol_sanitizeFileName($object->ref); |
281 | 297 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
282 | 298 | $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; |
283 | 299 | $file = $dir . "/" . $objectref . ".pdf"; |
284 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
300 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) { |
|
301 | + $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
302 | + } |
|
285 | 303 | } |
286 | 304 | |
287 | 305 | if (! file_exists($dir)) |
@@ -313,7 +331,9 @@ discard block |
||
313 | 331 | $heightforinfotot = 50; // Height reserved to output the info and total part |
314 | 332 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
315 | 333 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
316 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
334 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
335 | + $heightforfooter+= 6; |
|
336 | + } |
|
317 | 337 | $pdf->SetAutoPageBreak(1,0); |
318 | 338 | |
319 | 339 | if (class_exists('TCPDF')) |
@@ -338,7 +358,9 @@ discard block |
||
338 | 358 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
339 | 359 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
340 | 360 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
341 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
361 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
362 | + $pdf->SetCompression(false); |
|
363 | + } |
|
342 | 364 | |
343 | 365 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
344 | 366 | |
@@ -362,7 +384,9 @@ discard block |
||
362 | 384 | |
363 | 385 | // New page |
364 | 386 | $pdf->AddPage(); |
365 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
387 | + if (! empty($tplidx)) { |
|
388 | + $pdf->useTemplate($tplidx); |
|
389 | + } |
|
366 | 390 | $pagenb++; |
367 | 391 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
368 | 392 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -423,7 +447,9 @@ discard block |
||
423 | 447 | |
424 | 448 | // Define size of image if we need it |
425 | 449 | $imglinesize=array(); |
426 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
450 | + if (! empty($realpatharray[$i])) { |
|
451 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
452 | + } |
|
427 | 453 | |
428 | 454 | $pdf->setTopMargin($tab_top_newpage); |
429 | 455 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -434,11 +460,17 @@ discard block |
||
434 | 460 | $posYAfterDescription=0; |
435 | 461 | |
436 | 462 | // We start with Photo of product line |
437 | - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
463 | + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
464 | + // If photo too high, we moved completely on new page |
|
438 | 465 | { |
439 | 466 | $pdf->AddPage('','',true); |
440 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
441 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
467 | + } |
|
468 | + if (! empty($tplidx)) { |
|
469 | + $pdf->useTemplate($tplidx); |
|
470 | + } |
|
471 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
472 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
473 | + } |
|
442 | 474 | $pdf->setPage($pageposbefore+1); |
443 | 475 | |
444 | 476 | $curY = $tab_top_newpage; |
@@ -460,39 +492,44 @@ discard block |
||
460 | 492 | if ($posYAfterImage > 0) |
461 | 493 | { |
462 | 494 | $descWidth = $this->posxpicture-$curX; |
463 | - } |
|
464 | - else |
|
495 | + } else |
|
465 | 496 | { |
466 | 497 | $descWidth = $this->posxtva-$curX; |
467 | 498 | } |
468 | 499 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
469 | 500 | |
470 | 501 | $pageposafter=$pdf->getPage(); |
471 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
502 | + if ($pageposafter > $pageposbefore) { |
|
503 | + // There is a pagebreak |
|
472 | 504 | { |
473 | 505 | $pdf->rollbackTransaction(true); |
506 | + } |
|
474 | 507 | $pageposafter=$pageposbefore; |
475 | 508 | //print $pageposafter.'-'.$pageposbefore;exit; |
476 | 509 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
477 | 510 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
478 | 511 | $posyafter=$pdf->GetY(); |
479 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
512 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
513 | + // There is no space left for total+free text |
|
480 | 514 | { |
481 | 515 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
482 | 516 | { |
483 | 517 | $pdf->AddPage('','',true); |
484 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
518 | + } |
|
519 | + if (! empty($tplidx)) { |
|
520 | + $pdf->useTemplate($tplidx); |
|
521 | + } |
|
522 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
523 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
524 | + } |
|
486 | 525 | $pdf->setPage($pageposafter+1); |
487 | 526 | } |
488 | - } |
|
489 | - else |
|
527 | + } else |
|
490 | 528 | { |
491 | 529 | // We found a page break |
492 | 530 | $showpricebeforepagebreak=0; |
493 | 531 | } |
494 | - } |
|
495 | - else // No pagebreak |
|
532 | + } else // No pagebreak |
|
496 | 533 | { |
497 | 534 | $pdf->commitTransaction(); |
498 | 535 | } |
@@ -530,8 +567,7 @@ discard block |
||
530 | 567 | if($conf->global->PRODUCT_USE_UNITS) |
531 | 568 | { |
532 | 569 | $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
533 | - } |
|
534 | - else |
|
570 | + } else |
|
535 | 571 | { |
536 | 572 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
537 | 573 | } |
@@ -558,8 +594,11 @@ discard block |
||
558 | 594 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
559 | 595 | |
560 | 596 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
561 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
562 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
597 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { |
|
598 | + $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
599 | + } else { |
|
600 | + $tvaligne=$object->lines[$i]->total_tva; |
|
601 | + } |
|
563 | 602 | |
564 | 603 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
565 | 604 | $localtax2ligne=$object->lines[$i]->total_localtax2; |
@@ -568,32 +607,48 @@ discard block |
||
568 | 607 | $localtax1_type=$object->lines[$i]->localtax1_type; |
569 | 608 | $localtax2_type=$object->lines[$i]->localtax2_type; |
570 | 609 | |
571 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
572 | - if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
573 | - if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
610 | + if (! empty($object->remise_percent)) { |
|
611 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
612 | + } |
|
613 | + if (! empty($object->remise_percent)) { |
|
614 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
615 | + } |
|
616 | + if (! empty($object->remise_percent)) { |
|
617 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
618 | + } |
|
574 | 619 | |
575 | 620 | $vatrate=(string) $object->lines[$i]->tva_tx; |
576 | 621 | |
577 | 622 | // Retrieve type from database for backward compatibility with old records |
578 | 623 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
579 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
624 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
625 | + // and there is local tax |
|
580 | 626 | { |
581 | 627 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty); |
628 | + } |
|
582 | 629 | $localtax1_type = $localtaxtmp_array[0]; |
583 | 630 | $localtax2_type = $localtaxtmp_array[2]; |
584 | 631 | } |
585 | 632 | |
586 | 633 | // retrieve global local tax |
587 | - if ($localtax1_type && $localtax1ligne != 0) |
|
588 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
589 | - if ($localtax2_type && $localtax2ligne != 0) |
|
590 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
634 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
635 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
636 | + } |
|
637 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
638 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
639 | + } |
|
591 | 640 | |
592 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
593 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
641 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
642 | + $vatrate.='*'; |
|
643 | + } |
|
644 | + if (! isset($this->tva[$vatrate])) { |
|
645 | + $this->tva[$vatrate]=0; |
|
646 | + } |
|
594 | 647 | $this->tva[$vatrate] += $tvaligne; |
595 | 648 | |
596 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
649 | + if ($posYAfterImage > $posYAfterDescription) { |
|
650 | + $nexY=$posYAfterImage; |
|
651 | + } |
|
597 | 652 | |
598 | 653 | // Add line |
599 | 654 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -614,8 +669,7 @@ discard block |
||
614 | 669 | if ($pagenb == 1) |
615 | 670 | { |
616 | 671 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
617 | - } |
|
618 | - else |
|
672 | + } else |
|
619 | 673 | { |
620 | 674 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
621 | 675 | } |
@@ -623,24 +677,29 @@ discard block |
||
623 | 677 | $pagenb++; |
624 | 678 | $pdf->setPage($pagenb); |
625 | 679 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
626 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
680 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
681 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
682 | + } |
|
627 | 683 | } |
628 | 684 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
629 | 685 | { |
630 | 686 | if ($pagenb == 1) |
631 | 687 | { |
632 | 688 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
633 | - } |
|
634 | - else |
|
689 | + } else |
|
635 | 690 | { |
636 | 691 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
637 | 692 | } |
638 | 693 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
639 | 694 | // New page |
640 | 695 | $pdf->AddPage(); |
641 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
696 | + if (! empty($tplidx)) { |
|
697 | + $pdf->useTemplate($tplidx); |
|
698 | + } |
|
642 | 699 | $pagenb++; |
643 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
700 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
701 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
702 | + } |
|
644 | 703 | } |
645 | 704 | } |
646 | 705 | |
@@ -649,8 +708,7 @@ discard block |
||
649 | 708 | { |
650 | 709 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
651 | 710 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
652 | - } |
|
653 | - else |
|
711 | + } else |
|
654 | 712 | { |
655 | 713 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
656 | 714 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -670,7 +728,9 @@ discard block |
||
670 | 728 | |
671 | 729 | // Pied de page |
672 | 730 | $this->_pagefoot($pdf, $object, $outputlangs); |
673 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
731 | + if (method_exists($pdf,'AliasNbPages')) { |
|
732 | + $pdf->AliasNbPages(); |
|
733 | + } |
|
674 | 734 | |
675 | 735 | $pdf->Close(); |
676 | 736 | |
@@ -682,20 +742,19 @@ discard block |
||
682 | 742 | global $action; |
683 | 743 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
684 | 744 | |
685 | - if (! empty($conf->global->MAIN_UMASK)) |
|
686 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
745 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
746 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
747 | + } |
|
687 | 748 | |
688 | 749 | $this->result = array('fullpath'=>$file); |
689 | 750 | |
690 | 751 | return 1; // Pas d'erreur |
691 | - } |
|
692 | - else |
|
752 | + } else |
|
693 | 753 | { |
694 | 754 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
695 | 755 | return 0; |
696 | 756 | } |
697 | - } |
|
698 | - else |
|
757 | + } else |
|
699 | 758 | { |
700 | 759 | $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
701 | 760 | return 0; |
@@ -808,10 +867,12 @@ discard block |
||
808 | 867 | |
809 | 868 | // Tableau total |
810 | 869 | $col1x = 120; $col2x = 170; |
811 | - if ($this->page_largeur < 210) // To work with US executive format |
|
870 | + if ($this->page_largeur < 210) { |
|
871 | + // To work with US executive format |
|
812 | 872 | { |
813 | 873 | $col2x-=20; |
814 | 874 | } |
875 | + } |
|
815 | 876 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
816 | 877 | |
817 | 878 | $useborder=0; |
@@ -832,9 +893,11 @@ discard block |
||
832 | 893 | $this->atleastoneratenotnull=0; |
833 | 894 | foreach( $this->tva as $tvakey => $tvaval ) |
834 | 895 | { |
835 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
896 | + if ($tvakey > 0) { |
|
897 | + // On affiche pas taux 0 |
|
836 | 898 | { |
837 | 899 | $this->atleastoneratenotnull++; |
900 | + } |
|
838 | 901 | |
839 | 902 | $index++; |
840 | 903 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -855,9 +918,11 @@ discard block |
||
855 | 918 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
856 | 919 | } |
857 | 920 | } |
858 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
921 | + if (! $this->atleastoneratenotnull) { |
|
922 | + // If no vat at all |
|
859 | 923 | { |
860 | 924 | $index++; |
925 | + } |
|
861 | 926 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
862 | 927 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
863 | 928 | |
@@ -883,23 +948,26 @@ discard block |
||
883 | 948 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
884 | 949 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); |
885 | 950 | } |
886 | - } |
|
887 | - else |
|
951 | + } else |
|
888 | 952 | { |
889 | 953 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
890 | 954 | //{ |
891 | 955 | //Local tax 1 |
892 | 956 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
893 | 957 | { |
894 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
958 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
959 | + continue; |
|
960 | + } |
|
895 | 961 | |
896 | 962 | foreach( $localtax_rate as $tvakey => $tvaval ) |
897 | 963 | { |
898 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
964 | + if ($tvakey != 0) { |
|
965 | + // On affiche pas taux 0 |
|
899 | 966 | { |
900 | 967 | //$this->atleastoneratenotnull++; |
901 | 968 | |
902 | 969 | $index++; |
970 | + } |
|
903 | 971 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
904 | 972 | |
905 | 973 | $tvacompl=''; |
@@ -923,15 +991,19 @@ discard block |
||
923 | 991 | //Local tax 2 |
924 | 992 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
925 | 993 | { |
926 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
994 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
995 | + continue; |
|
996 | + } |
|
927 | 997 | |
928 | 998 | foreach( $localtax_rate as $tvakey => $tvaval ) |
929 | 999 | { |
930 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1000 | + if ($tvakey != 0) { |
|
1001 | + // On affiche pas taux 0 |
|
931 | 1002 | { |
932 | 1003 | //$this->atleastoneratenotnull++; |
933 | 1004 | |
934 | 1005 | $index++; |
1006 | + } |
|
935 | 1007 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
936 | 1008 | |
937 | 1009 | $tvacompl=''; |
@@ -970,7 +1042,9 @@ discard block |
||
970 | 1042 | //$depositsamount=$object->getSumDepositsUsed(); |
971 | 1043 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
972 | 1044 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
973 | - if (! empty($object->paye)) $resteapayer=0; |
|
1045 | + if (! empty($object->paye)) { |
|
1046 | + $resteapayer=0; |
|
1047 | + } |
|
974 | 1048 | |
975 | 1049 | if ($deja_regle > 0) |
976 | 1050 | { |
@@ -1018,7 +1092,9 @@ discard block |
||
1018 | 1092 | |
1019 | 1093 | // Force to disable hidetop and hidebottom |
1020 | 1094 | $hidebottom=0; |
1021 | - if ($hidetop) $hidetop=-1; |
|
1095 | + if ($hidetop) { |
|
1096 | + $hidetop=-1; |
|
1097 | + } |
|
1022 | 1098 | |
1023 | 1099 | $currency = !empty($currency) ? $currency : $conf->currency; |
1024 | 1100 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1034,7 +1110,9 @@ discard block |
||
1034 | 1110 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1035 | 1111 | |
1036 | 1112 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1037 | - 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)); |
|
1113 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1114 | + $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)); |
|
1115 | + } |
|
1038 | 1116 | } |
1039 | 1117 | |
1040 | 1118 | $pdf->SetDrawColor(128,128,128); |
@@ -1075,8 +1153,7 @@ discard block |
||
1075 | 1153 | if($conf->global->PRODUCT_USE_UNITS) |
1076 | 1154 | { |
1077 | 1155 | $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1078 | - } |
|
1079 | - else |
|
1156 | + } else |
|
1080 | 1157 | { |
1081 | 1158 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1082 | 1159 | } |
@@ -1156,16 +1233,14 @@ discard block |
||
1156 | 1233 | { |
1157 | 1234 | $height=pdf_getHeightForLogo($logo); |
1158 | 1235 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1159 | - } |
|
1160 | - else |
|
1236 | + } else |
|
1161 | 1237 | { |
1162 | 1238 | $pdf->SetTextColor(200,0,0); |
1163 | 1239 | $pdf->SetFont('','B', $default_font_size - 2); |
1164 | 1240 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1165 | 1241 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
1166 | 1242 | } |
1167 | - } |
|
1168 | - else |
|
1243 | + } else |
|
1169 | 1244 | { |
1170 | 1245 | $text=$this->emetteur->name; |
1171 | 1246 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1209,8 +1284,7 @@ discard block |
||
1209 | 1284 | $pdf->SetXY($posx,$posy); |
1210 | 1285 | $pdf->SetTextColor(0,0,60); |
1211 | 1286 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R'); |
1212 | - } |
|
1213 | - else |
|
1287 | + } else |
|
1214 | 1288 | { |
1215 | 1289 | $posy+=5; |
1216 | 1290 | $pdf->SetXY($posx,$posy); |
@@ -1220,7 +1294,9 @@ discard block |
||
1220 | 1294 | |
1221 | 1295 | $pdf->SetTextColor(0,0,60); |
1222 | 1296 | $usehourmin='day'; |
1223 | - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; |
|
1297 | + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { |
|
1298 | + $usehourmin='dayhour'; |
|
1299 | + } |
|
1224 | 1300 | if (! empty($object->date_livraison)) |
1225 | 1301 | { |
1226 | 1302 | $posy+=4; |
@@ -1280,7 +1356,9 @@ discard block |
||
1280 | 1356 | // Show sender |
1281 | 1357 | $posy=42+$top_shift; |
1282 | 1358 | $posx=$this->marge_gauche; |
1283 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1359 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1360 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1361 | + } |
|
1284 | 1362 | $hautcadre=40; |
1285 | 1363 | |
1286 | 1364 | // Show sender frame |
@@ -1329,10 +1407,15 @@ discard block |
||
1329 | 1407 | |
1330 | 1408 | // Show recipient |
1331 | 1409 | $widthrecbox=100; |
1332 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1410 | + if ($this->page_largeur < 210) { |
|
1411 | + $widthrecbox=84; |
|
1412 | + } |
|
1413 | + // To work with US executive format |
|
1333 | 1414 | $posy=42+$top_shift; |
1334 | 1415 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1335 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1416 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1417 | + $posx=$this->marge_gauche; |
|
1418 | + } |
|
1336 | 1419 | |
1337 | 1420 | // Show recipient frame |
1338 | 1421 | $pdf->SetTextColor(0,0,0); |
@@ -40,88 +40,88 @@ discard block |
||
40 | 40 | |
41 | 41 | if (GETPOST('search_proposal') != '') |
42 | 42 | { |
43 | - header("Location: ".DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode(GETPOST('search_proposal'))); |
|
44 | - exit; |
|
43 | + header("Location: ".DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode(GETPOST('search_proposal'))); |
|
44 | + exit; |
|
45 | 45 | } |
46 | 46 | if (GETPOST('search_customer_order') != '') |
47 | 47 | { |
48 | - header("Location: ".DOL_URL_ROOT.'/commande/list.php?sall='.urlencode(GETPOST('search_customer_order'))); |
|
49 | - exit; |
|
48 | + header("Location: ".DOL_URL_ROOT.'/commande/list.php?sall='.urlencode(GETPOST('search_customer_order'))); |
|
49 | + exit; |
|
50 | 50 | } |
51 | 51 | if (GETPOST('search_supplier_order') != '') |
52 | 52 | { |
53 | - header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode(GETPOST('search_supplier_order'))); |
|
54 | - exit; |
|
53 | + header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode(GETPOST('search_supplier_order'))); |
|
54 | + exit; |
|
55 | 55 | } |
56 | 56 | if (GETPOST('search_intervention') != '') |
57 | 57 | { |
58 | - header("Location: ".DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode(GETPOST('search_intervention'))); |
|
59 | - exit; |
|
58 | + header("Location: ".DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode(GETPOST('search_intervention'))); |
|
59 | + exit; |
|
60 | 60 | } |
61 | 61 | if (GETPOST('search_contract') != '') |
62 | 62 | { |
63 | - header("Location: ".DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode(GETPOST('search_contract'))); |
|
64 | - exit; |
|
63 | + header("Location: ".DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode(GETPOST('search_contract'))); |
|
64 | + exit; |
|
65 | 65 | } |
66 | 66 | if (GETPOST('search_invoice') != '') |
67 | 67 | { |
68 | - header("Location: ".DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode(GETPOST('search_invoice'))); |
|
69 | - exit; |
|
68 | + header("Location: ".DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode(GETPOST('search_invoice'))); |
|
69 | + exit; |
|
70 | 70 | } |
71 | 71 | if (GETPOST('search_supplier_invoice') != '') |
72 | 72 | { |
73 | - header("Location: ".DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode(GETPOST('search_supplier_invoice'))); |
|
74 | - exit; |
|
73 | + header("Location: ".DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode(GETPOST('search_supplier_invoice'))); |
|
74 | + exit; |
|
75 | 75 | } |
76 | 76 | if (GETPOST('search_supplier_proposal') != '') |
77 | 77 | { |
78 | - header("Location: ".DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode(GETPOST('search_supplier_proposal'))); |
|
79 | - exit; |
|
78 | + header("Location: ".DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode(GETPOST('search_supplier_proposal'))); |
|
79 | + exit; |
|
80 | 80 | } |
81 | 81 | if (GETPOST('search_donation') != '') |
82 | 82 | { |
83 | - header("Location: ".DOL_URL_ROOT.'/don/list.php?sall='.urlencode(GETPOST('search_donation'))); |
|
84 | - exit; |
|
83 | + header("Location: ".DOL_URL_ROOT.'/don/list.php?sall='.urlencode(GETPOST('search_donation'))); |
|
84 | + exit; |
|
85 | 85 | } |
86 | 86 | if (GETPOST('search_product') != '') |
87 | 87 | { |
88 | - header("Location: ".DOL_URL_ROOT.'/product/list.php?sall='.urlencode(GETPOST('search_product'))); |
|
89 | - exit; |
|
88 | + header("Location: ".DOL_URL_ROOT.'/product/list.php?sall='.urlencode(GETPOST('search_product'))); |
|
89 | + exit; |
|
90 | 90 | } |
91 | 91 | if (GETPOST('search_thirdparty') != '') |
92 | 92 | { |
93 | - header("Location: ".DOL_URL_ROOT.'/societe/list.php?mode=search&sall='.urlencode(GETPOST('search_thirdparty'))); |
|
94 | - exit; |
|
93 | + header("Location: ".DOL_URL_ROOT.'/societe/list.php?mode=search&sall='.urlencode(GETPOST('search_thirdparty'))); |
|
94 | + exit; |
|
95 | 95 | } |
96 | 96 | if (GETPOST('search_contact') != '') |
97 | 97 | { |
98 | - header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact'))); |
|
99 | - exit; |
|
98 | + header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact'))); |
|
99 | + exit; |
|
100 | 100 | } |
101 | 101 | if (GETPOST('search_deplacement') != '') |
102 | 102 | { |
103 | - header("Location: ".DOL_URL_ROOT.'/compta/deplacement/list.php?mode=search&sall='.urlencode(GETPOST('search_deplacement'))); |
|
104 | - exit; |
|
103 | + header("Location: ".DOL_URL_ROOT.'/compta/deplacement/list.php?mode=search&sall='.urlencode(GETPOST('search_deplacement'))); |
|
104 | + exit; |
|
105 | 105 | } |
106 | 106 | if (GETPOST('search_expensereport') != '') |
107 | 107 | { |
108 | - header("Location: ".DOL_URL_ROOT.'/expensereport/list.php?mode=search&sall='.urlencode(GETPOST('search_expensereport'))); |
|
109 | - exit; |
|
108 | + header("Location: ".DOL_URL_ROOT.'/expensereport/list.php?mode=search&sall='.urlencode(GETPOST('search_expensereport'))); |
|
109 | + exit; |
|
110 | 110 | } |
111 | 111 | if (GETPOST('search_holiday') != '') |
112 | 112 | { |
113 | - header("Location: ".DOL_URL_ROOT.'/holiday/list.php?mode=search&sall='.urlencode(GETPOST('search_holiday'))); |
|
114 | - exit; |
|
113 | + header("Location: ".DOL_URL_ROOT.'/holiday/list.php?mode=search&sall='.urlencode(GETPOST('search_holiday'))); |
|
114 | + exit; |
|
115 | 115 | } |
116 | 116 | if (GETPOST('search_member') != '') |
117 | 117 | { |
118 | - header("Location: ".DOL_URL_ROOT.'/adherents/list.php?mode=search&sall='.urlencode(GETPOST('search_member'))); |
|
119 | - exit; |
|
118 | + header("Location: ".DOL_URL_ROOT.'/adherents/list.php?mode=search&sall='.urlencode(GETPOST('search_member'))); |
|
119 | + exit; |
|
120 | 120 | } |
121 | 121 | if (GETPOST('search_project') != '') |
122 | 122 | { |
123 | - header("Location: ".DOL_URL_ROOT.'/projet/list.php?mode=search&search_all='.urlencode(GETPOST('search_project'))); |
|
124 | - exit; |
|
123 | + header("Location: ".DOL_URL_ROOT.'/projet/list.php?mode=search&search_all='.urlencode(GETPOST('search_project'))); |
|
124 | + exit; |
|
125 | 125 | } |
126 | 126 | if (GETPOST('search_task') != '') |
127 | 127 | { |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | // If we are here, search was called with no supported criteria |
146 | 146 | if (! empty($_SERVER['HTTP_REFERER'])) |
147 | 147 | { |
148 | - header("Location: ".$_SERVER['HTTP_REFERER']); |
|
149 | - exit; |
|
148 | + header("Location: ".$_SERVER['HTTP_REFERER']); |
|
149 | + exit; |
|
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
153 | - print 'The wrapper search.php was called without any search criteria'; |
|
153 | + print 'The wrapper search.php was called without any search criteria'; |
|
154 | 154 | } |
155 | 155 |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | * \brief Wrapper that receive any search. Depending on input field, make a redirect to correct URL. |
24 | 24 | */ |
25 | 25 | |
26 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
27 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
29 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
30 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
31 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
32 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); |
|
33 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
26 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
27 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
28 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
29 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
30 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); |
|
31 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); |
|
32 | +if (!defined('NOLOGIN')) define('NOLOGIN', 1); |
|
33 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); |
|
34 | 34 | |
35 | 35 | require_once '../main.inc.php'; |
36 | 36 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // If we are here, search was called with no supported criteria |
146 | -if (! empty($_SERVER['HTTP_REFERER'])) |
|
146 | +if (!empty($_SERVER['HTTP_REFERER'])) |
|
147 | 147 | { |
148 | 148 | header("Location: ".$_SERVER['HTTP_REFERER']); |
149 | 149 | exit; |
@@ -23,14 +23,30 @@ discard block |
||
23 | 23 | * \brief Wrapper that receive any search. Depending on input field, make a redirect to correct URL. |
24 | 24 | */ |
25 | 25 | |
26 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
27 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
29 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
30 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
31 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
32 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); |
|
33 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
26 | +if (! defined('NOREQUIREUSER')) { |
|
27 | + define('NOREQUIREUSER','1'); |
|
28 | +} |
|
29 | +if (! defined('NOREQUIREDB')) { |
|
30 | + define('NOREQUIREDB','1'); |
|
31 | +} |
|
32 | +if (! defined('NOREQUIRESOC')) { |
|
33 | + define('NOREQUIRESOC','1'); |
|
34 | +} |
|
35 | +if (! defined('NOREQUIRETRAN')) { |
|
36 | + define('NOREQUIRETRAN','1'); |
|
37 | +} |
|
38 | +if (! defined('NOCSRFCHECK')) { |
|
39 | + define('NOCSRFCHECK',1); |
|
40 | +} |
|
41 | +if (! defined('NOTOKENRENEWAL')) { |
|
42 | + define('NOTOKENRENEWAL',1); |
|
43 | +} |
|
44 | +if (! defined('NOLOGIN')) { |
|
45 | + define('NOLOGIN',1); |
|
46 | +} |
|
47 | +if (! defined('NOREQUIREMENU')) { |
|
48 | + define('NOREQUIREMENU',1); |
|
49 | +} |
|
34 | 50 | |
35 | 51 | require_once '../main.inc.php'; |
36 | 52 | |
@@ -147,8 +163,7 @@ discard block |
||
147 | 163 | { |
148 | 164 | header("Location: ".$_SERVER['HTTP_REFERER']); |
149 | 165 | exit; |
150 | -} |
|
151 | -else |
|
166 | +} else |
|
152 | 167 | { |
153 | 168 | print 'The wrapper search.php was called without any search criteria'; |
154 | 169 | } |
@@ -30,41 +30,41 @@ |
||
30 | 30 | // Set public note |
31 | 31 | if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
35 | 35 | |
36 | - $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
36 | + $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
37 | 37 | |
38 | - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | - { |
|
41 | - // Define output language |
|
42 | - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
43 | - { |
|
44 | - $outputlangs = $langs; |
|
45 | - $newlang = ''; |
|
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
48 | - if (! empty($newlang)) { |
|
49 | - $outputlangs = new Translate("", $conf); |
|
50 | - $outputlangs->setDefaultLang($newlang); |
|
51 | - } |
|
52 | - $model=$object->modelpdf; |
|
53 | - $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | - $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | - $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
38 | + if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | + elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | + { |
|
41 | + // Define output language |
|
42 | + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
43 | + { |
|
44 | + $outputlangs = $langs; |
|
45 | + $newlang = ''; |
|
46 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
48 | + if (! empty($newlang)) { |
|
49 | + $outputlangs = new Translate("", $conf); |
|
50 | + $outputlangs->setDefaultLang($newlang); |
|
51 | + } |
|
52 | + $model=$object->modelpdf; |
|
53 | + $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | + $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | + $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
56 | 56 | |
57 | - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
57 | + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
58 | 58 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
60 | - } |
|
61 | - } |
|
59 | + if ($result < 0) dol_print_error($db,$result); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | // Set public note |
64 | 64 | else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
65 | 65 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
69 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
66 | + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
69 | + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
70 | 70 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | // $id must be defined (object is loaded in this file with fetch) |
29 | 29 | |
30 | 30 | // Set public note |
31 | -if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
|
31 | +if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) |
|
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
35 | 35 | |
36 | - $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
36 | + $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES), '_public'); |
|
37 | 37 | |
38 | 38 | if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
39 | 39 | elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
@@ -43,28 +43,28 @@ discard block |
||
43 | 43 | { |
44 | 44 | $outputlangs = $langs; |
45 | 45 | $newlang = ''; |
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
46 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
47 | 47 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
48 | - if (! empty($newlang)) { |
|
48 | + if (!empty($newlang)) { |
|
49 | 49 | $outputlangs = new Translate("", $conf); |
50 | 50 | $outputlangs->setDefaultLang($newlang); |
51 | 51 | } |
52 | - $model=$object->modelpdf; |
|
53 | - $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | - $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | - $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
52 | + $model = $object->modelpdf; |
|
53 | + $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | + $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | + $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
56 | 56 | |
57 | - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
57 | + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
58 | 58 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
59 | + if ($result < 0) dol_print_error($db, $result); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | 63 | // Set public note |
64 | -else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
|
64 | +else if ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) |
|
65 | 65 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
66 | + if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | + $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES), '_private'); |
|
69 | 69 | if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
70 | 70 | } |
@@ -30,21 +30,31 @@ discard block |
||
30 | 30 | // Set public note |
31 | 31 | if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || ! is_object($object) || empty($id)) { |
|
34 | + dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
35 | + } |
|
36 | + if (empty($object->id)) { |
|
37 | + $object->fetch($id); |
|
38 | + } |
|
39 | + // Fetch may not be already done |
|
35 | 40 | |
36 | 41 | $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
37 | 42 | |
38 | - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
43 | + if ($result_update < 0) { |
|
44 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
45 | + } elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | 46 | { |
41 | 47 | // Define output language |
42 | 48 | if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
43 | 49 | { |
44 | 50 | $outputlangs = $langs; |
45 | 51 | $newlang = ''; |
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
52 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
53 | + $newlang = GETPOST('lang_id','aZ09'); |
|
54 | + } |
|
55 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
56 | + $newlang = $object->thirdparty->default_lang; |
|
57 | + } |
|
48 | 58 | if (! empty($newlang)) { |
49 | 59 | $outputlangs = new Translate("", $conf); |
50 | 60 | $outputlangs->setDefaultLang($newlang); |
@@ -56,15 +66,24 @@ discard block |
||
56 | 66 | |
57 | 67 | $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
58 | 68 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
69 | + if ($result < 0) { |
|
70 | + dol_print_error($db,$result); |
|
71 | + } |
|
60 | 72 | } |
61 | 73 | } |
62 | 74 | } |
63 | 75 | // Set public note |
64 | 76 | else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
65 | 77 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
78 | + if (empty($action) || ! is_object($object) || empty($id)) { |
|
79 | + dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
80 | + } |
|
81 | + if (empty($object->id)) { |
|
82 | + $object->fetch($id); |
|
83 | + } |
|
84 | + // Fetch may not be already done |
|
68 | 85 | $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
69 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
70 | -} |
|
86 | + if ($result < 0) { |
|
87 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
88 | + } |
|
89 | + } |
@@ -43,79 +43,79 @@ discard block |
||
43 | 43 | $accessallowed=0; |
44 | 44 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
45 | 45 | { |
46 | - $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
47 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
48 | - $accessallowed=1; |
|
46 | + $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
47 | + if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
48 | + $accessallowed=1; |
|
49 | 49 | } |
50 | 50 | elseif ($modulepart == 'project') |
51 | 51 | { |
52 | 52 | $result=restrictedArea($user,'projet',$id); |
53 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
54 | - $accessallowed=1; |
|
53 | + if (! $user->rights->projet->lire) accessforbidden(); |
|
54 | + $accessallowed=1; |
|
55 | 55 | } |
56 | 56 | elseif ($modulepart == 'expensereport') |
57 | 57 | { |
58 | - $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
59 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
60 | - $accessallowed=1; |
|
58 | + $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
59 | + if (! $user->rights->expensereport->lire) accessforbidden(); |
|
60 | + $accessallowed=1; |
|
61 | 61 | } |
62 | 62 | elseif ($modulepart == 'holiday') |
63 | 63 | { |
64 | - $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
65 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
66 | - $accessallowed=1; |
|
64 | + $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
65 | + if (! $user->rights->holiday->read) accessforbidden(); |
|
66 | + $accessallowed=1; |
|
67 | 67 | } |
68 | 68 | elseif ($modulepart == 'member') |
69 | 69 | { |
70 | - $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
71 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
72 | - $accessallowed=1; |
|
70 | + $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
71 | + if (! $user->rights->adherent->lire) accessforbidden(); |
|
72 | + $accessallowed=1; |
|
73 | 73 | } |
74 | 74 | elseif ($modulepart == 'user') |
75 | 75 | { |
76 | - $result=restrictedArea($user,'user',$id,'user'); |
|
77 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
78 | - $accessallowed=1; |
|
76 | + $result=restrictedArea($user,'user',$id,'user'); |
|
77 | + if (! $user->rights->user->user->lire) accessforbidden(); |
|
78 | + $accessallowed=1; |
|
79 | 79 | } |
80 | 80 | elseif ($modulepart == 'societe') |
81 | 81 | { |
82 | - $result=restrictedArea($user,'societe',$id,'societe'); |
|
83 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
84 | - $accessallowed=1; |
|
82 | + $result=restrictedArea($user,'societe',$id,'societe'); |
|
83 | + if (! $user->rights->societe->lire) accessforbidden(); |
|
84 | + $accessallowed=1; |
|
85 | 85 | } |
86 | 86 | elseif ($modulepart == 'tax') |
87 | 87 | { |
88 | - $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
89 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
90 | - $accessallowed=1; |
|
88 | + $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
89 | + if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
90 | + $accessallowed=1; |
|
91 | 91 | } |
92 | 92 | elseif ($modulepart == 'ticket') |
93 | 93 | { |
94 | - $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
95 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
96 | - $accessallowed=1; |
|
94 | + $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
95 | + if (! $user->rights->ticket->read) accessforbidden(); |
|
96 | + $accessallowed=1; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Security: |
100 | 100 | // Limit access if permissions are wrong |
101 | 101 | if (! $accessallowed) |
102 | 102 | { |
103 | - accessforbidden(); |
|
103 | + accessforbidden(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // Define dir according to modulepart |
107 | 107 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
108 | 108 | { |
109 | - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
110 | - $object = new Product($db); |
|
111 | - if ($id > 0) |
|
112 | - { |
|
113 | - $result = $object->fetch($id); |
|
114 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
115 | - $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
116 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
118 | - } |
|
109 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
110 | + $object = new Product($db); |
|
111 | + if ($id > 0) |
|
112 | + { |
|
113 | + $result = $object->fetch($id); |
|
114 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
115 | + $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
116 | + if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | + if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | elseif ($modulepart == 'project') |
121 | 121 | { |
@@ -130,25 +130,25 @@ discard block |
||
130 | 130 | } |
131 | 131 | elseif ($modulepart == 'holiday') |
132 | 132 | { |
133 | - require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
|
134 | - $object = new Holiday($db); |
|
135 | - if ($id > 0) |
|
136 | - { |
|
137 | - $result = $object->fetch($id); |
|
138 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
139 | - $dir=$conf->holiday->dir_output; // By default |
|
140 | - } |
|
133 | + require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
|
134 | + $object = new Holiday($db); |
|
135 | + if ($id > 0) |
|
136 | + { |
|
137 | + $result = $object->fetch($id); |
|
138 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
139 | + $dir=$conf->holiday->dir_output; // By default |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | elseif ($modulepart == 'member') |
143 | 143 | { |
144 | - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
145 | - $object = new Adherent($db); |
|
146 | - if ($id > 0) |
|
147 | - { |
|
148 | - $result = $object->fetch($id); |
|
149 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
150 | - $dir=$conf->adherent->dir_output; // By default |
|
151 | - } |
|
144 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
145 | + $object = new Adherent($db); |
|
146 | + if ($id > 0) |
|
147 | + { |
|
148 | + $result = $object->fetch($id); |
|
149 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
150 | + $dir=$conf->adherent->dir_output; // By default |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | elseif ($modulepart == 'societe') |
154 | 154 | { |
@@ -185,28 +185,28 @@ discard block |
||
185 | 185 | } |
186 | 186 | elseif ($modulepart == 'tax') |
187 | 187 | { |
188 | - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
|
189 | - $object = new ChargeSociales($db); |
|
190 | - if ($id > 0) |
|
191 | - { |
|
192 | - $result = $object->fetch($id); |
|
193 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
194 | - $dir=$conf->tax->dir_output; // By default |
|
195 | - } |
|
188 | + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
|
189 | + $object = new ChargeSociales($db); |
|
190 | + if ($id > 0) |
|
191 | + { |
|
192 | + $result = $object->fetch($id); |
|
193 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
194 | + $dir=$conf->tax->dir_output; // By default |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | elseif ($modulepart == 'ticket') |
198 | 198 | { |
199 | - require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
|
200 | - $object = new Ticket($db); |
|
201 | - if ($id > 0) |
|
202 | - { |
|
203 | - $result = $object->fetch($id); |
|
204 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
205 | - $dir=$conf->ticket->dir_output; // By default |
|
206 | - } |
|
199 | + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
|
200 | + $object = new Ticket($db); |
|
201 | + if ($id > 0) |
|
202 | + { |
|
203 | + $result = $object->fetch($id); |
|
204 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
205 | + $dir=$conf->ticket->dir_output; // By default |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | else { |
209 | - print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
|
209 | + print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | if (empty($backtourl)) |
@@ -229,154 +229,154 @@ discard block |
||
229 | 229 | |
230 | 230 | if ($cancel) |
231 | 231 | { |
232 | - if ($backtourl) |
|
233 | - { |
|
234 | - header("Location: ".$backtourl); |
|
235 | - exit; |
|
236 | - } |
|
237 | - else |
|
238 | - { |
|
239 | - dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
|
240 | - exit; |
|
241 | - } |
|
232 | + if ($backtourl) |
|
233 | + { |
|
234 | + header("Location: ".$backtourl); |
|
235 | + exit; |
|
236 | + } |
|
237 | + else |
|
238 | + { |
|
239 | + dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
|
240 | + exit; |
|
241 | + } |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) |
245 | 245 | { |
246 | - $fullpath=$dir."/".$original_file; |
|
247 | - |
|
248 | - $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
249 | - |
|
250 | - if ($result == $fullpath) |
|
251 | - { |
|
252 | - $object->addThumbs($fullpath); |
|
253 | - |
|
254 | - // Update/create database for file $fullpath |
|
255 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
256 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | - |
|
258 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
259 | - $ecmfile=new EcmFiles($db); |
|
260 | - $result = $ecmfile->fetch(0, '', $rel_filename); |
|
261 | - if ($result > 0) // If found |
|
262 | - { |
|
263 | - $filename = basename($rel_filename); |
|
264 | - $rel_dir = dirname($rel_filename); |
|
265 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
266 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
267 | - |
|
268 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
269 | - $result = $ecmfile->update($user); |
|
270 | - } |
|
271 | - elseif ($result == 0) // If not found |
|
272 | - { |
|
273 | - $filename = basename($rel_filename); |
|
274 | - $rel_dir = dirname($rel_filename); |
|
275 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
276 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
277 | - |
|
278 | - $ecmfile->filepath = $rel_dir; |
|
279 | - $ecmfile->filename = $filename; |
|
280 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
281 | - $ecmfile->fullpath_orig = $fullpath; |
|
282 | - $ecmfile->gen_or_uploaded = 'unknown'; |
|
283 | - $ecmfile->description = ''; // indexed content |
|
284 | - $ecmfile->keyword = ''; // keyword content |
|
285 | - $result = $ecmfile->create($user); |
|
286 | - if ($result < 0) |
|
287 | - { |
|
288 | - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
289 | - } |
|
290 | - $result = $ecmfile->create($user); |
|
291 | - } |
|
292 | - |
|
293 | - if ($backtourl) |
|
294 | - { |
|
295 | - header("Location: ".$backtourl); |
|
296 | - exit; |
|
297 | - } |
|
298 | - else |
|
299 | - { |
|
300 | - dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
301 | - exit; |
|
302 | - } |
|
303 | - } |
|
304 | - else |
|
305 | - { |
|
306 | - setEventMessages($result, null, 'errors'); |
|
307 | - $_GET['file']=$_POST["file"]; |
|
308 | - $action=''; |
|
309 | - } |
|
246 | + $fullpath=$dir."/".$original_file; |
|
247 | + |
|
248 | + $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
249 | + |
|
250 | + if ($result == $fullpath) |
|
251 | + { |
|
252 | + $object->addThumbs($fullpath); |
|
253 | + |
|
254 | + // Update/create database for file $fullpath |
|
255 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
256 | + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | + |
|
258 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
259 | + $ecmfile=new EcmFiles($db); |
|
260 | + $result = $ecmfile->fetch(0, '', $rel_filename); |
|
261 | + if ($result > 0) // If found |
|
262 | + { |
|
263 | + $filename = basename($rel_filename); |
|
264 | + $rel_dir = dirname($rel_filename); |
|
265 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
266 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
267 | + |
|
268 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
269 | + $result = $ecmfile->update($user); |
|
270 | + } |
|
271 | + elseif ($result == 0) // If not found |
|
272 | + { |
|
273 | + $filename = basename($rel_filename); |
|
274 | + $rel_dir = dirname($rel_filename); |
|
275 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
276 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
277 | + |
|
278 | + $ecmfile->filepath = $rel_dir; |
|
279 | + $ecmfile->filename = $filename; |
|
280 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
281 | + $ecmfile->fullpath_orig = $fullpath; |
|
282 | + $ecmfile->gen_or_uploaded = 'unknown'; |
|
283 | + $ecmfile->description = ''; // indexed content |
|
284 | + $ecmfile->keyword = ''; // keyword content |
|
285 | + $result = $ecmfile->create($user); |
|
286 | + if ($result < 0) |
|
287 | + { |
|
288 | + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
289 | + } |
|
290 | + $result = $ecmfile->create($user); |
|
291 | + } |
|
292 | + |
|
293 | + if ($backtourl) |
|
294 | + { |
|
295 | + header("Location: ".$backtourl); |
|
296 | + exit; |
|
297 | + } |
|
298 | + else |
|
299 | + { |
|
300 | + dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
301 | + exit; |
|
302 | + } |
|
303 | + } |
|
304 | + else |
|
305 | + { |
|
306 | + setEventMessages($result, null, 'errors'); |
|
307 | + $_GET['file']=$_POST["file"]; |
|
308 | + $action=''; |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Crop d'une image |
313 | 313 | if ($action == 'confirm_crop') |
314 | 314 | { |
315 | - $fullpath=$dir."/".$original_file; |
|
316 | - |
|
317 | - //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
|
318 | - $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
319 | - |
|
320 | - if ($result == $fullpath) |
|
321 | - { |
|
322 | - $object->addThumbs($fullpath); |
|
323 | - |
|
324 | - // Update/create database for file $fullpath |
|
325 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
326 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | - |
|
328 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
329 | - $ecmfile=new EcmFiles($db); |
|
330 | - $result = $ecmfile->fetch(0, '', $rel_filename); |
|
331 | - if ($result > 0) // If found |
|
332 | - { |
|
333 | - $filename = basename($rel_filename); |
|
334 | - $rel_dir = dirname($rel_filename); |
|
335 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
336 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
337 | - |
|
338 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
339 | - $result = $ecmfile->update($user); |
|
340 | - } |
|
341 | - elseif ($result == 0) // If not found |
|
342 | - { |
|
343 | - $filename = basename($rel_filename); |
|
344 | - $rel_dir = dirname($rel_filename); |
|
345 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
346 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
347 | - |
|
348 | - $ecmfile->filepath = $rel_dir; |
|
349 | - $ecmfile->filename = $filename; |
|
350 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
351 | - $ecmfile->fullpath_orig = $fullpath; |
|
352 | - $ecmfile->gen_or_uploaded = 'unknown'; |
|
353 | - $ecmfile->description = ''; // indexed content |
|
354 | - $ecmfile->keyword = ''; // keyword content |
|
355 | - $result = $ecmfile->create($user); |
|
356 | - if ($result < 0) |
|
357 | - { |
|
358 | - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
359 | - } |
|
360 | - $result = $ecmfile->create($user); |
|
361 | - } |
|
362 | - |
|
363 | - if ($backtourl) |
|
364 | - { |
|
365 | - header("Location: ".$backtourl); |
|
366 | - exit; |
|
367 | - } |
|
368 | - else |
|
369 | - { |
|
370 | - dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
371 | - exit; |
|
372 | - } |
|
373 | - } |
|
374 | - else |
|
375 | - { |
|
376 | - setEventMessages($result, null, 'errors'); |
|
377 | - $_GET['file']=$_POST["file"]; |
|
378 | - $action=''; |
|
379 | - } |
|
315 | + $fullpath=$dir."/".$original_file; |
|
316 | + |
|
317 | + //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
|
318 | + $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
319 | + |
|
320 | + if ($result == $fullpath) |
|
321 | + { |
|
322 | + $object->addThumbs($fullpath); |
|
323 | + |
|
324 | + // Update/create database for file $fullpath |
|
325 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
326 | + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | + |
|
328 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
329 | + $ecmfile=new EcmFiles($db); |
|
330 | + $result = $ecmfile->fetch(0, '', $rel_filename); |
|
331 | + if ($result > 0) // If found |
|
332 | + { |
|
333 | + $filename = basename($rel_filename); |
|
334 | + $rel_dir = dirname($rel_filename); |
|
335 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
336 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
337 | + |
|
338 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
339 | + $result = $ecmfile->update($user); |
|
340 | + } |
|
341 | + elseif ($result == 0) // If not found |
|
342 | + { |
|
343 | + $filename = basename($rel_filename); |
|
344 | + $rel_dir = dirname($rel_filename); |
|
345 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
346 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
347 | + |
|
348 | + $ecmfile->filepath = $rel_dir; |
|
349 | + $ecmfile->filename = $filename; |
|
350 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
351 | + $ecmfile->fullpath_orig = $fullpath; |
|
352 | + $ecmfile->gen_or_uploaded = 'unknown'; |
|
353 | + $ecmfile->description = ''; // indexed content |
|
354 | + $ecmfile->keyword = ''; // keyword content |
|
355 | + $result = $ecmfile->create($user); |
|
356 | + if ($result < 0) |
|
357 | + { |
|
358 | + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
359 | + } |
|
360 | + $result = $ecmfile->create($user); |
|
361 | + } |
|
362 | + |
|
363 | + if ($backtourl) |
|
364 | + { |
|
365 | + header("Location: ".$backtourl); |
|
366 | + exit; |
|
367 | + } |
|
368 | + else |
|
369 | + { |
|
370 | + dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
371 | + exit; |
|
372 | + } |
|
373 | + } |
|
374 | + else |
|
375 | + { |
|
376 | + setEventMessages($result, null, 'errors'); |
|
377 | + $_GET['file']=$_POST["file"]; |
|
378 | + $action=''; |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -433,28 +433,28 @@ discard block |
||
433 | 433 | |
434 | 434 | if (! empty($conf->use_javascript_ajax)) |
435 | 435 | { |
436 | - $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
437 | - $height=$infoarray['height']; |
|
438 | - $width=$infoarray['width']; |
|
439 | - $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
440 | - // If image is too large, we use another scale. |
|
441 | - if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
442 | - { |
|
443 | - $ratioforcrop=2; |
|
444 | - $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
445 | - $refsizeforcrop='screenwidth'; |
|
446 | - } |
|
447 | - |
|
448 | - print '<!-- Form to crop -->'."\n"; |
|
449 | - print '<fieldset id="redim_file">'; |
|
450 | - print '<legend>'.$langs->trans("Recenter").'</legend>'; |
|
451 | - print $langs->trans("DefineNewAreaToPick").'...<br>'; |
|
452 | - print '<br><div class="center">'; |
|
453 | - print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">'; |
|
454 | - print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>'; |
|
455 | - print '</div>'; |
|
456 | - print '</div><br>'; |
|
457 | - print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST"> |
|
436 | + $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
437 | + $height=$infoarray['height']; |
|
438 | + $width=$infoarray['width']; |
|
439 | + $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
440 | + // If image is too large, we use another scale. |
|
441 | + if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
442 | + { |
|
443 | + $ratioforcrop=2; |
|
444 | + $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
445 | + $refsizeforcrop='screenwidth'; |
|
446 | + } |
|
447 | + |
|
448 | + print '<!-- Form to crop -->'."\n"; |
|
449 | + print '<fieldset id="redim_file">'; |
|
450 | + print '<legend>'.$langs->trans("Recenter").'</legend>'; |
|
451 | + print $langs->trans("DefineNewAreaToPick").'...<br>'; |
|
452 | + print '<br><div class="center">'; |
|
453 | + print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">'; |
|
454 | + print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>'; |
|
455 | + print '</div>'; |
|
456 | + print '</div><br>'; |
|
457 | + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST"> |
|
458 | 458 | <div class="jc_coords"> |
459 | 459 | '.$langs->trans("NewSizeAfterCropping").': |
460 | 460 | <label>X1 <input type="number" class="flat maxwidth50" id="x" name="x" /></label> |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | |
478 | 478 | <input type="submit" id="cancelcrop" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" /> |
479 | 479 | </form>'."\n"; |
480 | - print '</fieldset>'."\n"; |
|
481 | - print '<br>'; |
|
480 | + print '</fieldset>'."\n"; |
|
481 | + print '<br>'; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /* Check that mandatory fields are filled */ |
@@ -39,60 +39,72 @@ discard block |
||
39 | 39 | $cancel=GETPOST('cancel','alpha'); |
40 | 40 | |
41 | 41 | // Security check |
42 | -if (empty($modulepart)) accessforbidden('Bad value for modulepart'); |
|
42 | +if (empty($modulepart)) { |
|
43 | + accessforbidden('Bad value for modulepart'); |
|
44 | +} |
|
43 | 45 | $accessallowed=0; |
44 | 46 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
45 | 47 | { |
46 | 48 | $result=restrictedArea($user,'produit|service',$id,'product&product'); |
47 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
49 | + if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) { |
|
50 | + accessforbidden(); |
|
51 | + } |
|
48 | 52 | $accessallowed=1; |
49 | -} |
|
50 | -elseif ($modulepart == 'project') |
|
53 | +} elseif ($modulepart == 'project') |
|
51 | 54 | { |
52 | 55 | $result=restrictedArea($user,'projet',$id); |
53 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
56 | + if (! $user->rights->projet->lire) { |
|
57 | + accessforbidden(); |
|
58 | + } |
|
54 | 59 | $accessallowed=1; |
55 | -} |
|
56 | -elseif ($modulepart == 'expensereport') |
|
60 | +} elseif ($modulepart == 'expensereport') |
|
57 | 61 | { |
58 | 62 | $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
59 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
63 | + if (! $user->rights->expensereport->lire) { |
|
64 | + accessforbidden(); |
|
65 | + } |
|
60 | 66 | $accessallowed=1; |
61 | -} |
|
62 | -elseif ($modulepart == 'holiday') |
|
67 | +} elseif ($modulepart == 'holiday') |
|
63 | 68 | { |
64 | 69 | $result=restrictedArea($user,'holiday',$id,'holiday'); |
65 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
70 | + if (! $user->rights->holiday->read) { |
|
71 | + accessforbidden(); |
|
72 | + } |
|
66 | 73 | $accessallowed=1; |
67 | -} |
|
68 | -elseif ($modulepart == 'member') |
|
74 | +} elseif ($modulepart == 'member') |
|
69 | 75 | { |
70 | 76 | $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
71 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
77 | + if (! $user->rights->adherent->lire) { |
|
78 | + accessforbidden(); |
|
79 | + } |
|
72 | 80 | $accessallowed=1; |
73 | -} |
|
74 | -elseif ($modulepart == 'user') |
|
81 | +} elseif ($modulepart == 'user') |
|
75 | 82 | { |
76 | 83 | $result=restrictedArea($user,'user',$id,'user'); |
77 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
84 | + if (! $user->rights->user->user->lire) { |
|
85 | + accessforbidden(); |
|
86 | + } |
|
78 | 87 | $accessallowed=1; |
79 | -} |
|
80 | -elseif ($modulepart == 'societe') |
|
88 | +} elseif ($modulepart == 'societe') |
|
81 | 89 | { |
82 | 90 | $result=restrictedArea($user,'societe',$id,'societe'); |
83 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
91 | + if (! $user->rights->societe->lire) { |
|
92 | + accessforbidden(); |
|
93 | + } |
|
84 | 94 | $accessallowed=1; |
85 | -} |
|
86 | -elseif ($modulepart == 'tax') |
|
95 | +} elseif ($modulepart == 'tax') |
|
87 | 96 | { |
88 | 97 | $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
89 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
98 | + if (! $user->rights->tax->charges->lire) { |
|
99 | + accessforbidden(); |
|
100 | + } |
|
90 | 101 | $accessallowed=1; |
91 | -} |
|
92 | -elseif ($modulepart == 'ticket') |
|
102 | +} elseif ($modulepart == 'ticket') |
|
93 | 103 | { |
94 | 104 | $result=restrictedArea($user,'ticket',$id,'ticket'); |
95 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
105 | + if (! $user->rights->ticket->read) { |
|
106 | + accessforbidden(); |
|
107 | + } |
|
96 | 108 | $accessallowed=1; |
97 | 109 | } |
98 | 110 | |
@@ -111,116 +123,139 @@ discard block |
||
111 | 123 | if ($id > 0) |
112 | 124 | { |
113 | 125 | $result = $object->fetch($id); |
114 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
126 | + if ($result <= 0) { |
|
127 | + dol_print_error($db,'Failed to load object'); |
|
128 | + } |
|
115 | 129 | $dir=$conf->product->multidir_output[$object->entity]; // By default |
116 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
130 | + if ($object->type == Product::TYPE_PRODUCT) { |
|
131 | + $dir=$conf->product->multidir_output[$object->entity]; |
|
132 | + } |
|
133 | + if ($object->type == Product::TYPE_SERVICE) { |
|
134 | + $dir=$conf->service->multidir_output[$object->entity]; |
|
135 | + } |
|
118 | 136 | } |
119 | -} |
|
120 | -elseif ($modulepart == 'project') |
|
137 | +} elseif ($modulepart == 'project') |
|
121 | 138 | { |
122 | 139 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
123 | 140 | $object = new Project($db); |
124 | 141 | if ($id > 0) |
125 | 142 | { |
126 | 143 | $result = $object->fetch($id); |
127 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
144 | + if ($result <= 0) { |
|
145 | + dol_print_error($db,'Failed to load object'); |
|
146 | + } |
|
128 | 147 | $dir=$conf->projet->dir_output; // By default |
129 | 148 | } |
130 | -} |
|
131 | -elseif ($modulepart == 'holiday') |
|
149 | +} elseif ($modulepart == 'holiday') |
|
132 | 150 | { |
133 | 151 | require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
134 | 152 | $object = new Holiday($db); |
135 | 153 | if ($id > 0) |
136 | 154 | { |
137 | 155 | $result = $object->fetch($id); |
138 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
156 | + if ($result <= 0) { |
|
157 | + dol_print_error($db,'Failed to load object'); |
|
158 | + } |
|
139 | 159 | $dir=$conf->holiday->dir_output; // By default |
140 | 160 | } |
141 | -} |
|
142 | -elseif ($modulepart == 'member') |
|
161 | +} elseif ($modulepart == 'member') |
|
143 | 162 | { |
144 | 163 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
145 | 164 | $object = new Adherent($db); |
146 | 165 | if ($id > 0) |
147 | 166 | { |
148 | 167 | $result = $object->fetch($id); |
149 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
168 | + if ($result <= 0) { |
|
169 | + dol_print_error($db,'Failed to load object'); |
|
170 | + } |
|
150 | 171 | $dir=$conf->adherent->dir_output; // By default |
151 | 172 | } |
152 | -} |
|
153 | -elseif ($modulepart == 'societe') |
|
173 | +} elseif ($modulepart == 'societe') |
|
154 | 174 | { |
155 | 175 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
156 | 176 | $object = new Societe($db); |
157 | 177 | if ($id > 0) |
158 | 178 | { |
159 | 179 | $result = $object->fetch($id); |
160 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
180 | + if ($result <= 0) { |
|
181 | + dol_print_error($db,'Failed to load object'); |
|
182 | + } |
|
161 | 183 | $dir=$conf->societe->dir_output; |
162 | 184 | } |
163 | -} |
|
164 | -elseif ($modulepart == 'user') |
|
185 | +} elseif ($modulepart == 'user') |
|
165 | 186 | { |
166 | 187 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
167 | 188 | $object = new User($db); |
168 | 189 | if ($id > 0) |
169 | 190 | { |
170 | 191 | $result = $object->fetch($id); |
171 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
192 | + if ($result <= 0) { |
|
193 | + dol_print_error($db,'Failed to load object'); |
|
194 | + } |
|
172 | 195 | $dir=$conf->user->dir_output; // By default |
173 | 196 | } |
174 | -} |
|
175 | -elseif ($modulepart == 'expensereport') |
|
197 | +} elseif ($modulepart == 'expensereport') |
|
176 | 198 | { |
177 | 199 | require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
178 | 200 | $object = new ExpenseReport($db); |
179 | 201 | if ($id > 0) |
180 | 202 | { |
181 | 203 | $result = $object->fetch($id); |
182 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
204 | + if ($result <= 0) { |
|
205 | + dol_print_error($db,'Failed to load object'); |
|
206 | + } |
|
183 | 207 | $dir=$conf->expensereport->dir_output; // By default |
184 | 208 | } |
185 | -} |
|
186 | -elseif ($modulepart == 'tax') |
|
209 | +} elseif ($modulepart == 'tax') |
|
187 | 210 | { |
188 | 211 | require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
189 | 212 | $object = new ChargeSociales($db); |
190 | 213 | if ($id > 0) |
191 | 214 | { |
192 | 215 | $result = $object->fetch($id); |
193 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
216 | + if ($result <= 0) { |
|
217 | + dol_print_error($db,'Failed to load object'); |
|
218 | + } |
|
194 | 219 | $dir=$conf->tax->dir_output; // By default |
195 | 220 | } |
196 | -} |
|
197 | -elseif ($modulepart == 'ticket') |
|
221 | +} elseif ($modulepart == 'ticket') |
|
198 | 222 | { |
199 | 223 | require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
200 | 224 | $object = new Ticket($db); |
201 | 225 | if ($id > 0) |
202 | 226 | { |
203 | 227 | $result = $object->fetch($id); |
204 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
228 | + if ($result <= 0) { |
|
229 | + dol_print_error($db,'Failed to load object'); |
|
230 | + } |
|
205 | 231 | $dir=$conf->ticket->dir_output; // By default |
206 | 232 | } |
207 | -} |
|
208 | -else { |
|
233 | +} else { |
|
209 | 234 | print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
210 | 235 | } |
211 | 236 | |
212 | 237 | if (empty($backtourl)) |
213 | 238 | { |
214 | - if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
215 | - else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
216 | - else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | - else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | - else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | - else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | - else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | - else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | -} |
|
239 | + if (in_array($modulepart, array('product','produit','service','produit|service'))) { |
|
240 | + $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
241 | + } else if (in_array($modulepart, array('expensereport'))) { |
|
242 | + $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
243 | + } else if (in_array($modulepart, array('holiday'))) { |
|
244 | + $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
245 | + } else if (in_array($modulepart, array('member'))) { |
|
246 | + $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
247 | + } else if (in_array($modulepart, array('project'))) { |
|
248 | + $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
249 | + } else if (in_array($modulepart, array('societe'))) { |
|
250 | + $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
251 | + } else if (in_array($modulepart, array('tax'))) { |
|
252 | + $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
253 | + } else if (in_array($modulepart, array('ticket'))) { |
|
254 | + $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
255 | + } else if (in_array($modulepart, array('user'))) { |
|
256 | + $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
257 | + } |
|
258 | + } |
|
224 | 259 | |
225 | 260 | |
226 | 261 | /* |
@@ -233,8 +268,7 @@ discard block |
||
233 | 268 | { |
234 | 269 | header("Location: ".$backtourl); |
235 | 270 | exit; |
236 | - } |
|
237 | - else |
|
271 | + } else |
|
238 | 272 | { |
239 | 273 | dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
240 | 274 | exit; |
@@ -258,19 +292,22 @@ discard block |
||
258 | 292 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
259 | 293 | $ecmfile=new EcmFiles($db); |
260 | 294 | $result = $ecmfile->fetch(0, '', $rel_filename); |
261 | - if ($result > 0) // If found |
|
295 | + if ($result > 0) { |
|
296 | + // If found |
|
262 | 297 | { |
263 | 298 | $filename = basename($rel_filename); |
299 | + } |
|
264 | 300 | $rel_dir = dirname($rel_filename); |
265 | 301 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
266 | 302 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
267 | 303 | |
268 | 304 | $ecmfile->label = md5_file(dol_osencode($fullpath)); |
269 | 305 | $result = $ecmfile->update($user); |
270 | - } |
|
271 | - elseif ($result == 0) // If not found |
|
306 | + } elseif ($result == 0) { |
|
307 | + // If not found |
|
272 | 308 | { |
273 | 309 | $filename = basename($rel_filename); |
310 | + } |
|
274 | 311 | $rel_dir = dirname($rel_filename); |
275 | 312 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
276 | 313 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -294,14 +331,12 @@ discard block |
||
294 | 331 | { |
295 | 332 | header("Location: ".$backtourl); |
296 | 333 | exit; |
297 | - } |
|
298 | - else |
|
334 | + } else |
|
299 | 335 | { |
300 | 336 | dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
301 | 337 | exit; |
302 | 338 | } |
303 | - } |
|
304 | - else |
|
339 | + } else |
|
305 | 340 | { |
306 | 341 | setEventMessages($result, null, 'errors'); |
307 | 342 | $_GET['file']=$_POST["file"]; |
@@ -328,19 +363,22 @@ discard block |
||
328 | 363 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
329 | 364 | $ecmfile=new EcmFiles($db); |
330 | 365 | $result = $ecmfile->fetch(0, '', $rel_filename); |
331 | - if ($result > 0) // If found |
|
366 | + if ($result > 0) { |
|
367 | + // If found |
|
332 | 368 | { |
333 | 369 | $filename = basename($rel_filename); |
370 | + } |
|
334 | 371 | $rel_dir = dirname($rel_filename); |
335 | 372 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
336 | 373 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
337 | 374 | |
338 | 375 | $ecmfile->label = md5_file(dol_osencode($fullpath)); |
339 | 376 | $result = $ecmfile->update($user); |
340 | - } |
|
341 | - elseif ($result == 0) // If not found |
|
377 | + } elseif ($result == 0) { |
|
378 | + // If not found |
|
342 | 379 | { |
343 | 380 | $filename = basename($rel_filename); |
381 | + } |
|
344 | 382 | $rel_dir = dirname($rel_filename); |
345 | 383 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
346 | 384 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -364,14 +402,12 @@ discard block |
||
364 | 402 | { |
365 | 403 | header("Location: ".$backtourl); |
366 | 404 | exit; |
367 | - } |
|
368 | - else |
|
405 | + } else |
|
369 | 406 | { |
370 | 407 | dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
371 | 408 | exit; |
372 | 409 | } |
373 | - } |
|
374 | - else |
|
410 | + } else |
|
375 | 411 | { |
376 | 412 | setEventMessages($result, null, 'errors'); |
377 | 413 | $_GET['file']=$_POST["file"]; |
@@ -26,81 +26,81 @@ discard block |
||
26 | 26 | |
27 | 27 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
28 | 28 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
29 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
30 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; |
|
29 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
|
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
32 | 32 | |
33 | 33 | // Load translation files required by the page |
34 | -$langs->loadLangs(array("products","other")); |
|
34 | +$langs->loadLangs(array("products", "other")); |
|
35 | 35 | |
36 | -$id=GETPOST('id','int'); |
|
37 | -$action=GETPOST('action','alpha'); |
|
38 | -$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; |
|
36 | +$id = GETPOST('id', 'int'); |
|
37 | +$action = GETPOST('action', 'alpha'); |
|
38 | +$modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service'; |
|
39 | 39 | $original_file = GETPOST("file"); |
40 | -$backtourl=GETPOST('backtourl'); |
|
41 | -$cancel=GETPOST('cancel','alpha'); |
|
40 | +$backtourl = GETPOST('backtourl'); |
|
41 | +$cancel = GETPOST('cancel', 'alpha'); |
|
42 | 42 | |
43 | 43 | // Security check |
44 | 44 | if (empty($modulepart)) accessforbidden('Bad value for modulepart'); |
45 | -$accessallowed=0; |
|
45 | +$accessallowed = 0; |
|
46 | 46 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
47 | 47 | { |
48 | - $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
49 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
50 | - $accessallowed=1; |
|
48 | + $result = restrictedArea($user, 'produit|service', $id, 'product&product'); |
|
49 | + if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden(); |
|
50 | + $accessallowed = 1; |
|
51 | 51 | } |
52 | 52 | elseif ($modulepart == 'project') |
53 | 53 | { |
54 | - $result=restrictedArea($user,'projet',$id); |
|
55 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
56 | - $accessallowed=1; |
|
54 | + $result = restrictedArea($user, 'projet', $id); |
|
55 | + if (!$user->rights->projet->lire) accessforbidden(); |
|
56 | + $accessallowed = 1; |
|
57 | 57 | } |
58 | 58 | elseif ($modulepart == 'expensereport') |
59 | 59 | { |
60 | - $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
61 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
62 | - $accessallowed=1; |
|
60 | + $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); |
|
61 | + if (!$user->rights->expensereport->lire) accessforbidden(); |
|
62 | + $accessallowed = 1; |
|
63 | 63 | } |
64 | 64 | elseif ($modulepart == 'holiday') |
65 | 65 | { |
66 | - $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
67 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
68 | - $accessallowed=1; |
|
66 | + $result = restrictedArea($user, 'holiday', $id, 'holiday'); |
|
67 | + if (!$user->rights->holiday->read) accessforbidden(); |
|
68 | + $accessallowed = 1; |
|
69 | 69 | } |
70 | 70 | elseif ($modulepart == 'member') |
71 | 71 | { |
72 | - $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
73 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
74 | - $accessallowed=1; |
|
72 | + $result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
73 | + if (!$user->rights->adherent->lire) accessforbidden(); |
|
74 | + $accessallowed = 1; |
|
75 | 75 | } |
76 | 76 | elseif ($modulepart == 'user') |
77 | 77 | { |
78 | - $result=restrictedArea($user,'user',$id,'user'); |
|
79 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
80 | - $accessallowed=1; |
|
78 | + $result = restrictedArea($user, 'user', $id, 'user'); |
|
79 | + if (!$user->rights->user->user->lire) accessforbidden(); |
|
80 | + $accessallowed = 1; |
|
81 | 81 | } |
82 | 82 | elseif ($modulepart == 'societe') |
83 | 83 | { |
84 | - $result=restrictedArea($user,'societe',$id,'societe'); |
|
85 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
86 | - $accessallowed=1; |
|
84 | + $result = restrictedArea($user, 'societe', $id, 'societe'); |
|
85 | + if (!$user->rights->societe->lire) accessforbidden(); |
|
86 | + $accessallowed = 1; |
|
87 | 87 | } |
88 | 88 | elseif ($modulepart == 'tax') |
89 | 89 | { |
90 | - $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
91 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
92 | - $accessallowed=1; |
|
90 | + $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); |
|
91 | + if (!$user->rights->tax->charges->lire) accessforbidden(); |
|
92 | + $accessallowed = 1; |
|
93 | 93 | } |
94 | 94 | elseif ($modulepart == 'ticket') |
95 | 95 | { |
96 | - $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
97 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
98 | - $accessallowed=1; |
|
96 | + $result = restrictedArea($user, 'ticket', $id, 'ticket'); |
|
97 | + if (!$user->rights->ticket->read) accessforbidden(); |
|
98 | + $accessallowed = 1; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // Security: |
102 | 102 | // Limit access if permissions are wrong |
103 | -if (! $accessallowed) |
|
103 | +if (!$accessallowed) |
|
104 | 104 | { |
105 | 105 | accessforbidden(); |
106 | 106 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | if ($id > 0) |
114 | 114 | { |
115 | 115 | $result = $object->fetch($id); |
116 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
117 | - $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
118 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
119 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
116 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
117 | + $dir = $conf->product->multidir_output[$object->entity]; // By default |
|
118 | + if ($object->type == Product::TYPE_PRODUCT) $dir = $conf->product->multidir_output[$object->entity]; |
|
119 | + if ($object->type == Product::TYPE_SERVICE) $dir = $conf->service->multidir_output[$object->entity]; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | elseif ($modulepart == 'project') |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | if ($id > 0) |
127 | 127 | { |
128 | 128 | $result = $object->fetch($id); |
129 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
130 | - $dir=$conf->projet->dir_output; // By default |
|
129 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
130 | + $dir = $conf->projet->dir_output; // By default |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | elseif ($modulepart == 'holiday') |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | if ($id > 0) |
138 | 138 | { |
139 | 139 | $result = $object->fetch($id); |
140 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
141 | - $dir=$conf->holiday->dir_output; // By default |
|
140 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
141 | + $dir = $conf->holiday->dir_output; // By default |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | elseif ($modulepart == 'member') |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | if ($id > 0) |
149 | 149 | { |
150 | 150 | $result = $object->fetch($id); |
151 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
152 | - $dir=$conf->adherent->dir_output; // By default |
|
151 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
152 | + $dir = $conf->adherent->dir_output; // By default |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | elseif ($modulepart == 'societe') |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | if ($id > 0) |
160 | 160 | { |
161 | 161 | $result = $object->fetch($id); |
162 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
163 | - $dir=$conf->societe->dir_output; |
|
162 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
163 | + $dir = $conf->societe->dir_output; |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | elseif ($modulepart == 'user') |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | if ($id > 0) |
171 | 171 | { |
172 | 172 | $result = $object->fetch($id); |
173 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
174 | - $dir=$conf->user->dir_output; // By default |
|
173 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
174 | + $dir = $conf->user->dir_output; // By default |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | elseif ($modulepart == 'expensereport') |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | if ($id > 0) |
182 | 182 | { |
183 | 183 | $result = $object->fetch($id); |
184 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
185 | - $dir=$conf->expensereport->dir_output; // By default |
|
184 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
185 | + $dir = $conf->expensereport->dir_output; // By default |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | elseif ($modulepart == 'tax') |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | if ($id > 0) |
193 | 193 | { |
194 | 194 | $result = $object->fetch($id); |
195 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
196 | - $dir=$conf->tax->dir_output; // By default |
|
195 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
196 | + $dir = $conf->tax->dir_output; // By default |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | elseif ($modulepart == 'ticket') |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | if ($id > 0) |
204 | 204 | { |
205 | 205 | $result = $object->fetch($id); |
206 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
207 | - $dir=$conf->ticket->dir_output; // By default |
|
206 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
207 | + $dir = $conf->ticket->dir_output; // By default |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | else { |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | |
214 | 214 | if (empty($backtourl)) |
215 | 215 | { |
216 | - if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | - else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | - else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | - else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | - else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | - else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | - else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | - else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
224 | - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
216 | + if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | + else if (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | + else if (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | + else if (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | + else if (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | + else if (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | + else if (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | + else if (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
224 | + else if (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -245,20 +245,20 @@ discard block |
||
245 | 245 | |
246 | 246 | if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) |
247 | 247 | { |
248 | - $fullpath=$dir."/".$original_file; |
|
248 | + $fullpath = $dir."/".$original_file; |
|
249 | 249 | |
250 | - $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
250 | + $result = dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']); |
|
251 | 251 | |
252 | 252 | if ($result == $fullpath) |
253 | 253 | { |
254 | 254 | $object->addThumbs($fullpath); |
255 | 255 | |
256 | 256 | // Update/create database for file $fullpath |
257 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
258 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); |
|
258 | + $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); |
|
259 | 259 | |
260 | 260 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
261 | - $ecmfile=new EcmFiles($db); |
|
261 | + $ecmfile = new EcmFiles($db); |
|
262 | 262 | $result = $ecmfile->fetch(0, '', $rel_filename); |
263 | 263 | if ($result > 0) // If found |
264 | 264 | { |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | |
280 | 280 | $ecmfile->filepath = $rel_dir; |
281 | 281 | $ecmfile->filename = $filename; |
282 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
282 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
283 | 283 | $ecmfile->fullpath_orig = $fullpath; |
284 | 284 | $ecmfile->gen_or_uploaded = 'unknown'; |
285 | - $ecmfile->description = ''; // indexed content |
|
286 | - $ecmfile->keyword = ''; // keyword content |
|
285 | + $ecmfile->description = ''; // indexed content |
|
286 | + $ecmfile->keyword = ''; // keyword content |
|
287 | 287 | $result = $ecmfile->create($user); |
288 | 288 | if ($result < 0) |
289 | 289 | { |
@@ -306,29 +306,29 @@ discard block |
||
306 | 306 | else |
307 | 307 | { |
308 | 308 | setEventMessages($result, null, 'errors'); |
309 | - $_GET['file']=$_POST["file"]; |
|
310 | - $action=''; |
|
309 | + $_GET['file'] = $_POST["file"]; |
|
310 | + $action = ''; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Crop d'une image |
315 | 315 | if ($action == 'confirm_crop') |
316 | 316 | { |
317 | - $fullpath=$dir."/".$original_file; |
|
317 | + $fullpath = $dir."/".$original_file; |
|
318 | 318 | |
319 | 319 | //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
320 | - $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
320 | + $result = dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']); |
|
321 | 321 | |
322 | 322 | if ($result == $fullpath) |
323 | 323 | { |
324 | 324 | $object->addThumbs($fullpath); |
325 | 325 | |
326 | 326 | // Update/create database for file $fullpath |
327 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
328 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); |
|
328 | + $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); |
|
329 | 329 | |
330 | 330 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
331 | - $ecmfile=new EcmFiles($db); |
|
331 | + $ecmfile = new EcmFiles($db); |
|
332 | 332 | $result = $ecmfile->fetch(0, '', $rel_filename); |
333 | 333 | if ($result > 0) // If found |
334 | 334 | { |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | |
350 | 350 | $ecmfile->filepath = $rel_dir; |
351 | 351 | $ecmfile->filename = $filename; |
352 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
352 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
353 | 353 | $ecmfile->fullpath_orig = $fullpath; |
354 | 354 | $ecmfile->gen_or_uploaded = 'unknown'; |
355 | - $ecmfile->description = ''; // indexed content |
|
356 | - $ecmfile->keyword = ''; // keyword content |
|
355 | + $ecmfile->description = ''; // indexed content |
|
356 | + $ecmfile->keyword = ''; // keyword content |
|
357 | 357 | $result = $ecmfile->create($user); |
358 | 358 | if ($result < 0) |
359 | 359 | { |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | else |
377 | 377 | { |
378 | 378 | setEventMessages($result, null, 'errors'); |
379 | - $_GET['file']=$_POST["file"]; |
|
380 | - $action=''; |
|
379 | + $_GET['file'] = $_POST["file"]; |
|
380 | + $action = ''; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | * View |
387 | 387 | */ |
388 | 388 | |
389 | -llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js','/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css')); |
|
389 | +llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css')); |
|
390 | 390 | |
391 | 391 | |
392 | 392 | print load_fiche_titre($langs->trans("ImageEditor")); |
393 | 393 | |
394 | -$infoarray=dol_getImageSize($dir."/".GETPOST("file",'alpha')); |
|
395 | -$height=$infoarray['height']; |
|
396 | -$width=$infoarray['width']; |
|
394 | +$infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha')); |
|
395 | +$height = $infoarray['height']; |
|
396 | +$width = $infoarray['width']; |
|
397 | 397 | print $langs->trans("CurrentInformationOnImage").': '; |
398 | 398 | print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>'; |
399 | 399 | |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | |
434 | 434 | print '<br>'."\n"; |
435 | 435 | |
436 | -if (! empty($conf->use_javascript_ajax)) |
|
436 | +if (!empty($conf->use_javascript_ajax)) |
|
437 | 437 | { |
438 | - $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
439 | - $height=$infoarray['height']; |
|
440 | - $width=$infoarray['width']; |
|
441 | - $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
438 | + $infoarray = dol_getImageSize($dir."/".GETPOST("file")); |
|
439 | + $height = $infoarray['height']; |
|
440 | + $width = $infoarray['width']; |
|
441 | + $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1; |
|
442 | 442 | // If image is too large, we use another scale. |
443 | - if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
443 | + if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2))) |
|
444 | 444 | { |
445 | - $ratioforcrop=2; |
|
446 | - $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
447 | - $refsizeforcrop='screenwidth'; |
|
445 | + $ratioforcrop = 2; |
|
446 | + $widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
447 | + $refsizeforcrop = 'screenwidth'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | print '<!-- Form to crop -->'."\n"; |