@@ -40,125 +40,125 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class pdf_strato extends ModelePDFContract |
42 | 42 | { |
43 | - /** |
|
43 | + /** |
|
44 | 44 | * @var DoliDb Database handler |
45 | 45 | */ |
46 | 46 | public $db; |
47 | 47 | |
48 | - /** |
|
48 | + /** |
|
49 | 49 | * @var string model name |
50 | 50 | */ |
51 | 51 | public $name; |
52 | 52 | |
53 | - /** |
|
53 | + /** |
|
54 | 54 | * @var string model description (short text) |
55 | 55 | */ |
56 | 56 | public $description; |
57 | 57 | |
58 | - /** |
|
58 | + /** |
|
59 | 59 | * @var string document type |
60 | 60 | */ |
61 | 61 | public $type; |
62 | 62 | |
63 | - /** |
|
63 | + /** |
|
64 | 64 | * @var array() Minimum version of PHP required by module. |
65 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
65 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
66 | 66 | */ |
67 | - public $phpmin = array(5, 4); |
|
67 | + public $phpmin = array(5, 4); |
|
68 | 68 | |
69 | - /** |
|
69 | + /** |
|
70 | 70 | * Dolibarr version of the loaded document |
71 | 71 | * @public string |
72 | 72 | */ |
73 | - public $version = 'dolibarr'; |
|
73 | + public $version = 'dolibarr'; |
|
74 | 74 | |
75 | - /** |
|
75 | + /** |
|
76 | 76 | * @var int page_largeur |
77 | 77 | */ |
78 | 78 | public $page_largeur; |
79 | 79 | |
80 | - /** |
|
80 | + /** |
|
81 | 81 | * @var int page_hauteur |
82 | 82 | */ |
83 | 83 | public $page_hauteur; |
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * @var array format |
87 | 87 | */ |
88 | 88 | public $format; |
89 | 89 | |
90 | - /** |
|
90 | + /** |
|
91 | 91 | * @var int marge_gauche |
92 | 92 | */ |
93 | - public $marge_gauche; |
|
93 | + public $marge_gauche; |
|
94 | 94 | |
95 | - /** |
|
95 | + /** |
|
96 | 96 | * @var int marge_droite |
97 | 97 | */ |
98 | - public $marge_droite; |
|
98 | + public $marge_droite; |
|
99 | 99 | |
100 | - /** |
|
100 | + /** |
|
101 | 101 | * @var int marge_haute |
102 | 102 | */ |
103 | - public $marge_haute; |
|
103 | + public $marge_haute; |
|
104 | 104 | |
105 | - /** |
|
105 | + /** |
|
106 | 106 | * @var int marge_basse |
107 | 107 | */ |
108 | - public $marge_basse; |
|
109 | - |
|
110 | - /** |
|
111 | - * Issuer |
|
112 | - * @var Societe |
|
113 | - */ |
|
114 | - public $emetteur; |
|
115 | - |
|
116 | - /** |
|
117 | - * Recipient |
|
118 | - * @var Societe |
|
119 | - */ |
|
120 | - public $recipient; |
|
121 | - |
|
122 | - /** |
|
123 | - * Constructor |
|
124 | - * |
|
125 | - * @param DoliDB $db Database handler |
|
126 | - */ |
|
127 | - function __construct($db) |
|
128 | - { |
|
129 | - global $conf,$langs,$mysoc; |
|
130 | - |
|
131 | - $this->db = $db; |
|
132 | - $this->name = 'strato'; |
|
133 | - $this->description = $langs->trans("StandardContractsTemplate"); |
|
134 | - |
|
135 | - // Dimension page pour format A4 |
|
136 | - $this->type = 'pdf'; |
|
137 | - $formatarray=pdf_getFormat(); |
|
138 | - |
|
139 | - $this->page_largeur = $formatarray['width']; |
|
140 | - $this->page_hauteur = $formatarray['height']; |
|
141 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
142 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
143 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
144 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
145 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
146 | - |
|
147 | - $this->option_logo = 1; // Affiche logo |
|
148 | - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION |
|
149 | - $this->option_modereg = 0; // Affiche mode reglement |
|
150 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
151 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
152 | - $this->option_multilang = 0; // Dispo en plusieurs langues |
|
153 | - $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
154 | - |
|
155 | - // Get source company |
|
156 | - $this->emetteur=$mysoc; |
|
157 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined |
|
158 | - |
|
159 | - // Define position of columns |
|
160 | - $this->posxdesc=$this->marge_gauche+1; |
|
161 | - } |
|
108 | + public $marge_basse; |
|
109 | + |
|
110 | + /** |
|
111 | + * Issuer |
|
112 | + * @var Societe |
|
113 | + */ |
|
114 | + public $emetteur; |
|
115 | + |
|
116 | + /** |
|
117 | + * Recipient |
|
118 | + * @var Societe |
|
119 | + */ |
|
120 | + public $recipient; |
|
121 | + |
|
122 | + /** |
|
123 | + * Constructor |
|
124 | + * |
|
125 | + * @param DoliDB $db Database handler |
|
126 | + */ |
|
127 | + function __construct($db) |
|
128 | + { |
|
129 | + global $conf,$langs,$mysoc; |
|
130 | + |
|
131 | + $this->db = $db; |
|
132 | + $this->name = 'strato'; |
|
133 | + $this->description = $langs->trans("StandardContractsTemplate"); |
|
134 | + |
|
135 | + // Dimension page pour format A4 |
|
136 | + $this->type = 'pdf'; |
|
137 | + $formatarray=pdf_getFormat(); |
|
138 | + |
|
139 | + $this->page_largeur = $formatarray['width']; |
|
140 | + $this->page_hauteur = $formatarray['height']; |
|
141 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
142 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
143 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
144 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
145 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
146 | + |
|
147 | + $this->option_logo = 1; // Affiche logo |
|
148 | + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION |
|
149 | + $this->option_modereg = 0; // Affiche mode reglement |
|
150 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
151 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
152 | + $this->option_multilang = 0; // Dispo en plusieurs langues |
|
153 | + $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
154 | + |
|
155 | + // Get source company |
|
156 | + $this->emetteur=$mysoc; |
|
157 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined |
|
158 | + |
|
159 | + // Define position of columns |
|
160 | + $this->posxdesc=$this->marge_gauche+1; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
164 | 164 | /** |
@@ -171,64 +171,64 @@ discard block |
||
171 | 171 | * @param int $hidedesc Do not show desc |
172 | 172 | * @param int $hideref Do not show ref |
173 | 173 | * @return int 1=OK, 0=KO |
174 | - */ |
|
175 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
176 | - { |
|
174 | + */ |
|
175 | + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
176 | + { |
|
177 | 177 | // phpcs:enable |
178 | - global $user,$langs,$conf,$hookmanager,$mysoc; |
|
178 | + global $user,$langs,$conf,$hookmanager,$mysoc; |
|
179 | 179 | |
180 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
181 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
182 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
180 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
181 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
182 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
183 | 183 | |
184 | - // Load traductions files requiredby by page |
|
185 | - $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); |
|
184 | + // Load traductions files requiredby by page |
|
185 | + $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); |
|
186 | 186 | |
187 | - if ($conf->contrat->dir_output) |
|
188 | - { |
|
187 | + if ($conf->contrat->dir_output) |
|
188 | + { |
|
189 | 189 | $object->fetch_thirdparty(); |
190 | 190 | |
191 | - // Definition of $dir and $file |
|
192 | - if ($object->specimen) |
|
193 | - { |
|
194 | - $dir = $conf->contrat->dir_output; |
|
195 | - $file = $dir . "/SPECIMEN.pdf"; |
|
196 | - } |
|
197 | - else |
|
198 | - { |
|
199 | - $objectref = dol_sanitizeFileName($object->ref); |
|
200 | - $dir = $conf->contrat->dir_output . "/" . $objectref; |
|
201 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
202 | - } |
|
203 | - |
|
204 | - if (! file_exists($dir)) |
|
205 | - { |
|
206 | - if (dol_mkdir($dir) < 0) |
|
207 | - { |
|
208 | - $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir); |
|
209 | - return 0; |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - if (file_exists($dir)) |
|
214 | - { |
|
215 | - // Add pdfgeneration hook |
|
216 | - if (! is_object($hookmanager)) |
|
217 | - { |
|
218 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
219 | - $hookmanager=new HookManager($this->db); |
|
220 | - } |
|
221 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
222 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
223 | - global $action; |
|
224 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
191 | + // Definition of $dir and $file |
|
192 | + if ($object->specimen) |
|
193 | + { |
|
194 | + $dir = $conf->contrat->dir_output; |
|
195 | + $file = $dir . "/SPECIMEN.pdf"; |
|
196 | + } |
|
197 | + else |
|
198 | + { |
|
199 | + $objectref = dol_sanitizeFileName($object->ref); |
|
200 | + $dir = $conf->contrat->dir_output . "/" . $objectref; |
|
201 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
202 | + } |
|
203 | + |
|
204 | + if (! file_exists($dir)) |
|
205 | + { |
|
206 | + if (dol_mkdir($dir) < 0) |
|
207 | + { |
|
208 | + $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir); |
|
209 | + return 0; |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + if (file_exists($dir)) |
|
214 | + { |
|
215 | + // Add pdfgeneration hook |
|
216 | + if (! is_object($hookmanager)) |
|
217 | + { |
|
218 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
219 | + $hookmanager=new HookManager($this->db); |
|
220 | + } |
|
221 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
222 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
223 | + global $action; |
|
224 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
225 | 225 | |
226 | 226 | $pdf=pdf_getInstance($this->format); |
227 | 227 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
228 | 228 | $heightforinfotot = 50; // Height reserved to output the info and total part |
229 | - $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 |
|
230 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
231 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
229 | + $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 |
|
230 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
231 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
232 | 232 | $pdf->SetAutoPageBreak(1,0); |
233 | 233 | |
234 | 234 | if (class_exists('TCPDF')) |
@@ -244,279 +244,279 @@ discard block |
||
244 | 244 | $tplidx = $pdf->importPage(1); |
245 | 245 | } |
246 | 246 | |
247 | - $pdf->Open(); |
|
248 | - $pagenb=0; |
|
249 | - $pdf->SetDrawColor(128,128,128); |
|
250 | - |
|
251 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
252 | - $pdf->SetSubject($outputlangs->transnoentities("ContractCard")); |
|
253 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
254 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
255 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
256 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
257 | - |
|
258 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
259 | - |
|
260 | - // New page |
|
261 | - $pdf->AddPage(); |
|
262 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
263 | - $pagenb++; |
|
264 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
265 | - $pdf->SetFont('','', $default_font_size - 1); |
|
266 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
267 | - $pdf->SetTextColor(0,0,0); |
|
268 | - |
|
269 | - $tab_top = 90; |
|
270 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
271 | - |
|
272 | - // Affiche notes |
|
273 | - if (! empty($object->note_public)) |
|
274 | - { |
|
275 | - $tab_top -= 2; |
|
276 | - |
|
277 | - $pdf->SetFont('','', $default_font_size - 1); |
|
278 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
279 | - $nexY = $pdf->GetY(); |
|
280 | - $height_note=$nexY-$tab_top; |
|
281 | - |
|
282 | - // Rect prend une longueur en 3eme param |
|
283 | - $pdf->SetDrawColor(192,192,192); |
|
284 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
285 | - |
|
286 | - $tab_top = $nexY+6; |
|
287 | - } |
|
288 | - |
|
289 | - $iniY = $tab_top + 7; |
|
290 | - $curY = $tab_top + 7; |
|
291 | - $nexY = $tab_top + 2; |
|
292 | - |
|
293 | - $pdf->SetXY($this->marge_gauche, $tab_top); |
|
294 | - |
|
295 | - $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
|
296 | - |
|
297 | - $nblines = count($object->lines); |
|
298 | - |
|
299 | - // Loop on each lines |
|
300 | - for ($i = 0; $i < $nblines; $i++) |
|
301 | - { |
|
302 | - $objectligne = $object->lines[$i]; |
|
303 | - |
|
304 | - $valide = $objectligne->id ? 1 : 0; |
|
305 | - |
|
306 | - if ($valide > 0 || $object->specimen) |
|
307 | - { |
|
308 | - $curX = $this->posxdesc-1; |
|
309 | - $curY = $nexY; |
|
310 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
311 | - $pdf->SetTextColor(0,0,0); |
|
312 | - |
|
313 | - $pdf->setTopMargin($tab_top_newpage); |
|
314 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
315 | - $pageposbefore=$pdf->getPage(); |
|
316 | - |
|
317 | - // Description of product line |
|
318 | - |
|
319 | - if ($objectligne->date_ouverture_prevue) { |
|
320 | - $datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true); |
|
321 | - } else { |
|
322 | - $datei = $langs->trans("Unknown"); |
|
323 | - } |
|
324 | - |
|
325 | - if ($objectligne->date_fin_validite) { |
|
326 | - $durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour'); |
|
327 | - $datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true); |
|
328 | - } else { |
|
329 | - $durationi = $langs->trans("Unknown"); |
|
330 | - $datee = $langs->trans("Unknown"); |
|
331 | - } |
|
332 | - |
|
333 | - if ($objectligne->date_ouverture) { |
|
334 | - $daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true); |
|
335 | - } else { |
|
336 | - $daters = $langs->trans("Unknown"); |
|
337 | - } |
|
338 | - |
|
339 | - if ($objectligne->date_cloture) { |
|
340 | - $datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true); |
|
341 | - } else { |
|
342 | - $datere = $langs->trans("Unknown"); |
|
343 | - } |
|
344 | - |
|
345 | - $txtpredefinedservice=''; |
|
247 | + $pdf->Open(); |
|
248 | + $pagenb=0; |
|
249 | + $pdf->SetDrawColor(128,128,128); |
|
250 | + |
|
251 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
252 | + $pdf->SetSubject($outputlangs->transnoentities("ContractCard")); |
|
253 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
254 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
255 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
256 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
257 | + |
|
258 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
259 | + |
|
260 | + // New page |
|
261 | + $pdf->AddPage(); |
|
262 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
263 | + $pagenb++; |
|
264 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
265 | + $pdf->SetFont('','', $default_font_size - 1); |
|
266 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
267 | + $pdf->SetTextColor(0,0,0); |
|
268 | + |
|
269 | + $tab_top = 90; |
|
270 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
271 | + |
|
272 | + // Affiche notes |
|
273 | + if (! empty($object->note_public)) |
|
274 | + { |
|
275 | + $tab_top -= 2; |
|
276 | + |
|
277 | + $pdf->SetFont('','', $default_font_size - 1); |
|
278 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
279 | + $nexY = $pdf->GetY(); |
|
280 | + $height_note=$nexY-$tab_top; |
|
281 | + |
|
282 | + // Rect prend une longueur en 3eme param |
|
283 | + $pdf->SetDrawColor(192,192,192); |
|
284 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
285 | + |
|
286 | + $tab_top = $nexY+6; |
|
287 | + } |
|
288 | + |
|
289 | + $iniY = $tab_top + 7; |
|
290 | + $curY = $tab_top + 7; |
|
291 | + $nexY = $tab_top + 2; |
|
292 | + |
|
293 | + $pdf->SetXY($this->marge_gauche, $tab_top); |
|
294 | + |
|
295 | + $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
|
296 | + |
|
297 | + $nblines = count($object->lines); |
|
298 | + |
|
299 | + // Loop on each lines |
|
300 | + for ($i = 0; $i < $nblines; $i++) |
|
301 | + { |
|
302 | + $objectligne = $object->lines[$i]; |
|
303 | + |
|
304 | + $valide = $objectligne->id ? 1 : 0; |
|
305 | + |
|
306 | + if ($valide > 0 || $object->specimen) |
|
307 | + { |
|
308 | + $curX = $this->posxdesc-1; |
|
309 | + $curY = $nexY; |
|
310 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
311 | + $pdf->SetTextColor(0,0,0); |
|
312 | + |
|
313 | + $pdf->setTopMargin($tab_top_newpage); |
|
314 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
315 | + $pageposbefore=$pdf->getPage(); |
|
316 | + |
|
317 | + // Description of product line |
|
318 | + |
|
319 | + if ($objectligne->date_ouverture_prevue) { |
|
320 | + $datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true); |
|
321 | + } else { |
|
322 | + $datei = $langs->trans("Unknown"); |
|
323 | + } |
|
324 | + |
|
325 | + if ($objectligne->date_fin_validite) { |
|
326 | + $durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour'); |
|
327 | + $datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true); |
|
328 | + } else { |
|
329 | + $durationi = $langs->trans("Unknown"); |
|
330 | + $datee = $langs->trans("Unknown"); |
|
331 | + } |
|
332 | + |
|
333 | + if ($objectligne->date_ouverture) { |
|
334 | + $daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true); |
|
335 | + } else { |
|
336 | + $daters = $langs->trans("Unknown"); |
|
337 | + } |
|
338 | + |
|
339 | + if ($objectligne->date_cloture) { |
|
340 | + $datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true); |
|
341 | + } else { |
|
342 | + $datere = $langs->trans("Unknown"); |
|
343 | + } |
|
344 | + |
|
345 | + $txtpredefinedservice=''; |
|
346 | 346 | $txtpredefinedservice = $objectligne->product_label; |
347 | 347 | if ($objectligne->product_label) |
348 | 348 | { |
349 | - $txtpredefinedservice .= ' - '; |
|
350 | - $txtpredefinedservice .= $objectligne->product_label; |
|
349 | + $txtpredefinedservice .= ' - '; |
|
350 | + $txtpredefinedservice .= $objectligne->product_label; |
|
351 | 351 | } |
352 | 352 | |
353 | - $desc=dol_htmlentitiesbr($objectligne->desc,1); // Desc (not empty for free lines) |
|
354 | - $txt=''; |
|
355 | - $txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines) |
|
356 | - $txt.='<br>'; |
|
357 | - $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>'; |
|
358 | - $txt.='<br>'; |
|
353 | + $desc=dol_htmlentitiesbr($objectligne->desc,1); // Desc (not empty for free lines) |
|
354 | + $txt=''; |
|
355 | + $txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines) |
|
356 | + $txt.='<br>'; |
|
357 | + $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>'; |
|
358 | + $txt.='<br>'; |
|
359 | 359 | $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>'; |
360 | - if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
361 | - |
|
362 | - $pdf->startTransaction(); |
|
363 | - $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
|
364 | - $pageposafter=$pdf->getPage(); |
|
365 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
366 | - { |
|
367 | - $pdf->rollbackTransaction(true); |
|
368 | - $pageposafter=$pageposbefore; |
|
369 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
370 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
371 | - $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
|
372 | - $pageposafter=$pdf->getPage(); |
|
373 | - $posyafter=$pdf->GetY(); |
|
374 | - |
|
375 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
376 | - { |
|
377 | - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page |
|
378 | - { |
|
379 | - $pdf->AddPage('','',true); |
|
380 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
381 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
382 | - $pdf->setPage($pageposafter+1); |
|
383 | - } |
|
384 | - } |
|
385 | - else |
|
386 | - { |
|
387 | - // We found a page break |
|
388 | - $showpricebeforepagebreak=0; |
|
389 | - } |
|
390 | - } |
|
391 | - else // No pagebreak |
|
392 | - { |
|
393 | - $pdf->commitTransaction(); |
|
394 | - } |
|
395 | - |
|
396 | - $nexY = $pdf->GetY() + 2; |
|
397 | - $pageposafter=$pdf->getPage(); |
|
398 | - |
|
399 | - $pdf->setPage($pageposbefore); |
|
400 | - $pdf->setTopMargin($this->marge_haute); |
|
401 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
402 | - |
|
403 | - // We suppose that a too long description is moved completely on next page |
|
404 | - if ($pageposafter > $pageposbefore) { |
|
405 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
406 | - } |
|
407 | - |
|
408 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
409 | - |
|
410 | - // Detect if some page were added automatically and output _tableau for past pages |
|
411 | - while ($pagenb < $pageposafter) |
|
412 | - { |
|
413 | - $pdf->setPage($pagenb); |
|
414 | - if ($pagenb == 1) |
|
415 | - { |
|
416 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
|
417 | - } |
|
418 | - else |
|
419 | - { |
|
420 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
|
421 | - } |
|
422 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
423 | - $pagenb++; |
|
424 | - $pdf->setPage($pagenb); |
|
425 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
426 | - } |
|
427 | - |
|
428 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
429 | - { |
|
430 | - if ($pagenb == 1) |
|
431 | - { |
|
432 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
|
433 | - } |
|
434 | - else |
|
435 | - { |
|
436 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
|
437 | - } |
|
438 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
439 | - // New page |
|
440 | - $pdf->AddPage(); |
|
441 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
442 | - $pagenb++; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - // Show square |
|
448 | - if ($pagenb == 1) |
|
449 | - { |
|
450 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
451 | - $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
|
452 | - $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
453 | - } |
|
454 | - else |
|
455 | - { |
|
456 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
457 | - $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
|
458 | - $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
459 | - } |
|
460 | - |
|
461 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
462 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
463 | - |
|
464 | - $pdf->Close(); |
|
465 | - |
|
466 | - $pdf->Output($file,'F'); |
|
467 | - |
|
468 | - // Add pdfgeneration hook |
|
469 | - if (! is_object($hookmanager)) |
|
470 | - { |
|
471 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
472 | - $hookmanager=new HookManager($this->db); |
|
473 | - } |
|
474 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
475 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
476 | - global $action; |
|
477 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
478 | - |
|
479 | - if (! empty($conf->global->MAIN_UMASK)) |
|
480 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
481 | - |
|
482 | - $this->result = array('fullpath'=>$file); |
|
483 | - |
|
484 | - return 1; |
|
485 | - } |
|
486 | - else |
|
487 | - { |
|
488 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
489 | - return 0; |
|
490 | - } |
|
491 | - } |
|
492 | - else |
|
493 | - { |
|
494 | - $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR"); |
|
495 | - return 0; |
|
496 | - } |
|
497 | - } |
|
498 | - |
|
499 | - /** |
|
500 | - * Show table for lines |
|
501 | - * |
|
502 | - * @param PDF $pdf Object PDF |
|
503 | - * @param string $tab_top Top position of table |
|
504 | - * @param string $tab_height Height of table (rectangle) |
|
505 | - * @param int $nexY Y |
|
506 | - * @param Translate $outputlangs Langs object |
|
507 | - * @param int $hidetop Hide top bar of array |
|
508 | - * @param int $hidebottom Hide bottom bar of array |
|
509 | - * @return void |
|
510 | - */ |
|
511 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
512 | - { |
|
513 | - global $conf; |
|
514 | - |
|
515 | - // Force to disable hidetop and hidebottom |
|
516 | - $hidebottom=0; |
|
517 | - if ($hidetop) $hidetop=-1; |
|
518 | - |
|
519 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
360 | + if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
361 | + |
|
362 | + $pdf->startTransaction(); |
|
363 | + $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
|
364 | + $pageposafter=$pdf->getPage(); |
|
365 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
366 | + { |
|
367 | + $pdf->rollbackTransaction(true); |
|
368 | + $pageposafter=$pageposbefore; |
|
369 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
370 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
371 | + $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
|
372 | + $pageposafter=$pdf->getPage(); |
|
373 | + $posyafter=$pdf->GetY(); |
|
374 | + |
|
375 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
376 | + { |
|
377 | + if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page |
|
378 | + { |
|
379 | + $pdf->AddPage('','',true); |
|
380 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
381 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
382 | + $pdf->setPage($pageposafter+1); |
|
383 | + } |
|
384 | + } |
|
385 | + else |
|
386 | + { |
|
387 | + // We found a page break |
|
388 | + $showpricebeforepagebreak=0; |
|
389 | + } |
|
390 | + } |
|
391 | + else // No pagebreak |
|
392 | + { |
|
393 | + $pdf->commitTransaction(); |
|
394 | + } |
|
395 | + |
|
396 | + $nexY = $pdf->GetY() + 2; |
|
397 | + $pageposafter=$pdf->getPage(); |
|
398 | + |
|
399 | + $pdf->setPage($pageposbefore); |
|
400 | + $pdf->setTopMargin($this->marge_haute); |
|
401 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
402 | + |
|
403 | + // We suppose that a too long description is moved completely on next page |
|
404 | + if ($pageposafter > $pageposbefore) { |
|
405 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
406 | + } |
|
407 | + |
|
408 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
409 | + |
|
410 | + // Detect if some page were added automatically and output _tableau for past pages |
|
411 | + while ($pagenb < $pageposafter) |
|
412 | + { |
|
413 | + $pdf->setPage($pagenb); |
|
414 | + if ($pagenb == 1) |
|
415 | + { |
|
416 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
|
417 | + } |
|
418 | + else |
|
419 | + { |
|
420 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
|
421 | + } |
|
422 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
423 | + $pagenb++; |
|
424 | + $pdf->setPage($pagenb); |
|
425 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
426 | + } |
|
427 | + |
|
428 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
429 | + { |
|
430 | + if ($pagenb == 1) |
|
431 | + { |
|
432 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
436 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
|
437 | + } |
|
438 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
439 | + // New page |
|
440 | + $pdf->AddPage(); |
|
441 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
442 | + $pagenb++; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + // Show square |
|
448 | + if ($pagenb == 1) |
|
449 | + { |
|
450 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
451 | + $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
|
452 | + $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
453 | + } |
|
454 | + else |
|
455 | + { |
|
456 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
457 | + $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
|
458 | + $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
459 | + } |
|
460 | + |
|
461 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
462 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
463 | + |
|
464 | + $pdf->Close(); |
|
465 | + |
|
466 | + $pdf->Output($file,'F'); |
|
467 | + |
|
468 | + // Add pdfgeneration hook |
|
469 | + if (! is_object($hookmanager)) |
|
470 | + { |
|
471 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
472 | + $hookmanager=new HookManager($this->db); |
|
473 | + } |
|
474 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
475 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
476 | + global $action; |
|
477 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
478 | + |
|
479 | + if (! empty($conf->global->MAIN_UMASK)) |
|
480 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
481 | + |
|
482 | + $this->result = array('fullpath'=>$file); |
|
483 | + |
|
484 | + return 1; |
|
485 | + } |
|
486 | + else |
|
487 | + { |
|
488 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
489 | + return 0; |
|
490 | + } |
|
491 | + } |
|
492 | + else |
|
493 | + { |
|
494 | + $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR"); |
|
495 | + return 0; |
|
496 | + } |
|
497 | + } |
|
498 | + |
|
499 | + /** |
|
500 | + * Show table for lines |
|
501 | + * |
|
502 | + * @param PDF $pdf Object PDF |
|
503 | + * @param string $tab_top Top position of table |
|
504 | + * @param string $tab_height Height of table (rectangle) |
|
505 | + * @param int $nexY Y |
|
506 | + * @param Translate $outputlangs Langs object |
|
507 | + * @param int $hidetop Hide top bar of array |
|
508 | + * @param int $hidebottom Hide bottom bar of array |
|
509 | + * @return void |
|
510 | + */ |
|
511 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
512 | + { |
|
513 | + global $conf; |
|
514 | + |
|
515 | + // Force to disable hidetop and hidebottom |
|
516 | + $hidebottom=0; |
|
517 | + if ($hidetop) $hidetop=-1; |
|
518 | + |
|
519 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
520 | 520 | /* |
521 | 521 | $pdf->SetXY($this->marge_gauche, $tab_top); |
522 | 522 | $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
544 | 544 | */ |
545 | 545 | |
546 | - // Output Rect |
|
547 | - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param |
|
548 | - } |
|
546 | + // Output Rect |
|
547 | + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param |
|
548 | + } |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Show footer signature of page |
@@ -555,217 +555,217 @@ discard block |
||
555 | 555 | * @param Translate $outputlangs Object language for output |
556 | 556 | * @return void |
557 | 557 | */ |
558 | - private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) |
|
558 | + private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) |
|
559 | 559 | { |
560 | - $pdf->SetDrawColor(128,128,128); |
|
561 | - $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); |
|
562 | - $posy = $tab_top + $tab_height + 3 + 3; |
|
563 | - |
|
564 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
565 | - $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); |
|
560 | + $pdf->SetDrawColor(128,128,128); |
|
561 | + $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); |
|
562 | + $posy = $tab_top + $tab_height + 3 + 3; |
|
566 | 563 | |
567 | - $pdf->SetXY($this->marge_gauche, $posy + 5); |
|
568 | - $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); |
|
564 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
565 | + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); |
|
569 | 566 | |
570 | - $pdf->SetXY($posmiddle + 5, $posy); |
|
571 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); |
|
567 | + $pdf->SetXY($this->marge_gauche, $posy + 5); |
|
568 | + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); |
|
572 | 569 | |
573 | - $pdf->SetXY($posmiddle + 5, $posy + 5); |
|
574 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); |
|
575 | - } |
|
570 | + $pdf->SetXY($posmiddle + 5, $posy); |
|
571 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); |
|
576 | 572 | |
577 | - /** |
|
578 | - * Show top header of page. |
|
579 | - * |
|
580 | - * @param PDF $pdf Object PDF |
|
581 | - * @param CommonObject $object Object to show |
|
582 | - * @param int $showaddress 0=no, 1=yes |
|
583 | - * @param Translate $outputlangs Object lang for output |
|
584 | - * @return void |
|
585 | - */ |
|
586 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
587 | - { |
|
588 | - global $conf,$langs; |
|
573 | + $pdf->SetXY($posmiddle + 5, $posy + 5); |
|
574 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); |
|
575 | + } |
|
589 | 576 | |
590 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
591 | - |
|
592 | - // Load traductions files requiredby by page |
|
593 | - $outputlangs->loadLangs(array("main", "dict", "contract", "companies")); |
|
594 | - |
|
595 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
596 | - |
|
597 | - //Affiche le filigrane brouillon - Print Draft Watermark |
|
598 | - if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) ) |
|
599 | - { |
|
600 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK); |
|
601 | - } |
|
602 | - |
|
603 | - //Prepare la suite |
|
604 | - $pdf->SetTextColor(0,0,60); |
|
605 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
606 | - |
|
607 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
608 | - $posy=$this->marge_haute; |
|
609 | - |
|
610 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
611 | - |
|
612 | - // Logo |
|
613 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
614 | - if ($this->emetteur->logo) |
|
615 | - { |
|
616 | - if (is_readable($logo)) |
|
617 | - { |
|
618 | - $height=pdf_getHeightForLogo($logo); |
|
619 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
620 | - } |
|
621 | - else |
|
622 | - { |
|
623 | - $pdf->SetTextColor(200,0,0); |
|
624 | - $pdf->SetFont('','B',$default_font_size - 2); |
|
625 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
626 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
627 | - } |
|
628 | - } |
|
629 | - else |
|
630 | - { |
|
631 | - $text=$this->emetteur->name; |
|
632 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
633 | - } |
|
634 | - |
|
635 | - $pdf->SetFont('','B',$default_font_size + 3); |
|
636 | - $pdf->SetXY($posx,$posy); |
|
637 | - $pdf->SetTextColor(0,0,60); |
|
638 | - $title=$outputlangs->transnoentities("ContractCard"); |
|
639 | - $pdf->MultiCell(100, 4, $title, '', 'R'); |
|
640 | - |
|
641 | - $pdf->SetFont('','B',$default_font_size + 2); |
|
642 | - |
|
643 | - $posy+=5; |
|
644 | - $pdf->SetXY($posx,$posy); |
|
645 | - $pdf->SetTextColor(0,0,60); |
|
646 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
647 | - |
|
648 | - $posy+=1; |
|
649 | - $pdf->SetFont('','', $default_font_size); |
|
650 | - |
|
651 | - $posy+=4; |
|
652 | - $pdf->SetXY($posx,$posy); |
|
653 | - $pdf->SetTextColor(0,0,60); |
|
654 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R'); |
|
655 | - |
|
656 | - if ($object->thirdparty->code_client) |
|
657 | - { |
|
658 | - $posy+=4; |
|
659 | - $pdf->SetXY($posx,$posy); |
|
660 | - $pdf->SetTextColor(0,0,60); |
|
661 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
662 | - } |
|
663 | - |
|
664 | - if ($showaddress) |
|
665 | - { |
|
666 | - // Sender properties |
|
667 | - $carac_emetteur=''; |
|
668 | - // Add internal contact of proposal if defined |
|
669 | - $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL'); |
|
670 | - if (count($arrayidcontact) > 0) |
|
671 | - { |
|
672 | - $object->fetch_user($arrayidcontact[0]); |
|
673 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
674 | - } |
|
675 | - |
|
676 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
677 | - |
|
678 | - // Show sender |
|
679 | - $posy=42; |
|
680 | - $posx=$this->marge_gauche; |
|
681 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
682 | - $hautcadre=40; |
|
683 | - |
|
684 | - // Show sender frame |
|
685 | - $pdf->SetTextColor(0,0,0); |
|
686 | - $pdf->SetFont('','', $default_font_size - 2); |
|
687 | - $pdf->SetXY($posx,$posy-5); |
|
688 | - $pdf->SetXY($posx,$posy); |
|
689 | - $pdf->SetFillColor(230,230,230); |
|
690 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
691 | - |
|
692 | - // Show sender name |
|
693 | - $pdf->SetXY($posx+2,$posy+3); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->SetFont('','B',$default_font_size); |
|
696 | - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
697 | - $posy=$pdf->getY(); |
|
698 | - |
|
699 | - // Show sender information |
|
700 | - $pdf->SetFont('','', $default_font_size - 1); |
|
701 | - $pdf->SetXY($posx+2,$posy); |
|
702 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
703 | - |
|
704 | - |
|
705 | - // If CUSTOMER contact defined, we use it |
|
706 | - $usecontact=false; |
|
707 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
708 | - if (count($arrayidcontact) > 0) |
|
709 | - { |
|
710 | - $usecontact=true; |
|
711 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
712 | - } |
|
713 | - |
|
714 | - $this->recipient = $object->thirdparty; |
|
715 | - |
|
716 | - //Recipient name |
|
717 | - // On peut utiliser le nom de la societe du contact |
|
718 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
719 | - $thirdparty = $object->contact; |
|
720 | - } else { |
|
721 | - $thirdparty = $object->thirdparty; |
|
722 | - } |
|
723 | - |
|
724 | - $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
725 | - |
|
726 | - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); |
|
727 | - |
|
728 | - // Show recipient |
|
729 | - $widthrecbox=100; |
|
730 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
731 | - $posy=42; |
|
732 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
733 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
734 | - |
|
735 | - // Show recipient frame |
|
736 | - $pdf->SetTextColor(0,0,0); |
|
737 | - $pdf->SetFont('','', $default_font_size - 2); |
|
738 | - $pdf->SetXY($posx+2,$posy-5); |
|
739 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
740 | - $pdf->SetTextColor(0,0,0); |
|
741 | - |
|
742 | - // Show recipient name |
|
743 | - $pdf->SetXY($posx+2,$posy+3); |
|
744 | - $pdf->SetFont('','B', $default_font_size); |
|
745 | - $pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L'); |
|
746 | - |
|
747 | - $posy = $pdf->getY(); |
|
748 | - |
|
749 | - // Show recipient information |
|
750 | - $pdf->SetFont('','', $default_font_size - 1); |
|
751 | - $pdf->SetXY($posx+2,$posy); |
|
752 | - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
753 | - } |
|
754 | - } |
|
577 | + /** |
|
578 | + * Show top header of page. |
|
579 | + * |
|
580 | + * @param PDF $pdf Object PDF |
|
581 | + * @param CommonObject $object Object to show |
|
582 | + * @param int $showaddress 0=no, 1=yes |
|
583 | + * @param Translate $outputlangs Object lang for output |
|
584 | + * @return void |
|
585 | + */ |
|
586 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
587 | + { |
|
588 | + global $conf,$langs; |
|
589 | + |
|
590 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
591 | + |
|
592 | + // Load traductions files requiredby by page |
|
593 | + $outputlangs->loadLangs(array("main", "dict", "contract", "companies")); |
|
594 | + |
|
595 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
596 | + |
|
597 | + //Affiche le filigrane brouillon - Print Draft Watermark |
|
598 | + if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) ) |
|
599 | + { |
|
600 | + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK); |
|
601 | + } |
|
602 | + |
|
603 | + //Prepare la suite |
|
604 | + $pdf->SetTextColor(0,0,60); |
|
605 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
606 | + |
|
607 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
608 | + $posy=$this->marge_haute; |
|
609 | + |
|
610 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
611 | + |
|
612 | + // Logo |
|
613 | + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
614 | + if ($this->emetteur->logo) |
|
615 | + { |
|
616 | + if (is_readable($logo)) |
|
617 | + { |
|
618 | + $height=pdf_getHeightForLogo($logo); |
|
619 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
620 | + } |
|
621 | + else |
|
622 | + { |
|
623 | + $pdf->SetTextColor(200,0,0); |
|
624 | + $pdf->SetFont('','B',$default_font_size - 2); |
|
625 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
626 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
627 | + } |
|
628 | + } |
|
629 | + else |
|
630 | + { |
|
631 | + $text=$this->emetteur->name; |
|
632 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
633 | + } |
|
634 | + |
|
635 | + $pdf->SetFont('','B',$default_font_size + 3); |
|
636 | + $pdf->SetXY($posx,$posy); |
|
637 | + $pdf->SetTextColor(0,0,60); |
|
638 | + $title=$outputlangs->transnoentities("ContractCard"); |
|
639 | + $pdf->MultiCell(100, 4, $title, '', 'R'); |
|
640 | + |
|
641 | + $pdf->SetFont('','B',$default_font_size + 2); |
|
642 | + |
|
643 | + $posy+=5; |
|
644 | + $pdf->SetXY($posx,$posy); |
|
645 | + $pdf->SetTextColor(0,0,60); |
|
646 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
647 | + |
|
648 | + $posy+=1; |
|
649 | + $pdf->SetFont('','', $default_font_size); |
|
650 | + |
|
651 | + $posy+=4; |
|
652 | + $pdf->SetXY($posx,$posy); |
|
653 | + $pdf->SetTextColor(0,0,60); |
|
654 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R'); |
|
655 | + |
|
656 | + if ($object->thirdparty->code_client) |
|
657 | + { |
|
658 | + $posy+=4; |
|
659 | + $pdf->SetXY($posx,$posy); |
|
660 | + $pdf->SetTextColor(0,0,60); |
|
661 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
662 | + } |
|
663 | + |
|
664 | + if ($showaddress) |
|
665 | + { |
|
666 | + // Sender properties |
|
667 | + $carac_emetteur=''; |
|
668 | + // Add internal contact of proposal if defined |
|
669 | + $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL'); |
|
670 | + if (count($arrayidcontact) > 0) |
|
671 | + { |
|
672 | + $object->fetch_user($arrayidcontact[0]); |
|
673 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
674 | + } |
|
675 | + |
|
676 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
677 | + |
|
678 | + // Show sender |
|
679 | + $posy=42; |
|
680 | + $posx=$this->marge_gauche; |
|
681 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
682 | + $hautcadre=40; |
|
683 | + |
|
684 | + // Show sender frame |
|
685 | + $pdf->SetTextColor(0,0,0); |
|
686 | + $pdf->SetFont('','', $default_font_size - 2); |
|
687 | + $pdf->SetXY($posx,$posy-5); |
|
688 | + $pdf->SetXY($posx,$posy); |
|
689 | + $pdf->SetFillColor(230,230,230); |
|
690 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
691 | + |
|
692 | + // Show sender name |
|
693 | + $pdf->SetXY($posx+2,$posy+3); |
|
694 | + $pdf->SetTextColor(0,0,60); |
|
695 | + $pdf->SetFont('','B',$default_font_size); |
|
696 | + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
697 | + $posy=$pdf->getY(); |
|
698 | + |
|
699 | + // Show sender information |
|
700 | + $pdf->SetFont('','', $default_font_size - 1); |
|
701 | + $pdf->SetXY($posx+2,$posy); |
|
702 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
703 | + |
|
704 | + |
|
705 | + // If CUSTOMER contact defined, we use it |
|
706 | + $usecontact=false; |
|
707 | + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
708 | + if (count($arrayidcontact) > 0) |
|
709 | + { |
|
710 | + $usecontact=true; |
|
711 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
712 | + } |
|
713 | + |
|
714 | + $this->recipient = $object->thirdparty; |
|
715 | + |
|
716 | + //Recipient name |
|
717 | + // On peut utiliser le nom de la societe du contact |
|
718 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
719 | + $thirdparty = $object->contact; |
|
720 | + } else { |
|
721 | + $thirdparty = $object->thirdparty; |
|
722 | + } |
|
723 | + |
|
724 | + $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
725 | + |
|
726 | + $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); |
|
727 | + |
|
728 | + // Show recipient |
|
729 | + $widthrecbox=100; |
|
730 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
731 | + $posy=42; |
|
732 | + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
733 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
734 | + |
|
735 | + // Show recipient frame |
|
736 | + $pdf->SetTextColor(0,0,0); |
|
737 | + $pdf->SetFont('','', $default_font_size - 2); |
|
738 | + $pdf->SetXY($posx+2,$posy-5); |
|
739 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
740 | + $pdf->SetTextColor(0,0,0); |
|
741 | + |
|
742 | + // Show recipient name |
|
743 | + $pdf->SetXY($posx+2,$posy+3); |
|
744 | + $pdf->SetFont('','B', $default_font_size); |
|
745 | + $pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L'); |
|
746 | + |
|
747 | + $posy = $pdf->getY(); |
|
748 | + |
|
749 | + // Show recipient information |
|
750 | + $pdf->SetFont('','', $default_font_size - 1); |
|
751 | + $pdf->SetXY($posx+2,$posy); |
|
752 | + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
753 | + } |
|
754 | + } |
|
755 | 755 | |
756 | - /** |
|
757 | - * Show footer of page. Need this->emetteur object |
|
756 | + /** |
|
757 | + * Show footer of page. Need this->emetteur object |
|
758 | 758 | * |
759 | - * @param PDF $pdf PDF |
|
760 | - * @param CommonObject $object Object to show |
|
761 | - * @param Translate $outputlangs Object lang for output |
|
762 | - * @param int $hidefreetext 1=Hide free text |
|
763 | - * @return integer |
|
764 | - */ |
|
765 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
766 | - { |
|
767 | - global $conf; |
|
768 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
769 | - return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
770 | - } |
|
759 | + * @param PDF $pdf PDF |
|
760 | + * @param CommonObject $object Object to show |
|
761 | + * @param Translate $outputlangs Object lang for output |
|
762 | + * @param int $hidefreetext 1=Hide free text |
|
763 | + * @return integer |
|
764 | + */ |
|
765 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
766 | + { |
|
767 | + global $conf; |
|
768 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
769 | + return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
770 | + } |
|
771 | 771 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function __construct($db) |
128 | 128 | { |
129 | - global $conf,$langs,$mysoc; |
|
129 | + global $conf, $langs, $mysoc; |
|
130 | 130 | |
131 | 131 | $this->db = $db; |
132 | 132 | $this->name = 'strato'; |
@@ -134,30 +134,30 @@ discard block |
||
134 | 134 | |
135 | 135 | // Dimension page pour format A4 |
136 | 136 | $this->type = 'pdf'; |
137 | - $formatarray=pdf_getFormat(); |
|
137 | + $formatarray = pdf_getFormat(); |
|
138 | 138 | |
139 | 139 | $this->page_largeur = $formatarray['width']; |
140 | 140 | $this->page_hauteur = $formatarray['height']; |
141 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
142 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
143 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
144 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
145 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
146 | - |
|
147 | - $this->option_logo = 1; // Affiche logo |
|
148 | - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION |
|
149 | - $this->option_modereg = 0; // Affiche mode reglement |
|
150 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
151 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
152 | - $this->option_multilang = 0; // Dispo en plusieurs langues |
|
153 | - $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
141 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
142 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
143 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
144 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
145 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
146 | + |
|
147 | + $this->option_logo = 1; // Affiche logo |
|
148 | + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION |
|
149 | + $this->option_modereg = 0; // Affiche mode reglement |
|
150 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
151 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
152 | + $this->option_multilang = 0; // Dispo en plusieurs langues |
|
153 | + $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
154 | 154 | |
155 | 155 | // Get source company |
156 | - $this->emetteur=$mysoc; |
|
157 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined |
|
156 | + $this->emetteur = $mysoc; |
|
157 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined |
|
158 | 158 | |
159 | 159 | // Define position of columns |
160 | - $this->posxdesc=$this->marge_gauche+1; |
|
160 | + $this->posxdesc = $this->marge_gauche + 1; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * @param int $hideref Do not show ref |
173 | 173 | * @return int 1=OK, 0=KO |
174 | 174 | */ |
175 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
175 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
176 | 176 | { |
177 | 177 | // phpcs:enable |
178 | - global $user,$langs,$conf,$hookmanager,$mysoc; |
|
178 | + global $user, $langs, $conf, $hookmanager, $mysoc; |
|
179 | 179 | |
180 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
180 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
181 | 181 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
182 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
182 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
183 | 183 | |
184 | 184 | // Load traductions files requiredby by page |
185 | 185 | $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); |
@@ -192,20 +192,20 @@ discard block |
||
192 | 192 | if ($object->specimen) |
193 | 193 | { |
194 | 194 | $dir = $conf->contrat->dir_output; |
195 | - $file = $dir . "/SPECIMEN.pdf"; |
|
195 | + $file = $dir."/SPECIMEN.pdf"; |
|
196 | 196 | } |
197 | 197 | else |
198 | 198 | { |
199 | 199 | $objectref = dol_sanitizeFileName($object->ref); |
200 | - $dir = $conf->contrat->dir_output . "/" . $objectref; |
|
201 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
200 | + $dir = $conf->contrat->dir_output."/".$objectref; |
|
201 | + $file = $dir."/".$objectref.".pdf"; |
|
202 | 202 | } |
203 | 203 | |
204 | - if (! file_exists($dir)) |
|
204 | + if (!file_exists($dir)) |
|
205 | 205 | { |
206 | 206 | if (dol_mkdir($dir) < 0) |
207 | 207 | { |
208 | - $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir); |
|
208 | + $this->error = $outputlangs->trans("ErrorCanNotCreateDir", $dir); |
|
209 | 209 | return 0; |
210 | 210 | } |
211 | 211 | } |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | if (file_exists($dir)) |
214 | 214 | { |
215 | 215 | // Add pdfgeneration hook |
216 | - if (! is_object($hookmanager)) |
|
216 | + if (!is_object($hookmanager)) |
|
217 | 217 | { |
218 | 218 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
219 | - $hookmanager=new HookManager($this->db); |
|
219 | + $hookmanager = new HookManager($this->db); |
|
220 | 220 | } |
221 | 221 | $hookmanager->initHooks(array('pdfgeneration')); |
222 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
222 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
223 | 223 | global $action; |
224 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
224 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
225 | 225 | |
226 | - $pdf=pdf_getInstance($this->format); |
|
227 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
228 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
229 | - $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 |
|
230 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
231 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
232 | - $pdf->SetAutoPageBreak(1,0); |
|
226 | + $pdf = pdf_getInstance($this->format); |
|
227 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
228 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
229 | + $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 |
|
230 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
231 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
232 | + $pdf->SetAutoPageBreak(1, 0); |
|
233 | 233 | |
234 | 234 | if (class_exists('TCPDF')) |
235 | 235 | { |
@@ -238,52 +238,52 @@ discard block |
||
238 | 238 | } |
239 | 239 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
240 | 240 | // Set path to the background PDF File |
241 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
241 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
242 | 242 | { |
243 | 243 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
244 | 244 | $tplidx = $pdf->importPage(1); |
245 | 245 | } |
246 | 246 | |
247 | 247 | $pdf->Open(); |
248 | - $pagenb=0; |
|
249 | - $pdf->SetDrawColor(128,128,128); |
|
248 | + $pagenb = 0; |
|
249 | + $pdf->SetDrawColor(128, 128, 128); |
|
250 | 250 | |
251 | 251 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
252 | 252 | $pdf->SetSubject($outputlangs->transnoentities("ContractCard")); |
253 | 253 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
254 | 254 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
255 | 255 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
256 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
256 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
257 | 257 | |
258 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
258 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
259 | 259 | |
260 | 260 | // New page |
261 | 261 | $pdf->AddPage(); |
262 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
262 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
263 | 263 | $pagenb++; |
264 | 264 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
265 | - $pdf->SetFont('','', $default_font_size - 1); |
|
266 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
267 | - $pdf->SetTextColor(0,0,0); |
|
265 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
266 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
267 | + $pdf->SetTextColor(0, 0, 0); |
|
268 | 268 | |
269 | 269 | $tab_top = 90; |
270 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
270 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); |
|
271 | 271 | |
272 | 272 | // Affiche notes |
273 | - if (! empty($object->note_public)) |
|
273 | + if (!empty($object->note_public)) |
|
274 | 274 | { |
275 | 275 | $tab_top -= 2; |
276 | 276 | |
277 | - $pdf->SetFont('','', $default_font_size - 1); |
|
278 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
277 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
278 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
279 | 279 | $nexY = $pdf->GetY(); |
280 | - $height_note=$nexY-$tab_top; |
|
280 | + $height_note = $nexY - $tab_top; |
|
281 | 281 | |
282 | 282 | // Rect prend une longueur en 3eme param |
283 | - $pdf->SetDrawColor(192,192,192); |
|
284 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
283 | + $pdf->SetDrawColor(192, 192, 192); |
|
284 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
285 | 285 | |
286 | - $tab_top = $nexY+6; |
|
286 | + $tab_top = $nexY + 6; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | $iniY = $tab_top + 7; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | $pdf->SetXY($this->marge_gauche, $tab_top); |
294 | 294 | |
295 | - $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
|
295 | + $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
|
296 | 296 | |
297 | 297 | $nblines = count($object->lines); |
298 | 298 | |
@@ -305,44 +305,44 @@ discard block |
||
305 | 305 | |
306 | 306 | if ($valide > 0 || $object->specimen) |
307 | 307 | { |
308 | - $curX = $this->posxdesc-1; |
|
308 | + $curX = $this->posxdesc - 1; |
|
309 | 309 | $curY = $nexY; |
310 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
311 | - $pdf->SetTextColor(0,0,0); |
|
310 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
311 | + $pdf->SetTextColor(0, 0, 0); |
|
312 | 312 | |
313 | 313 | $pdf->setTopMargin($tab_top_newpage); |
314 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
315 | - $pageposbefore=$pdf->getPage(); |
|
314 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
315 | + $pageposbefore = $pdf->getPage(); |
|
316 | 316 | |
317 | 317 | // Description of product line |
318 | 318 | |
319 | 319 | if ($objectligne->date_ouverture_prevue) { |
320 | - $datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true); |
|
320 | + $datei = dol_print_date($objectligne->date_ouverture_prevue, 'day', false, $outputlangs, true); |
|
321 | 321 | } else { |
322 | 322 | $datei = $langs->trans("Unknown"); |
323 | 323 | } |
324 | 324 | |
325 | 325 | if ($objectligne->date_fin_validite) { |
326 | 326 | $durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour'); |
327 | - $datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true); |
|
327 | + $datee = dol_print_date($objectligne->date_fin_validite, 'day', false, $outputlangs, true); |
|
328 | 328 | } else { |
329 | 329 | $durationi = $langs->trans("Unknown"); |
330 | 330 | $datee = $langs->trans("Unknown"); |
331 | 331 | } |
332 | 332 | |
333 | 333 | if ($objectligne->date_ouverture) { |
334 | - $daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true); |
|
334 | + $daters = dol_print_date($objectligne->date_ouverture, 'day', false, $outputlangs, true); |
|
335 | 335 | } else { |
336 | 336 | $daters = $langs->trans("Unknown"); |
337 | 337 | } |
338 | 338 | |
339 | 339 | if ($objectligne->date_cloture) { |
340 | - $datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true); |
|
340 | + $datere = dol_print_date($objectligne->date_cloture, 'day', false, $outputlangs, true); |
|
341 | 341 | } else { |
342 | 342 | $datere = $langs->trans("Unknown"); |
343 | 343 | } |
344 | 344 | |
345 | - $txtpredefinedservice=''; |
|
345 | + $txtpredefinedservice = ''; |
|
346 | 346 | $txtpredefinedservice = $objectligne->product_label; |
347 | 347 | if ($objectligne->product_label) |
348 | 348 | { |
@@ -350,42 +350,42 @@ discard block |
||
350 | 350 | $txtpredefinedservice .= $objectligne->product_label; |
351 | 351 | } |
352 | 352 | |
353 | - $desc=dol_htmlentitiesbr($objectligne->desc,1); // Desc (not empty for free lines) |
|
354 | - $txt=''; |
|
355 | - $txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines) |
|
356 | - $txt.='<br>'; |
|
357 | - $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>'; |
|
358 | - $txt.='<br>'; |
|
359 | - $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>'; |
|
360 | - if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
353 | + $desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines) |
|
354 | + $txt = ''; |
|
355 | + $txt .= $outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines) |
|
356 | + $txt .= '<br>'; |
|
357 | + $txt .= $outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>'; |
|
358 | + $txt .= '<br>'; |
|
359 | + $txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>'; |
|
360 | + if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
361 | 361 | |
362 | 362 | $pdf->startTransaction(); |
363 | 363 | $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
364 | - $pageposafter=$pdf->getPage(); |
|
364 | + $pageposafter = $pdf->getPage(); |
|
365 | 365 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
366 | 366 | { |
367 | 367 | $pdf->rollbackTransaction(true); |
368 | - $pageposafter=$pageposbefore; |
|
368 | + $pageposafter = $pageposbefore; |
|
369 | 369 | //print $pageposafter.'-'.$pageposbefore;exit; |
370 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
370 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
371 | 371 | $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
372 | - $pageposafter=$pdf->getPage(); |
|
373 | - $posyafter=$pdf->GetY(); |
|
372 | + $pageposafter = $pdf->getPage(); |
|
373 | + $posyafter = $pdf->GetY(); |
|
374 | 374 | |
375 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
375 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
376 | 376 | { |
377 | - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page |
|
377 | + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page |
|
378 | 378 | { |
379 | - $pdf->AddPage('','',true); |
|
380 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
379 | + $pdf->AddPage('', '', true); |
|
380 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
381 | 381 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
382 | - $pdf->setPage($pageposafter+1); |
|
382 | + $pdf->setPage($pageposafter + 1); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | else |
386 | 386 | { |
387 | 387 | // We found a page break |
388 | - $showpricebeforepagebreak=0; |
|
388 | + $showpricebeforepagebreak = 0; |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | else // No pagebreak |
@@ -394,18 +394,18 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | $nexY = $pdf->GetY() + 2; |
397 | - $pageposafter=$pdf->getPage(); |
|
397 | + $pageposafter = $pdf->getPage(); |
|
398 | 398 | |
399 | 399 | $pdf->setPage($pageposbefore); |
400 | 400 | $pdf->setTopMargin($this->marge_haute); |
401 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
401 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
402 | 402 | |
403 | 403 | // We suppose that a too long description is moved completely on next page |
404 | 404 | if ($pageposafter > $pageposbefore) { |
405 | 405 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
406 | 406 | } |
407 | 407 | |
408 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
408 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
409 | 409 | |
410 | 410 | // Detect if some page were added automatically and output _tableau for past pages |
411 | 411 | while ($pagenb < $pageposafter) |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | { |
420 | 420 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
421 | 421 | } |
422 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
422 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
423 | 423 | $pagenb++; |
424 | 424 | $pdf->setPage($pagenb); |
425 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
425 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
426 | 426 | } |
427 | 427 | |
428 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
428 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
429 | 429 | { |
430 | 430 | if ($pagenb == 1) |
431 | 431 | { |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | { |
436 | 436 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
437 | 437 | } |
438 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
438 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
439 | 439 | // New page |
440 | 440 | $pdf->AddPage(); |
441 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
441 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
442 | 442 | $pagenb++; |
443 | 443 | } |
444 | 444 | } |
@@ -449,34 +449,34 @@ discard block |
||
449 | 449 | { |
450 | 450 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
451 | 451 | $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
452 | - $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
452 | + $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
453 | 453 | } |
454 | 454 | else |
455 | 455 | { |
456 | 456 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
457 | 457 | $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
458 | - $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
458 | + $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
|
459 | 459 | } |
460 | 460 | |
461 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
462 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
461 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
462 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
463 | 463 | |
464 | 464 | $pdf->Close(); |
465 | 465 | |
466 | - $pdf->Output($file,'F'); |
|
466 | + $pdf->Output($file, 'F'); |
|
467 | 467 | |
468 | 468 | // Add pdfgeneration hook |
469 | - if (! is_object($hookmanager)) |
|
469 | + if (!is_object($hookmanager)) |
|
470 | 470 | { |
471 | 471 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
472 | - $hookmanager=new HookManager($this->db); |
|
472 | + $hookmanager = new HookManager($this->db); |
|
473 | 473 | } |
474 | 474 | $hookmanager->initHooks(array('pdfgeneration')); |
475 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
475 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
476 | 476 | global $action; |
477 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
477 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
478 | 478 | |
479 | - if (! empty($conf->global->MAIN_UMASK)) |
|
479 | + if (!empty($conf->global->MAIN_UMASK)) |
|
480 | 480 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
481 | 481 | |
482 | 482 | $this->result = array('fullpath'=>$file); |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | } |
486 | 486 | else |
487 | 487 | { |
488 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
488 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
489 | 489 | return 0; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | else |
493 | 493 | { |
494 | - $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR"); |
|
494 | + $this->error = $langs->trans("ErrorConstantNotDefined", "CONTRACT_OUTPUTDIR"); |
|
495 | 495 | return 0; |
496 | 496 | } |
497 | 497 | } |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | * @param int $hidebottom Hide bottom bar of array |
509 | 509 | * @return void |
510 | 510 | */ |
511 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
511 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
512 | 512 | { |
513 | 513 | global $conf; |
514 | 514 | |
515 | 515 | // Force to disable hidetop and hidebottom |
516 | - $hidebottom=0; |
|
517 | - if ($hidetop) $hidetop=-1; |
|
516 | + $hidebottom = 0; |
|
517 | + if ($hidetop) $hidetop = -1; |
|
518 | 518 | |
519 | 519 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
520 | 520 | /* |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | |
546 | 546 | // Output Rect |
547 | - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param |
|
547 | + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect prend une longueur en 3eme param et 4eme param |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -557,21 +557,21 @@ discard block |
||
557 | 557 | */ |
558 | 558 | private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) |
559 | 559 | { |
560 | - $pdf->SetDrawColor(128,128,128); |
|
561 | - $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); |
|
560 | + $pdf->SetDrawColor(128, 128, 128); |
|
561 | + $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2); |
|
562 | 562 | $posy = $tab_top + $tab_height + 3 + 3; |
563 | 563 | |
564 | 564 | $pdf->SetXY($this->marge_gauche, $posy); |
565 | - $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); |
|
565 | + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name), 0, 'L', 0); |
|
566 | 566 | |
567 | 567 | $pdf->SetXY($this->marge_gauche, $posy + 5); |
568 | 568 | $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); |
569 | 569 | |
570 | 570 | $pdf->SetXY($posmiddle + 5, $posy); |
571 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); |
|
571 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name), 0, 'L', 0); |
|
572 | 572 | |
573 | 573 | $pdf->SetXY($posmiddle + 5, $posy + 5); |
574 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); |
|
574 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -585,130 +585,130 @@ discard block |
||
585 | 585 | */ |
586 | 586 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
587 | 587 | { |
588 | - global $conf,$langs; |
|
588 | + global $conf, $langs; |
|
589 | 589 | |
590 | 590 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
591 | 591 | |
592 | 592 | // Load traductions files requiredby by page |
593 | 593 | $outputlangs->loadLangs(array("main", "dict", "contract", "companies")); |
594 | 594 | |
595 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
595 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
596 | 596 | |
597 | 597 | //Affiche le filigrane brouillon - Print Draft Watermark |
598 | - if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) ) |
|
598 | + if ($object->statut == 0 && (!empty($conf->global->CONTRACT_DRAFT_WATERMARK))) |
|
599 | 599 | { |
600 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK); |
|
600 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->CONTRACT_DRAFT_WATERMARK); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | //Prepare la suite |
604 | - $pdf->SetTextColor(0,0,60); |
|
605 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
604 | + $pdf->SetTextColor(0, 0, 60); |
|
605 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
606 | 606 | |
607 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
608 | - $posy=$this->marge_haute; |
|
607 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
608 | + $posy = $this->marge_haute; |
|
609 | 609 | |
610 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
610 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
611 | 611 | |
612 | 612 | // Logo |
613 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
613 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
614 | 614 | if ($this->emetteur->logo) |
615 | 615 | { |
616 | 616 | if (is_readable($logo)) |
617 | 617 | { |
618 | - $height=pdf_getHeightForLogo($logo); |
|
619 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
618 | + $height = pdf_getHeightForLogo($logo); |
|
619 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
620 | 620 | } |
621 | 621 | else |
622 | 622 | { |
623 | - $pdf->SetTextColor(200,0,0); |
|
624 | - $pdf->SetFont('','B',$default_font_size - 2); |
|
625 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
623 | + $pdf->SetTextColor(200, 0, 0); |
|
624 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
625 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
626 | 626 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
627 | 627 | } |
628 | 628 | } |
629 | 629 | else |
630 | 630 | { |
631 | - $text=$this->emetteur->name; |
|
631 | + $text = $this->emetteur->name; |
|
632 | 632 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
633 | 633 | } |
634 | 634 | |
635 | - $pdf->SetFont('','B',$default_font_size + 3); |
|
636 | - $pdf->SetXY($posx,$posy); |
|
637 | - $pdf->SetTextColor(0,0,60); |
|
638 | - $title=$outputlangs->transnoentities("ContractCard"); |
|
635 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
636 | + $pdf->SetXY($posx, $posy); |
|
637 | + $pdf->SetTextColor(0, 0, 60); |
|
638 | + $title = $outputlangs->transnoentities("ContractCard"); |
|
639 | 639 | $pdf->MultiCell(100, 4, $title, '', 'R'); |
640 | 640 | |
641 | - $pdf->SetFont('','B',$default_font_size + 2); |
|
641 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
642 | 642 | |
643 | - $posy+=5; |
|
644 | - $pdf->SetXY($posx,$posy); |
|
645 | - $pdf->SetTextColor(0,0,60); |
|
646 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
643 | + $posy += 5; |
|
644 | + $pdf->SetXY($posx, $posy); |
|
645 | + $pdf->SetTextColor(0, 0, 60); |
|
646 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
647 | 647 | |
648 | - $posy+=1; |
|
649 | - $pdf->SetFont('','', $default_font_size); |
|
648 | + $posy += 1; |
|
649 | + $pdf->SetFont('', '', $default_font_size); |
|
650 | 650 | |
651 | - $posy+=4; |
|
652 | - $pdf->SetXY($posx,$posy); |
|
653 | - $pdf->SetTextColor(0,0,60); |
|
654 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R'); |
|
651 | + $posy += 4; |
|
652 | + $pdf->SetXY($posx, $posy); |
|
653 | + $pdf->SetTextColor(0, 0, 60); |
|
654 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_contrat, "day", false, $outputlangs, true), '', 'R'); |
|
655 | 655 | |
656 | 656 | if ($object->thirdparty->code_client) |
657 | 657 | { |
658 | - $posy+=4; |
|
659 | - $pdf->SetXY($posx,$posy); |
|
660 | - $pdf->SetTextColor(0,0,60); |
|
661 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
658 | + $posy += 4; |
|
659 | + $pdf->SetXY($posx, $posy); |
|
660 | + $pdf->SetTextColor(0, 0, 60); |
|
661 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | if ($showaddress) |
665 | 665 | { |
666 | 666 | // Sender properties |
667 | - $carac_emetteur=''; |
|
667 | + $carac_emetteur = ''; |
|
668 | 668 | // Add internal contact of proposal if defined |
669 | - $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL'); |
|
669 | + $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL'); |
|
670 | 670 | if (count($arrayidcontact) > 0) |
671 | 671 | { |
672 | 672 | $object->fetch_user($arrayidcontact[0]); |
673 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
673 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
677 | 677 | |
678 | 678 | // Show sender |
679 | - $posy=42; |
|
680 | - $posx=$this->marge_gauche; |
|
681 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
682 | - $hautcadre=40; |
|
679 | + $posy = 42; |
|
680 | + $posx = $this->marge_gauche; |
|
681 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
682 | + $hautcadre = 40; |
|
683 | 683 | |
684 | 684 | // Show sender frame |
685 | - $pdf->SetTextColor(0,0,0); |
|
686 | - $pdf->SetFont('','', $default_font_size - 2); |
|
687 | - $pdf->SetXY($posx,$posy-5); |
|
688 | - $pdf->SetXY($posx,$posy); |
|
689 | - $pdf->SetFillColor(230,230,230); |
|
685 | + $pdf->SetTextColor(0, 0, 0); |
|
686 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
687 | + $pdf->SetXY($posx, $posy - 5); |
|
688 | + $pdf->SetXY($posx, $posy); |
|
689 | + $pdf->SetFillColor(230, 230, 230); |
|
690 | 690 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
691 | 691 | |
692 | 692 | // Show sender name |
693 | - $pdf->SetXY($posx+2,$posy+3); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->SetFont('','B',$default_font_size); |
|
693 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
694 | + $pdf->SetTextColor(0, 0, 60); |
|
695 | + $pdf->SetFont('', 'B', $default_font_size); |
|
696 | 696 | $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
697 | - $posy=$pdf->getY(); |
|
697 | + $posy = $pdf->getY(); |
|
698 | 698 | |
699 | 699 | // Show sender information |
700 | - $pdf->SetFont('','', $default_font_size - 1); |
|
701 | - $pdf->SetXY($posx+2,$posy); |
|
700 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
701 | + $pdf->SetXY($posx + 2, $posy); |
|
702 | 702 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
703 | 703 | |
704 | 704 | |
705 | 705 | // If CUSTOMER contact defined, we use it |
706 | - $usecontact=false; |
|
707 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
706 | + $usecontact = false; |
|
707 | + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); |
|
708 | 708 | if (count($arrayidcontact) > 0) |
709 | 709 | { |
710 | - $usecontact=true; |
|
711 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
710 | + $usecontact = true; |
|
711 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | $this->recipient = $object->thirdparty; |
@@ -723,32 +723,32 @@ discard block |
||
723 | 723 | |
724 | 724 | $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
725 | 725 | |
726 | - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); |
|
726 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), $usecontact, 'target', $object); |
|
727 | 727 | |
728 | 728 | // Show recipient |
729 | - $widthrecbox=100; |
|
730 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
731 | - $posy=42; |
|
732 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
733 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
729 | + $widthrecbox = 100; |
|
730 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
731 | + $posy = 42; |
|
732 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
733 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
734 | 734 | |
735 | 735 | // Show recipient frame |
736 | - $pdf->SetTextColor(0,0,0); |
|
737 | - $pdf->SetFont('','', $default_font_size - 2); |
|
738 | - $pdf->SetXY($posx+2,$posy-5); |
|
736 | + $pdf->SetTextColor(0, 0, 0); |
|
737 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
738 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
739 | 739 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
740 | - $pdf->SetTextColor(0,0,0); |
|
740 | + $pdf->SetTextColor(0, 0, 0); |
|
741 | 741 | |
742 | 742 | // Show recipient name |
743 | - $pdf->SetXY($posx+2,$posy+3); |
|
744 | - $pdf->SetFont('','B', $default_font_size); |
|
743 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
744 | + $pdf->SetFont('', 'B', $default_font_size); |
|
745 | 745 | $pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L'); |
746 | 746 | |
747 | 747 | $posy = $pdf->getY(); |
748 | 748 | |
749 | 749 | // Show recipient information |
750 | - $pdf->SetFont('','', $default_font_size - 1); |
|
751 | - $pdf->SetXY($posx+2,$posy); |
|
750 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
751 | + $pdf->SetXY($posx + 2, $posy); |
|
752 | 752 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
753 | 753 | } |
754 | 754 | } |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | * @param int $hidefreetext 1=Hide free text |
763 | 763 | * @return integer |
764 | 764 | */ |
765 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
765 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
766 | 766 | { |
767 | 767 | global $conf; |
768 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
769 | - return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
768 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
769 | + return pdf_pagefoot($pdf, $outputlangs, 'CONTRACT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
770 | 770 | } |
771 | 771 | } |
@@ -154,7 +154,10 @@ discard block |
||
154 | 154 | |
155 | 155 | // Get source company |
156 | 156 | $this->emetteur=$mysoc; |
157 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined |
|
157 | + if (empty($this->emetteur->country_code)) { |
|
158 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
159 | + } |
|
160 | + // By default, if not defined |
|
158 | 161 | |
159 | 162 | // Define position of columns |
160 | 163 | $this->posxdesc=$this->marge_gauche+1; |
@@ -177,9 +180,13 @@ discard block |
||
177 | 180 | // phpcs:enable |
178 | 181 | global $user,$langs,$conf,$hookmanager,$mysoc; |
179 | 182 | |
180 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
183 | + if (! is_object($outputlangs)) { |
|
184 | + $outputlangs=$langs; |
|
185 | + } |
|
181 | 186 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
182 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
187 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
188 | + $outputlangs->charset_output='ISO-8859-1'; |
|
189 | + } |
|
183 | 190 | |
184 | 191 | // Load traductions files requiredby by page |
185 | 192 | $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); |
@@ -193,8 +200,7 @@ discard block |
||
193 | 200 | { |
194 | 201 | $dir = $conf->contrat->dir_output; |
195 | 202 | $file = $dir . "/SPECIMEN.pdf"; |
196 | - } |
|
197 | - else |
|
203 | + } else |
|
198 | 204 | { |
199 | 205 | $objectref = dol_sanitizeFileName($object->ref); |
200 | 206 | $dir = $conf->contrat->dir_output . "/" . $objectref; |
@@ -228,7 +234,9 @@ discard block |
||
228 | 234 | $heightforinfotot = 50; // Height reserved to output the info and total part |
229 | 235 | $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 |
230 | 236 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
231 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
237 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
238 | + $heightforfooter+= 6; |
|
239 | + } |
|
232 | 240 | $pdf->SetAutoPageBreak(1,0); |
233 | 241 | |
234 | 242 | if (class_exists('TCPDF')) |
@@ -253,13 +261,17 @@ discard block |
||
253 | 261 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
254 | 262 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
255 | 263 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
256 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
264 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
265 | + $pdf->SetCompression(false); |
|
266 | + } |
|
257 | 267 | |
258 | 268 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
259 | 269 | |
260 | 270 | // New page |
261 | 271 | $pdf->AddPage(); |
262 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
272 | + if (! empty($tplidx)) { |
|
273 | + $pdf->useTemplate($tplidx); |
|
274 | + } |
|
263 | 275 | $pagenb++; |
264 | 276 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
265 | 277 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -357,14 +369,18 @@ discard block |
||
357 | 369 | $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>'; |
358 | 370 | $txt.='<br>'; |
359 | 371 | $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>'; |
360 | - if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
372 | + if ($objectligne->date_cloture) { |
|
373 | + $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; |
|
374 | + } |
|
361 | 375 | |
362 | 376 | $pdf->startTransaction(); |
363 | 377 | $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0); |
364 | 378 | $pageposafter=$pdf->getPage(); |
365 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
379 | + if ($pageposafter > $pageposbefore) { |
|
380 | + // There is a pagebreak |
|
366 | 381 | { |
367 | 382 | $pdf->rollbackTransaction(true); |
383 | + } |
|
368 | 384 | $pageposafter=$pageposbefore; |
369 | 385 | //print $pageposafter.'-'.$pageposbefore;exit; |
370 | 386 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -372,23 +388,27 @@ discard block |
||
372 | 388 | $pageposafter=$pdf->getPage(); |
373 | 389 | $posyafter=$pdf->GetY(); |
374 | 390 | |
375 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
391 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
392 | + // There is no space left for total+free text |
|
376 | 393 | { |
377 | 394 | if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page |
378 | 395 | { |
379 | 396 | $pdf->AddPage('','',true); |
380 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
381 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
397 | + } |
|
398 | + if (! empty($tplidx)) { |
|
399 | + $pdf->useTemplate($tplidx); |
|
400 | + } |
|
401 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
402 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
403 | + } |
|
382 | 404 | $pdf->setPage($pageposafter+1); |
383 | 405 | } |
384 | - } |
|
385 | - else |
|
406 | + } else |
|
386 | 407 | { |
387 | 408 | // We found a page break |
388 | 409 | $showpricebeforepagebreak=0; |
389 | 410 | } |
390 | - } |
|
391 | - else // No pagebreak |
|
411 | + } else // No pagebreak |
|
392 | 412 | { |
393 | 413 | $pdf->commitTransaction(); |
394 | 414 | } |
@@ -414,8 +434,7 @@ discard block |
||
414 | 434 | if ($pagenb == 1) |
415 | 435 | { |
416 | 436 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
417 | - } |
|
418 | - else |
|
437 | + } else |
|
419 | 438 | { |
420 | 439 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
421 | 440 | } |
@@ -430,15 +449,16 @@ discard block |
||
430 | 449 | if ($pagenb == 1) |
431 | 450 | { |
432 | 451 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1); |
433 | - } |
|
434 | - else |
|
452 | + } else |
|
435 | 453 | { |
436 | 454 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1); |
437 | 455 | } |
438 | 456 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
439 | 457 | // New page |
440 | 458 | $pdf->AddPage(); |
441 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
459 | + if (! empty($tplidx)) { |
|
460 | + $pdf->useTemplate($tplidx); |
|
461 | + } |
|
442 | 462 | $pagenb++; |
443 | 463 | } |
444 | 464 | } |
@@ -450,8 +470,7 @@ discard block |
||
450 | 470 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
451 | 471 | $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
452 | 472 | $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; |
453 | - } |
|
454 | - else |
|
473 | + } else |
|
455 | 474 | { |
456 | 475 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
457 | 476 | $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs); |
@@ -459,7 +478,9 @@ discard block |
||
459 | 478 | } |
460 | 479 | |
461 | 480 | $this->_pagefoot($pdf,$object,$outputlangs); |
462 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
481 | + if (method_exists($pdf,'AliasNbPages')) { |
|
482 | + $pdf->AliasNbPages(); |
|
483 | + } |
|
463 | 484 | |
464 | 485 | $pdf->Close(); |
465 | 486 | |
@@ -476,20 +497,19 @@ discard block |
||
476 | 497 | global $action; |
477 | 498 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
478 | 499 | |
479 | - if (! empty($conf->global->MAIN_UMASK)) |
|
480 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
500 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
501 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
502 | + } |
|
481 | 503 | |
482 | 504 | $this->result = array('fullpath'=>$file); |
483 | 505 | |
484 | 506 | return 1; |
485 | - } |
|
486 | - else |
|
507 | + } else |
|
487 | 508 | { |
488 | 509 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
489 | 510 | return 0; |
490 | 511 | } |
491 | - } |
|
492 | - else |
|
512 | + } else |
|
493 | 513 | { |
494 | 514 | $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR"); |
495 | 515 | return 0; |
@@ -514,7 +534,9 @@ discard block |
||
514 | 534 | |
515 | 535 | // Force to disable hidetop and hidebottom |
516 | 536 | $hidebottom=0; |
517 | - if ($hidetop) $hidetop=-1; |
|
537 | + if ($hidetop) { |
|
538 | + $hidetop=-1; |
|
539 | + } |
|
518 | 540 | |
519 | 541 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
520 | 542 | /* |
@@ -617,16 +639,14 @@ discard block |
||
617 | 639 | { |
618 | 640 | $height=pdf_getHeightForLogo($logo); |
619 | 641 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
620 | - } |
|
621 | - else |
|
642 | + } else |
|
622 | 643 | { |
623 | 644 | $pdf->SetTextColor(200,0,0); |
624 | 645 | $pdf->SetFont('','B',$default_font_size - 2); |
625 | 646 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
626 | 647 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
627 | 648 | } |
628 | - } |
|
629 | - else |
|
649 | + } else |
|
630 | 650 | { |
631 | 651 | $text=$this->emetteur->name; |
632 | 652 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -678,7 +698,9 @@ discard block |
||
678 | 698 | // Show sender |
679 | 699 | $posy=42; |
680 | 700 | $posx=$this->marge_gauche; |
681 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
701 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
702 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
703 | + } |
|
682 | 704 | $hautcadre=40; |
683 | 705 | |
684 | 706 | // Show sender frame |
@@ -727,10 +749,15 @@ discard block |
||
727 | 749 | |
728 | 750 | // Show recipient |
729 | 751 | $widthrecbox=100; |
730 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
752 | + if ($this->page_largeur < 210) { |
|
753 | + $widthrecbox=84; |
|
754 | + } |
|
755 | + // To work with US executive format |
|
731 | 756 | $posy=42; |
732 | 757 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
733 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
758 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
759 | + $posx=$this->marge_gauche; |
|
760 | + } |
|
734 | 761 | |
735 | 762 | // Show recipient frame |
736 | 763 | $pdf->SetTextColor(0,0,0); |
@@ -38,463 +38,463 @@ |
||
38 | 38 | */ |
39 | 39 | class doc_generic_contract_odt extends ModelePDFContract |
40 | 40 | { |
41 | - /** |
|
42 | - * Issuer |
|
43 | - * @var Societe |
|
44 | - */ |
|
45 | - public $emetteur; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var array() Minimum version of PHP required by module. |
|
49 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
50 | - */ |
|
51 | - public $phpmin = array(5, 4); |
|
52 | - |
|
53 | - /** |
|
41 | + /** |
|
42 | + * Issuer |
|
43 | + * @var Societe |
|
44 | + */ |
|
45 | + public $emetteur; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var array() Minimum version of PHP required by module. |
|
49 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
50 | + */ |
|
51 | + public $phpmin = array(5, 4); |
|
52 | + |
|
53 | + /** |
|
54 | 54 | * Dolibarr version of the loaded document |
55 | 55 | * @public string |
56 | 56 | */ |
57 | - public $version = 'dolibarr'; |
|
57 | + public $version = 'dolibarr'; |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Constructor |
|
62 | - * |
|
63 | - * @param DoliDB $db Database handler |
|
64 | - */ |
|
65 | - function __construct($db) |
|
66 | - { |
|
67 | - global $conf, $langs, $mysoc; |
|
60 | + /** |
|
61 | + * Constructor |
|
62 | + * |
|
63 | + * @param DoliDB $db Database handler |
|
64 | + */ |
|
65 | + function __construct($db) |
|
66 | + { |
|
67 | + global $conf, $langs, $mysoc; |
|
68 | 68 | |
69 | - // Load translation files required by the page |
|
69 | + // Load translation files required by the page |
|
70 | 70 | $langs->loadLangs(array("main","companies")); |
71 | 71 | |
72 | - $this->db = $db; |
|
73 | - $this->name = "ODT templates"; |
|
74 | - $this->description = $langs->trans("DocumentModelOdt"); |
|
75 | - $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
76 | - |
|
77 | - // Dimension page pour format A4 |
|
78 | - $this->type = 'odt'; |
|
79 | - $this->page_largeur = 0; |
|
80 | - $this->page_hauteur = 0; |
|
81 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
82 | - $this->marge_gauche=0; |
|
83 | - $this->marge_droite=0; |
|
84 | - $this->marge_haute=0; |
|
85 | - $this->marge_basse=0; |
|
86 | - |
|
87 | - $this->option_logo = 1; // Affiche logo |
|
88 | - $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION |
|
89 | - $this->option_modereg = 0; // Affiche mode reglement |
|
90 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | - $this->option_credit_note = 0; // Support credit notes |
|
95 | - $this->option_freetext = 1; // Support add of a personalised text |
|
96 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
97 | - |
|
98 | - // Recupere emetteur |
|
99 | - $this->emetteur=$mysoc; |
|
100 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Return description of a module |
|
106 | - * |
|
107 | - * @param Translate $langs Lang object to use for output |
|
108 | - * @return string Description |
|
109 | - */ |
|
110 | - function info($langs) |
|
111 | - { |
|
112 | - global $conf,$langs; |
|
113 | - |
|
114 | - // Load translation files required by the page |
|
72 | + $this->db = $db; |
|
73 | + $this->name = "ODT templates"; |
|
74 | + $this->description = $langs->trans("DocumentModelOdt"); |
|
75 | + $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
76 | + |
|
77 | + // Dimension page pour format A4 |
|
78 | + $this->type = 'odt'; |
|
79 | + $this->page_largeur = 0; |
|
80 | + $this->page_hauteur = 0; |
|
81 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
82 | + $this->marge_gauche=0; |
|
83 | + $this->marge_droite=0; |
|
84 | + $this->marge_haute=0; |
|
85 | + $this->marge_basse=0; |
|
86 | + |
|
87 | + $this->option_logo = 1; // Affiche logo |
|
88 | + $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION |
|
89 | + $this->option_modereg = 0; // Affiche mode reglement |
|
90 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | + $this->option_credit_note = 0; // Support credit notes |
|
95 | + $this->option_freetext = 1; // Support add of a personalised text |
|
96 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
97 | + |
|
98 | + // Recupere emetteur |
|
99 | + $this->emetteur=$mysoc; |
|
100 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Return description of a module |
|
106 | + * |
|
107 | + * @param Translate $langs Lang object to use for output |
|
108 | + * @return string Description |
|
109 | + */ |
|
110 | + function info($langs) |
|
111 | + { |
|
112 | + global $conf,$langs; |
|
113 | + |
|
114 | + // Load translation files required by the page |
|
115 | 115 | $langs->loadLangs(array('companies', 'errors')); |
116 | 116 | |
117 | - $form = new Form($this->db); |
|
118 | - |
|
119 | - $texte = $this->description.".<br>\n"; |
|
120 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">'; |
|
121 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | - $texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">'; |
|
124 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
125 | - |
|
126 | - // List of directories area |
|
127 | - $texte.= '<tr><td>'; |
|
128 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
129 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); |
|
130 | - $listoffiles=array(); |
|
131 | - foreach($listofdir as $key=>$tmpdir) |
|
132 | - { |
|
133 | - $tmpdir=trim($tmpdir); |
|
134 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
135 | - if (! $tmpdir) { |
|
136 | - unset($listofdir[$key]); continue; |
|
137 | - } |
|
138 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
139 | - else |
|
140 | - { |
|
141 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
142 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
143 | - } |
|
144 | - } |
|
145 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
146 | - // Add list of substitution keys |
|
147 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
148 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
149 | - |
|
150 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
151 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
152 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
153 | - $texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH; |
|
154 | - $texte.= '</textarea>'; |
|
155 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
156 | - $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">'; |
|
157 | - $texte.= '<br></div></div>'; |
|
158 | - |
|
159 | - // Scan directories |
|
160 | - if (count($listofdir)) |
|
161 | - { |
|
162 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; |
|
163 | - } |
|
164 | - |
|
165 | - // Add select to upload a new template file. TODO Copy this feature on other admin pages. |
|
166 | - $texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; |
|
167 | - $texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
|
168 | - $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; |
|
117 | + $form = new Form($this->db); |
|
118 | + |
|
119 | + $texte = $this->description.".<br>\n"; |
|
120 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">'; |
|
121 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | + $texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">'; |
|
124 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
125 | + |
|
126 | + // List of directories area |
|
127 | + $texte.= '<tr><td>'; |
|
128 | + $texttitle=$langs->trans("ListOfDirectories"); |
|
129 | + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); |
|
130 | + $listoffiles=array(); |
|
131 | + foreach($listofdir as $key=>$tmpdir) |
|
132 | + { |
|
133 | + $tmpdir=trim($tmpdir); |
|
134 | + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
135 | + if (! $tmpdir) { |
|
136 | + unset($listofdir[$key]); continue; |
|
137 | + } |
|
138 | + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
139 | + else |
|
140 | + { |
|
141 | + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
142 | + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
143 | + } |
|
144 | + } |
|
145 | + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
146 | + // Add list of substitution keys |
|
147 | + $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
148 | + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
149 | + |
|
150 | + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
151 | + $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
152 | + $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
153 | + $texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH; |
|
154 | + $texte.= '</textarea>'; |
|
155 | + $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
156 | + $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">'; |
|
157 | + $texte.= '<br></div></div>'; |
|
158 | + |
|
159 | + // Scan directories |
|
160 | + if (count($listofdir)) |
|
161 | + { |
|
162 | + $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; |
|
163 | + } |
|
164 | + |
|
165 | + // Add select to upload a new template file. TODO Copy this feature on other admin pages. |
|
166 | + $texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; |
|
167 | + $texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
|
168 | + $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; |
|
169 | 169 | $texte.= '</div>'; |
170 | 170 | |
171 | - $texte.= '</td>'; |
|
171 | + $texte.= '</td>'; |
|
172 | 172 | |
173 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
174 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
175 | - $texte.= '</td>'; |
|
176 | - $texte.= '</tr>'; |
|
173 | + $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
174 | + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
175 | + $texte.= '</td>'; |
|
176 | + $texte.= '</tr>'; |
|
177 | 177 | |
178 | - $texte.= '</table>'; |
|
179 | - $texte.= '</form>'; |
|
178 | + $texte.= '</table>'; |
|
179 | + $texte.= '</form>'; |
|
180 | 180 | |
181 | - return $texte; |
|
182 | - } |
|
181 | + return $texte; |
|
182 | + } |
|
183 | 183 | |
184 | 184 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
185 | - /** |
|
186 | - * Function to build a document on disk using the generic odt module. |
|
187 | - * |
|
188 | - * @param Contract $object Object source to build document |
|
189 | - * @param Translate $outputlangs Lang output object |
|
190 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
191 | - * @param int $hidedetails Do not show line details |
|
192 | - * @param int $hidedesc Do not show desc |
|
193 | - * @param int $hideref Do not show ref |
|
194 | - * @return int 1 if OK, <=0 if KO |
|
195 | - */ |
|
196 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
197 | - { |
|
185 | + /** |
|
186 | + * Function to build a document on disk using the generic odt module. |
|
187 | + * |
|
188 | + * @param Contract $object Object source to build document |
|
189 | + * @param Translate $outputlangs Lang output object |
|
190 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
191 | + * @param int $hidedetails Do not show line details |
|
192 | + * @param int $hidedesc Do not show desc |
|
193 | + * @param int $hideref Do not show ref |
|
194 | + * @return int 1 if OK, <=0 if KO |
|
195 | + */ |
|
196 | + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
197 | + { |
|
198 | 198 | // phpcs:enable |
199 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
200 | - |
|
201 | - if (empty($srctemplatepath)) |
|
202 | - { |
|
203 | - dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
204 | - return -1; |
|
205 | - } |
|
206 | - |
|
207 | - // Add odtgeneration hook |
|
208 | - if (! is_object($hookmanager)) |
|
209 | - { |
|
210 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
211 | - $hookmanager=new HookManager($this->db); |
|
212 | - } |
|
213 | - $hookmanager->initHooks(array('odtgeneration')); |
|
214 | - global $action; |
|
215 | - |
|
216 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | - $sav_charset_output=$outputlangs->charset_output; |
|
218 | - $outputlangs->charset_output='UTF-8'; |
|
219 | - |
|
220 | - // Load traductions files requiredby by page |
|
221 | - $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); |
|
222 | - |
|
223 | - if ($conf->contrat->dir_output) |
|
224 | - { |
|
225 | - // If $object is id instead of object |
|
226 | - if (! is_object($object)) |
|
227 | - { |
|
228 | - $id = $object; |
|
229 | - $object = new Contrat($this->db); |
|
230 | - $result=$object->fetch($id); |
|
231 | - if ($result < 0) |
|
232 | - { |
|
233 | - dol_print_error($this->db,$object->error); |
|
234 | - return -1; |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - $dir = $conf->contrat->dir_output; |
|
239 | - $objectref = dol_sanitizeFileName($object->ref); |
|
240 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
241 | - $file = $dir . "/" . $objectref . ".odt"; |
|
242 | - |
|
243 | - if (! file_exists($dir)) |
|
244 | - { |
|
245 | - if (dol_mkdir($dir) < 0) |
|
246 | - { |
|
247 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
248 | - return -1; |
|
249 | - } |
|
250 | - } |
|
251 | - |
|
252 | - if (file_exists($dir)) |
|
253 | - { |
|
254 | - //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
255 | - $newfile=basename($srctemplatepath); |
|
256 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
257 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
258 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
259 | - |
|
260 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
261 | - |
|
262 | - // Get extension (ods or odt) |
|
263 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
264 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
265 | - { |
|
266 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
267 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
268 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
269 | - } |
|
270 | - else |
|
271 | - { |
|
272 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
273 | - } |
|
274 | - $file=$dir.'/'.$filename; |
|
275 | - //print "newdir=".$dir; |
|
276 | - //print "newfile=".$newfile; |
|
277 | - //print "file=".$file; |
|
278 | - //print "conf->contrat->dir_temp=".$conf->contrat->dir_temp; |
|
279 | - |
|
280 | - dol_mkdir($conf->contrat->dir_temp); |
|
281 | - |
|
282 | - |
|
283 | - // If CUSTOMER contact defined on contract, we use it |
|
284 | - $usecontact=false; |
|
285 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
286 | - if (count($arrayidcontact) > 0) |
|
287 | - { |
|
288 | - $usecontact=true; |
|
289 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
290 | - } |
|
291 | - |
|
292 | - // Recipient name |
|
293 | - $contactobject=null; |
|
294 | - if (! empty($usecontact)) |
|
295 | - { |
|
296 | - // On peut utiliser le nom de la societe du contact |
|
297 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
298 | - else { |
|
299 | - $socobject = $object->thirdparty; |
|
300 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
301 | - $contactobject = $object->contact; |
|
302 | - } |
|
303 | - } |
|
304 | - else |
|
305 | - { |
|
306 | - $socobject=$object->thirdparty; |
|
307 | - } |
|
308 | - |
|
309 | - $object->fetch_optionals(); |
|
310 | - |
|
311 | - |
|
312 | - // Define substitution array |
|
313 | - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
314 | - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
315 | - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object |
|
316 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
317 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
318 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
319 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
320 | - // retrieve contact information for use in order as contact_xxx tags |
|
321 | - $array_thirdparty_contact = array(); |
|
322 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
323 | - |
|
324 | - $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
|
325 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
326 | - |
|
327 | - $tmparray = $substitutionarray; |
|
328 | - |
|
329 | - // Call the ODTSubstitution hook |
|
330 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
331 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
332 | - |
|
333 | - // Line of free text |
|
334 | - $newfreetext=''; |
|
335 | - $paramfreetext='CONTRACT_FREE_TEXT'; |
|
336 | - if (! empty($conf->global->$paramfreetext)) |
|
337 | - { |
|
338 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - // Open and load template |
|
343 | - require_once ODTPHP_PATH.'odf.php'; |
|
344 | - try { |
|
345 | - $odfHandler = new odf( |
|
346 | - $srctemplatepath, |
|
347 | - array( |
|
348 | - 'PATH_TO_TMP' => $conf->contrat->dir_temp, |
|
349 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
350 | - 'DELIMITER_LEFT' => '{', |
|
351 | - 'DELIMITER_RIGHT' => '}' |
|
352 | - ) |
|
353 | - ); |
|
354 | - } |
|
355 | - catch(Exception $e) |
|
356 | - { |
|
357 | - $this->error=$e->getMessage(); |
|
358 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
359 | - return -1; |
|
360 | - } |
|
361 | - // After construction $odfHandler->contentXml contains content and |
|
362 | - // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
363 | - // [!-- BEGIN lines --]*[!-- END lines --] |
|
364 | - //print html_entity_decode($odfHandler->__toString()); |
|
365 | - //print exit; |
|
366 | - |
|
367 | - |
|
368 | - // Make substitutions into odt of freetext |
|
369 | - try { |
|
370 | - $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
371 | - } |
|
372 | - catch (OdfException $e) |
|
373 | - { |
|
374 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
375 | - } |
|
376 | - |
|
377 | - foreach($tmparray as $key=>$value) |
|
378 | - { |
|
379 | - try { |
|
380 | - if (preg_match('/logo$/',$key)) // Image |
|
381 | - { |
|
382 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
383 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
384 | - } |
|
385 | - else // Text |
|
386 | - { |
|
387 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
388 | - } |
|
389 | - } |
|
390 | - catch (OdfException $e) |
|
391 | - { |
|
199 | + global $user,$langs,$conf,$mysoc,$hookmanager; |
|
200 | + |
|
201 | + if (empty($srctemplatepath)) |
|
202 | + { |
|
203 | + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
204 | + return -1; |
|
205 | + } |
|
206 | + |
|
207 | + // Add odtgeneration hook |
|
208 | + if (! is_object($hookmanager)) |
|
209 | + { |
|
210 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
211 | + $hookmanager=new HookManager($this->db); |
|
212 | + } |
|
213 | + $hookmanager->initHooks(array('odtgeneration')); |
|
214 | + global $action; |
|
215 | + |
|
216 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | + $sav_charset_output=$outputlangs->charset_output; |
|
218 | + $outputlangs->charset_output='UTF-8'; |
|
219 | + |
|
220 | + // Load traductions files requiredby by page |
|
221 | + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); |
|
222 | + |
|
223 | + if ($conf->contrat->dir_output) |
|
224 | + { |
|
225 | + // If $object is id instead of object |
|
226 | + if (! is_object($object)) |
|
227 | + { |
|
228 | + $id = $object; |
|
229 | + $object = new Contrat($this->db); |
|
230 | + $result=$object->fetch($id); |
|
231 | + if ($result < 0) |
|
232 | + { |
|
233 | + dol_print_error($this->db,$object->error); |
|
234 | + return -1; |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + $dir = $conf->contrat->dir_output; |
|
239 | + $objectref = dol_sanitizeFileName($object->ref); |
|
240 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
241 | + $file = $dir . "/" . $objectref . ".odt"; |
|
242 | + |
|
243 | + if (! file_exists($dir)) |
|
244 | + { |
|
245 | + if (dol_mkdir($dir) < 0) |
|
246 | + { |
|
247 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
248 | + return -1; |
|
249 | + } |
|
250 | + } |
|
251 | + |
|
252 | + if (file_exists($dir)) |
|
253 | + { |
|
254 | + //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
255 | + $newfile=basename($srctemplatepath); |
|
256 | + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
257 | + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
258 | + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
259 | + |
|
260 | + $newfiletmp=$objectref.'_'.$newfiletmp; |
|
261 | + |
|
262 | + // Get extension (ods or odt) |
|
263 | + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
264 | + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
265 | + { |
|
266 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
267 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
268 | + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
269 | + } |
|
270 | + else |
|
271 | + { |
|
272 | + $filename=$newfiletmp.'.'.$newfileformat; |
|
273 | + } |
|
274 | + $file=$dir.'/'.$filename; |
|
275 | + //print "newdir=".$dir; |
|
276 | + //print "newfile=".$newfile; |
|
277 | + //print "file=".$file; |
|
278 | + //print "conf->contrat->dir_temp=".$conf->contrat->dir_temp; |
|
279 | + |
|
280 | + dol_mkdir($conf->contrat->dir_temp); |
|
281 | + |
|
282 | + |
|
283 | + // If CUSTOMER contact defined on contract, we use it |
|
284 | + $usecontact=false; |
|
285 | + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
286 | + if (count($arrayidcontact) > 0) |
|
287 | + { |
|
288 | + $usecontact=true; |
|
289 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
290 | + } |
|
291 | + |
|
292 | + // Recipient name |
|
293 | + $contactobject=null; |
|
294 | + if (! empty($usecontact)) |
|
295 | + { |
|
296 | + // On peut utiliser le nom de la societe du contact |
|
297 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
298 | + else { |
|
299 | + $socobject = $object->thirdparty; |
|
300 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
301 | + $contactobject = $object->contact; |
|
302 | + } |
|
303 | + } |
|
304 | + else |
|
305 | + { |
|
306 | + $socobject=$object->thirdparty; |
|
307 | + } |
|
308 | + |
|
309 | + $object->fetch_optionals(); |
|
310 | + |
|
311 | + |
|
312 | + // Define substitution array |
|
313 | + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
314 | + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
315 | + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object |
|
316 | + $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
317 | + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
318 | + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
319 | + $array_other=$this->get_substitutionarray_other($outputlangs); |
|
320 | + // retrieve contact information for use in order as contact_xxx tags |
|
321 | + $array_thirdparty_contact = array(); |
|
322 | + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
323 | + |
|
324 | + $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
|
325 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
326 | + |
|
327 | + $tmparray = $substitutionarray; |
|
328 | + |
|
329 | + // Call the ODTSubstitution hook |
|
330 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
331 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
332 | + |
|
333 | + // Line of free text |
|
334 | + $newfreetext=''; |
|
335 | + $paramfreetext='CONTRACT_FREE_TEXT'; |
|
336 | + if (! empty($conf->global->$paramfreetext)) |
|
337 | + { |
|
338 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + // Open and load template |
|
343 | + require_once ODTPHP_PATH.'odf.php'; |
|
344 | + try { |
|
345 | + $odfHandler = new odf( |
|
346 | + $srctemplatepath, |
|
347 | + array( |
|
348 | + 'PATH_TO_TMP' => $conf->contrat->dir_temp, |
|
349 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
350 | + 'DELIMITER_LEFT' => '{', |
|
351 | + 'DELIMITER_RIGHT' => '}' |
|
352 | + ) |
|
353 | + ); |
|
354 | + } |
|
355 | + catch(Exception $e) |
|
356 | + { |
|
357 | + $this->error=$e->getMessage(); |
|
358 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
359 | + return -1; |
|
360 | + } |
|
361 | + // After construction $odfHandler->contentXml contains content and |
|
362 | + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
363 | + // [!-- BEGIN lines --]*[!-- END lines --] |
|
364 | + //print html_entity_decode($odfHandler->__toString()); |
|
365 | + //print exit; |
|
366 | + |
|
367 | + |
|
368 | + // Make substitutions into odt of freetext |
|
369 | + try { |
|
370 | + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
371 | + } |
|
372 | + catch (OdfException $e) |
|
373 | + { |
|
374 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
375 | + } |
|
376 | + |
|
377 | + foreach($tmparray as $key=>$value) |
|
378 | + { |
|
379 | + try { |
|
380 | + if (preg_match('/logo$/',$key)) // Image |
|
381 | + { |
|
382 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
383 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
384 | + } |
|
385 | + else // Text |
|
386 | + { |
|
387 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
388 | + } |
|
389 | + } |
|
390 | + catch (OdfException $e) |
|
391 | + { |
|
392 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + // Replace tags of lines |
|
397 | + try |
|
398 | + { |
|
399 | + $foundtagforlines = 1; |
|
400 | + try { |
|
401 | + $listlines = $odfHandler->setSegment('lines'); |
|
402 | + } |
|
403 | + catch(OdfException $e) |
|
404 | + { |
|
405 | + // We may arrive here if tags for lines not present into template |
|
406 | + $foundtagforlines = 0; |
|
392 | 407 | dol_syslog($e->getMessage(), LOG_INFO); |
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - // Replace tags of lines |
|
397 | - try |
|
398 | - { |
|
399 | - $foundtagforlines = 1; |
|
400 | - try { |
|
401 | - $listlines = $odfHandler->setSegment('lines'); |
|
402 | - } |
|
403 | - catch(OdfException $e) |
|
404 | - { |
|
405 | - // We may arrive here if tags for lines not present into template |
|
406 | - $foundtagforlines = 0; |
|
407 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
408 | - } |
|
409 | - if ($foundtagforlines) |
|
410 | - { |
|
411 | - foreach ($object->lines as $line) |
|
412 | - { |
|
413 | - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
414 | - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
415 | - // Call the ODTSubstitutionLine hook |
|
416 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
417 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | - foreach($tmparray as $key => $val) |
|
419 | - { |
|
420 | - try |
|
421 | - { |
|
422 | - $listlines->setVars($key, $val, true, 'UTF-8'); |
|
423 | - } |
|
424 | - catch(OdfException $e) |
|
425 | - { |
|
426 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
427 | - } |
|
428 | - catch(SegmentException $e) |
|
429 | - { |
|
430 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
431 | - } |
|
432 | - } |
|
433 | - $listlines->merge(); |
|
434 | - } |
|
435 | - $odfHandler->mergeSegment($listlines); |
|
436 | - } |
|
437 | - } |
|
438 | - catch(OdfException $e) |
|
439 | - { |
|
440 | - $this->error=$e->getMessage(); |
|
441 | - dol_syslog($this->error, LOG_WARNING); |
|
442 | - return -1; |
|
443 | - } |
|
444 | - |
|
445 | - // Replace labels translated |
|
446 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
447 | - foreach($tmparray as $key=>$value) |
|
448 | - { |
|
449 | - try { |
|
450 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
451 | - } |
|
452 | - catch(OdfException $e) |
|
453 | - { |
|
408 | + } |
|
409 | + if ($foundtagforlines) |
|
410 | + { |
|
411 | + foreach ($object->lines as $line) |
|
412 | + { |
|
413 | + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
414 | + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
415 | + // Call the ODTSubstitutionLine hook |
|
416 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
417 | + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | + foreach($tmparray as $key => $val) |
|
419 | + { |
|
420 | + try |
|
421 | + { |
|
422 | + $listlines->setVars($key, $val, true, 'UTF-8'); |
|
423 | + } |
|
424 | + catch(OdfException $e) |
|
425 | + { |
|
426 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
427 | + } |
|
428 | + catch(SegmentException $e) |
|
429 | + { |
|
430 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
431 | + } |
|
432 | + } |
|
433 | + $listlines->merge(); |
|
434 | + } |
|
435 | + $odfHandler->mergeSegment($listlines); |
|
436 | + } |
|
437 | + } |
|
438 | + catch(OdfException $e) |
|
439 | + { |
|
440 | + $this->error=$e->getMessage(); |
|
441 | + dol_syslog($this->error, LOG_WARNING); |
|
442 | + return -1; |
|
443 | + } |
|
444 | + |
|
445 | + // Replace labels translated |
|
446 | + $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
447 | + foreach($tmparray as $key=>$value) |
|
448 | + { |
|
449 | + try { |
|
450 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
451 | + } |
|
452 | + catch(OdfException $e) |
|
453 | + { |
|
454 | 454 | dol_syslog($e->getMessage(), LOG_INFO); |
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - // Call the beforeODTSave hook |
|
459 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
460 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
461 | - |
|
462 | - // Write new file |
|
463 | - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
464 | - try { |
|
465 | - $odfHandler->exportAsAttachedPDF($file); |
|
466 | - } catch (Exception $e) { |
|
467 | - $this->error=$e->getMessage(); |
|
468 | - return -1; |
|
469 | - } |
|
470 | - } |
|
471 | - else { |
|
472 | - try { |
|
473 | - $odfHandler->saveToDisk($file); |
|
474 | - } catch (Exception $e) { |
|
475 | - $this->error=$e->getMessage(); |
|
476 | - return -1; |
|
477 | - } |
|
478 | - } |
|
479 | - |
|
480 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
481 | - |
|
482 | - if (! empty($conf->global->MAIN_UMASK)) |
|
483 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
484 | - |
|
485 | - $odfHandler=null; // Destroy object |
|
486 | - |
|
487 | - $this->result = array('fullpath'=>$file); |
|
488 | - |
|
489 | - return 1; // Success |
|
490 | - } |
|
491 | - else |
|
492 | - { |
|
493 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
494 | - return -1; |
|
495 | - } |
|
496 | - } |
|
497 | - |
|
498 | - return -1; |
|
499 | - } |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + // Call the beforeODTSave hook |
|
459 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
460 | + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
461 | + |
|
462 | + // Write new file |
|
463 | + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
464 | + try { |
|
465 | + $odfHandler->exportAsAttachedPDF($file); |
|
466 | + } catch (Exception $e) { |
|
467 | + $this->error=$e->getMessage(); |
|
468 | + return -1; |
|
469 | + } |
|
470 | + } |
|
471 | + else { |
|
472 | + try { |
|
473 | + $odfHandler->saveToDisk($file); |
|
474 | + } catch (Exception $e) { |
|
475 | + $this->error=$e->getMessage(); |
|
476 | + return -1; |
|
477 | + } |
|
478 | + } |
|
479 | + |
|
480 | + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
481 | + |
|
482 | + if (! empty($conf->global->MAIN_UMASK)) |
|
483 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
484 | + |
|
485 | + $odfHandler=null; // Destroy object |
|
486 | + |
|
487 | + $this->result = array('fullpath'=>$file); |
|
488 | + |
|
489 | + return 1; // Success |
|
490 | + } |
|
491 | + else |
|
492 | + { |
|
493 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
494 | + return -1; |
|
495 | + } |
|
496 | + } |
|
497 | + |
|
498 | + return -1; |
|
499 | + } |
|
500 | 500 | } |
@@ -67,37 +67,37 @@ discard block |
||
67 | 67 | global $conf, $langs, $mysoc; |
68 | 68 | |
69 | 69 | // Load translation files required by the page |
70 | - $langs->loadLangs(array("main","companies")); |
|
70 | + $langs->loadLangs(array("main", "companies")); |
|
71 | 71 | |
72 | 72 | $this->db = $db; |
73 | 73 | $this->name = "ODT templates"; |
74 | 74 | $this->description = $langs->trans("DocumentModelOdt"); |
75 | - $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
75 | + $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
76 | 76 | |
77 | 77 | // Dimension page pour format A4 |
78 | 78 | $this->type = 'odt'; |
79 | 79 | $this->page_largeur = 0; |
80 | 80 | $this->page_hauteur = 0; |
81 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
82 | - $this->marge_gauche=0; |
|
83 | - $this->marge_droite=0; |
|
84 | - $this->marge_haute=0; |
|
85 | - $this->marge_basse=0; |
|
86 | - |
|
87 | - $this->option_logo = 1; // Affiche logo |
|
88 | - $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION |
|
89 | - $this->option_modereg = 0; // Affiche mode reglement |
|
90 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | - $this->option_credit_note = 0; // Support credit notes |
|
95 | - $this->option_freetext = 1; // Support add of a personalised text |
|
96 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
82 | + $this->marge_gauche = 0; |
|
83 | + $this->marge_droite = 0; |
|
84 | + $this->marge_haute = 0; |
|
85 | + $this->marge_basse = 0; |
|
86 | + |
|
87 | + $this->option_logo = 1; // Affiche logo |
|
88 | + $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION |
|
89 | + $this->option_modereg = 0; // Affiche mode reglement |
|
90 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | + $this->option_credit_note = 0; // Support credit notes |
|
95 | + $this->option_freetext = 1; // Support add of a personalised text |
|
96 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
97 | 97 | |
98 | 98 | // Recupere emetteur |
99 | - $this->emetteur=$mysoc; |
|
100 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
99 | + $this->emetteur = $mysoc; |
|
100 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function info($langs) |
111 | 111 | { |
112 | - global $conf,$langs; |
|
112 | + global $conf, $langs; |
|
113 | 113 | |
114 | 114 | // Load translation files required by the page |
115 | 115 | $langs->loadLangs(array('companies', 'errors')); |
@@ -117,66 +117,66 @@ discard block |
||
117 | 117 | $form = new Form($this->db); |
118 | 118 | |
119 | 119 | $texte = $this->description.".<br>\n"; |
120 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">'; |
|
121 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | - $texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">'; |
|
124 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
120 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">'; |
|
121 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | + $texte .= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">'; |
|
124 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
125 | 125 | |
126 | 126 | // List of directories area |
127 | - $texte.= '<tr><td>'; |
|
128 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
129 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); |
|
130 | - $listoffiles=array(); |
|
131 | - foreach($listofdir as $key=>$tmpdir) |
|
127 | + $texte .= '<tr><td>'; |
|
128 | + $texttitle = $langs->trans("ListOfDirectories"); |
|
129 | + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); |
|
130 | + $listoffiles = array(); |
|
131 | + foreach ($listofdir as $key=>$tmpdir) |
|
132 | 132 | { |
133 | - $tmpdir=trim($tmpdir); |
|
134 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
135 | - if (! $tmpdir) { |
|
133 | + $tmpdir = trim($tmpdir); |
|
134 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
135 | + if (!$tmpdir) { |
|
136 | 136 | unset($listofdir[$key]); continue; |
137 | 137 | } |
138 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
138 | + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); |
|
139 | 139 | else |
140 | 140 | { |
141 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
142 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
141 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); |
|
142 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
143 | 143 | } |
144 | 144 | } |
145 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
145 | + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); |
|
146 | 146 | // Add list of substitution keys |
147 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
148 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
149 | - |
|
150 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
151 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
152 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
153 | - $texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH; |
|
154 | - $texte.= '</textarea>'; |
|
155 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
156 | - $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">'; |
|
157 | - $texte.= '<br></div></div>'; |
|
147 | + $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
148 | + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
149 | + |
|
150 | + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); |
|
151 | + $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
152 | + $texte .= '<textarea class="flat" cols="60" name="value1">'; |
|
153 | + $texte .= $conf->global->CONTRACT_ADDON_PDF_ODT_PATH; |
|
154 | + $texte .= '</textarea>'; |
|
155 | + $texte .= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
156 | + $texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">'; |
|
157 | + $texte .= '<br></div></div>'; |
|
158 | 158 | |
159 | 159 | // Scan directories |
160 | 160 | if (count($listofdir)) |
161 | 161 | { |
162 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; |
|
162 | + $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Add select to upload a new template file. TODO Copy this feature on other admin pages. |
166 | - $texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; |
|
167 | - $texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
|
168 | - $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; |
|
169 | - $texte.= '</div>'; |
|
166 | + $texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; |
|
167 | + $texte .= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
|
168 | + $texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; |
|
169 | + $texte .= '</div>'; |
|
170 | 170 | |
171 | - $texte.= '</td>'; |
|
171 | + $texte .= '</td>'; |
|
172 | 172 | |
173 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
174 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
175 | - $texte.= '</td>'; |
|
176 | - $texte.= '</tr>'; |
|
173 | + $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
174 | + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
175 | + $texte .= '</td>'; |
|
176 | + $texte .= '</tr>'; |
|
177 | 177 | |
178 | - $texte.= '</table>'; |
|
179 | - $texte.= '</form>'; |
|
178 | + $texte .= '</table>'; |
|
179 | + $texte .= '</form>'; |
|
180 | 180 | |
181 | 181 | return $texte; |
182 | 182 | } |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * @param int $hideref Do not show ref |
194 | 194 | * @return int 1 if OK, <=0 if KO |
195 | 195 | */ |
196 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
196 | + function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
197 | 197 | { |
198 | 198 | // phpcs:enable |
199 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
199 | + global $user, $langs, $conf, $mysoc, $hookmanager; |
|
200 | 200 | |
201 | 201 | if (empty($srctemplatepath)) |
202 | 202 | { |
@@ -205,17 +205,17 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // Add odtgeneration hook |
208 | - if (! is_object($hookmanager)) |
|
208 | + if (!is_object($hookmanager)) |
|
209 | 209 | { |
210 | 210 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
211 | - $hookmanager=new HookManager($this->db); |
|
211 | + $hookmanager = new HookManager($this->db); |
|
212 | 212 | } |
213 | 213 | $hookmanager->initHooks(array('odtgeneration')); |
214 | 214 | global $action; |
215 | 215 | |
216 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | - $sav_charset_output=$outputlangs->charset_output; |
|
218 | - $outputlangs->charset_output='UTF-8'; |
|
216 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
217 | + $sav_charset_output = $outputlangs->charset_output; |
|
218 | + $outputlangs->charset_output = 'UTF-8'; |
|
219 | 219 | |
220 | 220 | // Load traductions files requiredby by page |
221 | 221 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | if ($conf->contrat->dir_output) |
224 | 224 | { |
225 | 225 | // If $object is id instead of object |
226 | - if (! is_object($object)) |
|
226 | + if (!is_object($object)) |
|
227 | 227 | { |
228 | 228 | $id = $object; |
229 | 229 | $object = new Contrat($this->db); |
230 | - $result=$object->fetch($id); |
|
230 | + $result = $object->fetch($id); |
|
231 | 231 | if ($result < 0) |
232 | 232 | { |
233 | - dol_print_error($this->db,$object->error); |
|
233 | + dol_print_error($this->db, $object->error); |
|
234 | 234 | return -1; |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | 238 | $dir = $conf->contrat->dir_output; |
239 | 239 | $objectref = dol_sanitizeFileName($object->ref); |
240 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
241 | - $file = $dir . "/" . $objectref . ".odt"; |
|
240 | + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; |
|
241 | + $file = $dir."/".$objectref.".odt"; |
|
242 | 242 | |
243 | - if (! file_exists($dir)) |
|
243 | + if (!file_exists($dir)) |
|
244 | 244 | { |
245 | 245 | if (dol_mkdir($dir) < 0) |
246 | 246 | { |
247 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
247 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
248 | 248 | return -1; |
249 | 249 | } |
250 | 250 | } |
@@ -252,26 +252,26 @@ discard block |
||
252 | 252 | if (file_exists($dir)) |
253 | 253 | { |
254 | 254 | //print "srctemplatepath=".$srctemplatepath; // Src filename |
255 | - $newfile=basename($srctemplatepath); |
|
256 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
257 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
258 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
255 | + $newfile = basename($srctemplatepath); |
|
256 | + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); |
|
257 | + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
|
258 | + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
|
259 | 259 | |
260 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
260 | + $newfiletmp = $objectref.'_'.$newfiletmp; |
|
261 | 261 | |
262 | 262 | // Get extension (ods or odt) |
263 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
264 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
263 | + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); |
|
264 | + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
265 | 265 | { |
266 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
267 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
268 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
266 | + $format = $conf->global->MAIN_DOC_USE_TIMING; |
|
267 | + if ($format == '1') $format = '%Y%m%d%H%M%S'; |
|
268 | + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; |
|
269 | 269 | } |
270 | 270 | else |
271 | 271 | { |
272 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
272 | + $filename = $newfiletmp.'.'.$newfileformat; |
|
273 | 273 | } |
274 | - $file=$dir.'/'.$filename; |
|
274 | + $file = $dir.'/'.$filename; |
|
275 | 275 | //print "newdir=".$dir; |
276 | 276 | //print "newfile=".$newfile; |
277 | 277 | //print "file=".$file; |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | |
282 | 282 | |
283 | 283 | // If CUSTOMER contact defined on contract, we use it |
284 | - $usecontact=false; |
|
285 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
284 | + $usecontact = false; |
|
285 | + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); |
|
286 | 286 | if (count($arrayidcontact) > 0) |
287 | 287 | { |
288 | - $usecontact=true; |
|
289 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
288 | + $usecontact = true; |
|
289 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Recipient name |
293 | - $contactobject=null; |
|
294 | - if (! empty($usecontact)) |
|
293 | + $contactobject = null; |
|
294 | + if (!empty($usecontact)) |
|
295 | 295 | { |
296 | 296 | // On peut utiliser le nom de la societe du contact |
297 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
297 | + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
298 | 298 | else { |
299 | 299 | $socobject = $object->thirdparty; |
300 | 300 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | } |
304 | 304 | else |
305 | 305 | { |
306 | - $socobject=$object->thirdparty; |
|
306 | + $socobject = $object->thirdparty; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | $object->fetch_optionals(); |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | |
312 | 312 | // Define substitution array |
313 | 313 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
314 | - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
315 | - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object |
|
316 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
317 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
318 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
319 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
314 | + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
315 | + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object |
|
316 | + $array_user = $this->get_substitutionarray_user($user, $outputlangs); |
|
317 | + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); |
|
318 | + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); |
|
319 | + $array_other = $this->get_substitutionarray_other($outputlangs); |
|
320 | 320 | // retrieve contact information for use in order as contact_xxx tags |
321 | 321 | $array_thirdparty_contact = array(); |
322 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
322 | + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); |
|
323 | 323 | |
324 | - $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
|
324 | + $substitutionarray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); |
|
325 | 325 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
326 | 326 | |
327 | 327 | $tmparray = $substitutionarray; |
328 | 328 | |
329 | 329 | // Call the ODTSubstitution hook |
330 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
331 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
330 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
331 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
332 | 332 | |
333 | 333 | // Line of free text |
334 | - $newfreetext=''; |
|
335 | - $paramfreetext='CONTRACT_FREE_TEXT'; |
|
336 | - if (! empty($conf->global->$paramfreetext)) |
|
334 | + $newfreetext = ''; |
|
335 | + $paramfreetext = 'CONTRACT_FREE_TEXT'; |
|
336 | + if (!empty($conf->global->$paramfreetext)) |
|
337 | 337 | { |
338 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); |
|
338 | + $newfreetext = make_substitutions($conf->global->$paramfreetext, $tmparray); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | $srctemplatepath, |
347 | 347 | array( |
348 | 348 | 'PATH_TO_TMP' => $conf->contrat->dir_temp, |
349 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
349 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
350 | 350 | 'DELIMITER_LEFT' => '{', |
351 | 351 | 'DELIMITER_RIGHT' => '}' |
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | } |
355 | - catch(Exception $e) |
|
355 | + catch (Exception $e) |
|
356 | 356 | { |
357 | - $this->error=$e->getMessage(); |
|
357 | + $this->error = $e->getMessage(); |
|
358 | 358 | dol_syslog($e->getMessage(), LOG_INFO); |
359 | 359 | return -1; |
360 | 360 | } |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | dol_syslog($e->getMessage(), LOG_INFO); |
375 | 375 | } |
376 | 376 | |
377 | - foreach($tmparray as $key=>$value) |
|
377 | + foreach ($tmparray as $key=>$value) |
|
378 | 378 | { |
379 | 379 | try { |
380 | - if (preg_match('/logo$/',$key)) // Image |
|
380 | + if (preg_match('/logo$/', $key)) // Image |
|
381 | 381 | { |
382 | 382 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
383 | 383 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | try { |
401 | 401 | $listlines = $odfHandler->setSegment('lines'); |
402 | 402 | } |
403 | - catch(OdfException $e) |
|
403 | + catch (OdfException $e) |
|
404 | 404 | { |
405 | 405 | // We may arrive here if tags for lines not present into template |
406 | 406 | $foundtagforlines = 0; |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | { |
411 | 411 | foreach ($object->lines as $line) |
412 | 412 | { |
413 | - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
413 | + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); |
|
414 | 414 | complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
415 | 415 | // Call the ODTSubstitutionLine hook |
416 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
417 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | - foreach($tmparray as $key => $val) |
|
416 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); |
|
417 | + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
418 | + foreach ($tmparray as $key => $val) |
|
419 | 419 | { |
420 | 420 | try |
421 | 421 | { |
422 | 422 | $listlines->setVars($key, $val, true, 'UTF-8'); |
423 | 423 | } |
424 | - catch(OdfException $e) |
|
424 | + catch (OdfException $e) |
|
425 | 425 | { |
426 | 426 | dol_syslog($e->getMessage(), LOG_INFO); |
427 | 427 | } |
428 | - catch(SegmentException $e) |
|
428 | + catch (SegmentException $e) |
|
429 | 429 | { |
430 | 430 | dol_syslog($e->getMessage(), LOG_INFO); |
431 | 431 | } |
@@ -435,36 +435,36 @@ discard block |
||
435 | 435 | $odfHandler->mergeSegment($listlines); |
436 | 436 | } |
437 | 437 | } |
438 | - catch(OdfException $e) |
|
438 | + catch (OdfException $e) |
|
439 | 439 | { |
440 | - $this->error=$e->getMessage(); |
|
440 | + $this->error = $e->getMessage(); |
|
441 | 441 | dol_syslog($this->error, LOG_WARNING); |
442 | 442 | return -1; |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Replace labels translated |
446 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
447 | - foreach($tmparray as $key=>$value) |
|
446 | + $tmparray = $outputlangs->get_translations_for_substitutions(); |
|
447 | + foreach ($tmparray as $key=>$value) |
|
448 | 448 | { |
449 | 449 | try { |
450 | 450 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
451 | 451 | } |
452 | - catch(OdfException $e) |
|
452 | + catch (OdfException $e) |
|
453 | 453 | { |
454 | 454 | dol_syslog($e->getMessage(), LOG_INFO); |
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
458 | 458 | // Call the beforeODTSave hook |
459 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
460 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
459 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
460 | + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
461 | 461 | |
462 | 462 | // Write new file |
463 | 463 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
464 | 464 | try { |
465 | 465 | $odfHandler->exportAsAttachedPDF($file); |
466 | 466 | } catch (Exception $e) { |
467 | - $this->error=$e->getMessage(); |
|
467 | + $this->error = $e->getMessage(); |
|
468 | 468 | return -1; |
469 | 469 | } |
470 | 470 | } |
@@ -472,25 +472,25 @@ discard block |
||
472 | 472 | try { |
473 | 473 | $odfHandler->saveToDisk($file); |
474 | 474 | } catch (Exception $e) { |
475 | - $this->error=$e->getMessage(); |
|
475 | + $this->error = $e->getMessage(); |
|
476 | 476 | return -1; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
480 | + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
481 | 481 | |
482 | - if (! empty($conf->global->MAIN_UMASK)) |
|
482 | + if (!empty($conf->global->MAIN_UMASK)) |
|
483 | 483 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
484 | 484 | |
485 | - $odfHandler=null; // Destroy object |
|
485 | + $odfHandler = null; // Destroy object |
|
486 | 486 | |
487 | 487 | $this->result = array('fullpath'=>$file); |
488 | 488 | |
489 | - return 1; // Success |
|
489 | + return 1; // Success |
|
490 | 490 | } |
491 | 491 | else |
492 | 492 | { |
493 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
493 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
494 | 494 | return -1; |
495 | 495 | } |
496 | 496 | } |
@@ -97,7 +97,10 @@ discard block |
||
97 | 97 | |
98 | 98 | // Recupere emetteur |
99 | 99 | $this->emetteur=$mysoc; |
100 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
100 | + if (! $this->emetteur->country_code) { |
|
101 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
102 | + } |
|
103 | + // By default if not defined |
|
101 | 104 | } |
102 | 105 | |
103 | 106 | |
@@ -135,11 +138,14 @@ discard block |
||
135 | 138 | if (! $tmpdir) { |
136 | 139 | unset($listofdir[$key]); continue; |
137 | 140 | } |
138 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
139 | - else |
|
141 | + if (! is_dir($tmpdir)) { |
|
142 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
143 | + } else |
|
140 | 144 | { |
141 | 145 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
142 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
146 | + if (count($tmpfiles)) { |
|
147 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
148 | + } |
|
143 | 149 | } |
144 | 150 | } |
145 | 151 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -213,7 +219,9 @@ discard block |
||
213 | 219 | $hookmanager->initHooks(array('odtgeneration')); |
214 | 220 | global $action; |
215 | 221 | |
216 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
222 | + if (! is_object($outputlangs)) { |
|
223 | + $outputlangs=$langs; |
|
224 | + } |
|
217 | 225 | $sav_charset_output=$outputlangs->charset_output; |
218 | 226 | $outputlangs->charset_output='UTF-8'; |
219 | 227 | |
@@ -237,7 +245,9 @@ discard block |
||
237 | 245 | |
238 | 246 | $dir = $conf->contrat->dir_output; |
239 | 247 | $objectref = dol_sanitizeFileName($object->ref); |
240 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
248 | + if (! preg_match('/specimen/i',$objectref)) { |
|
249 | + $dir.= "/" . $objectref; |
|
250 | + } |
|
241 | 251 | $file = $dir . "/" . $objectref . ".odt"; |
242 | 252 | |
243 | 253 | if (! file_exists($dir)) |
@@ -264,10 +274,11 @@ discard block |
||
264 | 274 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
265 | 275 | { |
266 | 276 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
267 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
277 | + if ($format == '1') { |
|
278 | + $format='%Y%m%d%H%M%S'; |
|
279 | + } |
|
268 | 280 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
269 | - } |
|
270 | - else |
|
281 | + } else |
|
271 | 282 | { |
272 | 283 | $filename=$newfiletmp.'.'.$newfileformat; |
273 | 284 | } |
@@ -294,14 +305,14 @@ discard block |
||
294 | 305 | if (! empty($usecontact)) |
295 | 306 | { |
296 | 307 | // On peut utiliser le nom de la societe du contact |
297 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
298 | - else { |
|
308 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
309 | + $socobject = $object->contact; |
|
310 | + } else { |
|
299 | 311 | $socobject = $object->thirdparty; |
300 | 312 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
301 | 313 | $contactobject = $object->contact; |
302 | 314 | } |
303 | - } |
|
304 | - else |
|
315 | + } else |
|
305 | 316 | { |
306 | 317 | $socobject=$object->thirdparty; |
307 | 318 | } |
@@ -319,7 +330,9 @@ discard block |
||
319 | 330 | $array_other=$this->get_substitutionarray_other($outputlangs); |
320 | 331 | // retrieve contact information for use in order as contact_xxx tags |
321 | 332 | $array_thirdparty_contact = array(); |
322 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
333 | + if ($usecontact && is_object($contactobject)) { |
|
334 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
335 | + } |
|
323 | 336 | |
324 | 337 | $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
325 | 338 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
@@ -351,8 +364,7 @@ discard block |
||
351 | 364 | 'DELIMITER_RIGHT' => '}' |
352 | 365 | ) |
353 | 366 | ); |
354 | - } |
|
355 | - catch(Exception $e) |
|
367 | + } catch(Exception $e) |
|
356 | 368 | { |
357 | 369 | $this->error=$e->getMessage(); |
358 | 370 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -368,8 +380,7 @@ discard block |
||
368 | 380 | // Make substitutions into odt of freetext |
369 | 381 | try { |
370 | 382 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
371 | - } |
|
372 | - catch (OdfException $e) |
|
383 | + } catch (OdfException $e) |
|
373 | 384 | { |
374 | 385 | dol_syslog($e->getMessage(), LOG_INFO); |
375 | 386 | } |
@@ -377,17 +388,18 @@ discard block |
||
377 | 388 | foreach($tmparray as $key=>$value) |
378 | 389 | { |
379 | 390 | try { |
380 | - if (preg_match('/logo$/',$key)) // Image |
|
391 | + if (preg_match('/logo$/',$key)) { |
|
392 | + // Image |
|
381 | 393 | { |
382 | 394 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
383 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
384 | - } |
|
385 | - else // Text |
|
395 | + } else { |
|
396 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
397 | + } |
|
398 | + } else // Text |
|
386 | 399 | { |
387 | 400 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
388 | 401 | } |
389 | - } |
|
390 | - catch (OdfException $e) |
|
402 | + } catch (OdfException $e) |
|
391 | 403 | { |
392 | 404 | dol_syslog($e->getMessage(), LOG_INFO); |
393 | 405 | } |
@@ -399,8 +411,7 @@ discard block |
||
399 | 411 | $foundtagforlines = 1; |
400 | 412 | try { |
401 | 413 | $listlines = $odfHandler->setSegment('lines'); |
402 | - } |
|
403 | - catch(OdfException $e) |
|
414 | + } catch(OdfException $e) |
|
404 | 415 | { |
405 | 416 | // We may arrive here if tags for lines not present into template |
406 | 417 | $foundtagforlines = 0; |
@@ -420,12 +431,10 @@ discard block |
||
420 | 431 | try |
421 | 432 | { |
422 | 433 | $listlines->setVars($key, $val, true, 'UTF-8'); |
423 | - } |
|
424 | - catch(OdfException $e) |
|
434 | + } catch(OdfException $e) |
|
425 | 435 | { |
426 | 436 | dol_syslog($e->getMessage(), LOG_INFO); |
427 | - } |
|
428 | - catch(SegmentException $e) |
|
437 | + } catch(SegmentException $e) |
|
429 | 438 | { |
430 | 439 | dol_syslog($e->getMessage(), LOG_INFO); |
431 | 440 | } |
@@ -434,8 +443,7 @@ discard block |
||
434 | 443 | } |
435 | 444 | $odfHandler->mergeSegment($listlines); |
436 | 445 | } |
437 | - } |
|
438 | - catch(OdfException $e) |
|
446 | + } catch(OdfException $e) |
|
439 | 447 | { |
440 | 448 | $this->error=$e->getMessage(); |
441 | 449 | dol_syslog($this->error, LOG_WARNING); |
@@ -448,8 +456,7 @@ discard block |
||
448 | 456 | { |
449 | 457 | try { |
450 | 458 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
451 | - } |
|
452 | - catch(OdfException $e) |
|
459 | + } catch(OdfException $e) |
|
453 | 460 | { |
454 | 461 | dol_syslog($e->getMessage(), LOG_INFO); |
455 | 462 | } |
@@ -467,8 +474,7 @@ discard block |
||
467 | 474 | $this->error=$e->getMessage(); |
468 | 475 | return -1; |
469 | 476 | } |
470 | - } |
|
471 | - else { |
|
477 | + } else { |
|
472 | 478 | try { |
473 | 479 | $odfHandler->saveToDisk($file); |
474 | 480 | } catch (Exception $e) { |
@@ -479,16 +485,16 @@ discard block |
||
479 | 485 | |
480 | 486 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
481 | 487 | |
482 | - if (! empty($conf->global->MAIN_UMASK)) |
|
483 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
488 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
489 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
490 | + } |
|
484 | 491 | |
485 | 492 | $odfHandler=null; // Destroy object |
486 | 493 | |
487 | 494 | $this->result = array('fullpath'=>$file); |
488 | 495 | |
489 | 496 | return 1; // Success |
490 | - } |
|
491 | - else |
|
497 | + } else |
|
492 | 498 | { |
493 | 499 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
494 | 500 | return -1; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering |
30 | 30 | */ |
31 | 31 | |
32 | - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
32 | + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | */ |
38 | 38 | abstract class ModelePDFContract extends CommonDocGenerator |
39 | 39 | { |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | 45 | |
46 | 46 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
47 | - /** |
|
48 | - * Return list of active generation modules |
|
49 | - * |
|
47 | + /** |
|
48 | + * Return list of active generation modules |
|
49 | + * |
|
50 | 50 | * @param DoliDB $db Database handler |
51 | 51 | * @param integer $maxfilenamelength Max length of value to show |
52 | 52 | * @return array List of templates |
53 | - */ |
|
54 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
55 | - { |
|
53 | + */ |
|
54 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
55 | + { |
|
56 | 56 | // phpcs:enable |
57 | - global $conf; |
|
57 | + global $conf; |
|
58 | 58 | |
59 | - $type='contract'; |
|
60 | - $liste=array(); |
|
59 | + $type='contract'; |
|
60 | + $liste=array(); |
|
61 | 61 | |
62 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
63 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
62 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
63 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
64 | 64 | |
65 | - return $liste; |
|
66 | - } |
|
65 | + return $liste; |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -72,82 +72,82 @@ discard block |
||
72 | 72 | */ |
73 | 73 | class ModelNumRefContracts |
74 | 74 | { |
75 | - /** |
|
76 | - * @var string Error code (or message) |
|
77 | - */ |
|
78 | - public $error=''; |
|
79 | - |
|
80 | - /** |
|
81 | - * Return if a module can be used or not |
|
82 | - * |
|
83 | - * @return boolean true if module can be used |
|
84 | - */ |
|
85 | - function isEnabled() |
|
86 | - { |
|
87 | - return true; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Return default description of numbering model |
|
92 | - * |
|
93 | - * @return string text description |
|
94 | - */ |
|
95 | - function info() |
|
96 | - { |
|
97 | - global $langs; |
|
98 | - $langs->load("contracts"); |
|
99 | - return $langs->trans("NoDescription"); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Return numbering example |
|
104 | - * |
|
105 | - * @return string Example |
|
106 | - */ |
|
107 | - function getExample() |
|
108 | - { |
|
109 | - global $langs; |
|
110 | - $langs->load("contracts"); |
|
111 | - return $langs->trans("NoExample"); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Test if existing numbers make problems with numbering |
|
116 | - * |
|
117 | - * @return boolean false if conflict, true if ok |
|
118 | - */ |
|
119 | - function canBeActivated() |
|
120 | - { |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Return next value |
|
126 | - * |
|
127 | - * @param Societe $objsoc third party object |
|
128 | - * @param Object $contract contract object |
|
129 | - * @return string Value |
|
130 | - */ |
|
131 | - function getNextValue($objsoc, $contract) |
|
132 | - { |
|
133 | - global $langs; |
|
134 | - return $langs->trans("NotAvailable"); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Return numbering version module |
|
139 | - * |
|
140 | - * @return string Value |
|
141 | - */ |
|
142 | - function getVersion() |
|
143 | - { |
|
144 | - global $langs; |
|
145 | - $langs->load("admin"); |
|
146 | - |
|
147 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
148 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
149 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
150 | - if ($this->version) return $this->version; |
|
151 | - return $langs->trans("NotAvailable"); |
|
152 | - } |
|
75 | + /** |
|
76 | + * @var string Error code (or message) |
|
77 | + */ |
|
78 | + public $error=''; |
|
79 | + |
|
80 | + /** |
|
81 | + * Return if a module can be used or not |
|
82 | + * |
|
83 | + * @return boolean true if module can be used |
|
84 | + */ |
|
85 | + function isEnabled() |
|
86 | + { |
|
87 | + return true; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Return default description of numbering model |
|
92 | + * |
|
93 | + * @return string text description |
|
94 | + */ |
|
95 | + function info() |
|
96 | + { |
|
97 | + global $langs; |
|
98 | + $langs->load("contracts"); |
|
99 | + return $langs->trans("NoDescription"); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Return numbering example |
|
104 | + * |
|
105 | + * @return string Example |
|
106 | + */ |
|
107 | + function getExample() |
|
108 | + { |
|
109 | + global $langs; |
|
110 | + $langs->load("contracts"); |
|
111 | + return $langs->trans("NoExample"); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Test if existing numbers make problems with numbering |
|
116 | + * |
|
117 | + * @return boolean false if conflict, true if ok |
|
118 | + */ |
|
119 | + function canBeActivated() |
|
120 | + { |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Return next value |
|
126 | + * |
|
127 | + * @param Societe $objsoc third party object |
|
128 | + * @param Object $contract contract object |
|
129 | + * @return string Value |
|
130 | + */ |
|
131 | + function getNextValue($objsoc, $contract) |
|
132 | + { |
|
133 | + global $langs; |
|
134 | + return $langs->trans("NotAvailable"); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Return numbering version module |
|
139 | + * |
|
140 | + * @return string Value |
|
141 | + */ |
|
142 | + function getVersion() |
|
143 | + { |
|
144 | + global $langs; |
|
145 | + $langs->load("admin"); |
|
146 | + |
|
147 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
148 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
149 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
150 | + if ($this->version) return $this->version; |
|
151 | + return $langs->trans("NotAvailable"); |
|
152 | + } |
|
153 | 153 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | |
46 | 46 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | * @param integer $maxfilenamelength Max length of value to show |
52 | 52 | * @return array List of templates |
53 | 53 | */ |
54 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
54 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
55 | 55 | { |
56 | 56 | // phpcs:enable |
57 | 57 | global $conf; |
58 | 58 | |
59 | - $type='contract'; |
|
60 | - $liste=array(); |
|
59 | + $type = 'contract'; |
|
60 | + $liste = array(); |
|
61 | 61 | |
62 | 62 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
63 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
63 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
64 | 64 | |
65 | 65 | return $liste; |
66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @var string Error code (or message) |
77 | 77 | */ |
78 | - public $error=''; |
|
78 | + public $error = ''; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Return if a module can be used or not |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |
@@ -29,122 +29,122 @@ |
||
29 | 29 | */ |
30 | 30 | class mod_contract_magre extends ModelNumRefContracts |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string Error message |
|
40 | - */ |
|
41 | - public $error = ''; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string nom |
|
45 | - * @deprecated |
|
46 | - * @see name |
|
47 | - */ |
|
48 | - public $nom='Magre'; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string name |
|
52 | - */ |
|
53 | - public $name='Magre'; |
|
54 | - |
|
55 | - public $code_auto=1; |
|
56 | - |
|
57 | - /** |
|
58 | - * Return default description of numbering model |
|
59 | - * |
|
60 | - * @return string text description |
|
61 | - */ |
|
62 | - function info() |
|
36 | + public $version = 'dolibarr'; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string Error message |
|
40 | + */ |
|
41 | + public $error = ''; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string nom |
|
45 | + * @deprecated |
|
46 | + * @see name |
|
47 | + */ |
|
48 | + public $nom='Magre'; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string name |
|
52 | + */ |
|
53 | + public $name='Magre'; |
|
54 | + |
|
55 | + public $code_auto=1; |
|
56 | + |
|
57 | + /** |
|
58 | + * Return default description of numbering model |
|
59 | + * |
|
60 | + * @return string text description |
|
61 | + */ |
|
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="maskconstcontract" value="CONTRACT_MAGRE_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="maskconstcontract" value="CONTRACT_MAGRE_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
78 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
84 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
86 | - $texte.= '</tr>'; |
|
87 | - $texte.= '</table>'; |
|
88 | - $texte.= '</form>'; |
|
83 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
84 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
86 | + $texte.= '</tr>'; |
|
87 | + $texte.= '</table>'; |
|
88 | + $texte.= '</form>'; |
|
89 | 89 | |
90 | - return $texte; |
|
90 | + return $texte; |
|
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Return numbering example |
|
95 | - * |
|
96 | - * @return string Example |
|
97 | - */ |
|
93 | + /** |
|
94 | + * Return numbering example |
|
95 | + * |
|
96 | + * @return string Example |
|
97 | + */ |
|
98 | 98 | function getExample() |
99 | 99 | { |
100 | - global $conf,$langs,$mysoc; |
|
101 | - |
|
102 | - $old_code_client=$mysoc->code_client; |
|
103 | - $mysoc->code_client='CCCCCCCCCC'; |
|
104 | - $numExample = $this->getNextValue($mysoc,''); |
|
105 | - $mysoc->code_client=$old_code_client; |
|
106 | - |
|
107 | - if (! $numExample) |
|
108 | - { |
|
109 | - $numExample = $langs->trans('NotConfigured'); |
|
110 | - } |
|
111 | - return $numExample; |
|
100 | + global $conf,$langs,$mysoc; |
|
101 | + |
|
102 | + $old_code_client=$mysoc->code_client; |
|
103 | + $mysoc->code_client='CCCCCCCCCC'; |
|
104 | + $numExample = $this->getNextValue($mysoc,''); |
|
105 | + $mysoc->code_client=$old_code_client; |
|
106 | + |
|
107 | + if (! $numExample) |
|
108 | + { |
|
109 | + $numExample = $langs->trans('NotConfigured'); |
|
110 | + } |
|
111 | + return $numExample; |
|
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Return next value |
|
116 | - * |
|
117 | - * @param Societe $objsoc third party object |
|
118 | - * @param Object $contract contract object |
|
119 | - * @return string Value if OK, 0 if KO |
|
120 | - */ |
|
114 | + /** |
|
115 | + * Return next value |
|
116 | + * |
|
117 | + * @param Societe $objsoc third party object |
|
118 | + * @param Object $contract contract object |
|
119 | + * @return string Value if OK, 0 if KO |
|
120 | + */ |
|
121 | 121 | function getNextValue($objsoc,$contract) |
122 | 122 | { |
123 | - global $db,$conf; |
|
123 | + global $db,$conf; |
|
124 | 124 | |
125 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
125 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
126 | 126 | |
127 | - $mask=$conf->global->CONTRACT_MAGRE_MASK; |
|
127 | + $mask=$conf->global->CONTRACT_MAGRE_MASK; |
|
128 | 128 | |
129 | - if (! $mask) |
|
130 | - { |
|
131 | - $this->error='NotConfigured'; |
|
132 | - return 0; |
|
133 | - } |
|
129 | + if (! $mask) |
|
130 | + { |
|
131 | + $this->error='NotConfigured'; |
|
132 | + return 0; |
|
133 | + } |
|
134 | 134 | |
135 | - $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat); |
|
135 | + $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat); |
|
136 | 136 | |
137 | - return $numFinal; |
|
138 | - } |
|
137 | + return $numFinal; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
141 | - /** |
|
142 | - * Return next value |
|
143 | - * |
|
144 | - * @param Societe $objsoc third party object |
|
145 | - * @param Object $objforref contract object |
|
146 | - * @return string Value if OK, 0 if KO |
|
147 | - */ |
|
141 | + /** |
|
142 | + * Return next value |
|
143 | + * |
|
144 | + * @param Societe $objsoc third party object |
|
145 | + * @param Object $objforref contract object |
|
146 | + * @return string Value if OK, 0 if KO |
|
147 | + */ |
|
148 | 148 | function contract_get_num($objsoc,$objforref) |
149 | 149 | { |
150 | 150 | // phpcs:enable |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File of class to manage contract numbering rules Magre |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage contract numbering rules Magre |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @deprecated |
46 | 46 | * @see name |
47 | 47 | */ |
48 | - public $nom='Magre'; |
|
48 | + public $nom = 'Magre'; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @var string name |
52 | 52 | */ |
53 | - public $name='Magre'; |
|
53 | + public $name = 'Magre'; |
|
54 | 54 | |
55 | - public $code_auto=1; |
|
55 | + public $code_auto = 1; |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Return default description of numbering model |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function info() |
63 | 63 | { |
64 | - global $conf,$langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | 66 | $langs->load("bills"); |
67 | 67 | |
68 | 68 | $form = new Form($this->db); |
69 | 69 | |
70 | 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="maskconstcontract" value="CONTRACT_MAGRE_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | - |
|
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | - |
|
83 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
84 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
86 | - $texte.= '</tr>'; |
|
87 | - $texte.= '</table>'; |
|
88 | - $texte.= '</form>'; |
|
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="maskconstcontract" value="CONTRACT_MAGRE_MASK">'; |
|
75 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
76 | + |
|
77 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); |
|
78 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
82 | + |
|
83 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
84 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
85 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
86 | + $texte .= '</tr>'; |
|
87 | + $texte .= '</table>'; |
|
88 | + $texte .= '</form>'; |
|
89 | 89 | |
90 | 90 | return $texte; |
91 | 91 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function getExample() |
99 | 99 | { |
100 | - global $conf,$langs,$mysoc; |
|
100 | + global $conf, $langs, $mysoc; |
|
101 | 101 | |
102 | - $old_code_client=$mysoc->code_client; |
|
103 | - $mysoc->code_client='CCCCCCCCCC'; |
|
104 | - $numExample = $this->getNextValue($mysoc,''); |
|
105 | - $mysoc->code_client=$old_code_client; |
|
102 | + $old_code_client = $mysoc->code_client; |
|
103 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
104 | + $numExample = $this->getNextValue($mysoc, ''); |
|
105 | + $mysoc->code_client = $old_code_client; |
|
106 | 106 | |
107 | - if (! $numExample) |
|
107 | + if (!$numExample) |
|
108 | 108 | { |
109 | 109 | $numExample = $langs->trans('NotConfigured'); |
110 | 110 | } |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | * @param Object $contract contract object |
119 | 119 | * @return string Value if OK, 0 if KO |
120 | 120 | */ |
121 | - function getNextValue($objsoc,$contract) |
|
121 | + function getNextValue($objsoc, $contract) |
|
122 | 122 | { |
123 | - global $db,$conf; |
|
123 | + global $db, $conf; |
|
124 | 124 | |
125 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
125 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
126 | 126 | |
127 | - $mask=$conf->global->CONTRACT_MAGRE_MASK; |
|
127 | + $mask = $conf->global->CONTRACT_MAGRE_MASK; |
|
128 | 128 | |
129 | - if (! $mask) |
|
129 | + if (!$mask) |
|
130 | 130 | { |
131 | - $this->error='NotConfigured'; |
|
131 | + $this->error = 'NotConfigured'; |
|
132 | 132 | return 0; |
133 | 133 | } |
134 | 134 | |
135 | - $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat); |
|
135 | + $numFinal = get_next_value($db, $mask, 'contrat', 'ref', '', $objsoc, $contract->date_contrat); |
|
136 | 136 | |
137 | 137 | return $numFinal; |
138 | 138 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param Object $objforref contract object |
146 | 146 | * @return string Value if OK, 0 if KO |
147 | 147 | */ |
148 | - function contract_get_num($objsoc,$objforref) |
|
148 | + function contract_get_num($objsoc, $objforref) |
|
149 | 149 | { |
150 | 150 | // phpcs:enable |
151 | - return $this->getNextValue($objsoc,$objforref); |
|
151 | + return $this->getNextValue($objsoc, $objforref); |
|
152 | 152 | } |
153 | 153 | } |
@@ -33,92 +33,92 @@ |
||
33 | 33 | class mod_contract_olive extends ModelNumRefContracts |
34 | 34 | { |
35 | 35 | /** |
36 | - * @var string Nom du modele |
|
37 | - * @deprecated |
|
38 | - * @see name |
|
39 | - */ |
|
40 | - public $nom='Olive'; |
|
36 | + * @var string Nom du modele |
|
37 | + * @deprecated |
|
38 | + * @see name |
|
39 | + */ |
|
40 | + public $nom='Olive'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var string model name |
|
44 | - */ |
|
45 | - public $name='Olive'; |
|
42 | + /** |
|
43 | + * @var string model name |
|
44 | + */ |
|
45 | + public $name='Olive'; |
|
46 | 46 | |
47 | - public $code_modifiable = 1; // Code modifiable |
|
47 | + public $code_modifiable = 1; // Code modifiable |
|
48 | 48 | |
49 | - public $code_modifiable_invalide = 1; // Code modifiable si il est invalide |
|
49 | + public $code_modifiable_invalide = 1; // Code modifiable si il est invalide |
|
50 | 50 | |
51 | - public $code_modifiable_null = 1; // Code modifiables si il est null |
|
51 | + public $code_modifiable_null = 1; // Code modifiables si il est null |
|
52 | 52 | |
53 | - public $code_null = 1; // Code facultatif |
|
53 | + public $code_null = 1; // Code facultatif |
|
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * Dolibarr version of the loaded document |
57 | 57 | * @public string |
58 | 58 | */ |
59 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | - |
|
61 | - public $code_auto = 0; // Numerotation automatique |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * Return description of module |
|
66 | - * |
|
67 | - * @return string Description of module |
|
68 | - */ |
|
69 | - function info() |
|
70 | - { |
|
71 | - global $langs; |
|
72 | - |
|
73 | - $langs->load("companies"); |
|
74 | - return $langs->trans("LeopardNumRefModelDesc"); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Return an example of result returned by getNextValue |
|
79 | - * |
|
80 | - * @param Societe $objsoc Object thirdparty |
|
81 | - * @param Contrat $contract Object contract |
|
82 | - * @return string Return next value |
|
83 | - */ |
|
84 | - function getNextValue($objsoc,$contract) |
|
85 | - { |
|
86 | - global $langs; |
|
87 | - return ''; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * Check validity of code according to its rules |
|
93 | - * |
|
94 | - * @param DoliDB $db Database handler |
|
95 | - * @param string $code Code to check/correct |
|
96 | - * @param Product $product Object product |
|
97 | - * @param int $type 0 = product , 1 = service |
|
98 | - * @return int 0 if OK |
|
99 | - * -1 ErrorBadProductCodeSyntax |
|
100 | - * -2 ErrorProductCodeRequired |
|
101 | - * -3 ErrorProductCodeAlreadyUsed |
|
102 | - * -4 ErrorPrefixRequired |
|
103 | - */ |
|
104 | - function verif($db, &$code, $product, $type) |
|
105 | - { |
|
106 | - global $conf; |
|
107 | - |
|
108 | - $result=0; |
|
109 | - $code = strtoupper(trim($code)); |
|
110 | - |
|
111 | - if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) |
|
112 | - { |
|
113 | - $result=0; |
|
114 | - } |
|
115 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) ) |
|
116 | - { |
|
117 | - $result=-2; |
|
118 | - } |
|
119 | - |
|
120 | - dol_syslog("mod_contract_olive::verif type=".$type." result=".$result); |
|
121 | - return $result; |
|
122 | - } |
|
59 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | + |
|
61 | + public $code_auto = 0; // Numerotation automatique |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * Return description of module |
|
66 | + * |
|
67 | + * @return string Description of module |
|
68 | + */ |
|
69 | + function info() |
|
70 | + { |
|
71 | + global $langs; |
|
72 | + |
|
73 | + $langs->load("companies"); |
|
74 | + return $langs->trans("LeopardNumRefModelDesc"); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Return an example of result returned by getNextValue |
|
79 | + * |
|
80 | + * @param Societe $objsoc Object thirdparty |
|
81 | + * @param Contrat $contract Object contract |
|
82 | + * @return string Return next value |
|
83 | + */ |
|
84 | + function getNextValue($objsoc,$contract) |
|
85 | + { |
|
86 | + global $langs; |
|
87 | + return ''; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * Check validity of code according to its rules |
|
93 | + * |
|
94 | + * @param DoliDB $db Database handler |
|
95 | + * @param string $code Code to check/correct |
|
96 | + * @param Product $product Object product |
|
97 | + * @param int $type 0 = product , 1 = service |
|
98 | + * @return int 0 if OK |
|
99 | + * -1 ErrorBadProductCodeSyntax |
|
100 | + * -2 ErrorProductCodeRequired |
|
101 | + * -3 ErrorProductCodeAlreadyUsed |
|
102 | + * -4 ErrorPrefixRequired |
|
103 | + */ |
|
104 | + function verif($db, &$code, $product, $type) |
|
105 | + { |
|
106 | + global $conf; |
|
107 | + |
|
108 | + $result=0; |
|
109 | + $code = strtoupper(trim($code)); |
|
110 | + |
|
111 | + if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) |
|
112 | + { |
|
113 | + $result=0; |
|
114 | + } |
|
115 | + else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) ) |
|
116 | + { |
|
117 | + $result=-2; |
|
118 | + } |
|
119 | + |
|
120 | + dol_syslog("mod_contract_olive::verif type=".$type." result=".$result); |
|
121 | + return $result; |
|
122 | + } |
|
123 | 123 | } |
124 | 124 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief File of class to manage contract numbering rules Olive |
25 | 25 | */ |
26 | 26 | |
27 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php'; |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | * @deprecated |
38 | 38 | * @see name |
39 | 39 | */ |
40 | - public $nom='Olive'; |
|
40 | + public $nom = 'Olive'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string model name |
44 | 44 | */ |
45 | - public $name='Olive'; |
|
45 | + public $name = 'Olive'; |
|
46 | 46 | |
47 | - public $code_modifiable = 1; // Code modifiable |
|
47 | + public $code_modifiable = 1; // Code modifiable |
|
48 | 48 | |
49 | - public $code_modifiable_invalide = 1; // Code modifiable si il est invalide |
|
49 | + public $code_modifiable_invalide = 1; // Code modifiable si il est invalide |
|
50 | 50 | |
51 | - public $code_modifiable_null = 1; // Code modifiables si il est null |
|
51 | + public $code_modifiable_null = 1; // Code modifiables si il est null |
|
52 | 52 | |
53 | - public $code_null = 1; // Code facultatif |
|
53 | + public $code_null = 1; // Code facultatif |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Dolibarr version of the loaded document |
57 | 57 | * @public string |
58 | 58 | */ |
59 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
59 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | 60 | |
61 | - public $code_auto = 0; // Numerotation automatique |
|
61 | + public $code_auto = 0; // Numerotation automatique |
|
62 | 62 | |
63 | 63 | |
64 | 64 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param Contrat $contract Object contract |
82 | 82 | * @return string Return next value |
83 | 83 | */ |
84 | - function getNextValue($objsoc,$contract) |
|
84 | + function getNextValue($objsoc, $contract) |
|
85 | 85 | { |
86 | 86 | global $langs; |
87 | 87 | return ''; |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | { |
106 | 106 | global $conf; |
107 | 107 | |
108 | - $result=0; |
|
108 | + $result = 0; |
|
109 | 109 | $code = strtoupper(trim($code)); |
110 | 110 | |
111 | 111 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) |
112 | 112 | { |
113 | - $result=0; |
|
113 | + $result = 0; |
|
114 | 114 | } |
115 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) ) |
|
115 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))) |
|
116 | 116 | { |
117 | - $result=-2; |
|
117 | + $result = -2; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | dol_syslog("mod_contract_olive::verif type=".$type." result=".$result); |
@@ -111,8 +111,7 @@ |
||
111 | 111 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) |
112 | 112 | { |
113 | 113 | $result=0; |
114 | - } |
|
115 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) ) |
|
114 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) ) |
|
116 | 115 | { |
117 | 116 | $result=-2; |
118 | 117 | } |
@@ -28,142 +28,142 @@ |
||
28 | 28 | */ |
29 | 29 | class mod_contract_serpis extends ModelNumRefContracts |
30 | 30 | { |
31 | - /** |
|
31 | + /** |
|
32 | 32 | * Dolibarr version of the loaded document |
33 | 33 | * @public string |
34 | 34 | */ |
35 | - public $version = 'dolibarr'; |
|
35 | + public $version = 'dolibarr'; |
|
36 | 36 | |
37 | - public $prefix='CT'; |
|
37 | + public $prefix='CT'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error code (or message) |
|
41 | - */ |
|
42 | - public $error=''; |
|
39 | + /** |
|
40 | + * @var string Error code (or message) |
|
41 | + */ |
|
42 | + public $error=''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Serpis'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Serpis'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Serpis'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Serpis'; |
|
55 | 55 | |
56 | - public $code_auto=1; |
|
56 | + public $code_auto=1; |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Return default description of numbering model |
|
61 | - * |
|
62 | - * @return string text description |
|
63 | - */ |
|
59 | + /** |
|
60 | + * Return default description of numbering model |
|
61 | + * |
|
62 | + * @return string text description |
|
63 | + */ |
|
64 | 64 | function info() |
65 | 65 | { |
66 | - global $langs; |
|
67 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
66 | + global $langs; |
|
67 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Return numbering example |
|
73 | - * |
|
74 | - * @return string Example |
|
75 | - */ |
|
76 | - function getExample() |
|
77 | - { |
|
78 | - return $this->prefix."0501-0001"; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Test if existing numbers make problems with numbering |
|
84 | - * |
|
85 | - * @return boolean false if conflit, true if ok |
|
86 | - */ |
|
87 | - function canBeActivated() |
|
88 | - { |
|
89 | - global $conf,$langs,$db; |
|
90 | - |
|
91 | - $coyymm=''; $max=''; |
|
92 | - |
|
93 | - $posindice=8; |
|
94 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
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) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | - } |
|
105 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
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 value |
|
117 | - * |
|
118 | - * @param Societe $objsoc third party object |
|
119 | - * @param Object $contract contract object |
|
120 | - * @return string Value if OK, 0 if KO |
|
121 | - */ |
|
122 | - function getNextValue($objsoc,$contract) |
|
123 | - { |
|
124 | - global $db,$conf; |
|
125 | - |
|
126 | - $posindice=8; |
|
127 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
128 | - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
129 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
130 | - $sql.= " AND entity = ".$conf->entity; |
|
131 | - |
|
132 | - $resql=$db->query($sql); |
|
133 | - if ($resql) |
|
134 | - { |
|
135 | - $obj = $db->fetch_object($resql); |
|
136 | - if ($obj) $max = intval($obj->max); |
|
137 | - else $max=0; |
|
138 | - } |
|
139 | - else |
|
140 | - { |
|
141 | - dol_syslog("mod_contract_serpis::getNextValue", LOG_DEBUG); |
|
142 | - return -1; |
|
143 | - } |
|
144 | - |
|
145 | - $date=$contract->date_contrat; |
|
146 | - $yymm = strftime("%y%m",$date); |
|
147 | - |
|
148 | - 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 |
|
149 | - else $num = sprintf("%04s",$max+1); |
|
150 | - |
|
151 | - dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
152 | - return $this->prefix.$yymm."-".$num; |
|
153 | - } |
|
71 | + /** |
|
72 | + * Return numbering example |
|
73 | + * |
|
74 | + * @return string Example |
|
75 | + */ |
|
76 | + function getExample() |
|
77 | + { |
|
78 | + return $this->prefix."0501-0001"; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Test if existing numbers make problems with numbering |
|
84 | + * |
|
85 | + * @return boolean false if conflit, true if ok |
|
86 | + */ |
|
87 | + function canBeActivated() |
|
88 | + { |
|
89 | + global $conf,$langs,$db; |
|
90 | + |
|
91 | + $coyymm=''; $max=''; |
|
92 | + |
|
93 | + $posindice=8; |
|
94 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | + $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
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) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + } |
|
105 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
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 value |
|
117 | + * |
|
118 | + * @param Societe $objsoc third party object |
|
119 | + * @param Object $contract contract object |
|
120 | + * @return string Value if OK, 0 if KO |
|
121 | + */ |
|
122 | + function getNextValue($objsoc,$contract) |
|
123 | + { |
|
124 | + global $db,$conf; |
|
125 | + |
|
126 | + $posindice=8; |
|
127 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
128 | + $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
129 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
130 | + $sql.= " AND entity = ".$conf->entity; |
|
131 | + |
|
132 | + $resql=$db->query($sql); |
|
133 | + if ($resql) |
|
134 | + { |
|
135 | + $obj = $db->fetch_object($resql); |
|
136 | + if ($obj) $max = intval($obj->max); |
|
137 | + else $max=0; |
|
138 | + } |
|
139 | + else |
|
140 | + { |
|
141 | + dol_syslog("mod_contract_serpis::getNextValue", LOG_DEBUG); |
|
142 | + return -1; |
|
143 | + } |
|
144 | + |
|
145 | + $date=$contract->date_contrat; |
|
146 | + $yymm = strftime("%y%m",$date); |
|
147 | + |
|
148 | + 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 |
|
149 | + else $num = sprintf("%04s",$max+1); |
|
150 | + |
|
151 | + dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
152 | + return $this->prefix.$yymm."-".$num; |
|
153 | + } |
|
154 | 154 | |
155 | 155 | |
156 | 156 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
157 | - /** |
|
158 | - * Return next value |
|
159 | - * |
|
160 | - * @param Societe $objsoc third party object |
|
161 | - * @param Object $objforref contract object |
|
162 | - * @return string Value if OK, 0 if KO |
|
163 | - */ |
|
164 | - function contract_get_num($objsoc,$objforref) |
|
165 | - { |
|
157 | + /** |
|
158 | + * Return next value |
|
159 | + * |
|
160 | + * @param Societe $objsoc third party object |
|
161 | + * @param Object $objforref contract object |
|
162 | + * @return string Value if OK, 0 if KO |
|
163 | + */ |
|
164 | + function contract_get_num($objsoc,$objforref) |
|
165 | + { |
|
166 | 166 | // phpcs:enable |
167 | - return $this->getNextValue($objsoc,$objforref); |
|
168 | - } |
|
167 | + return $this->getNextValue($objsoc,$objforref); |
|
168 | + } |
|
169 | 169 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * \ingroup contract |
22 | 22 | * \brief File of class to manage contract numbering rules Serpis |
23 | 23 | */ |
24 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php'; |
|
24 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Class to manage contract numbering rules Serpis |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public $version = 'dolibarr'; |
36 | 36 | |
37 | - public $prefix='CT'; |
|
37 | + public $prefix = 'CT'; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | - public $error=''; |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string Nom du modele |
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Serpis'; |
|
49 | + public $nom = 'Serpis'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Serpis'; |
|
54 | + public $name = 'Serpis'; |
|
55 | 55 | |
56 | - public $code_auto=1; |
|
56 | + public $code_auto = 1; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | function info() |
65 | 65 | { |
66 | 66 | global $langs; |
67 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function canBeActivated() |
88 | 88 | { |
89 | - global $conf,$langs,$db; |
|
89 | + global $conf, $langs, $db; |
|
90 | 90 | |
91 | - $coyymm=''; $max=''; |
|
91 | + $coyymm = ''; $max = ''; |
|
92 | 92 | |
93 | - $posindice=8; |
|
93 | + $posindice = 8; |
|
94 | 94 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
95 | + $sql .= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
96 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql .= " AND entity = ".$conf->entity; |
|
98 | 98 | |
99 | - $resql=$db->query($sql); |
|
99 | + $resql = $db->query($sql); |
|
100 | 100 | if ($resql) |
101 | 101 | { |
102 | 102 | $row = $db->fetch_row($resql); |
103 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
104 | 104 | } |
105 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
105 | + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
106 | 106 | { |
107 | 107 | $langs->load("errors"); |
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
@@ -119,22 +119,22 @@ discard block |
||
119 | 119 | * @param Object $contract contract object |
120 | 120 | * @return string Value if OK, 0 if KO |
121 | 121 | */ |
122 | - function getNextValue($objsoc,$contract) |
|
122 | + function getNextValue($objsoc, $contract) |
|
123 | 123 | { |
124 | - global $db,$conf; |
|
124 | + global $db, $conf; |
|
125 | 125 | |
126 | - $posindice=8; |
|
126 | + $posindice = 8; |
|
127 | 127 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
128 | - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
129 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
130 | - $sql.= " AND entity = ".$conf->entity; |
|
128 | + $sql .= " FROM ".MAIN_DB_PREFIX."contrat"; |
|
129 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
130 | + $sql .= " AND entity = ".$conf->entity; |
|
131 | 131 | |
132 | - $resql=$db->query($sql); |
|
132 | + $resql = $db->query($sql); |
|
133 | 133 | if ($resql) |
134 | 134 | { |
135 | 135 | $obj = $db->fetch_object($resql); |
136 | 136 | if ($obj) $max = intval($obj->max); |
137 | - else $max=0; |
|
137 | + else $max = 0; |
|
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | return -1; |
143 | 143 | } |
144 | 144 | |
145 | - $date=$contract->date_contrat; |
|
146 | - $yymm = strftime("%y%m",$date); |
|
145 | + $date = $contract->date_contrat; |
|
146 | + $yymm = strftime("%y%m", $date); |
|
147 | 147 | |
148 | - 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 |
|
149 | - else $num = sprintf("%04s",$max+1); |
|
148 | + 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 |
|
149 | + else $num = sprintf("%04s", $max + 1); |
|
150 | 150 | |
151 | 151 | dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); |
152 | 152 | return $this->prefix.$yymm."-".$num; |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param Object $objforref contract object |
162 | 162 | * @return string Value if OK, 0 if KO |
163 | 163 | */ |
164 | - function contract_get_num($objsoc,$objforref) |
|
164 | + function contract_get_num($objsoc, $objforref) |
|
165 | 165 | { |
166 | 166 | // phpcs:enable |
167 | - return $this->getNextValue($objsoc,$objforref); |
|
167 | + return $this->getNextValue($objsoc, $objforref); |
|
168 | 168 | } |
169 | 169 | } |
@@ -133,10 +133,12 @@ discard block |
||
133 | 133 | if ($resql) |
134 | 134 | { |
135 | 135 | $obj = $db->fetch_object($resql); |
136 | - if ($obj) $max = intval($obj->max); |
|
137 | - else $max=0; |
|
138 | - } |
|
139 | - else |
|
136 | + if ($obj) { |
|
137 | + $max = intval($obj->max); |
|
138 | + } else { |
|
139 | + $max=0; |
|
140 | + } |
|
141 | + } else |
|
140 | 142 | { |
141 | 143 | dol_syslog("mod_contract_serpis::getNextValue", LOG_DEBUG); |
142 | 144 | return -1; |
@@ -145,8 +147,13 @@ discard block |
||
145 | 147 | $date=$contract->date_contrat; |
146 | 148 | $yymm = strftime("%y%m",$date); |
147 | 149 | |
148 | - 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 |
|
149 | - else $num = sprintf("%04s",$max+1); |
|
150 | + if ($max >= (pow(10, 4) - 1)) { |
|
151 | + $num=$max+1; |
|
152 | + } |
|
153 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
154 | + else { |
|
155 | + $num = sprintf("%04s",$max+1); |
|
156 | + } |
|
150 | 157 | |
151 | 158 | dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); |
152 | 159 | return $this->prefix.$yymm."-".$num; |
@@ -40,156 +40,156 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class pdf_standard extends ModeleExpenseReport |
42 | 42 | { |
43 | - /** |
|
44 | - * @var DoliDb Database handler |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var DoliDb Database handler |
|
45 | + */ |
|
46 | 46 | public $db; |
47 | 47 | |
48 | - /** |
|
48 | + /** |
|
49 | 49 | * @var string model name |
50 | 50 | */ |
51 | 51 | public $name; |
52 | 52 | |
53 | - /** |
|
53 | + /** |
|
54 | 54 | * @var string model description (short text) |
55 | 55 | */ |
56 | 56 | public $description; |
57 | 57 | |
58 | - /** |
|
58 | + /** |
|
59 | 59 | * @var string document type |
60 | 60 | */ |
61 | 61 | public $type; |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @var array() Minimum version of PHP required by module. |
65 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
65 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
66 | 66 | */ |
67 | - public $phpmin = array(5, 4); |
|
67 | + public $phpmin = array(5, 4); |
|
68 | 68 | |
69 | - /** |
|
69 | + /** |
|
70 | 70 | * Dolibarr version of the loaded document |
71 | 71 | * @public string |
72 | 72 | */ |
73 | - public $version = 'dolibarr'; |
|
73 | + public $version = 'dolibarr'; |
|
74 | 74 | |
75 | - /** |
|
75 | + /** |
|
76 | 76 | * @var int page_largeur |
77 | 77 | */ |
78 | 78 | public $page_largeur; |
79 | 79 | |
80 | - /** |
|
80 | + /** |
|
81 | 81 | * @var int page_hauteur |
82 | 82 | */ |
83 | 83 | public $page_hauteur; |
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * @var array format |
87 | 87 | */ |
88 | 88 | public $format; |
89 | 89 | |
90 | - /** |
|
90 | + /** |
|
91 | 91 | * @var int marge_gauche |
92 | 92 | */ |
93 | - public $marge_gauche; |
|
93 | + public $marge_gauche; |
|
94 | 94 | |
95 | - /** |
|
95 | + /** |
|
96 | 96 | * @var int marge_droite |
97 | 97 | */ |
98 | - public $marge_droite; |
|
98 | + public $marge_droite; |
|
99 | 99 | |
100 | - /** |
|
100 | + /** |
|
101 | 101 | * @var int marge_haute |
102 | 102 | */ |
103 | - public $marge_haute; |
|
103 | + public $marge_haute; |
|
104 | 104 | |
105 | - /** |
|
105 | + /** |
|
106 | 106 | * @var int marge_basse |
107 | 107 | */ |
108 | - public $marge_basse; |
|
109 | - |
|
110 | - /** |
|
111 | - * Issuer |
|
112 | - * @var Company object that emits |
|
113 | - */ |
|
114 | - public $emetteur; |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * Constructor |
|
119 | - * |
|
120 | - * @param DoliDB $db Database handler |
|
121 | - */ |
|
122 | - function __construct($db) |
|
123 | - { |
|
124 | - global $conf, $langs, $mysoc; |
|
125 | - |
|
126 | - // Translations |
|
127 | - $langs->loadLangs(array("main", "trips", "projects")); |
|
128 | - |
|
129 | - $this->db = $db; |
|
130 | - $this->name = ""; |
|
131 | - $this->description = $langs->trans('PDFStandardExpenseReports'); |
|
132 | - |
|
133 | - // Dimension page pour format A4 |
|
134 | - $this->type = 'pdf'; |
|
135 | - $formatarray=pdf_getFormat(); |
|
136 | - $this->page_largeur = $formatarray['width']; |
|
137 | - $this->page_hauteur = $formatarray['height']; |
|
138 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | - |
|
144 | - $this->option_logo = 1; // Affiche logo |
|
145 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | - $this->option_modereg = 1; // Affiche mode reglement |
|
147 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | - $this->option_credit_note = 0; // Support credit notes |
|
152 | - $this->option_freetext = 1; // Support add of a personalised text |
|
153 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | - |
|
155 | - $this->franchise = !$mysoc->tva_assuj; |
|
156 | - |
|
157 | - // Get source company |
|
158 | - $this->emetteur=$mysoc; |
|
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
160 | - |
|
161 | - // Define position of columns |
|
162 | - $this->posxpiece=$this->marge_gauche+1; |
|
163 | - $this->posxcomment=$this->marge_gauche+10; |
|
164 | - //$this->posxdate=88; |
|
165 | - //$this->posxtype=107; |
|
166 | - //$this->posxprojet=120; |
|
167 | - $this->posxtva=130; |
|
168 | - $this->posxup=145; |
|
169 | - $this->posxqty=168; |
|
170 | - $this->postotalttc=178; |
|
108 | + public $marge_basse; |
|
109 | + |
|
110 | + /** |
|
111 | + * Issuer |
|
112 | + * @var Company object that emits |
|
113 | + */ |
|
114 | + public $emetteur; |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * Constructor |
|
119 | + * |
|
120 | + * @param DoliDB $db Database handler |
|
121 | + */ |
|
122 | + function __construct($db) |
|
123 | + { |
|
124 | + global $conf, $langs, $mysoc; |
|
125 | + |
|
126 | + // Translations |
|
127 | + $langs->loadLangs(array("main", "trips", "projects")); |
|
128 | + |
|
129 | + $this->db = $db; |
|
130 | + $this->name = ""; |
|
131 | + $this->description = $langs->trans('PDFStandardExpenseReports'); |
|
132 | + |
|
133 | + // Dimension page pour format A4 |
|
134 | + $this->type = 'pdf'; |
|
135 | + $formatarray=pdf_getFormat(); |
|
136 | + $this->page_largeur = $formatarray['width']; |
|
137 | + $this->page_hauteur = $formatarray['height']; |
|
138 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | + |
|
144 | + $this->option_logo = 1; // Affiche logo |
|
145 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | + $this->option_modereg = 1; // Affiche mode reglement |
|
147 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | + $this->option_credit_note = 0; // Support credit notes |
|
152 | + $this->option_freetext = 1; // Support add of a personalised text |
|
153 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | + |
|
155 | + $this->franchise = !$mysoc->tva_assuj; |
|
156 | + |
|
157 | + // Get source company |
|
158 | + $this->emetteur=$mysoc; |
|
159 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
160 | + |
|
161 | + // Define position of columns |
|
162 | + $this->posxpiece=$this->marge_gauche+1; |
|
163 | + $this->posxcomment=$this->marge_gauche+10; |
|
164 | + //$this->posxdate=88; |
|
165 | + //$this->posxtype=107; |
|
166 | + //$this->posxprojet=120; |
|
167 | + $this->posxtva=130; |
|
168 | + $this->posxup=145; |
|
169 | + $this->posxqty=168; |
|
170 | + $this->postotalttc=178; |
|
171 | 171 | // if (empty($conf->projet->enabled)) { |
172 | 172 | // $this->posxtva-=20; |
173 | 173 | // $this->posxup-=20; |
174 | 174 | // $this->posxqty-=20; |
175 | 175 | // $this->postotalttc-=20; |
176 | 176 | // } |
177 | - if ($this->page_largeur < 210) // To work with US executive format |
|
178 | - { |
|
179 | - $this->posxdate-=20; |
|
180 | - $this->posxtype-=20; |
|
181 | - $this->posxprojet-=20; |
|
182 | - $this->posxtva-=20; |
|
183 | - $this->posxup-=20; |
|
184 | - $this->posxqty-=20; |
|
185 | - $this->postotalttc-=20; |
|
186 | - } |
|
187 | - |
|
188 | - $this->tva=array(); |
|
189 | - $this->localtax1=array(); |
|
190 | - $this->localtax2=array(); |
|
191 | - $this->atleastoneratenotnull=0; |
|
192 | - } |
|
177 | + if ($this->page_largeur < 210) // To work with US executive format |
|
178 | + { |
|
179 | + $this->posxdate-=20; |
|
180 | + $this->posxtype-=20; |
|
181 | + $this->posxprojet-=20; |
|
182 | + $this->posxtva-=20; |
|
183 | + $this->posxup-=20; |
|
184 | + $this->posxqty-=20; |
|
185 | + $this->postotalttc-=20; |
|
186 | + } |
|
187 | + |
|
188 | + $this->tva=array(); |
|
189 | + $this->localtax1=array(); |
|
190 | + $this->localtax2=array(); |
|
191 | + $this->atleastoneratenotnull=0; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | 195 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -203,65 +203,65 @@ discard block |
||
203 | 203 | * @param int $hidedesc Do not show desc |
204 | 204 | * @param int $hideref Do not show ref |
205 | 205 | * @return int 1=OK, 0=KO |
206 | - */ |
|
207 | - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
208 | - { |
|
206 | + */ |
|
207 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
208 | + { |
|
209 | 209 | // phpcs:enable |
210 | - global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
|
211 | - |
|
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
213 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
215 | - |
|
216 | - // Load traductions files requiredby by page |
|
217 | - $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
|
218 | - |
|
219 | - $nblignes = count($object->lines); |
|
220 | - |
|
221 | - if ($conf->expensereport->dir_output) { |
|
222 | - // Definition of $dir and $file |
|
223 | - if ($object->specimen) { |
|
224 | - $dir = $conf->expensereport->dir_output; |
|
225 | - $file = $dir . "/SPECIMEN.pdf"; |
|
226 | - } |
|
227 | - else |
|
228 | - { |
|
229 | - $objectref = dol_sanitizeFileName($object->ref); |
|
230 | - $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
232 | - } |
|
233 | - |
|
234 | - if (! file_exists($dir)) |
|
235 | - { |
|
236 | - if (dol_mkdir($dir) < 0) |
|
237 | - { |
|
238 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
239 | - return 0; |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - if (file_exists($dir)) |
|
244 | - { |
|
245 | - // Add pdfgeneration hook |
|
246 | - if (! is_object($hookmanager)) |
|
247 | - { |
|
248 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
249 | - $hookmanager=new HookManager($this->db); |
|
250 | - } |
|
251 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
252 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
253 | - global $action; |
|
254 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
255 | - |
|
256 | - // Create pdf instance |
|
257 | - $pdf=pdf_getInstance($this->format); |
|
258 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | - $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 |
|
261 | - $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
263 | - |
|
264 | - $pdf->SetAutoPageBreak(1,0); |
|
210 | + global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
|
211 | + |
|
212 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
213 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
214 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
215 | + |
|
216 | + // Load traductions files requiredby by page |
|
217 | + $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
|
218 | + |
|
219 | + $nblignes = count($object->lines); |
|
220 | + |
|
221 | + if ($conf->expensereport->dir_output) { |
|
222 | + // Definition of $dir and $file |
|
223 | + if ($object->specimen) { |
|
224 | + $dir = $conf->expensereport->dir_output; |
|
225 | + $file = $dir . "/SPECIMEN.pdf"; |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
229 | + $objectref = dol_sanitizeFileName($object->ref); |
|
230 | + $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
232 | + } |
|
233 | + |
|
234 | + if (! file_exists($dir)) |
|
235 | + { |
|
236 | + if (dol_mkdir($dir) < 0) |
|
237 | + { |
|
238 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
239 | + return 0; |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + if (file_exists($dir)) |
|
244 | + { |
|
245 | + // Add pdfgeneration hook |
|
246 | + if (! is_object($hookmanager)) |
|
247 | + { |
|
248 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
249 | + $hookmanager=new HookManager($this->db); |
|
250 | + } |
|
251 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
252 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
253 | + global $action; |
|
254 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
255 | + |
|
256 | + // Create pdf instance |
|
257 | + $pdf=pdf_getInstance($this->format); |
|
258 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | + $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 |
|
261 | + $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
263 | + |
|
264 | + $pdf->SetAutoPageBreak(1,0); |
|
265 | 265 | |
266 | 266 | if (class_exists('TCPDF')) |
267 | 267 | { |
@@ -269,124 +269,124 @@ discard block |
||
269 | 269 | $pdf->setPrintFooter(false); |
270 | 270 | } |
271 | 271 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
272 | - // Set path to the background PDF File |
|
272 | + // Set path to the background PDF File |
|
273 | 273 | if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
274 | 274 | { |
275 | 275 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
276 | 276 | $tplidx = $pdf->importPage(1); |
277 | 277 | } |
278 | 278 | |
279 | - $pdf->Open(); |
|
280 | - $pagenb=0; |
|
281 | - $pdf->SetDrawColor(128,128,128); |
|
282 | - |
|
283 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
284 | - $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
|
285 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
286 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
287 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
|
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | - |
|
290 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | - |
|
292 | - // New page |
|
293 | - $pdf->AddPage(); |
|
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | - $pagenb++; |
|
296 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
297 | - $pdf->SetFont('','', $default_font_size - 1); |
|
298 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | - $pdf->SetTextColor(0,0,0); |
|
300 | - |
|
301 | - $tab_top = 95; |
|
302 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
303 | - $tab_height = 130; |
|
304 | - $tab_height_newpage = 150; |
|
305 | - |
|
306 | - // Show notes |
|
307 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | - { |
|
310 | - // Get first sale rep |
|
311 | - if (is_object($object->thirdparty)) |
|
312 | - { |
|
313 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | - $salerepobj=new User($this->db); |
|
315 | - $salerepobj->fetch($salereparray[0]['id']); |
|
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | - } |
|
318 | - } |
|
319 | - if ($notetoshow) |
|
320 | - { |
|
321 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
323 | - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
324 | - |
|
325 | - $tab_top = 95; |
|
326 | - |
|
327 | - $pdf->SetFont('','', $default_font_size - 1); |
|
328 | - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | - $nexY = $pdf->GetY(); |
|
330 | - $height_note=$nexY-$tab_top; |
|
331 | - |
|
332 | - // Rect prend une longueur en 3eme param |
|
333 | - $pdf->SetDrawColor(192,192,192); |
|
334 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
335 | - |
|
336 | - $tab_height = $tab_height - $height_note; |
|
337 | - $tab_top = $nexY+6; |
|
338 | - } |
|
339 | - else |
|
340 | - { |
|
341 | - $height_note=0; |
|
342 | - } |
|
343 | - |
|
344 | - $iniY = $tab_top + 7; |
|
345 | - $initialY = $tab_top + 7; |
|
346 | - $nexY = $tab_top + 7; |
|
347 | - |
|
348 | - // Loop on each lines |
|
349 | - for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | - $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | - $pdf->SetTextColor(0,0,0); |
|
352 | - |
|
353 | - $pdf->setTopMargin($tab_top_newpage); |
|
354 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | - $pageposbefore = $pdf->getPage(); |
|
279 | + $pdf->Open(); |
|
280 | + $pagenb=0; |
|
281 | + $pdf->SetDrawColor(128,128,128); |
|
282 | + |
|
283 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
284 | + $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
|
285 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
286 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
287 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
|
288 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | + |
|
290 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | + |
|
292 | + // New page |
|
293 | + $pdf->AddPage(); |
|
294 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | + $pagenb++; |
|
296 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
297 | + $pdf->SetFont('','', $default_font_size - 1); |
|
298 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | + $pdf->SetTextColor(0,0,0); |
|
300 | + |
|
301 | + $tab_top = 95; |
|
302 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
303 | + $tab_height = 130; |
|
304 | + $tab_height_newpage = 150; |
|
305 | + |
|
306 | + // Show notes |
|
307 | + $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | + if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | + { |
|
310 | + // Get first sale rep |
|
311 | + if (is_object($object->thirdparty)) |
|
312 | + { |
|
313 | + $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | + $salerepobj=new User($this->db); |
|
315 | + $salerepobj->fetch($salereparray[0]['id']); |
|
316 | + if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | + } |
|
318 | + } |
|
319 | + if ($notetoshow) |
|
320 | + { |
|
321 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
323 | + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
324 | + |
|
325 | + $tab_top = 95; |
|
326 | + |
|
327 | + $pdf->SetFont('','', $default_font_size - 1); |
|
328 | + $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | + $nexY = $pdf->GetY(); |
|
330 | + $height_note=$nexY-$tab_top; |
|
331 | + |
|
332 | + // Rect prend une longueur en 3eme param |
|
333 | + $pdf->SetDrawColor(192,192,192); |
|
334 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
335 | + |
|
336 | + $tab_height = $tab_height - $height_note; |
|
337 | + $tab_top = $nexY+6; |
|
338 | + } |
|
339 | + else |
|
340 | + { |
|
341 | + $height_note=0; |
|
342 | + } |
|
343 | + |
|
344 | + $iniY = $tab_top + 7; |
|
345 | + $initialY = $tab_top + 7; |
|
346 | + $nexY = $tab_top + 7; |
|
347 | + |
|
348 | + // Loop on each lines |
|
349 | + for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | + $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | + $pdf->SetTextColor(0,0,0); |
|
352 | + |
|
353 | + $pdf->setTopMargin($tab_top_newpage); |
|
354 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | + $pageposbefore = $pdf->getPage(); |
|
356 | 356 | $curY = $nexY; |
357 | 357 | $pdf->startTransaction(); |
358 | 358 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
359 | 359 | $pageposafter=$pdf->getPage(); |
360 | - if ($pageposafter > $pageposbefore) { |
|
360 | + if ($pageposafter > $pageposbefore) { |
|
361 | 361 | // There is a pagebreak |
362 | - $pdf->rollbackTransaction(true); |
|
363 | - $pageposafter = $pageposbefore; |
|
364 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
365 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | - $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
|
367 | - $pageposafter = $pdf->getPage(); |
|
368 | - $posyafter = $pdf->GetY(); |
|
369 | - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
370 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
362 | + $pdf->rollbackTransaction(true); |
|
363 | + $pageposafter = $pageposbefore; |
|
364 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
365 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | + $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
|
367 | + $pageposafter = $pdf->getPage(); |
|
368 | + $posyafter = $pdf->GetY(); |
|
369 | + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
370 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
371 | 371 | // There is no space left for total+free text |
372 | - if ($i == ($nblignes-1)) { |
|
372 | + if ($i == ($nblignes-1)) { |
|
373 | 373 | // No more lines, and no space left to show total, so we create a new page |
374 | - $pdf->AddPage('', '', true); |
|
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
377 | - $pdf->setPage($pageposafter+1); |
|
378 | - } |
|
379 | - } |
|
380 | - else |
|
381 | - { |
|
382 | - // We found a page break |
|
383 | - $showpricebeforepagebreak=0; |
|
384 | - } |
|
385 | - } |
|
386 | - else // No pagebreak |
|
387 | - { |
|
388 | - $pdf->commitTransaction(); |
|
389 | - } |
|
374 | + $pdf->AddPage('', '', true); |
|
375 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
377 | + $pdf->setPage($pageposafter+1); |
|
378 | + } |
|
379 | + } |
|
380 | + else |
|
381 | + { |
|
382 | + // We found a page break |
|
383 | + $showpricebeforepagebreak=0; |
|
384 | + } |
|
385 | + } |
|
386 | + else // No pagebreak |
|
387 | + { |
|
388 | + $pdf->commitTransaction(); |
|
389 | + } |
|
390 | 390 | //nexY |
391 | 391 | $nexY = $pdf->GetY(); |
392 | 392 | $pageposafter=$pdf->getPage(); |
@@ -396,140 +396,140 @@ discard block |
||
396 | 396 | |
397 | 397 | //$nblineFollowComment = 1; |
398 | 398 | // Cherche nombre de lignes a venir pour savoir si place suffisante |
399 | - // if ($i < ($nblignes - 1)) // If it's not last line |
|
400 | - // { |
|
401 | - // //Fetch current description to know on which line the next one should be placed |
|
402 | - // $follow_comment = $object->lines[$i]->comments; |
|
403 | - // $follow_type = $object->lines[$i]->type_fees_code; |
|
399 | + // if ($i < ($nblignes - 1)) // If it's not last line |
|
400 | + // { |
|
401 | + // //Fetch current description to know on which line the next one should be placed |
|
402 | + // $follow_comment = $object->lines[$i]->comments; |
|
403 | + // $follow_type = $object->lines[$i]->type_fees_code; |
|
404 | 404 | |
405 | - // //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) |
|
406 | - // $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output); |
|
407 | - // $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output); |
|
405 | + // //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) |
|
406 | + // $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output); |
|
407 | + // $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output); |
|
408 | 408 | |
409 | 409 | // $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed); |
410 | - // } |
|
410 | + // } |
|
411 | 411 | |
412 | 412 | //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
413 | 413 | $nexY += ($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
414 | 414 | |
415 | - // Detect if some page were added automatically and output _tableau for past pages |
|
416 | - while ($pagenb < $pageposafter) |
|
417 | - { |
|
418 | - $pdf->setPage($pagenb); |
|
419 | - if ($pagenb == 1) |
|
420 | - { |
|
421 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
422 | - } |
|
423 | - else |
|
424 | - { |
|
425 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
426 | - } |
|
427 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
428 | - $pagenb++; |
|
429 | - $pdf->setPage($pagenb); |
|
430 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | - } |
|
433 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
434 | - { |
|
435 | - if ($pagenb == 1) |
|
436 | - { |
|
437 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
438 | - } |
|
439 | - else |
|
440 | - { |
|
441 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
442 | - } |
|
443 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
444 | - // New page |
|
445 | - $pdf->AddPage(); |
|
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | - $pagenb++; |
|
448 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | - } |
|
450 | - } |
|
451 | - |
|
452 | - // Show square |
|
453 | - if ($pagenb == 1) |
|
454 | - { |
|
455 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
456 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | - } |
|
458 | - else |
|
459 | - { |
|
460 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
461 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | - } |
|
463 | - |
|
464 | - $pdf->SetFont('','', 10); |
|
465 | - |
|
466 | - // Show total area box |
|
467 | - $posy=$bottomlasttab+5; |
|
468 | - $posy_start_of_totals = $posy; |
|
469 | - $pdf->SetXY(130, $posy); |
|
470 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
|
471 | - $pdf->SetXY(180, $posy); |
|
472 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
|
473 | - $pdf->SetFillColor(248,248,248); |
|
474 | - |
|
475 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
476 | - { |
|
477 | - // TODO Show vat amout per tax level |
|
478 | - $posy+=5; |
|
479 | - $pdf->SetXY(130, $posy); |
|
480 | - $pdf->SetTextColor(0,0,60); |
|
481 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
482 | - $pdf->SetXY(180, $posy); |
|
483 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
484 | - } |
|
485 | - |
|
486 | - $posy+=5; |
|
487 | - $pdf->SetXY(130, $posy); |
|
488 | - $pdf->SetFont('','B', 10); |
|
489 | - $pdf->SetTextColor(0,0,60); |
|
490 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
491 | - $pdf->SetXY(180, $posy); |
|
492 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
493 | - |
|
494 | - // show payments zone |
|
495 | - $sumPayments = $object->getSumPayments(); |
|
496 | - if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
|
497 | - $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | - } |
|
499 | - |
|
500 | - // Pied de page |
|
501 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | - |
|
504 | - $pdf->Close(); |
|
505 | - |
|
506 | - $pdf->Output($file,'F'); |
|
507 | - |
|
508 | - // Add pdfgeneration hook |
|
509 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
510 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
511 | - global $action; |
|
512 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
513 | - |
|
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
515 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | - |
|
517 | - $this->result = array('fullpath'=>$file); |
|
518 | - |
|
519 | - return 1; // Pas d'erreur |
|
520 | - } |
|
521 | - else |
|
522 | - { |
|
523 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
524 | - return 0; |
|
525 | - } |
|
526 | - } |
|
527 | - else |
|
528 | - { |
|
529 | - $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
530 | - return 0; |
|
531 | - } |
|
532 | - } |
|
415 | + // Detect if some page were added automatically and output _tableau for past pages |
|
416 | + while ($pagenb < $pageposafter) |
|
417 | + { |
|
418 | + $pdf->setPage($pagenb); |
|
419 | + if ($pagenb == 1) |
|
420 | + { |
|
421 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
422 | + } |
|
423 | + else |
|
424 | + { |
|
425 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
426 | + } |
|
427 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
428 | + $pagenb++; |
|
429 | + $pdf->setPage($pagenb); |
|
430 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | + } |
|
433 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
434 | + { |
|
435 | + if ($pagenb == 1) |
|
436 | + { |
|
437 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
438 | + } |
|
439 | + else |
|
440 | + { |
|
441 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
442 | + } |
|
443 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
444 | + // New page |
|
445 | + $pdf->AddPage(); |
|
446 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | + $pagenb++; |
|
448 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | + } |
|
450 | + } |
|
451 | + |
|
452 | + // Show square |
|
453 | + if ($pagenb == 1) |
|
454 | + { |
|
455 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
456 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | + } |
|
458 | + else |
|
459 | + { |
|
460 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
461 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | + } |
|
463 | + |
|
464 | + $pdf->SetFont('','', 10); |
|
465 | + |
|
466 | + // Show total area box |
|
467 | + $posy=$bottomlasttab+5; |
|
468 | + $posy_start_of_totals = $posy; |
|
469 | + $pdf->SetXY(130, $posy); |
|
470 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
|
471 | + $pdf->SetXY(180, $posy); |
|
472 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
|
473 | + $pdf->SetFillColor(248,248,248); |
|
474 | + |
|
475 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
476 | + { |
|
477 | + // TODO Show vat amout per tax level |
|
478 | + $posy+=5; |
|
479 | + $pdf->SetXY(130, $posy); |
|
480 | + $pdf->SetTextColor(0,0,60); |
|
481 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
482 | + $pdf->SetXY(180, $posy); |
|
483 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
484 | + } |
|
485 | + |
|
486 | + $posy+=5; |
|
487 | + $pdf->SetXY(130, $posy); |
|
488 | + $pdf->SetFont('','B', 10); |
|
489 | + $pdf->SetTextColor(0,0,60); |
|
490 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
491 | + $pdf->SetXY(180, $posy); |
|
492 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
493 | + |
|
494 | + // show payments zone |
|
495 | + $sumPayments = $object->getSumPayments(); |
|
496 | + if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
|
497 | + $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | + } |
|
499 | + |
|
500 | + // Pied de page |
|
501 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | + |
|
504 | + $pdf->Close(); |
|
505 | + |
|
506 | + $pdf->Output($file,'F'); |
|
507 | + |
|
508 | + // Add pdfgeneration hook |
|
509 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
510 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
511 | + global $action; |
|
512 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
513 | + |
|
514 | + if (! empty($conf->global->MAIN_UMASK)) |
|
515 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | + |
|
517 | + $this->result = array('fullpath'=>$file); |
|
518 | + |
|
519 | + return 1; // Pas d'erreur |
|
520 | + } |
|
521 | + else |
|
522 | + { |
|
523 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
524 | + return 0; |
|
525 | + } |
|
526 | + } |
|
527 | + else |
|
528 | + { |
|
529 | + $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
530 | + return 0; |
|
531 | + } |
|
532 | + } |
|
533 | 533 | |
534 | 534 | /** |
535 | 535 | * @param TCPDF $pdf Object PDF |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @return void |
543 | 543 | */ |
544 | 544 | private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails=0) |
545 | - { |
|
545 | + { |
|
546 | 546 | global $conf; |
547 | 547 | $pdf->SetFont('','', $default_font_size - 1); |
548 | 548 | |
@@ -612,24 +612,24 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | - * Show top header of page. |
|
616 | - * |
|
617 | - * @param PDF $pdf Object PDF |
|
618 | - * @param Object $object Object to show |
|
619 | - * @param int $showaddress 0=no, 1=yes |
|
620 | - * @param Translate $outputlangs Object lang for output |
|
621 | - * @return void |
|
622 | - */ |
|
623 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
624 | - { |
|
625 | - global $conf, $langs, $hookmanager; |
|
626 | - |
|
627 | - // Load traductions files requiredby by page |
|
628 | - $outputlangs->loadLangs(array("main", "trips", "companies")); |
|
629 | - |
|
630 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
631 | - |
|
632 | - /* |
|
615 | + * Show top header of page. |
|
616 | + * |
|
617 | + * @param PDF $pdf Object PDF |
|
618 | + * @param Object $object Object to show |
|
619 | + * @param int $showaddress 0=no, 1=yes |
|
620 | + * @param Translate $outputlangs Object lang for output |
|
621 | + * @return void |
|
622 | + */ |
|
623 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
624 | + { |
|
625 | + global $conf, $langs, $hookmanager; |
|
626 | + |
|
627 | + // Load traductions files requiredby by page |
|
628 | + $outputlangs->loadLangs(array("main", "trips", "companies")); |
|
629 | + |
|
630 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
631 | + |
|
632 | + /* |
|
633 | 633 | // ajout du fondu vert en bas de page à droite |
634 | 634 | $image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg'; |
635 | 635 | $pdf->Image($image_fondue,20,107,200,190); |
@@ -637,430 +637,430 @@ discard block |
||
637 | 637 | pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
638 | 638 | */ |
639 | 639 | |
640 | - // Draft watermark |
|
641 | - if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | - } |
|
644 | - |
|
645 | - $pdf->SetTextColor(0, 0, 60); |
|
646 | - $pdf->SetFont('', 'B', $default_font_size + 3); |
|
647 | - |
|
648 | - $posy=$this->marge_haute; |
|
649 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
650 | - |
|
651 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
652 | - |
|
653 | - // Logo |
|
654 | - $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
655 | - if ($this->emetteur->logo) { |
|
656 | - if (is_readable($logo)) { |
|
657 | - $height=pdf_getHeightForLogo($logo); |
|
658 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | - } else { |
|
660 | - $pdf->SetTextColor(200,0,0); |
|
661 | - $pdf->SetFont('','B', $default_font_size -2); |
|
662 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
663 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
664 | - } |
|
665 | - } |
|
666 | - else |
|
667 | - { |
|
668 | - $text=$this->emetteur->name; |
|
669 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | - } |
|
671 | - |
|
672 | - $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | - $pdf->SetXY($posx,$posy); |
|
674 | - $pdf->SetTextColor(0,0,60); |
|
675 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | - |
|
677 | - $pdf->SetFont('','', $default_font_size -1); |
|
678 | - |
|
679 | - // Ref complete |
|
680 | - $posy+=8; |
|
681 | - $pdf->SetXY($posx,$posy); |
|
682 | - $pdf->SetTextColor(0,0,60); |
|
683 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
684 | - |
|
685 | - // Date start period |
|
686 | - $posy+=5; |
|
687 | - $pdf->SetXY($posx,$posy); |
|
688 | - $pdf->SetTextColor(0,0,60); |
|
689 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
690 | - |
|
691 | - // Date end period |
|
692 | - $posy+=5; |
|
693 | - $pdf->SetXY($posx,$posy); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
696 | - |
|
697 | - // Status Expense Report |
|
698 | - $posy+=6; |
|
699 | - $pdf->SetXY($posx,$posy); |
|
700 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | - $pdf->SetTextColor(111,81,124); |
|
702 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | - |
|
704 | - if ($showaddress) { |
|
705 | - // Sender properties |
|
706 | - $carac_emetteur = ''; |
|
707 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | - $carac_emetteur .= "\n"; |
|
710 | - // Phone |
|
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | - // Fax |
|
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | ||
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | - // Web |
|
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | - |
|
719 | - // Show sender |
|
720 | - $posy=50; |
|
721 | - $posx=$this->marge_gauche; |
|
722 | - $hautcadre=40; |
|
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
724 | - |
|
725 | - // Show sender frame |
|
726 | - $pdf->SetTextColor(0, 0, 0); |
|
727 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | - $pdf->SetXY($posx,$posy-5); |
|
729 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | - $pdf->SetXY($posx,$posy); |
|
731 | - $pdf->SetFillColor(224,224,224); |
|
732 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
733 | - $pdf->SetTextColor(0, 0, 60); |
|
734 | - |
|
735 | - // Show sender name |
|
736 | - $pdf->SetXY($posx+2,$posy+3); |
|
737 | - $pdf->SetFont('','B', $default_font_size); |
|
738 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
739 | - |
|
740 | - // Show sender information |
|
741 | - $pdf->SetXY($posx+2,$posy+8); |
|
742 | - $pdf->SetFont('', '', $default_font_size - 1); |
|
743 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
744 | - |
|
745 | - // Show recipient |
|
746 | - $posy=50; |
|
747 | - $posx=100; |
|
748 | - |
|
749 | - // Show recipient frame |
|
750 | - $pdf->SetTextColor(0, 0, 0); |
|
751 | - $pdf->SetFont('', 'B', 8); |
|
752 | - $pdf->SetXY($posx,$posy-5); |
|
753 | - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
|
754 | - $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
|
755 | - |
|
756 | - // Informations for trip (dates and users workflow) |
|
757 | - if ($object->fk_user_author > 0) { |
|
758 | - $userfee=new User($this->db); |
|
759 | - $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','',10); |
|
762 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | - $posy+=5; |
|
764 | - $pdf->SetXY($posx+2,$posy); |
|
765 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
766 | - } |
|
767 | - |
|
768 | - if ($object->fk_statut==99) |
|
769 | - { |
|
770 | - if ($object->fk_user_refuse > 0) { |
|
771 | - $userfee=new User($this->db); |
|
772 | - $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | - $pdf->SetXY($posx+2,$posy); |
|
774 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | - $posy+=5; |
|
776 | - $pdf->SetXY($posx+2,$posy); |
|
777 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | - $posy+=5; |
|
779 | - $pdf->SetXY($posx+2,$posy); |
|
780 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
781 | - } |
|
782 | - } |
|
783 | - else if($object->fk_statut==4) |
|
784 | - { |
|
785 | - if ($object->fk_user_cancel > 0) { |
|
786 | - $userfee=new User($this->db); |
|
787 | - $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | - $pdf->SetXY($posx+2,$posy); |
|
789 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | - $posy+=5; |
|
791 | - $pdf->SetXY($posx+2,$posy); |
|
792 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | - $posy+=5; |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
795 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
796 | - } |
|
797 | - } |
|
798 | - else |
|
799 | - { |
|
800 | - if ($object->fk_user_approve > 0) { |
|
801 | - $userfee=new User($this->db); |
|
802 | - $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | - $pdf->SetXY($posx+2,$posy); |
|
804 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | - $posy+=5; |
|
806 | - $pdf->SetXY($posx+2,$posy); |
|
807 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
808 | - } |
|
809 | - } |
|
810 | - |
|
811 | - if($object->fk_statut==6) { |
|
812 | - if ($object->fk_user_paid > 0) { |
|
813 | - $userfee=new User($this->db); |
|
814 | - $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | - $pdf->SetXY($posx+2,$posy); |
|
816 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | - $posy+=5; |
|
818 | - $pdf->SetXY($posx+2,$posy); |
|
819 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
820 | - } |
|
821 | - } |
|
822 | - } |
|
823 | - } |
|
824 | - |
|
825 | - /** |
|
826 | - * Show table for lines |
|
827 | - * |
|
828 | - * @param PDF $pdf Object PDF |
|
829 | - * @param int $tab_top Tab top |
|
830 | - * @param int $tab_height Tab height |
|
831 | - * @param int $nexY next y |
|
832 | - * @param Translate $outputlangs Output langs |
|
833 | - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
834 | - * @param int $hidebottom Hide bottom bar of array |
|
835 | - * @param string $currency Currency code |
|
836 | - * @return void |
|
837 | - */ |
|
838 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
839 | - { |
|
840 | - global $conf; |
|
841 | - |
|
842 | - // Force to disable hidetop and hidebottom |
|
843 | - $hidebottom=0; |
|
844 | - if ($hidetop) $hidetop=-1; |
|
845 | - |
|
846 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
847 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
848 | - |
|
849 | - // Amount in (at tab_top - 1) |
|
850 | - $pdf->SetTextColor(0,0,0); |
|
851 | - $pdf->SetFont('', '', $default_font_size - 2); |
|
852 | - $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
853 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
854 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
855 | - |
|
856 | - $pdf->SetDrawColor(128,128,128); |
|
857 | - |
|
858 | - // Rect prend une longueur en 3eme param |
|
859 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
860 | - // line prend une position y en 3eme param |
|
861 | - if (empty($hidetop)) { |
|
862 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
863 | - } |
|
864 | - |
|
865 | - $pdf->SetFont('','',8); |
|
866 | - |
|
867 | - // Accountancy piece |
|
868 | - if (empty($hidetop)) { |
|
869 | - $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | - $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
871 | - } |
|
872 | - |
|
873 | - // Comments |
|
874 | - $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
875 | - if (empty($hidetop)) { |
|
876 | - $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | - $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
878 | - } |
|
879 | - |
|
880 | - // Date |
|
881 | - //$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); |
|
882 | - //if (empty($hidetop)) |
|
883 | - //{ |
|
884 | - // $pdf->SetXY($this->posxdate-1, $tab_top+1); |
|
885 | - // $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); |
|
886 | - //} |
|
887 | - |
|
888 | - // Type |
|
889 | - //$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); |
|
890 | - //if (empty($hidetop)) |
|
891 | - //{ |
|
892 | - // $pdf->SetXY($this->posxtype-1, $tab_top+1); |
|
893 | - // $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); |
|
894 | - //} |
|
640 | + // Draft watermark |
|
641 | + if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | + } |
|
644 | + |
|
645 | + $pdf->SetTextColor(0, 0, 60); |
|
646 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
647 | + |
|
648 | + $posy=$this->marge_haute; |
|
649 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
650 | + |
|
651 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
652 | + |
|
653 | + // Logo |
|
654 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
655 | + if ($this->emetteur->logo) { |
|
656 | + if (is_readable($logo)) { |
|
657 | + $height=pdf_getHeightForLogo($logo); |
|
658 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | + } else { |
|
660 | + $pdf->SetTextColor(200,0,0); |
|
661 | + $pdf->SetFont('','B', $default_font_size -2); |
|
662 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
663 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
664 | + } |
|
665 | + } |
|
666 | + else |
|
667 | + { |
|
668 | + $text=$this->emetteur->name; |
|
669 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
670 | + } |
|
671 | + |
|
672 | + $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | + $pdf->SetXY($posx,$posy); |
|
674 | + $pdf->SetTextColor(0,0,60); |
|
675 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | + |
|
677 | + $pdf->SetFont('','', $default_font_size -1); |
|
678 | + |
|
679 | + // Ref complete |
|
680 | + $posy+=8; |
|
681 | + $pdf->SetXY($posx,$posy); |
|
682 | + $pdf->SetTextColor(0,0,60); |
|
683 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
684 | + |
|
685 | + // Date start period |
|
686 | + $posy+=5; |
|
687 | + $pdf->SetXY($posx,$posy); |
|
688 | + $pdf->SetTextColor(0,0,60); |
|
689 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
690 | + |
|
691 | + // Date end period |
|
692 | + $posy+=5; |
|
693 | + $pdf->SetXY($posx,$posy); |
|
694 | + $pdf->SetTextColor(0,0,60); |
|
695 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
696 | + |
|
697 | + // Status Expense Report |
|
698 | + $posy+=6; |
|
699 | + $pdf->SetXY($posx,$posy); |
|
700 | + $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | + $pdf->SetTextColor(111,81,124); |
|
702 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | + |
|
704 | + if ($showaddress) { |
|
705 | + // Sender properties |
|
706 | + $carac_emetteur = ''; |
|
707 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | + $carac_emetteur .= "\n"; |
|
710 | + // Phone |
|
711 | + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | + // Fax |
|
713 | + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | ||
715 | + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | + // Web |
|
717 | + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | + |
|
719 | + // Show sender |
|
720 | + $posy=50; |
|
721 | + $posx=$this->marge_gauche; |
|
722 | + $hautcadre=40; |
|
723 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
724 | + |
|
725 | + // Show sender frame |
|
726 | + $pdf->SetTextColor(0, 0, 0); |
|
727 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | + $pdf->SetXY($posx,$posy-5); |
|
729 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | + $pdf->SetXY($posx,$posy); |
|
731 | + $pdf->SetFillColor(224,224,224); |
|
732 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
733 | + $pdf->SetTextColor(0, 0, 60); |
|
734 | + |
|
735 | + // Show sender name |
|
736 | + $pdf->SetXY($posx+2,$posy+3); |
|
737 | + $pdf->SetFont('','B', $default_font_size); |
|
738 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
739 | + |
|
740 | + // Show sender information |
|
741 | + $pdf->SetXY($posx+2,$posy+8); |
|
742 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
743 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
744 | + |
|
745 | + // Show recipient |
|
746 | + $posy=50; |
|
747 | + $posx=100; |
|
748 | + |
|
749 | + // Show recipient frame |
|
750 | + $pdf->SetTextColor(0, 0, 0); |
|
751 | + $pdf->SetFont('', 'B', 8); |
|
752 | + $pdf->SetXY($posx,$posy-5); |
|
753 | + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
|
754 | + $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
|
755 | + |
|
756 | + // Informations for trip (dates and users workflow) |
|
757 | + if ($object->fk_user_author > 0) { |
|
758 | + $userfee=new User($this->db); |
|
759 | + $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | + $pdf->SetXY($posx+2,$posy); |
|
761 | + $pdf->SetFont('','',10); |
|
762 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | + $posy+=5; |
|
764 | + $pdf->SetXY($posx+2,$posy); |
|
765 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
766 | + } |
|
767 | + |
|
768 | + if ($object->fk_statut==99) |
|
769 | + { |
|
770 | + if ($object->fk_user_refuse > 0) { |
|
771 | + $userfee=new User($this->db); |
|
772 | + $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | + $pdf->SetXY($posx+2,$posy); |
|
774 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | + $posy+=5; |
|
776 | + $pdf->SetXY($posx+2,$posy); |
|
777 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | + $posy+=5; |
|
779 | + $pdf->SetXY($posx+2,$posy); |
|
780 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
781 | + } |
|
782 | + } |
|
783 | + else if($object->fk_statut==4) |
|
784 | + { |
|
785 | + if ($object->fk_user_cancel > 0) { |
|
786 | + $userfee=new User($this->db); |
|
787 | + $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | + $pdf->SetXY($posx+2,$posy); |
|
789 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | + $posy+=5; |
|
791 | + $pdf->SetXY($posx+2,$posy); |
|
792 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | + $posy+=5; |
|
794 | + $pdf->SetXY($posx+2,$posy); |
|
795 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
796 | + } |
|
797 | + } |
|
798 | + else |
|
799 | + { |
|
800 | + if ($object->fk_user_approve > 0) { |
|
801 | + $userfee=new User($this->db); |
|
802 | + $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | + $pdf->SetXY($posx+2,$posy); |
|
804 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | + $posy+=5; |
|
806 | + $pdf->SetXY($posx+2,$posy); |
|
807 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
808 | + } |
|
809 | + } |
|
810 | + |
|
811 | + if($object->fk_statut==6) { |
|
812 | + if ($object->fk_user_paid > 0) { |
|
813 | + $userfee=new User($this->db); |
|
814 | + $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | + $pdf->SetXY($posx+2,$posy); |
|
816 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | + $posy+=5; |
|
818 | + $pdf->SetXY($posx+2,$posy); |
|
819 | + $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
820 | + } |
|
821 | + } |
|
822 | + } |
|
823 | + } |
|
824 | + |
|
825 | + /** |
|
826 | + * Show table for lines |
|
827 | + * |
|
828 | + * @param PDF $pdf Object PDF |
|
829 | + * @param int $tab_top Tab top |
|
830 | + * @param int $tab_height Tab height |
|
831 | + * @param int $nexY next y |
|
832 | + * @param Translate $outputlangs Output langs |
|
833 | + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
834 | + * @param int $hidebottom Hide bottom bar of array |
|
835 | + * @param string $currency Currency code |
|
836 | + * @return void |
|
837 | + */ |
|
838 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
839 | + { |
|
840 | + global $conf; |
|
841 | + |
|
842 | + // Force to disable hidetop and hidebottom |
|
843 | + $hidebottom=0; |
|
844 | + if ($hidetop) $hidetop=-1; |
|
845 | + |
|
846 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
847 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
848 | + |
|
849 | + // Amount in (at tab_top - 1) |
|
850 | + $pdf->SetTextColor(0,0,0); |
|
851 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
852 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
853 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
854 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
855 | + |
|
856 | + $pdf->SetDrawColor(128,128,128); |
|
857 | + |
|
858 | + // Rect prend une longueur en 3eme param |
|
859 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
860 | + // line prend une position y en 3eme param |
|
861 | + if (empty($hidetop)) { |
|
862 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
863 | + } |
|
864 | + |
|
865 | + $pdf->SetFont('','',8); |
|
866 | + |
|
867 | + // Accountancy piece |
|
868 | + if (empty($hidetop)) { |
|
869 | + $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | + $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
871 | + } |
|
872 | + |
|
873 | + // Comments |
|
874 | + $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
875 | + if (empty($hidetop)) { |
|
876 | + $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | + $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
878 | + } |
|
879 | + |
|
880 | + // Date |
|
881 | + //$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); |
|
882 | + //if (empty($hidetop)) |
|
883 | + //{ |
|
884 | + // $pdf->SetXY($this->posxdate-1, $tab_top+1); |
|
885 | + // $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); |
|
886 | + //} |
|
887 | + |
|
888 | + // Type |
|
889 | + //$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); |
|
890 | + //if (empty($hidetop)) |
|
891 | + //{ |
|
892 | + // $pdf->SetXY($this->posxtype-1, $tab_top+1); |
|
893 | + // $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); |
|
894 | + //} |
|
895 | 895 | |
896 | 896 | //if (!empty($conf->projet->enabled)) |
897 | 897 | //{ |
898 | 898 | // // Project |
899 | 899 | // $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); |
900 | - // if (empty($hidetop)) { |
|
900 | + // if (empty($hidetop)) { |
|
901 | 901 | // $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); |
902 | 902 | // $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); |
903 | - // } |
|
903 | + // } |
|
904 | 904 | //} |
905 | 905 | |
906 | - // VAT |
|
907 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
908 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
909 | - if (empty($hidetop)) { |
|
910 | - $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | - $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | - } |
|
913 | - } |
|
906 | + // VAT |
|
907 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
908 | + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
909 | + if (empty($hidetop)) { |
|
910 | + $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | + $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | + } |
|
913 | + } |
|
914 | 914 | |
915 | 915 | // Unit price |
916 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
917 | - if (empty($hidetop)) { |
|
918 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
920 | - } |
|
921 | - |
|
922 | - // Quantity |
|
923 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
924 | - if (empty($hidetop)) { |
|
925 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | - $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
927 | - } |
|
928 | - |
|
929 | - // Total with all taxes |
|
930 | - $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
|
931 | - if (empty($hidetop)) { |
|
932 | - $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
934 | - } |
|
935 | - |
|
936 | - $pdf->SetTextColor(0,0,0); |
|
937 | - } |
|
938 | - |
|
939 | - /** |
|
940 | - * Show payments table |
|
941 | - * |
|
942 | - * @param PDF $pdf Object PDF |
|
943 | - * @param Object $object Object invoice |
|
944 | - * @param int $posy Position y in PDF |
|
945 | - * @param Translate $outputlangs Object langs for output |
|
946 | - * @return int <0 if KO, >0 if OK |
|
947 | - */ |
|
948 | - private function tablePayments(&$pdf, $object, $posy, $outputlangs) |
|
949 | - { |
|
950 | - global $conf; |
|
951 | - |
|
952 | - $sign=1; |
|
953 | - $tab3_posx = $this->marge_gauche; |
|
954 | - $tab3_top = $posy; |
|
955 | - $tab3_width = 88; |
|
956 | - $tab3_height = 5; |
|
957 | - |
|
958 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
959 | - |
|
960 | - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | - $pdf->SetFont('','', $default_font_size - 2); |
|
962 | - $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
963 | - $pdf->SetTextColor(0,0,0); |
|
964 | - $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
|
965 | - |
|
966 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
967 | - |
|
968 | - $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
969 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
|
970 | - $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
971 | - $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
|
972 | - $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
973 | - $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
974 | - if (! empty($conf->banque->enabled)) { |
|
975 | - $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
976 | - $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
|
977 | - } |
|
978 | - $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
979 | - |
|
980 | - $y=0; |
|
981 | - |
|
982 | - // Loop on each payment |
|
983 | - // TODO create method on expensereport class to get payments |
|
984 | - // Payments already done (from payment on this expensereport) |
|
985 | - $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
|
986 | - $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | - $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | - $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | - $sql.= " ORDER BY dp"; |
|
996 | - |
|
997 | - $resql=$this->db->query($sql); |
|
998 | - if ($resql) |
|
999 | - { |
|
1000 | - $num = $this->db->num_rows($resql); |
|
1001 | - $i=0; |
|
1002 | - while ($i < $num) { |
|
1003 | - $y+=$tab3_height; |
|
1004 | - $row = $this->db->fetch_object($resql); |
|
1005 | - |
|
1006 | - $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1009 | - $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
|
1010 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1012 | - |
|
1013 | - $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
|
1014 | - if (! empty($conf->banque->enabled)) { |
|
1015 | - $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1016 | - $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
|
1017 | - } |
|
1018 | - |
|
1019 | - $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1020 | - $totalpaid += $row->amount; |
|
1021 | - $i++; |
|
1022 | - } |
|
1023 | - if ($num > 0 && $object->paid == 0) |
|
1024 | - { |
|
1025 | - $y+=$tab3_height; |
|
916 | + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
917 | + if (empty($hidetop)) { |
|
918 | + $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
920 | + } |
|
921 | + |
|
922 | + // Quantity |
|
923 | + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
924 | + if (empty($hidetop)) { |
|
925 | + $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | + $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
927 | + } |
|
928 | + |
|
929 | + // Total with all taxes |
|
930 | + $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
|
931 | + if (empty($hidetop)) { |
|
932 | + $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
934 | + } |
|
935 | + |
|
936 | + $pdf->SetTextColor(0,0,0); |
|
937 | + } |
|
938 | + |
|
939 | + /** |
|
940 | + * Show payments table |
|
941 | + * |
|
942 | + * @param PDF $pdf Object PDF |
|
943 | + * @param Object $object Object invoice |
|
944 | + * @param int $posy Position y in PDF |
|
945 | + * @param Translate $outputlangs Object langs for output |
|
946 | + * @return int <0 if KO, >0 if OK |
|
947 | + */ |
|
948 | + private function tablePayments(&$pdf, $object, $posy, $outputlangs) |
|
949 | + { |
|
950 | + global $conf; |
|
951 | + |
|
952 | + $sign=1; |
|
953 | + $tab3_posx = $this->marge_gauche; |
|
954 | + $tab3_top = $posy; |
|
955 | + $tab3_width = 88; |
|
956 | + $tab3_height = 5; |
|
957 | + |
|
958 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
959 | + |
|
960 | + $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | + $pdf->SetFont('','', $default_font_size - 2); |
|
962 | + $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
963 | + $pdf->SetTextColor(0,0,0); |
|
964 | + $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
|
965 | + |
|
966 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
967 | + |
|
968 | + $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
969 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
|
970 | + $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
971 | + $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
|
972 | + $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
973 | + $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
974 | + if (! empty($conf->banque->enabled)) { |
|
975 | + $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
976 | + $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
|
977 | + } |
|
978 | + $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
979 | + |
|
980 | + $y=0; |
|
981 | + |
|
982 | + // Loop on each payment |
|
983 | + // TODO create method on expensereport class to get payments |
|
984 | + // Payments already done (from payment on this expensereport) |
|
985 | + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
|
986 | + $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | + $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | + $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | + $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | + $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | + $sql.= " ORDER BY dp"; |
|
996 | + |
|
997 | + $resql=$this->db->query($sql); |
|
998 | + if ($resql) |
|
999 | + { |
|
1000 | + $num = $this->db->num_rows($resql); |
|
1001 | + $i=0; |
|
1002 | + while ($i < $num) { |
|
1003 | + $y+=$tab3_height; |
|
1004 | + $row = $this->db->fetch_object($resql); |
|
1005 | + |
|
1006 | + $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1009 | + $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
|
1010 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1012 | + |
|
1013 | + $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
|
1014 | + if (! empty($conf->banque->enabled)) { |
|
1015 | + $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1016 | + $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
|
1017 | + } |
|
1018 | + |
|
1019 | + $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1020 | + $totalpaid += $row->amount; |
|
1021 | + $i++; |
|
1022 | + } |
|
1023 | + if ($num > 0 && $object->paid == 0) |
|
1024 | + { |
|
1025 | + $y+=$tab3_height; |
|
1026 | 1026 | |
1027 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1028 | - $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
|
1029 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1030 | - $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
|
1031 | - $y+=$tab3_height-2; |
|
1032 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1033 | - $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
|
1034 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1035 | - $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
|
1036 | - $y+=$tab3_height-2; |
|
1037 | - $remaintopay = $object->total_ttc - $totalpaid; |
|
1038 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1039 | - $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
|
1040 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1041 | - $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
|
1042 | - } |
|
1043 | - } |
|
1044 | - else |
|
1045 | - { |
|
1046 | - $this->error=$this->db->lasterror(); |
|
1047 | - return -1; |
|
1048 | - } |
|
1049 | - } |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * Show footer of page. Need this->emetteur object |
|
1027 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1028 | + $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
|
1029 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1030 | + $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
|
1031 | + $y+=$tab3_height-2; |
|
1032 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1033 | + $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
|
1034 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1035 | + $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
|
1036 | + $y+=$tab3_height-2; |
|
1037 | + $remaintopay = $object->total_ttc - $totalpaid; |
|
1038 | + $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1039 | + $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
|
1040 | + $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1041 | + $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
|
1042 | + } |
|
1043 | + } |
|
1044 | + else |
|
1045 | + { |
|
1046 | + $this->error=$this->db->lasterror(); |
|
1047 | + return -1; |
|
1048 | + } |
|
1049 | + } |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * Show footer of page. Need this->emetteur object |
|
1053 | 1053 | * |
1054 | - * @param PDF $pdf PDF |
|
1055 | - * @param Object $object Object to show |
|
1056 | - * @param Translate $outputlangs Object lang for output |
|
1057 | - * @param int $hidefreetext 1=Hide free text |
|
1058 | - * @return int Return height of bottom margin including footer text |
|
1059 | - */ |
|
1060 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1061 | - { |
|
1062 | - global $conf; |
|
1063 | - $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1064 | - return pdf_pagefoot($pdf, $outputlangs, 'EXPENSEREPORT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1065 | - } |
|
1054 | + * @param PDF $pdf PDF |
|
1055 | + * @param Object $object Object to show |
|
1056 | + * @param Translate $outputlangs Object lang for output |
|
1057 | + * @param int $hidefreetext 1=Hide free text |
|
1058 | + * @return int Return height of bottom margin including footer text |
|
1059 | + */ |
|
1060 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1061 | + { |
|
1062 | + global $conf; |
|
1063 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1064 | + return pdf_pagefoot($pdf, $outputlangs, 'EXPENSEREPORT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1065 | + } |
|
1066 | 1066 | } |
@@ -132,42 +132,42 @@ discard block |
||
132 | 132 | |
133 | 133 | // Dimension page pour format A4 |
134 | 134 | $this->type = 'pdf'; |
135 | - $formatarray=pdf_getFormat(); |
|
135 | + $formatarray = pdf_getFormat(); |
|
136 | 136 | $this->page_largeur = $formatarray['width']; |
137 | 137 | $this->page_hauteur = $formatarray['height']; |
138 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
139 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
140 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
141 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
142 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
143 | - |
|
144 | - $this->option_logo = 1; // Affiche logo |
|
145 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | - $this->option_modereg = 1; // Affiche mode reglement |
|
147 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | - $this->option_credit_note = 0; // Support credit notes |
|
152 | - $this->option_freetext = 1; // Support add of a personalised text |
|
153 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
138 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
139 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
140 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
141 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
142 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
143 | + |
|
144 | + $this->option_logo = 1; // Affiche logo |
|
145 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
146 | + $this->option_modereg = 1; // Affiche mode reglement |
|
147 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
148 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
149 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
150 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
151 | + $this->option_credit_note = 0; // Support credit notes |
|
152 | + $this->option_freetext = 1; // Support add of a personalised text |
|
153 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
154 | 154 | |
155 | 155 | $this->franchise = !$mysoc->tva_assuj; |
156 | 156 | |
157 | 157 | // Get source company |
158 | - $this->emetteur=$mysoc; |
|
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
158 | + $this->emetteur = $mysoc; |
|
159 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined |
|
160 | 160 | |
161 | 161 | // Define position of columns |
162 | - $this->posxpiece=$this->marge_gauche+1; |
|
163 | - $this->posxcomment=$this->marge_gauche+10; |
|
162 | + $this->posxpiece = $this->marge_gauche + 1; |
|
163 | + $this->posxcomment = $this->marge_gauche + 10; |
|
164 | 164 | //$this->posxdate=88; |
165 | 165 | //$this->posxtype=107; |
166 | 166 | //$this->posxprojet=120; |
167 | - $this->posxtva=130; |
|
168 | - $this->posxup=145; |
|
169 | - $this->posxqty=168; |
|
170 | - $this->postotalttc=178; |
|
167 | + $this->posxtva = 130; |
|
168 | + $this->posxup = 145; |
|
169 | + $this->posxqty = 168; |
|
170 | + $this->postotalttc = 178; |
|
171 | 171 | // if (empty($conf->projet->enabled)) { |
172 | 172 | // $this->posxtva-=20; |
173 | 173 | // $this->posxup-=20; |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | // } |
177 | 177 | if ($this->page_largeur < 210) // To work with US executive format |
178 | 178 | { |
179 | - $this->posxdate-=20; |
|
180 | - $this->posxtype-=20; |
|
181 | - $this->posxprojet-=20; |
|
182 | - $this->posxtva-=20; |
|
183 | - $this->posxup-=20; |
|
184 | - $this->posxqty-=20; |
|
185 | - $this->postotalttc-=20; |
|
179 | + $this->posxdate -= 20; |
|
180 | + $this->posxtype -= 20; |
|
181 | + $this->posxprojet -= 20; |
|
182 | + $this->posxtva -= 20; |
|
183 | + $this->posxup -= 20; |
|
184 | + $this->posxqty -= 20; |
|
185 | + $this->postotalttc -= 20; |
|
186 | 186 | } |
187 | 187 | |
188 | - $this->tva=array(); |
|
189 | - $this->localtax1=array(); |
|
190 | - $this->localtax2=array(); |
|
191 | - $this->atleastoneratenotnull=0; |
|
188 | + $this->tva = array(); |
|
189 | + $this->localtax1 = array(); |
|
190 | + $this->localtax2 = array(); |
|
191 | + $this->atleastoneratenotnull = 0; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | // phpcs:enable |
210 | 210 | global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
211 | 211 | |
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
212 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
213 | 213 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
214 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
215 | 215 | |
216 | 216 | // Load traductions files requiredby by page |
217 | 217 | $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
@@ -222,20 +222,20 @@ discard block |
||
222 | 222 | // Definition of $dir and $file |
223 | 223 | if ($object->specimen) { |
224 | 224 | $dir = $conf->expensereport->dir_output; |
225 | - $file = $dir . "/SPECIMEN.pdf"; |
|
225 | + $file = $dir."/SPECIMEN.pdf"; |
|
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | 229 | $objectref = dol_sanitizeFileName($object->ref); |
230 | - $dir = $conf->expensereport->dir_output . "/" . $objectref; |
|
231 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
230 | + $dir = $conf->expensereport->dir_output."/".$objectref; |
|
231 | + $file = $dir."/".$objectref.".pdf"; |
|
232 | 232 | } |
233 | 233 | |
234 | - if (! file_exists($dir)) |
|
234 | + if (!file_exists($dir)) |
|
235 | 235 | { |
236 | 236 | if (dol_mkdir($dir) < 0) |
237 | 237 | { |
238 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
238 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
239 | 239 | return 0; |
240 | 240 | } |
241 | 241 | } |
@@ -243,25 +243,25 @@ discard block |
||
243 | 243 | if (file_exists($dir)) |
244 | 244 | { |
245 | 245 | // Add pdfgeneration hook |
246 | - if (! is_object($hookmanager)) |
|
246 | + if (!is_object($hookmanager)) |
|
247 | 247 | { |
248 | 248 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
249 | - $hookmanager=new HookManager($this->db); |
|
249 | + $hookmanager = new HookManager($this->db); |
|
250 | 250 | } |
251 | 251 | $hookmanager->initHooks(array('pdfgeneration')); |
252 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
252 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
253 | 253 | global $action; |
254 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
254 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
255 | 255 | |
256 | 256 | // Create pdf instance |
257 | - $pdf=pdf_getInstance($this->format); |
|
258 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | - $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 |
|
261 | - $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
257 | + $pdf = pdf_getInstance($this->format); |
|
258 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
259 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
260 | + $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 |
|
261 | + $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
|
262 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
263 | 263 | |
264 | - $pdf->SetAutoPageBreak(1,0); |
|
264 | + $pdf->SetAutoPageBreak(1, 0); |
|
265 | 265 | |
266 | 266 | if (class_exists('TCPDF')) |
267 | 267 | { |
@@ -270,75 +270,75 @@ discard block |
||
270 | 270 | } |
271 | 271 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
272 | 272 | // Set path to the background PDF File |
273 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
273 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
274 | 274 | { |
275 | 275 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
276 | 276 | $tplidx = $pdf->importPage(1); |
277 | 277 | } |
278 | 278 | |
279 | 279 | $pdf->Open(); |
280 | - $pagenb=0; |
|
281 | - $pdf->SetDrawColor(128,128,128); |
|
280 | + $pagenb = 0; |
|
281 | + $pdf->SetDrawColor(128, 128, 128); |
|
282 | 282 | |
283 | 283 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
284 | 284 | $pdf->SetSubject($outputlangs->transnoentities("Trips")); |
285 | 285 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
286 | 286 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
287 | 287 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
288 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
289 | 289 | |
290 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
290 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
291 | 291 | |
292 | 292 | // New page |
293 | 293 | $pdf->AddPage(); |
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
294 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
295 | 295 | $pagenb++; |
296 | 296 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
297 | - $pdf->SetFont('','', $default_font_size - 1); |
|
298 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | - $pdf->SetTextColor(0,0,0); |
|
297 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
298 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
299 | + $pdf->SetTextColor(0, 0, 0); |
|
300 | 300 | |
301 | 301 | $tab_top = 95; |
302 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); |
|
302 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); |
|
303 | 303 | $tab_height = 130; |
304 | 304 | $tab_height_newpage = 150; |
305 | 305 | |
306 | 306 | // Show notes |
307 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
308 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
307 | + $notetoshow = empty($object->note_public) ? '' : $object->note_public; |
|
308 | + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
309 | 309 | { |
310 | 310 | // Get first sale rep |
311 | 311 | if (is_object($object->thirdparty)) |
312 | 312 | { |
313 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
314 | - $salerepobj=new User($this->db); |
|
313 | + $salereparray = $object->thirdparty->getSalesRepresentatives($user); |
|
314 | + $salerepobj = new User($this->db); |
|
315 | 315 | $salerepobj->fetch($salereparray[0]['id']); |
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
316 | + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | if ($notetoshow) |
320 | 320 | { |
321 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
321 | + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); |
|
322 | 322 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
323 | 323 | $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
324 | 324 | |
325 | 325 | $tab_top = 95; |
326 | 326 | |
327 | - $pdf->SetFont('','', $default_font_size - 1); |
|
328 | - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
327 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
328 | + $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
329 | 329 | $nexY = $pdf->GetY(); |
330 | - $height_note=$nexY-$tab_top; |
|
330 | + $height_note = $nexY - $tab_top; |
|
331 | 331 | |
332 | 332 | // Rect prend une longueur en 3eme param |
333 | - $pdf->SetDrawColor(192,192,192); |
|
334 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
333 | + $pdf->SetDrawColor(192, 192, 192); |
|
334 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
335 | 335 | |
336 | 336 | $tab_height = $tab_height - $height_note; |
337 | - $tab_top = $nexY+6; |
|
337 | + $tab_top = $nexY + 6; |
|
338 | 338 | } |
339 | 339 | else |
340 | 340 | { |
341 | - $height_note=0; |
|
341 | + $height_note = 0; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | $iniY = $tab_top + 7; |
@@ -346,41 +346,41 @@ discard block |
||
346 | 346 | $nexY = $tab_top + 7; |
347 | 347 | |
348 | 348 | // Loop on each lines |
349 | - for ($i = 0 ; $i < $nblignes ; $i++) { |
|
350 | - $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage |
|
351 | - $pdf->SetTextColor(0,0,0); |
|
349 | + for ($i = 0; $i < $nblignes; $i++) { |
|
350 | + $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage |
|
351 | + $pdf->SetTextColor(0, 0, 0); |
|
352 | 352 | |
353 | 353 | $pdf->setTopMargin($tab_top_newpage); |
354 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
354 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
355 | 355 | $pageposbefore = $pdf->getPage(); |
356 | 356 | $curY = $nexY; |
357 | 357 | $pdf->startTransaction(); |
358 | 358 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
359 | - $pageposafter=$pdf->getPage(); |
|
359 | + $pageposafter = $pdf->getPage(); |
|
360 | 360 | if ($pageposafter > $pageposbefore) { |
361 | 361 | // There is a pagebreak |
362 | 362 | $pdf->rollbackTransaction(true); |
363 | 363 | $pageposafter = $pageposbefore; |
364 | 364 | //print $pageposafter.'-'.$pageposbefore;exit; |
365 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
365 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
366 | 366 | $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); |
367 | 367 | $pageposafter = $pdf->getPage(); |
368 | 368 | $posyafter = $pdf->GetY(); |
369 | 369 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
370 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
370 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { |
|
371 | 371 | // There is no space left for total+free text |
372 | - if ($i == ($nblignes-1)) { |
|
372 | + if ($i == ($nblignes - 1)) { |
|
373 | 373 | // No more lines, and no space left to show total, so we create a new page |
374 | 374 | $pdf->AddPage('', '', true); |
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
375 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | 376 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
377 | - $pdf->setPage($pageposafter+1); |
|
377 | + $pdf->setPage($pageposafter + 1); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | else |
381 | 381 | { |
382 | 382 | // We found a page break |
383 | - $showpricebeforepagebreak=0; |
|
383 | + $showpricebeforepagebreak = 0; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | else // No pagebreak |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | } |
390 | 390 | //nexY |
391 | 391 | $nexY = $pdf->GetY(); |
392 | - $pageposafter=$pdf->getPage(); |
|
392 | + $pageposafter = $pdf->getPage(); |
|
393 | 393 | $pdf->setPage($pageposbefore); |
394 | 394 | $pdf->setTopMargin($this->marge_haute); |
395 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
395 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
396 | 396 | |
397 | 397 | //$nblineFollowComment = 1; |
398 | 398 | // Cherche nombre de lignes a venir pour savoir si place suffisante |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | // } |
411 | 411 | |
412 | 412 | //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
413 | - $nexY += ($pdf->getFontSize()*1.3); // Passe espace entre les lignes |
|
413 | + $nexY += ($pdf->getFontSize() * 1.3); // Passe espace entre les lignes |
|
414 | 414 | |
415 | 415 | // Detect if some page were added automatically and output _tableau for past pages |
416 | 416 | while ($pagenb < $pageposafter) |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | { |
425 | 425 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
426 | 426 | } |
427 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
427 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
428 | 428 | $pagenb++; |
429 | 429 | $pdf->setPage($pagenb); |
430 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
430 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
431 | 431 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
432 | 432 | } |
433 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
433 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
434 | 434 | { |
435 | 435 | if ($pagenb == 1) |
436 | 436 | { |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | { |
441 | 441 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
442 | 442 | } |
443 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
443 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
444 | 444 | // New page |
445 | 445 | $pdf->AddPage(); |
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
446 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
447 | 447 | $pagenb++; |
448 | 448 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
449 | 449 | } |
@@ -453,80 +453,80 @@ discard block |
||
453 | 453 | if ($pagenb == 1) |
454 | 454 | { |
455 | 455 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
456 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
456 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
457 | 457 | } |
458 | 458 | else |
459 | 459 | { |
460 | 460 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
461 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
461 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
462 | 462 | } |
463 | 463 | |
464 | - $pdf->SetFont('','', 10); |
|
464 | + $pdf->SetFont('', '', 10); |
|
465 | 465 | |
466 | 466 | // Show total area box |
467 | - $posy=$bottomlasttab+5; |
|
467 | + $posy = $bottomlasttab + 5; |
|
468 | 468 | $posy_start_of_totals = $posy; |
469 | 469 | $pdf->SetXY(130, $posy); |
470 | 470 | $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); |
471 | 471 | $pdf->SetXY(180, $posy); |
472 | 472 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ht), 1, 'R'); |
473 | - $pdf->SetFillColor(248,248,248); |
|
473 | + $pdf->SetFillColor(248, 248, 248); |
|
474 | 474 | |
475 | 475 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
476 | 476 | { |
477 | 477 | // TODO Show vat amout per tax level |
478 | - $posy+=5; |
|
478 | + $posy += 5; |
|
479 | 479 | $pdf->SetXY(130, $posy); |
480 | - $pdf->SetTextColor(0,0,60); |
|
481 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); |
|
480 | + $pdf->SetTextColor(0, 0, 60); |
|
481 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1, 'L'); |
|
482 | 482 | $pdf->SetXY(180, $posy); |
483 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva),1, 'R'); |
|
483 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva), 1, 'R'); |
|
484 | 484 | } |
485 | 485 | |
486 | - $posy+=5; |
|
486 | + $posy += 5; |
|
487 | 487 | $pdf->SetXY(130, $posy); |
488 | - $pdf->SetFont('','B', 10); |
|
489 | - $pdf->SetTextColor(0,0,60); |
|
490 | - $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); |
|
488 | + $pdf->SetFont('', 'B', 10); |
|
489 | + $pdf->SetTextColor(0, 0, 60); |
|
490 | + $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalTTC"), 1, 'L'); |
|
491 | 491 | $pdf->SetXY(180, $posy); |
492 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc),1, 'R'); |
|
492 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_ttc), 1, 'R'); |
|
493 | 493 | |
494 | 494 | // show payments zone |
495 | 495 | $sumPayments = $object->getSumPayments(); |
496 | 496 | if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { |
497 | - $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
497 | + $posy = $this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Pied de page |
501 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
501 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
502 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPage(); |
|
503 | 503 | |
504 | 504 | $pdf->Close(); |
505 | 505 | |
506 | - $pdf->Output($file,'F'); |
|
506 | + $pdf->Output($file, 'F'); |
|
507 | 507 | |
508 | 508 | // Add pdfgeneration hook |
509 | 509 | $hookmanager->initHooks(array('pdfgeneration')); |
510 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
510 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
511 | 511 | global $action; |
512 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
512 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
513 | 513 | |
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
514 | + if (!empty($conf->global->MAIN_UMASK)) |
|
515 | 515 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
516 | 516 | |
517 | 517 | $this->result = array('fullpath'=>$file); |
518 | 518 | |
519 | - return 1; // Pas d'erreur |
|
519 | + return 1; // Pas d'erreur |
|
520 | 520 | } |
521 | 521 | else |
522 | 522 | { |
523 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
523 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
524 | 524 | return 0; |
525 | 525 | } |
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
529 | - $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
|
529 | + $this->error = $langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR"); |
|
530 | 530 | return 0; |
531 | 531 | } |
532 | 532 | } |
@@ -541,21 +541,21 @@ discard block |
||
541 | 541 | * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) |
542 | 542 | * @return void |
543 | 543 | */ |
544 | - private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails=0) |
|
544 | + private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0) |
|
545 | 545 | { |
546 | 546 | global $conf; |
547 | - $pdf->SetFont('','', $default_font_size - 1); |
|
547 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
548 | 548 | |
549 | 549 | // Accountancy piece |
550 | 550 | $pdf->SetXY($this->posxpiece, $curY); |
551 | - $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $linenumber + 1, 0, 1); |
|
551 | + $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); |
|
552 | 552 | |
553 | 553 | // Date |
554 | 554 | //$pdf->SetXY($this->posxdate -1, $curY); |
555 | 555 | //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); |
556 | 556 | |
557 | 557 | // Type |
558 | - $pdf->SetXY($this->posxtype -1, $curY); |
|
558 | + $pdf->SetXY($this->posxtype - 1, $curY); |
|
559 | 559 | $nextColumnPosX = $this->posxup; |
560 | 560 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
561 | 561 | $nextColumnPosX = $this->posxtva; |
@@ -585,30 +585,30 @@ discard block |
||
585 | 585 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
586 | 586 | $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); |
587 | 587 | $pdf->SetXY($this->posxtva, $curY); |
588 | - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4,$vat_rate, 0, 'R'); |
|
588 | + $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | // Unit price |
592 | 592 | $pdf->SetXY($this->posxup, $curY); |
593 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4,price($object->lines[$linenumber]->value_unit), 0, 'R'); |
|
593 | + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); |
|
594 | 594 | |
595 | 595 | // Quantity |
596 | 596 | $pdf->SetXY($this->posxqty, $curY); |
597 | - $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4,$object->lines[$linenumber]->qty, 0, 'R'); |
|
597 | + $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); |
|
598 | 598 | |
599 | 599 | // Total with all taxes |
600 | - $pdf->SetXY($this->postotalttc-1, $curY); |
|
601 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); |
|
600 | + $pdf->SetXY($this->postotalttc - 1, $curY); |
|
601 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); |
|
602 | 602 | |
603 | 603 | // Comments |
604 | - $pdf->SetXY($this->posxcomment, $curY ); |
|
605 | - $comment = $outputlangs->trans("Date").':'. dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs).' '; |
|
606 | - $comment .= $outputlangs->trans("Type").':'. $expensereporttypecodetoshow.'<br>'; |
|
607 | - if (! empty($object->lines[$linenumber]->projet_ref)) { |
|
608 | - $comment .= $outputlangs->trans("Project").':'. $object->lines[$linenumber]->projet_ref.'<br>'; |
|
604 | + $pdf->SetXY($this->posxcomment, $curY); |
|
605 | + $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; |
|
606 | + $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>'; |
|
607 | + if (!empty($object->lines[$linenumber]->projet_ref)) { |
|
608 | + $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>'; |
|
609 | 609 | } |
610 | 610 | $comment .= $object->lines[$linenumber]->comments; |
611 | - $pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1); |
|
611 | + $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -638,185 +638,185 @@ discard block |
||
638 | 638 | */ |
639 | 639 | |
640 | 640 | // Draft watermark |
641 | - if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
641 | + if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { |
|
642 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | $pdf->SetTextColor(0, 0, 60); |
646 | 646 | $pdf->SetFont('', 'B', $default_font_size + 3); |
647 | 647 | |
648 | - $posy=$this->marge_haute; |
|
649 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
648 | + $posy = $this->marge_haute; |
|
649 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
650 | 650 | |
651 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
651 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
652 | 652 | |
653 | 653 | // Logo |
654 | 654 | $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
655 | 655 | if ($this->emetteur->logo) { |
656 | 656 | if (is_readable($logo)) { |
657 | - $height=pdf_getHeightForLogo($logo); |
|
658 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
657 | + $height = pdf_getHeightForLogo($logo); |
|
658 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
659 | 659 | } else { |
660 | - $pdf->SetTextColor(200,0,0); |
|
661 | - $pdf->SetFont('','B', $default_font_size -2); |
|
662 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
660 | + $pdf->SetTextColor(200, 0, 0); |
|
661 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
662 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
663 | 663 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | - $text=$this->emetteur->name; |
|
668 | + $text = $this->emetteur->name; |
|
669 | 669 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
670 | 670 | } |
671 | 671 | |
672 | - $pdf->SetFont('','B', $default_font_size + 4); |
|
673 | - $pdf->SetXY($posx,$posy); |
|
674 | - $pdf->SetTextColor(0,0,60); |
|
675 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R'); |
|
672 | + $pdf->SetFont('', 'B', $default_font_size + 4); |
|
673 | + $pdf->SetXY($posx, $posy); |
|
674 | + $pdf->SetTextColor(0, 0, 60); |
|
675 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans("ExpenseReport"), 0, 'R'); |
|
676 | 676 | |
677 | - $pdf->SetFont('','', $default_font_size -1); |
|
677 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
678 | 678 | |
679 | 679 | // Ref complete |
680 | - $posy+=8; |
|
681 | - $pdf->SetXY($posx,$posy); |
|
682 | - $pdf->SetTextColor(0,0,60); |
|
683 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); |
|
680 | + $posy += 8; |
|
681 | + $pdf->SetXY($posx, $posy); |
|
682 | + $pdf->SetTextColor(0, 0, 60); |
|
683 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); |
|
684 | 684 | |
685 | 685 | // Date start period |
686 | - $posy+=5; |
|
687 | - $pdf->SetXY($posx,$posy); |
|
688 | - $pdf->SetTextColor(0,0,60); |
|
689 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R'); |
|
686 | + $posy += 5; |
|
687 | + $pdf->SetXY($posx, $posy); |
|
688 | + $pdf->SetTextColor(0, 0, 60); |
|
689 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart")." : ".($object->date_debut > 0 ?dol_print_date($object->date_debut, "day", false, $outputlangs) : ''), '', 'R'); |
|
690 | 690 | |
691 | 691 | // Date end period |
692 | - $posy+=5; |
|
693 | - $pdf->SetXY($posx,$posy); |
|
694 | - $pdf->SetTextColor(0,0,60); |
|
695 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R'); |
|
692 | + $posy += 5; |
|
693 | + $pdf->SetXY($posx, $posy); |
|
694 | + $pdf->SetTextColor(0, 0, 60); |
|
695 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd")." : ".($object->date_fin > 0 ?dol_print_date($object->date_fin, "day", false, $outputlangs) : ''), '', 'R'); |
|
696 | 696 | |
697 | 697 | // Status Expense Report |
698 | - $posy+=6; |
|
699 | - $pdf->SetXY($posx,$posy); |
|
700 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
701 | - $pdf->SetTextColor(111,81,124); |
|
702 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); |
|
698 | + $posy += 6; |
|
699 | + $pdf->SetXY($posx, $posy); |
|
700 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
701 | + $pdf->SetTextColor(111, 81, 124); |
|
702 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $object->getLibStatut(0), '', 'R'); |
|
703 | 703 | |
704 | 704 | if ($showaddress) { |
705 | 705 | // Sender properties |
706 | 706 | $carac_emetteur = ''; |
707 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
707 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->address); |
|
708 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
|
709 | 709 | $carac_emetteur .= "\n"; |
710 | 710 | // Phone |
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
711 | + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
712 | 712 | // Fax |
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
713 | + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '').$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
714 | 714 | |
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
715 | + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
716 | 716 | // Web |
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
717 | + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
718 | 718 | |
719 | 719 | // Show sender |
720 | - $posy=50; |
|
721 | - $posx=$this->marge_gauche; |
|
722 | - $hautcadre=40; |
|
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
720 | + $posy = 50; |
|
721 | + $posx = $this->marge_gauche; |
|
722 | + $hautcadre = 40; |
|
723 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = 118; |
|
724 | 724 | |
725 | 725 | // Show sender frame |
726 | 726 | $pdf->SetTextColor(0, 0, 0); |
727 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
728 | - $pdf->SetXY($posx,$posy-5); |
|
729 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L'); |
|
730 | - $pdf->SetXY($posx,$posy); |
|
731 | - $pdf->SetFillColor(224,224,224); |
|
727 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
728 | + $pdf->SetXY($posx, $posy - 5); |
|
729 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete")." :", '', 'L'); |
|
730 | + $pdf->SetXY($posx, $posy); |
|
731 | + $pdf->SetFillColor(224, 224, 224); |
|
732 | 732 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
733 | 733 | $pdf->SetTextColor(0, 0, 60); |
734 | 734 | |
735 | 735 | // Show sender name |
736 | - $pdf->SetXY($posx+2,$posy+3); |
|
737 | - $pdf->SetFont('','B', $default_font_size); |
|
736 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
737 | + $pdf->SetFont('', 'B', $default_font_size); |
|
738 | 738 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
739 | 739 | |
740 | 740 | // Show sender information |
741 | - $pdf->SetXY($posx+2,$posy+8); |
|
741 | + $pdf->SetXY($posx + 2, $posy + 8); |
|
742 | 742 | $pdf->SetFont('', '', $default_font_size - 1); |
743 | 743 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
744 | 744 | |
745 | 745 | // Show recipient |
746 | - $posy=50; |
|
747 | - $posx=100; |
|
746 | + $posy = 50; |
|
747 | + $posx = 100; |
|
748 | 748 | |
749 | 749 | // Show recipient frame |
750 | 750 | $pdf->SetTextColor(0, 0, 0); |
751 | 751 | $pdf->SetFont('', 'B', 8); |
752 | - $pdf->SetXY($posx,$posy-5); |
|
752 | + $pdf->SetXY($posx, $posy - 5); |
|
753 | 753 | $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); |
754 | 754 | $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); |
755 | 755 | |
756 | 756 | // Informations for trip (dates and users workflow) |
757 | 757 | if ($object->fk_user_author > 0) { |
758 | - $userfee=new User($this->db); |
|
759 | - $userfee->fetch($object->fk_user_author); $posy+=3; |
|
760 | - $pdf->SetXY($posx+2,$posy); |
|
761 | - $pdf->SetFont('','',10); |
|
762 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
763 | - $posy+=5; |
|
764 | - $pdf->SetXY($posx+2,$posy); |
|
765 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L'); |
|
758 | + $userfee = new User($this->db); |
|
759 | + $userfee->fetch($object->fk_user_author); $posy += 3; |
|
760 | + $pdf->SetXY($posx + 2, $posy); |
|
761 | + $pdf->SetFont('', '', 10); |
|
762 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
763 | + $posy += 5; |
|
764 | + $pdf->SetXY($posx + 2, $posy); |
|
765 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); |
|
766 | 766 | } |
767 | 767 | |
768 | - if ($object->fk_statut==99) |
|
768 | + if ($object->fk_statut == 99) |
|
769 | 769 | { |
770 | 770 | if ($object->fk_user_refuse > 0) { |
771 | - $userfee=new User($this->db); |
|
772 | - $userfee->fetch($object->fk_user_refuse); $posy+=6; |
|
773 | - $pdf->SetXY($posx+2,$posy); |
|
774 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
775 | - $posy+=5; |
|
776 | - $pdf->SetXY($posx+2,$posy); |
|
777 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); |
|
778 | - $posy+=5; |
|
779 | - $pdf->SetXY($posx+2,$posy); |
|
780 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
|
771 | + $userfee = new User($this->db); |
|
772 | + $userfee->fetch($object->fk_user_refuse); $posy += 6; |
|
773 | + $pdf->SetXY($posx + 2, $posy); |
|
774 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
775 | + $posy += 5; |
|
776 | + $pdf->SetXY($posx + 2, $posy); |
|
777 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L'); |
|
778 | + $posy += 5; |
|
779 | + $pdf->SetXY($posx + 2, $posy); |
|
780 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse, "day", false, $outputlangs), 0, 'L'); |
|
781 | 781 | } |
782 | 782 | } |
783 | - else if($object->fk_statut==4) |
|
783 | + else if ($object->fk_statut == 4) |
|
784 | 784 | { |
785 | 785 | if ($object->fk_user_cancel > 0) { |
786 | - $userfee=new User($this->db); |
|
787 | - $userfee->fetch($object->fk_user_cancel); $posy+=6; |
|
788 | - $pdf->SetXY($posx+2,$posy); |
|
789 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
790 | - $posy+=5; |
|
791 | - $pdf->SetXY($posx+2,$posy); |
|
792 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); |
|
793 | - $posy+=5; |
|
794 | - $pdf->SetXY($posx+2,$posy); |
|
795 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
|
786 | + $userfee = new User($this->db); |
|
787 | + $userfee->fetch($object->fk_user_cancel); $posy += 6; |
|
788 | + $pdf->SetXY($posx + 2, $posy); |
|
789 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
790 | + $posy += 5; |
|
791 | + $pdf->SetXY($posx + 2, $posy); |
|
792 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L'); |
|
793 | + $posy += 5; |
|
794 | + $pdf->SetXY($posx + 2, $posy); |
|
795 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel, "day", false, $outputlangs), 0, 'L'); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | else |
799 | 799 | { |
800 | 800 | if ($object->fk_user_approve > 0) { |
801 | - $userfee=new User($this->db); |
|
802 | - $userfee->fetch($object->fk_user_approve); $posy+=6; |
|
803 | - $pdf->SetXY($posx+2,$posy); |
|
804 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
805 | - $posy+=5; |
|
806 | - $pdf->SetXY($posx+2,$posy); |
|
807 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L'); |
|
801 | + $userfee = new User($this->db); |
|
802 | + $userfee->fetch($object->fk_user_approve); $posy += 6; |
|
803 | + $pdf->SetXY($posx + 2, $posy); |
|
804 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
805 | + $posy += 5; |
|
806 | + $pdf->SetXY($posx + 2, $posy); |
|
807 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs), 0, 'L'); |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | - if($object->fk_statut==6) { |
|
811 | + if ($object->fk_statut == 6) { |
|
812 | 812 | if ($object->fk_user_paid > 0) { |
813 | - $userfee=new User($this->db); |
|
814 | - $userfee->fetch($object->fk_user_paid); $posy+=6; |
|
815 | - $pdf->SetXY($posx+2,$posy); |
|
816 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L'); |
|
817 | - $posy+=5; |
|
818 | - $pdf->SetXY($posx+2,$posy); |
|
819 | - $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L'); |
|
813 | + $userfee = new User($this->db); |
|
814 | + $userfee->fetch($object->fk_user_paid); $posy += 6; |
|
815 | + $pdf->SetXY($posx + 2, $posy); |
|
816 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); |
|
817 | + $posy += 5; |
|
818 | + $pdf->SetXY($posx + 2, $posy); |
|
819 | + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement, "day", false, $outputlangs), 0, 'L'); |
|
820 | 820 | } |
821 | 821 | } |
822 | 822 | } |
@@ -835,46 +835,46 @@ discard block |
||
835 | 835 | * @param string $currency Currency code |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
838 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
839 | 839 | { |
840 | 840 | global $conf; |
841 | 841 | |
842 | 842 | // Force to disable hidetop and hidebottom |
843 | - $hidebottom=0; |
|
844 | - if ($hidetop) $hidetop=-1; |
|
843 | + $hidebottom = 0; |
|
844 | + if ($hidetop) $hidetop = -1; |
|
845 | 845 | |
846 | 846 | $currency = !empty($currency) ? $currency : $conf->currency; |
847 | 847 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
848 | 848 | |
849 | 849 | // Amount in (at tab_top - 1) |
850 | - $pdf->SetTextColor(0,0,0); |
|
850 | + $pdf->SetTextColor(0, 0, 0); |
|
851 | 851 | $pdf->SetFont('', '', $default_font_size - 2); |
852 | 852 | $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
853 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); |
|
853 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4); |
|
854 | 854 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
855 | 855 | |
856 | - $pdf->SetDrawColor(128,128,128); |
|
856 | + $pdf->SetDrawColor(128, 128, 128); |
|
857 | 857 | |
858 | 858 | // Rect prend une longueur en 3eme param |
859 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
859 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); |
|
860 | 860 | // line prend une position y en 3eme param |
861 | 861 | if (empty($hidetop)) { |
862 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
862 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); |
|
863 | 863 | } |
864 | 864 | |
865 | - $pdf->SetFont('','',8); |
|
865 | + $pdf->SetFont('', '', 8); |
|
866 | 866 | |
867 | 867 | // Accountancy piece |
868 | 868 | if (empty($hidetop)) { |
869 | - $pdf->SetXY($this->posxpiece-1, $tab_top+1); |
|
870 | - $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); |
|
869 | + $pdf->SetXY($this->posxpiece - 1, $tab_top + 1); |
|
870 | + $pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R'); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // Comments |
874 | - $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); |
|
874 | + $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height); |
|
875 | 875 | if (empty($hidetop)) { |
876 | - $pdf->SetXY($this->posxcomment-1, $tab_top+1); |
|
877 | - $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"),'','L'); |
|
876 | + $pdf->SetXY($this->posxcomment - 1, $tab_top + 1); |
|
877 | + $pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | // Date |
@@ -905,35 +905,35 @@ discard block |
||
905 | 905 | |
906 | 906 | // VAT |
907 | 907 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
908 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
908 | + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); |
|
909 | 909 | if (empty($hidetop)) { |
910 | - $pdf->SetXY($this->posxtva-1, $tab_top+1); |
|
911 | - $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
910 | + $pdf->SetXY($this->posxtva - 1, $tab_top + 1); |
|
911 | + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | // Unit price |
916 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
916 | + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); |
|
917 | 917 | if (empty($hidetop)) { |
918 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
919 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); |
|
918 | + $pdf->SetXY($this->posxup - 1, $tab_top + 1); |
|
919 | + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | // Quantity |
923 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
923 | + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); |
|
924 | 924 | if (empty($hidetop)) { |
925 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
926 | - $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R'); |
|
925 | + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); |
|
926 | + $pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'R'); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | // Total with all taxes |
930 | 930 | $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); |
931 | 931 | if (empty($hidetop)) { |
932 | - $pdf->SetXY($this->postotalttc-1, $tab_top+1); |
|
933 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); |
|
932 | + $pdf->SetXY($this->postotalttc - 1, $tab_top + 1); |
|
933 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); |
|
934 | 934 | } |
935 | 935 | |
936 | - $pdf->SetTextColor(0,0,0); |
|
936 | + $pdf->SetTextColor(0, 0, 0); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | { |
950 | 950 | global $conf; |
951 | 951 | |
952 | - $sign=1; |
|
952 | + $sign = 1; |
|
953 | 953 | $tab3_posx = $this->marge_gauche; |
954 | 954 | $tab3_top = $posy; |
955 | 955 | $tab3_width = 88; |
@@ -957,93 +957,93 @@ discard block |
||
957 | 957 | |
958 | 958 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
959 | 959 | |
960 | - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | - $pdf->SetFont('','', $default_font_size - 2); |
|
960 | + $title = $outputlangs->transnoentities("PaymentsAlreadyDone"); |
|
961 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
962 | 962 | $pdf->SetXY($tab3_posx, $tab3_top - 4); |
963 | - $pdf->SetTextColor(0,0,0); |
|
963 | + $pdf->SetTextColor(0, 0, 0); |
|
964 | 964 | $pdf->MultiCell(60, 3, $title, 0, 'L', 0); |
965 | 965 | |
966 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title |
|
966 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top); // Top border line of table title |
|
967 | 967 | |
968 | - $pdf->SetXY($tab3_posx, $tab3_top+1); |
|
968 | + $pdf->SetXY($tab3_posx, $tab3_top + 1); |
|
969 | 969 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); |
970 | - $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 |
|
970 | + $pdf->SetXY($tab3_posx + 19, $tab3_top + 1); // Old value 17 |
|
971 | 971 | $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); |
972 | - $pdf->SetXY($tab3_posx+35, $tab3_top+1); |
|
972 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + 1); |
|
973 | 973 | $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
974 | - if (! empty($conf->banque->enabled)) { |
|
975 | - $pdf->SetXY($tab3_posx+65, $tab3_top+1); |
|
974 | + if (!empty($conf->banque->enabled)) { |
|
975 | + $pdf->SetXY($tab3_posx + 65, $tab3_top + 1); |
|
976 | 976 | $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); |
977 | 977 | } |
978 | - $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title |
|
978 | + $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height); // Bottom border line of table title |
|
979 | 979 | |
980 | - $y=0; |
|
980 | + $y = 0; |
|
981 | 981 | |
982 | 982 | // Loop on each payment |
983 | 983 | // TODO create method on expensereport class to get payments |
984 | 984 | // Payments already done (from payment on this expensereport) |
985 | 985 | $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; |
986 | - $sql.= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; |
|
991 | - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | - $sql.= " WHERE e.rowid = '".$object->id."'"; |
|
993 | - $sql.= " AND p.fk_expensereport = e.rowid"; |
|
994 | - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | - $sql.= " ORDER BY dp"; |
|
996 | - |
|
997 | - $resql=$this->db->query($sql); |
|
986 | + $sql .= "c.code as p_code, c.libelle as payment_type,"; |
|
987 | + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; |
|
988 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; |
|
989 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; |
|
990 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; |
|
991 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; |
|
992 | + $sql .= " WHERE e.rowid = '".$object->id."'"; |
|
993 | + $sql .= " AND p.fk_expensereport = e.rowid"; |
|
994 | + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; |
|
995 | + $sql .= " ORDER BY dp"; |
|
996 | + |
|
997 | + $resql = $this->db->query($sql); |
|
998 | 998 | if ($resql) |
999 | 999 | { |
1000 | 1000 | $num = $this->db->num_rows($resql); |
1001 | - $i=0; |
|
1001 | + $i = 0; |
|
1002 | 1002 | while ($i < $num) { |
1003 | - $y+=$tab3_height; |
|
1003 | + $y += $tab3_height; |
|
1004 | 1004 | $row = $this->db->fetch_object($resql); |
1005 | 1005 | |
1006 | - $pdf->SetXY($tab3_posx, $tab3_top+$y+1); |
|
1007 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1008 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); |
|
1006 | + $pdf->SetXY($tab3_posx, $tab3_top + $y + 1); |
|
1007 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp), 'day', false, $outputlangs, true), 0, 'L', 0); |
|
1008 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1); |
|
1009 | 1009 | $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); |
1010 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); |
|
1011 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); |
|
1010 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1); |
|
1011 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->p_code); |
|
1012 | 1012 | |
1013 | 1013 | $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); |
1014 | - if (! empty($conf->banque->enabled)) { |
|
1015 | - $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); |
|
1014 | + if (!empty($conf->banque->enabled)) { |
|
1015 | + $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1); |
|
1016 | 1016 | $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table |
|
1019 | + $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height); // Bottom line border of table |
|
1020 | 1020 | $totalpaid += $row->amount; |
1021 | 1021 | $i++; |
1022 | 1022 | } |
1023 | 1023 | if ($num > 0 && $object->paid == 0) |
1024 | 1024 | { |
1025 | - $y+=$tab3_height; |
|
1025 | + $y += $tab3_height; |
|
1026 | 1026 | |
1027 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1027 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1028 | 1028 | $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); |
1029 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1029 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1030 | 1030 | $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); |
1031 | - $y+=$tab3_height-2; |
|
1032 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1031 | + $y += $tab3_height - 2; |
|
1032 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1033 | 1033 | $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); |
1034 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1034 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1035 | 1035 | $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); |
1036 | - $y+=$tab3_height-2; |
|
1036 | + $y += $tab3_height - 2; |
|
1037 | 1037 | $remaintopay = $object->total_ttc - $totalpaid; |
1038 | - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); |
|
1038 | + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); |
|
1039 | 1039 | $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); |
1040 | - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
|
1040 | + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); |
|
1041 | 1041 | $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | else |
1045 | 1045 | { |
1046 | - $this->error=$this->db->lasterror(); |
|
1046 | + $this->error = $this->db->lasterror(); |
|
1047 | 1047 | return -1; |
1048 | 1048 | } |
1049 | 1049 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | * @param int $hidefreetext 1=Hide free text |
1058 | 1058 | * @return int Return height of bottom margin including footer text |
1059 | 1059 | */ |
1060 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1060 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1061 | 1061 | { |
1062 | 1062 | global $conf; |
1063 | 1063 | $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
@@ -156,7 +156,10 @@ discard block |
||
156 | 156 | |
157 | 157 | // Get source company |
158 | 158 | $this->emetteur=$mysoc; |
159 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
159 | + if (empty($this->emetteur->country_code)) { |
|
160 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
161 | + } |
|
162 | + // By default, if was not defined |
|
160 | 163 | |
161 | 164 | // Define position of columns |
162 | 165 | $this->posxpiece=$this->marge_gauche+1; |
@@ -174,9 +177,11 @@ discard block |
||
174 | 177 | // $this->posxqty-=20; |
175 | 178 | // $this->postotalttc-=20; |
176 | 179 | // } |
177 | - if ($this->page_largeur < 210) // To work with US executive format |
|
180 | + if ($this->page_largeur < 210) { |
|
181 | + // To work with US executive format |
|
178 | 182 | { |
179 | 183 | $this->posxdate-=20; |
184 | + } |
|
180 | 185 | $this->posxtype-=20; |
181 | 186 | $this->posxprojet-=20; |
182 | 187 | $this->posxtva-=20; |
@@ -209,9 +214,13 @@ discard block |
||
209 | 214 | // phpcs:enable |
210 | 215 | global $user, $langs, $conf, $mysoc, $db, $hookmanager; |
211 | 216 | |
212 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
217 | + if (! is_object($outputlangs)) { |
|
218 | + $outputlangs=$langs; |
|
219 | + } |
|
213 | 220 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
214 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
221 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
222 | + $outputlangs->charset_output='ISO-8859-1'; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | // Load traductions files requiredby by page |
217 | 226 | $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); |
@@ -223,8 +232,7 @@ discard block |
||
223 | 232 | if ($object->specimen) { |
224 | 233 | $dir = $conf->expensereport->dir_output; |
225 | 234 | $file = $dir . "/SPECIMEN.pdf"; |
226 | - } |
|
227 | - else |
|
235 | + } else |
|
228 | 236 | { |
229 | 237 | $objectref = dol_sanitizeFileName($object->ref); |
230 | 238 | $dir = $conf->expensereport->dir_output . "/" . $objectref; |
@@ -259,7 +267,9 @@ discard block |
||
259 | 267 | $heightforinfotot = 40; // Height reserved to output the info and total part |
260 | 268 | $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 |
261 | 269 | $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) |
262 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
270 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
271 | + $heightforfooter+= 6; |
|
272 | + } |
|
263 | 273 | |
264 | 274 | $pdf->SetAutoPageBreak(1,0); |
265 | 275 | |
@@ -285,13 +295,17 @@ discard block |
||
285 | 295 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
286 | 296 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
287 | 297 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); |
288 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
298 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
299 | + $pdf->SetCompression(false); |
|
300 | + } |
|
289 | 301 | |
290 | 302 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
291 | 303 | |
292 | 304 | // New page |
293 | 305 | $pdf->AddPage(); |
294 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
306 | + if (! empty($tplidx)) { |
|
307 | + $pdf->useTemplate($tplidx); |
|
308 | + } |
|
295 | 309 | $pagenb++; |
296 | 310 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
297 | 311 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -313,7 +327,9 @@ discard block |
||
313 | 327 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
314 | 328 | $salerepobj=new User($this->db); |
315 | 329 | $salerepobj->fetch($salereparray[0]['id']); |
316 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
330 | + if (! empty($salerepobj->signature)) { |
|
331 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
332 | + } |
|
317 | 333 | } |
318 | 334 | } |
319 | 335 | if ($notetoshow) |
@@ -335,8 +351,7 @@ discard block |
||
335 | 351 | |
336 | 352 | $tab_height = $tab_height - $height_note; |
337 | 353 | $tab_top = $nexY+6; |
338 | - } |
|
339 | - else |
|
354 | + } else |
|
340 | 355 | { |
341 | 356 | $height_note=0; |
342 | 357 | } |
@@ -372,18 +387,20 @@ discard block |
||
372 | 387 | if ($i == ($nblignes-1)) { |
373 | 388 | // No more lines, and no space left to show total, so we create a new page |
374 | 389 | $pdf->AddPage('', '', true); |
375 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
376 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
390 | + if (! empty($tplidx)) { |
|
391 | + $pdf->useTemplate($tplidx); |
|
392 | + } |
|
393 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
394 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
395 | + } |
|
377 | 396 | $pdf->setPage($pageposafter+1); |
378 | 397 | } |
379 | - } |
|
380 | - else |
|
398 | + } else |
|
381 | 399 | { |
382 | 400 | // We found a page break |
383 | 401 | $showpricebeforepagebreak=0; |
384 | 402 | } |
385 | - } |
|
386 | - else // No pagebreak |
|
403 | + } else // No pagebreak |
|
387 | 404 | { |
388 | 405 | $pdf->commitTransaction(); |
389 | 406 | } |
@@ -419,8 +436,7 @@ discard block |
||
419 | 436 | if ($pagenb == 1) |
420 | 437 | { |
421 | 438 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
422 | - } |
|
423 | - else |
|
439 | + } else |
|
424 | 440 | { |
425 | 441 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
426 | 442 | } |
@@ -428,24 +444,29 @@ discard block |
||
428 | 444 | $pagenb++; |
429 | 445 | $pdf->setPage($pagenb); |
430 | 446 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
431 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
447 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
448 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
449 | + } |
|
432 | 450 | } |
433 | 451 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
434 | 452 | { |
435 | 453 | if ($pagenb == 1) |
436 | 454 | { |
437 | 455 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
438 | - } |
|
439 | - else |
|
456 | + } else |
|
440 | 457 | { |
441 | 458 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
442 | 459 | } |
443 | 460 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
444 | 461 | // New page |
445 | 462 | $pdf->AddPage(); |
446 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
463 | + if (! empty($tplidx)) { |
|
464 | + $pdf->useTemplate($tplidx); |
|
465 | + } |
|
447 | 466 | $pagenb++; |
448 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
467 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
468 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
469 | + } |
|
449 | 470 | } |
450 | 471 | } |
451 | 472 | |
@@ -454,8 +475,7 @@ discard block |
||
454 | 475 | { |
455 | 476 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
456 | 477 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
457 | - } |
|
458 | - else |
|
478 | + } else |
|
459 | 479 | { |
460 | 480 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
461 | 481 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -499,7 +519,9 @@ discard block |
||
499 | 519 | |
500 | 520 | // Pied de page |
501 | 521 | $this->_pagefoot($pdf,$object,$outputlangs); |
502 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPage(); |
|
522 | + if (method_exists($pdf,'AliasNbPages')) { |
|
523 | + $pdf->AliasNbPage(); |
|
524 | + } |
|
503 | 525 | |
504 | 526 | $pdf->Close(); |
505 | 527 | |
@@ -511,20 +533,19 @@ discard block |
||
511 | 533 | global $action; |
512 | 534 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
513 | 535 | |
514 | - if (! empty($conf->global->MAIN_UMASK)) |
|
515 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
536 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
537 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
538 | + } |
|
516 | 539 | |
517 | 540 | $this->result = array('fullpath'=>$file); |
518 | 541 | |
519 | 542 | return 1; // Pas d'erreur |
520 | - } |
|
521 | - else |
|
543 | + } else |
|
522 | 544 | { |
523 | 545 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
524 | 546 | return 0; |
525 | 547 | } |
526 | - } |
|
527 | - else |
|
548 | + } else |
|
528 | 549 | { |
529 | 550 | $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); |
530 | 551 | return 0; |
@@ -662,8 +683,7 @@ discard block |
||
662 | 683 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
663 | 684 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
664 | 685 | } |
665 | - } |
|
666 | - else |
|
686 | + } else |
|
667 | 687 | { |
668 | 688 | $text=$this->emetteur->name; |
669 | 689 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -708,19 +728,29 @@ discard block |
||
708 | 728 | $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); |
709 | 729 | $carac_emetteur .= "\n"; |
710 | 730 | // Phone |
711 | - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
731 | + if ($this->emetteur->phone) { |
|
732 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); |
|
733 | + } |
|
712 | 734 | // Fax |
713 | - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
735 | + if ($this->emetteur->fax) { |
|
736 | + $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); |
|
737 | + } |
|
714 | 738 | |
715 | - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
739 | + if ($this->emetteur->email) { |
|
740 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); |
|
741 | + } |
|
716 | 742 | // Web |
717 | - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
743 | + if ($this->emetteur->url) { |
|
744 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); |
|
745 | + } |
|
718 | 746 | |
719 | 747 | // Show sender |
720 | 748 | $posy=50; |
721 | 749 | $posx=$this->marge_gauche; |
722 | 750 | $hautcadre=40; |
723 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; |
|
751 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
752 | + $posx=118; |
|
753 | + } |
|
724 | 754 | |
725 | 755 | // Show sender frame |
726 | 756 | $pdf->SetTextColor(0, 0, 0); |
@@ -779,8 +809,7 @@ discard block |
||
779 | 809 | $pdf->SetXY($posx+2,$posy); |
780 | 810 | $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L'); |
781 | 811 | } |
782 | - } |
|
783 | - else if($object->fk_statut==4) |
|
812 | + } else if($object->fk_statut==4) |
|
784 | 813 | { |
785 | 814 | if ($object->fk_user_cancel > 0) { |
786 | 815 | $userfee=new User($this->db); |
@@ -794,8 +823,7 @@ discard block |
||
794 | 823 | $pdf->SetXY($posx+2,$posy); |
795 | 824 | $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L'); |
796 | 825 | } |
797 | - } |
|
798 | - else |
|
826 | + } else |
|
799 | 827 | { |
800 | 828 | if ($object->fk_user_approve > 0) { |
801 | 829 | $userfee=new User($this->db); |
@@ -841,7 +869,9 @@ discard block |
||
841 | 869 | |
842 | 870 | // Force to disable hidetop and hidebottom |
843 | 871 | $hidebottom=0; |
844 | - if ($hidetop) $hidetop=-1; |
|
872 | + if ($hidetop) { |
|
873 | + $hidetop=-1; |
|
874 | + } |
|
845 | 875 | |
846 | 876 | $currency = !empty($currency) ? $currency : $conf->currency; |
847 | 877 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1040,8 +1070,7 @@ discard block |
||
1040 | 1070 | $pdf->SetXY($tab3_posx+35, $tab3_top+$y); |
1041 | 1071 | $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); |
1042 | 1072 | } |
1043 | - } |
|
1044 | - else |
|
1073 | + } else |
|
1045 | 1074 | { |
1046 | 1075 | $this->error=$this->db->lasterror(); |
1047 | 1076 | return -1; |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class mod_expensereport_jade extends ModeleNumRefExpenseReport |
30 | 30 | { |
31 | - /** |
|
31 | + /** |
|
32 | 32 | * Dolibarr version of the loaded document |
33 | 33 | * @public string |
34 | 34 | */ |
35 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | 36 | |
37 | - public $prefix='ER'; |
|
37 | + public $prefix='ER'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error code (or message) |
|
41 | - */ |
|
42 | - public $error=''; |
|
39 | + /** |
|
40 | + * @var string Error code (or message) |
|
41 | + */ |
|
42 | + public $error=''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Jade'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Jade'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Jade'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Jade'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -61,152 +61,152 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function info() |
63 | 63 | { |
64 | - global $langs; |
|
65 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
64 | + global $langs; |
|
65 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Renvoi un exemple de numerotation |
|
71 | - * |
|
72 | - * @return string Example |
|
73 | - */ |
|
74 | - function getExample() |
|
75 | - { |
|
76 | - return $this->prefix."0501-0001"; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
82 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
83 | - * |
|
84 | - * @return boolean false si conflit, true si ok |
|
85 | - */ |
|
86 | - function canBeActivated() |
|
87 | - { |
|
88 | - global $conf,$langs,$db; |
|
89 | - |
|
90 | - $coyymm=''; $max=''; |
|
91 | - |
|
92 | - $posindice=8; |
|
93 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | - $sql.= " AND entity = ".$conf->entity; |
|
97 | - |
|
98 | - $resql=$db->query($sql); |
|
99 | - if ($resql) |
|
100 | - { |
|
101 | - $row = $db->fetch_row($resql); |
|
102 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | - } |
|
104 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
105 | - { |
|
106 | - $langs->load("errors"); |
|
107 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | - return false; |
|
109 | - } |
|
110 | - |
|
111 | - return true; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Return next free value |
|
116 | - * |
|
117 | - * @param Object $object Object we need next value for |
|
118 | - * @return string Value if KO, <0 if KO |
|
119 | - */ |
|
120 | - function getNextValue($object) |
|
121 | - { |
|
122 | - global $db,$conf; |
|
123 | - |
|
124 | - // For backward compatibility and restore old behavior to get ref of expense report |
|
125 | - if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
|
126 | - { |
|
127 | - $fuser = null; |
|
128 | - if ($object->fk_user_author > 0) |
|
129 | - { |
|
130 | - $fuser=new User($db); |
|
131 | - $fuser->fetch($object->fk_user_author); |
|
132 | - } |
|
133 | - |
|
134 | - $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | - $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
136 | - |
|
137 | - $sql = 'SELECT MAX(de.ref_number_int) as max'; |
|
138 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | - |
|
140 | - $result = $db->query($sql); |
|
141 | - |
|
142 | - if($db->num_rows($result) > 0): |
|
143 | - $objp = $db->fetch_object($result); |
|
144 | - $newref = $objp->max; |
|
145 | - $newref++; |
|
146 | - while(strlen($newref) < $num_car): |
|
147 | - $newref = "0".$newref; |
|
148 | - endwhile; |
|
149 | - else: |
|
150 | - $newref = 1; |
|
151 | - while(strlen($newref) < $num_car): |
|
152 | - $newref = "0".$newref; |
|
153 | - endwhile; |
|
154 | - endif; |
|
155 | - |
|
156 | - $ref_number_int = ($newref+1)-1; |
|
157 | - $update_number_int = true; |
|
158 | - |
|
159 | - $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
|
160 | - |
|
161 | - $prefix="ER"; |
|
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | - $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
164 | - |
|
165 | - $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
|
166 | - $resqlbis = $db->query($sqlbis); |
|
167 | - if (! $resqlbis) |
|
168 | - { |
|
169 | - dol_print_error($resqlbis); |
|
170 | - exit; |
|
171 | - } |
|
172 | - |
|
173 | - dol_syslog("mod_expensereport_jade::getNextValue return ".$newref); |
|
174 | - return $newref; |
|
175 | - } |
|
176 | - |
|
177 | - // D'abord on recupere la valeur max |
|
178 | - $posindice=8; |
|
179 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
180 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | - $sql.= " AND entity = ".$conf->entity; |
|
183 | - |
|
184 | - $resql=$db->query($sql); |
|
185 | - if ($resql) |
|
186 | - { |
|
187 | - $obj = $db->fetch_object($resql); |
|
188 | - if ($obj) $max = intval($obj->max); |
|
189 | - else $max=0; |
|
190 | - } |
|
191 | - else |
|
192 | - { |
|
193 | - dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
|
194 | - return 0; |
|
195 | - } |
|
196 | - |
|
197 | - $date=$object->date_valid; // $object->date does not exists |
|
198 | - if (empty($date)) |
|
199 | - { |
|
200 | - $this->error = 'Date valid not defined'; |
|
201 | - return 0; |
|
202 | - } |
|
203 | - |
|
204 | - $yymm = strftime("%y%m",$date); |
|
205 | - |
|
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
208 | - |
|
209 | - dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
210 | - return $this->prefix.$yymm."-".$num; |
|
211 | - } |
|
69 | + /** |
|
70 | + * Renvoi un exemple de numerotation |
|
71 | + * |
|
72 | + * @return string Example |
|
73 | + */ |
|
74 | + function getExample() |
|
75 | + { |
|
76 | + return $this->prefix."0501-0001"; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
82 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
83 | + * |
|
84 | + * @return boolean false si conflit, true si ok |
|
85 | + */ |
|
86 | + function canBeActivated() |
|
87 | + { |
|
88 | + global $conf,$langs,$db; |
|
89 | + |
|
90 | + $coyymm=''; $max=''; |
|
91 | + |
|
92 | + $posindice=8; |
|
93 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
94 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | + $sql.= " AND entity = ".$conf->entity; |
|
97 | + |
|
98 | + $resql=$db->query($sql); |
|
99 | + if ($resql) |
|
100 | + { |
|
101 | + $row = $db->fetch_row($resql); |
|
102 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | + } |
|
104 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
105 | + { |
|
106 | + $langs->load("errors"); |
|
107 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | + return false; |
|
109 | + } |
|
110 | + |
|
111 | + return true; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Return next free value |
|
116 | + * |
|
117 | + * @param Object $object Object we need next value for |
|
118 | + * @return string Value if KO, <0 if KO |
|
119 | + */ |
|
120 | + function getNextValue($object) |
|
121 | + { |
|
122 | + global $db,$conf; |
|
123 | + |
|
124 | + // For backward compatibility and restore old behavior to get ref of expense report |
|
125 | + if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
|
126 | + { |
|
127 | + $fuser = null; |
|
128 | + if ($object->fk_user_author > 0) |
|
129 | + { |
|
130 | + $fuser=new User($db); |
|
131 | + $fuser->fetch($object->fk_user_author); |
|
132 | + } |
|
133 | + |
|
134 | + $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | + $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
136 | + |
|
137 | + $sql = 'SELECT MAX(de.ref_number_int) as max'; |
|
138 | + $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | + |
|
140 | + $result = $db->query($sql); |
|
141 | + |
|
142 | + if($db->num_rows($result) > 0): |
|
143 | + $objp = $db->fetch_object($result); |
|
144 | + $newref = $objp->max; |
|
145 | + $newref++; |
|
146 | + while(strlen($newref) < $num_car): |
|
147 | + $newref = "0".$newref; |
|
148 | + endwhile; |
|
149 | + else: |
|
150 | + $newref = 1; |
|
151 | + while(strlen($newref) < $num_car): |
|
152 | + $newref = "0".$newref; |
|
153 | + endwhile; |
|
154 | + endif; |
|
155 | + |
|
156 | + $ref_number_int = ($newref+1)-1; |
|
157 | + $update_number_int = true; |
|
158 | + |
|
159 | + $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
|
160 | + |
|
161 | + $prefix="ER"; |
|
162 | + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | + $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
164 | + |
|
165 | + $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
|
166 | + $resqlbis = $db->query($sqlbis); |
|
167 | + if (! $resqlbis) |
|
168 | + { |
|
169 | + dol_print_error($resqlbis); |
|
170 | + exit; |
|
171 | + } |
|
172 | + |
|
173 | + dol_syslog("mod_expensereport_jade::getNextValue return ".$newref); |
|
174 | + return $newref; |
|
175 | + } |
|
176 | + |
|
177 | + // D'abord on recupere la valeur max |
|
178 | + $posindice=8; |
|
179 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
180 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | + $sql.= " AND entity = ".$conf->entity; |
|
183 | + |
|
184 | + $resql=$db->query($sql); |
|
185 | + if ($resql) |
|
186 | + { |
|
187 | + $obj = $db->fetch_object($resql); |
|
188 | + if ($obj) $max = intval($obj->max); |
|
189 | + else $max=0; |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
193 | + dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
|
194 | + return 0; |
|
195 | + } |
|
196 | + |
|
197 | + $date=$object->date_valid; // $object->date does not exists |
|
198 | + if (empty($date)) |
|
199 | + { |
|
200 | + $this->error = 'Date valid not defined'; |
|
201 | + return 0; |
|
202 | + } |
|
203 | + |
|
204 | + $yymm = strftime("%y%m",$date); |
|
205 | + |
|
206 | + 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 |
|
207 | + else $num = sprintf("%04s",$max+1); |
|
208 | + |
|
209 | + dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
210 | + return $this->prefix.$yymm."-".$num; |
|
211 | + } |
|
212 | 212 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * \ingroup expensereport |
22 | 22 | * \brief File of class to manage customer order numbering rules Jade |
23 | 23 | */ |
24 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php'; |
|
24 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Class to manage customer order numbering rules Jade |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | * Dolibarr version of the loaded document |
33 | 33 | * @public string |
34 | 34 | */ |
35 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | 36 | |
37 | - public $prefix='ER'; |
|
37 | + public $prefix = 'ER'; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | - public $error=''; |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string Nom du modele |
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Jade'; |
|
49 | + public $nom = 'Jade'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Jade'; |
|
54 | + public $name = 'Jade'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | function info() |
63 | 63 | { |
64 | 64 | global $langs; |
65 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function canBeActivated() |
87 | 87 | { |
88 | - global $conf,$langs,$db; |
|
88 | + global $conf, $langs, $db; |
|
89 | 89 | |
90 | - $coyymm=''; $max=''; |
|
90 | + $coyymm = ''; $max = ''; |
|
91 | 91 | |
92 | - $posindice=8; |
|
92 | + $posindice = 8; |
|
93 | 93 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | - $sql.= " AND entity = ".$conf->entity; |
|
94 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
95 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
96 | + $sql .= " AND entity = ".$conf->entity; |
|
97 | 97 | |
98 | - $resql=$db->query($sql); |
|
98 | + $resql = $db->query($sql); |
|
99 | 99 | if ($resql) |
100 | 100 | { |
101 | 101 | $row = $db->fetch_row($resql); |
102 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
102 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
103 | 103 | } |
104 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
104 | + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
105 | 105 | { |
106 | 106 | $langs->load("errors"); |
107 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
107 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function getNextValue($object) |
121 | 121 | { |
122 | - global $db,$conf; |
|
122 | + global $db, $conf; |
|
123 | 123 | |
124 | 124 | // For backward compatibility and restore old behavior to get ref of expense report |
125 | 125 | if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) |
@@ -127,44 +127,44 @@ discard block |
||
127 | 127 | $fuser = null; |
128 | 128 | if ($object->fk_user_author > 0) |
129 | 129 | { |
130 | - $fuser=new User($db); |
|
130 | + $fuser = new User($db); |
|
131 | 131 | $fuser->fetch($object->fk_user_author); |
132 | 132 | } |
133 | 133 | |
134 | - $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; |
|
135 | - $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; |
|
134 | + $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR)) ? "-" : $conf->global->NDF_EXPLODE_CHAR; |
|
135 | + $num_car = (empty($conf->global->NDF_NUM_CAR_REF)) ? "5" : $conf->global->NDF_NUM_CAR_REF; |
|
136 | 136 | |
137 | 137 | $sql = 'SELECT MAX(de.ref_number_int) as max'; |
138 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
138 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport de'; |
|
139 | 139 | |
140 | 140 | $result = $db->query($sql); |
141 | 141 | |
142 | - if($db->num_rows($result) > 0): |
|
142 | + if ($db->num_rows($result) > 0): |
|
143 | 143 | $objp = $db->fetch_object($result); |
144 | 144 | $newref = $objp->max; |
145 | 145 | $newref++; |
146 | - while(strlen($newref) < $num_car): |
|
146 | + while (strlen($newref) < $num_car): |
|
147 | 147 | $newref = "0".$newref; |
148 | 148 | endwhile; |
149 | 149 | else: |
150 | 150 | $newref = 1; |
151 | - while(strlen($newref) < $num_car): |
|
151 | + while (strlen($newref) < $num_car): |
|
152 | 152 | $newref = "0".$newref; |
153 | 153 | endwhile; |
154 | 154 | endif; |
155 | 155 | |
156 | - $ref_number_int = ($newref+1)-1; |
|
156 | + $ref_number_int = ($newref + 1) - 1; |
|
157 | 157 | $update_number_int = true; |
158 | 158 | |
159 | 159 | $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
160 | 160 | |
161 | - $prefix="ER"; |
|
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | - $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
|
161 | + $prefix = "ER"; |
|
162 | + if (!empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix = $conf->global->EXPENSE_REPORT_PREFIX; |
|
163 | + $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); |
|
164 | 164 | |
165 | 165 | $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
166 | 166 | $resqlbis = $db->query($sqlbis); |
167 | - if (! $resqlbis) |
|
167 | + if (!$resqlbis) |
|
168 | 168 | { |
169 | 169 | dol_print_error($resqlbis); |
170 | 170 | exit; |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // D'abord on recupere la valeur max |
178 | - $posindice=8; |
|
178 | + $posindice = 8; |
|
179 | 179 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
180 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | - $sql.= " AND entity = ".$conf->entity; |
|
180 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport"; |
|
181 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
182 | + $sql .= " AND entity = ".$conf->entity; |
|
183 | 183 | |
184 | - $resql=$db->query($sql); |
|
184 | + $resql = $db->query($sql); |
|
185 | 185 | if ($resql) |
186 | 186 | { |
187 | 187 | $obj = $db->fetch_object($resql); |
188 | 188 | if ($obj) $max = intval($obj->max); |
189 | - else $max=0; |
|
189 | + else $max = 0; |
|
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
@@ -194,17 +194,17 @@ discard block |
||
194 | 194 | return 0; |
195 | 195 | } |
196 | 196 | |
197 | - $date=$object->date_valid; // $object->date does not exists |
|
197 | + $date = $object->date_valid; // $object->date does not exists |
|
198 | 198 | if (empty($date)) |
199 | 199 | { |
200 | 200 | $this->error = 'Date valid not defined'; |
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | - $yymm = strftime("%y%m",$date); |
|
204 | + $yymm = strftime("%y%m", $date); |
|
205 | 205 | |
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
206 | + 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 |
|
207 | + else $num = sprintf("%04s", $max + 1); |
|
208 | 208 | |
209 | 209 | dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
210 | 210 | return $this->prefix.$yymm."-".$num; |
@@ -146,8 +146,10 @@ discard block |
||
146 | 146 | while(strlen($newref) < $num_car): |
147 | 147 | $newref = "0".$newref; |
148 | 148 | endwhile; |
149 | - else: |
|
149 | + else { |
|
150 | + : |
|
150 | 151 | $newref = 1; |
152 | + } |
|
151 | 153 | while(strlen($newref) < $num_car): |
152 | 154 | $newref = "0".$newref; |
153 | 155 | endwhile; |
@@ -159,7 +161,9 @@ discard block |
||
159 | 161 | $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); |
160 | 162 | |
161 | 163 | $prefix="ER"; |
162 | - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
164 | + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) { |
|
165 | + $prefix=$conf->global->EXPENSE_REPORT_PREFIX; |
|
166 | + } |
|
163 | 167 | $newref = str_replace(' ','_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut,'%y%m%d'); |
164 | 168 | |
165 | 169 | $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; |
@@ -185,10 +189,12 @@ discard block |
||
185 | 189 | if ($resql) |
186 | 190 | { |
187 | 191 | $obj = $db->fetch_object($resql); |
188 | - if ($obj) $max = intval($obj->max); |
|
189 | - else $max=0; |
|
190 | - } |
|
191 | - else |
|
192 | + if ($obj) { |
|
193 | + $max = intval($obj->max); |
|
194 | + } else { |
|
195 | + $max=0; |
|
196 | + } |
|
197 | + } else |
|
192 | 198 | { |
193 | 199 | dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG); |
194 | 200 | return 0; |
@@ -203,8 +209,13 @@ discard block |
||
203 | 209 | |
204 | 210 | $yymm = strftime("%y%m",$date); |
205 | 211 | |
206 | - 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 |
|
207 | - else $num = sprintf("%04s",$max+1); |
|
212 | + if ($max >= (pow(10, 4) - 1)) { |
|
213 | + $num=$max+1; |
|
214 | + } |
|
215 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
216 | + else { |
|
217 | + $num = sprintf("%04s",$max+1); |
|
218 | + } |
|
208 | 219 | |
209 | 220 | dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
210 | 221 | return $this->prefix.$yymm."-".$num; |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_expensereport_sand extends ModeleNumRefExpenseReport |
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='Sand'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Sand'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Sand'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Sand'; |
|
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="maskconst" value="EXPENSEREPORT_SAND_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="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
78 | - //$tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
78 | + //$tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
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="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_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="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_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,59 +101,59 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$user; |
|
104 | + global $conf,$langs,$user; |
|
105 | 105 | |
106 | - $exp=new ExpenseReport($this->db); |
|
107 | - $exp->initAsSpecimen(); |
|
108 | - $exp->fk_user_author = $user->id; |
|
106 | + $exp=new ExpenseReport($this->db); |
|
107 | + $exp->initAsSpecimen(); |
|
108 | + $exp->fk_user_author = $user->id; |
|
109 | 109 | |
110 | - $numExample = $this->getNextValue($exp); |
|
110 | + $numExample = $this->getNextValue($exp); |
|
111 | 111 | |
112 | - if (! $numExample) |
|
113 | - { |
|
114 | - $numExample = $langs->trans('NotConfigured'); |
|
115 | - } |
|
116 | - return $numExample; |
|
112 | + if (! $numExample) |
|
113 | + { |
|
114 | + $numExample = $langs->trans('NotConfigured'); |
|
115 | + } |
|
116 | + return $numExample; |
|
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * Return next free value |
|
121 | - * |
|
122 | - * @param Object $object Object we need next value for |
|
123 | - * @return string Value if KO, <0 if KO |
|
124 | - */ |
|
119 | + /** |
|
120 | + * Return next free value |
|
121 | + * |
|
122 | + * @param Object $object Object we need next value for |
|
123 | + * @return string Value if KO, <0 if KO |
|
124 | + */ |
|
125 | 125 | function getNextValue($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->EXPENSEREPORT_SAND_MASK; |
|
131 | + // We get cursor rule |
|
132 | + $mask=$conf->global->EXPENSEREPORT_SAND_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 | - $date=$object->date_valid; // $object->date does not exists |
|
141 | - if (empty($date)) |
|
142 | - { |
|
143 | - $this->error = 'Date valid not defined'; |
|
144 | - return 0; |
|
145 | - } |
|
140 | + $date=$object->date_valid; // $object->date does not exists |
|
141 | + if (empty($date)) |
|
142 | + { |
|
143 | + $this->error = 'Date valid not defined'; |
|
144 | + return 0; |
|
145 | + } |
|
146 | 146 | |
147 | - $fuser = null; |
|
148 | - if ($object->fk_user_author > 0) |
|
149 | - { |
|
150 | - $fuser=new User($db); |
|
151 | - $fuser->fetch($object->fk_user_author); |
|
152 | - } |
|
147 | + $fuser = null; |
|
148 | + if ($object->fk_user_author > 0) |
|
149 | + { |
|
150 | + $fuser=new User($db); |
|
151 | + $fuser->fetch($object->fk_user_author); |
|
152 | + } |
|
153 | 153 | |
154 | - $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
154 | + $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
155 | 155 | |
156 | - return $numFinal; |
|
157 | - } |
|
156 | + return $numFinal; |
|
157 | + } |
|
158 | 158 | } |
159 | 159 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de note de frais Sand |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error message |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Sand'; |
|
49 | + public $nom = 'Sand'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Sand'; |
|
54 | + public $name = 'Sand'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $form = new Form($this->db); |
69 | 69 | |
70 | 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="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
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="maskconst" value="EXPENSEREPORT_SAND_MASK">'; |
|
75 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
77 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); |
|
78 | 78 | //$tooltip.=$langs->trans("GenericMaskCodes2"); |
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | 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="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">',$tooltip,1,1).'</td>'; |
|
84 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_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 | 94 | return $texte; |
95 | 95 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$user; |
|
104 | + global $conf, $langs, $user; |
|
105 | 105 | |
106 | - $exp=new ExpenseReport($this->db); |
|
106 | + $exp = new ExpenseReport($this->db); |
|
107 | 107 | $exp->initAsSpecimen(); |
108 | 108 | $exp->fk_user_author = $user->id; |
109 | 109 | |
110 | 110 | $numExample = $this->getNextValue($exp); |
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function getNextValue($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 | 131 | // We get cursor rule |
132 | - $mask=$conf->global->EXPENSEREPORT_SAND_MASK; |
|
132 | + $mask = $conf->global->EXPENSEREPORT_SAND_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
134 | + if (!$mask) |
|
135 | 135 | { |
136 | - $this->error='NotConfigured'; |
|
136 | + $this->error = 'NotConfigured'; |
|
137 | 137 | return 0; |
138 | 138 | } |
139 | 139 | |
140 | - $date=$object->date_valid; // $object->date does not exists |
|
140 | + $date = $object->date_valid; // $object->date does not exists |
|
141 | 141 | if (empty($date)) |
142 | 142 | { |
143 | 143 | $this->error = 'Date valid not defined'; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $fuser = null; |
148 | 148 | if ($object->fk_user_author > 0) |
149 | 149 | { |
150 | - $fuser=new User($db); |
|
150 | + $fuser = new User($db); |
|
151 | 151 | $fuser->fetch($object->fk_user_author); |
152 | 152 | } |
153 | 153 | |
154 | - $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser); |
|
154 | + $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); |
|
155 | 155 | |
156 | 156 | return $numFinal; |
157 | 157 | } |