Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/core/modules/contract/doc/pdf_strato.modules.php 1 patch
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/modules_contract.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/mod_contract_magre.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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">&nbsp; <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">&nbsp; <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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/mod_contract_olive.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/mod_contract_serpis.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php 1 patch
Spacing   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -132,42 +132,42 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 			// EMail
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expensereport/mod_expensereport_jade.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expensereport/mod_expensereport_sand.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
87
+		$texte .= '<td align="left" rowspan="2">&nbsp; <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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.