@@ -32,106 +32,106 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class pdf_squille extends ModelePdfReception |
34 | 34 | { |
35 | - var $emetteur; // Objet societe qui emet |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Constructor |
|
40 | - * |
|
41 | - * @param DoliDB $db Database handler |
|
42 | - */ |
|
43 | - function __construct($db=0) |
|
44 | - { |
|
45 | - global $conf,$langs,$mysoc; |
|
46 | - |
|
47 | - $this->db = $db; |
|
48 | - $this->name = "squille"; |
|
49 | - $this->description = $langs->trans("DocumentModelStandardPDF"); |
|
50 | - |
|
51 | - $this->type = 'pdf'; |
|
52 | - $formatarray=pdf_getFormat(); |
|
53 | - $this->page_largeur = $formatarray['width']; |
|
54 | - $this->page_hauteur = $formatarray['height']; |
|
55 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
56 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
57 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
58 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
59 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
60 | - |
|
61 | - $this->option_logo = 1; |
|
62 | - |
|
63 | - // Get source company |
|
64 | - $this->emetteur=$mysoc; |
|
65 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
66 | - |
|
67 | - // Define position of columns |
|
68 | - $this->posxdesc=$this->marge_gauche+1; |
|
69 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
70 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
71 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
72 | - $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
73 | - |
|
74 | - if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
75 | - |
|
76 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
77 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
78 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
79 | - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
80 | - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
81 | - } |
|
82 | - |
|
83 | - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
84 | - |
|
85 | - if ($this->page_largeur < 210) // To work with US executive format |
|
86 | - { |
|
87 | - $this->posxweightvol-=20; |
|
88 | - $this->posxpicture-=20; |
|
89 | - $this->posxqtyordered-=20; |
|
90 | - $this->posxqtytoship-=20; |
|
91 | - } |
|
35 | + var $emetteur; // Objet societe qui emet |
|
92 | 36 | |
93 | - if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
94 | - { |
|
95 | - $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
|
96 | - $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
|
97 | - $this->posxqtyordered = $this->posxqtytoship; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
102 | - /** |
|
103 | - * Function to build pdf onto disk |
|
104 | - * |
|
105 | - * @param Object $object Object reception to generate (or id if old method) |
|
106 | - * @param Translate $outputlangs Lang output object |
|
37 | + |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + * |
|
41 | + * @param DoliDB $db Database handler |
|
42 | + */ |
|
43 | + function __construct($db=0) |
|
44 | + { |
|
45 | + global $conf,$langs,$mysoc; |
|
46 | + |
|
47 | + $this->db = $db; |
|
48 | + $this->name = "squille"; |
|
49 | + $this->description = $langs->trans("DocumentModelStandardPDF"); |
|
50 | + |
|
51 | + $this->type = 'pdf'; |
|
52 | + $formatarray=pdf_getFormat(); |
|
53 | + $this->page_largeur = $formatarray['width']; |
|
54 | + $this->page_hauteur = $formatarray['height']; |
|
55 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
56 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
57 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
58 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
59 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
60 | + |
|
61 | + $this->option_logo = 1; |
|
62 | + |
|
63 | + // Get source company |
|
64 | + $this->emetteur=$mysoc; |
|
65 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
66 | + |
|
67 | + // Define position of columns |
|
68 | + $this->posxdesc=$this->marge_gauche+1; |
|
69 | + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
70 | + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
71 | + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
72 | + $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
73 | + |
|
74 | + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
75 | + |
|
76 | + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
77 | + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
78 | + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
79 | + $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
80 | + $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
81 | + } |
|
82 | + |
|
83 | + $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
84 | + |
|
85 | + if ($this->page_largeur < 210) // To work with US executive format |
|
86 | + { |
|
87 | + $this->posxweightvol-=20; |
|
88 | + $this->posxpicture-=20; |
|
89 | + $this->posxqtyordered-=20; |
|
90 | + $this->posxqtytoship-=20; |
|
91 | + } |
|
92 | + |
|
93 | + if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
94 | + { |
|
95 | + $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
|
96 | + $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
|
97 | + $this->posxqtyordered = $this->posxqtytoship; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
102 | + /** |
|
103 | + * Function to build pdf onto disk |
|
104 | + * |
|
105 | + * @param Object $object Object reception to generate (or id if old method) |
|
106 | + * @param Translate $outputlangs Lang output object |
|
107 | 107 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
108 | 108 | * @param int $hidedetails Do not show line details |
109 | 109 | * @param int $hidedesc Do not show desc |
110 | 110 | * @param int $hideref Do not show ref |
111 | 111 | * @return int 1=OK, 0=KO |
112 | - */ |
|
113 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
114 | - { |
|
115 | - // phpcs:enable |
|
116 | - global $user,$conf,$langs,$hookmanager; |
|
117 | - |
|
118 | - $object->fetch_thirdparty(); |
|
119 | - |
|
120 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
121 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
122 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
123 | - |
|
124 | - $outputlangs->load("main"); |
|
125 | - $outputlangs->load("dict"); |
|
126 | - $outputlangs->load("companies"); |
|
127 | - $outputlangs->load("bills"); |
|
128 | - $outputlangs->load("products"); |
|
129 | - $outputlangs->load("propal"); |
|
130 | - $outputlangs->load("deliveries"); |
|
112 | + */ |
|
113 | + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
114 | + { |
|
115 | + // phpcs:enable |
|
116 | + global $user,$conf,$langs,$hookmanager; |
|
117 | + |
|
118 | + $object->fetch_thirdparty(); |
|
119 | + |
|
120 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
121 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
122 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
123 | + |
|
124 | + $outputlangs->load("main"); |
|
125 | + $outputlangs->load("dict"); |
|
126 | + $outputlangs->load("companies"); |
|
127 | + $outputlangs->load("bills"); |
|
128 | + $outputlangs->load("products"); |
|
129 | + $outputlangs->load("propal"); |
|
130 | + $outputlangs->load("deliveries"); |
|
131 | 131 | $outputlangs->load("receptions"); |
132 | - $outputlangs->load("productbatch"); |
|
132 | + $outputlangs->load("productbatch"); |
|
133 | 133 | |
134 | - $nblignes = count($object->lines); |
|
134 | + $nblignes = count($object->lines); |
|
135 | 135 | |
136 | 136 | // Loop on each lines to detect if there is at least one image to show |
137 | 137 | $realpatharray=array(); |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | { |
144 | 144 | if (empty($object->lines[$i]->fk_product)) continue; |
145 | 145 | |
146 | - $objphoto = new Product($this->db); |
|
147 | - $objphoto->fetch($object->lines[$i]->fk_product); |
|
146 | + $objphoto = new Product($this->db); |
|
147 | + $objphoto->fetch($object->lines[$i]->fk_product); |
|
148 | 148 | |
149 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
150 | - $dir = $conf->product->dir_output.'/'.$pdir; |
|
149 | + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
150 | + $dir = $conf->product->dir_output.'/'.$pdir; |
|
151 | 151 | |
152 | - $realpath=''; |
|
152 | + $realpath=''; |
|
153 | 153 | |
154 | 154 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
155 | 155 | { |
@@ -179,51 +179,51 @@ discard block |
||
179 | 179 | |
180 | 180 | if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
181 | 181 | |
182 | - if ($conf->reception->dir_output) |
|
183 | - { |
|
184 | - // Definition de $dir et $file |
|
185 | - if ($object->specimen) |
|
186 | - { |
|
187 | - $dir = $conf->reception->dir_output; |
|
188 | - $file = $dir . "/SPECIMEN.pdf"; |
|
189 | - } |
|
190 | - else |
|
191 | - { |
|
192 | - $rcpref = dol_sanitizeFileName($object->ref); |
|
193 | - $dir = $conf->reception->dir_output."/" . $rcpref; |
|
194 | - $file = $dir . "/" . $rcpref . ".pdf"; |
|
195 | - } |
|
196 | - |
|
197 | - if (! file_exists($dir)) |
|
198 | - { |
|
199 | - if (dol_mkdir($dir) < 0) |
|
200 | - { |
|
201 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | - return 0; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - if (file_exists($dir)) |
|
207 | - { |
|
208 | - // Add pdfgeneration hook |
|
209 | - if (! is_object($hookmanager)) |
|
210 | - { |
|
211 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | - $hookmanager=new HookManager($this->db); |
|
213 | - } |
|
214 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | - global $action; |
|
217 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | - |
|
219 | - // Set nblignes with the new facture lines content after hook |
|
220 | - $nblignes = count($object->lines); |
|
221 | - |
|
222 | - $pdf=pdf_getInstance($this->format); |
|
223 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
224 | - $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | - $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 |
|
226 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
182 | + if ($conf->reception->dir_output) |
|
183 | + { |
|
184 | + // Definition de $dir et $file |
|
185 | + if ($object->specimen) |
|
186 | + { |
|
187 | + $dir = $conf->reception->dir_output; |
|
188 | + $file = $dir . "/SPECIMEN.pdf"; |
|
189 | + } |
|
190 | + else |
|
191 | + { |
|
192 | + $rcpref = dol_sanitizeFileName($object->ref); |
|
193 | + $dir = $conf->reception->dir_output."/" . $rcpref; |
|
194 | + $file = $dir . "/" . $rcpref . ".pdf"; |
|
195 | + } |
|
196 | + |
|
197 | + if (! file_exists($dir)) |
|
198 | + { |
|
199 | + if (dol_mkdir($dir) < 0) |
|
200 | + { |
|
201 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | + return 0; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + if (file_exists($dir)) |
|
207 | + { |
|
208 | + // Add pdfgeneration hook |
|
209 | + if (! is_object($hookmanager)) |
|
210 | + { |
|
211 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | + $hookmanager=new HookManager($this->db); |
|
213 | + } |
|
214 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | + global $action; |
|
217 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | + |
|
219 | + // Set nblignes with the new facture lines content after hook |
|
220 | + $nblignes = count($object->lines); |
|
221 | + |
|
222 | + $pdf=pdf_getInstance($this->format); |
|
223 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
224 | + $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | + $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 |
|
226 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | 227 | $pdf->SetAutoPageBreak(1,0); |
228 | 228 | |
229 | 229 | if (class_exists('TCPDF')) |
@@ -239,803 +239,803 @@ discard block |
||
239 | 239 | $tplidx = $pdf->importPage(1); |
240 | 240 | } |
241 | 241 | |
242 | - $pdf->Open(); |
|
243 | - $pagenb=0; |
|
244 | - $pdf->SetDrawColor(128,128,128); |
|
245 | - |
|
246 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
247 | - |
|
248 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
249 | - $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
|
250 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
251 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
252 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
|
253 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
254 | - |
|
255 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
256 | - |
|
257 | - // New page |
|
258 | - $pdf->AddPage(); |
|
259 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
260 | - $pagenb++; |
|
261 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
262 | - $pdf->SetFont('','', $default_font_size - 1); |
|
263 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | - $pdf->SetTextColor(0,0,0); |
|
265 | - |
|
266 | - $tab_top = 90; |
|
267 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
268 | - $tab_height = 130; |
|
269 | - $tab_height_newpage = 150; |
|
270 | - |
|
271 | - // Incoterm |
|
272 | - $height_incoterms = 0; |
|
273 | - if ($conf->incoterm->enabled) |
|
274 | - { |
|
275 | - $desc_incoterms = $object->getIncotermsForPDF(); |
|
276 | - if ($desc_incoterms) |
|
277 | - { |
|
278 | - $tab_top = 88; |
|
279 | - |
|
280 | - $pdf->SetFont('','', $default_font_size - 1); |
|
281 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
282 | - $nexY = $pdf->GetY(); |
|
283 | - $height_incoterms=$nexY-$tab_top; |
|
284 | - |
|
285 | - // Rect prend une longueur en 3eme param |
|
286 | - $pdf->SetDrawColor(192,192,192); |
|
287 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
288 | - |
|
289 | - $tab_top = $nexY+6; |
|
290 | - $height_incoterms += 4; |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
295 | - { |
|
296 | - $tab_top = 88 + $height_incoterms; |
|
297 | - $tab_top_alt = $tab_top; |
|
298 | - |
|
299 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
300 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
301 | - |
|
302 | - $tab_top_alt = $pdf->GetY(); |
|
303 | - //$tab_top_alt += 1; |
|
304 | - |
|
305 | - // Tracking number |
|
306 | - if (! empty($object->tracking_number)) |
|
307 | - { |
|
308 | - $object->getUrlTrackingStatus($object->tracking_number); |
|
309 | - if (! empty($object->tracking_url)) |
|
310 | - { |
|
311 | - if ($object->reception_method_id > 0) |
|
312 | - { |
|
313 | - // Get code using getLabelFromKey |
|
314 | - $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
|
315 | - $label=''; |
|
316 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | - $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
318 | - //var_dump($object->tracking_url != $object->tracking_number);exit; |
|
319 | - if ($object->tracking_url != $object->tracking_number) |
|
320 | - { |
|
321 | - $label.=" : "; |
|
322 | - $label.=$object->tracking_url; |
|
323 | - } |
|
324 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
325 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
326 | - |
|
327 | - $tab_top_alt = $pdf->GetY(); |
|
328 | - } |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - // Notes |
|
333 | - if (! empty($object->note_public)) |
|
334 | - { |
|
335 | - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
337 | - } |
|
338 | - |
|
339 | - $nexY = $pdf->GetY(); |
|
340 | - $height_note=$nexY-$tab_top; |
|
341 | - |
|
342 | - // Rect prend une longueur en 3eme param |
|
343 | - $pdf->SetDrawColor(192,192,192); |
|
344 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
345 | - |
|
346 | - $tab_height = $tab_height - $height_note; |
|
347 | - $tab_top = $nexY+6; |
|
348 | - } |
|
349 | - else |
|
350 | - { |
|
351 | - $height_note=0; |
|
352 | - } |
|
353 | - |
|
354 | - $iniY = $tab_top + 7; |
|
355 | - $curY = $tab_top + 7; |
|
356 | - $nexY = $tab_top + 7; |
|
357 | - $fk_commandefourndet=0; |
|
358 | - $totalOrdered=0; |
|
359 | - // Loop on each lines |
|
360 | - for ($i = 0; $i < $nblignes; $i++) |
|
361 | - { |
|
362 | - $curY = $nexY; |
|
363 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
364 | - $pdf->SetTextColor(0,0,0); |
|
365 | - |
|
366 | - // Define size of image if we need it |
|
367 | - $imglinesize=array(); |
|
368 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
369 | - |
|
370 | - $pdf->setTopMargin($tab_top_newpage); |
|
371 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | - $pageposbefore=$pdf->getPage(); |
|
373 | - |
|
374 | - $showpricebeforepagebreak=1; |
|
375 | - $posYAfterImage=0; |
|
376 | - $posYAfterDescription=0; |
|
377 | - |
|
378 | - // We start with Photo of product line |
|
379 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
380 | - { |
|
381 | - $pdf->AddPage('','',true); |
|
382 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
384 | - $pdf->setPage($pageposbefore+1); |
|
385 | - |
|
386 | - $curY = $tab_top_newpage; |
|
387 | - $showpricebeforepagebreak=0; |
|
388 | - } |
|
389 | - |
|
390 | - if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
|
391 | - { |
|
392 | - $curX = $this->posxpicture-1; |
|
393 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
394 | - // $pdf->Image does not increase value return by getY, so we save it manually |
|
395 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
396 | - } |
|
397 | - |
|
398 | - // Description of product line |
|
399 | - $curX = $this->posxdesc-1; |
|
400 | - |
|
401 | - $pdf->startTransaction(); |
|
402 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
403 | - |
|
404 | - $pageposafter=$pdf->getPage(); |
|
405 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
406 | - { |
|
407 | - $pdf->rollbackTransaction(true); |
|
408 | - $pageposafter=$pageposbefore; |
|
409 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
410 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
411 | - |
|
412 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
413 | - |
|
414 | - $pageposafter=$pdf->getPage(); |
|
415 | - $posyafter=$pdf->GetY(); |
|
416 | - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
418 | - { |
|
419 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
420 | - { |
|
421 | - $pdf->AddPage('','',true); |
|
422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
424 | - $pdf->setPage($pageposafter+1); |
|
425 | - } |
|
426 | - } |
|
427 | - else |
|
428 | - { |
|
429 | - // We found a page break |
|
430 | - $showpricebeforepagebreak=0; |
|
431 | - } |
|
432 | - } |
|
433 | - else // No pagebreak |
|
434 | - { |
|
435 | - $pdf->commitTransaction(); |
|
436 | - } |
|
437 | - $posYAfterDescription=$pdf->GetY(); |
|
438 | - |
|
439 | - $nexY = $pdf->GetY(); |
|
440 | - $pageposafter=$pdf->getPage(); |
|
441 | - |
|
442 | - $pdf->setPage($pageposbefore); |
|
443 | - $pdf->setTopMargin($this->marge_haute); |
|
444 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
445 | - |
|
446 | - // We suppose that a too long description or photo were moved completely on next page |
|
447 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
448 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
449 | - } |
|
450 | - |
|
451 | - // We suppose that a too long description is moved completely on next page |
|
452 | - if ($pageposafter > $pageposbefore) { |
|
453 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
454 | - } |
|
455 | - |
|
456 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
457 | - |
|
458 | - $pdf->SetXY($this->posxweightvol, $curY); |
|
459 | - $weighttxt=''; |
|
460 | - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) |
|
461 | - { |
|
462 | - $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight"); |
|
463 | - } |
|
464 | - $voltxt=''; |
|
465 | - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) |
|
466 | - { |
|
467 | - $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume"); |
|
468 | - } |
|
469 | - |
|
470 | - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
471 | - //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
|
472 | - |
|
473 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
474 | - { |
|
475 | - $pdf->SetXY($this->posxqtyordered, $curY); |
|
476 | - if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ |
|
477 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
478 | - $totalOrdered+=$object->lines[$i]->qty_asked; |
|
479 | - } |
|
480 | - $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; |
|
481 | - } |
|
482 | - |
|
483 | - $pdf->SetXY($this->posxqtytoship, $curY); |
|
484 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C'); |
|
485 | - |
|
486 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
487 | - { |
|
488 | - $pdf->SetXY($this->posxpuht, $curY); |
|
489 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
490 | - |
|
491 | - $pdf->SetXY($this->posxtotalht, $curY); |
|
492 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
493 | - } |
|
494 | - |
|
495 | - $nexY+=3; |
|
496 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
497 | - |
|
498 | - // Add line |
|
499 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
500 | - { |
|
501 | - $pdf->setPage($pageposafter); |
|
502 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
503 | - //$pdf->SetDrawColor(190,190,200); |
|
504 | - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
505 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
506 | - } |
|
507 | - |
|
508 | - // Detect if some page were added automatically and output _tableau for past pages |
|
509 | - while ($pagenb < $pageposafter) |
|
510 | - { |
|
511 | - $pdf->setPage($pagenb); |
|
512 | - if ($pagenb == 1) |
|
513 | - { |
|
514 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
515 | - } |
|
516 | - else |
|
517 | - { |
|
518 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
519 | - } |
|
520 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
521 | - $pagenb++; |
|
522 | - $pdf->setPage($pagenb); |
|
523 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
524 | - } |
|
525 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
526 | - { |
|
527 | - if ($pagenb == 1) |
|
528 | - { |
|
529 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
530 | - } |
|
531 | - else |
|
532 | - { |
|
533 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
534 | - } |
|
535 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
536 | - // New page |
|
537 | - $pdf->AddPage(); |
|
538 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
539 | - $pagenb++; |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - // Show square |
|
544 | - if ($pagenb == 1) |
|
545 | - { |
|
546 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
547 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
548 | - } |
|
549 | - else |
|
550 | - { |
|
551 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
552 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
553 | - } |
|
554 | - |
|
555 | - // Affiche zone totaux |
|
556 | - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
557 | - |
|
558 | - // Pied de page |
|
559 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
560 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
561 | - |
|
562 | - $pdf->Close(); |
|
563 | - |
|
564 | - $pdf->Output($file,'F'); |
|
565 | - |
|
566 | - // Add pdfgeneration hook |
|
567 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
568 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
569 | - global $action; |
|
570 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
571 | - |
|
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
574 | - |
|
575 | - return 1; // No error |
|
576 | - } |
|
577 | - else |
|
578 | - { |
|
579 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
580 | - return 0; |
|
581 | - } |
|
582 | - } |
|
583 | - else |
|
584 | - { |
|
585 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
586 | - return 0; |
|
587 | - } |
|
588 | - } |
|
589 | - |
|
590 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
591 | - /** |
|
592 | - * Show total to pay |
|
593 | - * |
|
594 | - * @param PDF $pdf Object PDF |
|
595 | - * @param Facture $object Object invoice |
|
596 | - * @param int $deja_regle Montant deja regle |
|
597 | - * @param int $posy Position depart |
|
598 | - * @param Translate $outputlangs Objet langs |
|
599 | - * @param int $totalOrdered Total ordered |
|
600 | - * @return int Position pour suite |
|
601 | - */ |
|
602 | - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) |
|
603 | - { |
|
604 | - // phpcs:enable |
|
605 | - global $conf,$mysoc; |
|
242 | + $pdf->Open(); |
|
243 | + $pagenb=0; |
|
244 | + $pdf->SetDrawColor(128,128,128); |
|
245 | + |
|
246 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
247 | + |
|
248 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
249 | + $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
|
250 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
251 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
252 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
|
253 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
254 | + |
|
255 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
256 | + |
|
257 | + // New page |
|
258 | + $pdf->AddPage(); |
|
259 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
260 | + $pagenb++; |
|
261 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
262 | + $pdf->SetFont('','', $default_font_size - 1); |
|
263 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | + $pdf->SetTextColor(0,0,0); |
|
265 | + |
|
266 | + $tab_top = 90; |
|
267 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
268 | + $tab_height = 130; |
|
269 | + $tab_height_newpage = 150; |
|
270 | + |
|
271 | + // Incoterm |
|
272 | + $height_incoterms = 0; |
|
273 | + if ($conf->incoterm->enabled) |
|
274 | + { |
|
275 | + $desc_incoterms = $object->getIncotermsForPDF(); |
|
276 | + if ($desc_incoterms) |
|
277 | + { |
|
278 | + $tab_top = 88; |
|
279 | + |
|
280 | + $pdf->SetFont('','', $default_font_size - 1); |
|
281 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
282 | + $nexY = $pdf->GetY(); |
|
283 | + $height_incoterms=$nexY-$tab_top; |
|
284 | + |
|
285 | + // Rect prend une longueur en 3eme param |
|
286 | + $pdf->SetDrawColor(192,192,192); |
|
287 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
288 | + |
|
289 | + $tab_top = $nexY+6; |
|
290 | + $height_incoterms += 4; |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
295 | + { |
|
296 | + $tab_top = 88 + $height_incoterms; |
|
297 | + $tab_top_alt = $tab_top; |
|
298 | + |
|
299 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
300 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
301 | + |
|
302 | + $tab_top_alt = $pdf->GetY(); |
|
303 | + //$tab_top_alt += 1; |
|
304 | + |
|
305 | + // Tracking number |
|
306 | + if (! empty($object->tracking_number)) |
|
307 | + { |
|
308 | + $object->getUrlTrackingStatus($object->tracking_number); |
|
309 | + if (! empty($object->tracking_url)) |
|
310 | + { |
|
311 | + if ($object->reception_method_id > 0) |
|
312 | + { |
|
313 | + // Get code using getLabelFromKey |
|
314 | + $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
|
315 | + $label=''; |
|
316 | + if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | + $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
318 | + //var_dump($object->tracking_url != $object->tracking_number);exit; |
|
319 | + if ($object->tracking_url != $object->tracking_number) |
|
320 | + { |
|
321 | + $label.=" : "; |
|
322 | + $label.=$object->tracking_url; |
|
323 | + } |
|
324 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
325 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
326 | + |
|
327 | + $tab_top_alt = $pdf->GetY(); |
|
328 | + } |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + // Notes |
|
333 | + if (! empty($object->note_public)) |
|
334 | + { |
|
335 | + $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
337 | + } |
|
338 | + |
|
339 | + $nexY = $pdf->GetY(); |
|
340 | + $height_note=$nexY-$tab_top; |
|
341 | + |
|
342 | + // Rect prend une longueur en 3eme param |
|
343 | + $pdf->SetDrawColor(192,192,192); |
|
344 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
345 | + |
|
346 | + $tab_height = $tab_height - $height_note; |
|
347 | + $tab_top = $nexY+6; |
|
348 | + } |
|
349 | + else |
|
350 | + { |
|
351 | + $height_note=0; |
|
352 | + } |
|
353 | + |
|
354 | + $iniY = $tab_top + 7; |
|
355 | + $curY = $tab_top + 7; |
|
356 | + $nexY = $tab_top + 7; |
|
357 | + $fk_commandefourndet=0; |
|
358 | + $totalOrdered=0; |
|
359 | + // Loop on each lines |
|
360 | + for ($i = 0; $i < $nblignes; $i++) |
|
361 | + { |
|
362 | + $curY = $nexY; |
|
363 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
364 | + $pdf->SetTextColor(0,0,0); |
|
365 | + |
|
366 | + // Define size of image if we need it |
|
367 | + $imglinesize=array(); |
|
368 | + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
369 | + |
|
370 | + $pdf->setTopMargin($tab_top_newpage); |
|
371 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | + $pageposbefore=$pdf->getPage(); |
|
373 | + |
|
374 | + $showpricebeforepagebreak=1; |
|
375 | + $posYAfterImage=0; |
|
376 | + $posYAfterDescription=0; |
|
377 | + |
|
378 | + // We start with Photo of product line |
|
379 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
380 | + { |
|
381 | + $pdf->AddPage('','',true); |
|
382 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
384 | + $pdf->setPage($pageposbefore+1); |
|
385 | + |
|
386 | + $curY = $tab_top_newpage; |
|
387 | + $showpricebeforepagebreak=0; |
|
388 | + } |
|
389 | + |
|
390 | + if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
|
391 | + { |
|
392 | + $curX = $this->posxpicture-1; |
|
393 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
394 | + // $pdf->Image does not increase value return by getY, so we save it manually |
|
395 | + $posYAfterImage=$curY+$imglinesize['height']; |
|
396 | + } |
|
397 | + |
|
398 | + // Description of product line |
|
399 | + $curX = $this->posxdesc-1; |
|
400 | + |
|
401 | + $pdf->startTransaction(); |
|
402 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
403 | + |
|
404 | + $pageposafter=$pdf->getPage(); |
|
405 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
406 | + { |
|
407 | + $pdf->rollbackTransaction(true); |
|
408 | + $pageposafter=$pageposbefore; |
|
409 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
410 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
411 | + |
|
412 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
413 | + |
|
414 | + $pageposafter=$pdf->getPage(); |
|
415 | + $posyafter=$pdf->GetY(); |
|
416 | + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
417 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
418 | + { |
|
419 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
420 | + { |
|
421 | + $pdf->AddPage('','',true); |
|
422 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
424 | + $pdf->setPage($pageposafter+1); |
|
425 | + } |
|
426 | + } |
|
427 | + else |
|
428 | + { |
|
429 | + // We found a page break |
|
430 | + $showpricebeforepagebreak=0; |
|
431 | + } |
|
432 | + } |
|
433 | + else // No pagebreak |
|
434 | + { |
|
435 | + $pdf->commitTransaction(); |
|
436 | + } |
|
437 | + $posYAfterDescription=$pdf->GetY(); |
|
438 | + |
|
439 | + $nexY = $pdf->GetY(); |
|
440 | + $pageposafter=$pdf->getPage(); |
|
441 | + |
|
442 | + $pdf->setPage($pageposbefore); |
|
443 | + $pdf->setTopMargin($this->marge_haute); |
|
444 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
445 | + |
|
446 | + // We suppose that a too long description or photo were moved completely on next page |
|
447 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
448 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
449 | + } |
|
450 | + |
|
451 | + // We suppose that a too long description is moved completely on next page |
|
452 | + if ($pageposafter > $pageposbefore) { |
|
453 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
454 | + } |
|
455 | + |
|
456 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
457 | + |
|
458 | + $pdf->SetXY($this->posxweightvol, $curY); |
|
459 | + $weighttxt=''; |
|
460 | + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) |
|
461 | + { |
|
462 | + $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight"); |
|
463 | + } |
|
464 | + $voltxt=''; |
|
465 | + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) |
|
466 | + { |
|
467 | + $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume"); |
|
468 | + } |
|
469 | + |
|
470 | + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
471 | + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
|
472 | + |
|
473 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
474 | + { |
|
475 | + $pdf->SetXY($this->posxqtyordered, $curY); |
|
476 | + if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ |
|
477 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
478 | + $totalOrdered+=$object->lines[$i]->qty_asked; |
|
479 | + } |
|
480 | + $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; |
|
481 | + } |
|
482 | + |
|
483 | + $pdf->SetXY($this->posxqtytoship, $curY); |
|
484 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C'); |
|
485 | + |
|
486 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
487 | + { |
|
488 | + $pdf->SetXY($this->posxpuht, $curY); |
|
489 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
490 | + |
|
491 | + $pdf->SetXY($this->posxtotalht, $curY); |
|
492 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
493 | + } |
|
494 | + |
|
495 | + $nexY+=3; |
|
496 | + if ($weighttxt && $voltxt) $nexY+=2; |
|
497 | + |
|
498 | + // Add line |
|
499 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
500 | + { |
|
501 | + $pdf->setPage($pageposafter); |
|
502 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
503 | + //$pdf->SetDrawColor(190,190,200); |
|
504 | + $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
505 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
506 | + } |
|
507 | + |
|
508 | + // Detect if some page were added automatically and output _tableau for past pages |
|
509 | + while ($pagenb < $pageposafter) |
|
510 | + { |
|
511 | + $pdf->setPage($pagenb); |
|
512 | + if ($pagenb == 1) |
|
513 | + { |
|
514 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
515 | + } |
|
516 | + else |
|
517 | + { |
|
518 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
519 | + } |
|
520 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
521 | + $pagenb++; |
|
522 | + $pdf->setPage($pagenb); |
|
523 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
524 | + } |
|
525 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
526 | + { |
|
527 | + if ($pagenb == 1) |
|
528 | + { |
|
529 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
530 | + } |
|
531 | + else |
|
532 | + { |
|
533 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
534 | + } |
|
535 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
536 | + // New page |
|
537 | + $pdf->AddPage(); |
|
538 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
539 | + $pagenb++; |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + // Show square |
|
544 | + if ($pagenb == 1) |
|
545 | + { |
|
546 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
547 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
548 | + } |
|
549 | + else |
|
550 | + { |
|
551 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
552 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
553 | + } |
|
554 | + |
|
555 | + // Affiche zone totaux |
|
556 | + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
557 | + |
|
558 | + // Pied de page |
|
559 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
560 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
561 | + |
|
562 | + $pdf->Close(); |
|
563 | + |
|
564 | + $pdf->Output($file,'F'); |
|
565 | + |
|
566 | + // Add pdfgeneration hook |
|
567 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
568 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
569 | + global $action; |
|
570 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
571 | + |
|
572 | + if (! empty($conf->global->MAIN_UMASK)) |
|
573 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
574 | + |
|
575 | + return 1; // No error |
|
576 | + } |
|
577 | + else |
|
578 | + { |
|
579 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
580 | + return 0; |
|
581 | + } |
|
582 | + } |
|
583 | + else |
|
584 | + { |
|
585 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
586 | + return 0; |
|
587 | + } |
|
588 | + } |
|
589 | + |
|
590 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
591 | + /** |
|
592 | + * Show total to pay |
|
593 | + * |
|
594 | + * @param PDF $pdf Object PDF |
|
595 | + * @param Facture $object Object invoice |
|
596 | + * @param int $deja_regle Montant deja regle |
|
597 | + * @param int $posy Position depart |
|
598 | + * @param Translate $outputlangs Objet langs |
|
599 | + * @param int $totalOrdered Total ordered |
|
600 | + * @return int Position pour suite |
|
601 | + */ |
|
602 | + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) |
|
603 | + { |
|
604 | + // phpcs:enable |
|
605 | + global $conf,$mysoc; |
|
606 | 606 | |
607 | 607 | $sign=1; |
608 | 608 | |
609 | 609 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
610 | 610 | |
611 | - $tab2_top = $posy; |
|
612 | - $tab2_hl = 4; |
|
613 | - $pdf->SetFont('','B', $default_font_size - 1); |
|
611 | + $tab2_top = $posy; |
|
612 | + $tab2_hl = 4; |
|
613 | + $pdf->SetFont('','B', $default_font_size - 1); |
|
614 | 614 | |
615 | - // Tableau total |
|
616 | - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
617 | - /*if ($this->page_largeur < 210) // To work with US executive format |
|
615 | + // Tableau total |
|
616 | + $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
617 | + /*if ($this->page_largeur < 210) // To work with US executive format |
|
618 | 618 | { |
619 | 619 | $col2x-=20; |
620 | 620 | }*/ |
621 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | - else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
621 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | + else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
623 | 623 | |
624 | - $useborder=0; |
|
625 | - $index = 0; |
|
624 | + $useborder=0; |
|
625 | + $index = 0; |
|
626 | 626 | |
627 | - $totalWeighttoshow=''; |
|
628 | - $totalVolumetoshow=''; |
|
627 | + $totalWeighttoshow=''; |
|
628 | + $totalVolumetoshow=''; |
|
629 | 629 | |
630 | - // Load dim data |
|
631 | - $tmparray=$object->getTotalWeightVolume(); |
|
632 | - $totalWeight=$tmparray['weight']; |
|
633 | - $totalVolume=$tmparray['volume']; |
|
634 | - $totalToShip=$tmparray['toship']; |
|
630 | + // Load dim data |
|
631 | + $tmparray=$object->getTotalWeightVolume(); |
|
632 | + $totalWeight=$tmparray['weight']; |
|
633 | + $totalVolume=$tmparray['volume']; |
|
634 | + $totalToShip=$tmparray['toship']; |
|
635 | 635 | |
636 | 636 | |
637 | - // Set trueVolume and volume_units not currently stored into database |
|
638 | - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
|
639 | - { |
|
640 | - $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | - $object->volume_units=$object->size_units * 3; |
|
642 | - } |
|
637 | + // Set trueVolume and volume_units not currently stored into database |
|
638 | + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
|
639 | + { |
|
640 | + $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | + $object->volume_units=$object->size_units * 3; |
|
642 | + } |
|
643 | 643 | |
644 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
644 | + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | + if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | + if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | + if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
648 | 648 | |
649 | - $pdf->SetFillColor(255,255,255); |
|
650 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
651 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
649 | + $pdf->SetFillColor(255,255,255); |
|
650 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
651 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
652 | 652 | |
653 | 653 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
654 | 654 | { |
655 | 655 | $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); |
656 | - $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); |
|
656 | + $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); |
|
657 | 657 | } |
658 | 658 | |
659 | - $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
|
660 | - $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
|
659 | + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
|
660 | + $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
|
661 | + |
|
662 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
661 | 663 | |
662 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
664 | + $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
|
665 | + $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
|
663 | 666 | |
664 | - $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
|
665 | - $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
|
667 | + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); |
|
668 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); |
|
669 | + } |
|
666 | 670 | |
667 | - $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); |
|
668 | - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); |
|
669 | - } |
|
671 | + // Total Weight |
|
672 | + if ($totalWeighttoshow) |
|
673 | + { |
|
674 | + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
675 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); |
|
670 | 676 | |
671 | - // Total Weight |
|
672 | - if ($totalWeighttoshow) |
|
673 | - { |
|
674 | - $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
675 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); |
|
677 | + $index++; |
|
678 | + } |
|
679 | + if ($totalVolumetoshow) |
|
680 | + { |
|
681 | + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
682 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); |
|
676 | 683 | |
677 | - $index++; |
|
678 | - } |
|
679 | - if ($totalVolumetoshow) |
|
680 | - { |
|
681 | - $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
682 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); |
|
683 | - |
|
684 | - $index++; |
|
685 | - } |
|
686 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
687 | - |
|
688 | - $pdf->SetTextColor(0,0,0); |
|
689 | - |
|
690 | - return ($tab2_top + ($tab2_hl * $index)); |
|
691 | - } |
|
692 | - |
|
693 | - /** |
|
694 | - * Show table for lines |
|
695 | - * |
|
696 | - * @param PDF $pdf Object PDF |
|
697 | - * @param string $tab_top Top position of table |
|
698 | - * @param string $tab_height Height of table (rectangle) |
|
699 | - * @param int $nexY Y |
|
700 | - * @param Translate $outputlangs Langs object |
|
701 | - * @param int $hidetop Hide top bar of array |
|
702 | - * @param int $hidebottom Hide bottom bar of array |
|
703 | - * @return void |
|
704 | - */ |
|
705 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
706 | - { |
|
707 | - global $conf; |
|
708 | - |
|
709 | - // Force to disable hidetop and hidebottom |
|
710 | - $hidebottom=0; |
|
711 | - if ($hidetop) $hidetop=-1; |
|
712 | - |
|
713 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
714 | - |
|
715 | - // Amount in (at tab_top - 1) |
|
716 | - $pdf->SetTextColor(0,0,0); |
|
717 | - $pdf->SetFont('','',$default_font_size - 2); |
|
718 | - |
|
719 | - // Output Rect |
|
720 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
721 | - |
|
722 | - $pdf->SetDrawColor(128,128,128); |
|
723 | - $pdf->SetFont('','', $default_font_size - 1); |
|
724 | - |
|
725 | - if (empty($hidetop)) |
|
726 | - { |
|
727 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
684 | + $index++; |
|
685 | + } |
|
686 | + if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
728 | 687 | |
729 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
730 | - $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
|
731 | - } |
|
688 | + $pdf->SetTextColor(0,0,0); |
|
732 | 689 | |
733 | - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
734 | - if (empty($hidetop)) |
|
735 | - { |
|
736 | - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
737 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
738 | - } |
|
690 | + return ($tab2_top + ($tab2_hl * $index)); |
|
691 | + } |
|
692 | + |
|
693 | + /** |
|
694 | + * Show table for lines |
|
695 | + * |
|
696 | + * @param PDF $pdf Object PDF |
|
697 | + * @param string $tab_top Top position of table |
|
698 | + * @param string $tab_height Height of table (rectangle) |
|
699 | + * @param int $nexY Y |
|
700 | + * @param Translate $outputlangs Langs object |
|
701 | + * @param int $hidetop Hide top bar of array |
|
702 | + * @param int $hidebottom Hide bottom bar of array |
|
703 | + * @return void |
|
704 | + */ |
|
705 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
706 | + { |
|
707 | + global $conf; |
|
708 | + |
|
709 | + // Force to disable hidetop and hidebottom |
|
710 | + $hidebottom=0; |
|
711 | + if ($hidetop) $hidetop=-1; |
|
712 | + |
|
713 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
714 | + |
|
715 | + // Amount in (at tab_top - 1) |
|
716 | + $pdf->SetTextColor(0,0,0); |
|
717 | + $pdf->SetFont('','',$default_font_size - 2); |
|
718 | + |
|
719 | + // Output Rect |
|
720 | + $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
721 | + |
|
722 | + $pdf->SetDrawColor(128,128,128); |
|
723 | + $pdf->SetFont('','', $default_font_size - 1); |
|
724 | + |
|
725 | + if (empty($hidetop)) |
|
726 | + { |
|
727 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
728 | + |
|
729 | + $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
730 | + $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
|
731 | + } |
|
732 | + |
|
733 | + $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
734 | + if (empty($hidetop)) |
|
735 | + { |
|
736 | + $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
737 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
738 | + } |
|
739 | 739 | |
740 | 740 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
741 | 741 | { |
742 | 742 | $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); |
743 | - if (empty($hidetop)) |
|
744 | - { |
|
745 | - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
746 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
747 | - } |
|
743 | + if (empty($hidetop)) |
|
744 | + { |
|
745 | + $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
746 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
751 | - if (empty($hidetop)) |
|
752 | - { |
|
753 | - $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
754 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C'); |
|
755 | - } |
|
756 | - |
|
757 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
758 | - |
|
759 | - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
760 | - if (empty($hidetop)) |
|
761 | - { |
|
762 | - $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
763 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
764 | - } |
|
765 | - |
|
766 | - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
767 | - if (empty($hidetop)) |
|
768 | - { |
|
769 | - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
770 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
771 | - } |
|
772 | - } |
|
773 | - } |
|
774 | - |
|
775 | - /** |
|
776 | - * Show top header of page. |
|
777 | - * |
|
778 | - * @param PDF $pdf Object PDF |
|
779 | - * @param Object $object Object to show |
|
780 | - * @param int $showaddress 0=no, 1=yes |
|
781 | - * @param Translate $outputlangs Object lang for output |
|
782 | - * @return void |
|
783 | - */ |
|
784 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
785 | - { |
|
786 | - global $conf,$langs,$mysoc; |
|
787 | - |
|
788 | - $langs->load("orders"); |
|
789 | - |
|
790 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
791 | - |
|
792 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
793 | - |
|
794 | - // Show Draft Watermark |
|
795 | - if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) |
|
796 | - { |
|
797 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK); |
|
798 | - } |
|
750 | + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
751 | + if (empty($hidetop)) |
|
752 | + { |
|
753 | + $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
754 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C'); |
|
755 | + } |
|
799 | 756 | |
800 | - //Prepare la suite |
|
801 | - $pdf->SetTextColor(0,0,60); |
|
802 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
757 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
803 | 758 | |
804 | - $w = 110; |
|
759 | + $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
760 | + if (empty($hidetop)) |
|
761 | + { |
|
762 | + $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
763 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
764 | + } |
|
805 | 765 | |
806 | - $posy=$this->marge_haute; |
|
807 | - $posx=$this->page_largeur-$this->marge_droite-$w; |
|
766 | + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
767 | + if (empty($hidetop)) |
|
768 | + { |
|
769 | + $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
770 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
771 | + } |
|
772 | + } |
|
773 | + } |
|
808 | 774 | |
809 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
775 | + /** |
|
776 | + * Show top header of page. |
|
777 | + * |
|
778 | + * @param PDF $pdf Object PDF |
|
779 | + * @param Object $object Object to show |
|
780 | + * @param int $showaddress 0=no, 1=yes |
|
781 | + * @param Translate $outputlangs Object lang for output |
|
782 | + * @return void |
|
783 | + */ |
|
784 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
785 | + { |
|
786 | + global $conf,$langs,$mysoc; |
|
787 | + |
|
788 | + $langs->load("orders"); |
|
810 | 789 | |
811 | - // Logo |
|
812 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
813 | - if ($this->emetteur->logo) |
|
814 | - { |
|
815 | - if (is_readable($logo)) |
|
816 | - { |
|
817 | - $height=pdf_getHeightForLogo($logo); |
|
818 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
819 | - } |
|
820 | - else |
|
821 | - { |
|
822 | - $pdf->SetTextColor(200,0,0); |
|
823 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
824 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
825 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
826 | - } |
|
827 | - } |
|
828 | - else |
|
829 | - { |
|
830 | - $text=$this->emetteur->name; |
|
831 | - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
832 | - } |
|
790 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
833 | 791 | |
834 | - // Show barcode |
|
835 | - if (! empty($conf->barcode->enabled)) |
|
836 | - { |
|
837 | - $posx=105; |
|
838 | - } |
|
839 | - else |
|
840 | - { |
|
841 | - $posx=$this->marge_gauche+3; |
|
842 | - } |
|
843 | - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
|
844 | - if (! empty($conf->barcode->enabled)) |
|
845 | - { |
|
846 | - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
847 | - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
848 | - //$pdf->Image($logo,10, 5, 0, 24); |
|
849 | - } |
|
792 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
850 | 793 | |
851 | - $pdf->SetDrawColor(128,128,128); |
|
852 | - if (! empty($conf->barcode->enabled)) |
|
853 | - { |
|
854 | - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
855 | - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
856 | - //$pdf->Image($logo,10, 5, 0, 24); |
|
857 | - } |
|
794 | + // Show Draft Watermark |
|
795 | + if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) |
|
796 | + { |
|
797 | + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK); |
|
798 | + } |
|
858 | 799 | |
800 | + //Prepare la suite |
|
801 | + $pdf->SetTextColor(0,0,60); |
|
802 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
859 | 803 | |
860 | - $posx=$this->page_largeur - $w - $this->marge_droite; |
|
861 | - $posy=$this->marge_haute; |
|
804 | + $w = 110; |
|
862 | 805 | |
863 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
864 | - $pdf->SetXY($posx,$posy); |
|
865 | - $pdf->SetTextColor(0,0,60); |
|
866 | - $title=$outputlangs->transnoentities("ReceptionSheet"); |
|
867 | - $pdf->MultiCell($w, 4, $title, '', 'R'); |
|
806 | + $posy=$this->marge_haute; |
|
807 | + $posx=$this->page_largeur-$this->marge_droite-$w; |
|
868 | 808 | |
869 | - $pdf->SetFont('','', $default_font_size + 1); |
|
809 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
870 | 810 | |
871 | - $posy+=5; |
|
811 | + // Logo |
|
812 | + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
813 | + if ($this->emetteur->logo) |
|
814 | + { |
|
815 | + if (is_readable($logo)) |
|
816 | + { |
|
817 | + $height=pdf_getHeightForLogo($logo); |
|
818 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
819 | + } |
|
820 | + else |
|
821 | + { |
|
822 | + $pdf->SetTextColor(200,0,0); |
|
823 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
824 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
825 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
826 | + } |
|
827 | + } |
|
828 | + else |
|
829 | + { |
|
830 | + $text=$this->emetteur->name; |
|
831 | + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
832 | + } |
|
872 | 833 | |
873 | - $pdf->SetXY($posx,$posy); |
|
874 | - $pdf->SetTextColor(0,0,60); |
|
875 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); |
|
834 | + // Show barcode |
|
835 | + if (! empty($conf->barcode->enabled)) |
|
836 | + { |
|
837 | + $posx=105; |
|
838 | + } |
|
839 | + else |
|
840 | + { |
|
841 | + $posx=$this->marge_gauche+3; |
|
842 | + } |
|
843 | + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
|
844 | + if (! empty($conf->barcode->enabled)) |
|
845 | + { |
|
846 | + // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
847 | + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
848 | + //$pdf->Image($logo,10, 5, 0, 24); |
|
849 | + } |
|
876 | 850 | |
877 | - // Date planned delivery |
|
878 | - if (! empty($object->date_delivery)) |
|
879 | - { |
|
880 | - $posy+=4; |
|
881 | - $pdf->SetXY($posx,$posy); |
|
882 | - $pdf->SetTextColor(0,0,60); |
|
883 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
884 | - } |
|
851 | + $pdf->SetDrawColor(128,128,128); |
|
852 | + if (! empty($conf->barcode->enabled)) |
|
853 | + { |
|
854 | + // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
855 | + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
856 | + //$pdf->Image($logo,10, 5, 0, 24); |
|
857 | + } |
|
885 | 858 | |
886 | - if (! empty($object->thirdparty->code_fournisseur)) |
|
887 | - { |
|
888 | - $posy+=4; |
|
889 | - $pdf->SetXY($posx,$posy); |
|
890 | - $pdf->SetTextColor(0,0,60); |
|
891 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
892 | - } |
|
893 | 859 | |
860 | + $posx=$this->page_largeur - $w - $this->marge_droite; |
|
861 | + $posy=$this->marge_haute; |
|
894 | 862 | |
895 | - $pdf->SetFont('','', $default_font_size + 3); |
|
896 | - $Yoff=25; |
|
863 | + $pdf->SetFont('','B', $default_font_size + 2); |
|
864 | + $pdf->SetXY($posx,$posy); |
|
865 | + $pdf->SetTextColor(0,0,60); |
|
866 | + $title=$outputlangs->transnoentities("ReceptionSheet"); |
|
867 | + $pdf->MultiCell($w, 4, $title, '', 'R'); |
|
897 | 868 | |
898 | - // Add list of linked orders |
|
899 | - $origin = $object->origin; |
|
900 | - $origin_id = $object->origin_id; |
|
869 | + $pdf->SetFont('','', $default_font_size + 1); |
|
901 | 870 | |
902 | - // TODO move to external function |
|
903 | - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
904 | - { |
|
905 | - $outputlangs->load('orders'); |
|
906 | - |
|
907 | - $classname = 'CommandeFournisseur'; |
|
908 | - $linkedobject = new $classname($this->db); |
|
909 | - $result=$linkedobject->fetch($origin_id); |
|
910 | - if ($result >= 0) |
|
911 | - { |
|
912 | - //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
|
913 | - |
|
914 | - $pdf->SetFont('','', $default_font_size - 2); |
|
915 | - $text=$linkedobject->ref; |
|
916 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
917 | - $Yoff = $Yoff+8; |
|
918 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
919 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | - $Yoff = $Yoff+3; |
|
921 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
922 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
923 | - } |
|
924 | - } |
|
925 | - |
|
926 | - if ($showaddress) |
|
927 | - { |
|
928 | - // Sender properties |
|
929 | - $carac_emetteur=''; |
|
930 | - // Add internal contact of origin element if defined |
|
931 | - $arrayidcontact=array(); |
|
932 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
934 | - if (count($arrayidcontact) > 0) |
|
935 | - { |
|
936 | - $object->fetch_user(reset($arrayidcontact)); |
|
937 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
938 | - } |
|
939 | - |
|
940 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
941 | - |
|
942 | - // Show sender |
|
943 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | - $posx=$this->marge_gauche; |
|
945 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
946 | - |
|
947 | - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
949 | - |
|
950 | - // Show sender frame |
|
951 | - $pdf->SetTextColor(0,0,0); |
|
952 | - $pdf->SetFont('','', $default_font_size - 2); |
|
953 | - $pdf->SetXY($posx,$posy-5); |
|
954 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | - $pdf->SetXY($posx,$posy); |
|
956 | - $pdf->SetFillColor(230,230,230); |
|
957 | - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
|
958 | - $pdf->SetTextColor(0,0,60); |
|
959 | - $pdf->SetFillColor(255,255,255); |
|
960 | - |
|
961 | - // If RECEPTION contact defined, we use it |
|
962 | - $usecontact=false; |
|
963 | - $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
964 | - |
|
965 | - if (count($arrayidcontact) > 0) |
|
966 | - { |
|
967 | - $usecontact=true; |
|
968 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
969 | - } |
|
970 | - |
|
971 | - //Recipient name |
|
972 | - // On peut utiliser le nom de la societe du contact |
|
973 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
974 | - $thirdparty = $object->contact; |
|
975 | - } else { |
|
976 | - $thirdparty = $object->thirdparty; |
|
977 | - } |
|
978 | - |
|
979 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
980 | - |
|
981 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
982 | - |
|
983 | - // Show recipient name |
|
984 | - $pdf->SetXY($posx+2,$posy+3); |
|
985 | - $pdf->SetFont('','B', $default_font_size); |
|
986 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); |
|
987 | - |
|
988 | - $posy = $pdf->getY(); |
|
989 | - |
|
990 | - // Show recipient information |
|
991 | - $pdf->SetFont('','', $default_font_size - 1); |
|
992 | - $pdf->SetXY($posx+2,$posy); |
|
993 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); |
|
994 | - |
|
995 | - // Show recipient |
|
996 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
998 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1001 | - |
|
1002 | - // Show recipient frame |
|
1003 | - $pdf->SetTextColor(0,0,0); |
|
1004 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1005 | - $pdf->SetXY($posx+2,$posy-5); |
|
1006 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
|
1007 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1008 | - |
|
1009 | - |
|
1010 | - |
|
1011 | - // Show sender name |
|
1012 | - $pdf->SetXY($posx+2,$posy+3); |
|
1013 | - $pdf->SetFont('','B',$default_font_size); |
|
1014 | - $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1015 | - $posy=$pdf->getY(); |
|
1016 | - |
|
1017 | - // Show sender information |
|
1018 | - $pdf->SetXY($posx+2,$posy); |
|
1019 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1020 | - $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); |
|
1021 | - } |
|
1022 | - |
|
1023 | - $pdf->SetTextColor(0,0,0); |
|
1024 | - } |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * Show footer of page. Need this->emetteur object |
|
871 | + $posy+=5; |
|
872 | + |
|
873 | + $pdf->SetXY($posx,$posy); |
|
874 | + $pdf->SetTextColor(0,0,60); |
|
875 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); |
|
876 | + |
|
877 | + // Date planned delivery |
|
878 | + if (! empty($object->date_delivery)) |
|
879 | + { |
|
880 | + $posy+=4; |
|
881 | + $pdf->SetXY($posx,$posy); |
|
882 | + $pdf->SetTextColor(0,0,60); |
|
883 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
884 | + } |
|
885 | + |
|
886 | + if (! empty($object->thirdparty->code_fournisseur)) |
|
887 | + { |
|
888 | + $posy+=4; |
|
889 | + $pdf->SetXY($posx,$posy); |
|
890 | + $pdf->SetTextColor(0,0,60); |
|
891 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
892 | + } |
|
893 | + |
|
894 | + |
|
895 | + $pdf->SetFont('','', $default_font_size + 3); |
|
896 | + $Yoff=25; |
|
897 | + |
|
898 | + // Add list of linked orders |
|
899 | + $origin = $object->origin; |
|
900 | + $origin_id = $object->origin_id; |
|
901 | + |
|
902 | + // TODO move to external function |
|
903 | + if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
904 | + { |
|
905 | + $outputlangs->load('orders'); |
|
906 | + |
|
907 | + $classname = 'CommandeFournisseur'; |
|
908 | + $linkedobject = new $classname($this->db); |
|
909 | + $result=$linkedobject->fetch($origin_id); |
|
910 | + if ($result >= 0) |
|
911 | + { |
|
912 | + //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
|
913 | + |
|
914 | + $pdf->SetFont('','', $default_font_size - 2); |
|
915 | + $text=$linkedobject->ref; |
|
916 | + if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
917 | + $Yoff = $Yoff+8; |
|
918 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
919 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | + $Yoff = $Yoff+3; |
|
921 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
922 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
923 | + } |
|
924 | + } |
|
925 | + |
|
926 | + if ($showaddress) |
|
927 | + { |
|
928 | + // Sender properties |
|
929 | + $carac_emetteur=''; |
|
930 | + // Add internal contact of origin element if defined |
|
931 | + $arrayidcontact=array(); |
|
932 | + if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | + if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
934 | + if (count($arrayidcontact) > 0) |
|
935 | + { |
|
936 | + $object->fetch_user(reset($arrayidcontact)); |
|
937 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
938 | + } |
|
939 | + |
|
940 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
941 | + |
|
942 | + // Show sender |
|
943 | + $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | + $posx=$this->marge_gauche; |
|
945 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
946 | + |
|
947 | + $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | + $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
949 | + |
|
950 | + // Show sender frame |
|
951 | + $pdf->SetTextColor(0,0,0); |
|
952 | + $pdf->SetFont('','', $default_font_size - 2); |
|
953 | + $pdf->SetXY($posx,$posy-5); |
|
954 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | + $pdf->SetXY($posx,$posy); |
|
956 | + $pdf->SetFillColor(230,230,230); |
|
957 | + $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
|
958 | + $pdf->SetTextColor(0,0,60); |
|
959 | + $pdf->SetFillColor(255,255,255); |
|
960 | + |
|
961 | + // If RECEPTION contact defined, we use it |
|
962 | + $usecontact=false; |
|
963 | + $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
964 | + |
|
965 | + if (count($arrayidcontact) > 0) |
|
966 | + { |
|
967 | + $usecontact=true; |
|
968 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
969 | + } |
|
970 | + |
|
971 | + //Recipient name |
|
972 | + // On peut utiliser le nom de la societe du contact |
|
973 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
974 | + $thirdparty = $object->contact; |
|
975 | + } else { |
|
976 | + $thirdparty = $object->thirdparty; |
|
977 | + } |
|
978 | + |
|
979 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
980 | + |
|
981 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
982 | + |
|
983 | + // Show recipient name |
|
984 | + $pdf->SetXY($posx+2,$posy+3); |
|
985 | + $pdf->SetFont('','B', $default_font_size); |
|
986 | + $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); |
|
987 | + |
|
988 | + $posy = $pdf->getY(); |
|
989 | + |
|
990 | + // Show recipient information |
|
991 | + $pdf->SetFont('','', $default_font_size - 1); |
|
992 | + $pdf->SetXY($posx+2,$posy); |
|
993 | + $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); |
|
994 | + |
|
995 | + // Show recipient |
|
996 | + $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
998 | + $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | + $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1001 | + |
|
1002 | + // Show recipient frame |
|
1003 | + $pdf->SetTextColor(0,0,0); |
|
1004 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1005 | + $pdf->SetXY($posx+2,$posy-5); |
|
1006 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
|
1007 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1008 | + |
|
1009 | + |
|
1010 | + |
|
1011 | + // Show sender name |
|
1012 | + $pdf->SetXY($posx+2,$posy+3); |
|
1013 | + $pdf->SetFont('','B',$default_font_size); |
|
1014 | + $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1015 | + $posy=$pdf->getY(); |
|
1016 | + |
|
1017 | + // Show sender information |
|
1018 | + $pdf->SetXY($posx+2,$posy); |
|
1019 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1020 | + $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); |
|
1021 | + } |
|
1022 | + |
|
1023 | + $pdf->SetTextColor(0,0,0); |
|
1024 | + } |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * Show footer of page. Need this->emetteur object |
|
1028 | 1028 | * |
1029 | - * @param PDF $pdf PDF |
|
1030 | - * @param Object $object Object to show |
|
1031 | - * @param Translate $outputlangs Object lang for output |
|
1032 | - * @param int $hidefreetext 1=Hide free text |
|
1033 | - * @return int Return height of bottom margin including footer text |
|
1034 | - */ |
|
1035 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1036 | - { |
|
1037 | - global $conf; |
|
1038 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | - return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1040 | - } |
|
1029 | + * @param PDF $pdf PDF |
|
1030 | + * @param Object $object Object to show |
|
1031 | + * @param Translate $outputlangs Object lang for output |
|
1032 | + * @param int $hidefreetext 1=Hide free text |
|
1033 | + * @return int Return height of bottom margin including footer text |
|
1034 | + */ |
|
1035 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1036 | + { |
|
1037 | + global $conf; |
|
1038 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | + return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1040 | + } |
|
1041 | 1041 | } |
@@ -35,488 +35,488 @@ |
||
35 | 35 | */ |
36 | 36 | class doc_generic_reception_odt extends ModelePdfReception |
37 | 37 | { |
38 | - var $emetteur; // Objet societe qui emet |
|
39 | - |
|
40 | - var $phpmin = array(5,2,0); // Minimum version of PHP required by module |
|
41 | - var $version = 'dolibarr'; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Constructor |
|
46 | - * |
|
47 | - * @param DoliDB $db Database handler |
|
48 | - */ |
|
49 | - function __construct($db) |
|
50 | - { |
|
51 | - global $conf,$langs,$mysoc; |
|
52 | - |
|
53 | - $langs->load("main"); |
|
54 | - $langs->load("companies"); |
|
55 | - |
|
56 | - $this->db = $db; |
|
57 | - $this->name = "ODT templates"; |
|
58 | - $this->description = $langs->trans("DocumentModelOdt"); |
|
59 | - $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
60 | - |
|
61 | - // Dimension page pour format A4 |
|
62 | - $this->type = 'odt'; |
|
63 | - $this->page_largeur = 0; |
|
64 | - $this->page_hauteur = 0; |
|
65 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | - $this->marge_gauche=0; |
|
67 | - $this->marge_droite=0; |
|
68 | - $this->marge_haute=0; |
|
69 | - $this->marge_basse=0; |
|
70 | - |
|
71 | - $this->option_logo = 1; // Affiche logo |
|
72 | - $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | - $this->option_modereg = 0; // Affiche mode reglement |
|
74 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | - $this->option_credit_note = 0; // Support credit notes |
|
79 | - $this->option_freetext = 1; // Support add of a personalised text |
|
80 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | - |
|
82 | - // Recupere emetteur |
|
83 | - $this->emetteur=$mysoc; |
|
84 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Return description of a module |
|
90 | - * |
|
91 | - * @param Translate $langs Lang object to use for output |
|
92 | - * @return string Description |
|
93 | - */ |
|
94 | - function info($langs) |
|
95 | - { |
|
96 | - global $conf,$langs; |
|
97 | - |
|
98 | - $langs->load("companies"); |
|
99 | - $langs->load("errors"); |
|
100 | - |
|
101 | - $form = new Form($this->db); |
|
102 | - |
|
103 | - $texte = $this->description.".<br>\n"; |
|
104 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | - $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
109 | - |
|
110 | - // List of directories area |
|
111 | - $texte.= '<tr><td>'; |
|
112 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
113 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | - $listoffiles=array(); |
|
115 | - foreach($listofdir as $key=>$tmpdir) |
|
116 | - { |
|
117 | - $tmpdir=trim($tmpdir); |
|
118 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
119 | - if (! $tmpdir) { |
|
120 | - unset($listofdir[$key]); continue; |
|
121 | - } |
|
122 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | - else |
|
124 | - { |
|
125 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
126 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | - } |
|
128 | - } |
|
129 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
130 | - // Add list of substitution keys |
|
131 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | - |
|
134 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
135 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | - $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | - $texte.= '</textarea>'; |
|
139 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | - $texte.= '<br></div></div>'; |
|
142 | - |
|
143 | - // Scan directories |
|
144 | - $nbofiles=count($listoffiles); |
|
145 | - if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
146 | - { |
|
147 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | - //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | - $texte.=count($listoffiles); |
|
150 | - //$texte.=$nbofiles?'</a>':''; |
|
151 | - $texte.='</b>'; |
|
152 | - } |
|
153 | - if ($nbofiles) |
|
154 | - { |
|
155 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | - foreach($listoffiles as $file) |
|
157 | - { |
|
38 | + var $emetteur; // Objet societe qui emet |
|
39 | + |
|
40 | + var $phpmin = array(5,2,0); // Minimum version of PHP required by module |
|
41 | + var $version = 'dolibarr'; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Constructor |
|
46 | + * |
|
47 | + * @param DoliDB $db Database handler |
|
48 | + */ |
|
49 | + function __construct($db) |
|
50 | + { |
|
51 | + global $conf,$langs,$mysoc; |
|
52 | + |
|
53 | + $langs->load("main"); |
|
54 | + $langs->load("companies"); |
|
55 | + |
|
56 | + $this->db = $db; |
|
57 | + $this->name = "ODT templates"; |
|
58 | + $this->description = $langs->trans("DocumentModelOdt"); |
|
59 | + $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
60 | + |
|
61 | + // Dimension page pour format A4 |
|
62 | + $this->type = 'odt'; |
|
63 | + $this->page_largeur = 0; |
|
64 | + $this->page_hauteur = 0; |
|
65 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | + $this->marge_gauche=0; |
|
67 | + $this->marge_droite=0; |
|
68 | + $this->marge_haute=0; |
|
69 | + $this->marge_basse=0; |
|
70 | + |
|
71 | + $this->option_logo = 1; // Affiche logo |
|
72 | + $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | + $this->option_modereg = 0; // Affiche mode reglement |
|
74 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | + $this->option_credit_note = 0; // Support credit notes |
|
79 | + $this->option_freetext = 1; // Support add of a personalised text |
|
80 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | + |
|
82 | + // Recupere emetteur |
|
83 | + $this->emetteur=$mysoc; |
|
84 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Return description of a module |
|
90 | + * |
|
91 | + * @param Translate $langs Lang object to use for output |
|
92 | + * @return string Description |
|
93 | + */ |
|
94 | + function info($langs) |
|
95 | + { |
|
96 | + global $conf,$langs; |
|
97 | + |
|
98 | + $langs->load("companies"); |
|
99 | + $langs->load("errors"); |
|
100 | + |
|
101 | + $form = new Form($this->db); |
|
102 | + |
|
103 | + $texte = $this->description.".<br>\n"; |
|
104 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | + $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
109 | + |
|
110 | + // List of directories area |
|
111 | + $texte.= '<tr><td>'; |
|
112 | + $texttitle=$langs->trans("ListOfDirectories"); |
|
113 | + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | + $listoffiles=array(); |
|
115 | + foreach($listofdir as $key=>$tmpdir) |
|
116 | + { |
|
117 | + $tmpdir=trim($tmpdir); |
|
118 | + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
119 | + if (! $tmpdir) { |
|
120 | + unset($listofdir[$key]); continue; |
|
121 | + } |
|
122 | + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | + else |
|
124 | + { |
|
125 | + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
126 | + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | + } |
|
128 | + } |
|
129 | + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
130 | + // Add list of substitution keys |
|
131 | + $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | + |
|
134 | + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
135 | + $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | + $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | + $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | + $texte.= '</textarea>'; |
|
139 | + $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | + $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | + $texte.= '<br></div></div>'; |
|
142 | + |
|
143 | + // Scan directories |
|
144 | + $nbofiles=count($listoffiles); |
|
145 | + if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
146 | + { |
|
147 | + $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | + //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | + $texte.=count($listoffiles); |
|
150 | + //$texte.=$nbofiles?'</a>':''; |
|
151 | + $texte.='</b>'; |
|
152 | + } |
|
153 | + if ($nbofiles) |
|
154 | + { |
|
155 | + $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | + foreach($listoffiles as $file) |
|
157 | + { |
|
158 | 158 | $texte.=$file['name'].'<br>'; |
159 | - } |
|
160 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
161 | - } |
|
162 | - |
|
163 | - $texte.= '</td>'; |
|
164 | - |
|
165 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | - $texte.= '</td>'; |
|
168 | - $texte.= '</tr>'; |
|
169 | - |
|
170 | - $texte.= '</table>'; |
|
171 | - $texte.= '</form>'; |
|
172 | - |
|
173 | - return $texte; |
|
174 | - } |
|
175 | - |
|
176 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
177 | - /** |
|
178 | - * Function to build a document on disk using the generic odt module. |
|
179 | - * |
|
180 | - * @param Reception $object Object source to build document |
|
181 | - * @param Translate $outputlangs Lang output object |
|
182 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
183 | - * @param int $hidedetails Do not show line details |
|
184 | - * @param int $hidedesc Do not show desc |
|
185 | - * @param int $hideref Do not show ref |
|
186 | - * @return int 1 if OK, <=0 if KO |
|
187 | - */ |
|
188 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
189 | - { |
|
190 | - // phpcs:enable |
|
191 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | - |
|
193 | - if (empty($srctemplatepath)) |
|
194 | - { |
|
195 | - dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
196 | - return -1; |
|
197 | - } |
|
198 | - |
|
199 | - // Add odtgeneration hook |
|
200 | - if (! is_object($hookmanager)) |
|
201 | - { |
|
202 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
203 | - $hookmanager=new HookManager($this->db); |
|
204 | - } |
|
205 | - $hookmanager->initHooks(array('odtgeneration')); |
|
206 | - global $action; |
|
207 | - |
|
208 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | - $sav_charset_output=$outputlangs->charset_output; |
|
210 | - $outputlangs->charset_output='UTF-8'; |
|
211 | - |
|
212 | - $outputlangs->load("main"); |
|
213 | - $outputlangs->load("dict"); |
|
214 | - $outputlangs->load("companies"); |
|
215 | - $outputlangs->load("bills"); |
|
216 | - |
|
217 | - if ($conf->reception->dir_output."/reception") |
|
218 | - { |
|
219 | - // If $object is id instead of object |
|
220 | - if (! is_object($object)) |
|
221 | - { |
|
222 | - $id = $object; |
|
223 | - $object = new Reception($this->db); |
|
224 | - $result=$object->fetch($id); |
|
225 | - if ($result < 0) |
|
226 | - { |
|
227 | - dol_print_error($this->db,$object->error); |
|
228 | - return -1; |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - $dir = $conf->reception->dir_output."/reception"; |
|
233 | - $objectref = dol_sanitizeFileName($object->ref); |
|
234 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
235 | - $file = $dir . "/" . $objectref . ".odt"; |
|
236 | - |
|
237 | - if (! file_exists($dir)) |
|
238 | - { |
|
239 | - if (dol_mkdir($dir) < 0) |
|
240 | - { |
|
241 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
242 | - return -1; |
|
243 | - } |
|
244 | - } |
|
245 | - |
|
246 | - if (file_exists($dir)) |
|
247 | - { |
|
248 | - //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
249 | - $newfile=basename($srctemplatepath); |
|
250 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
251 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
252 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
253 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
254 | - //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
255 | - // Get extension (ods or odt) |
|
256 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
257 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
258 | - { |
|
259 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
260 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
261 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
262 | - } |
|
263 | - else |
|
264 | - { |
|
265 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
266 | - } |
|
267 | - $file=$dir.'/'.$filename; |
|
268 | - //print "newdir=".$dir; |
|
269 | - //print "newfile=".$newfile; |
|
270 | - //print "file=".$file; |
|
271 | - //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
272 | - |
|
273 | - dol_mkdir($conf->reception->dir_temp); |
|
274 | - |
|
275 | - |
|
276 | - // If BILLING contact defined on invoice, we use it |
|
277 | - $usecontact=false; |
|
278 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
279 | - if (count($arrayidcontact) > 0) |
|
280 | - { |
|
281 | - $usecontact=true; |
|
282 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
283 | - } |
|
284 | - |
|
285 | - // Recipient name |
|
286 | - if (! empty($usecontact)) |
|
287 | - { |
|
288 | - // On peut utiliser le nom de la societe du contact |
|
289 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | - else $socobject = $object->thirdparty; |
|
291 | - } |
|
292 | - else |
|
293 | - { |
|
294 | - $socobject=$object->thirdparty; |
|
295 | - } |
|
296 | - |
|
297 | - // Make substitution |
|
298 | - $substitutionarray=array( |
|
299 | - '__FROM_NAME__' => $this->emetteur->name, |
|
300 | - '__FROM_EMAIL__' => $this->emetteur->email, |
|
301 | - '__TOTAL_TTC__' => $object->total_ttc, |
|
302 | - '__TOTAL_HT__' => $object->total_ht, |
|
303 | - '__TOTAL_VAT__' => $object->total_vat |
|
304 | - ); |
|
305 | - complete_substitutions_array($substitutionarray, $langs, $object); |
|
306 | - // Call the ODTSubstitution hook |
|
307 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
308 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
309 | - |
|
310 | - // Line of free text |
|
311 | - $newfreetext=''; |
|
312 | - $paramfreetext='RECEPTION_FREE_TEXT'; |
|
313 | - if (! empty($conf->global->$paramfreetext)) |
|
314 | - { |
|
315 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
316 | - } |
|
317 | - |
|
318 | - // Open and load template |
|
319 | - require_once ODTPHP_PATH.'odf.php'; |
|
320 | - try { |
|
321 | - $odfHandler = new odf( |
|
322 | - $srctemplatepath, |
|
323 | - array( |
|
324 | - 'PATH_TO_TMP' => $conf->reception->dir_temp, |
|
325 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
326 | - 'DELIMITER_LEFT' => '{', |
|
327 | - 'DELIMITER_RIGHT' => '}' |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - catch(Exception $e) |
|
332 | - { |
|
333 | - $this->error=$e->getMessage(); |
|
334 | - return -1; |
|
335 | - } |
|
336 | - // After construction $odfHandler->contentXml contains content and |
|
337 | - // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
338 | - // [!-- BEGIN lines --]*[!-- END lines --] |
|
339 | - //print html_entity_decode($odfHandler->__toString()); |
|
340 | - //print exit; |
|
341 | - |
|
342 | - |
|
343 | - // Make substitutions into odt of freetext |
|
344 | - try { |
|
345 | - $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
346 | - } |
|
347 | - catch(OdfException $e) |
|
348 | - { |
|
349 | - } |
|
350 | - |
|
351 | - // Make substitutions into odt of user info |
|
352 | - $tmparray=$this->get_substitutionarray_user($user,$outputlangs); |
|
353 | - //var_dump($tmparray); exit; |
|
354 | - foreach($tmparray as $key=>$value) |
|
355 | - { |
|
356 | - try { |
|
357 | - if (preg_match('/logo$/',$key)) // Image |
|
358 | - { |
|
359 | - //var_dump($value);exit; |
|
360 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
361 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | - } |
|
363 | - else // Text |
|
364 | - { |
|
365 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
366 | - } |
|
367 | - } |
|
368 | - catch(OdfException $e) |
|
369 | - { |
|
370 | - } |
|
371 | - } |
|
372 | - // Make substitutions into odt of mysoc |
|
373 | - $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
374 | - //var_dump($tmparray); exit; |
|
375 | - foreach($tmparray as $key=>$value) |
|
376 | - { |
|
377 | - try { |
|
378 | - if (preg_match('/logo$/',$key)) // Image |
|
379 | - { |
|
380 | - //var_dump($value);exit; |
|
381 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | - } |
|
384 | - else // Text |
|
385 | - { |
|
386 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
387 | - } |
|
388 | - } |
|
389 | - catch(OdfException $e) |
|
390 | - { |
|
391 | - } |
|
392 | - } |
|
393 | - // Make substitutions into odt of thirdparty |
|
394 | - $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
395 | - foreach($tmparray as $key=>$value) |
|
396 | - { |
|
397 | - try { |
|
398 | - if (preg_match('/logo$/',$key)) // Image |
|
399 | - { |
|
400 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
401 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | - } |
|
403 | - else // Text |
|
404 | - { |
|
405 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
406 | - } |
|
407 | - } |
|
408 | - catch(OdfException $e) |
|
409 | - { |
|
410 | - } |
|
411 | - } |
|
412 | - // Replace tags of object + external modules |
|
413 | - $tmparray=$this->get_substitutionarray_reception($object,$outputlangs); |
|
414 | - complete_substitutions_array($tmparray, $outputlangs, $object); |
|
415 | - // Call the ODTSubstitution hook |
|
416 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
417 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | - foreach($tmparray as $key=>$value) |
|
419 | - { |
|
420 | - try { |
|
421 | - if (preg_match('/logo$/',$key)) // Image |
|
422 | - { |
|
423 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
424 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | - } |
|
426 | - else // Text |
|
427 | - { |
|
428 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
429 | - } |
|
430 | - } |
|
431 | - catch(OdfException $e) |
|
432 | - { |
|
433 | - } |
|
434 | - } |
|
435 | - // Replace tags of lines |
|
436 | - try |
|
437 | - { |
|
438 | - $listlines = $odfHandler->setSegment('lines'); |
|
439 | - foreach ($object->lines as $line) |
|
440 | - { |
|
441 | - $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs); |
|
442 | - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
443 | - // Call the ODTSubstitutionLine hook |
|
444 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
445 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
446 | - foreach($tmparray as $key => $val) |
|
447 | - { |
|
448 | - try |
|
449 | - { |
|
450 | - $listlines->setVars($key, $val, true, 'UTF-8'); |
|
451 | - } |
|
452 | - catch(OdfException $e) |
|
453 | - { |
|
454 | - } |
|
455 | - catch(SegmentException $e) |
|
456 | - { |
|
457 | - } |
|
458 | - } |
|
459 | - $listlines->merge(); |
|
460 | - } |
|
461 | - $odfHandler->mergeSegment($listlines); |
|
462 | - } |
|
463 | - catch(OdfException $e) |
|
464 | - { |
|
465 | - $this->error=$e->getMessage(); |
|
466 | - dol_syslog($this->error, LOG_WARNING); |
|
467 | - return -1; |
|
468 | - } |
|
469 | - |
|
470 | - // Replace labels translated |
|
471 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
472 | - foreach($tmparray as $key=>$value) |
|
473 | - { |
|
474 | - try { |
|
475 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
476 | - } |
|
477 | - catch(OdfException $e) |
|
478 | - { |
|
479 | - } |
|
480 | - } |
|
481 | - |
|
482 | - // Call the beforeODTSave hook |
|
483 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
484 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
485 | - |
|
486 | - // Write new file |
|
487 | - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
488 | - try { |
|
489 | - $odfHandler->exportAsAttachedPDF($file); |
|
490 | - }catch (Exception $e){ |
|
491 | - $this->error=$e->getMessage(); |
|
492 | - return -1; |
|
493 | - } |
|
494 | - } |
|
495 | - else { |
|
496 | - try { |
|
497 | - $odfHandler->saveToDisk($file); |
|
498 | - }catch (Exception $e){ |
|
499 | - $this->error=$e->getMessage(); |
|
500 | - return -1; |
|
501 | - } |
|
502 | - } |
|
503 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
504 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
505 | - |
|
506 | - if (! empty($conf->global->MAIN_UMASK)) |
|
507 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
508 | - |
|
509 | - $odfHandler=null; // Destroy object |
|
510 | - |
|
511 | - return 1; // Success |
|
512 | - } |
|
513 | - else |
|
514 | - { |
|
515 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
516 | - return -1; |
|
517 | - } |
|
518 | - } |
|
519 | - |
|
520 | - return -1; |
|
521 | - } |
|
159 | + } |
|
160 | + $texte.='<div id="div_'.get_class($this).'">'; |
|
161 | + } |
|
162 | + |
|
163 | + $texte.= '</td>'; |
|
164 | + |
|
165 | + $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | + $texte.= '</td>'; |
|
168 | + $texte.= '</tr>'; |
|
169 | + |
|
170 | + $texte.= '</table>'; |
|
171 | + $texte.= '</form>'; |
|
172 | + |
|
173 | + return $texte; |
|
174 | + } |
|
175 | + |
|
176 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
177 | + /** |
|
178 | + * Function to build a document on disk using the generic odt module. |
|
179 | + * |
|
180 | + * @param Reception $object Object source to build document |
|
181 | + * @param Translate $outputlangs Lang output object |
|
182 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
183 | + * @param int $hidedetails Do not show line details |
|
184 | + * @param int $hidedesc Do not show desc |
|
185 | + * @param int $hideref Do not show ref |
|
186 | + * @return int 1 if OK, <=0 if KO |
|
187 | + */ |
|
188 | + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
189 | + { |
|
190 | + // phpcs:enable |
|
191 | + global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | + |
|
193 | + if (empty($srctemplatepath)) |
|
194 | + { |
|
195 | + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
196 | + return -1; |
|
197 | + } |
|
198 | + |
|
199 | + // Add odtgeneration hook |
|
200 | + if (! is_object($hookmanager)) |
|
201 | + { |
|
202 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
203 | + $hookmanager=new HookManager($this->db); |
|
204 | + } |
|
205 | + $hookmanager->initHooks(array('odtgeneration')); |
|
206 | + global $action; |
|
207 | + |
|
208 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | + $sav_charset_output=$outputlangs->charset_output; |
|
210 | + $outputlangs->charset_output='UTF-8'; |
|
211 | + |
|
212 | + $outputlangs->load("main"); |
|
213 | + $outputlangs->load("dict"); |
|
214 | + $outputlangs->load("companies"); |
|
215 | + $outputlangs->load("bills"); |
|
216 | + |
|
217 | + if ($conf->reception->dir_output."/reception") |
|
218 | + { |
|
219 | + // If $object is id instead of object |
|
220 | + if (! is_object($object)) |
|
221 | + { |
|
222 | + $id = $object; |
|
223 | + $object = new Reception($this->db); |
|
224 | + $result=$object->fetch($id); |
|
225 | + if ($result < 0) |
|
226 | + { |
|
227 | + dol_print_error($this->db,$object->error); |
|
228 | + return -1; |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + $dir = $conf->reception->dir_output."/reception"; |
|
233 | + $objectref = dol_sanitizeFileName($object->ref); |
|
234 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
235 | + $file = $dir . "/" . $objectref . ".odt"; |
|
236 | + |
|
237 | + if (! file_exists($dir)) |
|
238 | + { |
|
239 | + if (dol_mkdir($dir) < 0) |
|
240 | + { |
|
241 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
242 | + return -1; |
|
243 | + } |
|
244 | + } |
|
245 | + |
|
246 | + if (file_exists($dir)) |
|
247 | + { |
|
248 | + //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
249 | + $newfile=basename($srctemplatepath); |
|
250 | + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
251 | + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
252 | + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
253 | + $newfiletmp=$objectref.'_'.$newfiletmp; |
|
254 | + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
255 | + // Get extension (ods or odt) |
|
256 | + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
257 | + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
258 | + { |
|
259 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
260 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
261 | + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
262 | + } |
|
263 | + else |
|
264 | + { |
|
265 | + $filename=$newfiletmp.'.'.$newfileformat; |
|
266 | + } |
|
267 | + $file=$dir.'/'.$filename; |
|
268 | + //print "newdir=".$dir; |
|
269 | + //print "newfile=".$newfile; |
|
270 | + //print "file=".$file; |
|
271 | + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
272 | + |
|
273 | + dol_mkdir($conf->reception->dir_temp); |
|
274 | + |
|
275 | + |
|
276 | + // If BILLING contact defined on invoice, we use it |
|
277 | + $usecontact=false; |
|
278 | + $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
279 | + if (count($arrayidcontact) > 0) |
|
280 | + { |
|
281 | + $usecontact=true; |
|
282 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
283 | + } |
|
284 | + |
|
285 | + // Recipient name |
|
286 | + if (! empty($usecontact)) |
|
287 | + { |
|
288 | + // On peut utiliser le nom de la societe du contact |
|
289 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | + else $socobject = $object->thirdparty; |
|
291 | + } |
|
292 | + else |
|
293 | + { |
|
294 | + $socobject=$object->thirdparty; |
|
295 | + } |
|
296 | + |
|
297 | + // Make substitution |
|
298 | + $substitutionarray=array( |
|
299 | + '__FROM_NAME__' => $this->emetteur->name, |
|
300 | + '__FROM_EMAIL__' => $this->emetteur->email, |
|
301 | + '__TOTAL_TTC__' => $object->total_ttc, |
|
302 | + '__TOTAL_HT__' => $object->total_ht, |
|
303 | + '__TOTAL_VAT__' => $object->total_vat |
|
304 | + ); |
|
305 | + complete_substitutions_array($substitutionarray, $langs, $object); |
|
306 | + // Call the ODTSubstitution hook |
|
307 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
308 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
309 | + |
|
310 | + // Line of free text |
|
311 | + $newfreetext=''; |
|
312 | + $paramfreetext='RECEPTION_FREE_TEXT'; |
|
313 | + if (! empty($conf->global->$paramfreetext)) |
|
314 | + { |
|
315 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
316 | + } |
|
317 | + |
|
318 | + // Open and load template |
|
319 | + require_once ODTPHP_PATH.'odf.php'; |
|
320 | + try { |
|
321 | + $odfHandler = new odf( |
|
322 | + $srctemplatepath, |
|
323 | + array( |
|
324 | + 'PATH_TO_TMP' => $conf->reception->dir_temp, |
|
325 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
326 | + 'DELIMITER_LEFT' => '{', |
|
327 | + 'DELIMITER_RIGHT' => '}' |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + catch(Exception $e) |
|
332 | + { |
|
333 | + $this->error=$e->getMessage(); |
|
334 | + return -1; |
|
335 | + } |
|
336 | + // After construction $odfHandler->contentXml contains content and |
|
337 | + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
338 | + // [!-- BEGIN lines --]*[!-- END lines --] |
|
339 | + //print html_entity_decode($odfHandler->__toString()); |
|
340 | + //print exit; |
|
341 | + |
|
342 | + |
|
343 | + // Make substitutions into odt of freetext |
|
344 | + try { |
|
345 | + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
346 | + } |
|
347 | + catch(OdfException $e) |
|
348 | + { |
|
349 | + } |
|
350 | + |
|
351 | + // Make substitutions into odt of user info |
|
352 | + $tmparray=$this->get_substitutionarray_user($user,$outputlangs); |
|
353 | + //var_dump($tmparray); exit; |
|
354 | + foreach($tmparray as $key=>$value) |
|
355 | + { |
|
356 | + try { |
|
357 | + if (preg_match('/logo$/',$key)) // Image |
|
358 | + { |
|
359 | + //var_dump($value);exit; |
|
360 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
361 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | + } |
|
363 | + else // Text |
|
364 | + { |
|
365 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
366 | + } |
|
367 | + } |
|
368 | + catch(OdfException $e) |
|
369 | + { |
|
370 | + } |
|
371 | + } |
|
372 | + // Make substitutions into odt of mysoc |
|
373 | + $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
374 | + //var_dump($tmparray); exit; |
|
375 | + foreach($tmparray as $key=>$value) |
|
376 | + { |
|
377 | + try { |
|
378 | + if (preg_match('/logo$/',$key)) // Image |
|
379 | + { |
|
380 | + //var_dump($value);exit; |
|
381 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
382 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | + } |
|
384 | + else // Text |
|
385 | + { |
|
386 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
387 | + } |
|
388 | + } |
|
389 | + catch(OdfException $e) |
|
390 | + { |
|
391 | + } |
|
392 | + } |
|
393 | + // Make substitutions into odt of thirdparty |
|
394 | + $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
395 | + foreach($tmparray as $key=>$value) |
|
396 | + { |
|
397 | + try { |
|
398 | + if (preg_match('/logo$/',$key)) // Image |
|
399 | + { |
|
400 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
401 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | + } |
|
403 | + else // Text |
|
404 | + { |
|
405 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
406 | + } |
|
407 | + } |
|
408 | + catch(OdfException $e) |
|
409 | + { |
|
410 | + } |
|
411 | + } |
|
412 | + // Replace tags of object + external modules |
|
413 | + $tmparray=$this->get_substitutionarray_reception($object,$outputlangs); |
|
414 | + complete_substitutions_array($tmparray, $outputlangs, $object); |
|
415 | + // Call the ODTSubstitution hook |
|
416 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
417 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | + foreach($tmparray as $key=>$value) |
|
419 | + { |
|
420 | + try { |
|
421 | + if (preg_match('/logo$/',$key)) // Image |
|
422 | + { |
|
423 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
424 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | + } |
|
426 | + else // Text |
|
427 | + { |
|
428 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
429 | + } |
|
430 | + } |
|
431 | + catch(OdfException $e) |
|
432 | + { |
|
433 | + } |
|
434 | + } |
|
435 | + // Replace tags of lines |
|
436 | + try |
|
437 | + { |
|
438 | + $listlines = $odfHandler->setSegment('lines'); |
|
439 | + foreach ($object->lines as $line) |
|
440 | + { |
|
441 | + $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs); |
|
442 | + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
443 | + // Call the ODTSubstitutionLine hook |
|
444 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
445 | + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
446 | + foreach($tmparray as $key => $val) |
|
447 | + { |
|
448 | + try |
|
449 | + { |
|
450 | + $listlines->setVars($key, $val, true, 'UTF-8'); |
|
451 | + } |
|
452 | + catch(OdfException $e) |
|
453 | + { |
|
454 | + } |
|
455 | + catch(SegmentException $e) |
|
456 | + { |
|
457 | + } |
|
458 | + } |
|
459 | + $listlines->merge(); |
|
460 | + } |
|
461 | + $odfHandler->mergeSegment($listlines); |
|
462 | + } |
|
463 | + catch(OdfException $e) |
|
464 | + { |
|
465 | + $this->error=$e->getMessage(); |
|
466 | + dol_syslog($this->error, LOG_WARNING); |
|
467 | + return -1; |
|
468 | + } |
|
469 | + |
|
470 | + // Replace labels translated |
|
471 | + $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
472 | + foreach($tmparray as $key=>$value) |
|
473 | + { |
|
474 | + try { |
|
475 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
476 | + } |
|
477 | + catch(OdfException $e) |
|
478 | + { |
|
479 | + } |
|
480 | + } |
|
481 | + |
|
482 | + // Call the beforeODTSave hook |
|
483 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
484 | + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
485 | + |
|
486 | + // Write new file |
|
487 | + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
488 | + try { |
|
489 | + $odfHandler->exportAsAttachedPDF($file); |
|
490 | + }catch (Exception $e){ |
|
491 | + $this->error=$e->getMessage(); |
|
492 | + return -1; |
|
493 | + } |
|
494 | + } |
|
495 | + else { |
|
496 | + try { |
|
497 | + $odfHandler->saveToDisk($file); |
|
498 | + }catch (Exception $e){ |
|
499 | + $this->error=$e->getMessage(); |
|
500 | + return -1; |
|
501 | + } |
|
502 | + } |
|
503 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
504 | + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
505 | + |
|
506 | + if (! empty($conf->global->MAIN_UMASK)) |
|
507 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
508 | + |
|
509 | + $odfHandler=null; // Destroy object |
|
510 | + |
|
511 | + return 1; // Success |
|
512 | + } |
|
513 | + else |
|
514 | + { |
|
515 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
516 | + return -1; |
|
517 | + } |
|
518 | + } |
|
519 | + |
|
520 | + return -1; |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | \ No newline at end of file |
@@ -28,119 +28,119 @@ |
||
28 | 28 | */ |
29 | 29 | class mod_reception_beryl extends ModelNumRefReception |
30 | 30 | { |
31 | - var $version='dolibarr'; |
|
32 | - var $prefix='RCP'; |
|
33 | - var $error=''; |
|
34 | - var $nom='Beryl'; |
|
31 | + var $version='dolibarr'; |
|
32 | + var $prefix='RCP'; |
|
33 | + var $error=''; |
|
34 | + var $nom='Beryl'; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Return default description of numbering model |
|
39 | - * |
|
40 | - * @return string text description |
|
41 | - */ |
|
37 | + /** |
|
38 | + * Return default description of numbering model |
|
39 | + * |
|
40 | + * @return string text description |
|
41 | + */ |
|
42 | 42 | function info() |
43 | 43 | { |
44 | - global $langs; |
|
45 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
44 | + global $langs; |
|
45 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Return numbering example |
|
51 | - * |
|
52 | - * @return string Example |
|
53 | - */ |
|
54 | - function getExample() |
|
55 | - { |
|
56 | - return $this->prefix."0501-0001"; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Test if existing numbers make problems with numbering |
|
62 | - * |
|
63 | - * @return boolean false if conflit, true if ok |
|
64 | - */ |
|
65 | - function canBeActivated() |
|
66 | - { |
|
67 | - global $conf,$langs,$db; |
|
68 | - |
|
69 | - $coyymm=''; $max=''; |
|
70 | - |
|
71 | - $posindice=8; |
|
72 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
73 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | - $sql.= " AND entity = ".$conf->entity; |
|
76 | - |
|
77 | - $resql=$db->query($sql); |
|
78 | - if ($resql) |
|
79 | - { |
|
80 | - $row = $db->fetch_row($resql); |
|
81 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
82 | - } |
|
83 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
84 | - { |
|
85 | - $langs->load("errors"); |
|
86 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
87 | - return false; |
|
88 | - } |
|
89 | - |
|
90 | - return true; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Return next value |
|
95 | - * |
|
96 | - * @param Societe $objsoc Third party object |
|
97 | - * @param Object $shipment Shipment object |
|
98 | - * @return string Value if OK, 0 if KO |
|
99 | - */ |
|
100 | - function getNextValue($objsoc,$shipment) |
|
101 | - { |
|
102 | - global $db,$conf; |
|
103 | - |
|
104 | - $posindice=9; |
|
105 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | - $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | - |
|
110 | - $resql=$db->query($sql); |
|
111 | - if ($resql) |
|
112 | - { |
|
113 | - $obj = $db->fetch_object($resql); |
|
114 | - if ($obj) $max = intval($obj->max); |
|
115 | - else $max=0; |
|
116 | - } |
|
117 | - else |
|
118 | - { |
|
119 | - dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
|
120 | - return -1; |
|
121 | - } |
|
122 | - |
|
123 | - $date=time(); |
|
124 | - $yymm = strftime("%y%m",$date); |
|
125 | - |
|
126 | - 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 |
|
127 | - else $num = sprintf("%04s",$max+1); |
|
128 | - |
|
129 | - dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
130 | - return $this->prefix.$yymm."-".$num; |
|
131 | - } |
|
132 | - |
|
133 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
134 | - /** |
|
135 | - * Return next free value |
|
136 | - * |
|
137 | - * @param Societe $objsoc Third party object |
|
138 | - * @param Object $objforref Shipment object |
|
139 | - * @return string Next free value |
|
140 | - */ |
|
141 | - function reception_get_num($objsoc,$objforref) |
|
142 | - { |
|
143 | - // phpcs:enable |
|
144 | - return $this->getNextValue($objsoc,$objforref); |
|
145 | - } |
|
49 | + /** |
|
50 | + * Return numbering example |
|
51 | + * |
|
52 | + * @return string Example |
|
53 | + */ |
|
54 | + function getExample() |
|
55 | + { |
|
56 | + return $this->prefix."0501-0001"; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Test if existing numbers make problems with numbering |
|
62 | + * |
|
63 | + * @return boolean false if conflit, true if ok |
|
64 | + */ |
|
65 | + function canBeActivated() |
|
66 | + { |
|
67 | + global $conf,$langs,$db; |
|
68 | + |
|
69 | + $coyymm=''; $max=''; |
|
70 | + |
|
71 | + $posindice=8; |
|
72 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
73 | + $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | + $sql.= " AND entity = ".$conf->entity; |
|
76 | + |
|
77 | + $resql=$db->query($sql); |
|
78 | + if ($resql) |
|
79 | + { |
|
80 | + $row = $db->fetch_row($resql); |
|
81 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
82 | + } |
|
83 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
84 | + { |
|
85 | + $langs->load("errors"); |
|
86 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
87 | + return false; |
|
88 | + } |
|
89 | + |
|
90 | + return true; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Return next value |
|
95 | + * |
|
96 | + * @param Societe $objsoc Third party object |
|
97 | + * @param Object $shipment Shipment object |
|
98 | + * @return string Value if OK, 0 if KO |
|
99 | + */ |
|
100 | + function getNextValue($objsoc,$shipment) |
|
101 | + { |
|
102 | + global $db,$conf; |
|
103 | + |
|
104 | + $posindice=9; |
|
105 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | + $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | + $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | + $sql.= " AND entity = ".$conf->entity; |
|
109 | + |
|
110 | + $resql=$db->query($sql); |
|
111 | + if ($resql) |
|
112 | + { |
|
113 | + $obj = $db->fetch_object($resql); |
|
114 | + if ($obj) $max = intval($obj->max); |
|
115 | + else $max=0; |
|
116 | + } |
|
117 | + else |
|
118 | + { |
|
119 | + dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
|
120 | + return -1; |
|
121 | + } |
|
122 | + |
|
123 | + $date=time(); |
|
124 | + $yymm = strftime("%y%m",$date); |
|
125 | + |
|
126 | + 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 |
|
127 | + else $num = sprintf("%04s",$max+1); |
|
128 | + |
|
129 | + dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
130 | + return $this->prefix.$yymm."-".$num; |
|
131 | + } |
|
132 | + |
|
133 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
134 | + /** |
|
135 | + * Return next free value |
|
136 | + * |
|
137 | + * @param Societe $objsoc Third party object |
|
138 | + * @param Object $objforref Shipment object |
|
139 | + * @return string Next free value |
|
140 | + */ |
|
141 | + function reception_get_num($objsoc,$objforref) |
|
142 | + { |
|
143 | + // phpcs:enable |
|
144 | + return $this->getNextValue($objsoc,$objforref); |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File that contains parent class for sending receipts models |
23 | 23 | * and parent class for sending receipts numbering models |
24 | 24 | */ |
25 | - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
25 | + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Parent class of sending receipts models |
@@ -34,25 +34,25 @@ discard block |
||
34 | 34 | |
35 | 35 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
36 | 36 | /** |
37 | - * Return list of active generation modules |
|
38 | - * |
|
37 | + * Return list of active generation modules |
|
38 | + * |
|
39 | 39 | * @param DoliDB $db Database handler |
40 | 40 | * @param integer $maxfilenamelength Max length of value to show |
41 | 41 | * @return array List of templates |
42 | - */ |
|
43 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
44 | - { |
|
45 | - // phpcs:enable |
|
46 | - global $conf; |
|
42 | + */ |
|
43 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
44 | + { |
|
45 | + // phpcs:enable |
|
46 | + global $conf; |
|
47 | 47 | |
48 | - $type='reception'; |
|
49 | - $liste=array(); |
|
48 | + $type='reception'; |
|
49 | + $liste=array(); |
|
50 | 50 | |
51 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
51 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
53 | 53 | |
54 | - return $liste; |
|
55 | - } |
|
54 | + return $liste; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -61,78 +61,78 @@ discard block |
||
61 | 61 | */ |
62 | 62 | abstract class ModelNumRefReception |
63 | 63 | { |
64 | - var $error=''; |
|
65 | - |
|
66 | - /** Return if a model can be used or not |
|
67 | - * |
|
68 | - * @return boolean true if model can be used |
|
69 | - */ |
|
70 | - function isEnabled() |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Return default description of numbering model |
|
77 | - * |
|
78 | - * @return string text description |
|
79 | - */ |
|
80 | - function info() |
|
81 | - { |
|
82 | - global $langs; |
|
83 | - $langs->load("reception"); |
|
84 | - return $langs->trans("NoDescription"); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns numbering example |
|
89 | - * |
|
90 | - * @return string Example |
|
91 | - */ |
|
92 | - function getExample() |
|
93 | - { |
|
94 | - global $langs; |
|
95 | - $langs->load("reception"); |
|
96 | - return $langs->trans("NoExample"); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Test if existing numbers make problems with numbering |
|
101 | - * |
|
102 | - * @return boolean false if conflit, true if ok |
|
103 | - */ |
|
104 | - function canBeActivated() |
|
105 | - { |
|
106 | - return true; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Returns next value assigned |
|
111 | - * |
|
112 | - * @param Societe $objsoc Third party object |
|
113 | - * @param Object $shipment Shipment object |
|
114 | - * @return string Value |
|
115 | - */ |
|
116 | - function getNextValue($objsoc, $shipment) |
|
117 | - { |
|
118 | - global $langs; |
|
119 | - return $langs->trans("NotAvailable"); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Returns version of the numbering model |
|
124 | - * |
|
125 | - * @return string Value |
|
126 | - */ |
|
127 | - function getVersion() |
|
128 | - { |
|
129 | - global $langs; |
|
130 | - $langs->load("admin"); |
|
131 | - |
|
132 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
133 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
134 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
135 | - if ($this->version) return $this->version; |
|
136 | - return $langs->trans("NotAvailable"); |
|
137 | - } |
|
64 | + var $error=''; |
|
65 | + |
|
66 | + /** Return if a model can be used or not |
|
67 | + * |
|
68 | + * @return boolean true if model can be used |
|
69 | + */ |
|
70 | + function isEnabled() |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Return default description of numbering model |
|
77 | + * |
|
78 | + * @return string text description |
|
79 | + */ |
|
80 | + function info() |
|
81 | + { |
|
82 | + global $langs; |
|
83 | + $langs->load("reception"); |
|
84 | + return $langs->trans("NoDescription"); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns numbering example |
|
89 | + * |
|
90 | + * @return string Example |
|
91 | + */ |
|
92 | + function getExample() |
|
93 | + { |
|
94 | + global $langs; |
|
95 | + $langs->load("reception"); |
|
96 | + return $langs->trans("NoExample"); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Test if existing numbers make problems with numbering |
|
101 | + * |
|
102 | + * @return boolean false if conflit, true if ok |
|
103 | + */ |
|
104 | + function canBeActivated() |
|
105 | + { |
|
106 | + return true; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Returns next value assigned |
|
111 | + * |
|
112 | + * @param Societe $objsoc Third party object |
|
113 | + * @param Object $shipment Shipment object |
|
114 | + * @return string Value |
|
115 | + */ |
|
116 | + function getNextValue($objsoc, $shipment) |
|
117 | + { |
|
118 | + global $langs; |
|
119 | + return $langs->trans("NotAvailable"); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Returns version of the numbering model |
|
124 | + * |
|
125 | + * @return string Value |
|
126 | + */ |
|
127 | + function getVersion() |
|
128 | + { |
|
129 | + global $langs; |
|
130 | + $langs->load("admin"); |
|
131 | + |
|
132 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
133 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
134 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
135 | + if ($this->version) return $this->version; |
|
136 | + return $langs->trans("NotAvailable"); |
|
137 | + } |
|
138 | 138 | } |
@@ -29,109 +29,109 @@ |
||
29 | 29 | */ |
30 | 30 | class mod_reception_moonstone extends ModelNumRefReception |
31 | 31 | { |
32 | - var $version='dolibarr'; |
|
33 | - var $error = ''; |
|
34 | - var $nom = 'Moonstone'; |
|
35 | - |
|
36 | - /** |
|
37 | - * Return default description of numbering model |
|
38 | - * |
|
39 | - * @return string text description |
|
40 | - */ |
|
41 | - function info() |
|
32 | + var $version='dolibarr'; |
|
33 | + var $error = ''; |
|
34 | + var $nom = 'Moonstone'; |
|
35 | + |
|
36 | + /** |
|
37 | + * Return default description of numbering model |
|
38 | + * |
|
39 | + * @return string text description |
|
40 | + */ |
|
41 | + function info() |
|
42 | 42 | { |
43 | - global $conf,$langs; |
|
43 | + global $conf,$langs; |
|
44 | 44 | |
45 | - $langs->load("bills"); |
|
45 | + $langs->load("bills"); |
|
46 | 46 | |
47 | - $form = new Form($this->db); |
|
47 | + $form = new Form($this->db); |
|
48 | 48 | |
49 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
50 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | - $texte.= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
49 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
50 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | + $texte.= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
55 | 55 | |
56 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
57 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
58 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
59 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
56 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
57 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
58 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
59 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
60 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
61 | 61 | |
62 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>'; |
|
64 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | - $texte.= '</tr>'; |
|
66 | - $texte.= '</table>'; |
|
67 | - $texte.= '</form>'; |
|
62 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>'; |
|
64 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | + $texte.= '</tr>'; |
|
66 | + $texte.= '</table>'; |
|
67 | + $texte.= '</form>'; |
|
68 | 68 | |
69 | - return $texte; |
|
69 | + return $texte; |
|
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Return numbering example |
|
74 | - * |
|
75 | - * @return string Example |
|
76 | - */ |
|
72 | + /** |
|
73 | + * Return numbering example |
|
74 | + * |
|
75 | + * @return string Example |
|
76 | + */ |
|
77 | 77 | function getExample() |
78 | 78 | { |
79 | - global $conf,$langs,$mysoc; |
|
80 | - |
|
81 | - $old_code_client=$mysoc->code_client; |
|
82 | - $old_code_type=$mysoc->typent_code; |
|
83 | - $mysoc->code_client='CCCCCCCCCC'; |
|
84 | - $mysoc->typent_code='TTTTTTTTTT'; |
|
85 | - $numExample = $this->getNextValue($mysoc,''); |
|
86 | - $mysoc->code_client=$old_code_client; |
|
87 | - $mysoc->typent_code=$old_code_type; |
|
88 | - |
|
89 | - if (! $numExample) |
|
90 | - { |
|
91 | - $numExample = $langs->trans('NotConfigured'); |
|
92 | - } |
|
93 | - return $numExample; |
|
79 | + global $conf,$langs,$mysoc; |
|
80 | + |
|
81 | + $old_code_client=$mysoc->code_client; |
|
82 | + $old_code_type=$mysoc->typent_code; |
|
83 | + $mysoc->code_client='CCCCCCCCCC'; |
|
84 | + $mysoc->typent_code='TTTTTTTTTT'; |
|
85 | + $numExample = $this->getNextValue($mysoc,''); |
|
86 | + $mysoc->code_client=$old_code_client; |
|
87 | + $mysoc->typent_code=$old_code_type; |
|
88 | + |
|
89 | + if (! $numExample) |
|
90 | + { |
|
91 | + $numExample = $langs->trans('NotConfigured'); |
|
92 | + } |
|
93 | + return $numExample; |
|
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Return next value |
|
98 | - * |
|
99 | - * @param Societe $objsoc Third party object |
|
100 | - * @param Object $reception Reception object |
|
101 | - * @return string Value if OK, 0 if KO |
|
102 | - */ |
|
96 | + /** |
|
97 | + * Return next value |
|
98 | + * |
|
99 | + * @param Societe $objsoc Third party object |
|
100 | + * @param Object $reception Reception object |
|
101 | + * @return string Value if OK, 0 if KO |
|
102 | + */ |
|
103 | 103 | function getNextValue($objsoc,$reception) |
104 | 104 | { |
105 | - global $db,$conf; |
|
106 | - |
|
107 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
108 | - |
|
109 | - $mask=$conf->global->RECEPTION_MOONSTONE_MASK; |
|
110 | - |
|
111 | - if (! $mask) |
|
112 | - { |
|
113 | - $this->error='NotConfigured'; |
|
114 | - return 0; |
|
115 | - } |
|
116 | - |
|
117 | - $date = $reception->date_reception; |
|
118 | - |
|
119 | - $numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date); |
|
120 | - |
|
121 | - return $numFinal; |
|
122 | - } |
|
123 | - |
|
124 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
125 | - /** |
|
126 | - * Return next free value |
|
127 | - * |
|
128 | - * @param Societe $objsoc Third party object |
|
129 | - * @param Object $objforref Reception object |
|
130 | - * @return string Next free value |
|
131 | - */ |
|
132 | - function reception_get_num($objsoc,$objforref) |
|
133 | - { |
|
134 | - // phpcs:enable |
|
135 | - return $this->getNextValue($objsoc,$objforref); |
|
136 | - } |
|
105 | + global $db,$conf; |
|
106 | + |
|
107 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
108 | + |
|
109 | + $mask=$conf->global->RECEPTION_MOONSTONE_MASK; |
|
110 | + |
|
111 | + if (! $mask) |
|
112 | + { |
|
113 | + $this->error='NotConfigured'; |
|
114 | + return 0; |
|
115 | + } |
|
116 | + |
|
117 | + $date = $reception->date_reception; |
|
118 | + |
|
119 | + $numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date); |
|
120 | + |
|
121 | + return $numFinal; |
|
122 | + } |
|
123 | + |
|
124 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
125 | + /** |
|
126 | + * Return next free value |
|
127 | + * |
|
128 | + * @param Societe $objsoc Third party object |
|
129 | + * @param Object $objforref Reception object |
|
130 | + * @return string Next free value |
|
131 | + */ |
|
132 | + function reception_get_num($objsoc,$objforref) |
|
133 | + { |
|
134 | + // phpcs:enable |
|
135 | + return $this->getNextValue($objsoc,$objforref); |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_payment_ant extends ModeleNumRefPayments |
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 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Ant'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Ant'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Ant'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Ant'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -59,39 +59,39 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return string Texte descripif |
61 | 61 | */ |
62 | - function info() |
|
62 | + function info() |
|
63 | 63 | { |
64 | - global $conf, $langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | - $langs->load("bills"); |
|
66 | + $langs->load("bills"); |
|
67 | 67 | |
68 | - $form = new Form($this->db); |
|
68 | + $form = new Form($this->db); |
|
69 | 69 | |
70 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
70 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | - // Parametrage du prefix |
|
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
83 | + // Parametrage du prefix |
|
84 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte.= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte.= '</table>'; |
|
92 | + $texte.= '</form>'; |
|
93 | 93 | |
94 | - return $texte; |
|
94 | + return $texte; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,55 +101,55 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$mysoc; |
|
105 | - |
|
106 | - $old_code_client=$mysoc->code_client; |
|
107 | - $mysoc->code_client='CCCCCCCCCC'; |
|
108 | - $numExample = $this->getNextValue($mysoc,''); |
|
109 | - $mysoc->code_client=$old_code_client; |
|
110 | - |
|
111 | - if (! $numExample) |
|
112 | - { |
|
113 | - $numExample = $langs->trans('NotConfigured'); |
|
114 | - } |
|
115 | - return $numExample; |
|
104 | + global $conf,$langs,$mysoc; |
|
105 | + |
|
106 | + $old_code_client=$mysoc->code_client; |
|
107 | + $mysoc->code_client='CCCCCCCCCC'; |
|
108 | + $numExample = $this->getNextValue($mysoc,''); |
|
109 | + $mysoc->code_client=$old_code_client; |
|
110 | + |
|
111 | + if (! $numExample) |
|
112 | + { |
|
113 | + $numExample = $langs->trans('NotConfigured'); |
|
114 | + } |
|
115 | + return $numExample; |
|
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Return next free value |
|
120 | - * |
|
121 | - * @param Societe $objsoc Object thirdparty |
|
122 | - * @param Object $object Object we need next value for |
|
123 | - * @return string Value if KO, <0 if KO |
|
124 | - */ |
|
118 | + /** |
|
119 | + * Return next free value |
|
120 | + * |
|
121 | + * @param Societe $objsoc Object thirdparty |
|
122 | + * @param Object $object Object we need next value for |
|
123 | + * @return string Value if KO, <0 if KO |
|
124 | + */ |
|
125 | 125 | function getNextValue($objsoc,$object) |
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db,$conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | - // We get cursor rule |
|
132 | - $mask=$conf->global->PAYMENT_ANT_MASK; |
|
131 | + // We get cursor rule |
|
132 | + $mask=$conf->global->PAYMENT_ANT_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
135 | - { |
|
136 | - $this->error='NotConfigured'; |
|
137 | - return 0; |
|
138 | - } |
|
134 | + if (! $mask) |
|
135 | + { |
|
136 | + $this->error='NotConfigured'; |
|
137 | + return 0; |
|
138 | + } |
|
139 | 139 | |
140 | - $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
140 | + $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
141 | 141 | |
142 | - return $numFinal; |
|
143 | - } |
|
142 | + return $numFinal; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | 146 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
147 | - /** |
|
148 | - * Return next free value |
|
149 | - * |
|
150 | - * @param Societe $objsoc Object third party |
|
151 | - * @param string $objforref Object for number to search |
|
152 | - * @return string Next free value |
|
147 | + /** |
|
148 | + * Return next free value |
|
149 | + * |
|
150 | + * @param Societe $objsoc Object third party |
|
151 | + * @param string $objforref Object for number to search |
|
152 | + * @return string Next free value |
|
153 | 153 | */ |
154 | 154 | function commande_get_num($objsoc,$objforref) |
155 | 155 | { |
@@ -29,30 +29,30 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class mod_payment_cicada extends ModeleNumRefPayments |
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='PAY'; |
|
38 | + public $prefix='PAY'; |
|
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 | - /** |
|
46 | - * @var string Nom du modele |
|
47 | - * @deprecated |
|
48 | - * @see name |
|
49 | - */ |
|
50 | - public $nom='Cicada'; |
|
45 | + /** |
|
46 | + * @var string Nom du modele |
|
47 | + * @deprecated |
|
48 | + * @see name |
|
49 | + */ |
|
50 | + public $nom='Cicada'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string model name |
|
54 | - */ |
|
55 | - public $name='Cicada'; |
|
52 | + /** |
|
53 | + * @var string model name |
|
54 | + */ |
|
55 | + public $name='Cicada'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -62,110 +62,110 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function info() |
64 | 64 | { |
65 | - global $langs; |
|
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + global $langs; |
|
66 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Renvoi un exemple de numerotation |
|
72 | - * |
|
73 | - * @return string Example |
|
74 | - */ |
|
75 | - function getExample() |
|
76 | - { |
|
77 | - return $this->prefix."0501-0001"; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | - * |
|
85 | - * @return boolean false si conflit, true si ok |
|
86 | - */ |
|
87 | - function canBeActivated() |
|
88 | - { |
|
89 | - global $conf,$langs,$db; |
|
90 | - |
|
91 | - $payyymm=''; $max=''; |
|
92 | - |
|
93 | - $posindice=9; |
|
94 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
98 | - |
|
99 | - $resql=$db->query($sql); |
|
100 | - if ($resql) |
|
101 | - { |
|
102 | - $row = $db->fetch_row($resql); |
|
103 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | - } |
|
105 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | - { |
|
107 | - $langs->load("errors"); |
|
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Return next free value |
|
117 | - * |
|
118 | - * @param Societe $objsoc Object thirdparty |
|
119 | - * @param Object $object Object we need next value for |
|
120 | - * @return string Value if KO, <0 if KO |
|
121 | - */ |
|
122 | - function getNextValue($objsoc,$object) |
|
123 | - { |
|
124 | - global $db,$conf; |
|
125 | - |
|
126 | - // D'abord on recupere la valeur max |
|
127 | - $posindice=9; |
|
128 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | - |
|
133 | - $resql=$db->query($sql); |
|
134 | - if ($resql) |
|
135 | - { |
|
136 | - $obj = $db->fetch_object($resql); |
|
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
141 | - { |
|
142 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | - return -1; |
|
144 | - } |
|
145 | - |
|
146 | - //$date=time(); |
|
147 | - $date=$object->datepaye; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
149 | - |
|
150 | - 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 |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | - |
|
153 | - dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | - return $this->prefix.$yymm."-".$num; |
|
155 | - } |
|
70 | + /** |
|
71 | + * Renvoi un exemple de numerotation |
|
72 | + * |
|
73 | + * @return string Example |
|
74 | + */ |
|
75 | + function getExample() |
|
76 | + { |
|
77 | + return $this->prefix."0501-0001"; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | + * |
|
85 | + * @return boolean false si conflit, true si ok |
|
86 | + */ |
|
87 | + function canBeActivated() |
|
88 | + { |
|
89 | + global $conf,$langs,$db; |
|
90 | + |
|
91 | + $payyymm=''; $max=''; |
|
92 | + |
|
93 | + $posindice=9; |
|
94 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql.= " AND entity = ".$conf->entity; |
|
98 | + |
|
99 | + $resql=$db->query($sql); |
|
100 | + if ($resql) |
|
101 | + { |
|
102 | + $row = $db->fetch_row($resql); |
|
103 | + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + } |
|
105 | + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | + { |
|
107 | + $langs->load("errors"); |
|
108 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Return next free value |
|
117 | + * |
|
118 | + * @param Societe $objsoc Object thirdparty |
|
119 | + * @param Object $object Object we need next value for |
|
120 | + * @return string Value if KO, <0 if KO |
|
121 | + */ |
|
122 | + function getNextValue($objsoc,$object) |
|
123 | + { |
|
124 | + global $db,$conf; |
|
125 | + |
|
126 | + // D'abord on recupere la valeur max |
|
127 | + $posindice=9; |
|
128 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql.= " AND entity = ".$conf->entity; |
|
132 | + |
|
133 | + $resql=$db->query($sql); |
|
134 | + if ($resql) |
|
135 | + { |
|
136 | + $obj = $db->fetch_object($resql); |
|
137 | + if ($obj) $max = intval($obj->max); |
|
138 | + else $max=0; |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
142 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | + return -1; |
|
144 | + } |
|
145 | + |
|
146 | + //$date=time(); |
|
147 | + $date=$object->datepaye; |
|
148 | + $yymm = strftime("%y%m",$date); |
|
149 | + |
|
150 | + 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 |
|
151 | + else $num = sprintf("%04s",$max+1); |
|
152 | + |
|
153 | + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | + return $this->prefix.$yymm."-".$num; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
159 | - /** |
|
160 | - * Return next free value |
|
161 | - * |
|
162 | - * @param Societe $objsoc Object third party |
|
163 | - * @param string $objforref Object for number to search |
|
164 | - * @return string Next free value |
|
165 | - */ |
|
166 | - function payment_get_num($objsoc,$objforref) |
|
167 | - { |
|
159 | + /** |
|
160 | + * Return next free value |
|
161 | + * |
|
162 | + * @param Societe $objsoc Object third party |
|
163 | + * @param string $objforref Object for number to search |
|
164 | + * @return string Next free value |
|
165 | + */ |
|
166 | + function payment_get_num($objsoc,$objforref) |
|
167 | + { |
|
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
170 | - } |
|
169 | + return $this->getNextValue($objsoc,$objforref); |
|
170 | + } |
|
171 | 171 | } |
@@ -23,82 +23,82 @@ |
||
23 | 23 | |
24 | 24 | abstract class ModeleNumRefPayments |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string Error code (or message) |
|
28 | - */ |
|
29 | - public $error=''; |
|
26 | + /** |
|
27 | + * @var string Error code (or message) |
|
28 | + */ |
|
29 | + public $error=''; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return if a module can be used or not |
|
33 | - * |
|
34 | - * @return boolean true if module can be used |
|
35 | - */ |
|
36 | - function isEnabled() |
|
37 | - { |
|
38 | - return true; |
|
39 | - } |
|
31 | + /** |
|
32 | + * Return if a module can be used or not |
|
33 | + * |
|
34 | + * @return boolean true if module can be used |
|
35 | + */ |
|
36 | + function isEnabled() |
|
37 | + { |
|
38 | + return true; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Return the default description of numbering module |
|
43 | - * |
|
44 | - * @return string Texte descripif |
|
45 | - */ |
|
46 | - function info() |
|
47 | - { |
|
48 | - global $langs; |
|
49 | - $langs->load("bills"); |
|
50 | - return $langs->trans("NoDescription"); |
|
51 | - } |
|
41 | + /** |
|
42 | + * Return the default description of numbering module |
|
43 | + * |
|
44 | + * @return string Texte descripif |
|
45 | + */ |
|
46 | + function info() |
|
47 | + { |
|
48 | + global $langs; |
|
49 | + $langs->load("bills"); |
|
50 | + return $langs->trans("NoDescription"); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Return numbering example |
|
55 | - * |
|
56 | - * @return string Example |
|
57 | - */ |
|
58 | - function getExample() |
|
59 | - { |
|
60 | - global $langs; |
|
61 | - $langs->load("bills"); |
|
62 | - return $langs->trans("NoExample"); |
|
63 | - } |
|
53 | + /** |
|
54 | + * Return numbering example |
|
55 | + * |
|
56 | + * @return string Example |
|
57 | + */ |
|
58 | + function getExample() |
|
59 | + { |
|
60 | + global $langs; |
|
61 | + $langs->load("bills"); |
|
62 | + return $langs->trans("NoExample"); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
67 | - * |
|
68 | - * @return boolean false si conflit, true si ok |
|
69 | - */ |
|
70 | - function canBeActivated() |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
65 | + /** |
|
66 | + * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
67 | + * |
|
68 | + * @return boolean false si conflit, true si ok |
|
69 | + */ |
|
70 | + function canBeActivated() |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Returns the next value |
|
77 | - * |
|
78 | - * @param Societe $objsoc Object thirdparty |
|
79 | - * @param Object $object Object we need next value for |
|
80 | - * @return string Valeur |
|
81 | - */ |
|
82 | - function getNextValue($objsoc,$object) |
|
83 | - { |
|
84 | - global $langs; |
|
85 | - return $langs->trans("NotAvailable"); |
|
86 | - } |
|
75 | + /** |
|
76 | + * Returns the next value |
|
77 | + * |
|
78 | + * @param Societe $objsoc Object thirdparty |
|
79 | + * @param Object $object Object we need next value for |
|
80 | + * @return string Valeur |
|
81 | + */ |
|
82 | + function getNextValue($objsoc,$object) |
|
83 | + { |
|
84 | + global $langs; |
|
85 | + return $langs->trans("NotAvailable"); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Returns the module numbering version |
|
90 | - * |
|
91 | - * @return string Value |
|
92 | - */ |
|
93 | - function getVersion() |
|
94 | - { |
|
95 | - global $langs; |
|
96 | - $langs->load("admin"); |
|
88 | + /** |
|
89 | + * Returns the module numbering version |
|
90 | + * |
|
91 | + * @return string Value |
|
92 | + */ |
|
93 | + function getVersion() |
|
94 | + { |
|
95 | + global $langs; |
|
96 | + $langs->load("admin"); |
|
97 | 97 | |
98 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
99 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
100 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
101 | - if ($this->version) return $this->version; |
|
102 | - return $langs->trans("NotAvailable"); |
|
103 | - } |
|
98 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
99 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
100 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
101 | + if ($this->version) return $this->version; |
|
102 | + return $langs->trans("NotAvailable"); |
|
103 | + } |
|
104 | 104 | } |
@@ -35,131 +35,131 @@ |
||
35 | 35 | class modDon extends DolibarrModules |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
40 | - * |
|
41 | - * @param DoliDB $db Database handler |
|
42 | - */ |
|
43 | - function __construct($db) |
|
44 | - { |
|
45 | - $this->db = $db; |
|
46 | - $this->numero = 700; |
|
47 | - |
|
48 | - $this->family = "financial"; |
|
49 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
50 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | - $this->description = "Gestion des dons"; |
|
52 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
53 | - $this->version = 'dolibarr'; |
|
54 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
55 | - // Name of png file (without png) used for this module. |
|
56 | - // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. |
|
57 | - $this->picto='bill'; |
|
58 | - |
|
59 | - // Data directories to create when module is enabled |
|
60 | - $this->dirs = array("/don/temp"); |
|
61 | - |
|
62 | - // Dependancies |
|
63 | - $this->depends = array(); |
|
64 | - $this->requiredby = array(); |
|
65 | - |
|
66 | - // Config pages |
|
67 | - $this->config_page_url = array("donation.php@don"); |
|
68 | - |
|
69 | - // Constants |
|
70 | - $this->const = array(); |
|
71 | - $r=0; |
|
72 | - |
|
73 | - $this->const[$r][0] = "DON_ADDON_MODEL"; |
|
74 | - $this->const[$r][1] = "chaine"; |
|
75 | - $this->const[$r][2] = "html_cerfafr"; |
|
76 | - $this->const[$r][3] = 'Nom du gestionnaire de generation de recu de dons'; |
|
77 | - $this->const[$r][4] = 0; |
|
78 | - |
|
79 | - $r++; |
|
80 | - $this->const[$r][0] = "DONATION_ART200"; |
|
81 | - $this->const[$r][1] = "yesno"; |
|
82 | - $this->const[$r][2] = "0"; |
|
83 | - $this->const[$r][3] = 'Option Française - Eligibilité Art200 du CGI'; |
|
84 | - $this->const[$r][4] = 0; |
|
85 | - |
|
86 | - $r++; |
|
87 | - $this->const[$r][0] = "DONATION_ART238"; |
|
88 | - $this->const[$r][1] = "yesno"; |
|
89 | - $this->const[$r][2] = "0"; |
|
90 | - $this->const[$r][3] = 'Option Française - Eligibilité Art238 bis du CGI'; |
|
91 | - $this->const[$r][4] = 0; |
|
92 | - |
|
93 | - $r++; |
|
94 | - $this->const[$r][0] = "DONATION_ART885"; |
|
95 | - $this->const[$r][1] = "yesno"; |
|
96 | - $this->const[$r][2] = "0"; |
|
97 | - $this->const[$r][3] = 'Option Française - Eligibilité Art885-0 V bis du CGI'; |
|
98 | - $this->const[$r][4] = 0; |
|
99 | - |
|
100 | - $r++; |
|
101 | - $this->const[$r][0] = "DONATION_MESSAGE"; |
|
102 | - $this->const[$r][1] = "chaine"; |
|
103 | - $this->const[$r][2] = "Thank you"; |
|
104 | - $this->const[$r][3] = 'Message affiché sur le récépissé de versements ou dons'; |
|
105 | - $this->const[$r][4] = 0; |
|
106 | - |
|
107 | - $r++; |
|
108 | - $this->const[$r][0] = "DONATION_ACCOUNTINGACCOUNT"; |
|
109 | - $this->const[$r][1] = "chaine"; |
|
110 | - $this->const[$r][2] = "758"; |
|
111 | - $this->const[$r][3] = 'Compte comptable de remise des versements ou dons'; |
|
112 | - $this->const[$r][4] = 0; |
|
113 | - |
|
114 | - // Boxes |
|
115 | - $this->boxes = array(); |
|
116 | - |
|
117 | - // Permissions |
|
118 | - $this->rights = array(); |
|
119 | - $this->rights_class = 'don'; |
|
120 | - |
|
121 | - $this->rights[1][0] = 701; |
|
122 | - $this->rights[1][1] = 'Lire les dons'; |
|
123 | - $this->rights[1][2] = 'r'; |
|
124 | - $this->rights[1][3] = 1; |
|
125 | - $this->rights[1][4] = 'lire'; |
|
126 | - |
|
127 | - $this->rights[2][0] = 702; |
|
128 | - $this->rights[2][1] = 'Creer/modifier les dons'; |
|
129 | - $this->rights[2][2] = 'w'; |
|
130 | - $this->rights[2][3] = 0; |
|
131 | - $this->rights[2][4] = 'creer'; |
|
132 | - |
|
133 | - $this->rights[3][0] = 703; |
|
134 | - $this->rights[3][1] = 'Supprimer les dons'; |
|
135 | - $this->rights[3][2] = 'd'; |
|
136 | - $this->rights[3][3] = 0; |
|
137 | - $this->rights[3][4] = 'supprimer'; |
|
138 | - |
|
139 | - |
|
140 | - // Menus |
|
141 | - //------- |
|
142 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Function called when module is enabled. |
|
148 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
149 | - * It also creates data directories |
|
150 | - * |
|
38 | + /** |
|
39 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
40 | + * |
|
41 | + * @param DoliDB $db Database handler |
|
42 | + */ |
|
43 | + function __construct($db) |
|
44 | + { |
|
45 | + $this->db = $db; |
|
46 | + $this->numero = 700; |
|
47 | + |
|
48 | + $this->family = "financial"; |
|
49 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
50 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | + $this->description = "Gestion des dons"; |
|
52 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
53 | + $this->version = 'dolibarr'; |
|
54 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
55 | + // Name of png file (without png) used for this module. |
|
56 | + // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. |
|
57 | + $this->picto='bill'; |
|
58 | + |
|
59 | + // Data directories to create when module is enabled |
|
60 | + $this->dirs = array("/don/temp"); |
|
61 | + |
|
62 | + // Dependancies |
|
63 | + $this->depends = array(); |
|
64 | + $this->requiredby = array(); |
|
65 | + |
|
66 | + // Config pages |
|
67 | + $this->config_page_url = array("donation.php@don"); |
|
68 | + |
|
69 | + // Constants |
|
70 | + $this->const = array(); |
|
71 | + $r=0; |
|
72 | + |
|
73 | + $this->const[$r][0] = "DON_ADDON_MODEL"; |
|
74 | + $this->const[$r][1] = "chaine"; |
|
75 | + $this->const[$r][2] = "html_cerfafr"; |
|
76 | + $this->const[$r][3] = 'Nom du gestionnaire de generation de recu de dons'; |
|
77 | + $this->const[$r][4] = 0; |
|
78 | + |
|
79 | + $r++; |
|
80 | + $this->const[$r][0] = "DONATION_ART200"; |
|
81 | + $this->const[$r][1] = "yesno"; |
|
82 | + $this->const[$r][2] = "0"; |
|
83 | + $this->const[$r][3] = 'Option Française - Eligibilité Art200 du CGI'; |
|
84 | + $this->const[$r][4] = 0; |
|
85 | + |
|
86 | + $r++; |
|
87 | + $this->const[$r][0] = "DONATION_ART238"; |
|
88 | + $this->const[$r][1] = "yesno"; |
|
89 | + $this->const[$r][2] = "0"; |
|
90 | + $this->const[$r][3] = 'Option Française - Eligibilité Art238 bis du CGI'; |
|
91 | + $this->const[$r][4] = 0; |
|
92 | + |
|
93 | + $r++; |
|
94 | + $this->const[$r][0] = "DONATION_ART885"; |
|
95 | + $this->const[$r][1] = "yesno"; |
|
96 | + $this->const[$r][2] = "0"; |
|
97 | + $this->const[$r][3] = 'Option Française - Eligibilité Art885-0 V bis du CGI'; |
|
98 | + $this->const[$r][4] = 0; |
|
99 | + |
|
100 | + $r++; |
|
101 | + $this->const[$r][0] = "DONATION_MESSAGE"; |
|
102 | + $this->const[$r][1] = "chaine"; |
|
103 | + $this->const[$r][2] = "Thank you"; |
|
104 | + $this->const[$r][3] = 'Message affiché sur le récépissé de versements ou dons'; |
|
105 | + $this->const[$r][4] = 0; |
|
106 | + |
|
107 | + $r++; |
|
108 | + $this->const[$r][0] = "DONATION_ACCOUNTINGACCOUNT"; |
|
109 | + $this->const[$r][1] = "chaine"; |
|
110 | + $this->const[$r][2] = "758"; |
|
111 | + $this->const[$r][3] = 'Compte comptable de remise des versements ou dons'; |
|
112 | + $this->const[$r][4] = 0; |
|
113 | + |
|
114 | + // Boxes |
|
115 | + $this->boxes = array(); |
|
116 | + |
|
117 | + // Permissions |
|
118 | + $this->rights = array(); |
|
119 | + $this->rights_class = 'don'; |
|
120 | + |
|
121 | + $this->rights[1][0] = 701; |
|
122 | + $this->rights[1][1] = 'Lire les dons'; |
|
123 | + $this->rights[1][2] = 'r'; |
|
124 | + $this->rights[1][3] = 1; |
|
125 | + $this->rights[1][4] = 'lire'; |
|
126 | + |
|
127 | + $this->rights[2][0] = 702; |
|
128 | + $this->rights[2][1] = 'Creer/modifier les dons'; |
|
129 | + $this->rights[2][2] = 'w'; |
|
130 | + $this->rights[2][3] = 0; |
|
131 | + $this->rights[2][4] = 'creer'; |
|
132 | + |
|
133 | + $this->rights[3][0] = 703; |
|
134 | + $this->rights[3][1] = 'Supprimer les dons'; |
|
135 | + $this->rights[3][2] = 'd'; |
|
136 | + $this->rights[3][3] = 0; |
|
137 | + $this->rights[3][4] = 'supprimer'; |
|
138 | + |
|
139 | + |
|
140 | + // Menus |
|
141 | + //------- |
|
142 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Function called when module is enabled. |
|
148 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
149 | + * It also creates data directories |
|
150 | + * |
|
151 | 151 | * @param string $options Options when enabling module ('', 'noboxes') |
152 | - * @return int 1 if OK, 0 if KO |
|
153 | - */ |
|
154 | - function init($options='') |
|
155 | - { |
|
156 | - global $conf; |
|
157 | - |
|
158 | - $sql = array( |
|
159 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".$conf->entity, |
|
160 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".$conf->entity.")", |
|
161 | - ); |
|
162 | - |
|
163 | - return $this->_init($sql,$options); |
|
164 | - } |
|
152 | + * @return int 1 if OK, 0 if KO |
|
153 | + */ |
|
154 | + function init($options='') |
|
155 | + { |
|
156 | + global $conf; |
|
157 | + |
|
158 | + $sql = array( |
|
159 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".$conf->entity, |
|
160 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".$conf->entity.")", |
|
161 | + ); |
|
162 | + |
|
163 | + return $this->_init($sql,$options); |
|
164 | + } |
|
165 | 165 | } |
166 | 166 | \ No newline at end of file |