@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | /** |
35 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
36 | - * |
|
37 | - * @param DoliDB $db Database handler |
|
35 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
36 | + * |
|
37 | + * @param DoliDB $db Database handler |
|
38 | 38 | */ |
39 | 39 | function __construct($db) |
40 | 40 | { |
41 | - global $langs,$conf; |
|
41 | + global $langs,$conf; |
|
42 | 42 | |
43 | 43 | $this->db = $db; |
44 | 44 | $this->numero = 3400; |
45 | 45 | |
46 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
47 | - // It is used to group modules in module setup page |
|
46 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
47 | + // It is used to group modules in module setup page |
|
48 | 48 | $this->family = "interface"; |
49 | 49 | // Module position in the family on 2 digits ('01', '10', '20', ...) |
50 | 50 | $this->module_position = '20'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | 52 | $this->name = preg_replace('/^mod/i','',get_class($this)); |
53 | 53 | $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; |
54 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
54 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
55 | 55 | $this->version = 'dolibarr'; |
56 | 56 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
57 | 57 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | |
67 | 67 | // Dependencies |
68 | 68 | $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
69 | - $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
69 | + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
73 | 73 | $this->langfiles = array(); |
74 | 74 | |
75 | 75 | // Constants |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup socialnetworks |
24 | 24 | * \brief Description and activation file for module SocialNetworks |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class to describe a SocialNetworks module |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function __construct($db) |
40 | 40 | { |
41 | - global $langs,$conf; |
|
41 | + global $langs, $conf; |
|
42 | 42 | |
43 | 43 | $this->db = $db; |
44 | 44 | $this->numero = 3400; |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | // Module position in the family on 2 digits ('01', '10', '20', ...) |
50 | 50 | $this->module_position = '20'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; |
54 | 54 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
55 | 55 | $this->version = 'dolibarr'; |
56 | 56 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
57 | 57 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
58 | 58 | // Name of image file used for this module. |
59 | - $this->picto='generic'; |
|
59 | + $this->picto = 'generic'; |
|
60 | 60 | |
61 | 61 | // Data directories to create when module is enabled |
62 | 62 | $this->dirs = array(); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | $this->config_page_url = array("socialnetworks.php"); |
66 | 66 | |
67 | 67 | // Dependencies |
68 | - $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | - $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
68 | + $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
73 | 73 | $this->langfiles = array(); |
74 | 74 | |
75 | 75 | // Constants |
@@ -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 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param array $param Associative array containing label content and optional parameters |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - function addSticker(&$pdf,$outputlangs,$param) |
|
45 | + function addSticker(&$pdf, $outputlangs, $param) |
|
46 | 46 | { |
47 | 47 | // use this method in future refactoring |
48 | 48 | } |
@@ -63,162 +63,162 @@ discard block |
||
63 | 63 | * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
66 | + function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') |
|
67 | 67 | { |
68 | 68 | // phpcs:enable |
69 | - global $db,$mysoc,$conf,$langs; |
|
70 | - global $forceimgscalewidth,$forceimgscaleheight; |
|
69 | + global $db, $mysoc, $conf, $langs; |
|
70 | + global $forceimgscalewidth, $forceimgscaleheight; |
|
71 | 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) |
|
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 | 74 | |
75 | 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)) { |
|
76 | + if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) { |
|
77 | 77 | $pdf->AddPage(); |
78 | 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)); |
|
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 | 82 | |
83 | 83 | // Define logo |
84 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | - if (! is_readable($logo)) |
|
84 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | + if (!is_readable($logo)) |
|
86 | 86 | { |
87 | - $logo=''; |
|
88 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | + $logo = ''; |
|
88 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
89 | 89 | { |
90 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
90 | + $logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
91 | 91 | } |
92 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
92 | + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | 93 | { |
94 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
94 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - $member=new Adherent($db); |
|
98 | + $member = new Adherent($db); |
|
99 | 99 | $member->id = $idmember; |
100 | 100 | $member->ref = $idmember; |
101 | 101 | |
102 | 102 | // Define photo |
103 | - $dir=$conf->adherent->dir_output; |
|
104 | - if (! empty($photo)) |
|
103 | + $dir = $conf->adherent->dir_output; |
|
104 | + if (!empty($photo)) |
|
105 | 105 | { |
106 | - $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
107 | - $photo=$dir.'/'.$file; |
|
108 | - if (! is_readable($photo)) $photo=''; |
|
106 | + $file = get_exdir(0, 0, 0, 0, $member, 'member').'photos/'.$photo; |
|
107 | + $photo = $dir.'/'.$file; |
|
108 | + if (!is_readable($photo)) $photo = ''; |
|
109 | 109 | } |
110 | 110 | |
111 | 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)) |
|
112 | + $backgroundimage = ''; |
|
113 | + if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
114 | 114 | { |
115 | - $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
115 | + $backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Print lines |
119 | 119 | if ($this->code == "CARD") |
120 | 120 | { |
121 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
121 | + $this->Tformat = $this->_Avery_Labels["CARD"]; |
|
122 | 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); |
|
123 | + $this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Background |
127 | 127 | if ($backgroundimage) |
128 | 128 | { |
129 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
129 | + $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); |
|
130 | 130 | } |
131 | 131 | |
132 | - $xleft=2; $ytop=2; |
|
132 | + $xleft = 2; $ytop = 2; |
|
133 | 133 | |
134 | 134 | // Top |
135 | - if ($header!='') |
|
135 | + if ($header != '') |
|
136 | 136 | { |
137 | 137 | if ($this->code == "CARD") |
138 | 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); |
|
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 | 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'); |
|
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 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
148 | + $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); |
|
149 | 149 | |
150 | 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); |
|
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 | 155 | if ($tmp['height']) |
156 | 156 | { |
157 | - $imgratio=$tmp['width']/$tmp['height']; |
|
157 | + $imgratio = $tmp['width'] / $tmp['height']; |
|
158 | 158 | if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
159 | 159 | else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
160 | 160 | } |
161 | 161 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
162 | 162 | |
163 | 163 | // Center |
164 | - if ($textright=='') // Only a left part |
|
164 | + if ($textright == '') // Only a left part |
|
165 | 165 | { |
166 | 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); |
|
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 | 169 | else |
170 | 170 | { |
171 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
172 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
171 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
172 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
173 | 173 | } |
174 | 174 | } |
175 | - else if ($textleft!='' && $textright!='') // |
|
175 | + else if ($textleft != '' && $textright != '') // |
|
176 | 176 | { |
177 | 177 | if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
178 | 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'); |
|
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 | 183 | } |
184 | 184 | else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
185 | 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'); |
|
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 | 190 | } |
191 | 191 | else // text on halft left and text on half right |
192 | 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'); |
|
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 | 197 | } |
198 | 198 | } |
199 | 199 | else // Only a right part |
200 | 200 | { |
201 | 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); |
|
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 | 204 | else |
205 | 205 | { |
206 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
207 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
206 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
207 | + $pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | // Bottom |
212 | - if ($footer!='') |
|
212 | + if ($footer != '') |
|
213 | 213 | { |
214 | 214 | if ($this->code == "CARD") |
215 | 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); |
|
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 | 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'); |
|
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 | 222 | } |
223 | 223 | //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
224 | 224 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | if ($this->_COUNTY == $this->_Y_Number) { |
228 | 228 | // Si on est en bas de page, on remonte le 'curseur' de position |
229 | 229 | $this->_COUNTX++; |
230 | - $this->_COUNTY=0; |
|
230 | + $this->_COUNTY = 0; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($this->_COUNTX == $this->_X_Number) { |
234 | 234 | // Si on est en bout de page, alors on repart sur une nouvelle page |
235 | - $this->_COUNTX=0; |
|
236 | - $this->_COUNTY=0; |
|
235 | + $this->_COUNTX = 0; |
|
236 | + $this->_COUNTY = 0; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | * @param int $nooutput 1=Generate only file on disk and do not return it on response |
249 | 249 | * @return int 1=OK, 0=KO |
250 | 250 | */ |
251 | - function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
251 | + function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) |
|
252 | 252 | { |
253 | 253 | // phpcs:enable |
254 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
254 | + global $user, $conf, $langs, $mysoc, $_Avery_Labels; |
|
255 | 255 | |
256 | - $this->code=$srctemplatepath; |
|
256 | + $this->code = $srctemplatepath; |
|
257 | 257 | |
258 | 258 | if (is_object($object)) |
259 | 259 | { |
260 | - if ($object->country == '-') $object->country=''; |
|
260 | + if ($object->country == '-') $object->country = ''; |
|
261 | 261 | |
262 | 262 | // List of values to scan for a replacement |
263 | - $substitutionarray = array ( |
|
263 | + $substitutionarray = array( |
|
264 | 264 | '__ID__'=>$object->rowid, |
265 | 265 | '__LOGIN__'=>$object->login, |
266 | 266 | '__FIRSTNAME__'=>$object->firstname, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | '__COUNTRY__'=>$object->country, |
274 | 274 | '__COUNTRY_CODE__'=>$object->country_code, |
275 | 275 | '__EMAIL__'=>$object->email, |
276 | - '__BIRTH__'=>dol_print_date($object->birth,'day'), |
|
276 | + '__BIRTH__'=>dol_print_date($object->birth, 'day'), |
|
277 | 277 | '__TYPE__'=>$object->type, |
278 | 278 | '__YEAR__'=>$year, |
279 | 279 | '__MONTH__'=>$month, |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | complete_substitutions_array($substitutionarray, $langs); |
285 | 285 | |
286 | 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); |
|
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 | 291 | |
292 | 292 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
293 | + if ($nb <= 0) $nb = 1; // Protection to avoid empty page |
|
294 | 294 | |
295 | - for($j=0;$j<$nb;$j++) |
|
295 | + for ($j = 0; $j < $nb; $j++) |
|
296 | 296 | { |
297 | - $arrayofmembers[]=array( |
|
297 | + $arrayofmembers[] = array( |
|
298 | 298 | 'textleft'=>$textleft, |
299 | 299 | 'textheader'=>$textheader, |
300 | 300 | 'textfooter'=>$textfooter, |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | //var_dump($arrayofrecords);exit; |
315 | 315 | |
316 | 316 | $this->Tformat = $_Avery_Labels[$this->code]; |
317 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
317 | + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } |
|
318 | 318 | $this->type = 'pdf'; |
319 | 319 | // standard format or custom |
320 | - if ($this->Tformat['paper-size']!='custom') { |
|
320 | + if ($this->Tformat['paper-size'] != 'custom') { |
|
321 | 321 | $this->format = $this->Tformat['paper-size']; |
322 | 322 | } else { |
323 | 323 | //custom |
324 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
324 | + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
325 | 325 | $this->format = $resolution; |
326 | 326 | } |
327 | 327 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
328 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
329 | 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'; |
|
330 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
331 | 331 | |
332 | 332 | // Load traductions files requiredby by page |
333 | 333 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
334 | 334 | |
335 | 335 | if (empty($mode) || $mode == 'member') |
336 | 336 | { |
337 | - $title=$outputlangs->transnoentities('MembersCards'); |
|
338 | - $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
337 | + $title = $outputlangs->transnoentities('MembersCards'); |
|
338 | + $keywords = $outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
339 | 339 | } |
340 | 340 | else |
341 | 341 | { |
342 | - dol_print_error('','Bad value for $mode'); |
|
342 | + dol_print_error('', 'Bad value for $mode'); |
|
343 | 343 | return -1; |
344 | 344 | } |
345 | 345 | |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | |
360 | 360 | //var_dump($file);exit; |
361 | 361 | |
362 | - if (! file_exists($dir)) |
|
362 | + if (!file_exists($dir)) |
|
363 | 363 | { |
364 | 364 | if (dol_mkdir($dir) < 0) |
365 | 365 | { |
366 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
366 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
371 | + $pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']); |
|
372 | 372 | |
373 | 373 | if (class_exists('TCPDF')) |
374 | 374 | { |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
383 | 383 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
384 | 384 | $pdf->SetKeyWords($keywords); |
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
385 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
386 | 386 | |
387 | - $pdf->SetMargins(0,0); |
|
387 | + $pdf->SetMargins(0, 0); |
|
388 | 388 | $pdf->SetAutoPageBreak(false); |
389 | 389 | |
390 | 390 | $this->_Metric_Doc = $this->Tformat['metric']; |
391 | 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; |
|
392 | + $posX = 1; |
|
393 | + $posY = 1; |
|
394 | + if ($posX > 0) $posX--; else $posX = 0; |
|
395 | + if ($posY > 0) $posY--; else $posY = 0; |
|
396 | 396 | $this->_COUNTX = $posX; |
397 | 397 | $this->_COUNTY = $posY; |
398 | 398 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -403,10 +403,10 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | // Add each record |
406 | - foreach($arrayofrecords as $val) |
|
406 | + foreach ($arrayofrecords as $val) |
|
407 | 407 | { |
408 | 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']); |
|
409 | + $this->Add_PDF_card($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['id'], $val['photo']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | //$pdf->SetXY(10, 295); |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | |
415 | 415 | |
416 | 416 | // Output to file |
417 | - $pdf->Output($file,'F'); |
|
417 | + $pdf->Output($file, 'F'); |
|
418 | 418 | |
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
419 | + if (!empty($conf->global->MAIN_UMASK)) |
|
420 | 420 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
421 | 421 | |
422 | 422 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | { |
428 | 428 | clearstatcache(); |
429 | 429 | |
430 | - $attachment=true; |
|
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
432 | - $type=dol_mimetype($filename); |
|
430 | + $attachment = true; |
|
431 | + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; |
|
432 | + $type = dol_mimetype($filename); |
|
433 | 433 | |
434 | 434 | //if ($encoding) header('Content-Encoding: '.$encoding); |
435 | 435 | if ($type) header('Content-Type: '.$type); |
@@ -88,8 +88,7 @@ discard block |
||
88 | 88 | if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
89 | 89 | { |
90 | 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)) |
|
91 | + } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | 92 | { |
94 | 93 | $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
95 | 94 | } |
@@ -105,7 +104,9 @@ discard block |
||
105 | 104 | { |
106 | 105 | $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
107 | 106 | $photo=$dir.'/'.$file; |
108 | - if (! is_readable($photo)) $photo=''; |
|
107 | + if (! is_readable($photo)) { |
|
108 | + $photo=''; |
|
109 | + } |
|
109 | 110 | } |
110 | 111 | |
111 | 112 | // Define background image |
@@ -155,53 +156,58 @@ discard block |
||
155 | 156 | if ($tmp['height']) |
156 | 157 | { |
157 | 158 | $imgratio=$tmp['width']/$tmp['height']; |
158 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
159 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
159 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
160 | 160 | } |
161 | 161 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
162 | 162 | |
163 | 163 | // Center |
164 | - if ($textright=='') // Only a left part |
|
164 | + if ($textright=='') { |
|
165 | + // Only a left part |
|
165 | 166 | { |
166 | 167 | // Output left area |
167 | 168 | 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 |
|
169 | + } else if ($textleft == '__PHOTO__' && $photo) { |
|
170 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
171 | + } else |
|
170 | 172 | { |
171 | 173 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
172 | 174 | $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
173 | 175 | } |
174 | - } |
|
175 | - else if ($textleft!='' && $textright!='') // |
|
176 | + } else if ($textleft!='' && $textright!='') { |
|
177 | + // |
|
176 | 178 | { |
177 | 179 | if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
178 | 180 | { |
179 | 181 | 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); |
|
182 | + } else if ($textleft == '__PHOTO__' && $photo) { |
|
183 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
184 | + } |
|
181 | 185 | $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
182 | 186 | $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
183 | - } |
|
184 | - else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
187 | + } else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
185 | 188 | { |
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); |
|
189 | + if ($textright == '__LOGO__' && $logo) { |
|
190 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
191 | + } else if ($textright == '__PHOTO__' && $photo) { |
|
192 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
193 | + } |
|
188 | 194 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
189 | 195 | $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 |
|
196 | + } else // text on halft left and text on half right |
|
192 | 197 | { |
193 | 198 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
194 | 199 | $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
195 | 200 | $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
196 | 201 | $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
197 | 202 | } |
198 | - } |
|
199 | - else // Only a right part |
|
203 | + } else // Only a right part |
|
200 | 204 | { |
201 | 205 | // 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 |
|
206 | + if ($textright == '__LOGO__' && $logo) { |
|
207 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
208 | + } else if ($textright == '__PHOTO__' && $photo) { |
|
209 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
210 | + } else |
|
205 | 211 | { |
206 | 212 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
207 | 213 | $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
@@ -257,7 +263,9 @@ discard block |
||
257 | 263 | |
258 | 264 | if (is_object($object)) |
259 | 265 | { |
260 | - if ($object->country == '-') $object->country=''; |
|
266 | + if ($object->country == '-') { |
|
267 | + $object->country=''; |
|
268 | + } |
|
261 | 269 | |
262 | 270 | // List of values to scan for a replacement |
263 | 271 | $substitutionarray = array ( |
@@ -290,7 +298,10 @@ discard block |
||
290 | 298 | $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
291 | 299 | |
292 | 300 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
301 | + if ($nb <= 0) { |
|
302 | + $nb=1; |
|
303 | + } |
|
304 | + // Protection to avoid empty page |
|
294 | 305 | |
295 | 306 | for($j=0;$j<$nb;$j++) |
296 | 307 | { |
@@ -305,8 +316,7 @@ discard block |
||
305 | 316 | } |
306 | 317 | |
307 | 318 | $arrayofrecords = $arrayofmembers; |
308 | - } |
|
309 | - else |
|
319 | + } else |
|
310 | 320 | { |
311 | 321 | $arrayofrecords = $object; |
312 | 322 | } |
@@ -325,9 +335,13 @@ discard block |
||
325 | 335 | $this->format = $resolution; |
326 | 336 | } |
327 | 337 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
338 | + if (! is_object($outputlangs)) { |
|
339 | + $outputlangs=$langs; |
|
340 | + } |
|
329 | 341 | // 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'; |
|
342 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
343 | + $outputlangs->charset_output='ISO-8859-1'; |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Load traductions files requiredby by page |
333 | 347 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
@@ -336,8 +350,7 @@ discard block |
||
336 | 350 | { |
337 | 351 | $title=$outputlangs->transnoentities('MembersCards'); |
338 | 352 | $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
339 | - } |
|
340 | - else |
|
353 | + } else |
|
341 | 354 | { |
342 | 355 | dol_print_error('','Bad value for $mode'); |
343 | 356 | return -1; |
@@ -349,8 +362,7 @@ discard block |
||
349 | 362 | $outputdir = $conf->adherent->dir_output; |
350 | 363 | $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
351 | 364 | $file = $dir.'/'.$filename; |
352 | - } |
|
353 | - else |
|
365 | + } else |
|
354 | 366 | { |
355 | 367 | $outputdir = $conf->adherent->dir_temp; |
356 | 368 | $dir = $outputdir; |
@@ -382,7 +394,9 @@ discard block |
||
382 | 394 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
383 | 395 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
384 | 396 | $pdf->SetKeyWords($keywords); |
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
397 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
398 | + $pdf->SetCompression(false); |
|
399 | + } |
|
386 | 400 | |
387 | 401 | $pdf->SetMargins(0,0); |
388 | 402 | $pdf->SetAutoPageBreak(false); |
@@ -391,8 +405,16 @@ discard block |
||
391 | 405 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
392 | 406 | $posX=1; |
393 | 407 | $posY=1; |
394 | - if ($posX > 0) $posX--; else $posX=0; |
|
395 | - if ($posY > 0) $posY--; else $posY=0; |
|
408 | + if ($posX > 0) { |
|
409 | + $posX--; |
|
410 | + } else { |
|
411 | + $posX=0; |
|
412 | + } |
|
413 | + if ($posY > 0) { |
|
414 | + $posY--; |
|
415 | + } else { |
|
416 | + $posY=0; |
|
417 | + } |
|
396 | 418 | $this->_COUNTX = $posX; |
397 | 419 | $this->_COUNTY = $posY; |
398 | 420 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -416,8 +438,9 @@ discard block |
||
416 | 438 | // Output to file |
417 | 439 | $pdf->Output($file,'F'); |
418 | 440 | |
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
420 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
441 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
442 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
443 | + } |
|
421 | 444 | |
422 | 445 | |
423 | 446 | $this->result = array('fullpath'=>$file); |
@@ -428,13 +451,20 @@ discard block |
||
428 | 451 | clearstatcache(); |
429 | 452 | |
430 | 453 | $attachment=true; |
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
454 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) { |
|
455 | + $attachment=false; |
|
456 | + } |
|
432 | 457 | $type=dol_mimetype($filename); |
433 | 458 | |
434 | 459 | //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.'"'); |
|
460 | + if ($type) { |
|
461 | + header('Content-Type: '.$type); |
|
462 | + } |
|
463 | + if ($attachment) { |
|
464 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
465 | + } else { |
|
466 | + header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
467 | + } |
|
438 | 468 | |
439 | 469 | // Ajout directives pour resoudre bug IE |
440 | 470 | header('Cache-Control: Public, must-revalidate'); |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | 50 | */ |
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
51 | + function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | // phpcs:enable |
54 | 54 | global $conf; |
55 | 55 | |
56 | - $type='member'; |
|
57 | - $liste=array(); |
|
56 | + $type = 'member'; |
|
57 | + $liste = array(); |
|
58 | 58 | |
59 | 59 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
60 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
60 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | 62 | return $liste; |
63 | 63 | } |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param string $template pdf generenate document class to use default 'standard' |
77 | 77 | * @return int <0 if KO, >0 if OK |
78 | 78 | */ |
79 | -function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard') |
|
79 | +function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard') |
|
80 | 80 | { |
81 | 81 | // phpcs:enable |
82 | - global $conf,$langs; |
|
82 | + global $conf, $langs; |
|
83 | 83 | $langs->load("members"); |
84 | 84 | |
85 | - $error=0; |
|
85 | + $error = 0; |
|
86 | 86 | |
87 | 87 | // Increase limit for PDF build |
88 | - $err=error_reporting(); |
|
88 | + $err = error_reporting(); |
|
89 | 89 | error_reporting(0); |
90 | 90 | @set_time_limit(120); |
91 | 91 | error_reporting($err); |
92 | 92 | |
93 | - $code=''; |
|
94 | - $srctemplatepath=''; |
|
93 | + $code = ''; |
|
94 | + $srctemplatepath = ''; |
|
95 | 95 | |
96 | 96 | // Positionne le modele sur le nom du modele a utiliser |
97 | - if (! dol_strlen($modele)) |
|
97 | + if (!dol_strlen($modele)) |
|
98 | 98 | { |
99 | - if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
99 | + if (!empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
100 | 100 | { |
101 | 101 | $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
102 | 102 | } |
@@ -105,33 +105,33 @@ discard block |
||
105 | 105 | $code = $modele; |
106 | 106 | } |
107 | 107 | } |
108 | - else $code=$modele; |
|
108 | + else $code = $modele; |
|
109 | 109 | |
110 | 110 | // If selected modele is a filename template (then $modele="modelname:filename") |
111 | - $tmp=explode(':',$template,2); |
|
112 | - if (! empty($tmp[1])) |
|
111 | + $tmp = explode(':', $template, 2); |
|
112 | + if (!empty($tmp[1])) |
|
113 | 113 | { |
114 | - $template=$tmp[0]; |
|
115 | - $srctemplatepath=$tmp[1]; |
|
114 | + $template = $tmp[0]; |
|
115 | + $srctemplatepath = $tmp[1]; |
|
116 | 116 | } |
117 | - else $srctemplatepath=$code; |
|
117 | + else $srctemplatepath = $code; |
|
118 | 118 | |
119 | 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) |
|
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 | 124 | { |
125 | - foreach(array('doc','pdf') as $prefix) |
|
125 | + foreach (array('doc', 'pdf') as $prefix) |
|
126 | 126 | { |
127 | 127 | $file = $prefix."_".$template.".class.php"; |
128 | 128 | |
129 | 129 | // On verifie l'emplacement du modele |
130 | - $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0); |
|
130 | + $file = dol_buildpath($reldir."core/modules/member/doc/".$file, 0); |
|
131 | 131 | if (file_exists($file)) |
132 | 132 | { |
133 | - $filefound=1; |
|
134 | - $classname=$prefix.'_'.$template; |
|
133 | + $filefound = 1; |
|
134 | + $classname = $prefix.'_'.$template; |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | } |
@@ -148,23 +148,23 @@ discard block |
||
148 | 148 | |
149 | 149 | // We save charset_output to restore it because write_file can change it if needed for |
150 | 150 | // output format that does not support UTF8. |
151 | - $sav_charset_output=$outputlangs->charset_output; |
|
151 | + $sav_charset_output = $outputlangs->charset_output; |
|
152 | 152 | if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) |
153 | 153 | { |
154 | - $outputlangs->charset_output=$sav_charset_output; |
|
154 | + $outputlangs->charset_output = $sav_charset_output; |
|
155 | 155 | return 1; |
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $outputlangs->charset_output=$sav_charset_output; |
|
160 | - dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
|
159 | + $outputlangs->charset_output = $sav_charset_output; |
|
160 | + dol_print_error($db, "members_card_pdf_create Error: ".$obj->error); |
|
161 | 161 | return -1; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | else |
166 | 166 | { |
167 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
167 | + dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file)); |
|
168 | 168 | return -1; |
169 | 169 | } |
170 | 170 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
100 | 100 | { |
101 | 101 | $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
102 | - } |
|
103 | - else |
|
102 | + } else |
|
104 | 103 | { |
105 | 104 | $code = $modele; |
106 | 105 | } |
106 | + } else { |
|
107 | + $code=$modele; |
|
107 | 108 | } |
108 | - else $code=$modele; |
|
109 | 109 | |
110 | 110 | // If selected modele is a filename template (then $modele="modelname:filename") |
111 | 111 | $tmp=explode(':',$template,2); |
@@ -113,13 +113,16 @@ discard block |
||
113 | 113 | { |
114 | 114 | $template=$tmp[0]; |
115 | 115 | $srctemplatepath=$tmp[1]; |
116 | + } else { |
|
117 | + $srctemplatepath=$code; |
|
116 | 118 | } |
117 | - else $srctemplatepath=$code; |
|
118 | 119 | |
119 | 120 | // Search template files |
120 | 121 | $file=''; $classname=''; $filefound=0; |
121 | 122 | $dirmodels=array('/'); |
122 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | + if (is_array($conf->modules_parts['models'])) { |
|
124 | + $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
125 | + } |
|
123 | 126 | foreach($dirmodels as $reldir) |
124 | 127 | { |
125 | 128 | foreach(array('doc','pdf') as $prefix) |
@@ -135,7 +138,9 @@ discard block |
||
135 | 138 | break; |
136 | 139 | } |
137 | 140 | } |
138 | - if ($filefound) break; |
|
141 | + if ($filefound) { |
|
142 | + break; |
|
143 | + } |
|
139 | 144 | } |
140 | 145 | |
141 | 146 | |
@@ -153,16 +158,13 @@ discard block |
||
153 | 158 | { |
154 | 159 | $outputlangs->charset_output=$sav_charset_output; |
155 | 160 | return 1; |
156 | - } |
|
157 | - else |
|
161 | + } else |
|
158 | 162 | { |
159 | 163 | $outputlangs->charset_output=$sav_charset_output; |
160 | 164 | dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
161 | 165 | return -1; |
162 | 166 | } |
163 | - } |
|
164 | - |
|
165 | - else |
|
167 | + } else |
|
166 | 168 | { |
167 | 169 | dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
168 | 170 | return -1; |
@@ -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); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * \brief Fichier de description et activation du module Ficheinter |
29 | 29 | */ |
30 | 30 | |
31 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
31 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->family = "crm"; |
53 | 53 | $this->module_position = '45'; |
54 | 54 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
55 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
56 | 56 | $this->description = "Gestion des fiches d'intervention"; |
57 | 57 | |
58 | 58 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $this->depends = array("modSociete"); |
69 | 69 | $this->requiredby = array(); |
70 | 70 | $this->conflictwith = array(); |
71 | - $this->langfiles = array("bills","companies","interventions"); |
|
71 | + $this->langfiles = array("bills", "companies", "interventions"); |
|
72 | 72 | |
73 | 73 | // Config pages |
74 | 74 | $this->config_page_url = array("fichinter.php"); |
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $this->const[$r][0] = "FICHEINTER_ADDON_PDF"; |
81 | 81 | $this->const[$r][1] = "chaine"; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | $r++; |
89 | 89 | |
90 | 90 | // Boxes |
91 | - $this->boxes = array(0=>array('file'=>'box_ficheinter.php','enabledbydefaulton'=>'Home')); |
|
91 | + $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home')); |
|
92 | 92 | |
93 | 93 | // Permissions |
94 | 94 | $this->rights = array(); |
95 | 95 | $this->rights_class = 'ficheinter'; |
96 | - $r=0; |
|
96 | + $r = 0; |
|
97 | 97 | |
98 | 98 | $r++; |
99 | 99 | $this->rights[$r][0] = 61; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel'; |
129 | 129 | $this->rights[$r][2] = 'r'; |
130 | 130 | $this->rights[$r][3] = 0; |
131 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
131 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
132 | 132 | $this->rights[$r][5] = 'send'; |
133 | 133 | |
134 | 134 | $r++; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->rights[$r][1] = 'Valider les fiches d\'intervention '; |
137 | 137 | $this->rights[$r][2] = 'a'; |
138 | 138 | $this->rights[$r][3] = 0; |
139 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
139 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
140 | 140 | $this->rights[$r][5] = 'validate'; |
141 | 141 | |
142 | 142 | $r++; |
@@ -144,28 +144,28 @@ discard block |
||
144 | 144 | $this->rights[$r][1] = 'Dévalider les fiches d\'intervention'; |
145 | 145 | $this->rights[$r][2] = 'a'; |
146 | 146 | $this->rights[$r][3] = 0; |
147 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
147 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
148 | 148 | $this->rights[$r][5] = 'unvalidate'; |
149 | 149 | |
150 | 150 | |
151 | 151 | // Menus |
152 | 152 | //------- |
153 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
153 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
154 | 154 | |
155 | 155 | |
156 | 156 | //Exports |
157 | 157 | //-------- |
158 | - $r=1; |
|
159 | - |
|
160 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
161 | - $this->export_label[$r]='InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
162 | - $this->export_permission[$r]=array(array("ficheinter","export")); |
|
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" |
|
158 | + $r = 1; |
|
159 | + |
|
160 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
161 | + $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
162 | + $this->export_permission[$r] = array(array("ficheinter", "export")); |
|
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 | 169 | ); |
170 | 170 | //$this->export_TypeFields_array[$r]=array( |
171 | 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', |
@@ -174,28 +174,28 @@ discard block |
||
174 | 174 | // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", |
175 | 175 | // 'fd.total_ht'=>"Numeric" |
176 | 176 | //); |
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" |
|
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 | 182 | ); |
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' |
|
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 | 189 | ); |
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 | - |
|
192 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
193 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
194 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
195 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; |
|
196 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; |
|
197 | - $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; |
|
198 | - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention').')'; |
|
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 | + |
|
192 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
193 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
194 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
195 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; |
|
196 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; |
|
197 | + $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; |
|
198 | + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')'; |
|
199 | 199 | $r++; |
200 | 200 | } |
201 | 201 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param string $options Options when enabling module ('', 'noboxes') |
209 | 209 | * @return int 1 if OK, 0 if KO |
210 | 210 | */ |
211 | - function init($options='') |
|
211 | + function init($options = '') |
|
212 | 212 | { |
213 | 213 | global $conf; |
214 | 214 | |
@@ -220,6 +220,6 @@ discard block |
||
220 | 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 | - return $this->_init($sql,$options); |
|
223 | + return $this->_init($sql, $options); |
|
224 | 224 | } |
225 | 225 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \brief Fichier de description et activation du module Expedition |
28 | 28 | */ |
29 | 29 | |
30 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
30 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->family = "crm"; |
52 | 52 | $this->module_position = '40'; |
53 | 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)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | $this->description = "Gestion des expeditions"; |
56 | 56 | |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | $this->depends = array("modCommande"); |
78 | 78 | $this->requiredby = array(); |
79 | 79 | $this->conflictwith = array(); |
80 | - $this->langfiles = array('deliveries','sendings'); |
|
80 | + $this->langfiles = array('deliveries', 'sendings'); |
|
81 | 81 | |
82 | 82 | // Constants |
83 | 83 | $this->const = array(); |
84 | - $r=0; |
|
84 | + $r = 0; |
|
85 | 85 | |
86 | 86 | $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; |
87 | 87 | $this->const[$r][1] = "chaine"; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | // Permissions |
139 | 139 | $this->rights = array(); |
140 | 140 | $this->rights_class = 'expedition'; |
141 | - $r=0; |
|
141 | + $r = 0; |
|
142 | 142 | |
143 | 143 | $r++; |
144 | 144 | $this->rights[$r][0] = 101; |
@@ -220,90 +220,90 @@ discard block |
||
220 | 220 | |
221 | 221 | // Menus |
222 | 222 | //------- |
223 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
223 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
224 | 224 | |
225 | 225 | |
226 | 226 | // Exports |
227 | 227 | //-------- |
228 | - $r=0; |
|
228 | + $r = 0; |
|
229 | 229 | |
230 | 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,''))); |
|
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 | 235 | } else { |
236 | - $idcontacts=0; |
|
236 | + $idcontacts = 0; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
240 | 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' |
|
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 | 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'); |
|
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 | 254 | //$this->export_TypeFields_array[$r]=array( |
255 | 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 | 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 | 257 | // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", |
258 | 258 | // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text" |
259 | 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' |
|
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 | 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' |
|
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 | 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)) |
|
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 | 278 | { |
279 | - $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3'; |
|
279 | + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; |
|
280 | 280 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
281 | 281 | } |
282 | - $keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra'; |
|
282 | + $keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra'; |
|
283 | 283 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
284 | - $keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2'; |
|
284 | + $keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2'; |
|
285 | 285 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
286 | 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)) |
|
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 | 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'; |
|
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 | 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; |
|
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 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -315,27 +315,27 @@ discard block |
||
315 | 315 | * @param string $options Options when enabling module ('', 'noboxes') |
316 | 316 | * @return int 1 if OK, 0 if KO |
317 | 317 | */ |
318 | - function init($options='') |
|
318 | + function init($options = '') |
|
319 | 319 | { |
320 | - global $conf,$langs; |
|
320 | + global $conf, $langs; |
|
321 | 321 | |
322 | 322 | // Permissions |
323 | 323 | $this->remove($options); |
324 | 324 | |
325 | 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'; |
|
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 | 329 | |
330 | - if (file_exists($src) && ! file_exists($dest)) |
|
330 | + if (file_exists($src) && !file_exists($dest)) |
|
331 | 331 | { |
332 | 332 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
333 | 333 | dol_mkdir($dirodt); |
334 | - $result=dol_copy($src,$dest,0,0); |
|
334 | + $result = dol_copy($src, $dest, 0, 0); |
|
335 | 335 | if ($result < 0) |
336 | 336 | { |
337 | 337 | $langs->load("errors"); |
338 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
338 | + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
339 | 339 | return 0; |
340 | 340 | } |
341 | 341 | } |
@@ -349,6 +349,6 @@ discard block |
||
349 | 349 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".$conf->entity.")", |
350 | 350 | ); |
351 | 351 | |
352 | - return $this->_init($sql,$options); |
|
352 | + return $this->_init($sql, $options); |
|
353 | 353 | } |
354 | 354 | } |
@@ -250,7 +250,9 @@ discard block |
||
250 | 250 | 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', |
251 | 251 | 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' |
252 | 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'); |
|
253 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { |
|
254 | + $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); |
|
255 | + } |
|
254 | 256 | //$this->export_TypeFields_array[$r]=array( |
255 | 257 | // '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 | 258 | // '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", |
@@ -272,7 +274,9 @@ discard block |
||
272 | 274 | 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', |
273 | 275 | 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' |
274 | 276 | ); |
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'); |
|
277 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { |
|
278 | + $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); |
|
279 | + } |
|
276 | 280 | $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 | 281 | if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
278 | 282 | { |
@@ -288,7 +292,9 @@ discard block |
||
288 | 292 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; |
289 | 293 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; |
290 | 294 | $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'; |
|
295 | + if(!$user->rights->societe->client->voir) { |
|
296 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
297 | + } |
|
292 | 298 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
293 | 299 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
294 | 300 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; |
@@ -303,7 +309,9 @@ discard block |
||
303 | 309 | } |
304 | 310 | $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 | 311 | $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; |
|
312 | + if(!$user->rights->societe->client->voir) { |
|
313 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
314 | + } |
|
307 | 315 | } |
308 | 316 | |
309 | 317 |
@@ -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 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup workflow |
24 | 24 | * \brief File to describe and activate module Workflow |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | |
44 | 44 | // Id for module (must be unique). |
45 | 45 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
46 | - $this->numero = 6000 ; |
|
46 | + $this->numero = 6000; |
|
47 | 47 | // Key text used to identify module (for permissions, menus, etc...) |
48 | 48 | $this->rights_class = 'workflow'; |
49 | 49 | |
50 | 50 | $this->family = "technic"; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
54 | 54 | $this->description = "Workflow management"; |
55 | 55 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // Name of png file (without png) used for this module. |
60 | 60 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
61 | 61 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
62 | - $this->picto='technic'; |
|
62 | + $this->picto = 'technic'; |
|
63 | 63 | |
64 | 64 | // Data directories to create when module is enabled |
65 | 65 | $this->dirs = array("/workflow/temp"); |
@@ -68,26 +68,26 @@ 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 |
|
76 | - $this->need_dolibarr_version = array(2,8); // Minimum version of Dolibarr 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 | + $this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module |
|
77 | 77 | $this->langfiles = array("@workflow"); |
78 | 78 | |
79 | 79 | // Constants |
80 | 80 | // List of particular constants to add when module is enabled |
81 | 81 | //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), |
82 | 82 | // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); |
83 | - $this->const=array(); |
|
83 | + $this->const = array(); |
|
84 | 84 | |
85 | 85 | // Boxes |
86 | 86 | $this->boxes = array(); |
87 | 87 | |
88 | 88 | // Permissions |
89 | 89 | $this->rights = array(); |
90 | - $r=0; |
|
90 | + $r = 0; |
|
91 | 91 | |
92 | 92 | /* |
93 | 93 | $r++; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | |
101 | 101 | // Main menu entries |
102 | - $this->menus = array(); // List of menus to add |
|
103 | - $r=0; |
|
102 | + $this->menus = array(); // List of menus to add |
|
103 | + $r = 0; |
|
104 | 104 | /* |
105 | 105 | $this->menu[$r]=array('fk_menu'=>0, |
106 | 106 | 'type'=>'top', |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | * @param string $options Options when enabling module ('', 'noboxes') |
140 | 140 | * @return int 1 if OK, 0 if KO |
141 | 141 | */ |
142 | - function init($options='') |
|
142 | + function init($options = '') |
|
143 | 143 | { |
144 | 144 | // Permissions |
145 | 145 | $this->remove($options); |
146 | 146 | |
147 | 147 | $sql = array(); |
148 | 148 | |
149 | - return $this->_init($sql,$options); |
|
149 | + return $this->_init($sql, $options); |
|
150 | 150 | } |
151 | 151 | } |
@@ -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 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function __construct($db) |
49 | 49 | { |
50 | - global $conf,$langs,$mysoc; |
|
50 | + global $conf, $langs, $mysoc; |
|
51 | 51 | |
52 | 52 | // Load traductions files requiredby by page |
53 | 53 | $langs->loadLangs(array("main", "bills")); |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | |
60 | 60 | // Dimension page pour format A4 |
61 | 61 | $this->type = 'pdf'; |
62 | - $formatarray=pdf_getFormat(); |
|
62 | + $formatarray = pdf_getFormat(); |
|
63 | 63 | $this->page_largeur = $formatarray['width']; |
64 | 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; |
|
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 | - $this->emetteur=$mysoc; |
|
73 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
72 | + $this->emetteur = $mysoc; |
|
73 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
74 | 74 | |
75 | 75 | // Defini position des colonnes |
76 | 76 | $this->line_height = 5; |
77 | 77 | $this->line_per_page = 40; |
78 | - $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
78 | + $this->tab_height = 200; //$this->line_height * $this->line_per_page; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -91,49 +91,49 @@ discard block |
||
91 | 91 | function write_file($object, $_dir, $number, $outputlangs) |
92 | 92 | { |
93 | 93 | // phpcs:enable |
94 | - global $user,$conf,$langs,$hookmanager; |
|
94 | + global $user, $conf, $langs, $hookmanager; |
|
95 | 95 | |
96 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
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 |
98 | - $sav_charset_output=$outputlangs->charset_output; |
|
99 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
98 | + $sav_charset_output = $outputlangs->charset_output; |
|
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 | 102 | $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); |
103 | 103 | |
104 | - $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; |
|
104 | + $dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number; |
|
105 | 105 | |
106 | - if (! is_dir($dir)) |
|
106 | + if (!is_dir($dir)) |
|
107 | 107 | { |
108 | - $result=dol_mkdir($dir); |
|
108 | + $result = dol_mkdir($dir); |
|
109 | 109 | |
110 | 110 | if ($result < 0) |
111 | 111 | { |
112 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
112 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
113 | 113 | return -1; |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - $file = $dir . "/bordereau-".$number.".pdf"; |
|
117 | + $file = $dir."/bordereau-".$number.".pdf"; |
|
118 | 118 | |
119 | 119 | // Add pdfgeneration hook |
120 | - if (! is_object($hookmanager)) |
|
120 | + if (!is_object($hookmanager)) |
|
121 | 121 | { |
122 | 122 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
123 | - $hookmanager=new HookManager($this->db); |
|
123 | + $hookmanager = new HookManager($this->db); |
|
124 | 124 | } |
125 | 125 | $hookmanager->initHooks(array('pdfgeneration')); |
126 | - $parameters=array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
126 | + $parameters = array('file'=>$file, 'outputlangs'=>$outputlangs); |
|
127 | 127 | global $action; |
128 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
128 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
129 | 129 | |
130 | 130 | // Create PDF instance |
131 | - $pdf=pdf_getInstance($this->format); |
|
132 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
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 |
|
134 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
135 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
136 | - $pdf->SetAutoPageBreak(1,0); |
|
131 | + $pdf = pdf_getInstance($this->format); |
|
132 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
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 |
|
134 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
135 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
136 | + $pdf->SetAutoPageBreak(1, 0); |
|
137 | 137 | |
138 | 138 | if (class_exists('TCPDF')) |
139 | 139 | { |
@@ -143,23 +143,23 @@ discard block |
||
143 | 143 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
144 | 144 | |
145 | 145 | $pdf->Open(); |
146 | - $pagenb=0; |
|
147 | - $pdf->SetDrawColor(128,128,128); |
|
146 | + $pagenb = 0; |
|
147 | + $pdf->SetDrawColor(128, 128, 128); |
|
148 | 148 | |
149 | 149 | $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt")." ".$number); |
150 | 150 | $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); |
151 | 151 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
152 | 152 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
153 | 153 | $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
154 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
154 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
155 | 155 | |
156 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
156 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
157 | 157 | |
158 | - $nboflines=count($this->lines); |
|
158 | + $nboflines = count($this->lines); |
|
159 | 159 | |
160 | 160 | // Define nb of page |
161 | 161 | $pages = intval($nboflines / $this->line_per_page); |
162 | - if (($nboflines % $this->line_per_page)>0) |
|
162 | + if (($nboflines % $this->line_per_page) > 0) |
|
163 | 163 | { |
164 | 164 | $pages++; |
165 | 165 | } |
@@ -176,31 +176,31 @@ discard block |
||
176 | 176 | $this->Body($pdf, $pagenb, $pages, $outputlangs); |
177 | 177 | |
178 | 178 | // Pied de page |
179 | - $this->_pagefoot($pdf,'',$outputlangs); |
|
180 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
179 | + $this->_pagefoot($pdf, '', $outputlangs); |
|
180 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
181 | 181 | |
182 | 182 | $pdf->Close(); |
183 | 183 | |
184 | - $pdf->Output($file,'F'); |
|
184 | + $pdf->Output($file, 'F'); |
|
185 | 185 | |
186 | 186 | // Add pdfgeneration hook |
187 | - if (! is_object($hookmanager)) |
|
187 | + if (!is_object($hookmanager)) |
|
188 | 188 | { |
189 | 189 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
190 | - $hookmanager=new HookManager($this->db); |
|
190 | + $hookmanager = new HookManager($this->db); |
|
191 | 191 | } |
192 | 192 | $hookmanager->initHooks(array('pdfgeneration')); |
193 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
193 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
194 | 194 | global $action; |
195 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
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)) |
|
197 | + if (!empty($conf->global->MAIN_UMASK)) |
|
198 | 198 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
199 | 199 | |
200 | 200 | $this->result = array('fullpath'=>$file); |
201 | 201 | |
202 | - $outputlangs->charset_output=$sav_charset_output; |
|
203 | - return 1; // Pas d'erreur |
|
202 | + $outputlangs->charset_output = $sav_charset_output; |
|
203 | + return 1; // Pas d'erreur |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -224,38 +224,38 @@ discard block |
||
224 | 224 | $outputlangs->loadLangs(array("compta", "banks")); |
225 | 225 | |
226 | 226 | $title = $outputlangs->transnoentities("CheckReceipt"); |
227 | - $pdf->SetFont('','B', $default_font_size); |
|
228 | - $pdf->SetXY(10,8); |
|
229 | - $pdf->MultiCell(0,2,$title,0,'L'); |
|
230 | - |
|
231 | - $pdf->SetFont('','', $default_font_size); |
|
232 | - $pdf->SetXY(10,15); |
|
233 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Ref"),0,'L'); |
|
234 | - $pdf->SetXY(32,15); |
|
235 | - $pdf->SetFont('','', $default_font_size); |
|
236 | - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext?" - ".$this->ref_ext:'')), 0, 'L'); |
|
237 | - |
|
238 | - $pdf->SetFont('','', $default_font_size); |
|
239 | - $pdf->SetXY(10,20); |
|
240 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Date"),0,'L'); |
|
241 | - $pdf->SetXY(32,20); |
|
242 | - $pdf->SetFont('','', $default_font_size); |
|
243 | - $pdf->MultiCell(60, 2, dol_print_date($this->date,"day",false,$outputlangs)); |
|
244 | - |
|
245 | - $pdf->SetFont('','', $default_font_size); |
|
246 | - $pdf->SetXY(10,26); |
|
247 | - $pdf->MultiCell(22,2,$outputlangs->transnoentities("Owner"),0,'L'); |
|
248 | - $pdf->SetFont('','', $default_font_size); |
|
249 | - $pdf->SetXY(32,26); |
|
250 | - $pdf->MultiCell(60,2,$outputlangs->convToOutputCharset($this->account->proprio),0,'L'); |
|
251 | - |
|
252 | - $pdf->SetFont('','', $default_font_size); |
|
253 | - $pdf->SetXY(10,32); |
|
254 | - $pdf->MultiCell(0,2,$outputlangs->transnoentities("Account"),0,'L'); |
|
255 | - pdf_bank($pdf,$outputlangs,32,32,$this->account,1); |
|
256 | - |
|
257 | - $pdf->SetFont('','', $default_font_size); |
|
258 | - $pdf->SetXY(114,15); |
|
227 | + $pdf->SetFont('', 'B', $default_font_size); |
|
228 | + $pdf->SetXY(10, 8); |
|
229 | + $pdf->MultiCell(0, 2, $title, 0, 'L'); |
|
230 | + |
|
231 | + $pdf->SetFont('', '', $default_font_size); |
|
232 | + $pdf->SetXY(10, 15); |
|
233 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L'); |
|
234 | + $pdf->SetXY(32, 15); |
|
235 | + $pdf->SetFont('', '', $default_font_size); |
|
236 | + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L'); |
|
237 | + |
|
238 | + $pdf->SetFont('', '', $default_font_size); |
|
239 | + $pdf->SetXY(10, 20); |
|
240 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L'); |
|
241 | + $pdf->SetXY(32, 20); |
|
242 | + $pdf->SetFont('', '', $default_font_size); |
|
243 | + $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs)); |
|
244 | + |
|
245 | + $pdf->SetFont('', '', $default_font_size); |
|
246 | + $pdf->SetXY(10, 26); |
|
247 | + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); |
|
248 | + $pdf->SetFont('', '', $default_font_size); |
|
249 | + $pdf->SetXY(32, 26); |
|
250 | + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); |
|
251 | + |
|
252 | + $pdf->SetFont('', '', $default_font_size); |
|
253 | + $pdf->SetXY(10, 32); |
|
254 | + $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); |
|
255 | + pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); |
|
256 | + |
|
257 | + $pdf->SetFont('', '', $default_font_size); |
|
258 | + $pdf->SetXY(114, 15); |
|
259 | 259 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); |
260 | 260 | |
261 | 261 | $pdf->Rect(9, 14, 192, 35); |
@@ -268,44 +268,44 @@ discard block |
||
268 | 268 | $pdf->line(112, 14, 112, 49); |
269 | 269 | |
270 | 270 | // Number of cheques |
271 | - $posy=51; |
|
271 | + $posy = 51; |
|
272 | 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); |
|
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); |
|
277 | + $pdf->SetFont('', '', $default_font_size); |
|
278 | + $pdf->SetXY(10, $posy + 1); |
|
279 | 279 | $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); |
280 | 280 | |
281 | - $pdf->SetFont('','B', $default_font_size); |
|
282 | - $pdf->SetXY(57,$posy+1); |
|
281 | + $pdf->SetFont('', 'B', $default_font_size); |
|
282 | + $pdf->SetXY(57, $posy + 1); |
|
283 | 283 | $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); |
284 | 284 | |
285 | - $pdf->SetFont('','', $default_font_size); |
|
286 | - $pdf->SetXY(148,$posy+1); |
|
285 | + $pdf->SetFont('', '', $default_font_size); |
|
286 | + $pdf->SetXY(148, $posy + 1); |
|
287 | 287 | $pdf->MultiCell(40, 2, $langs->trans("Total")); |
288 | 288 | |
289 | - $pdf->SetFont('','B', $default_font_size); |
|
290 | - $pdf->SetXY(170, $posy+1); |
|
289 | + $pdf->SetFont('', 'B', $default_font_size); |
|
290 | + $pdf->SetXY(170, $posy + 1); |
|
291 | 291 | $pdf->MultiCell(31, 2, price($this->amount), 0, 'C', 0); |
292 | 292 | |
293 | 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'); |
|
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 | 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); |
|
300 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("Bank"), 0, 'L'); |
|
299 | + $pdf->SetXY(41, $this->tab_top + 2); |
|
300 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L'); |
|
301 | 301 | $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); |
302 | 302 | |
303 | - $pdf->SetXY(101, $this->tab_top+2); |
|
304 | - $pdf->MultiCell(40,2,$outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
303 | + $pdf->SetXY(101, $this->tab_top + 2); |
|
304 | + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); |
|
305 | 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'); |
|
307 | + $pdf->SetXY(180, $this->tab_top + 2); |
|
308 | + $pdf->MultiCell(20, 2, $outputlangs->transnoentities("Amount"), 0, 'R'); |
|
309 | 309 | $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8); |
310 | 310 | |
311 | 311 | $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); |
@@ -329,44 +329,44 @@ discard block |
||
329 | 329 | // x=30 - Banque |
330 | 330 | // x=100 - Emetteur |
331 | 331 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
332 | - $pdf->SetFont('','', $default_font_size - 1); |
|
332 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
333 | 333 | $oldprowid = 0; |
334 | - $pdf->SetFillColor(220,220,220); |
|
334 | + $pdf->SetFillColor(220, 220, 220); |
|
335 | 335 | $yp = 0; |
336 | - $lineinpage=0; |
|
337 | - $num=count($this->lines); |
|
336 | + $lineinpage = 0; |
|
337 | + $num = count($this->lines); |
|
338 | 338 | for ($j = 0; $j < $num; $j++) |
339 | 339 | { |
340 | 340 | $lineinpage++; |
341 | 341 | |
342 | 342 | $pdf->SetXY(1, $this->tab_top + 10 + $yp); |
343 | - $pdf->MultiCell(8, $this->line_height, $j+1, 0, 'R', 0); |
|
343 | + $pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0); |
|
344 | 344 | |
345 | 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); |
|
346 | + $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq : '', 0, 'L', 0); |
|
347 | 347 | |
348 | 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); |
|
349 | + $pdf->MultiCell(70, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->bank_chq), 44), 0, 'L', 0); |
|
350 | 350 | |
351 | 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); |
|
352 | + $pdf->MultiCell(80, $this->line_height, dol_trunc($outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq), 50), 0, 'L', 0); |
|
353 | 353 | |
354 | 354 | $pdf->SetXY(180, $this->tab_top + 10 + $yp); |
355 | 355 | $pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0); |
356 | 356 | |
357 | 357 | $yp = $yp + $this->line_height; |
358 | 358 | |
359 | - if ($lineinpage >= $this->line_per_page && $j < (count($this->lines)-1)) |
|
359 | + if ($lineinpage >= $this->line_per_page && $j < (count($this->lines) - 1)) |
|
360 | 360 | { |
361 | - $lineinpage=0; $yp=0; |
|
361 | + $lineinpage = 0; $yp = 0; |
|
362 | 362 | |
363 | 363 | // New page |
364 | 364 | $pdf->AddPage(); |
365 | 365 | $pagenb++; |
366 | 366 | $this->Header($pdf, $pagenb, $pages, $outputlangs); |
367 | - $pdf->SetFont('','', $default_font_size - 1); |
|
368 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
369 | - $pdf->SetTextColor(0,0,0); |
|
367 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
368 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
369 | + $pdf->SetTextColor(0, 0, 0); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | * @param int $hidefreetext 1=Hide free text |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
384 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
385 | 385 | { |
386 | 386 | global $conf; |
387 | 387 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
388 | 388 | |
389 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
389 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
390 | 390 | |
391 | 391 | // Line of free text |
392 | - $newfreetext=''; |
|
393 | - $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
394 | - if (! empty($conf->global->$paramfreetext)) |
|
392 | + $newfreetext = ''; |
|
393 | + $paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT'; |
|
394 | + if (!empty($conf->global->$paramfreetext)) |
|
395 | 395 | { |
396 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
396 | + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); |
|
397 | 397 | } |
398 | 398 | |
399 | - return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
399 | + return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
400 | 400 | } |
401 | 401 | } |
@@ -70,7 +70,10 @@ discard block |
||
70 | 70 | |
71 | 71 | // Recupere emmetteur |
72 | 72 | $this->emetteur=$mysoc; |
73 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
73 | + if (! $this->emetteur->country_code) { |
|
74 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
75 | + } |
|
76 | + // By default if not defined |
|
74 | 77 | |
75 | 78 | // Defini position des colonnes |
76 | 79 | $this->line_height = 5; |
@@ -93,10 +96,14 @@ discard block |
||
93 | 96 | // phpcs:enable |
94 | 97 | global $user,$conf,$langs,$hookmanager; |
95 | 98 | |
96 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
99 | + if (! is_object($outputlangs)) { |
|
100 | + $outputlangs=$langs; |
|
101 | + } |
|
97 | 102 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
98 | 103 | $sav_charset_output=$outputlangs->charset_output; |
99 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
104 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
105 | + $outputlangs->charset_output='ISO-8859-1'; |
|
106 | + } |
|
100 | 107 | |
101 | 108 | // Load traductions files requiredby by page |
102 | 109 | $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); |
@@ -132,7 +139,9 @@ discard block |
||
132 | 139 | $heightforinfotot = 50; // Height reserved to output the info and total part |
133 | 140 | $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 |
134 | 141 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
135 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
142 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
143 | + $heightforfooter+= 6; |
|
144 | + } |
|
136 | 145 | $pdf->SetAutoPageBreak(1,0); |
137 | 146 | |
138 | 147 | if (class_exists('TCPDF')) |
@@ -151,7 +160,9 @@ discard block |
||
151 | 160 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
152 | 161 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
153 | 162 | $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt")." ".$number); |
154 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
163 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
164 | + $pdf->SetCompression(false); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
157 | 168 | |
@@ -177,7 +188,9 @@ discard block |
||
177 | 188 | |
178 | 189 | // Pied de page |
179 | 190 | $this->_pagefoot($pdf,'',$outputlangs); |
180 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
191 | + if (method_exists($pdf,'AliasNbPages')) { |
|
192 | + $pdf->AliasNbPages(); |
|
193 | + } |
|
181 | 194 | |
182 | 195 | $pdf->Close(); |
183 | 196 | |
@@ -194,8 +207,9 @@ discard block |
||
194 | 207 | global $action; |
195 | 208 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
196 | 209 | |
197 | - if (! empty($conf->global->MAIN_UMASK)) |
|
198 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
210 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
211 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
212 | + } |
|
199 | 213 | |
200 | 214 | $this->result = array('fullpath'=>$file); |
201 | 215 |
@@ -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 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Mint |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage cheque receipts numbering rules Mint |
@@ -33,16 +33,16 @@ discard block |
||
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 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | - public $name='Mint'; |
|
45 | + public $name = 'Mint'; |
|
46 | 46 | |
47 | 47 | |
48 | 48 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | function info() |
54 | 54 | { |
55 | 55 | global $langs; |
56 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
56 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -76,26 +76,26 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function canBeActivated() |
78 | 78 | { |
79 | - global $conf,$langs,$db; |
|
79 | + global $conf, $langs, $db; |
|
80 | 80 | |
81 | - $payyymm=''; $max=''; |
|
81 | + $payyymm = ''; $max = ''; |
|
82 | 82 | |
83 | - $posindice=9; |
|
83 | + $posindice = 9; |
|
84 | 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; |
|
85 | + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
86 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
87 | + $sql .= " AND entity = ".$conf->entity; |
|
88 | 88 | |
89 | - $resql=$db->query($sql); |
|
89 | + $resql = $db->query($sql); |
|
90 | 90 | if ($resql) |
91 | 91 | { |
92 | 92 | $row = $db->fetch_row($resql); |
93 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
93 | + if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
94 | 94 | } |
95 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
95 | + if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) |
|
96 | 96 | { |
97 | 97 | $langs->load("errors"); |
98 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
98 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
@@ -109,23 +109,23 @@ discard block |
||
109 | 109 | * @param Object $object Object we need next value for |
110 | 110 | * @return string Value if KO, <0 if KO |
111 | 111 | */ |
112 | - function getNextValue($objsoc,$object) |
|
112 | + function getNextValue($objsoc, $object) |
|
113 | 113 | { |
114 | - global $db,$conf; |
|
114 | + global $db, $conf; |
|
115 | 115 | |
116 | 116 | // D'abord on recupere la valeur max |
117 | - $posindice=9; |
|
117 | + $posindice = 9; |
|
118 | 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; |
|
119 | + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; |
|
120 | + $sql .= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
121 | + $sql .= " AND entity = ".$conf->entity; |
|
122 | 122 | |
123 | - $resql=$db->query($sql); |
|
123 | + $resql = $db->query($sql); |
|
124 | 124 | if ($resql) |
125 | 125 | { |
126 | 126 | $obj = $db->fetch_object($resql); |
127 | 127 | if ($obj) $max = intval($obj->max); |
128 | - else $max=0; |
|
128 | + else $max = 0; |
|
129 | 129 | } |
130 | 130 | else |
131 | 131 | { |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | //$date=time(); |
137 | - $date=$object->date_bordereau; |
|
138 | - $yymm = strftime("%y%m",$date); |
|
137 | + $date = $object->date_bordereau; |
|
138 | + $yymm = strftime("%y%m", $date); |
|
139 | 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); |
|
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 | 142 | |
143 | 143 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
144 | 144 | return $this->prefix.$yymm."-".$num; |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | * @param string $objforref Object for number to search |
154 | 154 | * @return string Next free value |
155 | 155 | */ |
156 | - function chequereceipt_get_num($objsoc,$objforref) |
|
156 | + function chequereceipt_get_num($objsoc, $objforref) |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | - return $this->getNextValue($objsoc,$objforref); |
|
159 | + return $this->getNextValue($objsoc, $objforref); |
|
160 | 160 | } |
161 | 161 | } |
@@ -124,10 +124,12 @@ discard block |
||
124 | 124 | if ($resql) |
125 | 125 | { |
126 | 126 | $obj = $db->fetch_object($resql); |
127 | - if ($obj) $max = intval($obj->max); |
|
128 | - else $max=0; |
|
129 | - } |
|
130 | - else |
|
127 | + if ($obj) { |
|
128 | + $max = intval($obj->max); |
|
129 | + } else { |
|
130 | + $max=0; |
|
131 | + } |
|
132 | + } else |
|
131 | 133 | { |
132 | 134 | dol_syslog(__METHOD__, LOG_DEBUG); |
133 | 135 | return -1; |
@@ -137,8 +139,13 @@ discard block |
||
137 | 139 | $date=$object->date_bordereau; |
138 | 140 | $yymm = strftime("%y%m",$date); |
139 | 141 | |
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 | + if ($max >= (pow(10, 4) - 1)) { |
|
143 | + $num=$max+1; |
|
144 | + } |
|
145 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
146 | + else { |
|
147 | + $num = sprintf("%04s",$max+1); |
|
148 | + } |
|
142 | 149 | |
143 | 150 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
144 | 151 | return $this->prefix.$yymm."-".$num; |
@@ -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 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Thyme |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
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 | 39 | /** |
40 | 40 | * @var string Error message |
@@ -58,28 +58,28 @@ discard block |
||
58 | 58 | $form = new Form($this->db); |
59 | 59 | |
60 | 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 | - |
|
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"); |
|
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 | + |
|
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 | 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>'; |
|
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 | 84 | return $texte; |
85 | 85 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function getExample() |
93 | 93 | { |
94 | - global $conf,$langs,$mysoc; |
|
94 | + global $conf, $langs, $mysoc; |
|
95 | 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; |
|
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 | 100 | |
101 | - if (! $numExample) |
|
101 | + if (!$numExample) |
|
102 | 102 | { |
103 | 103 | $numExample = $langs->trans('NotConfigured'); |
104 | 104 | } |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | * @param Object $object Object we need next value for |
113 | 113 | * @return string Value if KO, <0 if KO |
114 | 114 | */ |
115 | - function getNextValue($objsoc,$object) |
|
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 | 121 | // We get cursor rule |
122 | - $mask=$conf->global->CHEQUERECEIPTS_THYME_MASK; |
|
122 | + $mask = $conf->global->CHEQUERECEIPTS_THYME_MASK; |
|
123 | 123 | |
124 | - if (! $mask) |
|
124 | + if (!$mask) |
|
125 | 125 | { |
126 | - $this->error='NotConfigured'; |
|
126 | + $this->error = 'NotConfigured'; |
|
127 | 127 | return 0; |
128 | 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 | 132 | return $numFinal; |
133 | 133 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @param string $objforref Object for number to search |
142 | 142 | * @return string Next free value |
143 | 143 | */ |
144 | - function chequereceipt_get_num($objsoc,$objforref) |
|
144 | + function chequereceipt_get_num($objsoc, $objforref) |
|
145 | 145 | { |
146 | 146 | // phpcs:enable |
147 | - return $this->getNextValue($objsoc,$objforref); |
|
147 | + return $this->getNextValue($objsoc, $objforref); |
|
148 | 148 | } |
149 | 149 | } |