@@ -34,288 +34,288 @@ discard block |
||
34 | 34 | class pdf_standard extends CommonStickerGenerator |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
39 | - * |
|
40 | - * @param PDF $pdf PDF reference |
|
41 | - * @param Translate $outputlangs Output langs |
|
42 | - * @param array $param Associative array containing label content and optional parameters |
|
43 | - * @return void |
|
44 | - */ |
|
37 | + /** |
|
38 | + * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
39 | + * |
|
40 | + * @param PDF $pdf PDF reference |
|
41 | + * @param Translate $outputlangs Output langs |
|
42 | + * @param array $param Associative array containing label content and optional parameters |
|
43 | + * @return void |
|
44 | + */ |
|
45 | 45 | function addSticker(&$pdf,$outputlangs,$param) |
46 | 46 | { |
47 | - // use this method in future refactoring |
|
48 | - } |
|
47 | + // use this method in future refactoring |
|
48 | + } |
|
49 | 49 | |
50 | 50 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
51 | - /** |
|
52 | - * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
53 | - * - __LOGO__ is replace with company logo |
|
54 | - * - __PHOTO__ is replace with photo provided as parameter |
|
55 | - * |
|
56 | - * @param PDF $pdf PDF |
|
57 | - * @param string $textleft Text left |
|
58 | - * @param string $header Header |
|
59 | - * @param string $footer Footer |
|
60 | - * @param Translate $outputlangs Output langs |
|
61 | - * @param string $textright Text right |
|
62 | - * @param int $idmember Id member |
|
63 | - * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
67 | - { |
|
51 | + /** |
|
52 | + * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
53 | + * - __LOGO__ is replace with company logo |
|
54 | + * - __PHOTO__ is replace with photo provided as parameter |
|
55 | + * |
|
56 | + * @param PDF $pdf PDF |
|
57 | + * @param string $textleft Text left |
|
58 | + * @param string $header Header |
|
59 | + * @param string $footer Footer |
|
60 | + * @param Translate $outputlangs Output langs |
|
61 | + * @param string $textright Text right |
|
62 | + * @param int $idmember Id member |
|
63 | + * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
67 | + { |
|
68 | 68 | // phpcs:enable |
69 | - global $db,$mysoc,$conf,$langs; |
|
70 | - global $forceimgscalewidth,$forceimgscaleheight; |
|
71 | - |
|
72 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | - $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
74 | - |
|
75 | - // We are in a new page, then we must add a page |
|
76 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
77 | - $pdf->AddPage(); |
|
78 | - } |
|
79 | - $this->_First=0; |
|
80 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
81 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
82 | - |
|
83 | - // Define logo |
|
84 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | - if (! is_readable($logo)) |
|
86 | - { |
|
87 | - $logo=''; |
|
88 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
89 | - { |
|
90 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
91 | - } |
|
92 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | - { |
|
94 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - $member=new Adherent($db); |
|
99 | - $member->id = $idmember; |
|
100 | - $member->ref = $idmember; |
|
101 | - |
|
102 | - // Define photo |
|
103 | - $dir=$conf->adherent->dir_output; |
|
104 | - if (! empty($photo)) |
|
105 | - { |
|
106 | - $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
107 | - $photo=$dir.'/'.$file; |
|
108 | - if (! is_readable($photo)) $photo=''; |
|
109 | - } |
|
110 | - |
|
111 | - // Define background image |
|
112 | - $backgroundimage=''; |
|
113 | - if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
114 | - { |
|
115 | - $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
116 | - } |
|
117 | - |
|
118 | - // Print lines |
|
119 | - if ($this->code == "CARD") |
|
120 | - { |
|
121 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
122 | - //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
|
123 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
124 | - } |
|
125 | - |
|
126 | - // Background |
|
127 | - if ($backgroundimage) |
|
128 | - { |
|
129 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
130 | - } |
|
131 | - |
|
132 | - $xleft=2; $ytop=2; |
|
133 | - |
|
134 | - // Top |
|
135 | - if ($header!='') |
|
136 | - { |
|
137 | - if ($this->code == "CARD") |
|
138 | - { |
|
139 | - $pdf->SetDrawColor(128,128,128); |
|
140 | - $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 |
|
141 | - $pdf->SetDrawColor(0,0,0); |
|
142 | - } |
|
143 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
144 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
149 | - |
|
150 | - // Define widthtouse and heighttouse |
|
151 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
152 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
153 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
154 | - $tmp=dol_getImageSize($photo, false); |
|
155 | - if ($tmp['height']) |
|
156 | - { |
|
157 | - $imgratio=$tmp['width']/$tmp['height']; |
|
158 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
159 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
160 | - } |
|
161 | - //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
|
162 | - |
|
163 | - // Center |
|
164 | - if ($textright=='') // Only a left part |
|
165 | - { |
|
166 | - // Output left area |
|
167 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
169 | - else |
|
170 | - { |
|
171 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
172 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
173 | - } |
|
174 | - } |
|
175 | - else if ($textleft!='' && $textright!='') // |
|
176 | - { |
|
177 | - if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
|
178 | - { |
|
179 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
180 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
181 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
182 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
183 | - } |
|
184 | - else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
185 | - { |
|
186 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
187 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
188 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
189 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
190 | - } |
|
191 | - else // text on halft left and text on half right |
|
192 | - { |
|
193 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
195 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
196 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
197 | - } |
|
198 | - } |
|
199 | - else // Only a right part |
|
200 | - { |
|
201 | - // Output right area |
|
202 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
203 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
204 | - else |
|
205 | - { |
|
206 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
207 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - // Bottom |
|
212 | - if ($footer!='') |
|
213 | - { |
|
214 | - if ($this->code == "CARD") |
|
215 | - { |
|
216 | - $pdf->SetDrawColor(128,128,128); |
|
217 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
218 | - $pdf->SetDrawColor(0,0,0); |
|
219 | - } |
|
220 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
221 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
222 | - } |
|
223 | - //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
|
224 | - |
|
225 | - $this->_COUNTY++; |
|
226 | - |
|
227 | - if ($this->_COUNTY == $this->_Y_Number) { |
|
228 | - // Si on est en bas de page, on remonte le 'curseur' de position |
|
229 | - $this->_COUNTX++; |
|
230 | - $this->_COUNTY=0; |
|
231 | - } |
|
232 | - |
|
233 | - if ($this->_COUNTX == $this->_X_Number) { |
|
234 | - // Si on est en bout de page, alors on repart sur une nouvelle page |
|
235 | - $this->_COUNTX=0; |
|
236 | - $this->_COUNTY=0; |
|
237 | - } |
|
238 | - } |
|
69 | + global $db,$mysoc,$conf,$langs; |
|
70 | + global $forceimgscalewidth,$forceimgscaleheight; |
|
71 | + |
|
72 | + $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | + $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
74 | + |
|
75 | + // We are in a new page, then we must add a page |
|
76 | + if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
77 | + $pdf->AddPage(); |
|
78 | + } |
|
79 | + $this->_First=0; |
|
80 | + $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
81 | + $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
82 | + |
|
83 | + // Define logo |
|
84 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | + if (! is_readable($logo)) |
|
86 | + { |
|
87 | + $logo=''; |
|
88 | + if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
89 | + { |
|
90 | + $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
91 | + } |
|
92 | + elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | + { |
|
94 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + $member=new Adherent($db); |
|
99 | + $member->id = $idmember; |
|
100 | + $member->ref = $idmember; |
|
101 | + |
|
102 | + // Define photo |
|
103 | + $dir=$conf->adherent->dir_output; |
|
104 | + if (! empty($photo)) |
|
105 | + { |
|
106 | + $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
107 | + $photo=$dir.'/'.$file; |
|
108 | + if (! is_readable($photo)) $photo=''; |
|
109 | + } |
|
110 | + |
|
111 | + // Define background image |
|
112 | + $backgroundimage=''; |
|
113 | + if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
114 | + { |
|
115 | + $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
116 | + } |
|
117 | + |
|
118 | + // Print lines |
|
119 | + if ($this->code == "CARD") |
|
120 | + { |
|
121 | + $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
122 | + //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
|
123 | + $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
124 | + } |
|
125 | + |
|
126 | + // Background |
|
127 | + if ($backgroundimage) |
|
128 | + { |
|
129 | + $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
130 | + } |
|
131 | + |
|
132 | + $xleft=2; $ytop=2; |
|
133 | + |
|
134 | + // Top |
|
135 | + if ($header!='') |
|
136 | + { |
|
137 | + if ($this->code == "CARD") |
|
138 | + { |
|
139 | + $pdf->SetDrawColor(128,128,128); |
|
140 | + $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 |
|
141 | + $pdf->SetDrawColor(0,0,0); |
|
142 | + } |
|
143 | + $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
144 | + $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
149 | + |
|
150 | + // Define widthtouse and heighttouse |
|
151 | + $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
152 | + $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
153 | + $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
154 | + $tmp=dol_getImageSize($photo, false); |
|
155 | + if ($tmp['height']) |
|
156 | + { |
|
157 | + $imgratio=$tmp['width']/$tmp['height']; |
|
158 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
159 | + else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
160 | + } |
|
161 | + //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
|
162 | + |
|
163 | + // Center |
|
164 | + if ($textright=='') // Only a left part |
|
165 | + { |
|
166 | + // Output left area |
|
167 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
169 | + else |
|
170 | + { |
|
171 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
172 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
173 | + } |
|
174 | + } |
|
175 | + else if ($textleft!='' && $textright!='') // |
|
176 | + { |
|
177 | + if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
|
178 | + { |
|
179 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
180 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
181 | + $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
182 | + $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
183 | + } |
|
184 | + else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
185 | + { |
|
186 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
187 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
188 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
189 | + $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
190 | + } |
|
191 | + else // text on halft left and text on half right |
|
192 | + { |
|
193 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | + $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
195 | + $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
196 | + $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
197 | + } |
|
198 | + } |
|
199 | + else // Only a right part |
|
200 | + { |
|
201 | + // Output right area |
|
202 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
203 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
204 | + else |
|
205 | + { |
|
206 | + $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
207 | + $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + // Bottom |
|
212 | + if ($footer!='') |
|
213 | + { |
|
214 | + if ($this->code == "CARD") |
|
215 | + { |
|
216 | + $pdf->SetDrawColor(128,128,128); |
|
217 | + $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
218 | + $pdf->SetDrawColor(0,0,0); |
|
219 | + } |
|
220 | + $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
221 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
222 | + } |
|
223 | + //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
|
224 | + |
|
225 | + $this->_COUNTY++; |
|
226 | + |
|
227 | + if ($this->_COUNTY == $this->_Y_Number) { |
|
228 | + // Si on est en bas de page, on remonte le 'curseur' de position |
|
229 | + $this->_COUNTX++; |
|
230 | + $this->_COUNTY=0; |
|
231 | + } |
|
232 | + |
|
233 | + if ($this->_COUNTX == $this->_X_Number) { |
|
234 | + // Si on est en bout de page, alors on repart sur une nouvelle page |
|
235 | + $this->_COUNTX=0; |
|
236 | + $this->_COUNTY=0; |
|
237 | + } |
|
238 | + } |
|
239 | 239 | |
240 | 240 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
241 | - /** |
|
242 | - * Function to build PDF on disk, then output on HTTP stream. |
|
243 | - * |
|
244 | - * @param Adherent $object Member object. Old usage: Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) |
|
245 | - * @param Translate $outputlangs Lang object for output language |
|
246 | - * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... |
|
247 | - * @param string $mode Tell if doc module is called for 'member', ... |
|
248 | - * @param int $nooutput 1=Generate only file on disk and do not return it on response |
|
249 | - * @return int 1=OK, 0=KO |
|
250 | - */ |
|
251 | - function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
252 | - { |
|
241 | + /** |
|
242 | + * Function to build PDF on disk, then output on HTTP stream. |
|
243 | + * |
|
244 | + * @param Adherent $object Member object. Old usage: Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) |
|
245 | + * @param Translate $outputlangs Lang object for output language |
|
246 | + * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... |
|
247 | + * @param string $mode Tell if doc module is called for 'member', ... |
|
248 | + * @param int $nooutput 1=Generate only file on disk and do not return it on response |
|
249 | + * @return int 1=OK, 0=KO |
|
250 | + */ |
|
251 | + function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
252 | + { |
|
253 | 253 | // phpcs:enable |
254 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
255 | - |
|
256 | - $this->code=$srctemplatepath; |
|
257 | - |
|
258 | - if (is_object($object)) |
|
259 | - { |
|
260 | - if ($object->country == '-') $object->country=''; |
|
261 | - |
|
262 | - // List of values to scan for a replacement |
|
263 | - $substitutionarray = array ( |
|
264 | - '__ID__'=>$object->rowid, |
|
265 | - '__LOGIN__'=>$object->login, |
|
266 | - '__FIRSTNAME__'=>$object->firstname, |
|
267 | - '__LASTNAME__'=>$object->lastname, |
|
268 | - '__FULLNAME__'=>$object->getFullName($langs), |
|
269 | - '__COMPANY__'=>$object->company, |
|
270 | - '__ADDRESS__'=>$object->address, |
|
271 | - '__ZIP__'=>$object->zip, |
|
272 | - '__TOWN__'=>$object->town, |
|
273 | - '__COUNTRY__'=>$object->country, |
|
274 | - '__COUNTRY_CODE__'=>$object->country_code, |
|
275 | - '__EMAIL__'=>$object->email, |
|
276 | - '__BIRTH__'=>dol_print_date($object->birth,'day'), |
|
277 | - '__TYPE__'=>$object->type, |
|
278 | - '__YEAR__'=>$year, |
|
279 | - '__MONTH__'=>$month, |
|
280 | - '__DAY__'=>$day, |
|
281 | - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, |
|
282 | - '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" |
|
283 | - ); |
|
284 | - complete_substitutions_array($substitutionarray, $langs); |
|
285 | - |
|
286 | - // For business cards |
|
287 | - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
291 | - |
|
292 | - $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
|
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
294 | - |
|
295 | - for($j=0;$j<$nb;$j++) |
|
296 | - { |
|
297 | - $arrayofmembers[]=array( |
|
298 | - 'textleft'=>$textleft, |
|
299 | - 'textheader'=>$textheader, |
|
300 | - 'textfooter'=>$textfooter, |
|
301 | - 'textright'=>$textright, |
|
302 | - 'id'=>$object->rowid, |
|
303 | - 'photo'=>$object->photo |
|
304 | - ); |
|
305 | - } |
|
306 | - |
|
307 | - $arrayofrecords = $arrayofmembers; |
|
308 | - } |
|
309 | - else |
|
310 | - { |
|
311 | - $arrayofrecords = $object; |
|
312 | - } |
|
313 | - |
|
314 | - //var_dump($arrayofrecords);exit; |
|
315 | - |
|
316 | - $this->Tformat = $_Avery_Labels[$this->code]; |
|
317 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
318 | - $this->type = 'pdf'; |
|
254 | + global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
255 | + |
|
256 | + $this->code=$srctemplatepath; |
|
257 | + |
|
258 | + if (is_object($object)) |
|
259 | + { |
|
260 | + if ($object->country == '-') $object->country=''; |
|
261 | + |
|
262 | + // List of values to scan for a replacement |
|
263 | + $substitutionarray = array ( |
|
264 | + '__ID__'=>$object->rowid, |
|
265 | + '__LOGIN__'=>$object->login, |
|
266 | + '__FIRSTNAME__'=>$object->firstname, |
|
267 | + '__LASTNAME__'=>$object->lastname, |
|
268 | + '__FULLNAME__'=>$object->getFullName($langs), |
|
269 | + '__COMPANY__'=>$object->company, |
|
270 | + '__ADDRESS__'=>$object->address, |
|
271 | + '__ZIP__'=>$object->zip, |
|
272 | + '__TOWN__'=>$object->town, |
|
273 | + '__COUNTRY__'=>$object->country, |
|
274 | + '__COUNTRY_CODE__'=>$object->country_code, |
|
275 | + '__EMAIL__'=>$object->email, |
|
276 | + '__BIRTH__'=>dol_print_date($object->birth,'day'), |
|
277 | + '__TYPE__'=>$object->type, |
|
278 | + '__YEAR__'=>$year, |
|
279 | + '__MONTH__'=>$month, |
|
280 | + '__DAY__'=>$day, |
|
281 | + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, |
|
282 | + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" |
|
283 | + ); |
|
284 | + complete_substitutions_array($substitutionarray, $langs); |
|
285 | + |
|
286 | + // For business cards |
|
287 | + $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | + $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | + $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | + $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
291 | + |
|
292 | + $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
|
293 | + if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
294 | + |
|
295 | + for($j=0;$j<$nb;$j++) |
|
296 | + { |
|
297 | + $arrayofmembers[]=array( |
|
298 | + 'textleft'=>$textleft, |
|
299 | + 'textheader'=>$textheader, |
|
300 | + 'textfooter'=>$textfooter, |
|
301 | + 'textright'=>$textright, |
|
302 | + 'id'=>$object->rowid, |
|
303 | + 'photo'=>$object->photo |
|
304 | + ); |
|
305 | + } |
|
306 | + |
|
307 | + $arrayofrecords = $arrayofmembers; |
|
308 | + } |
|
309 | + else |
|
310 | + { |
|
311 | + $arrayofrecords = $object; |
|
312 | + } |
|
313 | + |
|
314 | + //var_dump($arrayofrecords);exit; |
|
315 | + |
|
316 | + $this->Tformat = $_Avery_Labels[$this->code]; |
|
317 | + if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
318 | + $this->type = 'pdf'; |
|
319 | 319 | // standard format or custom |
320 | 320 | if ($this->Tformat['paper-size']!='custom') { |
321 | 321 | $this->format = $this->Tformat['paper-size']; |
@@ -325,124 +325,124 @@ discard block |
||
325 | 325 | $this->format = $resolution; |
326 | 326 | } |
327 | 327 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
329 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
330 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
331 | - |
|
332 | - // Load traductions files requiredby by page |
|
333 | - $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
|
334 | - |
|
335 | - if (empty($mode) || $mode == 'member') |
|
336 | - { |
|
337 | - $title=$outputlangs->transnoentities('MembersCards'); |
|
338 | - $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
339 | - } |
|
340 | - else |
|
341 | - { |
|
342 | - dol_print_error('','Bad value for $mode'); |
|
343 | - return -1; |
|
344 | - } |
|
345 | - |
|
346 | - $filename = 'tmp_cards.pdf'; |
|
347 | - if (is_object($object)) |
|
348 | - { |
|
349 | - $outputdir = $conf->adherent->dir_output; |
|
350 | - $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
|
351 | - $file = $dir.'/'.$filename; |
|
352 | - } |
|
353 | - else |
|
354 | - { |
|
355 | - $outputdir = $conf->adherent->dir_temp; |
|
356 | - $dir = $outputdir; |
|
357 | - $file = $dir.'/'.$filename; |
|
358 | - } |
|
359 | - |
|
360 | - //var_dump($file);exit; |
|
361 | - |
|
362 | - if (! file_exists($dir)) |
|
363 | - { |
|
364 | - if (dol_mkdir($dir) < 0) |
|
365 | - { |
|
366 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
367 | - return 0; |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
372 | - |
|
373 | - if (class_exists('TCPDF')) |
|
374 | - { |
|
375 | - $pdf->setPrintHeader(false); |
|
376 | - $pdf->setPrintFooter(false); |
|
377 | - } |
|
378 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
379 | - |
|
380 | - $pdf->SetTitle($title); |
|
381 | - $pdf->SetSubject($title); |
|
382 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
383 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
384 | - $pdf->SetKeyWords($keywords); |
|
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
386 | - |
|
387 | - $pdf->SetMargins(0,0); |
|
388 | - $pdf->SetAutoPageBreak(false); |
|
389 | - |
|
390 | - $this->_Metric_Doc = $this->Tformat['metric']; |
|
391 | - // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
|
392 | - $posX=1; |
|
393 | - $posY=1; |
|
394 | - if ($posX > 0) $posX--; else $posX=0; |
|
395 | - if ($posY > 0) $posY--; else $posY=0; |
|
396 | - $this->_COUNTX = $posX; |
|
397 | - $this->_COUNTY = $posY; |
|
398 | - $this->_Set_Format($pdf, $this->Tformat); |
|
399 | - |
|
400 | - |
|
401 | - $pdf->Open(); |
|
402 | - $pdf->AddPage(); |
|
403 | - |
|
404 | - |
|
405 | - // Add each record |
|
406 | - foreach($arrayofrecords as $val) |
|
407 | - { |
|
408 | - // imprime le texte specifique sur la carte |
|
409 | - $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']); |
|
410 | - } |
|
411 | - |
|
412 | - //$pdf->SetXY(10, 295); |
|
413 | - //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C'); |
|
414 | - |
|
415 | - |
|
416 | - // Output to file |
|
417 | - $pdf->Output($file,'F'); |
|
418 | - |
|
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
420 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
421 | - |
|
422 | - |
|
423 | - $this->result = array('fullpath'=>$file); |
|
424 | - |
|
425 | - // Output to http stream |
|
426 | - if (empty($nooutput)) |
|
427 | - { |
|
428 | - clearstatcache(); |
|
429 | - |
|
430 | - $attachment=true; |
|
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
432 | - $type=dol_mimetype($filename); |
|
433 | - |
|
434 | - //if ($encoding) header('Content-Encoding: '.$encoding); |
|
435 | - if ($type) header('Content-Type: '.$type); |
|
436 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
437 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
438 | - |
|
439 | - // Ajout directives pour resoudre bug IE |
|
440 | - header('Cache-Control: Public, must-revalidate'); |
|
441 | - header('Pragma: public'); |
|
442 | - |
|
443 | - readfile($file); |
|
444 | - } |
|
445 | - |
|
446 | - return 1; |
|
447 | - } |
|
328 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
329 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
330 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
331 | + |
|
332 | + // Load traductions files requiredby by page |
|
333 | + $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
|
334 | + |
|
335 | + if (empty($mode) || $mode == 'member') |
|
336 | + { |
|
337 | + $title=$outputlangs->transnoentities('MembersCards'); |
|
338 | + $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
339 | + } |
|
340 | + else |
|
341 | + { |
|
342 | + dol_print_error('','Bad value for $mode'); |
|
343 | + return -1; |
|
344 | + } |
|
345 | + |
|
346 | + $filename = 'tmp_cards.pdf'; |
|
347 | + if (is_object($object)) |
|
348 | + { |
|
349 | + $outputdir = $conf->adherent->dir_output; |
|
350 | + $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
|
351 | + $file = $dir.'/'.$filename; |
|
352 | + } |
|
353 | + else |
|
354 | + { |
|
355 | + $outputdir = $conf->adherent->dir_temp; |
|
356 | + $dir = $outputdir; |
|
357 | + $file = $dir.'/'.$filename; |
|
358 | + } |
|
359 | + |
|
360 | + //var_dump($file);exit; |
|
361 | + |
|
362 | + if (! file_exists($dir)) |
|
363 | + { |
|
364 | + if (dol_mkdir($dir) < 0) |
|
365 | + { |
|
366 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
367 | + return 0; |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
372 | + |
|
373 | + if (class_exists('TCPDF')) |
|
374 | + { |
|
375 | + $pdf->setPrintHeader(false); |
|
376 | + $pdf->setPrintFooter(false); |
|
377 | + } |
|
378 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
379 | + |
|
380 | + $pdf->SetTitle($title); |
|
381 | + $pdf->SetSubject($title); |
|
382 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
383 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
384 | + $pdf->SetKeyWords($keywords); |
|
385 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
386 | + |
|
387 | + $pdf->SetMargins(0,0); |
|
388 | + $pdf->SetAutoPageBreak(false); |
|
389 | + |
|
390 | + $this->_Metric_Doc = $this->Tformat['metric']; |
|
391 | + // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
|
392 | + $posX=1; |
|
393 | + $posY=1; |
|
394 | + if ($posX > 0) $posX--; else $posX=0; |
|
395 | + if ($posY > 0) $posY--; else $posY=0; |
|
396 | + $this->_COUNTX = $posX; |
|
397 | + $this->_COUNTY = $posY; |
|
398 | + $this->_Set_Format($pdf, $this->Tformat); |
|
399 | + |
|
400 | + |
|
401 | + $pdf->Open(); |
|
402 | + $pdf->AddPage(); |
|
403 | + |
|
404 | + |
|
405 | + // Add each record |
|
406 | + foreach($arrayofrecords as $val) |
|
407 | + { |
|
408 | + // imprime le texte specifique sur la carte |
|
409 | + $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']); |
|
410 | + } |
|
411 | + |
|
412 | + //$pdf->SetXY(10, 295); |
|
413 | + //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C'); |
|
414 | + |
|
415 | + |
|
416 | + // Output to file |
|
417 | + $pdf->Output($file,'F'); |
|
418 | + |
|
419 | + if (! empty($conf->global->MAIN_UMASK)) |
|
420 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
421 | + |
|
422 | + |
|
423 | + $this->result = array('fullpath'=>$file); |
|
424 | + |
|
425 | + // Output to http stream |
|
426 | + if (empty($nooutput)) |
|
427 | + { |
|
428 | + clearstatcache(); |
|
429 | + |
|
430 | + $attachment=true; |
|
431 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
432 | + $type=dol_mimetype($filename); |
|
433 | + |
|
434 | + //if ($encoding) header('Content-Encoding: '.$encoding); |
|
435 | + if ($type) header('Content-Type: '.$type); |
|
436 | + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
437 | + else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
438 | + |
|
439 | + // Ajout directives pour resoudre bug IE |
|
440 | + header('Cache-Control: Public, must-revalidate'); |
|
441 | + header('Pragma: public'); |
|
442 | + |
|
443 | + readfile($file); |
|
444 | + } |
|
445 | + |
|
446 | + return 1; |
|
447 | + } |
|
448 | 448 | } |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class ModelePDFCards |
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 | - * |
|
47 | - * @param DoliDB $db Database handler |
|
48 | - * @param integer $maxfilenamelength Max length of value to show |
|
49 | - * @return array List of templates |
|
50 | - */ |
|
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
52 | - { |
|
44 | + /** |
|
45 | + * Return list of active generation modules |
|
46 | + * |
|
47 | + * @param DoliDB $db Database handler |
|
48 | + * @param integer $maxfilenamelength Max length of value to show |
|
49 | + * @return array List of templates |
|
50 | + */ |
|
51 | + function liste_modeles($db,$maxfilenamelength=0) |
|
52 | + { |
|
53 | 53 | // phpcs:enable |
54 | - global $conf; |
|
54 | + global $conf; |
|
55 | 55 | |
56 | - $type='member'; |
|
57 | - $liste=array(); |
|
56 | + $type='member'; |
|
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 | |
@@ -79,92 +79,92 @@ discard block |
||
79 | 79 | function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard') |
80 | 80 | { |
81 | 81 | // phpcs:enable |
82 | - global $conf,$langs; |
|
83 | - $langs->load("members"); |
|
84 | - |
|
85 | - $error=0; |
|
86 | - |
|
87 | - // Increase limit for PDF build |
|
88 | - $err=error_reporting(); |
|
89 | - error_reporting(0); |
|
90 | - @set_time_limit(120); |
|
91 | - error_reporting($err); |
|
92 | - |
|
93 | - $code=''; |
|
94 | - $srctemplatepath=''; |
|
95 | - |
|
96 | - // Positionne le modele sur le nom du modele a utiliser |
|
97 | - if (! dol_strlen($modele)) |
|
98 | - { |
|
99 | - if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
100 | - { |
|
101 | - $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
|
102 | - } |
|
103 | - else |
|
104 | - { |
|
105 | - $code = $modele; |
|
106 | - } |
|
107 | - } |
|
108 | - else $code=$modele; |
|
109 | - |
|
110 | - // If selected modele is a filename template (then $modele="modelname:filename") |
|
111 | - $tmp=explode(':',$template,2); |
|
112 | - if (! empty($tmp[1])) |
|
113 | - { |
|
114 | - $template=$tmp[0]; |
|
115 | - $srctemplatepath=$tmp[1]; |
|
116 | - } |
|
117 | - else $srctemplatepath=$code; |
|
118 | - |
|
119 | - // Search template files |
|
120 | - $file=''; $classname=''; $filefound=0; |
|
121 | - $dirmodels=array('/'); |
|
122 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | - foreach($dirmodels as $reldir) |
|
124 | - { |
|
125 | - foreach(array('doc','pdf') as $prefix) |
|
126 | - { |
|
127 | - $file = $prefix."_".$template.".class.php"; |
|
128 | - |
|
129 | - // On verifie l'emplacement du modele |
|
130 | - $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0); |
|
131 | - if (file_exists($file)) |
|
132 | - { |
|
133 | - $filefound=1; |
|
134 | - $classname=$prefix.'_'.$template; |
|
135 | - break; |
|
136 | - } |
|
137 | - } |
|
138 | - if ($filefound) break; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - // Charge le modele |
|
143 | - if ($filefound) |
|
144 | - { |
|
145 | - require_once $file; |
|
146 | - |
|
147 | - $obj = new $classname($db); |
|
148 | - |
|
149 | - // We save charset_output to restore it because write_file can change it if needed for |
|
150 | - // output format that does not support UTF8. |
|
151 | - $sav_charset_output=$outputlangs->charset_output; |
|
152 | - if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) |
|
153 | - { |
|
154 | - $outputlangs->charset_output=$sav_charset_output; |
|
155 | - return 1; |
|
156 | - } |
|
157 | - else |
|
158 | - { |
|
159 | - $outputlangs->charset_output=$sav_charset_output; |
|
160 | - dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
|
161 | - return -1; |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - else |
|
166 | - { |
|
167 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
168 | - return -1; |
|
169 | - } |
|
82 | + global $conf,$langs; |
|
83 | + $langs->load("members"); |
|
84 | + |
|
85 | + $error=0; |
|
86 | + |
|
87 | + // Increase limit for PDF build |
|
88 | + $err=error_reporting(); |
|
89 | + error_reporting(0); |
|
90 | + @set_time_limit(120); |
|
91 | + error_reporting($err); |
|
92 | + |
|
93 | + $code=''; |
|
94 | + $srctemplatepath=''; |
|
95 | + |
|
96 | + // Positionne le modele sur le nom du modele a utiliser |
|
97 | + if (! dol_strlen($modele)) |
|
98 | + { |
|
99 | + if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
100 | + { |
|
101 | + $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
105 | + $code = $modele; |
|
106 | + } |
|
107 | + } |
|
108 | + else $code=$modele; |
|
109 | + |
|
110 | + // If selected modele is a filename template (then $modele="modelname:filename") |
|
111 | + $tmp=explode(':',$template,2); |
|
112 | + if (! empty($tmp[1])) |
|
113 | + { |
|
114 | + $template=$tmp[0]; |
|
115 | + $srctemplatepath=$tmp[1]; |
|
116 | + } |
|
117 | + else $srctemplatepath=$code; |
|
118 | + |
|
119 | + // Search template files |
|
120 | + $file=''; $classname=''; $filefound=0; |
|
121 | + $dirmodels=array('/'); |
|
122 | + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | + foreach($dirmodels as $reldir) |
|
124 | + { |
|
125 | + foreach(array('doc','pdf') as $prefix) |
|
126 | + { |
|
127 | + $file = $prefix."_".$template.".class.php"; |
|
128 | + |
|
129 | + // On verifie l'emplacement du modele |
|
130 | + $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0); |
|
131 | + if (file_exists($file)) |
|
132 | + { |
|
133 | + $filefound=1; |
|
134 | + $classname=$prefix.'_'.$template; |
|
135 | + break; |
|
136 | + } |
|
137 | + } |
|
138 | + if ($filefound) break; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + // Charge le modele |
|
143 | + if ($filefound) |
|
144 | + { |
|
145 | + require_once $file; |
|
146 | + |
|
147 | + $obj = new $classname($db); |
|
148 | + |
|
149 | + // We save charset_output to restore it because write_file can change it if needed for |
|
150 | + // output format that does not support UTF8. |
|
151 | + $sav_charset_output=$outputlangs->charset_output; |
|
152 | + if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) |
|
153 | + { |
|
154 | + $outputlangs->charset_output=$sav_charset_output; |
|
155 | + return 1; |
|
156 | + } |
|
157 | + else |
|
158 | + { |
|
159 | + $outputlangs->charset_output=$sav_charset_output; |
|
160 | + dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
|
161 | + return -1; |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + else |
|
166 | + { |
|
167 | + dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
168 | + return -1; |
|
169 | + } |
|
170 | 170 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | { |
39 | 39 | |
40 | 40 | /** |
41 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
42 | - * |
|
43 | - * @param DoliDB $db Database handler |
|
41 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
42 | + * |
|
43 | + * @param DoliDB $db Database handler |
|
44 | 44 | */ |
45 | 45 | function __construct($db) |
46 | 46 | { |
@@ -161,32 +161,32 @@ discard block |
||
161 | 161 | $this->export_label[$r]='InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
162 | 162 | $this->export_permission[$r]=array(array("ficheinter","export")); |
163 | 163 | $this->export_fields_array[$r]=array( |
164 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', |
|
165 | - 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', |
|
166 | - 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation", |
|
167 | - 'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId', |
|
168 | - 'fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc" |
|
169 | - ); |
|
164 | + 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', |
|
165 | + 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', |
|
166 | + 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation", |
|
167 | + 'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId', |
|
168 | + 'fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc" |
|
169 | + ); |
|
170 | 170 | //$this->export_TypeFields_array[$r]=array( |
171 | - // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', |
|
172 | - // 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text', |
|
173 | - // 's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text", |
|
174 | - // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", |
|
175 | - // 'fd.total_ht'=>"Numeric" |
|
176 | - //); |
|
171 | + // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', |
|
172 | + // 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text', |
|
173 | + // 's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text", |
|
174 | + // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", |
|
175 | + // 'fd.total_ht'=>"Numeric" |
|
176 | + //); |
|
177 | 177 | $this->export_TypeFields_array[$r]=array( |
178 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text', |
|
179 | - 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date", |
|
180 | - 'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', |
|
181 | - 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric" |
|
182 | - ); |
|
178 | + 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text', |
|
179 | + 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date", |
|
180 | + 'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', |
|
181 | + 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric" |
|
182 | + ); |
|
183 | 183 | $this->export_entities_array[$r]=array( |
184 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', |
|
185 | - 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company', |
|
186 | - 's.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention", |
|
187 | - 'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line", |
|
188 | - 'fd.duree'=>'inter_line','fd.description'=>'inter_line' |
|
189 | - ); |
|
184 | + 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', |
|
185 | + 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company', |
|
186 | + 's.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention", |
|
187 | + 'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line", |
|
188 | + 'fd.duree'=>'inter_line','fd.description'=>'inter_line' |
|
189 | + ); |
|
190 | 190 | $this->export_dependencies_array[$r]=array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
191 | 191 | |
192 | 192 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | |
202 | 202 | |
203 | 203 | /** |
204 | - * Function called when module is enabled. |
|
205 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
206 | - * It also creates data directories |
|
207 | - * |
|
204 | + * Function called when module is enabled. |
|
205 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
206 | + * It also creates data directories |
|
207 | + * |
|
208 | 208 | * @param string $options Options when enabling module ('', 'noboxes') |
209 | - * @return int 1 if OK, 0 if KO |
|
209 | + * @return int 1 if OK, 0 if KO |
|
210 | 210 | */ |
211 | 211 | function init($options='') |
212 | 212 | { |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | $this->remove($options); |
217 | 217 | |
218 | 218 | $sql = array( |
219 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".$conf->entity, |
|
220 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")", |
|
219 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".$conf->entity, |
|
220 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")", |
|
221 | 221 | ); |
222 | 222 | |
223 | 223 | return $this->_init($sql,$options); |
@@ -36,319 +36,319 @@ |
||
36 | 36 | class modExpedition extends DolibarrModules |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - global $conf, $user; |
|
47 | - |
|
48 | - $this->db = $db; |
|
49 | - $this->numero = 80; |
|
50 | - |
|
51 | - $this->family = "crm"; |
|
52 | - $this->module_position = '40'; |
|
53 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | - $this->description = "Gestion des expeditions"; |
|
56 | - |
|
57 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | - $this->version = 'dolibarr'; |
|
59 | - |
|
60 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | - $this->picto = "sending"; |
|
62 | - |
|
63 | - // Data directories to create when module is enabled |
|
64 | - $this->dirs = array("/expedition/temp", |
|
65 | - "/expedition/sending", |
|
66 | - "/expedition/sending/temp", |
|
67 | - "/expedition/receipt", |
|
68 | - "/expedition/receipt/temp", |
|
69 | - "/doctemplates/shipment", |
|
70 | - "/doctemplates/delivery" |
|
71 | - ); |
|
72 | - |
|
73 | - // Config pages |
|
74 | - $this->config_page_url = array("confexped.php"); |
|
75 | - |
|
76 | - // Dependencies |
|
77 | - $this->depends = array("modCommande"); |
|
78 | - $this->requiredby = array(); |
|
79 | - $this->conflictwith = array(); |
|
80 | - $this->langfiles = array('deliveries','sendings'); |
|
81 | - |
|
82 | - // Constants |
|
83 | - $this->const = array(); |
|
84 | - $r=0; |
|
85 | - |
|
86 | - $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; |
|
87 | - $this->const[$r][1] = "chaine"; |
|
88 | - $this->const[$r][2] = "rouget"; |
|
89 | - $this->const[$r][3] = 'Nom du gestionnaire de generation des bons expeditions en PDF'; |
|
90 | - $this->const[$r][4] = 0; |
|
91 | - $r++; |
|
92 | - |
|
93 | - $this->const[$r][0] = "EXPEDITION_ADDON_NUMBER"; |
|
94 | - $this->const[$r][1] = "chaine"; |
|
95 | - $this->const[$r][2] = "mod_expedition_safor"; |
|
96 | - $this->const[$r][3] = 'Name for numbering manager for shipments'; |
|
97 | - $this->const[$r][4] = 0; |
|
98 | - $r++; |
|
99 | - |
|
100 | - $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH"; |
|
101 | - $this->const[$r][1] = "chaine"; |
|
102 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipment"; |
|
103 | - $this->const[$r][3] = ""; |
|
104 | - $this->const[$r][4] = 0; |
|
105 | - $r++; |
|
106 | - |
|
107 | - $this->const[$r][0] = "LIVRAISON_ADDON_PDF"; |
|
108 | - $this->const[$r][1] = "chaine"; |
|
109 | - $this->const[$r][2] = "typhon"; |
|
110 | - $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de reception en PDF'; |
|
111 | - $this->const[$r][4] = 0; |
|
112 | - $r++; |
|
113 | - |
|
114 | - $this->const[$r][0] = "LIVRAISON_ADDON_NUMBER"; |
|
115 | - $this->const[$r][1] = "chaine"; |
|
116 | - $this->const[$r][2] = "mod_livraison_jade"; |
|
117 | - $this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception'; |
|
118 | - $this->const[$r][4] = 0; |
|
119 | - $r++; |
|
120 | - |
|
121 | - $this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH"; |
|
122 | - $this->const[$r][1] = "chaine"; |
|
123 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; |
|
124 | - $this->const[$r][3] = ""; |
|
125 | - $this->const[$r][4] = 0; |
|
126 | - $r++; |
|
127 | - |
|
128 | - $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; |
|
129 | - $this->const[$r][1] = "chaine"; |
|
130 | - $this->const[$r][2] = "1"; |
|
131 | - $this->const[$r][3] = "Enable shipments"; |
|
132 | - $this->const[$r][4] = 0; |
|
133 | - $r++; |
|
134 | - |
|
135 | - // Boxes |
|
136 | - $this->boxes = array(); |
|
137 | - |
|
138 | - // Permissions |
|
139 | - $this->rights = array(); |
|
140 | - $this->rights_class = 'expedition'; |
|
141 | - $r=0; |
|
142 | - |
|
143 | - $r++; |
|
144 | - $this->rights[$r][0] = 101; |
|
145 | - $this->rights[$r][1] = 'Lire les expeditions'; |
|
146 | - $this->rights[$r][2] = 'r'; |
|
147 | - $this->rights[$r][3] = 0; |
|
148 | - $this->rights[$r][4] = 'lire'; |
|
149 | - |
|
150 | - $r++; |
|
151 | - $this->rights[$r][0] = 102; |
|
152 | - $this->rights[$r][1] = 'Creer modifier les expeditions'; |
|
153 | - $this->rights[$r][2] = 'w'; |
|
154 | - $this->rights[$r][3] = 0; |
|
155 | - $this->rights[$r][4] = 'creer'; |
|
156 | - |
|
157 | - $r++; |
|
158 | - $this->rights[$r][0] = 104; |
|
159 | - $this->rights[$r][1] = 'Valider les expeditions'; |
|
160 | - $this->rights[$r][2] = 'd'; |
|
161 | - $this->rights[$r][3] = 0; |
|
162 | - $this->rights[$r][4] = 'shipping_advance'; |
|
163 | - $this->rights[$r][5] = 'validate'; |
|
164 | - |
|
165 | - $r++; |
|
166 | - $this->rights[$r][0] = 105; // id de la permission |
|
167 | - $this->rights[$r][1] = 'Envoyer les expeditions aux clients'; // libelle de la permission |
|
168 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
169 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
170 | - $this->rights[$r][4] = 'shipping_advance'; |
|
39 | + /** |
|
40 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + global $conf, $user; |
|
47 | + |
|
48 | + $this->db = $db; |
|
49 | + $this->numero = 80; |
|
50 | + |
|
51 | + $this->family = "crm"; |
|
52 | + $this->module_position = '40'; |
|
53 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->description = "Gestion des expeditions"; |
|
56 | + |
|
57 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | + $this->version = 'dolibarr'; |
|
59 | + |
|
60 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | + $this->picto = "sending"; |
|
62 | + |
|
63 | + // Data directories to create when module is enabled |
|
64 | + $this->dirs = array("/expedition/temp", |
|
65 | + "/expedition/sending", |
|
66 | + "/expedition/sending/temp", |
|
67 | + "/expedition/receipt", |
|
68 | + "/expedition/receipt/temp", |
|
69 | + "/doctemplates/shipment", |
|
70 | + "/doctemplates/delivery" |
|
71 | + ); |
|
72 | + |
|
73 | + // Config pages |
|
74 | + $this->config_page_url = array("confexped.php"); |
|
75 | + |
|
76 | + // Dependencies |
|
77 | + $this->depends = array("modCommande"); |
|
78 | + $this->requiredby = array(); |
|
79 | + $this->conflictwith = array(); |
|
80 | + $this->langfiles = array('deliveries','sendings'); |
|
81 | + |
|
82 | + // Constants |
|
83 | + $this->const = array(); |
|
84 | + $r=0; |
|
85 | + |
|
86 | + $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; |
|
87 | + $this->const[$r][1] = "chaine"; |
|
88 | + $this->const[$r][2] = "rouget"; |
|
89 | + $this->const[$r][3] = 'Nom du gestionnaire de generation des bons expeditions en PDF'; |
|
90 | + $this->const[$r][4] = 0; |
|
91 | + $r++; |
|
92 | + |
|
93 | + $this->const[$r][0] = "EXPEDITION_ADDON_NUMBER"; |
|
94 | + $this->const[$r][1] = "chaine"; |
|
95 | + $this->const[$r][2] = "mod_expedition_safor"; |
|
96 | + $this->const[$r][3] = 'Name for numbering manager for shipments'; |
|
97 | + $this->const[$r][4] = 0; |
|
98 | + $r++; |
|
99 | + |
|
100 | + $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH"; |
|
101 | + $this->const[$r][1] = "chaine"; |
|
102 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipment"; |
|
103 | + $this->const[$r][3] = ""; |
|
104 | + $this->const[$r][4] = 0; |
|
105 | + $r++; |
|
106 | + |
|
107 | + $this->const[$r][0] = "LIVRAISON_ADDON_PDF"; |
|
108 | + $this->const[$r][1] = "chaine"; |
|
109 | + $this->const[$r][2] = "typhon"; |
|
110 | + $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de reception en PDF'; |
|
111 | + $this->const[$r][4] = 0; |
|
112 | + $r++; |
|
113 | + |
|
114 | + $this->const[$r][0] = "LIVRAISON_ADDON_NUMBER"; |
|
115 | + $this->const[$r][1] = "chaine"; |
|
116 | + $this->const[$r][2] = "mod_livraison_jade"; |
|
117 | + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception'; |
|
118 | + $this->const[$r][4] = 0; |
|
119 | + $r++; |
|
120 | + |
|
121 | + $this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH"; |
|
122 | + $this->const[$r][1] = "chaine"; |
|
123 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; |
|
124 | + $this->const[$r][3] = ""; |
|
125 | + $this->const[$r][4] = 0; |
|
126 | + $r++; |
|
127 | + |
|
128 | + $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; |
|
129 | + $this->const[$r][1] = "chaine"; |
|
130 | + $this->const[$r][2] = "1"; |
|
131 | + $this->const[$r][3] = "Enable shipments"; |
|
132 | + $this->const[$r][4] = 0; |
|
133 | + $r++; |
|
134 | + |
|
135 | + // Boxes |
|
136 | + $this->boxes = array(); |
|
137 | + |
|
138 | + // Permissions |
|
139 | + $this->rights = array(); |
|
140 | + $this->rights_class = 'expedition'; |
|
141 | + $r=0; |
|
142 | + |
|
143 | + $r++; |
|
144 | + $this->rights[$r][0] = 101; |
|
145 | + $this->rights[$r][1] = 'Lire les expeditions'; |
|
146 | + $this->rights[$r][2] = 'r'; |
|
147 | + $this->rights[$r][3] = 0; |
|
148 | + $this->rights[$r][4] = 'lire'; |
|
149 | + |
|
150 | + $r++; |
|
151 | + $this->rights[$r][0] = 102; |
|
152 | + $this->rights[$r][1] = 'Creer modifier les expeditions'; |
|
153 | + $this->rights[$r][2] = 'w'; |
|
154 | + $this->rights[$r][3] = 0; |
|
155 | + $this->rights[$r][4] = 'creer'; |
|
156 | + |
|
157 | + $r++; |
|
158 | + $this->rights[$r][0] = 104; |
|
159 | + $this->rights[$r][1] = 'Valider les expeditions'; |
|
160 | + $this->rights[$r][2] = 'd'; |
|
161 | + $this->rights[$r][3] = 0; |
|
162 | + $this->rights[$r][4] = 'shipping_advance'; |
|
163 | + $this->rights[$r][5] = 'validate'; |
|
164 | + |
|
165 | + $r++; |
|
166 | + $this->rights[$r][0] = 105; // id de la permission |
|
167 | + $this->rights[$r][1] = 'Envoyer les expeditions aux clients'; // libelle de la permission |
|
168 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
169 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
170 | + $this->rights[$r][4] = 'shipping_advance'; |
|
171 | 171 | $this->rights[$r][5] = 'send'; |
172 | 172 | |
173 | - $r++; |
|
174 | - $this->rights[$r][0] = 106; |
|
175 | - $this->rights[$r][1] = 'Exporter les expeditions'; |
|
176 | - $this->rights[$r][2] = 'r'; |
|
177 | - $this->rights[$r][3] = 0; |
|
178 | - $this->rights[$r][4] = 'shipment'; |
|
179 | - $this->rights[$r][5] = 'export'; |
|
180 | - |
|
181 | - $r++; |
|
182 | - $this->rights[$r][0] = 109; |
|
183 | - $this->rights[$r][1] = 'Supprimer les expeditions'; |
|
184 | - $this->rights[$r][2] = 'd'; |
|
185 | - $this->rights[$r][3] = 0; |
|
186 | - $this->rights[$r][4] = 'supprimer'; |
|
187 | - |
|
188 | - $r++; |
|
189 | - $this->rights[$r][0] = 1101; |
|
190 | - $this->rights[$r][1] = 'Lire les bons de livraison'; |
|
191 | - $this->rights[$r][2] = 'r'; |
|
192 | - $this->rights[$r][3] = 0; |
|
193 | - $this->rights[$r][4] = 'livraison'; |
|
194 | - $this->rights[$r][5] = 'lire'; |
|
195 | - |
|
196 | - $r++; |
|
197 | - $this->rights[$r][0] = 1102; |
|
198 | - $this->rights[$r][1] = 'Creer modifier les bons de livraison'; |
|
199 | - $this->rights[$r][2] = 'w'; |
|
200 | - $this->rights[$r][3] = 0; |
|
201 | - $this->rights[$r][4] = 'livraison'; |
|
202 | - $this->rights[$r][5] = 'creer'; |
|
203 | - |
|
204 | - $r++; |
|
205 | - $this->rights[$r][0] = 1104; |
|
206 | - $this->rights[$r][1] = 'Valider les bons de livraison'; |
|
207 | - $this->rights[$r][2] = 'd'; |
|
208 | - $this->rights[$r][3] = 0; |
|
209 | - $this->rights[$r][4] = 'livraison_advance'; |
|
210 | - $this->rights[$r][5] = 'validate'; |
|
211 | - |
|
212 | - $r++; |
|
213 | - $this->rights[$r][0] = 1109; |
|
214 | - $this->rights[$r][1] = 'Supprimer les bons de livraison'; |
|
215 | - $this->rights[$r][2] = 'd'; |
|
216 | - $this->rights[$r][3] = 0; |
|
217 | - $this->rights[$r][4] = 'livraison'; |
|
218 | - $this->rights[$r][5] = 'supprimer'; |
|
219 | - |
|
220 | - |
|
221 | - // Menus |
|
222 | - //------- |
|
223 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
224 | - |
|
225 | - |
|
226 | - // Exports |
|
227 | - //-------- |
|
228 | - $r=0; |
|
229 | - |
|
230 | - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
231 | - $shipment=new Commande($this->db); |
|
232 | - $contact_arrays=$shipment->liste_type_contact('external','',0,0,''); |
|
233 | - if (is_array($contact_arrays) && count($contact_arrays)>0){ |
|
234 | - $idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,''))); |
|
235 | - } else { |
|
236 | - $idcontacts=0; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - $r++; |
|
241 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
242 | - $this->export_label[$r]='Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
243 | - $this->export_permission[$r]=array(array("expedition","shipment","export")); |
|
244 | - $this->export_fields_array[$r]=array( |
|
245 | - 's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', |
|
246 | - 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5', |
|
247 | - 's.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation", |
|
248 | - 'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth", |
|
249 | - 'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic", |
|
250 | - 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', |
|
251 | - 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' |
|
252 | - ); |
|
253 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); |
|
254 | - //$this->export_TypeFields_array[$r]=array( |
|
255 | - // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
|
256 | - // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", |
|
257 | - // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
258 | - // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text" |
|
259 | - //); |
|
260 | - $this->export_TypeFields_array[$r]=array( |
|
261 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', |
|
262 | - 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date", |
|
263 | - 'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status', |
|
264 | - 'c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text' |
|
265 | - ); |
|
266 | - $this->export_entities_array[$r]=array( |
|
267 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', |
|
268 | - 'co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company', |
|
269 | - 's.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment", |
|
270 | - 'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment", |
|
271 | - 'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment", |
|
272 | - 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', |
|
273 | - 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' |
|
274 | - ); |
|
275 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); |
|
276 | - $this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
277 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
|
278 | - { |
|
279 | - $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3'; |
|
280 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
281 | - } |
|
282 | - $keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra'; |
|
283 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
284 | - $keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2'; |
|
285 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
286 | - |
|
287 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
288 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; |
|
289 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; |
|
290 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; |
|
291 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
292 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
293 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
294 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; |
|
295 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; |
|
296 | - $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
297 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
298 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
|
299 | - { |
|
300 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; |
|
301 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; |
|
302 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; |
|
303 | - } |
|
304 | - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; |
|
305 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; |
|
306 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Function called when module is enabled. |
|
312 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
313 | - * It also creates data directories |
|
314 | - * |
|
173 | + $r++; |
|
174 | + $this->rights[$r][0] = 106; |
|
175 | + $this->rights[$r][1] = 'Exporter les expeditions'; |
|
176 | + $this->rights[$r][2] = 'r'; |
|
177 | + $this->rights[$r][3] = 0; |
|
178 | + $this->rights[$r][4] = 'shipment'; |
|
179 | + $this->rights[$r][5] = 'export'; |
|
180 | + |
|
181 | + $r++; |
|
182 | + $this->rights[$r][0] = 109; |
|
183 | + $this->rights[$r][1] = 'Supprimer les expeditions'; |
|
184 | + $this->rights[$r][2] = 'd'; |
|
185 | + $this->rights[$r][3] = 0; |
|
186 | + $this->rights[$r][4] = 'supprimer'; |
|
187 | + |
|
188 | + $r++; |
|
189 | + $this->rights[$r][0] = 1101; |
|
190 | + $this->rights[$r][1] = 'Lire les bons de livraison'; |
|
191 | + $this->rights[$r][2] = 'r'; |
|
192 | + $this->rights[$r][3] = 0; |
|
193 | + $this->rights[$r][4] = 'livraison'; |
|
194 | + $this->rights[$r][5] = 'lire'; |
|
195 | + |
|
196 | + $r++; |
|
197 | + $this->rights[$r][0] = 1102; |
|
198 | + $this->rights[$r][1] = 'Creer modifier les bons de livraison'; |
|
199 | + $this->rights[$r][2] = 'w'; |
|
200 | + $this->rights[$r][3] = 0; |
|
201 | + $this->rights[$r][4] = 'livraison'; |
|
202 | + $this->rights[$r][5] = 'creer'; |
|
203 | + |
|
204 | + $r++; |
|
205 | + $this->rights[$r][0] = 1104; |
|
206 | + $this->rights[$r][1] = 'Valider les bons de livraison'; |
|
207 | + $this->rights[$r][2] = 'd'; |
|
208 | + $this->rights[$r][3] = 0; |
|
209 | + $this->rights[$r][4] = 'livraison_advance'; |
|
210 | + $this->rights[$r][5] = 'validate'; |
|
211 | + |
|
212 | + $r++; |
|
213 | + $this->rights[$r][0] = 1109; |
|
214 | + $this->rights[$r][1] = 'Supprimer les bons de livraison'; |
|
215 | + $this->rights[$r][2] = 'd'; |
|
216 | + $this->rights[$r][3] = 0; |
|
217 | + $this->rights[$r][4] = 'livraison'; |
|
218 | + $this->rights[$r][5] = 'supprimer'; |
|
219 | + |
|
220 | + |
|
221 | + // Menus |
|
222 | + //------- |
|
223 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
224 | + |
|
225 | + |
|
226 | + // Exports |
|
227 | + //-------- |
|
228 | + $r=0; |
|
229 | + |
|
230 | + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
231 | + $shipment=new Commande($this->db); |
|
232 | + $contact_arrays=$shipment->liste_type_contact('external','',0,0,''); |
|
233 | + if (is_array($contact_arrays) && count($contact_arrays)>0){ |
|
234 | + $idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,''))); |
|
235 | + } else { |
|
236 | + $idcontacts=0; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + $r++; |
|
241 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
242 | + $this->export_label[$r]='Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
243 | + $this->export_permission[$r]=array(array("expedition","shipment","export")); |
|
244 | + $this->export_fields_array[$r]=array( |
|
245 | + 's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', |
|
246 | + 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5', |
|
247 | + 's.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation", |
|
248 | + 'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth", |
|
249 | + 'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic", |
|
250 | + 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', |
|
251 | + 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' |
|
252 | + ); |
|
253 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); |
|
254 | + //$this->export_TypeFields_array[$r]=array( |
|
255 | + // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
|
256 | + // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", |
|
257 | + // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
|
258 | + // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text" |
|
259 | + //); |
|
260 | + $this->export_TypeFields_array[$r]=array( |
|
261 | + 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', |
|
262 | + 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date", |
|
263 | + 'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status', |
|
264 | + 'c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text' |
|
265 | + ); |
|
266 | + $this->export_entities_array[$r]=array( |
|
267 | + 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', |
|
268 | + 'co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company', |
|
269 | + 's.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment", |
|
270 | + 'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment", |
|
271 | + 'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment", |
|
272 | + 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', |
|
273 | + 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' |
|
274 | + ); |
|
275 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); |
|
276 | + $this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
277 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
|
278 | + { |
|
279 | + $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3'; |
|
280 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
281 | + } |
|
282 | + $keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra'; |
|
283 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
284 | + $keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2'; |
|
285 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
286 | + |
|
287 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
288 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; |
|
289 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; |
|
290 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; |
|
291 | + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
292 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
293 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
294 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; |
|
295 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; |
|
296 | + $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; |
|
297 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; |
|
298 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
|
299 | + { |
|
300 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; |
|
301 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; |
|
302 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; |
|
303 | + } |
|
304 | + $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; |
|
305 | + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; |
|
306 | + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Function called when module is enabled. |
|
312 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
313 | + * It also creates data directories |
|
314 | + * |
|
315 | 315 | * @param string $options Options when enabling module ('', 'noboxes') |
316 | - * @return int 1 if OK, 0 if KO |
|
317 | - */ |
|
318 | - function init($options='') |
|
319 | - { |
|
320 | - global $conf,$langs; |
|
321 | - |
|
322 | - // Permissions |
|
323 | - $this->remove($options); |
|
324 | - |
|
325 | - //ODT template |
|
326 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; |
|
327 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/shipment'; |
|
328 | - $dest=$dirodt.'/template_shipment.odt'; |
|
329 | - |
|
330 | - if (file_exists($src) && ! file_exists($dest)) |
|
331 | - { |
|
332 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
333 | - dol_mkdir($dirodt); |
|
334 | - $result=dol_copy($src,$dest,0,0); |
|
335 | - if ($result < 0) |
|
336 | - { |
|
337 | - $langs->load("errors"); |
|
338 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
339 | - return 0; |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - $sql = array(); |
|
344 | - |
|
345 | - $sql = array( |
|
346 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'shipping' AND entity = ".$conf->entity, |
|
347 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','shipping',".$conf->entity.")", |
|
348 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'delivery' AND entity = ".$conf->entity, |
|
349 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".$conf->entity.")", |
|
350 | - ); |
|
351 | - |
|
352 | - return $this->_init($sql,$options); |
|
353 | - } |
|
316 | + * @return int 1 if OK, 0 if KO |
|
317 | + */ |
|
318 | + function init($options='') |
|
319 | + { |
|
320 | + global $conf,$langs; |
|
321 | + |
|
322 | + // Permissions |
|
323 | + $this->remove($options); |
|
324 | + |
|
325 | + //ODT template |
|
326 | + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; |
|
327 | + $dirodt=DOL_DATA_ROOT.'/doctemplates/shipment'; |
|
328 | + $dest=$dirodt.'/template_shipment.odt'; |
|
329 | + |
|
330 | + if (file_exists($src) && ! file_exists($dest)) |
|
331 | + { |
|
332 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
333 | + dol_mkdir($dirodt); |
|
334 | + $result=dol_copy($src,$dest,0,0); |
|
335 | + if ($result < 0) |
|
336 | + { |
|
337 | + $langs->load("errors"); |
|
338 | + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
339 | + return 0; |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + $sql = array(); |
|
344 | + |
|
345 | + $sql = array( |
|
346 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'shipping' AND entity = ".$conf->entity, |
|
347 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','shipping',".$conf->entity.")", |
|
348 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'delivery' AND entity = ".$conf->entity, |
|
349 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".$conf->entity.")", |
|
350 | + ); |
|
351 | + |
|
352 | + return $this->_init($sql,$options); |
|
353 | + } |
|
354 | 354 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | { |
34 | 34 | |
35 | 35 | /** |
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | 39 | */ |
40 | 40 | function __construct($db) |
41 | 41 | { |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | $this->config_page_url = array('workflow.php'); |
69 | 69 | |
70 | 70 | // Dependencies |
71 | - $this->hidden = false; // A condition to hide module |
|
72 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
73 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
71 | + $this->hidden = false; // A condition to hide module |
|
72 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
73 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
76 | 76 | $this->need_dolibarr_version = array(2,8); // Minimum version of Dolibarr required by module |
77 | 77 | $this->langfiles = array("@workflow"); |
78 | 78 | |
@@ -132,19 +132,19 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | /** |
135 | - * Function called when module is enabled. |
|
136 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
137 | - * It also creates data directories |
|
138 | - * |
|
135 | + * Function called when module is enabled. |
|
136 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
137 | + * It also creates data directories |
|
138 | + * |
|
139 | 139 | * @param string $options Options when enabling module ('', 'noboxes') |
140 | - * @return int 1 if OK, 0 if KO |
|
140 | + * @return int 1 if OK, 0 if KO |
|
141 | 141 | */ |
142 | 142 | function init($options='') |
143 | 143 | { |
144 | - // Permissions |
|
145 | - $this->remove($options); |
|
144 | + // Permissions |
|
145 | + $this->remove($options); |
|
146 | 146 | |
147 | - $sql = array(); |
|
147 | + $sql = array(); |
|
148 | 148 | |
149 | 149 | return $this->_init($sql,$options); |
150 | 150 | } |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class BordereauChequeBlochet extends ModeleChequeReceipts |
36 | 36 | { |
37 | - /** |
|
38 | - * Issuer |
|
39 | - * @var Societe |
|
40 | - */ |
|
41 | - public $emetteur; |
|
42 | - |
|
43 | - /** |
|
44 | - * Constructor |
|
45 | - * |
|
46 | - * @param DoliDB $db Database handler |
|
47 | - */ |
|
48 | - function __construct($db) |
|
49 | - { |
|
50 | - global $conf,$langs,$mysoc; |
|
51 | - |
|
52 | - // Load traductions files requiredby by page |
|
53 | - $langs->loadLangs(array("main", "bills")); |
|
54 | - |
|
55 | - $this->db = $db; |
|
56 | - $this->name = "blochet"; |
|
57 | - |
|
58 | - $this->tab_top = 60; |
|
59 | - |
|
60 | - // Dimension page pour format A4 |
|
61 | - $this->type = 'pdf'; |
|
62 | - $formatarray=pdf_getFormat(); |
|
63 | - $this->page_largeur = $formatarray['width']; |
|
64 | - $this->page_hauteur = $formatarray['height']; |
|
65 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
67 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
68 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
69 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
37 | + /** |
|
38 | + * Issuer |
|
39 | + * @var Societe |
|
40 | + */ |
|
41 | + public $emetteur; |
|
42 | + |
|
43 | + /** |
|
44 | + * Constructor |
|
45 | + * |
|
46 | + * @param DoliDB $db Database handler |
|
47 | + */ |
|
48 | + function __construct($db) |
|
49 | + { |
|
50 | + global $conf,$langs,$mysoc; |
|
51 | + |
|
52 | + // Load traductions files requiredby by page |
|
53 | + $langs->loadLangs(array("main", "bills")); |
|
54 | + |
|
55 | + $this->db = $db; |
|
56 | + $this->name = "blochet"; |
|
57 | + |
|
58 | + $this->tab_top = 60; |
|
59 | + |
|
60 | + // Dimension page pour format A4 |
|
61 | + $this->type = 'pdf'; |
|
62 | + $formatarray=pdf_getFormat(); |
|
63 | + $this->page_largeur = $formatarray['width']; |
|
64 | + $this->page_hauteur = $formatarray['height']; |
|
65 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
67 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
68 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
69 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
70 | 70 | |
71 | 71 | // Recupere emmetteur |
72 | 72 | $this->emetteur=$mysoc; |
@@ -74,24 +74,24 @@ discard block |
||
74 | 74 | |
75 | 75 | // Defini position des colonnes |
76 | 76 | $this->line_height = 5; |
77 | - $this->line_per_page = 40; |
|
78 | - $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
79 | - } |
|
77 | + $this->line_per_page = 40; |
|
78 | + $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
82 | - /** |
|
83 | - * Fonction to generate document on disk |
|
84 | - * |
|
85 | - * @param RemiseCheque $object Object RemiseCheque |
|
86 | - * @param string $_dir Directory |
|
87 | - * @param string $number Number |
|
88 | - * @param Translate $outputlangs Lang output object |
|
82 | + /** |
|
83 | + * Fonction to generate document on disk |
|
84 | + * |
|
85 | + * @param RemiseCheque $object Object RemiseCheque |
|
86 | + * @param string $_dir Directory |
|
87 | + * @param string $number Number |
|
88 | + * @param Translate $outputlangs Lang output object |
|
89 | 89 | * @return int 1=ok, 0=ko |
90 | - */ |
|
91 | - function write_file($object, $_dir, $number, $outputlangs) |
|
92 | - { |
|
90 | + */ |
|
91 | + function write_file($object, $_dir, $number, $outputlangs) |
|
92 | + { |
|
93 | 93 | // phpcs:enable |
94 | - global $user,$conf,$langs,$hookmanager; |
|
94 | + global $user,$conf,$langs,$hookmanager; |
|
95 | 95 | |
96 | 96 | if (! is_object($outputlangs)) $outputlangs=$langs; |
97 | 97 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
100 | 100 | |
101 | 101 | // Load traductions files requiredby by page |
102 | - $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); |
|
103 | - |
|
104 | - $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; |
|
105 | - |
|
106 | - if (! is_dir($dir)) |
|
107 | - { |
|
108 | - $result=dol_mkdir($dir); |
|
109 | - |
|
110 | - if ($result < 0) |
|
111 | - { |
|
112 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
113 | - return -1; |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - $file = $dir . "/bordereau-".$number.".pdf"; |
|
118 | - |
|
119 | - // Add pdfgeneration hook |
|
120 | - if (! is_object($hookmanager)) |
|
121 | - { |
|
122 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
123 | - $hookmanager=new HookManager($this->db); |
|
124 | - } |
|
125 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
126 | - $parameters=array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
127 | - global $action; |
|
128 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
129 | - |
|
130 | - // Create PDF instance |
|
102 | + $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); |
|
103 | + |
|
104 | + $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; |
|
105 | + |
|
106 | + if (! is_dir($dir)) |
|
107 | + { |
|
108 | + $result=dol_mkdir($dir); |
|
109 | + |
|
110 | + if ($result < 0) |
|
111 | + { |
|
112 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
113 | + return -1; |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + $file = $dir . "/bordereau-".$number.".pdf"; |
|
118 | + |
|
119 | + // Add pdfgeneration hook |
|
120 | + if (! is_object($hookmanager)) |
|
121 | + { |
|
122 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
123 | + $hookmanager=new HookManager($this->db); |
|
124 | + } |
|
125 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
126 | + $parameters=array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
127 | + global $action; |
|
128 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
129 | + |
|
130 | + // Create PDF instance |
|
131 | 131 | $pdf=pdf_getInstance($this->format); |
132 | 132 | $heightforinfotot = 50; // Height reserved to output the info and total part |
133 | 133 | $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 |
@@ -142,121 +142,121 @@ discard block |
||
142 | 142 | } |
143 | 143 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
144 | 144 | |
145 | - $pdf->Open(); |
|
146 | - $pagenb=0; |
|
147 | - $pdf->SetDrawColor(128,128,128); |
|
148 | - |
|
149 | - $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt")." ".$number); |
|
150 | - $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); |
|
151 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
152 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
153 | - $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
|
154 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
155 | - |
|
156 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
157 | - |
|
158 | - $nboflines=count($this->lines); |
|
159 | - |
|
160 | - // Define nb of page |
|
161 | - $pages = intval($nboflines / $this->line_per_page); |
|
162 | - if (($nboflines % $this->line_per_page)>0) |
|
163 | - { |
|
164 | - $pages++; |
|
165 | - } |
|
166 | - if ($pages == 0) |
|
167 | - { |
|
168 | - // force to build at least one page if report has no lines |
|
169 | - $pages = 1; |
|
170 | - } |
|
171 | - |
|
172 | - $pdf->AddPage(); |
|
145 | + $pdf->Open(); |
|
146 | + $pagenb=0; |
|
147 | + $pdf->SetDrawColor(128,128,128); |
|
148 | + |
|
149 | + $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt")." ".$number); |
|
150 | + $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); |
|
151 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
152 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
153 | + $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
|
154 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
155 | + |
|
156 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
157 | + |
|
158 | + $nboflines=count($this->lines); |
|
159 | + |
|
160 | + // Define nb of page |
|
161 | + $pages = intval($nboflines / $this->line_per_page); |
|
162 | + if (($nboflines % $this->line_per_page)>0) |
|
163 | + { |
|
164 | + $pages++; |
|
165 | + } |
|
166 | + if ($pages == 0) |
|
167 | + { |
|
168 | + // force to build at least one page if report has no lines |
|
169 | + $pages = 1; |
|
170 | + } |
|
171 | + |
|
172 | + $pdf->AddPage(); |
|
173 | 173 | $pagenb++; |
174 | - $this->Header($pdf, $pagenb, $pages, $outputlangs); |
|
174 | + $this->Header($pdf, $pagenb, $pages, $outputlangs); |
|
175 | 175 | |
176 | - $this->Body($pdf, $pagenb, $pages, $outputlangs); |
|
176 | + $this->Body($pdf, $pagenb, $pages, $outputlangs); |
|
177 | 177 | |
178 | - // Pied de page |
|
179 | - $this->_pagefoot($pdf,'',$outputlangs); |
|
180 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
178 | + // Pied de page |
|
179 | + $this->_pagefoot($pdf,'',$outputlangs); |
|
180 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
181 | 181 | |
182 | - $pdf->Close(); |
|
182 | + $pdf->Close(); |
|
183 | 183 | |
184 | - $pdf->Output($file,'F'); |
|
184 | + $pdf->Output($file,'F'); |
|
185 | 185 | |
186 | - // Add pdfgeneration hook |
|
187 | - if (! is_object($hookmanager)) |
|
188 | - { |
|
189 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
190 | - $hookmanager=new HookManager($this->db); |
|
191 | - } |
|
192 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
193 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
194 | - global $action; |
|
195 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
186 | + // Add pdfgeneration hook |
|
187 | + if (! is_object($hookmanager)) |
|
188 | + { |
|
189 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
190 | + $hookmanager=new HookManager($this->db); |
|
191 | + } |
|
192 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
193 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
194 | + global $action; |
|
195 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
196 | 196 | |
197 | - if (! empty($conf->global->MAIN_UMASK)) |
|
198 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
197 | + if (! empty($conf->global->MAIN_UMASK)) |
|
198 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
199 | 199 | |
200 | - $this->result = array('fullpath'=>$file); |
|
200 | + $this->result = array('fullpath'=>$file); |
|
201 | 201 | |
202 | 202 | $outputlangs->charset_output=$sav_charset_output; |
203 | - return 1; // Pas d'erreur |
|
204 | - } |
|
203 | + return 1; // Pas d'erreur |
|
204 | + } |
|
205 | 205 | |
206 | 206 | |
207 | 207 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
208 | - /** |
|
209 | - * Generate Header |
|
210 | - * |
|
211 | - * @param PDF $pdf Pdf object |
|
212 | - * @param int $page Current page number |
|
213 | - * @param int $pages Total number of pages |
|
214 | - * @param Translate $outputlangs Object language for output |
|
215 | - * @return void |
|
216 | - */ |
|
217 | - function Header(&$pdf, $page, $pages, $outputlangs) |
|
218 | - { |
|
208 | + /** |
|
209 | + * Generate Header |
|
210 | + * |
|
211 | + * @param PDF $pdf Pdf object |
|
212 | + * @param int $page Current page number |
|
213 | + * @param int $pages Total number of pages |
|
214 | + * @param Translate $outputlangs Object language for output |
|
215 | + * @return void |
|
216 | + */ |
|
217 | + function Header(&$pdf, $page, $pages, $outputlangs) |
|
218 | + { |
|
219 | 219 | // phpcs:enable |
220 | - global $langs; |
|
221 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
220 | + global $langs; |
|
221 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
222 | 222 | |
223 | - // Load traductions files requiredby by page |
|
224 | - $outputlangs->loadLangs(array("compta", "banks")); |
|
223 | + // Load traductions files requiredby by page |
|
224 | + $outputlangs->loadLangs(array("compta", "banks")); |
|
225 | 225 | |
226 | - $title = $outputlangs->transnoentities("CheckReceipt"); |
|
227 | - $pdf->SetFont('','B', $default_font_size); |
|
226 | + $title = $outputlangs->transnoentities("CheckReceipt"); |
|
227 | + $pdf->SetFont('','B', $default_font_size); |
|
228 | 228 | $pdf->SetXY(10,8); |
229 | 229 | $pdf->MultiCell(0,2,$title,0,'L'); |
230 | 230 | |
231 | - $pdf->SetFont('','', $default_font_size); |
|
231 | + $pdf->SetFont('','', $default_font_size); |
|
232 | 232 | $pdf->SetXY(10,15); |
233 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Ref"),0,'L'); |
|
233 | + $pdf->MultiCell(22,2,$outputlangs->transnoentities("Ref"),0,'L'); |
|
234 | 234 | $pdf->SetXY(32,15); |
235 | - $pdf->SetFont('','', $default_font_size); |
|
235 | + $pdf->SetFont('','', $default_font_size); |
|
236 | 236 | $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext?" - ".$this->ref_ext:'')), 0, 'L'); |
237 | 237 | |
238 | - $pdf->SetFont('','', $default_font_size); |
|
238 | + $pdf->SetFont('','', $default_font_size); |
|
239 | 239 | $pdf->SetXY(10,20); |
240 | 240 | $pdf->MultiCell(22,2,$outputlangs->transnoentities("Date"),0,'L'); |
241 | 241 | $pdf->SetXY(32,20); |
242 | 242 | $pdf->SetFont('','', $default_font_size); |
243 | 243 | $pdf->MultiCell(60, 2, dol_print_date($this->date,"day",false,$outputlangs)); |
244 | 244 | |
245 | - $pdf->SetFont('','', $default_font_size); |
|
245 | + $pdf->SetFont('','', $default_font_size); |
|
246 | 246 | $pdf->SetXY(10,26); |
247 | 247 | $pdf->MultiCell(22,2,$outputlangs->transnoentities("Owner"),0,'L'); |
248 | - $pdf->SetFont('','', $default_font_size); |
|
248 | + $pdf->SetFont('','', $default_font_size); |
|
249 | 249 | $pdf->SetXY(32,26); |
250 | 250 | $pdf->MultiCell(60,2,$outputlangs->convToOutputCharset($this->account->proprio),0,'L'); |
251 | 251 | |
252 | - $pdf->SetFont('','', $default_font_size); |
|
252 | + $pdf->SetFont('','', $default_font_size); |
|
253 | 253 | $pdf->SetXY(10,32); |
254 | 254 | $pdf->MultiCell(0,2,$outputlangs->transnoentities("Account"),0,'L'); |
255 | 255 | pdf_bank($pdf,$outputlangs,32,32,$this->account,1); |
256 | 256 | |
257 | - $pdf->SetFont('','', $default_font_size); |
|
257 | + $pdf->SetFont('','', $default_font_size); |
|
258 | 258 | $pdf->SetXY(114,15); |
259 | - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); |
|
259 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); |
|
260 | 260 | |
261 | 261 | $pdf->Rect(9, 14, 192, 35); |
262 | 262 | $pdf->line(9, 19, 112, 19); |
@@ -267,98 +267,98 @@ discard block |
||
267 | 267 | $pdf->line(30, 14, 30, 49); |
268 | 268 | $pdf->line(112, 14, 112, 49); |
269 | 269 | |
270 | - // Number of cheques |
|
271 | - $posy=51; |
|
272 | - $pdf->Rect(9, $posy, 192, 6); |
|
273 | - $pdf->line(55, $posy, 55, $posy+6); |
|
274 | - $pdf->line(140, $posy, 140, $posy+6); |
|
275 | - $pdf->line(170, $posy, 170, $posy+6); |
|
270 | + // Number of cheques |
|
271 | + $posy=51; |
|
272 | + $pdf->Rect(9, $posy, 192, 6); |
|
273 | + $pdf->line(55, $posy, 55, $posy+6); |
|
274 | + $pdf->line(140, $posy, 140, $posy+6); |
|
275 | + $pdf->line(170, $posy, 170, $posy+6); |
|
276 | 276 | |
277 | - $pdf->SetFont('','', $default_font_size); |
|
278 | - $pdf->SetXY(10,$posy+1); |
|
279 | - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); |
|
277 | + $pdf->SetFont('','', $default_font_size); |
|
278 | + $pdf->SetXY(10,$posy+1); |
|
279 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); |
|
280 | 280 | |
281 | - $pdf->SetFont('','B', $default_font_size); |
|
281 | + $pdf->SetFont('','B', $default_font_size); |
|
282 | 282 | $pdf->SetXY(57,$posy+1); |
283 | 283 | $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); |
284 | 284 | |
285 | - $pdf->SetFont('','', $default_font_size); |
|
285 | + $pdf->SetFont('','', $default_font_size); |
|
286 | 286 | $pdf->SetXY(148,$posy+1); |
287 | - $pdf->MultiCell(40, 2, $langs->trans("Total")); |
|
287 | + $pdf->MultiCell(40, 2, $langs->trans("Total")); |
|
288 | 288 | |
289 | - $pdf->SetFont('','B', $default_font_size); |
|
290 | - $pdf->SetXY(170, $posy+1); |
|
291 | - $pdf->MultiCell(31, 2, price($this->amount), 0, 'C', 0); |
|
289 | + $pdf->SetFont('','B', $default_font_size); |
|
290 | + $pdf->SetXY(170, $posy+1); |
|
291 | + $pdf->MultiCell(31, 2, price($this->amount), 0, 'C', 0); |
|
292 | 292 | |
293 | - // Tableau |
|
294 | - $pdf->SetFont('','', $default_font_size - 2); |
|
295 | - $pdf->SetXY(11, $this->tab_top+2); |
|
296 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("Num"), 0, 'L'); |
|
297 | - $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); |
|
293 | + // Tableau |
|
294 | + $pdf->SetFont('','', $default_font_size - 2); |
|
295 | + $pdf->SetXY(11, $this->tab_top+2); |
|
296 | + $pdf->MultiCell(40,2,$outputlangs->transnoentities("Num"), 0, 'L'); |
|
297 | + $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); |
|
298 | 298 | |
299 | - $pdf->SetXY(41, $this->tab_top+2); |
|
299 | + $pdf->SetXY(41, $this->tab_top+2); |
|
300 | 300 | $pdf->MultiCell(40,2,$outputlangs->transnoentities("Bank"), 0, 'L'); |
301 | - $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); |
|
301 | + $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); |
|
302 | 302 | |
303 | 303 | $pdf->SetXY(101, $this->tab_top+2); |
304 | 304 | $pdf->MultiCell(40,2,$outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
305 | - $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); |
|
305 | + $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); |
|
306 | 306 | |
307 | - $pdf->SetXY(180, $this->tab_top+2); |
|
308 | - $pdf->MultiCell(20,2,$outputlangs->transnoentities("Amount"), 0, 'R'); |
|
309 | - $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8); |
|
307 | + $pdf->SetXY(180, $this->tab_top+2); |
|
308 | + $pdf->MultiCell(20,2,$outputlangs->transnoentities("Amount"), 0, 'R'); |
|
309 | + $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8); |
|
310 | 310 | |
311 | - $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); |
|
312 | - } |
|
311 | + $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); |
|
312 | + } |
|
313 | 313 | |
314 | 314 | |
315 | 315 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
316 | - /** |
|
317 | - * Output array |
|
318 | - * |
|
319 | - * @param PDF $pdf PDF object |
|
320 | - * @param int $pagenb Page nb |
|
321 | - * @param int $pages Pages |
|
322 | - * @param Translate $outputlangs Object lang |
|
323 | - * @return void |
|
324 | - */ |
|
325 | - function Body(&$pdf, $pagenb, $pages, $outputlangs) |
|
326 | - { |
|
316 | + /** |
|
317 | + * Output array |
|
318 | + * |
|
319 | + * @param PDF $pdf PDF object |
|
320 | + * @param int $pagenb Page nb |
|
321 | + * @param int $pages Pages |
|
322 | + * @param Translate $outputlangs Object lang |
|
323 | + * @return void |
|
324 | + */ |
|
325 | + function Body(&$pdf, $pagenb, $pages, $outputlangs) |
|
326 | + { |
|
327 | 327 | // phpcs:enable |
328 | - // x=10 - Num |
|
329 | - // x=30 - Banque |
|
330 | - // x=100 - Emetteur |
|
331 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
332 | - $pdf->SetFont('','', $default_font_size - 1); |
|
333 | - $oldprowid = 0; |
|
334 | - $pdf->SetFillColor(220,220,220); |
|
335 | - $yp = 0; |
|
336 | - $lineinpage=0; |
|
337 | - $num=count($this->lines); |
|
338 | - for ($j = 0; $j < $num; $j++) |
|
339 | - { |
|
340 | - $lineinpage++; |
|
328 | + // x=10 - Num |
|
329 | + // x=30 - Banque |
|
330 | + // x=100 - Emetteur |
|
331 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
332 | + $pdf->SetFont('','', $default_font_size - 1); |
|
333 | + $oldprowid = 0; |
|
334 | + $pdf->SetFillColor(220,220,220); |
|
335 | + $yp = 0; |
|
336 | + $lineinpage=0; |
|
337 | + $num=count($this->lines); |
|
338 | + for ($j = 0; $j < $num; $j++) |
|
339 | + { |
|
340 | + $lineinpage++; |
|
341 | 341 | |
342 | - $pdf->SetXY(1, $this->tab_top + 10 + $yp); |
|
343 | - $pdf->MultiCell(8, $this->line_height, $j+1, 0, 'R', 0); |
|
342 | + $pdf->SetXY(1, $this->tab_top + 10 + $yp); |
|
343 | + $pdf->MultiCell(8, $this->line_height, $j+1, 0, 'R', 0); |
|
344 | 344 | |
345 | - $pdf->SetXY(10, $this->tab_top + 10 + $yp); |
|
346 | - $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq?$this->lines[$j]->num_chq:'', 0, 'L', 0); |
|
345 | + $pdf->SetXY(10, $this->tab_top + 10 + $yp); |
|
346 | + $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq?$this->lines[$j]->num_chq:'', 0, 'L', 0); |
|
347 | 347 | |
348 | - $pdf->SetXY(40, $this->tab_top + 10 + $yp); |
|
349 | - $pdf->MultiCell(70, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->bank_chq),44), 0, 'L', 0); |
|
348 | + $pdf->SetXY(40, $this->tab_top + 10 + $yp); |
|
349 | + $pdf->MultiCell(70, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->bank_chq),44), 0, 'L', 0); |
|
350 | 350 | |
351 | - $pdf->SetXY(100, $this->tab_top + 10 + $yp); |
|
352 | - $pdf->MultiCell(80, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq),50), 0, 'L', 0); |
|
351 | + $pdf->SetXY(100, $this->tab_top + 10 + $yp); |
|
352 | + $pdf->MultiCell(80, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq),50), 0, 'L', 0); |
|
353 | 353 | |
354 | - $pdf->SetXY(180, $this->tab_top + 10 + $yp); |
|
355 | - $pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0); |
|
354 | + $pdf->SetXY(180, $this->tab_top + 10 + $yp); |
|
355 | + $pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0); |
|
356 | 356 | |
357 | - $yp = $yp + $this->line_height; |
|
357 | + $yp = $yp + $this->line_height; |
|
358 | 358 | |
359 | - if ($lineinpage >= $this->line_per_page && $j < (count($this->lines)-1)) |
|
360 | - { |
|
361 | - $lineinpage=0; $yp=0; |
|
359 | + if ($lineinpage >= $this->line_per_page && $j < (count($this->lines)-1)) |
|
360 | + { |
|
361 | + $lineinpage=0; $yp=0; |
|
362 | 362 | |
363 | 363 | // New page |
364 | 364 | $pdf->AddPage(); |
@@ -367,35 +367,35 @@ discard block |
||
367 | 367 | $pdf->SetFont('','', $default_font_size - 1); |
368 | 368 | $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
369 | 369 | $pdf->SetTextColor(0,0,0); |
370 | - } |
|
371 | - } |
|
372 | - } |
|
370 | + } |
|
371 | + } |
|
372 | + } |
|
373 | 373 | |
374 | 374 | |
375 | - /** |
|
376 | - * Show footer of page. Need this->emetteur object |
|
375 | + /** |
|
376 | + * Show footer of page. Need this->emetteur object |
|
377 | 377 | * |
378 | - * @param PDF $pdf PDF |
|
379 | - * @param Object $object Object to show |
|
380 | - * @param Translate $outputlangs Object lang for output |
|
381 | - * @param int $hidefreetext 1=Hide free text |
|
382 | - * @return void |
|
383 | - */ |
|
384 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
385 | - { |
|
386 | - global $conf; |
|
387 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
388 | - |
|
389 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
390 | - |
|
391 | - // Line of free text |
|
392 | - $newfreetext=''; |
|
393 | - $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
394 | - if (! empty($conf->global->$paramfreetext)) |
|
395 | - { |
|
396 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
397 | - } |
|
398 | - |
|
399 | - return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
400 | - } |
|
378 | + * @param PDF $pdf PDF |
|
379 | + * @param Object $object Object to show |
|
380 | + * @param Translate $outputlangs Object lang for output |
|
381 | + * @param int $hidefreetext 1=Hide free text |
|
382 | + * @return void |
|
383 | + */ |
|
384 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
385 | + { |
|
386 | + global $conf; |
|
387 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
388 | + |
|
389 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
390 | + |
|
391 | + // Line of free text |
|
392 | + $newfreetext=''; |
|
393 | + $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
394 | + if (! empty($conf->global->$paramfreetext)) |
|
395 | + { |
|
396 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
397 | + } |
|
398 | + |
|
399 | + return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
400 | + } |
|
401 | 401 | } |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | - public $prefix='CHK'; |
|
38 | + public $prefix='CHK'; |
|
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 | - public $name='Mint'; |
|
45 | + public $name='Mint'; |
|
46 | 46 | |
47 | 47 | |
48 | 48 | /** |
@@ -52,110 +52,110 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function info() |
54 | 54 | { |
55 | - global $langs; |
|
56 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
55 | + global $langs; |
|
56 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Renvoi un exemple de numerotation |
|
62 | - * |
|
63 | - * @return string Example |
|
64 | - */ |
|
65 | - function getExample() |
|
66 | - { |
|
67 | - return $this->prefix."0501-0001"; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
73 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
74 | - * |
|
75 | - * @return boolean false si conflit, true si ok |
|
76 | - */ |
|
77 | - function canBeActivated() |
|
78 | - { |
|
79 | - global $conf,$langs,$db; |
|
80 | - |
|
81 | - $payyymm=''; $max=''; |
|
82 | - |
|
83 | - $posindice=9; |
|
84 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
85 | - $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
86 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
87 | - $sql.= " AND entity = ".$conf->entity; |
|
88 | - |
|
89 | - $resql=$db->query($sql); |
|
90 | - if ($resql) |
|
91 | - { |
|
92 | - $row = $db->fetch_row($resql); |
|
93 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
94 | - } |
|
95 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
96 | - { |
|
97 | - $langs->load("errors"); |
|
98 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
99 | - return false; |
|
100 | - } |
|
101 | - |
|
102 | - return true; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Return next free value |
|
107 | - * |
|
108 | - * @param Societe $objsoc Object thirdparty |
|
109 | - * @param Object $object Object we need next value for |
|
110 | - * @return string Value if KO, <0 if KO |
|
111 | - */ |
|
112 | - function getNextValue($objsoc,$object) |
|
113 | - { |
|
114 | - global $db,$conf; |
|
115 | - |
|
116 | - // D'abord on recupere la valeur max |
|
117 | - $posindice=9; |
|
118 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
119 | - $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
120 | - $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
121 | - $sql.= " AND entity = ".$conf->entity; |
|
122 | - |
|
123 | - $resql=$db->query($sql); |
|
124 | - if ($resql) |
|
125 | - { |
|
126 | - $obj = $db->fetch_object($resql); |
|
127 | - if ($obj) $max = intval($obj->max); |
|
128 | - else $max=0; |
|
129 | - } |
|
130 | - else |
|
131 | - { |
|
132 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
133 | - return -1; |
|
134 | - } |
|
135 | - |
|
136 | - //$date=time(); |
|
137 | - $date=$object->date_bordereau; |
|
138 | - $yymm = strftime("%y%m",$date); |
|
139 | - |
|
140 | - 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 |
|
141 | - else $num = sprintf("%04s",$max+1); |
|
142 | - |
|
143 | - dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
144 | - return $this->prefix.$yymm."-".$num; |
|
145 | - } |
|
60 | + /** |
|
61 | + * Renvoi un exemple de numerotation |
|
62 | + * |
|
63 | + * @return string Example |
|
64 | + */ |
|
65 | + function getExample() |
|
66 | + { |
|
67 | + return $this->prefix."0501-0001"; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
73 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
74 | + * |
|
75 | + * @return boolean false si conflit, true si ok |
|
76 | + */ |
|
77 | + function canBeActivated() |
|
78 | + { |
|
79 | + global $conf,$langs,$db; |
|
80 | + |
|
81 | + $payyymm=''; $max=''; |
|
82 | + |
|
83 | + $posindice=9; |
|
84 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
85 | + $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
86 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
87 | + $sql.= " AND entity = ".$conf->entity; |
|
88 | + |
|
89 | + $resql=$db->query($sql); |
|
90 | + if ($resql) |
|
91 | + { |
|
92 | + $row = $db->fetch_row($resql); |
|
93 | + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
94 | + } |
|
95 | + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
96 | + { |
|
97 | + $langs->load("errors"); |
|
98 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
99 | + return false; |
|
100 | + } |
|
101 | + |
|
102 | + return true; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Return next free value |
|
107 | + * |
|
108 | + * @param Societe $objsoc Object thirdparty |
|
109 | + * @param Object $object Object we need next value for |
|
110 | + * @return string Value if KO, <0 if KO |
|
111 | + */ |
|
112 | + function getNextValue($objsoc,$object) |
|
113 | + { |
|
114 | + global $db,$conf; |
|
115 | + |
|
116 | + // D'abord on recupere la valeur max |
|
117 | + $posindice=9; |
|
118 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
119 | + $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
120 | + $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
121 | + $sql.= " AND entity = ".$conf->entity; |
|
122 | + |
|
123 | + $resql=$db->query($sql); |
|
124 | + if ($resql) |
|
125 | + { |
|
126 | + $obj = $db->fetch_object($resql); |
|
127 | + if ($obj) $max = intval($obj->max); |
|
128 | + else $max=0; |
|
129 | + } |
|
130 | + else |
|
131 | + { |
|
132 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
133 | + return -1; |
|
134 | + } |
|
135 | + |
|
136 | + //$date=time(); |
|
137 | + $date=$object->date_bordereau; |
|
138 | + $yymm = strftime("%y%m",$date); |
|
139 | + |
|
140 | + 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 |
|
141 | + else $num = sprintf("%04s",$max+1); |
|
142 | + |
|
143 | + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
144 | + return $this->prefix.$yymm."-".$num; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | 148 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
149 | - /** |
|
150 | - * Return next free value |
|
151 | - * |
|
152 | - * @param Societe $objsoc Object third party |
|
153 | - * @param string $objforref Object for number to search |
|
154 | - * @return string Next free value |
|
155 | - */ |
|
156 | - function chequereceipt_get_num($objsoc,$objforref) |
|
157 | - { |
|
149 | + /** |
|
150 | + * Return next free value |
|
151 | + * |
|
152 | + * @param Societe $objsoc Object third party |
|
153 | + * @param string $objforref Object for number to search |
|
154 | + * @return string Next free value |
|
155 | + */ |
|
156 | + function chequereceipt_get_num($objsoc,$objforref) |
|
157 | + { |
|
158 | 158 | // phpcs:enable |
159 | - return $this->getNextValue($objsoc,$objforref); |
|
160 | - } |
|
159 | + return $this->getNextValue($objsoc,$objforref); |
|
160 | + } |
|
161 | 161 | } |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error message |
|
41 | - */ |
|
42 | - public $error = ''; |
|
39 | + /** |
|
40 | + * @var string Error message |
|
41 | + */ |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | - public $name = 'Thyme'; |
|
44 | + public $name = 'Thyme'; |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /** |
@@ -49,39 +49,39 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string Texte descripif |
51 | 51 | */ |
52 | - function info() |
|
52 | + function info() |
|
53 | 53 | { |
54 | - global $conf, $langs; |
|
54 | + global $conf, $langs; |
|
55 | 55 | |
56 | - $langs->load("bills"); |
|
56 | + $langs->load("bills"); |
|
57 | 57 | |
58 | - $form = new Form($this->db); |
|
58 | + $form = new Form($this->db); |
|
59 | 59 | |
60 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
61 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
62 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
63 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
64 | - $texte.= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">'; |
|
65 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
60 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
61 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
62 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
63 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
64 | + $texte.= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">'; |
|
65 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
66 | 66 | |
67 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort")); |
|
68 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
69 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
70 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort")); |
|
71 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
67 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort")); |
|
68 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
69 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
70 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort")); |
|
71 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
72 | 72 | |
73 | - // Parametrage du prefix |
|
74 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
75 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">',$tooltip,1,1).'</td>'; |
|
73 | + // Parametrage du prefix |
|
74 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
75 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">',$tooltip,1,1).'</td>'; |
|
76 | 76 | |
77 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
77 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
78 | 78 | |
79 | - $texte.= '</tr>'; |
|
79 | + $texte.= '</tr>'; |
|
80 | 80 | |
81 | - $texte.= '</table>'; |
|
82 | - $texte.= '</form>'; |
|
81 | + $texte.= '</table>'; |
|
82 | + $texte.= '</form>'; |
|
83 | 83 | |
84 | - return $texte; |
|
84 | + return $texte; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,55 +91,55 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function getExample() |
93 | 93 | { |
94 | - global $conf,$langs,$mysoc; |
|
95 | - |
|
96 | - $old_code_client=$mysoc->code_client; |
|
97 | - $mysoc->code_client='CCCCCCCCCC'; |
|
98 | - $numExample = $this->getNextValue($mysoc,''); |
|
99 | - $mysoc->code_client=$old_code_client; |
|
100 | - |
|
101 | - if (! $numExample) |
|
102 | - { |
|
103 | - $numExample = $langs->trans('NotConfigured'); |
|
104 | - } |
|
105 | - return $numExample; |
|
94 | + global $conf,$langs,$mysoc; |
|
95 | + |
|
96 | + $old_code_client=$mysoc->code_client; |
|
97 | + $mysoc->code_client='CCCCCCCCCC'; |
|
98 | + $numExample = $this->getNextValue($mysoc,''); |
|
99 | + $mysoc->code_client=$old_code_client; |
|
100 | + |
|
101 | + if (! $numExample) |
|
102 | + { |
|
103 | + $numExample = $langs->trans('NotConfigured'); |
|
104 | + } |
|
105 | + return $numExample; |
|
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Return next free value |
|
110 | - * |
|
111 | - * @param Societe $objsoc Object thirdparty |
|
112 | - * @param Object $object Object we need next value for |
|
113 | - * @return string Value if KO, <0 if KO |
|
114 | - */ |
|
108 | + /** |
|
109 | + * Return next free value |
|
110 | + * |
|
111 | + * @param Societe $objsoc Object thirdparty |
|
112 | + * @param Object $object Object we need next value for |
|
113 | + * @return string Value if KO, <0 if KO |
|
114 | + */ |
|
115 | 115 | function getNextValue($objsoc,$object) |
116 | 116 | { |
117 | - global $db,$conf; |
|
117 | + global $db,$conf; |
|
118 | 118 | |
119 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
119 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
120 | 120 | |
121 | - // We get cursor rule |
|
122 | - $mask=$conf->global->CHEQUERECEIPTS_THYME_MASK; |
|
121 | + // We get cursor rule |
|
122 | + $mask=$conf->global->CHEQUERECEIPTS_THYME_MASK; |
|
123 | 123 | |
124 | - if (! $mask) |
|
125 | - { |
|
126 | - $this->error='NotConfigured'; |
|
127 | - return 0; |
|
128 | - } |
|
124 | + if (! $mask) |
|
125 | + { |
|
126 | + $this->error='NotConfigured'; |
|
127 | + return 0; |
|
128 | + } |
|
129 | 129 | |
130 | - $numFinal=get_next_value($db,$mask,'bordereau_cheque','ref','',$objsoc,$object->date_bordereau); |
|
130 | + $numFinal=get_next_value($db,$mask,'bordereau_cheque','ref','',$objsoc,$object->date_bordereau); |
|
131 | 131 | |
132 | - return $numFinal; |
|
133 | - } |
|
132 | + return $numFinal; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | 136 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
137 | - /** |
|
138 | - * Return next free value |
|
139 | - * |
|
140 | - * @param Societe $objsoc Object third party |
|
141 | - * @param string $objforref Object for number to search |
|
142 | - * @return string Next free value |
|
137 | + /** |
|
138 | + * Return next free value |
|
139 | + * |
|
140 | + * @param Societe $objsoc Object third party |
|
141 | + * @param string $objforref Object for number to search |
|
142 | + * @return string Next free value |
|
143 | 143 | */ |
144 | 144 | function chequereceipt_get_num($objsoc,$objforref) |
145 | 145 | { |
@@ -36,84 +36,84 @@ discard block |
||
36 | 36 | */ |
37 | 37 | abstract class ModeleNumRefChequeReceipts |
38 | 38 | { |
39 | - /** |
|
40 | - * @var string Error code (or message) |
|
41 | - */ |
|
42 | - public $error=''; |
|
43 | - |
|
44 | - /** |
|
45 | - * Return if a module can be used or not |
|
46 | - * |
|
47 | - * @return boolean true if module can be used |
|
48 | - */ |
|
49 | - function isEnabled() |
|
50 | - { |
|
51 | - return true; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Return the default description of numbering module |
|
56 | - * |
|
57 | - * @return string Texte descripif |
|
58 | - */ |
|
59 | - function info() |
|
60 | - { |
|
61 | - global $langs; |
|
62 | - $langs->load("bills"); |
|
63 | - return $langs->trans("NoDescription"); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Return numbering example |
|
68 | - * |
|
69 | - * @return string Example |
|
70 | - */ |
|
71 | - function getExample() |
|
72 | - { |
|
73 | - global $langs; |
|
74 | - $langs->load("bills"); |
|
75 | - return $langs->trans("NoExample"); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
80 | - * |
|
81 | - * @return boolean false si conflit, true si ok |
|
82 | - */ |
|
83 | - function canBeActivated() |
|
84 | - { |
|
85 | - return true; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns the next value |
|
90 | - * |
|
91 | - * @param Societe $objsoc Object thirdparty |
|
92 | - * @param Object $object Object we need next value for |
|
93 | - * @return string Valeur |
|
94 | - */ |
|
95 | - function getNextValue($objsoc,$object) |
|
96 | - { |
|
97 | - global $langs; |
|
98 | - return $langs->trans("NotAvailable"); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Returns the module numbering version |
|
103 | - * |
|
104 | - * @return string Value |
|
105 | - */ |
|
106 | - function getVersion() |
|
107 | - { |
|
108 | - global $langs; |
|
109 | - $langs->load("admin"); |
|
110 | - |
|
111 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
112 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
113 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
114 | - if ($this->version) return $this->version; |
|
115 | - return $langs->trans("NotAvailable"); |
|
116 | - } |
|
39 | + /** |
|
40 | + * @var string Error code (or message) |
|
41 | + */ |
|
42 | + public $error=''; |
|
43 | + |
|
44 | + /** |
|
45 | + * Return if a module can be used or not |
|
46 | + * |
|
47 | + * @return boolean true if module can be used |
|
48 | + */ |
|
49 | + function isEnabled() |
|
50 | + { |
|
51 | + return true; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Return the default description of numbering module |
|
56 | + * |
|
57 | + * @return string Texte descripif |
|
58 | + */ |
|
59 | + function info() |
|
60 | + { |
|
61 | + global $langs; |
|
62 | + $langs->load("bills"); |
|
63 | + return $langs->trans("NoDescription"); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Return numbering example |
|
68 | + * |
|
69 | + * @return string Example |
|
70 | + */ |
|
71 | + function getExample() |
|
72 | + { |
|
73 | + global $langs; |
|
74 | + $langs->load("bills"); |
|
75 | + return $langs->trans("NoExample"); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
80 | + * |
|
81 | + * @return boolean false si conflit, true si ok |
|
82 | + */ |
|
83 | + function canBeActivated() |
|
84 | + { |
|
85 | + return true; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns the next value |
|
90 | + * |
|
91 | + * @param Societe $objsoc Object thirdparty |
|
92 | + * @param Object $object Object we need next value for |
|
93 | + * @return string Valeur |
|
94 | + */ |
|
95 | + function getNextValue($objsoc,$object) |
|
96 | + { |
|
97 | + global $langs; |
|
98 | + return $langs->trans("NotAvailable"); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Returns the module numbering version |
|
103 | + * |
|
104 | + * @return string Value |
|
105 | + */ |
|
106 | + function getVersion() |
|
107 | + { |
|
108 | + global $langs; |
|
109 | + $langs->load("admin"); |
|
110 | + |
|
111 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
112 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
113 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
114 | + if ($this->version) return $this->version; |
|
115 | + return $langs->trans("NotAvailable"); |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,34 +122,34 @@ discard block |
||
122 | 122 | */ |
123 | 123 | abstract class ModeleChequeReceipts extends CommonDocGenerator |
124 | 124 | { |
125 | - /** |
|
126 | - * @var string Error code (or message) |
|
127 | - */ |
|
128 | - public $error=''; |
|
125 | + /** |
|
126 | + * @var string Error code (or message) |
|
127 | + */ |
|
128 | + public $error=''; |
|
129 | 129 | |
130 | 130 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
131 | - /** |
|
132 | - * Return list of active generation modules |
|
133 | - * |
|
131 | + /** |
|
132 | + * Return list of active generation modules |
|
133 | + * |
|
134 | 134 | * @param DoliDB $db Database handler |
135 | 135 | * @param integer $maxfilenamelength Max length of value to show |
136 | 136 | * @return array List of templates |
137 | - */ |
|
138 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
139 | - { |
|
137 | + */ |
|
138 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
139 | + { |
|
140 | 140 | // phpcs:enable |
141 | - global $conf; |
|
141 | + global $conf; |
|
142 | 142 | |
143 | - $type='chequereceipt'; |
|
144 | - $liste=array(); |
|
143 | + $type='chequereceipt'; |
|
144 | + $liste=array(); |
|
145 | 145 | |
146 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
147 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
148 | - // TODO Remove this to use getListOfModels only |
|
149 | - $liste = array('blochet'=>'blochet'); |
|
146 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
147 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
148 | + // TODO Remove this to use getListOfModels only |
|
149 | + $liste = array('blochet'=>'blochet'); |
|
150 | 150 | |
151 | - return $liste; |
|
152 | - } |
|
151 | + return $liste; |
|
152 | + } |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -166,53 +166,53 @@ discard block |
||
166 | 166 | */ |
167 | 167 | function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs) |
168 | 168 | { |
169 | - global $conf,$langs; |
|
170 | - $langs->load("bills"); |
|
171 | - |
|
172 | - $dir = DOL_DOCUMENT_ROOT . "/core/modules/cheque/doc/"; |
|
173 | - |
|
174 | - // Positionne modele sur le nom du modele a utiliser |
|
175 | - if (! dol_strlen($modele)) |
|
176 | - { |
|
177 | - if (! empty($conf->global->CHEQUERECEIPT_ADDON_PDF)) |
|
178 | - { |
|
179 | - $modele = $conf->global->CHEQUERECEIPT_ADDON_PDF; |
|
180 | - } |
|
181 | - else |
|
182 | - { |
|
183 | - //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined"); |
|
184 | - //return 0; |
|
185 | - $modele = 'blochet'; |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - // Charge le modele |
|
190 | - $file = "pdf_".$modele.".modules.php"; |
|
191 | - if (file_exists($dir.$file)) |
|
192 | - { |
|
193 | - $classname = "pdf_".$modele; |
|
194 | - require_once $dir.$file; |
|
195 | - |
|
196 | - $obj = new $classname($db); |
|
197 | - |
|
198 | - // We save charset_output to restore it because write_file can change it if needed for |
|
199 | - // output format that does not support UTF8. |
|
200 | - $sav_charset_output=$outputlangs->charset_output; |
|
201 | - if ($obj->write_file($id, $outputlangs) > 0) |
|
202 | - { |
|
203 | - $outputlangs->charset_output=$sav_charset_output; |
|
204 | - return 1; |
|
205 | - } |
|
206 | - else |
|
207 | - { |
|
208 | - $outputlangs->charset_output=$sav_charset_output; |
|
209 | - dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error); |
|
210 | - return -1; |
|
211 | - } |
|
212 | - } |
|
213 | - else |
|
214 | - { |
|
215 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file)); |
|
216 | - return -1; |
|
217 | - } |
|
169 | + global $conf,$langs; |
|
170 | + $langs->load("bills"); |
|
171 | + |
|
172 | + $dir = DOL_DOCUMENT_ROOT . "/core/modules/cheque/doc/"; |
|
173 | + |
|
174 | + // Positionne modele sur le nom du modele a utiliser |
|
175 | + if (! dol_strlen($modele)) |
|
176 | + { |
|
177 | + if (! empty($conf->global->CHEQUERECEIPT_ADDON_PDF)) |
|
178 | + { |
|
179 | + $modele = $conf->global->CHEQUERECEIPT_ADDON_PDF; |
|
180 | + } |
|
181 | + else |
|
182 | + { |
|
183 | + //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined"); |
|
184 | + //return 0; |
|
185 | + $modele = 'blochet'; |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + // Charge le modele |
|
190 | + $file = "pdf_".$modele.".modules.php"; |
|
191 | + if (file_exists($dir.$file)) |
|
192 | + { |
|
193 | + $classname = "pdf_".$modele; |
|
194 | + require_once $dir.$file; |
|
195 | + |
|
196 | + $obj = new $classname($db); |
|
197 | + |
|
198 | + // We save charset_output to restore it because write_file can change it if needed for |
|
199 | + // output format that does not support UTF8. |
|
200 | + $sav_charset_output=$outputlangs->charset_output; |
|
201 | + if ($obj->write_file($id, $outputlangs) > 0) |
|
202 | + { |
|
203 | + $outputlangs->charset_output=$sav_charset_output; |
|
204 | + return 1; |
|
205 | + } |
|
206 | + else |
|
207 | + { |
|
208 | + $outputlangs->charset_output=$sav_charset_output; |
|
209 | + dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error); |
|
210 | + return -1; |
|
211 | + } |
|
212 | + } |
|
213 | + else |
|
214 | + { |
|
215 | + dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file)); |
|
216 | + return -1; |
|
217 | + } |
|
218 | 218 | } |