Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/modules/stock/doc/pdf_standard.modules.php 1 patch
Spacing   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function __construct($db)
119 119
 	{
120
-		global $conf,$langs,$mysoc;
120
+		global $conf, $langs, $mysoc;
121 121
 
122 122
 		// Load traductions files requiredby by page
123 123
 		$langs->loadLangs(array("main", "companies"));
@@ -128,52 +128,52 @@  discard block
 block discarded – undo
128 128
 
129 129
 		// Dimension page pour format A4
130 130
 		$this->type = 'pdf';
131
-		$formatarray=pdf_getFormat();
131
+		$formatarray = pdf_getFormat();
132 132
 		$this->page_largeur = $formatarray['width'];
133 133
 		$this->page_hauteur = $formatarray['height'];
134
-		$this->format = array($this->page_largeur,$this->page_hauteur);
135
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
136
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
137
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
138
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
134
+		$this->format = array($this->page_largeur, $this->page_hauteur);
135
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
136
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
137
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
138
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
139 139
 
140
-		$this->option_logo = 1;                    // Affiche logo
141
-		$this->option_codestockservice = 0;      // Affiche code stock-service
142
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
143
-		$this->option_freetext = 0;				   // Support add of a personalised text
140
+		$this->option_logo = 1; // Affiche logo
141
+		$this->option_codestockservice = 0; // Affiche code stock-service
142
+		$this->option_multilang = 1; // Dispo en plusieurs langues
143
+		$this->option_freetext = 0; // Support add of a personalised text
144 144
 
145 145
 		// Recupere emetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
146
+		$this->emetteur = $mysoc;
147
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
148 148
 
149 149
 		// Define position of columns
150 150
 		$this->wref = 15;
151
-		$this->posxdesc=$this->marge_gauche+1;
152
-		$this->posxlabel=$this->posxdesc+$this->wref;
153
-		$this->posxtva=80;
154
-		$this->posxqty=95;
155
-		$this->posxup=115;
156
-		$this->posxunit=135;
157
-		$this->posxdiscount=155;
158
-		$this->postotalht=175;
159
-
160
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
161
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
151
+		$this->posxdesc = $this->marge_gauche + 1;
152
+		$this->posxlabel = $this->posxdesc + $this->wref;
153
+		$this->posxtva = 80;
154
+		$this->posxqty = 95;
155
+		$this->posxup = 115;
156
+		$this->posxunit = 135;
157
+		$this->posxdiscount = 155;
158
+		$this->postotalht = 175;
159
+
160
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
161
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
162 162
 		if ($this->page_largeur < 210) // To work with US executive format
163 163
 		{
164
-			$this->posxpicture-=20;
165
-			$this->posxtva-=20;
166
-			$this->posxup-=20;
167
-			$this->posxqty-=20;
168
-			$this->posxunit-=20;
169
-			$this->posxdiscount-=20;
170
-			$this->postotalht-=20;
164
+			$this->posxpicture -= 20;
165
+			$this->posxtva -= 20;
166
+			$this->posxup -= 20;
167
+			$this->posxqty -= 20;
168
+			$this->posxunit -= 20;
169
+			$this->posxdiscount -= 20;
170
+			$this->postotalht -= 20;
171 171
 		}
172
-		$this->tva=array();
173
-		$this->localtax1=array();
174
-		$this->localtax2=array();
175
-		$this->atleastoneratenotnull=0;
176
-		$this->atleastonediscount=0;
172
+		$this->tva = array();
173
+		$this->localtax1 = array();
174
+		$this->localtax2 = array();
175
+		$this->atleastoneratenotnull = 0;
176
+		$this->atleastonediscount = 0;
177 177
 	}
178 178
 
179 179
 
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 	 *  @param		int			$hideref			Do not show ref
190 190
 	 *	@return		int         					1 if OK, <=0 if KO
191 191
 	 */
192
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
192
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
193 193
 	{
194 194
         // phpcs:enable
195
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
195
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
196 196
 
197
-		if (! is_object($outputlangs)) $outputlangs=$langs;
197
+		if (!is_object($outputlangs)) $outputlangs = $langs;
198 198
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
199
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
199
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
200 200
 
201 201
 		// Load traductions files requiredby by page
202 202
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
 			if ($object->specimen)
210 210
 			{
211 211
 				$dir = $conf->stock->dir_output;
212
-				$file = $dir . "/SPECIMEN.pdf";
212
+				$file = $dir."/SPECIMEN.pdf";
213 213
 			}
214 214
 			else
215 215
 			{
216 216
 				$objectref = dol_sanitizeFileName($object->ref);
217
-				$dir = $conf->stock->dir_output . "/" . $objectref;
218
-				$file = $dir . "/" . $objectref . ".pdf";
217
+				$dir = $conf->stock->dir_output."/".$objectref;
218
+				$file = $dir."/".$objectref.".pdf";
219 219
 			}
220 220
 
221 221
 			$stockFournisseur = new ProductFournisseur($this->db);
222 222
 			$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
223 223
 			$object->supplierprices = $supplierprices;
224 224
 
225
-			$productstatic=new Product($db);
225
+			$productstatic = new Product($db);
226 226
 
227
-			if (! file_exists($dir))
227
+			if (!file_exists($dir))
228 228
 			{
229 229
 				if (dol_mkdir($dir) < 0)
230 230
 				{
231
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
231
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
232 232
 					return -1;
233 233
 				}
234 234
 			}
@@ -236,24 +236,24 @@  discard block
 block discarded – undo
236 236
 			if (file_exists($dir))
237 237
 			{
238 238
 				// Add pdfgeneration hook
239
-				if (! is_object($hookmanager))
239
+				if (!is_object($hookmanager))
240 240
 				{
241 241
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
242
-					$hookmanager=new HookManager($this->db);
242
+					$hookmanager = new HookManager($this->db);
243 243
 				}
244 244
 				$hookmanager->initHooks(array('pdfgeneration'));
245
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
245
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
246 246
 				global $action;
247
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
247
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
248 248
 
249 249
 				// Create pdf instance
250
-				$pdf=pdf_getInstance($this->format);
251
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
252
-				$pdf->SetAutoPageBreak(1,0);
250
+				$pdf = pdf_getInstance($this->format);
251
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
252
+				$pdf->SetAutoPageBreak(1, 0);
253 253
 
254
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
255
-		        $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
256
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
254
+				$heightforinfotot = 40; // Height reserved to output the info and total part
255
+		        $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
256
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
257 257
 
258 258
                 if (class_exists('TCPDF'))
259 259
                 {
@@ -262,37 +262,37 @@  discard block
 block discarded – undo
262 262
                 }
263 263
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
264 264
                 // Set path to the background PDF File
265
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
265
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
266 266
                 {
267 267
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
268 268
                     $tplidx = $pdf->importPage(1);
269 269
                 }
270 270
 
271 271
 				$pdf->Open();
272
-				$pagenb=0;
273
-				$pdf->SetDrawColor(128,128,128);
272
+				$pagenb = 0;
273
+				$pdf->SetDrawColor(128, 128, 128);
274 274
 
275 275
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
276 276
 				$pdf->SetSubject($outputlangs->transnoentities("Stock"));
277 277
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
278 278
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
279 279
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
280
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
280
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
281 281
 
282
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
282
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
283 283
 
284 284
 
285 285
 				// New page
286 286
 				$pdf->AddPage();
287
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
287
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
288 288
 				$pagenb++;
289 289
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
290
-				$pdf->SetFont('','', $default_font_size - 1);
291
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
292
-				$pdf->SetTextColor(0,0,0);
290
+				$pdf->SetFont('', '', $default_font_size - 1);
291
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
292
+				$pdf->SetTextColor(0, 0, 0);
293 293
 
294 294
 				$tab_top = 42;
295
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
295
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
296 296
 				$tab_height = 130;
297 297
 				$tab_height_newpage = 150;
298 298
 
@@ -302,20 +302,20 @@  discard block
 block discarded – undo
302 302
 				/*                                                                            */
303 303
 				/* ************************************************************************** */
304 304
 
305
-				$nexY+=5;
305
+				$nexY += 5;
306 306
 				$nexY = $pdf->GetY();
307
-				$nexY+=10;
307
+				$nexY += 10;
308 308
 
309
-				$totalunit=0;
310
-				$totalvalue=$totalvaluesell=0;
309
+				$totalunit = 0;
310
+				$totalvalue = $totalvaluesell = 0;
311 311
 
312 312
 				$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
313
-				$sql.= " ps.reel as value";
314
-				$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
315
-				$sql.= " WHERE ps.fk_product = p.rowid";
316
-				$sql.= " AND ps.reel <> 0";	// We do not show if stock is 0 (no product in this warehouse)
317
-				$sql.= " AND ps.fk_entrepot = ".$object->id;
318
-				$sql.= $db->order($sortfield,$sortorder);
313
+				$sql .= " ps.reel as value";
314
+				$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
315
+				$sql .= " WHERE ps.fk_product = p.rowid";
316
+				$sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)
317
+				$sql .= " AND ps.fk_entrepot = ".$object->id;
318
+				$sql .= $db->order($sortfield, $sortorder);
319 319
 
320 320
 				//dol_syslog('List products', LOG_DEBUG);
321 321
 				$resql = $db->query($sql);
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
 					$num = $db->num_rows($resql);
325 325
 					$i = 0;
326 326
 					$nblignes = $num;
327
-					for ($i = 0 ; $i < $nblignes ; $i++)
327
+					for ($i = 0; $i < $nblignes; $i++)
328 328
 					{
329 329
 						$objp = $db->fetch_object($resql);
330 330
 
331 331
 						// Multilangs
332
-						if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
332
+						if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
333 333
 						{
334 334
 							$sql = "SELECT label";
335
-							$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
336
-							$sql.= " WHERE fk_product=".$objp->rowid;
337
-							$sql.= " AND lang='". $langs->getDefaultLang() ."'";
338
-							$sql.= " LIMIT 1";
335
+							$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
336
+							$sql .= " WHERE fk_product=".$objp->rowid;
337
+							$sql .= " AND lang='".$langs->getDefaultLang()."'";
338
+							$sql .= " LIMIT 1";
339 339
 
340 340
 							$result = $db->query($sql);
341 341
 							if ($result)
@@ -346,122 +346,122 @@  discard block
 block discarded – undo
346 346
 						}
347 347
 
348 348
 						$curY = $nexY;
349
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
350
-						$pdf->SetTextColor(0,0,0);
349
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
350
+						$pdf->SetTextColor(0, 0, 0);
351 351
 
352 352
 						$pdf->setTopMargin($tab_top_newpage);
353
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
354
-						$pageposbefore=$pdf->getPage();
353
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
354
+						$pageposbefore = $pdf->getPage();
355 355
 
356 356
 						// Description of product line
357
-						$curX = $this->posxdesc-1;
357
+						$curX = $this->posxdesc - 1;
358 358
 
359
-						$showpricebeforepagebreak=1;
359
+						$showpricebeforepagebreak = 1;
360 360
 
361 361
 						$pdf->startTransaction();
362
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
363
-						$pageposafter=$pdf->getPage();
362
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
363
+						$pageposafter = $pdf->getPage();
364 364
 						if ($pageposafter > $pageposbefore)	// There is a pagebreak
365 365
 						{
366 366
 							$pdf->rollbackTransaction(true);
367
-							$pageposafter=$pageposbefore;
367
+							$pageposafter = $pageposbefore;
368 368
 							//print $pageposafter.'-'.$pageposbefore;exit;
369
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
370
-							pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
371
-							$pageposafter=$pdf->getPage();
372
-							$posyafter=$pdf->GetY();
373
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
369
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
370
+							pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
371
+							$pageposafter = $pdf->getPage();
372
+							$posyafter = $pdf->GetY();
373
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
374 374
 							{
375
-								if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
375
+								if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
376 376
 								{
377
-									$pdf->AddPage('','',true);
378
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
377
+									$pdf->AddPage('', '', true);
378
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
379 379
 									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
380
-									$pdf->setPage($pageposafter+1);
380
+									$pdf->setPage($pageposafter + 1);
381 381
 								}
382 382
 							}
383 383
 							else
384 384
 							{
385 385
 								// We found a page break
386
-								$showpricebeforepagebreak=0;
386
+								$showpricebeforepagebreak = 0;
387 387
 							}
388 388
 						}
389 389
 						else	// No pagebreak
390 390
 						{
391 391
 							$pdf->commitTransaction();
392 392
 						}
393
-						$posYAfterDescription=$pdf->GetY();
393
+						$posYAfterDescription = $pdf->GetY();
394 394
 
395 395
 						$nexY = $pdf->GetY();
396
-						$pageposafter=$pdf->getPage();
396
+						$pageposafter = $pdf->getPage();
397 397
 
398 398
 						$pdf->setPage($pageposbefore);
399 399
 						$pdf->setTopMargin($this->marge_haute);
400
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
400
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
401 401
 
402 402
 						// We suppose that a too long description is moved completely on next page
403 403
 						if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
404 404
 							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
405 405
 						}
406 406
 
407
-						$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
407
+						$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
408 408
 
409
-						$productstatic->id=$objp->rowid;
409
+						$productstatic->id = $objp->rowid;
410 410
 						$productstatic->ref = $objp->ref;
411 411
 						$productstatic->label = $objp->produit;
412
-						$productstatic->type=$objp->type;
413
-						$productstatic->entity=$objp->entity;
414
-						$productstatic->status_batch=$objp->tobatch;
412
+						$productstatic->type = $objp->type;
413
+						$productstatic->entity = $objp->entity;
414
+						$productstatic->status_batch = $objp->tobatch;
415 415
 
416 416
 						// Ref.
417 417
 						$pdf->SetXY($this->posxdesc, $curY);
418 418
 						$pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L');
419 419
 
420 420
 						// Label
421
-						$pdf->SetXY($this->posxlabel+0.8, $curY);
422
-						$pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 3, $objp->produit, 0, 'L');
421
+						$pdf->SetXY($this->posxlabel + 0.8, $curY);
422
+						$pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3, $objp->produit, 0, 'L');
423 423
 
424 424
 						// Quantity
425
-						$valtoshow=price2num($objp->value, 'MS');
426
-						$towrite = (empty($valtoshow)?'0':$valtoshow);
425
+						$valtoshow = price2num($objp->value, 'MS');
426
+						$towrite = (empty($valtoshow) ? '0' : $valtoshow);
427 427
 
428 428
 						$pdf->SetXY($this->posxqty, $curY);
429
-						$pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R');
429
+						$pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $towrite, 0, 'R');
430 430
 
431
-						$totalunit+=$objp->value;
431
+						$totalunit += $objp->value;
432 432
 
433 433
 						$pdf->SetXY($this->posxup, $curY);
434
-						$pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, price(price2num($objp->ppmp,'MU'), 0, $outputlangs), 0, 'R');
434
+						$pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, price(price2num($objp->ppmp, 'MU'), 0, $outputlangs), 0, 'R');
435 435
 
436 436
 						// Total PMP
437 437
 						$pdf->SetXY($this->posxunit, $curY);
438
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($objp->ppmp*$objp->value,'MT'), 0, $outputlangs), 0, 'R');
439
-						$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
438
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, price(price2num($objp->ppmp * $objp->value, 'MT'), 0, $outputlangs), 0, 'R');
439
+						$totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
440 440
 
441 441
 						// Price sell min
442 442
 						if (empty($conf->global->PRODUIT_MULTIPRICES))
443 443
 						{
444
-							$pricemin=$objp->price;
444
+							$pricemin = $objp->price;
445 445
 							$pdf->SetXY($this->posxdiscount, $curY);
446
-							$pdf->MultiCell($this->postotalht-$this->posxdiscount, 3, price(price2num($pricemin,'MU'), 0, $outputlangs), 0, 'R', 0);
446
+							$pdf->MultiCell($this->postotalht - $this->posxdiscount, 3, price(price2num($pricemin, 'MU'), 0, $outputlangs), 0, 'R', 0);
447 447
 
448 448
 							// Total sell min
449 449
 							$pdf->SetXY($this->postotalht, $curY);
450
-							$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($pricemin*$objp->value,'MT'), 0, $outputlangs), 0, 'R', 0);
450
+							$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, price(price2num($pricemin * $objp->value, 'MT'), 0, $outputlangs), 0, 'R', 0);
451 451
 						}
452
-						$totalvaluesell+=price2num($pricemin*$objp->value,'MT');
452
+						$totalvaluesell += price2num($pricemin * $objp->value, 'MT');
453 453
 
454 454
 						// Add line
455
-						if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
455
+						if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
456 456
 						{
457 457
 							$pdf->setPage($pageposafter);
458
-							$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
458
+							$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
459 459
 							//$pdf->SetDrawColor(190,190,200);
460
-							$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
460
+							$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
461 461
 							$pdf->SetLineStyle(array('dash'=>0));
462 462
 						}
463 463
 
464
-						$nexY+=2;    // Passe espace entre les lignes
464
+						$nexY += 2; // Passe espace entre les lignes
465 465
 
466 466
 						// Detect if some page were added automatically and output _tableau for past pages
467 467
 						while ($pagenb < $pageposafter)
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
 							{
476 476
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
477 477
 							}
478
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
478
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
479 479
 							$pagenb++;
480 480
 							$pdf->setPage($pagenb);
481
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
481
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
482 482
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
483 483
 						}
484
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
484
+						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
485 485
 						{
486 486
 							if ($pagenb == 1)
487 487
 							{
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 							{
492 492
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
493 493
 							}
494
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
494
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
495 495
 							// New page
496 496
 							$pdf->AddPage();
497
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
497
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
498 498
 							$pagenb++;
499 499
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
500 500
 						}
@@ -506,37 +506,37 @@  discard block
 block discarded – undo
506 506
 					 * footer table
507 507
 					 */
508 508
 					$nexY = $pdf->GetY();
509
-					$nexY+=2;
509
+					$nexY += 2;
510 510
 					$curY = $nexY;
511 511
 
512
-					$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
513
-					$pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
512
+					$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
513
+					$pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
514 514
 					$pdf->SetLineStyle(array('dash'=>0));
515 515
 
516
-					$pdf->SetFont('','B',$default_font_size-1);
517
-					$pdf->SetTextColor(0,0,120);
516
+					$pdf->SetFont('', 'B', $default_font_size - 1);
517
+					$pdf->SetTextColor(0, 0, 120);
518 518
 
519 519
 					// Ref.
520 520
 					$pdf->SetXY($this->posxdesc, $curY);
521 521
 					$pdf->MultiCell($this->wref, 3, $langs->trans("Total"), 0, 'L');
522 522
 
523 523
 					// Quantity
524
-					$valtoshow=price2num($totalunit, 'MS');
525
-					$towrite = empty($valtoshow)?'0':$valtoshow;
524
+					$valtoshow = price2num($totalunit, 'MS');
525
+					$towrite = empty($valtoshow) ? '0' : $valtoshow;
526 526
 
527 527
 					$pdf->SetXY($this->posxqty, $curY);
528
-					$pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R');
528
+					$pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $towrite, 0, 'R');
529 529
 
530 530
 					// Total PMP
531 531
 					$pdf->SetXY($this->posxunit, $curY);
532
-					$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($totalvalue,'MT'), 0, $outputlangs), 0, 'R');
532
+					$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, price(price2num($totalvalue, 'MT'), 0, $outputlangs), 0, 'R');
533 533
 
534 534
 					// Price sell min
535 535
 					if (empty($conf->global->PRODUIT_MULTIPRICES))
536 536
 					{
537 537
 						// Total sell min
538 538
 						$pdf->SetXY($this->postotalht, $curY);
539
-						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($totalvaluesell,'MT'), 0, $outputlangs), 0, 'R', 0);
539
+						$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, price(price2num($totalvaluesell, 'MT'), 0, $outputlangs), 0, 'R', 0);
540 540
 					}
541 541
 				}
542 542
 				else
@@ -546,27 +546,27 @@  discard block
 block discarded – undo
546 546
 
547 547
 				if ($notetoshow)
548 548
 				{
549
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
549
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
550 550
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
551 551
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
552 552
 
553 553
 					$tab_top = 88;
554 554
 
555
-					$pdf->SetFont('','', $default_font_size - 1);
556
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
555
+					$pdf->SetFont('', '', $default_font_size - 1);
556
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
557 557
 					$nexY = $pdf->GetY();
558
-					$height_note=$nexY-$tab_top;
558
+					$height_note = $nexY - $tab_top;
559 559
 
560 560
 					// Rect prend une longueur en 3eme param
561
-					$pdf->SetDrawColor(192,192,192);
562
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
561
+					$pdf->SetDrawColor(192, 192, 192);
562
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
563 563
 
564 564
 					$tab_height = $tab_height - $height_note;
565
-					$tab_top = $nexY+6;
565
+					$tab_top = $nexY + 6;
566 566
 				}
567 567
 				else
568 568
 				{
569
-					$height_note=0;
569
+					$height_note = 0;
570 570
 				}
571 571
 
572 572
 				$iniY = $tab_top + 7;
@@ -769,21 +769,21 @@  discard block
 block discarded – undo
769 769
 					}
770 770
 				}
771 771
 				*/
772
-				$tab_top = $tab_top_newpage+21;
772
+				$tab_top = $tab_top_newpage + 21;
773 773
 
774 774
 				// Show square
775 775
 				if ($pagenb == 1)
776 776
 				{
777 777
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
778
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
778
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
779 779
 				}
780 780
 				else
781 781
 				{
782 782
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
783
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
783
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
784 784
 				}
785 785
 
786
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
786
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
787 787
 
788 788
 				// Affiche zone infos
789 789
 				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -792,35 +792,35 @@  discard block
 block discarded – undo
792 792
 				//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
793 793
 
794 794
 				// Pied de page
795
-				$this->_pagefoot($pdf,$object,$outputlangs);
796
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
795
+				$this->_pagefoot($pdf, $object, $outputlangs);
796
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
797 797
 
798 798
 				$pdf->Close();
799 799
 
800
-				$pdf->Output($file,'F');
800
+				$pdf->Output($file, 'F');
801 801
 
802 802
 				// Add pdfgeneration hook
803 803
 				$hookmanager->initHooks(array('pdfgeneration'));
804
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
804
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
805 805
 				global $action;
806
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
806
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
807 807
 
808
-				if (! empty($conf->global->MAIN_UMASK))
808
+				if (!empty($conf->global->MAIN_UMASK))
809 809
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
810 810
 
811 811
 				$this->result = array('fullpath'=>$file);
812 812
 
813
-				return 1;   // Pas d'erreur
813
+				return 1; // Pas d'erreur
814 814
 			}
815 815
 			else
816 816
 			{
817
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
817
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
818 818
 				return 0;
819 819
 			}
820 820
 		}
821 821
 		else
822 822
 		{
823
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
823
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR");
824 824
 			return 0;
825 825
 		}
826 826
 	}
@@ -839,70 +839,70 @@  discard block
 block discarded – undo
839 839
 	 *   @param		string		$currency		Currency code
840 840
 	 *   @return	void
841 841
 	 */
842
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
842
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
843 843
 	{
844 844
 	    global $conf;
845 845
 
846 846
 	    // Force to disable hidetop and hidebottom
847
-	    $hidebottom=0;
848
-	    if ($hidetop) $hidetop=-1;
847
+	    $hidebottom = 0;
848
+	    if ($hidetop) $hidetop = -1;
849 849
 
850 850
 	    $currency = !empty($currency) ? $currency : $conf->currency;
851 851
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
852 852
 
853 853
 	    // Amount in (at tab_top - 1)
854
-	    $pdf->SetTextColor(0,0,0);
855
-	    $pdf->SetFont('','', $default_font_size - 2);
854
+	    $pdf->SetTextColor(0, 0, 0);
855
+	    $pdf->SetFont('', '', $default_font_size - 2);
856 856
 
857 857
 	    if (empty($hidetop))
858 858
 	    {
859
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
860
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
859
+	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
860
+	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
861 861
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
862 862
 
863 863
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
864
-	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
864
+	        if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
865 865
 	    }
866 866
 
867
-	    $pdf->SetDrawColor(128,128,128);
868
-	    $pdf->SetFont('','B', $default_font_size - 3);
867
+	    $pdf->SetDrawColor(128, 128, 128);
868
+	    $pdf->SetFont('', 'B', $default_font_size - 3);
869 869
 
870 870
 	    // Output Rect
871 871
 	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
872 872
 
873
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
874
-		$pdf->SetDrawColor(220,26,26);
875
-		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
873
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
874
+		$pdf->SetDrawColor(220, 26, 26);
875
+		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
876 876
 		$pdf->SetLineStyle(array('dash'=>0));
877
-		$pdf->SetDrawColor(128,128,128);
878
-		$pdf->SetTextColor(0,0,120);
877
+		$pdf->SetDrawColor(128, 128, 128);
878
+		$pdf->SetTextColor(0, 0, 120);
879 879
 
880 880
 	    if (empty($hidetop))
881 881
 	    {
882 882
 	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
883
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
884
-	        $pdf->MultiCell($this->wref,3, $outputlangs->transnoentities("Ref"),'','L');
883
+	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
884
+	        $pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L');
885 885
 	    }
886 886
 
887 887
 		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
888 888
 		if (empty($hidetop))
889 889
 		{
890
-			$pdf->SetXY($this->posxlabel-3, $tab_top+1);
891
-			$pdf->MultiCell($this->posxqty-$this->posxlabel+3,2, $outputlangs->transnoentities("Label"),'','C');
890
+			$pdf->SetXY($this->posxlabel - 3, $tab_top + 1);
891
+			$pdf->MultiCell($this->posxqty - $this->posxlabel + 3, 2, $outputlangs->transnoentities("Label"), '', 'C');
892 892
 		}
893 893
 
894 894
 	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
895 895
 	    if (empty($hidetop))
896 896
 	    {
897
-	        $pdf->SetXY($this->posxqty-1, $tab_top+1);
898
-	        $pdf->MultiCell($this->posxup-$this->posxqty-1,2, $outputlangs->transnoentities("Units"),'','C');
897
+	        $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
898
+	        $pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities("Units"), '', 'C');
899 899
 	    }
900 900
 
901 901
 	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
902 902
 	    if (empty($hidetop))
903 903
 	    {
904
-	        $pdf->SetXY($this->posxup-1, $tab_top+1);
905
-			$pdf->MultiCell($this->posxunit-$this->posxup-1,2, $outputlangs->transnoentities("AverageUnitPricePMPShort"),'','C');
904
+	        $pdf->SetXY($this->posxup - 1, $tab_top + 1);
905
+			$pdf->MultiCell($this->posxunit - $this->posxup - 1, 2, $outputlangs->transnoentities("AverageUnitPricePMPShort"), '', 'C');
906 906
 	    }
907 907
 
908 908
 		//$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
@@ -916,20 +916,20 @@  discard block
 block discarded – undo
916 916
 	    //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
917 917
 	    if (empty($hidetop))
918 918
 	    {
919
-			$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
920
-			$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("SellPriceMin"),'','C');
919
+			$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
920
+			$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("SellPriceMin"), '', 'C');
921 921
 	    }
922 922
 
923 923
 	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
924 924
 	    if (empty($hidetop))
925 925
 	    {
926
-	        $pdf->SetXY($this->postotalht-1, $tab_top+1);
927
-	        $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("EstimatedStockValueSellShort"),'','C');
926
+	        $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
927
+	        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'C');
928 928
 	    }
929 929
 
930
-		$pdf->SetDrawColor(220,26,26);
931
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
932
-		$pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
930
+		$pdf->SetDrawColor(220, 26, 26);
931
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
932
+		$pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
933 933
 		$pdf->SetLineStyle(array('dash'=>0));
934 934
 	}
935 935
 
@@ -943,92 +943,92 @@  discard block
 block discarded – undo
943 943
 	 *  @param	string		$titlekey		Translation key to show as title of document
944 944
 	 *  @return	void
945 945
 	 */
946
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
946
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
947 947
 	{
948
-	    global $conf,$langs,$db,$hookmanager;
948
+	    global $conf, $langs, $db, $hookmanager;
949 949
 
950 950
 	    // Load traductions files requiredby by page
951 951
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
952 952
 
953 953
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
954 954
 
955
-	    if ($object->type == 1) $titlekey='ServiceSheet';
956
-	    else $titlekey='StockSheet';
955
+	    if ($object->type == 1) $titlekey = 'ServiceSheet';
956
+	    else $titlekey = 'StockSheet';
957 957
 
958
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
958
+	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
959 959
 
960 960
 	    // Show Draft Watermark
961
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
961
+	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
962 962
 	    {
963
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
963
+	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
964 964
 	    }
965 965
 
966
-	    $pdf->SetTextColor(0,0,60);
967
-	    $pdf->SetFont('','B', $default_font_size + 3);
966
+	    $pdf->SetTextColor(0, 0, 60);
967
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
968 968
 
969
-	    $posy=$this->marge_haute;
970
-	    $posx=$this->page_largeur-$this->marge_droite-100;
969
+	    $posy = $this->marge_haute;
970
+	    $posx = $this->page_largeur - $this->marge_droite - 100;
971 971
 
972
-	    $pdf->SetXY($this->marge_gauche,$posy);
972
+	    $pdf->SetXY($this->marge_gauche, $posy);
973 973
 
974 974
 	    // Logo
975
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
975
+	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
976 976
 	    if ($this->emetteur->logo)
977 977
 	    {
978 978
 	        if (is_readable($logo))
979 979
 	        {
980
-	            $height=pdf_getHeightForLogo($logo);
981
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
980
+	            $height = pdf_getHeightForLogo($logo);
981
+	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
982 982
 	        }
983 983
 	        else
984 984
 	        {
985
-	            $pdf->SetTextColor(200,0,0);
986
-	            $pdf->SetFont('','B', $default_font_size -2);
987
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
985
+	            $pdf->SetTextColor(200, 0, 0);
986
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
987
+	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
988 988
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
989 989
 	        }
990 990
 	    }
991 991
 	    else
992 992
 	    {
993
-	        $text=$this->emetteur->name;
993
+	        $text = $this->emetteur->name;
994 994
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
995 995
 	    }
996 996
 
997
-	    $pdf->SetFont('','B', $default_font_size + 3);
998
-	    $pdf->SetXY($posx,$posy);
999
-	    $pdf->SetTextColor(0,0,60);
1000
-	    $title=$outputlangs->transnoentities("Warehouse");
997
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
998
+	    $pdf->SetXY($posx, $posy);
999
+	    $pdf->SetTextColor(0, 0, 60);
1000
+	    $title = $outputlangs->transnoentities("Warehouse");
1001 1001
 	    $pdf->MultiCell(100, 3, $title, '', 'R');
1002 1002
 
1003
-	    $pdf->SetFont('','B',$default_font_size);
1003
+	    $pdf->SetFont('', 'B', $default_font_size);
1004 1004
 
1005
-	    $posy+=5;
1006
-	    $pdf->SetXY($posx,$posy);
1007
-	    $pdf->SetTextColor(0,0,60);
1005
+	    $posy += 5;
1006
+	    $pdf->SetXY($posx, $posy);
1007
+	    $pdf->SetTextColor(0, 0, 60);
1008 1008
 
1009
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
1009
+	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->libelle), '', 'R');
1010 1010
 
1011
-	    $posy+=5;
1012
-	    $pdf->SetFont('','', $default_font_size - 1);
1013
-		$pdf->SetXY($posx,$posy);
1014
-	    $pdf->SetTextColor(0,0,60);
1011
+	    $posy += 5;
1012
+	    $pdf->SetFont('', '', $default_font_size - 1);
1013
+		$pdf->SetXY($posx, $posy);
1014
+	    $pdf->SetTextColor(0, 0, 60);
1015 1015
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1016 1016
 
1017
-		$posy+=4;
1018
-		$pdf->SetXY($posx-50,$posy);
1017
+		$posy += 4;
1018
+		$pdf->SetXY($posx - 50, $posy);
1019 1019
 		$pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1020 1020
 
1021 1021
 
1022 1022
 		// Parent entrepot
1023
-		$posy+=4;
1024
-		$pdf->SetXY($posx,$posy);
1025
-		$pdf->SetTextColor(0,0,60);
1023
+		$posy += 4;
1024
+		$pdf->SetXY($posx, $posy);
1025
+		$pdf->SetTextColor(0, 0, 60);
1026 1026
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1027 1027
 
1028
-		$posy+=4;
1029
-		$pdf->SetXY($posx-50,$posy);
1028
+		$posy += 4;
1029
+		$pdf->SetXY($posx - 50, $posy);
1030 1030
 		$e = new Entrepot($db);
1031
-		if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1031
+		if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1032 1032
 		{
1033 1033
 			$pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1034 1034
 		}
@@ -1039,25 +1039,25 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		// Description
1041 1041
 		$nexY = $pdf->GetY();
1042
-		$nexY+=5;
1043
-		$pdf->SetXY($posx,$posy);
1042
+		$nexY += 5;
1043
+		$pdf->SetXY($posx, $posy);
1044 1044
 		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1045 1045
 		$nexY = $pdf->GetY();
1046 1046
 
1047
-		$calcproductsunique=$object->nb_different_products();
1048
-		$calcproducts=$object->nb_products();
1047
+		$calcproductsunique = $object->nb_different_products();
1048
+		$calcproducts = $object->nb_products();
1049 1049
 
1050 1050
 		// Total nb of different products
1051
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1051
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
1052 1052
 		$nexY = $pdf->GetY();
1053 1053
 
1054 1054
 		// Nb of products
1055
-		$valtoshow=price2num($calcproducts['nb'], 'MS');
1056
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1055
+		$valtoshow = price2num($calcproducts['nb'], 'MS');
1056
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
1057 1057
 		$nexY = $pdf->GetY();
1058 1058
 
1059 1059
 		// Value
1060
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1060
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1061 1061
 		$nexY = $pdf->GetY();
1062 1062
 
1063 1063
 
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 		if ($resqlbis)
1070 1070
 		{
1071 1071
 			$obj = $db->fetch_object($resqlbis);
1072
-			$lastmovementdate=$db->jdate($obj->datem);
1072
+			$lastmovementdate = $db->jdate($obj->datem);
1073 1073
 		}
1074 1074
 		else
1075 1075
 		{
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
 		if ($lastmovementdate)
1080 1080
 		{
1081
-			$toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1081
+			$toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
1082 1082
 		}
1083 1083
 		else
1084 1084
 		{
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	        }
1120 1120
 	    }*/
1121 1121
 
1122
-	    $posy+=2;
1122
+	    $posy += 2;
1123 1123
 
1124 1124
 	    // Show list of linked objects
1125 1125
 	    $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 	        */
1160 1160
 	    }
1161 1161
 
1162
-	    $pdf->SetTextColor(0,0,0);
1162
+	    $pdf->SetTextColor(0, 0, 0);
1163 1163
 	}
1164 1164
 
1165 1165
 	/**
@@ -1171,10 +1171,10 @@  discard block
 block discarded – undo
1171 1171
 	 *      @param	int			$hidefreetext		1=Hide free text
1172 1172
 	 *      @return	int								Return height of bottom margin including footer text
1173 1173
 	 */
1174
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1174
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1175 1175
 	{
1176 1176
 	    global $conf;
1177
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1178
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1177
+	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1178
+	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1179 1179
 	}
1180 1180
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php 1 patch
Spacing   +331 added lines, -331 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function __construct($db)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		// Load traductions files requiredby by page
124 124
 		$langs->loadLangs(array("main", "companies"));
@@ -129,54 +129,54 @@  discard block
 block discarded – undo
129 129
 
130 130
 		// Dimension page pour format A4
131 131
 		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
132
+		$formatarray = pdf_getFormat();
133 133
 		$this->page_largeur = $formatarray['width'];
134 134
 		$this->page_hauteur = $formatarray['height'];
135
-		$this->format = array($this->page_largeur,$this->page_hauteur);
136
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
135
+		$this->format = array($this->page_largeur, $this->page_hauteur);
136
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
137
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
138
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
139
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
140 140
 
141
-		$this->option_logo = 1;                    // Affiche logo
142
-		$this->option_codestockservice = 0;      // Affiche code stock-service
143
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
144
-		$this->option_freetext = 0;				   // Support add of a personalised text
141
+		$this->option_logo = 1; // Affiche logo
142
+		$this->option_codestockservice = 0; // Affiche code stock-service
143
+		$this->option_multilang = 1; // Dispo en plusieurs langues
144
+		$this->option_freetext = 0; // Support add of a personalised text
145 145
 
146 146
 		// Recupere emetteur
147
-		$this->emetteur=$mysoc;
148
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
147
+		$this->emetteur = $mysoc;
148
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
149 149
 
150 150
 		// Define position of columns
151 151
 		$this->wref = 15;
152 152
 		$this->posxidref = $this->marge_gauche;
153
-		$this->posxdatemouv = $this->marge_gauche+8;
154
-		$this->posxdesc=37;
155
-		$this->posxlabel=50;
156
-		$this->posxtva=80;
157
-		$this->posxqty=105;
158
-		$this->posxup=119;
159
-		$this->posxunit=136;
160
-		$this->posxdiscount=167;
161
-		$this->postotalht=180;
162
-
163
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
164
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
153
+		$this->posxdatemouv = $this->marge_gauche + 8;
154
+		$this->posxdesc = 37;
155
+		$this->posxlabel = 50;
156
+		$this->posxtva = 80;
157
+		$this->posxqty = 105;
158
+		$this->posxup = 119;
159
+		$this->posxunit = 136;
160
+		$this->posxdiscount = 167;
161
+		$this->postotalht = 180;
162
+
163
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
164
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
165 165
 		if ($this->page_largeur < 210) // To work with US executive format
166 166
 		{
167
-			$this->posxpicture-=20;
168
-			$this->posxtva-=20;
169
-			$this->posxup-=20;
170
-			$this->posxqty-=20;
171
-			$this->posxunit-=20;
172
-			$this->posxdiscount-=20;
173
-			$this->postotalht-=20;
167
+			$this->posxpicture -= 20;
168
+			$this->posxtva -= 20;
169
+			$this->posxup -= 20;
170
+			$this->posxqty -= 20;
171
+			$this->posxunit -= 20;
172
+			$this->posxdiscount -= 20;
173
+			$this->postotalht -= 20;
174 174
 		}
175
-		$this->tva=array();
176
-		$this->localtax1=array();
177
-		$this->localtax2=array();
178
-		$this->atleastoneratenotnull=0;
179
-		$this->atleastonediscount=0;
175
+		$this->tva = array();
176
+		$this->localtax1 = array();
177
+		$this->localtax2 = array();
178
+		$this->atleastoneratenotnull = 0;
179
+		$this->atleastonediscount = 0;
180 180
 	}
181 181
 
182 182
 
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 	 *  @param		int			$hideref			Do not show ref
193 193
 	 *	@return		int         					1 if OK, <=0 if KO
194 194
 	 */
195
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
195
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
196 196
 	{
197 197
         // phpcs:enable
198
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
198
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
199 199
 
200
-		if (! is_object($outputlangs)) $outputlangs=$langs;
200
+		if (!is_object($outputlangs)) $outputlangs = $langs;
201 201
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
202
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
202
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
203 203
 
204 204
 		// Load traductions files requiredby by page
205 205
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 	 * TODO: get from object
209 209
 	 */
210 210
 
211
-		$id=GETPOST('id','int');
212
-		$ref = GETPOST('ref','alpha');
213
-		$msid=GETPOST('msid','int');
214
-		$product_id=GETPOST("product_id");
215
-		$action=GETPOST('action','aZ09');
216
-		$cancel=GETPOST('cancel','alpha');
217
-		$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist';
211
+		$id = GETPOST('id', 'int');
212
+		$ref = GETPOST('ref', 'alpha');
213
+		$msid = GETPOST('msid', 'int');
214
+		$product_id = GETPOST("product_id");
215
+		$action = GETPOST('action', 'aZ09');
216
+		$cancel = GETPOST('cancel', 'alpha');
217
+		$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist';
218 218
 
219
-		$idproduct = GETPOST('idproduct','int');
219
+		$idproduct = GETPOST('idproduct', 'int');
220 220
 		$year = GETPOST("year");
221 221
 		$month = GETPOST("month");
222 222
 		$search_ref = GETPOST('search_ref', 'alpha');
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 		$search_user = trim(GETPOST("search_user"));
229 229
 		$search_batch = trim(GETPOST("search_batch"));
230 230
 		$search_qty = trim(GETPOST("search_qty"));
231
-		$search_type_mouvement=GETPOST('search_type_mouvement','int');
231
+		$search_type_mouvement = GETPOST('search_type_mouvement', 'int');
232 232
 
233
-		$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
234
-		$page = GETPOST("page",'int');
235
-		$sortfield = GETPOST("sortfield",'alpha');
236
-		$sortorder = GETPOST("sortorder",'alpha');
233
+		$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
234
+		$page = GETPOST("page", 'int');
235
+		$sortfield = GETPOST("sortfield", 'alpha');
236
+		$sortorder = GETPOST("sortorder", 'alpha');
237 237
 		if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
238 238
 		$offset = $limit * $page;
239
-		if (! $sortfield) $sortfield="m.datem";
240
-		if (! $sortorder) $sortorder="DESC";
239
+		if (!$sortfield) $sortfield = "m.datem";
240
+		if (!$sortorder) $sortorder = "DESC";
241 241
 
242
-		$pdluoid=GETPOST('pdluoid','int');
242
+		$pdluoid = GETPOST('pdluoid', 'int');
243 243
 
244 244
 		// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
245 245
 		$hookmanager->initHooks(array('movementlist'));
@@ -247,68 +247,68 @@  discard block
 block discarded – undo
247 247
 
248 248
 		// fetch optionals attributes and labels
249 249
 		$extralabels = $extrafields->fetch_name_optionals_label('movement');
250
-		$search_array_options=$extrafields->getOptionalsFromPost('movement','','search_');
250
+		$search_array_options = $extrafields->getOptionalsFromPost('movement', '', 'search_');
251 251
 
252
-		$productlot=new ProductLot($db);
253
-		$productstatic=new Product($db);
254
-		$warehousestatic=new Entrepot($db);
255
-		$movement=new MouvementStock($db);
256
-		$userstatic=new User($db);
252
+		$productlot = new ProductLot($db);
253
+		$productstatic = new Product($db);
254
+		$warehousestatic = new Entrepot($db);
255
+		$movement = new MouvementStock($db);
256
+		$userstatic = new User($db);
257 257
 
258 258
 		$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
259
-		$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
-		$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
-		$sql.= " m.batch, m.price,";
262
-		$sql.= " m.type_mouvement,";
263
-		$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
-		$sql.= " u.login, u.photo, u.lastname, u.firstname";
259
+		$sql .= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
+		$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
+		$sql .= " m.batch, m.price,";
262
+		$sql .= " m.type_mouvement,";
263
+		$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
+		$sql .= " u.login, u.photo, u.lastname, u.firstname";
265 265
 		// Add fields from extrafields
266
-		foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
266
+		foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
267 267
 		// Add fields from hooks
268
-		$parameters=array();
269
-		$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
270
-		$sql.=$hookmanager->resPrint;
271
-		$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
-		$sql.= " ".MAIN_DB_PREFIX."product as p,";
273
-		$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
-		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
-		$sql.= " WHERE m.fk_product = p.rowid";
268
+		$parameters = array();
269
+		$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
270
+		$sql .= $hookmanager->resPrint;
271
+		$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
+		$sql .= " ".MAIN_DB_PREFIX."product as p,";
273
+		$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
+		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
+		$sql .= " WHERE m.fk_product = p.rowid";
278 278
 		if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
279
-		$sql.= " AND m.fk_entrepot = e.rowid";
280
-		$sql.= " AND e.entity IN (".getEntity('stock').")";
281
-		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
282
-		if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
279
+		$sql .= " AND m.fk_entrepot = e.rowid";
280
+		$sql .= " AND e.entity IN (".getEntity('stock').")";
281
+		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
282
+		if ($id > 0) $sql .= " AND e.rowid ='".$id."'";
283 283
 		if ($month > 0)
284 284
 		{
285 285
 			if ($year > 0)
286
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
286
+			$sql .= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'";
287 287
 			else
288
-			$sql.= " AND date_format(m.datem, '%m') = '$month'";
288
+			$sql .= " AND date_format(m.datem, '%m') = '$month'";
289 289
 		}
290 290
 		else if ($year > 0)
291 291
 		{
292
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
292
+			$sql .= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
293 293
 		}
294
-		if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
295
-		if (! empty($search_ref))			$sql.= natural_search('m.rowid', $search_ref, 1);
296
-		if (! empty($search_movement))      $sql.= natural_search('m.label', $search_movement);
297
-		if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
298
-		if (! empty($search_product_ref))   $sql.= natural_search('p.ref', $search_product_ref);
299
-		if (! empty($search_product))       $sql.= natural_search('p.label', $search_product);
300
-		if ($search_warehouse > 0)          $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
-		if (! empty($search_user))          $sql.= natural_search('u.login', $search_user);
302
-		if (! empty($search_batch))         $sql.= natural_search('m.batch', $search_batch);
303
-		if ($search_qty != '')				$sql.= natural_search('m.value', $search_qty, 1);
304
-		if ($search_type_mouvement > 0)		$sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
294
+		if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'";
295
+		if (!empty($search_ref))			$sql .= natural_search('m.rowid', $search_ref, 1);
296
+		if (!empty($search_movement))      $sql .= natural_search('m.label', $search_movement);
297
+		if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
298
+		if (!empty($search_product_ref))   $sql .= natural_search('p.ref', $search_product_ref);
299
+		if (!empty($search_product))       $sql .= natural_search('p.label', $search_product);
300
+		if ($search_warehouse > 0)          $sql .= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
+		if (!empty($search_user))          $sql .= natural_search('u.login', $search_user);
302
+		if (!empty($search_batch))         $sql .= natural_search('m.batch', $search_batch);
303
+		if ($search_qty != '')				$sql .= natural_search('m.value', $search_qty, 1);
304
+		if ($search_type_mouvement > 0)		$sql .= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
305 305
 		// Add where from extra fields
306 306
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307 307
 		// Add where from hooks
308
-		$parameters=array();
309
-		$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
310
-		$sql.=$hookmanager->resPrint;
311
-		$sql.= $db->order($sortfield,$sortorder);
308
+		$parameters = array();
309
+		$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
310
+		$sql .= $hookmanager->resPrint;
311
+		$sql .= $db->order($sortfield, $sortorder);
312 312
 
313 313
 		$nbtotalofrecords = '';
314 314
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			}
323 323
 		}
324 324
 
325
-		if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset);
325
+		if (empty($search_inventorycode)) $sql .= $db->plimit($limit + 1, $offset);
326 326
 
327 327
 
328 328
 		$resql = $db->query($sql);
@@ -357,44 +357,44 @@  discard block
 block discarded – undo
357 357
 
358 358
 				$num = $db->num_rows($resql);
359 359
 
360
-				$arrayofselected=is_array($toselect)?$toselect:array();
360
+				$arrayofselected = is_array($toselect) ? $toselect : array();
361 361
 
362 362
 				$i = 0;
363
-				$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
363
+				$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
364 364
 				if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
365 365
 				else
366 366
 				{
367 367
 					$texte = $langs->trans("ListOfStockMovements");
368
-					if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
368
+					if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')';
369 369
 				}
370 370
 			}
371 371
 
372 372
 			// Definition of $dir and $file
373 373
 			if ($object->specimen)
374 374
 			{
375
-				$dir = $conf->stock->dir_output . "/movement";
376
-				$file = $dir . "/SPECIMEN.pdf";
375
+				$dir = $conf->stock->dir_output."/movement";
376
+				$file = $dir."/SPECIMEN.pdf";
377 377
 			}
378 378
 			else
379 379
 			{
380 380
 				$objectref = dol_sanitizeFileName($object->ref);
381
-				if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
382
-				if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
383
-				$dir = $conf->stock->dir_output . "/movement/" . $objectref;
384
-				$file = $dir . "/" . $objectref . ".pdf";
381
+				if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode;
382
+				if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement;
383
+				$dir = $conf->stock->dir_output."/movement/".$objectref;
384
+				$file = $dir."/".$objectref.".pdf";
385 385
 			}
386 386
 
387 387
 			$stockFournisseur = new ProductFournisseur($this->db);
388 388
 			$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
389 389
 			$object->supplierprices = $supplierprices;
390 390
 
391
-			$productstatic=new Product($db);
391
+			$productstatic = new Product($db);
392 392
 
393
-			if (! file_exists($dir))
393
+			if (!file_exists($dir))
394 394
 			{
395 395
 				if (dol_mkdir($dir) < 0)
396 396
 				{
397
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
397
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
398 398
 					return -1;
399 399
 				}
400 400
 			}
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
 			if (file_exists($dir))
403 403
 			{
404 404
 				// Add pdfgeneration hook
405
-				if (! is_object($hookmanager))
405
+				if (!is_object($hookmanager))
406 406
 				{
407 407
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
408
-					$hookmanager=new HookManager($this->db);
408
+					$hookmanager = new HookManager($this->db);
409 409
 				}
410 410
 				$hookmanager->initHooks(array('pdfgeneration'));
411
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
411
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
412 412
 				global $action;
413
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
413
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
414 414
 
415 415
 				// Create pdf instance
416
-				$pdf=pdf_getInstance($this->format);
417
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
418
-				$pdf->SetAutoPageBreak(1,0);
416
+				$pdf = pdf_getInstance($this->format);
417
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
418
+				$pdf->SetAutoPageBreak(1, 0);
419 419
 
420
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
421
-		        $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
422
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
420
+				$heightforinfotot = 40; // Height reserved to output the info and total part
421
+		        $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
422
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
423 423
 
424 424
                 if (class_exists('TCPDF'))
425 425
                 {
@@ -428,37 +428,37 @@  discard block
 block discarded – undo
428 428
                 }
429 429
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
430 430
                 // Set path to the background PDF File
431
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
431
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
432 432
                 {
433 433
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
434 434
                     $tplidx = $pdf->importPage(1);
435 435
                 }
436 436
 
437 437
 				$pdf->Open();
438
-				$pagenb=0;
439
-				$pdf->SetDrawColor(128,128,128);
438
+				$pagenb = 0;
439
+				$pdf->SetDrawColor(128, 128, 128);
440 440
 
441 441
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
442 442
 				$pdf->SetSubject($outputlangs->transnoentities("Stock"));
443 443
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
444 444
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
445 445
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
446
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
446
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
447 447
 
448
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
448
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
449 449
 
450 450
 
451 451
 				// New page
452 452
 				$pdf->AddPage();
453
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
453
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
454 454
 				$pagenb++;
455 455
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
456
-				$pdf->SetFont('','', $default_font_size - 1);
457
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
458
-				$pdf->SetTextColor(0,0,0);
456
+				$pdf->SetFont('', '', $default_font_size - 1);
457
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
458
+				$pdf->SetTextColor(0, 0, 0);
459 459
 
460 460
 				$tab_top = 42;
461
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
461
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
462 462
 				$tab_height = 130;
463 463
 				$tab_height_newpage = 150;
464 464
 
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 				/*                                                                            */
469 469
 				/* ************************************************************************** */
470 470
 
471
-				$nexY+=5;
471
+				$nexY += 5;
472 472
 				$nexY = $pdf->GetY();
473
-				$nexY+=10;
473
+				$nexY += 10;
474 474
 
475
-				$totalunit=0;
476
-				$totalvalue=$totalvaluesell=0;
475
+				$totalunit = 0;
476
+				$totalvalue = $totalvaluesell = 0;
477 477
 				$arrayofuniqueproduct = array();
478 478
 
479 479
 				//dol_syslog('List products', LOG_DEBUG);
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 					$num = $db->num_rows($resql);
484 484
 					$i = 0;
485 485
 					$nblignes = $num;
486
-					for ($i = 0 ; $i < $nblignes ; $i++)
486
+					for ($i = 0; $i < $nblignes; $i++)
487 487
 					{
488 488
 						$objp = $db->fetch_object($resql);
489 489
 
490 490
 						// Multilangs
491
-						if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
491
+						if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
492 492
 						{
493 493
 							$sql = "SELECT label";
494
-							$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
495
-							$sql.= " WHERE fk_product=".$objp->rowid;
496
-							$sql.= " AND lang='". $langs->getDefaultLang() ."'";
497
-							$sql.= " LIMIT 1";
494
+							$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
495
+							$sql .= " WHERE fk_product=".$objp->rowid;
496
+							$sql .= " AND lang='".$langs->getDefaultLang()."'";
497
+							$sql .= " LIMIT 1";
498 498
 
499 499
 							$result = $db->query($sql);
500 500
 							if ($result)
@@ -505,92 +505,92 @@  discard block
 block discarded – undo
505 505
 						}
506 506
 
507 507
 						$curY = $nexY;
508
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
509
-						$pdf->SetTextColor(0,0,0);
508
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
509
+						$pdf->SetTextColor(0, 0, 0);
510 510
 
511 511
 						$pdf->setTopMargin($tab_top_newpage);
512
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
513
-						$pageposbefore=$pdf->getPage();
512
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
513
+						$pageposbefore = $pdf->getPage();
514 514
 
515 515
 						// Description of product line
516
-						$curX = $this->posxdesc-1;
516
+						$curX = $this->posxdesc - 1;
517 517
 
518
-						$showpricebeforepagebreak=1;
518
+						$showpricebeforepagebreak = 1;
519 519
 
520 520
 						$pdf->startTransaction();
521
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
522
-						$pageposafter=$pdf->getPage();
521
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
522
+						$pageposafter = $pdf->getPage();
523 523
 						if ($pageposafter > $pageposbefore)	// There is a pagebreak
524 524
 						{
525 525
 							$pdf->rollbackTransaction(true);
526
-							$pageposafter=$pageposbefore;
526
+							$pageposafter = $pageposbefore;
527 527
 							//print $pageposafter.'-'.$pageposbefore;exit;
528
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
529
-							pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
530
-							$pageposafter=$pdf->getPage();
531
-							$posyafter=$pdf->GetY();
532
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
528
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
529
+							pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
530
+							$pageposafter = $pdf->getPage();
531
+							$posyafter = $pdf->GetY();
532
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
533 533
 							{
534
-								if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
534
+								if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
535 535
 								{
536
-									$pdf->AddPage('','',true);
537
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
536
+									$pdf->AddPage('', '', true);
537
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
538 538
 									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
539
-									$pdf->setPage($pageposafter+1);
539
+									$pdf->setPage($pageposafter + 1);
540 540
 								}
541 541
 							}
542 542
 							else
543 543
 							{
544 544
 								// We found a page break
545
-								$showpricebeforepagebreak=0;
545
+								$showpricebeforepagebreak = 0;
546 546
 							}
547 547
 						}
548 548
 						else	// No pagebreak
549 549
 						{
550 550
 							$pdf->commitTransaction();
551 551
 						}
552
-						$posYAfterDescription=$pdf->GetY();
552
+						$posYAfterDescription = $pdf->GetY();
553 553
 
554 554
 						$nexY = $pdf->GetY();
555
-						$pageposafter=$pdf->getPage();
555
+						$pageposafter = $pdf->getPage();
556 556
 
557 557
 						$pdf->setPage($pageposbefore);
558 558
 						$pdf->setTopMargin($this->marge_haute);
559
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
559
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
560 560
 
561 561
 						// We suppose that a too long description is moved completely on next page
562 562
 						if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563 563
 							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
564 564
 						}
565 565
 
566
-						$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
566
+						$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
567 567
 
568 568
 						// $objp = $db->fetch_object($resql);
569 569
 
570
-						$userstatic->id=$objp->fk_user_author;
571
-						$userstatic->login=$objp->login;
572
-						$userstatic->lastname=$objp->lastname;
573
-						$userstatic->firstname=$objp->firstname;
574
-						$userstatic->photo=$objp->photo;
570
+						$userstatic->id = $objp->fk_user_author;
571
+						$userstatic->login = $objp->login;
572
+						$userstatic->lastname = $objp->lastname;
573
+						$userstatic->firstname = $objp->firstname;
574
+						$userstatic->photo = $objp->photo;
575 575
 
576
-						$productstatic->id=$objp->rowid;
577
-						$productstatic->ref=$objp->product_ref;
578
-						$productstatic->label=$objp->produit;
579
-						$productstatic->type=$objp->type;
580
-						$productstatic->entity=$objp->entity;
581
-						$productstatic->status_batch=$objp->tobatch;
576
+						$productstatic->id = $objp->rowid;
577
+						$productstatic->ref = $objp->product_ref;
578
+						$productstatic->label = $objp->produit;
579
+						$productstatic->type = $objp->type;
580
+						$productstatic->entity = $objp->entity;
581
+						$productstatic->status_batch = $objp->tobatch;
582 582
 
583 583
 						$productlot->id = $objp->lotid;
584
-						$productlot->batch= $objp->batch;
585
-						$productlot->eatby= $objp->eatby;
586
-						$productlot->sellby= $objp->sellby;
584
+						$productlot->batch = $objp->batch;
585
+						$productlot->eatby = $objp->eatby;
586
+						$productlot->sellby = $objp->sellby;
587 587
 
588
-						$warehousestatic->id=$objp->entrepot_id;
589
-						$warehousestatic->libelle=$objp->stock;
590
-						$warehousestatic->lieu=$objp->lieu;
588
+						$warehousestatic->id = $objp->entrepot_id;
589
+						$warehousestatic->libelle = $objp->stock;
590
+						$warehousestatic->lieu = $objp->lieu;
591 591
 
592
-						$arrayofuniqueproduct[$objp->rowid]=$objp->produit;
593
-						if(!empty($objp->fk_origin)) {
592
+						$arrayofuniqueproduct[$objp->rowid] = $objp->produit;
593
+						if (!empty($objp->fk_origin)) {
594 594
 							$origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
595 595
 						} else {
596 596
 							$origin = '';
@@ -598,60 +598,60 @@  discard block
 block discarded – undo
598 598
 
599 599
 						// Id movement.
600 600
 						$pdf->SetXY($this->posxidref, $curY);
601
-						$pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L');
601
+						$pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0, 'L');
602 602
 
603 603
 						// Date.
604 604
 						$pdf->SetXY($this->posxdatemouv, $curY);
605
-						$pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L');
605
+						$pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L');
606 606
 
607 607
 						// Ref.
608 608
 						$pdf->SetXY($this->posxdesc, $curY);
609
-						$pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L');
609
+						$pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0, 'L');
610 610
 
611 611
 						// Label
612
-						$pdf->SetXY($this->posxlabel+0.8, $curY);
613
-						$pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L');
612
+						$pdf->SetXY($this->posxlabel + 0.8, $curY);
613
+						$pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0, 'L');
614 614
 
615 615
 						// Lot/serie
616 616
 						$pdf->SetXY($this->posxqty, $curY);
617
-						$pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R');
617
+						$pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0, 'R');
618 618
 
619 619
 						// Inv. code
620 620
 						$pdf->SetXY($this->posxup, $curY);
621
-						$pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R');
621
+						$pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0, 'R');
622 622
 
623 623
 						// Label mouvement
624 624
 						$pdf->SetXY($this->posxunit, $curY);
625
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R');
626
-						$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
625
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0, 'R');
626
+						$totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
627 627
 
628 628
 						// Origin
629
-						$pricemin=$objp->price;
629
+						$pricemin = $objp->price;
630 630
 						$pdf->SetXY($this->posxdiscount, $curY);
631
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0);
631
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0, 'R', 0);
632 632
 
633 633
 						// Qty
634
-						$valtoshow=price2num($objp->qty, 'MS');
635
-						$towrite = (empty($valtoshow)?'0':$valtoshow);
636
-						$totalunit+=$objp->qty;
634
+						$valtoshow = price2num($objp->qty, 'MS');
635
+						$towrite = (empty($valtoshow) ? '0' : $valtoshow);
636
+						$totalunit += $objp->qty;
637 637
 
638 638
 						$pdf->SetXY($this->postotalht, $curY);
639
-						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0);
639
+						$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0, 'R', 0);
640 640
 
641
-						$totalvaluesell+=price2num($pricemin*$objp->value,'MT');
641
+						$totalvaluesell += price2num($pricemin * $objp->value, 'MT');
642 642
 
643
-						$nexY+=3.5;    // Passe espace entre les lignes
643
+						$nexY += 3.5; // Passe espace entre les lignes
644 644
 						// Add line
645
-						if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
645
+						if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
646 646
 						{
647 647
 							$pdf->setPage($pageposafter);
648
-							$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
648
+							$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
649 649
 							//$pdf->SetDrawColor(190,190,200);
650
-							$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
650
+							$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
651 651
 							$pdf->SetLineStyle(array('dash'=>0));
652 652
 						}
653 653
 
654
-						$nexY+=2;    // Passe espace entre les lignes
654
+						$nexY += 2; // Passe espace entre les lignes
655 655
 
656 656
 						// Detect if some page were added automatically and output _tableau for past pages
657 657
 						while ($pagenb < $pageposafter)
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
 							{
666 666
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667 667
 							}
668
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
668
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
669 669
 							$pagenb++;
670 670
 							$pdf->setPage($pagenb);
671
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
671
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
672 672
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
673 673
 						}
674
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
674
+						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
675 675
 						{
676 676
 							if ($pagenb == 1)
677 677
 							{
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 							{
682 682
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
683 683
 							}
684
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
684
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
685 685
 							// New page
686 686
 							$pdf->AddPage();
687
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
687
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
688 688
 							$pagenb++;
689 689
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
690 690
 						}
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
 					 * footer table
697 697
 					 */
698 698
 					$nexY = $pdf->GetY();
699
-					$nexY+=5;
699
+					$nexY += 5;
700 700
 					$curY = $nexY;
701 701
 
702
-					$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
703
-					$pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
702
+					$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
703
+					$pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
704 704
 					$pdf->SetLineStyle(array('dash'=>0));
705 705
 
706
-					$pdf->SetFont('','B',$default_font_size-1);
707
-					$pdf->SetTextColor(0,0,120);
706
+					$pdf->SetFont('', 'B', $default_font_size - 1);
707
+					$pdf->SetTextColor(0, 0, 120);
708 708
 
709 709
 					// Total
710 710
 					$pdf->SetXY($this->posxidref, $curY);
711
-					$pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L');
711
+					$pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans("Total"), 0, 'L');
712 712
 
713 713
 					// Total Qty
714 714
 					$pdf->SetXY($this->postotalht, $curY);
715
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
715
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0, 'R', 0);
716 716
 				}
717 717
 				else
718 718
 				{
@@ -721,48 +721,48 @@  discard block
 block discarded – undo
721 721
 
722 722
 				if ($notetoshow)
723 723
 				{
724
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
724
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
725 725
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
726 726
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
727 727
 
728 728
 					$tab_top = 88;
729 729
 
730
-					$pdf->SetFont('','', $default_font_size - 1);
731
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
730
+					$pdf->SetFont('', '', $default_font_size - 1);
731
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
732 732
 					$nexY = $pdf->GetY();
733
-					$height_note=$nexY-$tab_top;
733
+					$height_note = $nexY - $tab_top;
734 734
 
735 735
 					// Rect prend une longueur en 3eme param
736
-					$pdf->SetDrawColor(192,192,192);
737
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
736
+					$pdf->SetDrawColor(192, 192, 192);
737
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
738 738
 
739 739
 					$tab_height = $tab_height - $height_note;
740
-					$tab_top = $nexY+6;
740
+					$tab_top = $nexY + 6;
741 741
 				}
742 742
 				else
743 743
 				{
744
-					$height_note=0;
744
+					$height_note = 0;
745 745
 				}
746 746
 
747 747
 				$iniY = $tab_top + 7;
748 748
 				$curY = $tab_top + 7;
749 749
 				$nexY = $tab_top + 7;
750 750
 
751
-				$tab_top = $tab_top_newpage+21;
751
+				$tab_top = $tab_top_newpage + 21;
752 752
 
753 753
 				// Show square
754 754
 				if ($pagenb == 1)
755 755
 				{
756 756
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
757
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
757
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758 758
 				}
759 759
 				else
760 760
 				{
761 761
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
762
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763 763
 				}
764 764
 
765
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
765
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
766 766
 
767 767
 				// Affiche zone infos
768 768
 				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -771,35 +771,35 @@  discard block
 block discarded – undo
771 771
 				//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
772 772
 
773 773
 				// Pied de page
774
-				$this->_pagefoot($pdf,$object,$outputlangs);
775
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
774
+				$this->_pagefoot($pdf, $object, $outputlangs);
775
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
776 776
 
777 777
 				$pdf->Close();
778 778
 
779
-				$pdf->Output($file,'F');
779
+				$pdf->Output($file, 'F');
780 780
 
781 781
 				// Add pdfgeneration hook
782 782
 				$hookmanager->initHooks(array('pdfgeneration'));
783
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
783
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
784 784
 				global $action;
785
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
785
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
786 786
 
787
-				if (! empty($conf->global->MAIN_UMASK))
787
+				if (!empty($conf->global->MAIN_UMASK))
788 788
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
789 789
 
790 790
 				$this->result = array('fullpath'=>$file);
791 791
 
792
-				return 1;   // Pas d'erreur
792
+				return 1; // Pas d'erreur
793 793
 			}
794 794
 			else
795 795
 			{
796
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
796
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
797 797
 				return 0;
798 798
 			}
799 799
 		}
800 800
 		else
801 801
 		{
802
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
802
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR");
803 803
 			return 0;
804 804
 		}
805 805
 	}
@@ -818,74 +818,74 @@  discard block
 block discarded – undo
818 818
 	 *   @param		string		$currency		Currency code
819 819
 	 *   @return	void
820 820
 	 */
821
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
821
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
822 822
 	{
823 823
 	    global $conf;
824 824
 
825 825
 	    // Force to disable hidetop and hidebottom
826
-	    $hidebottom=0;
827
-	    if ($hidetop) $hidetop=-1;
826
+	    $hidebottom = 0;
827
+	    if ($hidetop) $hidetop = -1;
828 828
 
829 829
 	    $currency = !empty($currency) ? $currency : $conf->currency;
830 830
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
831 831
 
832 832
 	    // Amount in (at tab_top - 1)
833
-	    $pdf->SetTextColor(0,0,0);
834
-	    $pdf->SetFont('','', $default_font_size - 2);
833
+	    $pdf->SetTextColor(0, 0, 0);
834
+	    $pdf->SetFont('', '', $default_font_size - 2);
835 835
 
836 836
 	    if (empty($hidetop))
837 837
 	    {
838
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
839
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
838
+	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
839
+	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
840 840
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
841 841
 
842 842
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
843
-	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
843
+	        if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
844 844
 	    }
845 845
 
846
-	    $pdf->SetDrawColor(128,128,128);
847
-	    $pdf->SetFont('','B', $default_font_size - 3);
846
+	    $pdf->SetDrawColor(128, 128, 128);
847
+	    $pdf->SetFont('', 'B', $default_font_size - 3);
848 848
 
849 849
 	    // Output Rect
850 850
 	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
851 851
 
852
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
853
-		$pdf->SetDrawColor(220,26,26);
854
-		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
852
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
853
+		$pdf->SetDrawColor(220, 26, 26);
854
+		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
855 855
 		$pdf->SetLineStyle(array('dash'=>0));
856
-		$pdf->SetDrawColor(128,128,128);
857
-		$pdf->SetTextColor(0,0,120);
856
+		$pdf->SetDrawColor(128, 128, 128);
857
+		$pdf->SetTextColor(0, 0, 120);
858 858
 
859 859
 		//Ref mouv
860 860
 	    if (empty($hidetop))
861 861
 	    {
862 862
 	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
863
-	        $pdf->SetXY($this->posxidref, $tab_top+1);
864
-	        $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L');
863
+	        $pdf->SetXY($this->posxidref, $tab_top + 1);
864
+	        $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
865 865
 	    }
866 866
 
867 867
 		//Date mouv
868 868
 		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
869 869
 		if (empty($hidetop))
870 870
 		{
871
-			$pdf->SetXY($this->posxdatemouv, $tab_top+1);
872
-			$pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C');
871
+			$pdf->SetXY($this->posxdatemouv, $tab_top + 1);
872
+			$pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C');
873 873
 		}
874 874
 
875 875
 		//Ref Product
876 876
 	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
877 877
 	    if (empty($hidetop))
878 878
 	    {
879
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
880
-	        $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C');
879
+	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
880
+	        $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
881 881
 	    }
882 882
 
883 883
 		//Label Product
884 884
 	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
885 885
 	    if (empty($hidetop))
886 886
 	    {
887
-	        $pdf->SetXY($this->posxlabel-1, $tab_top+1);
888
-			$pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C');
887
+	        $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
888
+			$pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C');
889 889
 	    }
890 890
 
891 891
 		//Lot/serie Product
@@ -893,44 +893,44 @@  discard block
 block discarded – undo
893 893
 		if (empty($hidetop))
894 894
 		{
895 895
 			$pdf->SetXY($this->posxqty, $tab_top + 1);
896
-			$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C');
896
+			$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '', 'C');
897 897
 		}
898 898
 
899 899
 		//Code Inv
900 900
 	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
901 901
 	    if (empty($hidetop))
902 902
 	    {
903
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
904
-			$pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C');
903
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
904
+			$pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C');
905 905
 	    }
906 906
 
907 907
 		//Label mouvement
908 908
 	    //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
909 909
 	    if (empty($hidetop))
910 910
 	    {
911
-	        $pdf->SetXY($this->posxunit, $tab_top+1);
912
-	        $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C');
911
+	        $pdf->SetXY($this->posxunit, $tab_top + 1);
912
+	        $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
913 913
 	    }
914 914
 
915 915
 		//Origin
916 916
 	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
917 917
 	    if (empty($hidetop))
918 918
 	    {
919
-	        $pdf->SetXY($this->posxdiscount+2, $tab_top+1);
920
-	        $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C');
919
+	        $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
920
+	        $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
921 921
 	    }
922 922
 
923 923
 		//Qty
924 924
 	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
925 925
 	    if (empty($hidetop))
926 926
 	    {
927
-	        $pdf->SetXY($this->postotalht+2, $tab_top+1);
928
-	        $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C');
927
+	        $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
928
+	        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
929 929
 	    }
930 930
 
931
-		$pdf->SetDrawColor(220,26,26);
932
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
933
-		$pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
931
+		$pdf->SetDrawColor(220, 26, 26);
932
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
933
+		$pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
934 934
 		$pdf->SetLineStyle(array('dash'=>0));
935 935
 	}
936 936
 
@@ -944,92 +944,92 @@  discard block
 block discarded – undo
944 944
 	 *  @param	string		$titlekey		Translation key to show as title of document
945 945
 	 *  @return	void
946 946
 	 */
947
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
947
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
948 948
 	{
949
-	    global $conf,$langs,$db,$hookmanager;
949
+	    global $conf, $langs, $db, $hookmanager;
950 950
 
951 951
 	    // Load traductions files requiredby by page
952 952
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
953 953
 
954 954
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
955 955
 
956
-	    if ($object->type == 1) $titlekey='ServiceSheet';
957
-	    else $titlekey='StockSheet';
956
+	    if ($object->type == 1) $titlekey = 'ServiceSheet';
957
+	    else $titlekey = 'StockSheet';
958 958
 
959
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
959
+	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
960 960
 
961 961
 	    // Show Draft Watermark
962
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
962
+	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
963 963
 	    {
964
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
964
+	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
965 965
 	    }
966 966
 
967
-	    $pdf->SetTextColor(0,0,60);
968
-	    $pdf->SetFont('','B', $default_font_size + 3);
967
+	    $pdf->SetTextColor(0, 0, 60);
968
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
969 969
 
970
-	    $posy=$this->marge_haute;
971
-	    $posx=$this->page_largeur-$this->marge_droite-100;
970
+	    $posy = $this->marge_haute;
971
+	    $posx = $this->page_largeur - $this->marge_droite - 100;
972 972
 
973
-	    $pdf->SetXY($this->marge_gauche,$posy);
973
+	    $pdf->SetXY($this->marge_gauche, $posy);
974 974
 
975 975
 	    // Logo
976
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
976
+	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
977 977
 	    if ($this->emetteur->logo)
978 978
 	    {
979 979
 	        if (is_readable($logo))
980 980
 	        {
981
-	            $height=pdf_getHeightForLogo($logo);
982
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
981
+	            $height = pdf_getHeightForLogo($logo);
982
+	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
983 983
 	        }
984 984
 	        else
985 985
 	        {
986
-	            $pdf->SetTextColor(200,0,0);
987
-	            $pdf->SetFont('','B', $default_font_size -2);
988
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
986
+	            $pdf->SetTextColor(200, 0, 0);
987
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
988
+	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
989 989
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
990 990
 	        }
991 991
 	    }
992 992
 	    else
993 993
 	    {
994
-	        $text=$this->emetteur->name;
994
+	        $text = $this->emetteur->name;
995 995
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
996 996
 	    }
997 997
 
998
-	    $pdf->SetFont('','B', $default_font_size + 3);
999
-	    $pdf->SetXY($posx,$posy);
1000
-	    $pdf->SetTextColor(0,0,60);
1001
-	    $title=$outputlangs->transnoentities("Warehouse");
998
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
999
+	    $pdf->SetXY($posx, $posy);
1000
+	    $pdf->SetTextColor(0, 0, 60);
1001
+	    $title = $outputlangs->transnoentities("Warehouse");
1002 1002
 	    $pdf->MultiCell(100, 3, $title, '', 'R');
1003 1003
 
1004
-	    $pdf->SetFont('','B',$default_font_size);
1004
+	    $pdf->SetFont('', 'B', $default_font_size);
1005 1005
 
1006
-	    $posy+=5;
1007
-	    $pdf->SetXY($posx,$posy);
1008
-	    $pdf->SetTextColor(0,0,60);
1006
+	    $posy += 5;
1007
+	    $pdf->SetXY($posx, $posy);
1008
+	    $pdf->SetTextColor(0, 0, 60);
1009 1009
 
1010
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
1010
+	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->libelle), '', 'R');
1011 1011
 
1012
-	    $posy+=5;
1013
-	    $pdf->SetFont('','', $default_font_size - 1);
1014
-		$pdf->SetXY($posx,$posy);
1015
-	    $pdf->SetTextColor(0,0,60);
1012
+	    $posy += 5;
1013
+	    $pdf->SetFont('', '', $default_font_size - 1);
1014
+		$pdf->SetXY($posx, $posy);
1015
+	    $pdf->SetTextColor(0, 0, 60);
1016 1016
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1017 1017
 
1018
-		$posy+=4;
1019
-		$pdf->SetXY($posx-50,$posy);
1018
+		$posy += 4;
1019
+		$pdf->SetXY($posx - 50, $posy);
1020 1020
 		$pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1021 1021
 
1022 1022
 
1023 1023
 		// Parent MouvementStock
1024
-		$posy+=4;
1025
-		$pdf->SetXY($posx,$posy);
1026
-		$pdf->SetTextColor(0,0,60);
1024
+		$posy += 4;
1025
+		$pdf->SetXY($posx, $posy);
1026
+		$pdf->SetTextColor(0, 0, 60);
1027 1027
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1028 1028
 
1029
-		$posy+=4;
1030
-		$pdf->SetXY($posx-50,$posy);
1029
+		$posy += 4;
1030
+		$pdf->SetXY($posx - 50, $posy);
1031 1031
 		$e = new MouvementStock($db);
1032
-		if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1032
+		if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1033 1033
 		{
1034 1034
 			$pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1035 1035
 		}
@@ -1040,25 +1040,25 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 		// Description
1042 1042
 		$nexY = $pdf->GetY();
1043
-		$nexY+=5;
1044
-		$pdf->SetXY($posx,$posy);
1043
+		$nexY += 5;
1044
+		$pdf->SetXY($posx, $posy);
1045 1045
 		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1046 1046
 		$nexY = $pdf->GetY();
1047 1047
 
1048
-		$calcproductsunique=$object->nb_different_products();
1049
-		$calcproducts=$object->nb_products();
1048
+		$calcproductsunique = $object->nb_different_products();
1049
+		$calcproducts = $object->nb_products();
1050 1050
 
1051 1051
 		// Total nb of different products
1052
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1052
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
1053 1053
 		$nexY = $pdf->GetY();
1054 1054
 
1055 1055
 		// Nb of products
1056
-		$valtoshow=price2num($calcproducts['nb'], 'MS');
1057
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1056
+		$valtoshow = price2num($calcproducts['nb'], 'MS');
1057
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
1058 1058
 		$nexY = $pdf->GetY();
1059 1059
 
1060 1060
 		// Value
1061
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1061
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1062 1062
 		$nexY = $pdf->GetY();
1063 1063
 
1064 1064
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 		if ($resqlbis)
1071 1071
 		{
1072 1072
 			$obj = $db->fetch_object($resqlbis);
1073
-			$lastmovementdate=$db->jdate($obj->datem);
1073
+			$lastmovementdate = $db->jdate($obj->datem);
1074 1074
 		}
1075 1075
 		else
1076 1076
 		{
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 
1080 1080
 		if ($lastmovementdate)
1081 1081
 		{
1082
-			$toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1082
+			$toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
1083 1083
 		}
1084 1084
 		else
1085 1085
 		{
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 	        }
1121 1121
 	    }*/
1122 1122
 
1123
-	    $posy+=2;
1123
+	    $posy += 2;
1124 1124
 
1125 1125
 	    // Show list of linked objects
1126 1126
 	    //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	        */
1161 1161
 	    }
1162 1162
 
1163
-	    $pdf->SetTextColor(0,0,0);
1163
+	    $pdf->SetTextColor(0, 0, 0);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
@@ -1172,10 +1172,10 @@  discard block
 block discarded – undo
1172 1172
 	 *      @param	int			$hidefreetext		1=Hide free text
1173 1173
 	 *      @return	int								Return height of bottom margin including footer text
1174 1174
 	 */
1175
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1175
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1176 1176
 	{
1177 1177
 	    global $conf;
1178
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1178
+	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
+	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1180 1180
 	}
1181 1181
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/stock/modules_movement.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var string Error code (or message)
35 35
 	 */
36
-	public $error='';
36
+	public $error = '';
37 37
 
38 38
 
39 39
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
      *  @param  integer	$maxfilenamelength  Max length of value to show
45 45
      *  @return	array						List of templates
46 46
 	 */
47
-	static function liste_modeles($db,$maxfilenamelength=0)
47
+	static function liste_modeles($db, $maxfilenamelength = 0)
48 48
 	{
49 49
         // phpcs:enable
50 50
 		global $conf;
51 51
 
52
-		$type='mouvement';
53
-		$liste=array();
52
+		$type = 'mouvement';
53
+		$liste = array();
54 54
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
55
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
56 56
 		return $liste;
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modProjet.class.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  *	\ingroup    projet
29 29
  *	\brief      Fichier de description et activation du module Projet
30 30
  */
31
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
31
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32 32
 
33 33
 
34 34
 /**
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 		$this->family = "projects";
52 52
 		$this->module_position = '10';
53 53
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
55 55
 		$this->description = "Gestion des projets";
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		$this->config_page_url = array("project.php@projet");
61
-		$this->picto='project';
61
+		$this->picto = 'project';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array("/projet/temp");
65 65
 
66 66
 		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
67
+		$this->hidden = false; // A condition to hide module
68
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
69
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
70
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
71
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
72 72
 		$this->langfiles = array('projects');
73 73
 
74 74
 		// Constants
75 75
 		$this->const = array();
76
-		$r=0;
76
+		$r = 0;
77 77
 
78 78
 		$this->const[$r][0] = "PROJECT_ADDON_PDF";
79 79
 		$this->const[$r][1] = "chaine";
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		// Boxes
141 141
 		$this->boxes = array();
142
-		$r=0;
142
+		$r = 0;
143 143
 		$this->boxes[$r][1] = "box_project.php";
144 144
 		$r++;
145 145
 		$this->boxes[$r][1] = "box_task.php";
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		// Permissions
149 149
 		$this->rights = array();
150 150
 		$this->rights_class = 'projet';
151
-		$r=0;
151
+		$r = 0;
152 152
 
153 153
 		$r++;
154 154
 		$this->rights[$r][0] = 41; // id de la permission
@@ -205,34 +205,34 @@  discard block
 block discarded – undo
205 205
 
206 206
 		// Menus
207 207
 		//-------
208
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
208
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
209 209
 
210 210
 
211 211
 		//Exports
212 212
 		//--------
213
-		$r=1;
214
-
215
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
216
-		$this->export_label[$r]='ProjectsAndTasksLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
217
-		$this->export_permission[$r]=array(array("projet","export"));
218
-		$this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
-
220
-		$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
221
-		's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
222
-		'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
223
-		'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
224
-		'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
225
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
226
-		's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
227
-
228
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
229
-		's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
-		'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description");
213
+		$r = 1;
214
+
215
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
216
+		$this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
217
+		$this->export_permission[$r] = array(array("projet", "export"));
218
+		$this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
+
220
+		$this->export_TypeFields_array[$r] = array('s.rowid'=>"List:societe:nom", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
221
+		's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
222
+		'p.rowid'=>"List:projet:ref", 'p.ref'=>"Text", 'p.title'=>"Text", 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric',
223
+		'pt.rowid'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text",
224
+		'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text");
225
+		$this->export_entities_array[$r] = array('s.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
226
+		's.phone'=>'company', 's.email'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company');
227
+
228
+		$this->export_fields_array[$r] = array('s.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
229
+		's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
+		'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description");
231 231
 	    // Add multicompany field
232
-        if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
232
+        if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
233 233
         {
234
-            $nbofallowedentities=count(explode(',',getEntity('project')));    // If project are shared, nb will be > 1
235
-            if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
234
+            $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
235
+            if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity');
236 236
         }
237 237
 		if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
238 238
 		{
@@ -242,62 +242,62 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 
244 244
 		// Add fields for project
245
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
245
+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
246 246
 		// Add extra fields for project
247
-		$keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
247
+		$keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra';
248 248
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
249 249
 		// Add fields for tasks
250
-        $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
251
-		$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
250
+        $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
251
+		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
252 252
         // Add extra fields for task
253
-		$keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
253
+		$keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2';
254 254
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
255 255
         // End add extra fields
256
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
257
-        $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
256
+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));
257
+        $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));
258 258
 
259
-        $this->export_sql_start[$r]='SELECT DISTINCT ';
260
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'projet as p';
261
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
262
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
263
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
264
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
265
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
-		$this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")";
259
+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
260
+		$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
261
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
262
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
263
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
264
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
265
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
+		$this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
268 268
 
269 269
 
270 270
 		// Import list of tasks
271 271
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
272 272
 		{
273 273
     		$r++;
274
-    		$this->import_code[$r]='tasksofprojects';
275
-    		$this->import_label[$r]='ImportDatasetTasks';
276
-    		$this->import_icon[$r]='task';
277
-    		$this->import_entities_array[$r]=array('t.fk_projet'=>'project');	// We define here only fields that use another icon that the one defined into import_icon
278
-    		$this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields');	// List of tables to insert into (insert done in same order)
279
-    		$this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation");
274
+    		$this->import_code[$r] = 'tasksofprojects';
275
+    		$this->import_label[$r] = 'ImportDatasetTasks';
276
+    		$this->import_icon[$r] = 'task';
277
+    		$this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon
278
+    		$this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)
279
+    		$this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");
280 280
     		// Add extra fields
281
-    		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
-    		$resql=$this->db->query($sql);
281
+    		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
+    		$resql = $this->db->query($sql);
283 283
     		if ($resql)    // This can fail when class is used on old database (during migration for example)
284 284
     		{
285
-    		    while ($obj=$this->db->fetch_object($resql))
285
+    		    while ($obj = $this->db->fetch_object($resql))
286 286
     		    {
287
-    		        $fieldname='extra.'.$obj->name;
288
-    		        $fieldlabel=ucfirst($obj->label);
289
-    		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
287
+    		        $fieldname = 'extra.'.$obj->name;
288
+    		        $fieldlabel = ucfirst($obj->label);
289
+    		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
290 290
     		    }
291 291
     		}
292 292
     		// End add extra fields
293
-    		$this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
-    		$this->import_convertvalue_array[$r]=array(
295
-    		    't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'),
293
+    		$this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
+    		$this->import_convertvalue_array[$r] = array(
295
+    		    't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
296 296
     		    't.ref'=>array('rule'=>'getrefifauto')
297 297
     		);
298 298
     		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
299
-    		$this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
-    		$this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note");
299
+    		$this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
+    		$this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");
301 301
 		}
302 302
 	}
303 303
 
@@ -310,58 +310,58 @@  discard block
 block discarded – undo
310 310
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
311 311
 	 *      @return     int             	1 if OK, 0 if KO
312 312
 	 */
313
-	function init($options='')
313
+	function init($options = '')
314 314
 	{
315
-		global $conf,$langs;
315
+		global $conf, $langs;
316 316
 
317 317
 		// Permissions
318 318
 		$this->remove($options);
319 319
 
320 320
 		//ODT template for project
321
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/projects';
323
-		$dest=$dirodt.'/template_project.odt';
321
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
323
+		$dest = $dirodt.'/template_project.odt';
324 324
 
325
-		if (file_exists($src) && ! file_exists($dest))
325
+		if (file_exists($src) && !file_exists($dest))
326 326
 		{
327 327
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
328 328
 			dol_mkdir($dirodt);
329
-			$result=dol_copy($src,$dest,0,0);
329
+			$result = dol_copy($src, $dest, 0, 0);
330 330
 			if ($result < 0)
331 331
 			{
332 332
 				$langs->load("errors");
333
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
333
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
334 334
 				return 0;
335 335
 			}
336 336
 		}
337 337
 
338 338
 		//ODT template for tasks
339
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/tasks';
341
-		$dest=$dirodt.'/template_task_summary.odt';
339
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
341
+		$dest = $dirodt.'/template_task_summary.odt';
342 342
 
343
-		if (file_exists($src) && ! file_exists($dest))
343
+		if (file_exists($src) && !file_exists($dest))
344 344
 		{
345 345
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
346 346
 			dol_mkdir($dirodt);
347
-			$result=dol_copy($src,$dest,0,0);
347
+			$result = dol_copy($src, $dest, 0, 0);
348 348
 			if ($result < 0)
349 349
 			{
350 350
 				$langs->load("errors");
351
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
351
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
352 352
 				return 0;
353 353
 			}
354 354
 		}
355 355
 
356 356
 		$sql = array();
357
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
357
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
363 363
 
364 364
 
365
-		return $this->_init($sql,$options);
365
+		return $this->_init($sql, $options);
366 366
 	}
367 367
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modFournisseur.class.php 1 patch
Spacing   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *		\ingroup    fournisseur
27 27
  *		\brief      Description and activation file for module Fournisseur
28 28
  */
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		$this->family = "srm";
53 53
 		$this->module_position = '10';
54 54
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
-		$this->name = preg_replace('/^mod/i','',get_class($this));
55
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
56 56
 		$this->description = "Gestion des fournisseurs";
57 57
 
58 58
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59 59
 		$this->version = 'dolibarr';
60 60
 
61 61
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		$this->picto='company';
62
+		$this->picto = 'company';
63 63
 
64 64
 		// Data directories to create when module is enabled
65 65
 		$this->dirs = array("/fournisseur/temp",
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 		// Constants
81 81
 		$this->const = array();
82
-		$r=0;
82
+		$r = 0;
83 83
 
84 84
 		$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
85 85
 		$this->const[$r][1] = "chaine";
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 		// Boxes
115 115
 		$this->boxes = array(
116
-		0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
117
-		1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'),
118
-		2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
119
-		3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
120
-		4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
121
-		5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
116
+		0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
117
+		1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
118
+		2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),
119
+		3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),
120
+		4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),
121
+		5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),
122 122
 		);
123 123
 
124 124
 		// Permissions
125 125
 		$this->rights = array();
126 126
 		$this->rights_class = 'fournisseur';
127
-		$r=0;
127
+		$r = 0;
128 128
 
129 129
 		$r++;
130 130
 		$this->rights[$r][0] = 1181;
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 		$this->rights[$r][4] = 'commande';
198 198
 		$this->rights[$r][5] = 'supprimer';
199 199
 
200
-		if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
200
+		if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
201 201
 		{
202 202
 			$r++;
203 203
 			$this->rights[$r][0] = 1190;
204
-			$this->rights[$r][1] = 'Approve supplier order (second level)';		// $langs->trans("Permission1190");
204
+			$this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190");
205 205
 			$this->rights[$r][2] = 'w';
206 206
 			$this->rights[$r][3] = 0;
207 207
 			$this->rights[$r][4] = 'commande';
@@ -267,27 +267,27 @@  discard block
 block discarded – undo
267 267
 
268 268
 	    // Menus
269 269
 	    //-------
270
-	    $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
270
+	    $this->menu = 1; // This module add menu entries. They are coded into menu manager.
271 271
 
272 272
 
273 273
 		// Exports
274 274
 		//--------
275
-		$r=0;
275
+		$r = 0;
276 276
 
277 277
 		$r++;
278
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
279
-		$this->export_label[$r]='Factures fournisseurs et lignes de facture';
280
-		$this->export_icon[$r]='bill';
281
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
282
-		$this->export_fields_array[$r]=array(
283
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
284
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
285
-			'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment',
286
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",
287
-			'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",
288
-			'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
289
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId',
290
-			'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
278
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
279
+		$this->export_label[$r] = 'Factures fournisseurs et lignes de facture';
280
+		$this->export_icon[$r] = 'bill';
281
+		$this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
282
+		$this->export_fields_array[$r] = array(
283
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
284
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
285
+			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>'DateMaxPayment',
286
+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",
287
+			'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT",
288
+			'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',
289
+			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',
290
+			'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
291 291
 		);
292 292
 		//$this->export_TypeFields_array[$r]=array(
293 293
 		//    's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
@@ -295,122 +295,122 @@  discard block
 block discarded – undo
295 295
 		//    'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
296 296
 		//     'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
297 297
 		//);
298
-		$this->export_TypeFields_array[$r]=array(
299
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
300
-			's.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date','f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",
301
-			'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",
302
-			'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
303
-			'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
298
+		$this->export_TypeFields_array[$r] = array(
299
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text',
300
+			's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date', 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric",
301
+			'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Text", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric",
302
+			'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label',
303
+			'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
304 304
 		);
305
-		$this->export_entities_array[$r]=array(
306
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company',
307
-			's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",
308
-			'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',
309
-			'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",
310
-			'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product',
311
-			'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
305
+		$this->export_entities_array[$r] = array(
306
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',
307
+			's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice",
308
+			'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice', 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice',
309
+			'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.remise_percent'=>"invoice_line",
310
+			'fd.total_ht'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',
311
+			'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
312 312
 		);
313
-		$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
313
+		$this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
314 314
 		// Add extra fields object
315
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
-		$resql=$this->db->query($sql);
315
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
+		$resql = $this->db->query($sql);
317 317
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
318 318
 		{
319
-			while ($obj=$this->db->fetch_object($resql))
319
+			while ($obj = $this->db->fetch_object($resql))
320 320
 			{
321
-				$fieldname='extra.'.$obj->name;
322
-				$fieldlabel=ucfirst($obj->label);
323
-				$typeFilter="Text";
324
-				switch($obj->type)
321
+				$fieldname = 'extra.'.$obj->name;
322
+				$fieldlabel = ucfirst($obj->label);
323
+				$typeFilter = "Text";
324
+				switch ($obj->type)
325 325
 				{
326 326
 					case 'int':
327 327
 					case 'double':
328 328
 					case 'price':
329
-						$typeFilter="Numeric";
329
+						$typeFilter = "Numeric";
330 330
 						break;
331 331
 					case 'date':
332 332
 					case 'datetime':
333
-						$typeFilter="Date";
333
+						$typeFilter = "Date";
334 334
 						break;
335 335
 					case 'boolean':
336
-						$typeFilter="Boolean";
336
+						$typeFilter = "Boolean";
337 337
 						break;
338 338
 					case 'sellist':
339
-						$tmp='';
340
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
342
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
339
+						$tmp = '';
340
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
342
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
343 343
 						break;
344 344
 				}
345
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
346
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
347
-				$this->export_entities_array[$r][$fieldname]='invoice';
345
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
346
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
347
+				$this->export_entities_array[$r][$fieldname] = 'invoice';
348 348
 			}
349 349
 		}
350 350
 		// End add extra fields
351 351
 		// Add extra fields line
352
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
-		$resql=$this->db->query($sql);
352
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
+		$resql = $this->db->query($sql);
354 354
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
355 355
 		{
356
-			while ($obj=$this->db->fetch_object($resql))
356
+			while ($obj = $this->db->fetch_object($resql))
357 357
 			{
358
-				$fieldname='extraline.'.$obj->name;
359
-				$fieldlabel=ucfirst($obj->label);
360
-				$typeFilter="Text";
361
-				switch($obj->type)
358
+				$fieldname = 'extraline.'.$obj->name;
359
+				$fieldlabel = ucfirst($obj->label);
360
+				$typeFilter = "Text";
361
+				switch ($obj->type)
362 362
 				{
363 363
 					case 'int':
364 364
 					case 'double':
365 365
 					case 'price':
366
-						$typeFilter="Numeric";
366
+						$typeFilter = "Numeric";
367 367
 						break;
368 368
 					case 'date':
369 369
 					case 'datetime':
370
-						$typeFilter="Date";
370
+						$typeFilter = "Date";
371 371
 						break;
372 372
 					case 'boolean':
373
-						$typeFilter="Boolean";
373
+						$typeFilter = "Boolean";
374 374
 						break;
375 375
 					case 'sellist':
376
-						$tmp='';
377
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
379
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
376
+						$tmp = '';
377
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
379
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
380 380
 						break;
381 381
 				}
382
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
383
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
384
-				$this->export_entities_array[$r][$fieldname]='invoice_line';
382
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
383
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
384
+				$this->export_entities_array[$r][$fieldname] = 'invoice_line';
385 385
 			}
386 386
 		}
387 387
 		// End add extra fields line
388
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
389
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
390
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
388
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
389
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
390
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399
+		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
401 401
 
402 402
 		$r++;
403
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
404
-		$this->export_label[$r]='Factures fournisseurs et reglements';
405
-		$this->export_icon[$r]='bill';
406
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
407
-		$this->export_fields_array[$r]=array(
408
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
409
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
410
-			's.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",
411
-			'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",
412
-			'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment',
413
-			'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
403
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
404
+		$this->export_label[$r] = 'Factures fournisseurs et reglements';
405
+		$this->export_icon[$r] = 'bill';
406
+		$this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
407
+		$this->export_fields_array[$r] = array(
408
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
409
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
410
+			's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation",
411
+			'f.datef'=>"DateInvoice", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid",
412
+			'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment',
413
+			'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
414 414
 		);
415 415
 		//$this->export_TypeFields_array[$r]=array(
416 416
 		//	's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
@@ -418,200 +418,200 @@  discard block
 block discarded – undo
418 418
 		//	'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
419 419
 		//	'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
420 420
 		//);
421
-		$this->export_TypeFields_array[$r]=array(
422
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text',
423
-			's.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",
424
-			'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric',
425
-			'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text'
421
+		$this->export_TypeFields_array[$r] = array(
422
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',
423
+			's.idprof4'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.total_ht'=>"Numeric",
424
+			'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',
425
+			'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text'
426 426
 		);
427
-		$this->export_entities_array[$r]=array(
428
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company',
429
-			's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company',
430
-			'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",
431
-			'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment',
432
-		    'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');
433
-		$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
427
+		$this->export_entities_array[$r] = array(
428
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
429
+			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company',
430
+			'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice",
431
+			'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',
432
+		    'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');
433
+		$this->export_dependencies_array[$r] = array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
434 434
 		// Add extra fields object
435
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
-		$resql=$this->db->query($sql);
435
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
+		$resql = $this->db->query($sql);
437 437
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
438 438
 		{
439
-			while ($obj=$this->db->fetch_object($resql))
439
+			while ($obj = $this->db->fetch_object($resql))
440 440
 			{
441
-				$fieldname='extra.'.$obj->name;
442
-				$fieldlabel=ucfirst($obj->label);
443
-				$typeFilter="Text";
444
-				switch($obj->type)
441
+				$fieldname = 'extra.'.$obj->name;
442
+				$fieldlabel = ucfirst($obj->label);
443
+				$typeFilter = "Text";
444
+				switch ($obj->type)
445 445
 				{
446 446
 					case 'int':
447 447
 					case 'double':
448 448
 					case 'price':
449
-						$typeFilter="Numeric";
449
+						$typeFilter = "Numeric";
450 450
 						break;
451 451
 					case 'date':
452 452
 					case 'datetime':
453
-						$typeFilter="Date";
453
+						$typeFilter = "Date";
454 454
 						break;
455 455
 					case 'boolean':
456
-						$typeFilter="Boolean";
456
+						$typeFilter = "Boolean";
457 457
 						break;
458 458
 					case 'sellist':
459
-						$tmp='';
460
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
462
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
459
+						$tmp = '';
460
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
462
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
463 463
 						break;
464 464
 				}
465
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
466
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
467
-				$this->export_entities_array[$r][$fieldname]='invoice';
465
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
466
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
467
+				$this->export_entities_array[$r][$fieldname] = 'invoice';
468 468
 			}
469 469
 		}
470 470
 		// End add extra fields object
471
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
472
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
473
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
481
-        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
471
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
472
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
473
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
481
+        $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
483 483
 
484 484
 		// Order
485 485
 		$r++;
486
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
487
-		$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
488
-		$this->export_icon[$r]='order';
489
-		$this->export_permission[$r]=array(array("fournisseur","commande","export"));
490
-		$this->export_fields_array[$r]=array(
491
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
492
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
493
-			'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",
494
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2',
495
-			'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",
496
-			'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",
497
-			'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId',
498
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
486
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
487
+		$this->export_label[$r] = 'Commandes fournisseurs et lignes de commandes';
488
+		$this->export_icon[$r] = 'order';
489
+		$this->export_permission[$r] = array(array("fournisseur", "commande", "export"));
490
+		$this->export_fields_array[$r] = array(
491
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
492
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
493
+			'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned",
494
+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
495
+			'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
496
+			'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC",
497
+			'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
498
+			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
499 499
 		);
500 500
 		if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
501 501
 		{
502 502
 			unset($this->export_fields_array['f.date_approve2']);
503 503
 			unset($this->export_fields_array['ua2.login']);
504 504
 		}
505
-		$this->export_TypeFields_array[$r]=array(
506
-			's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text',
507
-			's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",
508
-			'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
509
-			'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",
510
-			'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",
511
-			'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
505
+		$this->export_TypeFields_array[$r] = array(
506
+			's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',
507
+			's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",
508
+			'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",
509
+			'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",
510
+			'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric",
511
+			'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
512 512
 		);
513
-		$this->export_entities_array[$r]=array(
514
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company',
515
-			's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user',
516
-			'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",
517
-			'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product',
518
-			'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
513
+		$this->export_entities_array[$r] = array(
514
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',
515
+			's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'ua1.login'=>'user',
516
+			'ua2.login'=>'user', 'fd.rowid'=>'order_line', 'fd.description'=>"order_line", 'fd.tva_tx'=>"order_line", 'fd.qty'=>"order_line", 'fd.remise_percent'=>"order_line",
517
+			'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',
518
+			'p.ref'=>'product', 'p.label'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
519 519
 		);
520
-		$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
520
+		$this->export_dependencies_array[$r] = array('order_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
521 521
 		// Add extra fields object
522
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
-		$resql=$this->db->query($sql);
522
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
+		$resql = $this->db->query($sql);
524 524
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
525 525
 		{
526
-			while ($obj=$this->db->fetch_object($resql))
526
+			while ($obj = $this->db->fetch_object($resql))
527 527
 			{
528
-				$fieldname='extra.'.$obj->name;
529
-				$fieldlabel=ucfirst($obj->label);
530
-				$typeFilter="Text";
531
-				switch($obj->type)
528
+				$fieldname = 'extra.'.$obj->name;
529
+				$fieldlabel = ucfirst($obj->label);
530
+				$typeFilter = "Text";
531
+				switch ($obj->type)
532 532
 				{
533 533
 					case 'int':
534 534
 					case 'double':
535 535
 					case 'price':
536
-						$typeFilter="Numeric";
536
+						$typeFilter = "Numeric";
537 537
 						break;
538 538
 					case 'date':
539 539
 					case 'datetime':
540
-						$typeFilter="Date";
540
+						$typeFilter = "Date";
541 541
 						break;
542 542
 					case 'boolean':
543
-						$typeFilter="Boolean";
543
+						$typeFilter = "Boolean";
544 544
 						break;
545 545
 					case 'sellist':
546
-						$tmp='';
547
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
-						$tmpkey=array_keys($tmpparam['options']);
549
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
550
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
546
+						$tmp = '';
547
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
+						$tmpkey = array_keys($tmpparam['options']);
549
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey);
550
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
551 551
 						break;
552 552
 				}
553
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
554
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
555
-				$this->export_entities_array[$r][$fieldname]='order';
553
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
554
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
555
+				$this->export_entities_array[$r][$fieldname] = 'order';
556 556
 			}
557 557
 		}
558 558
 		// End add extra fields object
559 559
 		// Add extra fields line
560
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
-		$resql=$this->db->query($sql);
560
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
+		$resql = $this->db->query($sql);
562 562
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
563 563
 		{
564
-			while ($obj=$this->db->fetch_object($resql))
564
+			while ($obj = $this->db->fetch_object($resql))
565 565
 			{
566
-				$fieldname='extraline.'.$obj->name;
567
-				$fieldlabel=ucfirst($obj->label);
568
-				$typeFilter="Text";
569
-				switch($obj->type)
566
+				$fieldname = 'extraline.'.$obj->name;
567
+				$fieldlabel = ucfirst($obj->label);
568
+				$typeFilter = "Text";
569
+				switch ($obj->type)
570 570
 				{
571 571
 					case 'int':
572 572
 					case 'double':
573 573
 					case 'price':
574
-						$typeFilter="Numeric";
574
+						$typeFilter = "Numeric";
575 575
 						break;
576 576
 					case 'date':
577 577
 					case 'datetime':
578
-						$typeFilter="Date";
578
+						$typeFilter = "Date";
579 579
 						break;
580 580
 					case 'boolean':
581
-						$typeFilter="Boolean";
581
+						$typeFilter = "Boolean";
582 582
 						break;
583 583
 					case 'sellist':
584
-						$tmp='';
585
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
584
+						$tmp = '';
585
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
586 586
 
587 587
 						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
588
-							$tmpparam_param_key=array_keys($tmpparam['options']);
589
-							$tmp=array_shift($tmpparam_param_key);
588
+							$tmpparam_param_key = array_keys($tmpparam['options']);
589
+							$tmp = array_shift($tmpparam_param_key);
590 590
 						}
591
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
591
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
592 592
 						break;
593 593
 				}
594
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
595
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
596
-				$this->export_entities_array[$r][$fieldname]='order_line';
594
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
595
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
596
+				$this->export_entities_array[$r][$fieldname] = 'order_line';
597 597
 			}
598 598
 		}
599 599
 		// End add extra fields line
600
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
601
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
602
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
614
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
600
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
601
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
602
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
+		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')';
614
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
615 615
 	}
616 616
 
617 617
 
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
624 624
 	 *      @return     int             	1 if OK, 0 if KO
625 625
 	 */
626
-	function init($options='')
626
+	function init($options = '')
627 627
 	{
628 628
 		global $conf;
629 629
 
@@ -634,6 +634,6 @@  discard block
 block discarded – undo
634 634
 			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",
635 635
 		);
636 636
 
637
-		return $this->_init($sql,$options);
637
+		return $this->_init($sql, $options);
638 638
 	}
639 639
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modSalaries.class.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *  \ingroup    salaries
30 30
  *  \brief      File to activate module salaries
31 31
  */
32
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 33
 
34 34
 
35 35
 /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		// It is used to group modules by family in module setup page
55 55
 		$this->family = "financial";
56 56
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
57
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
58 58
 		// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59 59
 		$this->description = "Payment of salaries";
60 60
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->version = 'dolibarr';
63 63
 
64 64
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65
-		$this->picto='bill';
65
+		$this->picto = 'bill';
66 66
 
67 67
 		// Data directories to create when module is enabled
68 68
 		$this->dirs = array("/salaries/temp");
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		$this->config_page_url = array();
73 73
 
74 74
 		// Dependencies
75
-		$this->hidden = false;			// A condition to hide module
76
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
77
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
78
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
79
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
80
-		$this->langfiles = array("salaries","bills");
75
+		$this->hidden = false; // A condition to hide module
76
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
77
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
78
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
79
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
80
+		$this->langfiles = array("salaries", "bills");
81 81
 
82 82
 		// Constants
83 83
 		$this->const = array();
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		// Permissions
99 99
 		$this->rights = array();
100 100
 		$this->rights_class = 'salaries';
101
-		$r=0;
101
+		$r = 0;
102 102
 
103 103
 		$r++;
104 104
 		$this->rights[$r][0] = 511;
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 
136 136
 		// Menus
137 137
 		//-------
138
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
138
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
139 139
 
140 140
 
141 141
 		// Exports
142 142
 		//--------
143
-		$r=0;
143
+		$r = 0;
144 144
 
145 145
 		$r++;
146
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
147
-		$this->export_label[$r]='Salaries and payments';
148
-		$this->export_permission[$r]=array(array("salaries","export"));
149
-		$this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_payment'=>'Numero','p.label'=>'Label','p.note'=>'Note');
150
-		$this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Numeric",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Numeric','p.num_payment'=>'Numeric','p.label'=>'Text');
151
-		$this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_payment'=>'payment');
152
-
153
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
154
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
155
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
146
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
147
+		$this->export_label[$r] = 'Salaries and payments';
148
+		$this->export_permission[$r] = array(array("salaries", "export"));
149
+		$this->export_fields_array[$r] = array('u.firstname'=>"Firstname", 'u.lastname'=>"Lastname", 'u.login'=>"Login", 'u.salary'=>'CurrentSalary', 'p.datep'=>'DatePayment', 'p.datesp'=>'DateStartPeriod', 'p.dateep'=>'DateEndPeriod', 'p.amount'=>'AmountPayment', 'p.num_payment'=>'Numero', 'p.label'=>'Label', 'p.note'=>'Note');
150
+		$this->export_TypeFields_array[$r] = array('u.firstname'=>"Text", 'u.lastname'=>"Text", 'u.login'=>'Text', 'u.salary'=>"Numeric", 'p.datep'=>'Date', 'p.datesp'=>'Date', 'p.dateep'=>'Date', 'p.amount'=>'Numeric', 'p.num_payment'=>'Numeric', 'p.label'=>'Text');
151
+		$this->export_entities_array[$r] = array('u.firstname'=>'user', 'u.lastname'=>'user', 'u.login'=>'user', 'u.salary'=>'user', 'p.datep'=>'payment', 'p.datesp'=>'payment', 'p.dateep'=>'payment', 'p.amount'=>'payment', 'p.label'=>'payment', 'p.note'=>'payment', 'p.num_payment'=>'payment');
152
+
153
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
154
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'user as u';
155
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('user').')';
158 158
 	}
159 159
 
160 160
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
167 167
 	 *      @return     int             	1 if OK, 0 if KO
168 168
 	 */
169
-	function init($options='')
169
+	function init($options = '')
170 170
 	{
171 171
 		global $conf;
172 172
 
@@ -175,6 +175,6 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$sql = array();
177 177
 
178
-		return $this->_init($sql,$options);
178
+		return $this->_init($sql, $options);
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modService.class.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\ingroup    service
27 27
  *	\brief      Fichier de description et activation du module Service
28 28
  */
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,42 +50,42 @@  discard block
 block discarded – undo
50 50
 		$this->family = "products";
51 51
 		$this->module_position = '30';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Service management";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='service';
60
+		$this->picto = 'service';
61 61
 
62 62
 		// Data directories to create when module is enabled
63 63
 		$this->dirs = array("/product/temp");
64 64
 
65 65
 		// Dependencies
66
-		$this->hidden = false;			// A condition to hide module
67
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
69
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
66
+		$this->hidden = false; // A condition to hide module
67
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
68
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
69
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
70
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
71 71
 
72 72
 		// Config pages
73 73
 		$this->config_page_url = array("product.php@product");
74
-		$this->langfiles = array("products","companies","bills");
74
+		$this->langfiles = array("products", "companies", "bills");
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array();
78 78
 
79 79
 		// Boxes
80 80
 		$this->boxes = array(
81
-			0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'),
82
-			1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home')
81
+			0=>array('file'=>'box_services_contracts.php', 'enabledbydefaulton'=>'Home'),
82
+			1=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home')
83 83
 		);
84 84
 
85 85
 		// Permissions
86 86
 		$this->rights = array();
87 87
 		$this->rights_class = 'service';
88
-		$r=0;
88
+		$r = 0;
89 89
 
90 90
 		$this->rights[$r][0] = 531; // id de la permission
91 91
 		$this->rights[$r][1] = 'Read services'; // libelle de la permission
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$this->rights[$r][4] = 'supprimer';
109 109
         $r++;
110 110
 
111
-		$this->rights[$r][0] = 538;	// Must be same permission than in product module
111
+		$this->rights[$r][0] = 538; // Must be same permission than in product module
112 112
 		$this->rights[$r][1] = 'Export services';
113 113
 		$this->rights[$r][2] = 'r';
114 114
 		$this->rights[$r][3] = 0;
@@ -134,85 +134,85 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Menus
136 136
 		//-------
137
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
137
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
138 138
 
139 139
 
140 140
         // Exports
141 141
 		//--------
142
-		$r=0;
142
+		$r = 0;
143 143
 
144 144
 		$r++;
145
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
146
-		$this->export_label[$r]="Services";	// Translation key (used only if key ExportDataset_xxx_z not found)
147
-		$this->export_permission[$r]=array(array("service","export"));
148
-		$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
149
-		if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
150
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
145
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
146
+		$this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found)
147
+		$this->export_permission[$r] = array(array("service", "export"));
148
+		$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification');
149
+		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock'));
150
+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
151 151
 		//$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
152
-		$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
153
-		if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
154
-		if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
155
-		$this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
156
-		if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
157
-		if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
152
+		$this->export_TypeFields_array[$r] = array('p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.note'=>"Text", 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date');
153
+		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric'));
154
+		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
155
+		$this->export_entities_array[$r] = array('p.rowid'=>"service", 'p.ref'=>"service", 'p.label'=>"service", 'p.description'=>"service", 'p.accountancy_code_sell'=>'service', 'p.note'=>"service", 'p.price_base_type'=>"service", 'p.price'=>"service", 'p.price_ttc'=>"service", 'p.tva_tx'=>"service", 'p.tosell'=>"service", 'p.tobuy'=>"service", 'p.duration'=>"service", 'p.datec'=>"service", 'p.tms'=>"service");
156
+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'service'));
157
+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'service'));
158 158
 		// Add extra fields
159
-		$sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
-		$resql=$this->db->query($sql);
159
+		$sql = "SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
+		$resql = $this->db->query($sql);
161 161
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
162 162
 		{
163
-		    while ($obj=$this->db->fetch_object($resql))
163
+		    while ($obj = $this->db->fetch_object($resql))
164 164
 		    {
165
-		        $fieldname='extra.'.$obj->name;
166
-		        $fieldlabel=ucfirst($obj->label);
167
-		    	$typeFilter="Text";
168
-				switch($obj->type)
165
+		        $fieldname = 'extra.'.$obj->name;
166
+		        $fieldlabel = ucfirst($obj->label);
167
+		    	$typeFilter = "Text";
168
+				switch ($obj->type)
169 169
 				{
170 170
 					case 'int':
171 171
 					case 'double':
172 172
 					case 'price':
173
-						$typeFilter="Numeric";
173
+						$typeFilter = "Numeric";
174 174
 						break;
175 175
 					case 'date':
176 176
 					case 'datetime':
177
-						$typeFilter="Date";
177
+						$typeFilter = "Date";
178 178
 						break;
179 179
 					case 'boolean':
180
-						$typeFilter="Boolean";
180
+						$typeFilter = "Boolean";
181 181
 						break;
182 182
 					case 'sellist':
183
-						$tmp='';
184
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
186
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
183
+						$tmp = '';
184
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
186
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
187 187
 						break;
188 188
 				}
189
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
190
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
191
-				$this->export_entities_array[$r][$fieldname]='product';
189
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
190
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
191
+				$this->export_entities_array[$r][$fieldname] = 'product';
192 192
 		    }
193 193
 		}
194 194
 		// End add extra fields
195 195
 
196
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
198
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
-		if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
200
-        $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
196
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
197
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
198
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
+		if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
200
+        $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
201 201
 
202 202
 
203 203
 		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
204 204
 		{
205
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
205
+			if (!empty($conf->global->PRODUIT_MULTIPRICES))
206 206
 			{
207 207
 				// Exports product multiprice
208 208
 				$r++;
209
-				$this->export_code[$r]=$this->rights_class.'_'.$r;
210
-				$this->export_label[$r]="ProductsMultiPrice";	// Translation key (used only if key ExportDataset_xxx_z not found)
211
-				$this->export_permission[$r]=array(array("produit","export"));
212
-				$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",
213
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
214
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
209
+				$this->export_code[$r] = $this->rights_class.'_'.$r;
210
+				$this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found)
211
+				$this->export_permission[$r] = array(array("produit", "export"));
212
+				$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",
213
+					'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel",
214
+					'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
+					'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
216 216
 					'pr.tva_tx'=>'PriceLevelVATRate',
217 217
 					'pr.date_price'=>'DateCreation');
218 218
 				//$this->export_TypeFields_array[$r]=array(
@@ -221,135 +221,135 @@  discard block
 block discarded – undo
221 221
 				//	'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
222 222
 				//	'p.datec'=>'Date','p.tms'=>'Date'
223 223
 				//);
224
-				$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",
225
-					'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product",
224
+				$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
225
+					'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product",
226 226
 					'pr.price_ttc'=>"product",
227
-					'pr.price_min'=>"product",'pr.price_min_ttc'=>"product",
227
+					'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",
228 228
 					'pr.tva_tx'=>'product',
229 229
 					'pr.date_price'=>"product");
230
-				$this->export_sql_start[$r]='SELECT DISTINCT ';
231
-				$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
232
-				$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
-				$this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
230
+				$this->export_sql_start[$r] = 'SELECT DISTINCT ';
231
+				$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
232
+				$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
+				$this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
234 234
 			}
235 235
 		}
236 236
 
237 237
 
238 238
 		// Imports
239 239
 		//--------
240
-		$r=0;
240
+		$r = 0;
241 241
 
242 242
 		$r++;
243
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
244
-		$this->import_label[$r]="Products";	// Translation key
245
-		$this->import_icon[$r]=$this->picto;
246
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
247
-		$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
-		$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author');	// Fields to store import user id
249
-        $this->import_fields_array[$r]=array(
250
-			'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
-			'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",
252
-			'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",
253
-			'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
243
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
244
+		$this->import_label[$r] = "Products"; // Translation key
245
+		$this->import_icon[$r] = $this->picto;
246
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
247
+		$this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
+		$this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id
249
+        $this->import_fields_array[$r] = array(
250
+			'p.ref'=>"Ref*", 'p.label'=>"Label*", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
+			'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume",
252
+			'p.weight'=>"Weight", 'p.duration'=>"Duration", 'p.customcode'=>'CustomCode', 'p.price'=>"SellingPriceHT", 'p.price_ttc'=>"SellingPriceTTC",
253
+			'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell*", 'p.tobuy'=>"OnBuy*", 'p.fk_product_type'=>"Type*", 'p.finished'=>'Nature', 'p.datec'=>'DateCreation'
254 254
 		);
255
-		if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
256
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
255
+		if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));
256
+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
257 257
         // Add extra fields
258
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
-		$resql=$this->db->query($sql);
258
+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
+		$resql = $this->db->query($sql);
260 260
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
261 261
 		{
262
-		    while ($obj=$this->db->fetch_object($resql))
262
+		    while ($obj = $this->db->fetch_object($resql))
263 263
 		    {
264
-		        $fieldname='extra.'.$obj->name;
265
-		        $fieldlabel=ucfirst($obj->label);
266
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
264
+		        $fieldname = 'extra.'.$obj->name;
265
+		        $fieldlabel = ucfirst($obj->label);
266
+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
267 267
 		    }
268 268
 		}
269 269
 		// End add extra fields
270
-		$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
-		$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
-		$this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
270
+		$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
+		$this->import_regex_array[$r] = array('p.ref'=>'[^ ]', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
+		$this->import_examplevalues_array[$r] = array('p.ref'=>"PREF123456", 'p.label'=>"My product", 'p.description'=>"This is a description example for record", 'p.note'=>"Some note", 'p.price'=>"100", 'p.price_ttc'=>"110", 'p.tva_tx'=>'10', 'p.tosell'=>"0 or 1", 'p.tobuy'=>"0 or 1", 'p.fk_product_type'=>"0 for product/1 for service", 'p.finished'=>'', 'p.duration'=>"1y", 'p.datec'=>'2008-12-31');
273 273
 
274 274
 
275 275
 		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
276 276
 		{
277
-			if (! empty($conf->fournisseur->enabled))
277
+			if (!empty($conf->fournisseur->enabled))
278 278
 			{
279 279
 				// Import suppliers prices (note: this code is duplicated into module product)
280 280
 				$r++;
281
-				$this->import_code[$r]=$this->rights_class.'_supplierprices';
282
-				$this->import_label[$r]="SuppliersPricesOfProductsOrServices";	// Translation key
283
-				$this->import_icon[$r]=$this->picto;
284
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
285
-				$this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
-				$this->import_tables_creator_array[$r]=array('sp'=>'fk_user');
287
-				$this->import_fields_array[$r]=array(
281
+				$this->import_code[$r] = $this->rights_class.'_supplierprices';
282
+				$this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key
283
+				$this->import_icon[$r] = $this->picto;
284
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
285
+				$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
+				$this->import_tables_creator_array[$r] = array('sp'=>'fk_user');
287
+				$this->import_fields_array[$r] = array(
288 288
 					'sp.fk_product'=>"ProductOrService*",
289 289
 					'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode'
290 290
 				);
291
-				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
292
-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
-				$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array(
291
+				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
292
+				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
+				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
+				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
295 295
 					'sp.price'=>"PriceQtyMinHT*",
296
-					'sp.unitprice'=>'UnitPriceHT*',	// TODO Make this field not required and calculate it from price and qty
296
+					'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
297 297
 					'sp.remise_percent'=>'DiscountQtyMin'
298 298
 				));
299 299
 
300
-				$this->import_convertvalue_array[$r]=array(
301
-						'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
302
-						'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
300
+				$this->import_convertvalue_array[$r] = array(
301
+						'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
302
+						'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
303 303
 				);
304
-				$this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456",
305
-						'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
304
+				$this->import_examplevalues_array[$r] = array('sp.fk_product'=>"PREF123456",
305
+						'sp.fk_soc'=>"My Supplier", 'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
306 306
 						'sp.price'=>"50",
307 307
 						'sp.unitprice'=>'50',
308 308
 						'sp.remise_percent'=>'0'
309 309
 				);
310 310
 			}
311 311
 
312
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
312
+			if (!empty($conf->global->PRODUIT_MULTIPRICES))
313 313
 			{
314 314
 				// Import product multiprice
315 315
 				$r++;
316
-				$this->import_code[$r]=$this->rights_class.'_multiprice';
317
-				$this->import_label[$r]="ProductsOrServiceMultiPrice";	// Translation key
318
-				$this->import_icon[$r]=$this->picto;
319
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
320
-				$this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price');
321
-				$this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author');	// Fields to store import user id
322
-				$this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*",
323
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
324
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
316
+				$this->import_code[$r] = $this->rights_class.'_multiprice';
317
+				$this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key
318
+				$this->import_icon[$r] = $this->picto;
319
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
320
+				$this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price');
321
+				$this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id
322
+				$this->import_fields_array[$r] = array('pr.fk_product'=>"ProductRowid*",
323
+					'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel",
324
+					'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
+					'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
326 326
 					'pr.tva_tx'=>'PriceLevelVATRate',
327 327
 					'pr.date_price'=>'DateCreation*');
328
-				$this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
-				$this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1",
330
-					'pr.price_base_type'=>"HT",'pr.price_level'=>"1",
331
-					'pr.price'=>"100",'pr.price_ttc'=>"110",
332
-					'pr.price_min'=>"100",'pr.price_min_ttc'=>"110",
328
+				$this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
+				$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"1",
330
+					'pr.price_base_type'=>"HT", 'pr.price_level'=>"1",
331
+					'pr.price'=>"100", 'pr.price_ttc'=>"110",
332
+					'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
333 333
 					'pr.tva_tx'=>'19.6',
334 334
 					'pr.date_price'=>'2013-04-10');
335 335
 			}
336 336
 
337
-			if (! empty($conf->global->MAIN_MULTILANGS))
337
+			if (!empty($conf->global->MAIN_MULTILANGS))
338 338
 			{
339 339
 				$r++;
340
-				$this->import_code[$r]=$this->rights_class.'_languages';
341
-				$this->import_label[$r]="ProductsOrServicesTranslations";
342
-				$this->import_icon[$r]=$this->picto;
343
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
344
-				$this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
340
+				$this->import_code[$r] = $this->rights_class.'_languages';
341
+				$this->import_label[$r] = "ProductsOrServicesTranslations";
342
+				$this->import_icon[$r] = $this->picto;
343
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
344
+				$this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');
345 345
 				// multiline translation, one line per translation
346
-				$this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
346
+				$this->import_fields_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
347 347
 				//$this->import_fields_array[$r]['l.note']='TranslatedNote';
348
-				$this->import_convertvalue_array[$r]=array(
349
-				'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
348
+				$this->import_convertvalue_array[$r] = array(
349
+				'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
350 350
 				);
351
-				$this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
352
-				$this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
351
+				$this->import_examplevalues_array[$r] = array('l.fk_product'=>'MyProductRef', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');
352
+				$this->import_updatekeys_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language');
353 353
 			}
354 354
 		}
355 355
 	}
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
364 364
 	 *      @return     int             	1 if OK, 0 if KO
365 365
 	 */
366
-	function init($options='')
366
+	function init($options = '')
367 367
 	{
368 368
 		$this->remove($options);
369 369
 
370 370
 		$sql = array();
371 371
 
372
-		return $this->_init($sql,$options);
372
+		return $this->_init($sql, $options);
373 373
 	}
374 374
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modECM.class.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \brief      Description and activation file for module ECM
24 24
  */
25 25
 
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 
29 29
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->family = "ecm";
51 51
 		$this->module_position = '10';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55 55
 		$this->description = "Electronic Content Management";
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		// Name of png file (without png) used for this module
61
-		$this->picto='dir';
61
+		$this->picto = 'dir';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array("/ecm/temp");
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 		$this->config_page_url = array('ecm.php');
68 68
 
69 69
 		// Dependencies
70
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
71
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
70
+		$this->depends = array(); // List of modules id that must be enabled if this module is enabled
71
+		$this->requiredby = array(); // List of modules id to disable if this one is disabled
72 72
 
73 73
 		// Constants
74
-		$this->const = array();			// List of parameters
75
-		$r=0;
74
+		$this->const = array(); // List of parameters
75
+		$r = 0;
76 76
 
77 77
 		$this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";
78 78
 		$this->const[$r][1] = "chaine";
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 		$this->const[$r][4] = 0;
82 82
 
83 83
 		// Boxes
84
-		$this->boxes = array();			// List of boxes
85
-		$r=0;
84
+		$this->boxes = array(); // List of boxes
85
+		$r = 0;
86 86
 
87 87
 		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
88 88
 		// Example:
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     	//$r++;
93 93
 
94 94
 		// Permissions
95
-		$this->rights_class = 'ecm';	// Permission key
96
-		$this->rights = array();		// Permission array used by this module
95
+		$this->rights_class = 'ecm'; // Permission key
96
+		$this->rights = array(); // Permission array used by this module
97 97
 
98 98
 		$r++;
99 99
 		$this->rights[$r][0] = 2501;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
         // Menus
121 121
 		//------
122
-		$this->menus = array();			// List of menus to add
123
-		$r=0;
122
+		$this->menus = array(); // List of menus to add
123
+		$r = 0;
124 124
 
125 125
 		// Top menu
126
-		$this->menu[$r]=array('fk_menu'=>0,
126
+		$this->menu[$r] = array('fk_menu'=>0,
127 127
 							  'type'=>'top',
128 128
 							  'titre'=>'MenuECM',
129 129
 							  'mainmenu'=>'ecm',
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',
134 134
 							  'enabled'=>'$conf->ecm->enabled',
135 135
 							  'target'=>'',
136
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
136
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
137 137
 		$r++;
138 138
 
139 139
 		// Left menu linked to top menu
140
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm',
140
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm',
141 141
 							  'type'=>'left',
142 142
 							  'titre'=>'ECMArea',
143 143
 							  'mainmenu'=>'ecm',
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
149 149
 							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
150 150
 							  'target'=>'',
151
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
151
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
152 152
 		$r++;
153 153
 
154
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
154
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
155 155
 							  'type'=>'left',
156 156
 							  'titre'=>'ECMSectionsManual',
157 157
 							  'mainmenu'=>'ecm',
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
163 163
 							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
164 164
 							  'target'=>'',
165
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
165
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
166 166
 		$r++;
167 167
 
168
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
168
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
169 169
 							  'type'=>'left',
170 170
 							  'titre'=>'ECMSectionsAuto',
171 171
 							  'mainmenu'=>'ecm',
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
176 176
 							  'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)',
177 177
 							  'target'=>'',
178
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
178
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
179 179
 		$r++;
180 180
 	}
181 181
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/reception/doc/pdf_squille.modules.php 1 patch
Spacing   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class pdf_squille extends ModelePdfReception
34 34
 {
35
-	var $emetteur;	// Objet societe qui emet
35
+	var $emetteur; // Objet societe qui emet
36 36
 
37 37
 
38 38
 	/**
@@ -40,57 +40,57 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 *	@param	DoliDB	$db		Database handler
42 42
 	 */
43
-	function __construct($db=0)
43
+	function __construct($db = 0)
44 44
 	{
45
-		global $conf,$langs,$mysoc;
45
+		global $conf, $langs, $mysoc;
46 46
 
47 47
 		$this->db = $db;
48 48
 		$this->name = "squille";
49 49
 		$this->description = $langs->trans("DocumentModelStandardPDF");
50 50
 
51 51
 		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
52
+		$formatarray = pdf_getFormat();
53 53
 		$this->page_largeur = $formatarray['width'];
54 54
 		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
55
+		$this->format = array($this->page_largeur, $this->page_hauteur);
56
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
57
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
58
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
59
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
60 60
 
61 61
 		$this->option_logo = 1;
62 62
 
63 63
 		// Get source company
64
-		$this->emetteur=$mysoc;
65
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
64
+		$this->emetteur = $mysoc;
65
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
66 66
 
67 67
 		// Define position of columns
68
-		$this->posxdesc=$this->marge_gauche+1;
69
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
70
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
71
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
72
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
68
+		$this->posxdesc = $this->marge_gauche + 1;
69
+		$this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
70
+		$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
71
+		$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
72
+		$this->posxpuht = $this->page_largeur - $this->marge_droite;
73 73
 
74 74
 		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
75 75
 
76
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
77
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
78
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
79
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
80
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
76
+			$this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
77
+			$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
78
+			$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
79
+			$this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
80
+			$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
81 81
 		}
82 82
 
83
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
83
+		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
84 84
 
85 85
 		if ($this->page_largeur < 210) // To work with US executive format
86 86
 		{
87
-		    $this->posxweightvol-=20;
88
-		    $this->posxpicture-=20;
89
-		    $this->posxqtyordered-=20;
90
-		    $this->posxqtytoship-=20;
87
+		    $this->posxweightvol -= 20;
88
+		    $this->posxpicture -= 20;
89
+		    $this->posxqtyordered -= 20;
90
+		    $this->posxqtytoship -= 20;
91 91
 		}
92 92
 
93
-		if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
93
+		if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
94 94
 		{
95 95
 		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
96 96
 		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
      *  @param		int			$hideref			Do not show ref
111 111
      *  @return     int         	    			1=OK, 0=KO
112 112
 	 */
113
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
113
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
114 114
 	{
115 115
 		// phpcs:enable
116
-		global $user,$conf,$langs,$hookmanager;
116
+		global $user, $conf, $langs, $hookmanager;
117 117
 
118 118
 		$object->fetch_thirdparty();
119 119
 
120
-		if (! is_object($outputlangs)) $outputlangs=$langs;
120
+		if (!is_object($outputlangs)) $outputlangs = $langs;
121 121
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
122
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
122
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
123 123
 
124 124
 		$outputlangs->load("main");
125 125
 		$outputlangs->load("dict");
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 		$nblignes = count($object->lines);
135 135
 
136 136
         // Loop on each lines to detect if there is at least one image to show
137
-        $realpatharray=array();
138
-        if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
137
+        $realpatharray = array();
138
+        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
139 139
         {
140 140
             $objphoto = new Product($this->db);
141 141
 
142
-            for ($i = 0 ; $i < $nblignes ; $i++)
142
+            for ($i = 0; $i < $nblignes; $i++)
143 143
             {
144 144
                 if (empty($object->lines[$i]->fk_product)) continue;
145 145
 
146 146
 				$objphoto = new Product($this->db);
147 147
 				$objphoto->fetch($object->lines[$i]->fk_product);
148 148
 
149
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
149
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
150 150
 				$dir = $conf->product->dir_output.'/'.$pdir;
151 151
 
152
-				$realpath='';
152
+				$realpath = '';
153 153
 
154
-                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
154
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
155 155
                         {
156 156
                             if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
157 157
                             {
158 158
                                 if ($obj['photo_vignette'])
159 159
                                 {
160
-                                    $filename= $obj['photo_vignette'];
160
+                                    $filename = $obj['photo_vignette'];
161 161
                                 }
162 162
                                 else
163 163
                                 {
164
-                                    $filename=$obj['photo'];
164
+                                    $filename = $obj['photo'];
165 165
                                 }
166 166
                             }
167 167
                             else
168 168
                             {
169
-                                $filename=$obj['photo'];
169
+                                $filename = $obj['photo'];
170 170
                             }
171 171
 
172 172
                             $realpath = $dir.$filename;
173 173
                             break;
174 174
                 }
175 175
 
176
-                if ($realpath) $realpatharray[$i]=$realpath;
176
+                if ($realpath) $realpatharray[$i] = $realpath;
177 177
             }
178 178
         }
179 179
 
180
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
180
+        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
181 181
 
182 182
 		if ($conf->reception->dir_output)
183 183
 		{
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 			if ($object->specimen)
186 186
 			{
187 187
 				$dir = $conf->reception->dir_output;
188
-				$file = $dir . "/SPECIMEN.pdf";
188
+				$file = $dir."/SPECIMEN.pdf";
189 189
 			}
190 190
 			else
191 191
 			{
192 192
 				$rcpref = dol_sanitizeFileName($object->ref);
193
-				$dir = $conf->reception->dir_output."/" . $rcpref;
194
-				$file = $dir . "/" . $rcpref . ".pdf";
193
+				$dir = $conf->reception->dir_output."/".$rcpref;
194
+				$file = $dir."/".$rcpref.".pdf";
195 195
 			}
196 196
 
197
-			if (! file_exists($dir))
197
+			if (!file_exists($dir))
198 198
 			{
199 199
 				if (dol_mkdir($dir) < 0)
200 200
 				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
201
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
202 202
 					return 0;
203 203
 				}
204 204
 			}
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
 			if (file_exists($dir))
207 207
 			{
208 208
 				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
209
+				if (!is_object($hookmanager))
210 210
 				{
211 211
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
212
+					$hookmanager = new HookManager($this->db);
213 213
 				}
214 214
 				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
216 216
 				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
218 218
 
219 219
 				// Set nblignes with the new facture lines content after hook
220 220
 				$nblignes = count($object->lines);
221 221
 
222
-				$pdf=pdf_getInstance($this->format);
222
+				$pdf = pdf_getInstance($this->format);
223 223
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
224
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
225
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
226
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-                $pdf->SetAutoPageBreak(1,0);
224
+				$heightforinfotot = 8; // Height reserved to output the info and total part
225
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
226
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
227
+                $pdf->SetAutoPageBreak(1, 0);
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -233,38 +233,38 @@  discard block
 block discarded – undo
233 233
                 }
234 234
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
235 235
                 // Set path to the background PDF File
236
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237 237
                 {
238 238
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239 239
                     $tplidx = $pdf->importPage(1);
240 240
                 }
241 241
 
242 242
 				$pdf->Open();
243
-				$pagenb=0;
244
-				$pdf->SetDrawColor(128,128,128);
243
+				$pagenb = 0;
244
+				$pdf->SetDrawColor(128, 128, 128);
245 245
 
246
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
246
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
247 247
 
248 248
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
249 249
 				$pdf->SetSubject($outputlangs->transnoentities("Reception"));
250 250
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
251 251
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
252 252
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
253
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
253
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
254 254
 
255
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
255
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
256 256
 
257 257
 				// New page
258 258
 				$pdf->AddPage();
259
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
259
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
260 260
 				$pagenb++;
261 261
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
262
-				$pdf->SetFont('','', $default_font_size - 1);
263
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
264
-				$pdf->SetTextColor(0,0,0);
262
+				$pdf->SetFont('', '', $default_font_size - 1);
263
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
264
+				$pdf->SetTextColor(0, 0, 0);
265 265
 
266 266
 				$tab_top = 90;
267
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
267
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
268 268
 				$tab_height = 130;
269 269
 				$tab_height_newpage = 150;
270 270
 
@@ -277,52 +277,52 @@  discard block
 block discarded – undo
277 277
 					{
278 278
 						$tab_top = 88;
279 279
 
280
-						$pdf->SetFont('','', $default_font_size - 1);
281
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
280
+						$pdf->SetFont('', '', $default_font_size - 1);
281
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
282 282
 						$nexY = $pdf->GetY();
283
-						$height_incoterms=$nexY-$tab_top;
283
+						$height_incoterms = $nexY - $tab_top;
284 284
 
285 285
 						// Rect prend une longueur en 3eme param
286
-						$pdf->SetDrawColor(192,192,192);
287
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
286
+						$pdf->SetDrawColor(192, 192, 192);
287
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
288 288
 
289
-						$tab_top = $nexY+6;
289
+						$tab_top = $nexY + 6;
290 290
 						$height_incoterms += 4;
291 291
 					}
292 292
 				}
293 293
 
294
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
294
+				if (!empty($object->note_public) || !empty($object->tracking_number))
295 295
 				{
296 296
 					$tab_top = 88 + $height_incoterms;
297 297
 					$tab_top_alt = $tab_top;
298 298
 
299
-					$pdf->SetFont('','B', $default_font_size - 2);
300
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
299
+					$pdf->SetFont('', 'B', $default_font_size - 2);
300
+					$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
301 301
 
302 302
 					$tab_top_alt = $pdf->GetY();
303 303
 					//$tab_top_alt += 1;
304 304
 
305 305
 					// Tracking number
306
-					if (! empty($object->tracking_number))
306
+					if (!empty($object->tracking_number))
307 307
 					{
308 308
 						$object->getUrlTrackingStatus($object->tracking_number);
309
-						if (! empty($object->tracking_url))
309
+						if (!empty($object->tracking_url))
310 310
 						{
311 311
 							if ($object->reception_method_id > 0)
312 312
 							{
313 313
 								// Get code using getLabelFromKey
314
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code');
315
-								$label='';
316
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
-								$label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
314
+								$code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code');
315
+								$label = '';
316
+								if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
+								$label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
318 318
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
319 319
 								if ($object->tracking_url != $object->tracking_number)
320 320
 								{
321
-									$label.=" : ";
322
-									$label.=$object->tracking_url;
321
+									$label .= " : ";
322
+									$label .= $object->tracking_url;
323 323
 								}
324
-								$pdf->SetFont('','B', $default_font_size - 2);
325
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
324
+								$pdf->SetFont('', 'B', $default_font_size - 2);
325
+								$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
326 326
 
327 327
 								$tab_top_alt = $pdf->GetY();
328 328
 							}
@@ -330,118 +330,118 @@  discard block
 block discarded – undo
330 330
 					}
331 331
 
332 332
 					// Notes
333
-					if (! empty($object->note_public))
333
+					if (!empty($object->note_public))
334 334
 					{
335
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
336
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
335
+						$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
336
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
337 337
 					}
338 338
 
339 339
 					$nexY = $pdf->GetY();
340
-					$height_note=$nexY-$tab_top;
340
+					$height_note = $nexY - $tab_top;
341 341
 
342 342
 					// Rect prend une longueur en 3eme param
343
-					$pdf->SetDrawColor(192,192,192);
344
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
343
+					$pdf->SetDrawColor(192, 192, 192);
344
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
345 345
 
346 346
 					$tab_height = $tab_height - $height_note;
347
-					$tab_top = $nexY+6;
347
+					$tab_top = $nexY + 6;
348 348
 				}
349 349
 				else
350 350
 				{
351
-					$height_note=0;
351
+					$height_note = 0;
352 352
 				}
353 353
 
354 354
 				$iniY = $tab_top + 7;
355 355
 				$curY = $tab_top + 7;
356 356
 				$nexY = $tab_top + 7;
357
-				$fk_commandefourndet=0;
358
-				$totalOrdered=0;
357
+				$fk_commandefourndet = 0;
358
+				$totalOrdered = 0;
359 359
 				// Loop on each lines
360 360
 				for ($i = 0; $i < $nblignes; $i++)
361 361
 				{
362 362
 					$curY = $nexY;
363
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
364
-					$pdf->SetTextColor(0,0,0);
363
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
364
+					$pdf->SetTextColor(0, 0, 0);
365 365
 
366 366
 					// Define size of image if we need it
367
-					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
367
+					$imglinesize = array();
368
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
369 369
 
370 370
 					$pdf->setTopMargin($tab_top_newpage);
371
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
372
-					$pageposbefore=$pdf->getPage();
371
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
372
+					$pageposbefore = $pdf->getPage();
373 373
 
374
-					$showpricebeforepagebreak=1;
375
-					$posYAfterImage=0;
376
-					$posYAfterDescription=0;
374
+					$showpricebeforepagebreak = 1;
375
+					$posYAfterImage = 0;
376
+					$posYAfterDescription = 0;
377 377
 
378 378
 					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
379
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
380 380
 					{
381
-						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
+						$pdf->AddPage('', '', true);
382
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
383 383
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
384
-						$pdf->setPage($pageposbefore+1);
384
+						$pdf->setPage($pageposbefore + 1);
385 385
 
386 386
 						$curY = $tab_top_newpage;
387
-						$showpricebeforepagebreak=0;
387
+						$showpricebeforepagebreak = 0;
388 388
 					}
389 389
 
390 390
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
391 391
 					{
392
-						$curX = $this->posxpicture-1;
393
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
392
+						$curX = $this->posxpicture - 1;
393
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
394 394
 						// $pdf->Image does not increase value return by getY, so we save it manually
395
-						$posYAfterImage=$curY+$imglinesize['height'];
395
+						$posYAfterImage = $curY + $imglinesize['height'];
396 396
 					}
397 397
 
398 398
 					// Description of product line
399
-					$curX = $this->posxdesc-1;
399
+					$curX = $this->posxdesc - 1;
400 400
 
401 401
 					$pdf->startTransaction();
402
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
402
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
403 403
 
404
-					$pageposafter=$pdf->getPage();
404
+					$pageposafter = $pdf->getPage();
405 405
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
406 406
 					{
407 407
 						$pdf->rollbackTransaction(true);
408
-						$pageposafter=$pageposbefore;
408
+						$pageposafter = $pageposbefore;
409 409
 						//print $pageposafter.'-'.$pageposbefore;exit;
410
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
410
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
411 411
 
412
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
412
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
413 413
 
414
-						$pageposafter=$pdf->getPage();
415
-						$posyafter=$pdf->GetY();
414
+						$pageposafter = $pdf->getPage();
415
+						$posyafter = $pdf->GetY();
416 416
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
417
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
417
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
418 418
 						{
419
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
419
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
420 420
 							{
421
-								$pdf->AddPage('','',true);
422
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
421
+								$pdf->AddPage('', '', true);
422
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
423 423
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424
-								$pdf->setPage($pageposafter+1);
424
+								$pdf->setPage($pageposafter + 1);
425 425
 							}
426 426
 						}
427 427
 						else
428 428
 						{
429 429
 							// We found a page break
430
-							$showpricebeforepagebreak=0;
430
+							$showpricebeforepagebreak = 0;
431 431
 						}
432 432
 					}
433 433
 					else	// No pagebreak
434 434
 					{
435 435
 						$pdf->commitTransaction();
436 436
 					}
437
-					$posYAfterDescription=$pdf->GetY();
437
+					$posYAfterDescription = $pdf->GetY();
438 438
 
439 439
 					$nexY = $pdf->GetY();
440
-					$pageposafter=$pdf->getPage();
440
+					$pageposafter = $pdf->getPage();
441 441
 
442 442
 					$pdf->setPage($pageposbefore);
443 443
 					$pdf->setTopMargin($this->marge_haute);
444
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
444
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
445 445
 
446 446
 					// We suppose that a too long description or photo were moved completely on next page
447 447
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -453,55 +453,55 @@  discard block
 block discarded – undo
453 453
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
454 454
 					}
455 455
 
456
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
456
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
457 457
 
458 458
 					$pdf->SetXY($this->posxweightvol, $curY);
459
-					$weighttxt='';
459
+					$weighttxt = '';
460 460
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight)
461 461
 					{
462
-					    $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight");
462
+					    $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units, "weight");
463 463
 					}
464
-					$voltxt='';
464
+					$voltxt = '';
465 465
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume)
466 466
 					{
467
-					    $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume");
467
+					    $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, "volume");
468 468
 					}
469 469
 
470
-					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
470
+					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
471 471
 					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
472 472
 
473 473
 					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
474 474
 					{
475 475
 					   $pdf->SetXY($this->posxqtyordered, $curY);
476
-					   if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
477
-						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
478
-						   $totalOrdered+=$object->lines[$i]->qty_asked;
476
+					   if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
477
+						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
478
+						   $totalOrdered += $object->lines[$i]->qty_asked;
479 479
 					   }
480 480
 					   $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
481 481
 					}
482 482
 
483 483
 					$pdf->SetXY($this->posxqtytoship, $curY);
484
-					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C');
484
+					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C');
485 485
 
486
-					if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
486
+					if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
487 487
 					{
488 488
 						$pdf->SetXY($this->posxpuht, $curY);
489
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
489
+						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
490 490
 
491 491
 						$pdf->SetXY($this->posxtotalht, $curY);
492
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
492
+						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
493 493
 					}
494 494
 
495
-					$nexY+=3;
496
-					if ($weighttxt && $voltxt) $nexY+=2;
495
+					$nexY += 3;
496
+					if ($weighttxt && $voltxt) $nexY += 2;
497 497
 
498 498
 					// Add line
499
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
499
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
500 500
 					{
501 501
 						$pdf->setPage($pageposafter);
502
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
502
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
503 503
 						//$pdf->SetDrawColor(190,190,200);
504
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
504
+						$pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
505 505
 						$pdf->SetLineStyle(array('dash'=>0));
506 506
 					}
507 507
 
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 						{
518 518
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
519 519
 						}
520
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
520
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
521 521
 						$pagenb++;
522 522
 						$pdf->setPage($pagenb);
523
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
523
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
524 524
 					}
525
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
525
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
526 526
 					{
527 527
 						if ($pagenb == 1)
528 528
 						{
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
 						{
533 533
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
534 534
 						}
535
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
535
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
536 536
 						// New page
537 537
 						$pdf->AddPage();
538
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
538
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
539 539
 						$pagenb++;
540 540
 					}
541 541
 				}
@@ -544,45 +544,45 @@  discard block
 block discarded – undo
544 544
 				if ($pagenb == 1)
545 545
 				{
546 546
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
547
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
547
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548 548
 				}
549 549
 				else
550 550
 				{
551 551
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
552
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
552
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
553 553
 				}
554 554
 
555 555
 				// Affiche zone totaux
556
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
556
+				$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
557 557
 
558 558
 				// Pied de page
559
-				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
559
+				$this->_pagefoot($pdf, $object, $outputlangs);
560
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
561 561
 
562 562
 				$pdf->Close();
563 563
 
564
-				$pdf->Output($file,'F');
564
+				$pdf->Output($file, 'F');
565 565
 
566 566
 				// Add pdfgeneration hook
567 567
 				$hookmanager->initHooks(array('pdfgeneration'));
568
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
568
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
569 569
 				global $action;
570
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
571 571
 
572
-				if (! empty($conf->global->MAIN_UMASK))
572
+				if (!empty($conf->global->MAIN_UMASK))
573 573
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
574 574
 
575
-				return 1;	// No error
575
+				return 1; // No error
576 576
 			}
577 577
 			else
578 578
 			{
579
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
579
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
580 580
 				return 0;
581 581
 			}
582 582
 		}
583 583
 		else
584 584
 		{
585
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
585
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
586 586
 			return 0;
587 587
 		}
588 588
 	}
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
603 603
 	{
604 604
 		// phpcs:enable
605
-		global $conf,$mysoc;
605
+		global $conf, $mysoc;
606 606
 
607
-        $sign=1;
607
+        $sign = 1;
608 608
 
609 609
         $default_font_size = pdf_getPDFFontSize($outputlangs);
610 610
 
611 611
 		$tab2_top = $posy;
612 612
 		$tab2_hl = 4;
613
-		$pdf->SetFont('','B', $default_font_size - 1);
613
+		$pdf->SetFont('', 'B', $default_font_size - 1);
614 614
 
615 615
 		// Tableau total
616
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
616
+		$col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
617 617
 		/*if ($this->page_largeur < 210) // To work with US executive format
618 618
 		{
619 619
 			$col2x-=20;
@@ -621,34 +621,34 @@  discard block
 block discarded – undo
621 621
 		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
622 622
 		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
623 623
 
624
-		$useborder=0;
624
+		$useborder = 0;
625 625
 		$index = 0;
626 626
 
627
-		$totalWeighttoshow='';
628
-		$totalVolumetoshow='';
627
+		$totalWeighttoshow = '';
628
+		$totalVolumetoshow = '';
629 629
 
630 630
 		// Load dim data
631
-		$tmparray=$object->getTotalWeightVolume();
632
-		$totalWeight=$tmparray['weight'];
633
-		$totalVolume=$tmparray['volume'];
634
-		$totalToShip=$tmparray['toship'];
631
+		$tmparray = $object->getTotalWeightVolume();
632
+		$totalWeight = $tmparray['weight'];
633
+		$totalVolume = $tmparray['volume'];
634
+		$totalToShip = $tmparray['toship'];
635 635
 
636 636
 
637 637
 		// Set trueVolume and volume_units not currently stored into database
638 638
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
639 639
 		{
640
-		    $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
-		    $object->volume_units=$object->size_units * 3;
640
+		    $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
+		    $object->volume_units = $object->size_units * 3;
642 642
 		}
643 643
 
644
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
644
+		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
+		if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
+		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
+		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
648 648
 
649
-    	$pdf->SetFillColor(255,255,255);
649
+    	$pdf->SetFillColor(255, 255, 255);
650 650
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
651
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
651
+    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
652 652
 
653 653
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
654 654
         {
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
660 660
     	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
661 661
 
662
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
662
+		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
663 663
 
664 664
 	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
665 665
 	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 
684 684
 		    $index++;
685 685
 		}
686
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
686
+		if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
687 687
 
688
-		$pdf->SetTextColor(0,0,0);
688
+		$pdf->SetTextColor(0, 0, 0);
689 689
 
690 690
 		return ($tab2_top + ($tab2_hl * $index));
691 691
 	}
@@ -702,72 +702,72 @@  discard block
 block discarded – undo
702 702
 	 *   @param		int			$hidebottom		Hide bottom bar of array
703 703
 	 *   @return	void
704 704
 	 */
705
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
705
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
706 706
 	{
707 707
 		global $conf;
708 708
 
709 709
 		// Force to disable hidetop and hidebottom
710
-		$hidebottom=0;
711
-		if ($hidetop) $hidetop=-1;
710
+		$hidebottom = 0;
711
+		if ($hidetop) $hidetop = -1;
712 712
 
713 713
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
714 714
 
715 715
 		// Amount in (at tab_top - 1)
716
-		$pdf->SetTextColor(0,0,0);
717
-		$pdf->SetFont('','',$default_font_size - 2);
716
+		$pdf->SetTextColor(0, 0, 0);
717
+		$pdf->SetFont('', '', $default_font_size - 2);
718 718
 
719 719
 		// Output Rect
720
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
720
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
721 721
 
722
-		$pdf->SetDrawColor(128,128,128);
723
-		$pdf->SetFont('','', $default_font_size - 1);
722
+		$pdf->SetDrawColor(128, 128, 128);
723
+		$pdf->SetFont('', '', $default_font_size - 1);
724 724
 
725 725
 		if (empty($hidetop))
726 726
 		{
727
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
727
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
728 728
 
729
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
729
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
730 730
 			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
731 731
 		}
732 732
 
733
-		$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
733
+		$pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
734 734
 		if (empty($hidetop))
735 735
 		{
736
-			$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
737
-			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
736
+			$pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
737
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
738 738
 		}
739 739
 
740 740
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
741 741
         {
742
-            $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
742
+            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
743 743
     		if (empty($hidetop))
744 744
     		{
745
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
746
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
745
+    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
746
+    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
747 747
     		}
748 748
         }
749 749
 
750
-		$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
750
+		$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
751 751
 		if (empty($hidetop))
752 752
 		{
753
-			$pdf->SetXY($this->posxqtytoship, $tab_top+1);
754
-			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C');
753
+			$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
754
+			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C');
755 755
 		}
756 756
 
757
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
757
+		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
758 758
 
759
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
759
+			$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
760 760
 			if (empty($hidetop))
761 761
 			{
762
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
763
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
762
+				$pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
763
+				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
764 764
 			}
765 765
 
766
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
766
+			$pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
767 767
 			if (empty($hidetop))
768 768
 			{
769
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
770
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
769
+				$pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
770
+				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
771 771
 			}
772 772
 		}
773 773
 	}
@@ -783,73 +783,73 @@  discard block
 block discarded – undo
783 783
 	 */
784 784
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
785 785
 	{
786
-		global $conf,$langs,$mysoc;
786
+		global $conf, $langs, $mysoc;
787 787
 
788 788
 		$langs->load("orders");
789 789
 
790 790
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
791 791
 
792
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
792
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
793 793
 
794 794
 		// Show Draft Watermark
795
-		if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) )
795
+		if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK)))
796 796
 		{
797
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK);
797
+            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
798 798
 		}
799 799
 
800 800
 		//Prepare la suite
801
-		$pdf->SetTextColor(0,0,60);
802
-		$pdf->SetFont('','B', $default_font_size + 3);
801
+		$pdf->SetTextColor(0, 0, 60);
802
+		$pdf->SetFont('', 'B', $default_font_size + 3);
803 803
 
804 804
 		$w = 110;
805 805
 
806
-		$posy=$this->marge_haute;
807
-		$posx=$this->page_largeur-$this->marge_droite-$w;
806
+		$posy = $this->marge_haute;
807
+		$posx = $this->page_largeur - $this->marge_droite - $w;
808 808
 
809
-		$pdf->SetXY($this->marge_gauche,$posy);
809
+		$pdf->SetXY($this->marge_gauche, $posy);
810 810
 
811 811
 		// Logo
812
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
812
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
813 813
 		if ($this->emetteur->logo)
814 814
 		{
815 815
 			if (is_readable($logo))
816 816
 			{
817
-			    $height=pdf_getHeightForLogo($logo);
818
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
817
+			    $height = pdf_getHeightForLogo($logo);
818
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
819 819
 			}
820 820
 			else
821 821
 			{
822
-				$pdf->SetTextColor(200,0,0);
823
-				$pdf->SetFont('','B', $default_font_size - 2);
824
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
822
+				$pdf->SetTextColor(200, 0, 0);
823
+				$pdf->SetFont('', 'B', $default_font_size - 2);
824
+				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
825 825
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
826 826
 			}
827 827
 		}
828 828
 		else
829 829
 		{
830
-			$text=$this->emetteur->name;
830
+			$text = $this->emetteur->name;
831 831
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
832 832
 		}
833 833
 
834 834
 		// Show barcode
835
-		if (! empty($conf->barcode->enabled))
835
+		if (!empty($conf->barcode->enabled))
836 836
 		{
837
-			$posx=105;
837
+			$posx = 105;
838 838
 		}
839 839
 		else
840 840
 		{
841
-			$posx=$this->marge_gauche+3;
841
+			$posx = $this->marge_gauche + 3;
842 842
 		}
843 843
 		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
844
-		if (! empty($conf->barcode->enabled))
844
+		if (!empty($conf->barcode->enabled))
845 845
 		{
846 846
 			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
847 847
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
848 848
 			//$pdf->Image($logo,10, 5, 0, 24);
849 849
 		}
850 850
 
851
-		$pdf->SetDrawColor(128,128,128);
852
-		if (! empty($conf->barcode->enabled))
851
+		$pdf->SetDrawColor(128, 128, 128);
852
+		if (!empty($conf->barcode->enabled))
853 853
 		{
854 854
 			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
855 855
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@@ -857,115 +857,115 @@  discard block
 block discarded – undo
857 857
 		}
858 858
 
859 859
 
860
-		$posx=$this->page_largeur - $w - $this->marge_droite;
861
-		$posy=$this->marge_haute;
860
+		$posx = $this->page_largeur - $w - $this->marge_droite;
861
+		$posy = $this->marge_haute;
862 862
 
863
-		$pdf->SetFont('','B', $default_font_size + 2);
864
-		$pdf->SetXY($posx,$posy);
865
-		$pdf->SetTextColor(0,0,60);
866
-		$title=$outputlangs->transnoentities("ReceptionSheet");
863
+		$pdf->SetFont('', 'B', $default_font_size + 2);
864
+		$pdf->SetXY($posx, $posy);
865
+		$pdf->SetTextColor(0, 0, 60);
866
+		$title = $outputlangs->transnoentities("ReceptionSheet");
867 867
 		$pdf->MultiCell($w, 4, $title, '', 'R');
868 868
 
869
-		$pdf->SetFont('','', $default_font_size + 1);
869
+		$pdf->SetFont('', '', $default_font_size + 1);
870 870
 
871
-		$posy+=5;
871
+		$posy += 5;
872 872
 
873
-		$pdf->SetXY($posx,$posy);
874
-		$pdf->SetTextColor(0,0,60);
875
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R');
873
+		$pdf->SetXY($posx, $posy);
874
+		$pdf->SetTextColor(0, 0, 60);
875
+		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R');
876 876
 
877 877
 		// Date planned delivery
878
-		if (! empty($object->date_delivery))
878
+		if (!empty($object->date_delivery))
879 879
 		{
880
-    			$posy+=4;
881
-    			$pdf->SetXY($posx,$posy);
882
-    			$pdf->SetTextColor(0,0,60);
883
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
880
+    			$posy += 4;
881
+    			$pdf->SetXY($posx, $posy);
882
+    			$pdf->SetTextColor(0, 0, 60);
883
+    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
884 884
 		}
885 885
 
886
-		if (! empty($object->thirdparty->code_fournisseur))
886
+		if (!empty($object->thirdparty->code_fournisseur))
887 887
 		{
888
-			$posy+=4;
889
-			$pdf->SetXY($posx,$posy);
890
-			$pdf->SetTextColor(0,0,60);
891
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
888
+			$posy += 4;
889
+			$pdf->SetXY($posx, $posy);
890
+			$pdf->SetTextColor(0, 0, 60);
891
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
892 892
 		}
893 893
 
894 894
 
895
-		$pdf->SetFont('','', $default_font_size + 3);
896
-		$Yoff=25;
895
+		$pdf->SetFont('', '', $default_font_size + 3);
896
+		$Yoff = 25;
897 897
 
898 898
 		// Add list of linked orders
899
-		$origin 	= $object->origin;
900
-		$origin_id 	= $object->origin_id;
899
+		$origin = $object->origin;
900
+		$origin_id = $object->origin_id;
901 901
 
902 902
 	    // TODO move to external function
903
-		if (! empty($conf->fournisseur->enabled))     // commonly $origin='commande'
903
+		if (!empty($conf->fournisseur->enabled))     // commonly $origin='commande'
904 904
 		{
905 905
 			$outputlangs->load('orders');
906 906
 
907 907
 			$classname = 'CommandeFournisseur';
908 908
 			$linkedobject = new $classname($this->db);
909
-			$result=$linkedobject->fetch($origin_id);
909
+			$result = $linkedobject->fetch($origin_id);
910 910
 			if ($result >= 0)
911 911
 			{
912 912
 			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
913 913
 
914
-				$pdf->SetFont('','', $default_font_size - 2);
915
-				$text=$linkedobject->ref;
916
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
917
-				$Yoff = $Yoff+8;
918
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
919
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
920
-				$Yoff = $Yoff+3;
921
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
922
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
914
+				$pdf->SetFont('', '', $default_font_size - 2);
915
+				$text = $linkedobject->ref;
916
+				if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
917
+				$Yoff = $Yoff + 8;
918
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
919
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
920
+				$Yoff = $Yoff + 3;
921
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
922
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
923 923
 			}
924 924
 		}
925 925
 
926 926
 		if ($showaddress)
927 927
 		{
928 928
 			// Sender properties
929
-			$carac_emetteur='';
929
+			$carac_emetteur = '';
930 930
 		 	// Add internal contact of origin element if defined
931
-			$arrayidcontact=array();
932
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
933
-			if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
931
+			$arrayidcontact = array();
932
+			if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
933
+			if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
934 934
 		 	if (count($arrayidcontact) > 0)
935 935
 		 	{
936 936
 		 		$object->fetch_user(reset($arrayidcontact));
937
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
937
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
938 938
 		 	}
939 939
 
940 940
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
941 941
 
942 942
 			// Show sender
943
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
-			$posx=$this->marge_gauche;
945
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
943
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
+			$posx = $this->marge_gauche;
945
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
946 946
 
947
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
947
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
949 949
 
950 950
 			// Show sender frame
951
-			$pdf->SetTextColor(0,0,0);
952
-			$pdf->SetFont('','', $default_font_size - 2);
953
-			$pdf->SetXY($posx,$posy-5);
954
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
-			$pdf->SetXY($posx,$posy);
956
-			$pdf->SetFillColor(230,230,230);
951
+			$pdf->SetTextColor(0, 0, 0);
952
+			$pdf->SetFont('', '', $default_font_size - 2);
953
+			$pdf->SetXY($posx, $posy - 5);
954
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
+			$pdf->SetXY($posx, $posy);
956
+			$pdf->SetFillColor(230, 230, 230);
957 957
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
958
-			$pdf->SetTextColor(0,0,60);
959
-			$pdf->SetFillColor(255,255,255);
958
+			$pdf->SetTextColor(0, 0, 60);
959
+			$pdf->SetFillColor(255, 255, 255);
960 960
 
961 961
 			// If RECEPTION contact defined, we use it
962
-			$usecontact=false;
963
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
962
+			$usecontact = false;
963
+			$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
964 964
 
965 965
 			if (count($arrayidcontact) > 0)
966 966
 			{
967
-				$usecontact=true;
968
-				$result=$object->fetch_contact($arrayidcontact[0]);
967
+				$usecontact = true;
968
+				$result = $object->fetch_contact($arrayidcontact[0]);
969 969
 			}
970 970
 
971 971
 			//Recipient name
@@ -976,51 +976,51 @@  discard block
 block discarded – undo
976 976
 				$thirdparty = $object->thirdparty;
977 977
 			}
978 978
 
979
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
979
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
980 980
 
981
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
981
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
982 982
 
983 983
 				// Show recipient name
984
-			$pdf->SetXY($posx+2,$posy+3);
985
-			$pdf->SetFont('','B', $default_font_size);
986
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L');
984
+			$pdf->SetXY($posx + 2, $posy + 3);
985
+			$pdf->SetFont('', 'B', $default_font_size);
986
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L');
987 987
 
988 988
 			$posy = $pdf->getY();
989 989
 
990 990
 			// Show recipient information
991
-			$pdf->SetFont('','', $default_font_size - 1);
992
-			$pdf->SetXY($posx+2,$posy);
993
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L');
991
+			$pdf->SetFont('', '', $default_font_size - 1);
992
+			$pdf->SetXY($posx + 2, $posy);
993
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L');
994 994
 
995 995
 			// Show recipient
996
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
998
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1000
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
996
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
998
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1000
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1001 1001
 
1002 1002
 			// Show recipient frame
1003
-			$pdf->SetTextColor(0,0,0);
1004
-			$pdf->SetFont('','', $default_font_size - 2);
1005
-			$pdf->SetXY($posx+2,$posy-5);
1003
+			$pdf->SetTextColor(0, 0, 0);
1004
+			$pdf->SetFont('', '', $default_font_size - 2);
1005
+			$pdf->SetXY($posx + 2, $posy - 5);
1006 1006
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1007 1007
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1008 1008
 
1009 1009
 
1010 1010
 
1011 1011
 			// Show sender name
1012
-			$pdf->SetXY($posx+2,$posy+3);
1013
-			$pdf->SetFont('','B',$default_font_size);
1012
+			$pdf->SetXY($posx + 2, $posy + 3);
1013
+			$pdf->SetFont('', 'B', $default_font_size);
1014 1014
 			$pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1015
-			$posy=$pdf->getY();
1015
+			$posy = $pdf->getY();
1016 1016
 
1017 1017
 			// Show sender information
1018
-			$pdf->SetXY($posx+2,$posy);
1019
-			$pdf->SetFont('','', $default_font_size - 1);
1018
+			$pdf->SetXY($posx + 2, $posy);
1019
+			$pdf->SetFont('', '', $default_font_size - 1);
1020 1020
 			$pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1021 1021
 		}
1022 1022
 
1023
-		$pdf->SetTextColor(0,0,0);
1023
+		$pdf->SetTextColor(0, 0, 0);
1024 1024
 	}
1025 1025
 
1026 1026
 	/**
@@ -1032,10 +1032,10 @@  discard block
 block discarded – undo
1032 1032
 	 *      @param	int			$hidefreetext		1=Hide free text
1033 1033
 	 *      @return	int								Return height of bottom margin including footer text
1034 1034
 	 */
1035
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1035
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1036 1036
 	{
1037 1037
 		global $conf;
1038
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
-		return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1038
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
+		return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1040 1040
 	}
1041 1041
 }
Please login to merge, or discard this patch.