Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php 3 patches
Indentation   +1422 added lines, -1422 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public $db;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model name
52 52
      */
53 53
     public $name;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string model description (short text)
57 57
      */
58 58
     public $description;
@@ -62,89 +62,89 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public $update_main_doc_field;
64 64
 
65
-	/**
65
+    /**
66 66
      * @var string document type
67 67
      */
68 68
     public $type;
69 69
 
70
-	/**
70
+    /**
71 71
      * @var array Minimum version of PHP required by module.
72
-	 * e.g.: PHP ≥ 5.3 = array(5, 3)
72
+     * e.g.: PHP ≥ 5.3 = array(5, 3)
73 73
      */
74
-	public $phpmin = array(5, 2);
74
+    public $phpmin = array(5, 2);
75 75
 
76
-	/**
76
+    /**
77 77
      * Dolibarr version of the loaded document
78 78
      * @public string
79 79
      */
80
-	public $version = 'development';
80
+    public $version = 'development';
81 81
 
82 82
     public $page_largeur;
83 83
     public $page_hauteur;
84 84
     public $format;
85
-	public $marge_gauche;
86
-	public $marge_droite;
87
-	public $marge_haute;
88
-	public $marge_basse;
85
+    public $marge_gauche;
86
+    public $marge_droite;
87
+    public $marge_haute;
88
+    public $marge_basse;
89 89
 
90 90
     public $emetteur;	// Objet societe qui emet
91 91
 
92 92
 
93
-	/**
94
-	 *	Constructor
95
-	 *
96
-	 *  @param		DoliDB		$db      Database handler
97
-	 */
98
-	public function __construct($db)
99
-	{
100
-		global $conf,$langs,$mysoc;
101
-
102
-		// Translations
103
-		$langs->loadLangs(array("main", "bills", "products"));
104
-
105
-		$this->db = $db;
106
-		$this->name = "eratosthene";
107
-		$this->description = $langs->trans('PDFEratostheneDescription');
108
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
109
-
110
-		// Dimension page
111
-		$this->type = 'pdf';
112
-		$formatarray=pdf_getFormat();
113
-		$this->page_largeur = $formatarray['width'];
114
-		$this->page_hauteur = $formatarray['height'];
115
-		$this->format = array($this->page_largeur,$this->page_hauteur);
116
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
117
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
118
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
119
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
120
-
121
-		$this->option_logo = 1;                    // Affiche logo
122
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
123
-		$this->option_modereg = 1;                 // Affiche mode reglement
124
-		$this->option_condreg = 1;                 // Affiche conditions reglement
125
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
126
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
127
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
128
-		$this->option_credit_note = 0;             // Support credit notes
129
-		$this->option_freetext = 1;				   // Support add of a personalised text
130
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
131
-
132
-		$this->franchise=!$mysoc->tva_assuj;
133
-
134
-		// Get source company
135
-		$this->emetteur=$mysoc;
136
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
137
-
138
-		// Define position of columns
139
-		$this->posxdesc=$this->marge_gauche+1;
140
-
141
-
142
-		$this->tva=array();
143
-		$this->localtax1=array();
144
-		$this->localtax2=array();
145
-		$this->atleastoneratenotnull=0;
146
-		$this->atleastonediscount=0;
147
-	}
93
+    /**
94
+     *	Constructor
95
+     *
96
+     *  @param		DoliDB		$db      Database handler
97
+     */
98
+    public function __construct($db)
99
+    {
100
+        global $conf,$langs,$mysoc;
101
+
102
+        // Translations
103
+        $langs->loadLangs(array("main", "bills", "products"));
104
+
105
+        $this->db = $db;
106
+        $this->name = "eratosthene";
107
+        $this->description = $langs->trans('PDFEratostheneDescription');
108
+        $this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
109
+
110
+        // Dimension page
111
+        $this->type = 'pdf';
112
+        $formatarray=pdf_getFormat();
113
+        $this->page_largeur = $formatarray['width'];
114
+        $this->page_hauteur = $formatarray['height'];
115
+        $this->format = array($this->page_largeur,$this->page_hauteur);
116
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
117
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
118
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
119
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
120
+
121
+        $this->option_logo = 1;                    // Affiche logo
122
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
123
+        $this->option_modereg = 1;                 // Affiche mode reglement
124
+        $this->option_condreg = 1;                 // Affiche conditions reglement
125
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
126
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
127
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
128
+        $this->option_credit_note = 0;             // Support credit notes
129
+        $this->option_freetext = 1;				   // Support add of a personalised text
130
+        $this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
131
+
132
+        $this->franchise=!$mysoc->tva_assuj;
133
+
134
+        // Get source company
135
+        $this->emetteur=$mysoc;
136
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
137
+
138
+        // Define position of columns
139
+        $this->posxdesc=$this->marge_gauche+1;
140
+
141
+
142
+        $this->tva=array();
143
+        $this->localtax1=array();
144
+        $this->localtax2=array();
145
+        $this->atleastoneratenotnull=0;
146
+        $this->atleastonediscount=0;
147
+    }
148 148
 
149 149
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150 150
     /**
@@ -157,70 +157,70 @@  discard block
 block discarded – undo
157 157
      *  @param		int			$hidedesc			Do not show desc
158 158
      *  @param		int			$hideref			Do not show ref
159 159
      *  @return     int             			    1=OK, 0=KO
160
-	 */
161
-	public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
162
-	{
163
-	    // phpcs:enable
164
-		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
160
+     */
161
+    public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
162
+    {
163
+        // phpcs:enable
164
+        global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 165
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
167
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
168
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
166
+        if (! is_object($outputlangs)) $outputlangs=$langs;
167
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
168
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
169 169
 
170
-		// Translations
171
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
170
+        // Translations
171
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
172 172
 
173
-		$nblignes = count($object->lines);
173
+        $nblignes = count($object->lines);
174 174
 
175
-		if ($conf->commande->dir_output)
176
-		{
175
+        if ($conf->commande->dir_output)
176
+        {
177 177
             $object->fetch_thirdparty();
178 178
 
179 179
             $deja_regle = 0;
180 180
 
181 181
             // Definition of $dir and $file
182
-			if ($object->specimen)
183
-			{
184
-				$dir = $conf->commande->dir_output;
185
-				$file = $dir . "/SPECIMEN.pdf";
186
-			}
187
-			else
188
-			{
189
-				$objectref = dol_sanitizeFileName($object->ref);
190
-				$dir = $conf->commande->dir_output . "/" . $objectref;
191
-				$file = $dir . "/" . $objectref . ".pdf";
192
-			}
193
-
194
-			if (! file_exists($dir))
195
-			{
196
-				if (dol_mkdir($dir) < 0)
197
-				{
198
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
199
-					return 0;
200
-				}
201
-			}
182
+            if ($object->specimen)
183
+            {
184
+                $dir = $conf->commande->dir_output;
185
+                $file = $dir . "/SPECIMEN.pdf";
186
+            }
187
+            else
188
+            {
189
+                $objectref = dol_sanitizeFileName($object->ref);
190
+                $dir = $conf->commande->dir_output . "/" . $objectref;
191
+                $file = $dir . "/" . $objectref . ".pdf";
192
+            }
193
+
194
+            if (! file_exists($dir))
195
+            {
196
+                if (dol_mkdir($dir) < 0)
197
+                {
198
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
199
+                    return 0;
200
+                }
201
+            }
202 202
 
203
-			if (file_exists($dir))
204
-			{
205
-				// Add pdfgeneration hook
206
-				if (! is_object($hookmanager))
207
-				{
208
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
-					$hookmanager=new HookManager($this->db);
210
-				}
211
-				$hookmanager->initHooks(array('pdfgeneration'));
212
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
213
-				global $action;
214
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
203
+            if (file_exists($dir))
204
+            {
205
+                // Add pdfgeneration hook
206
+                if (! is_object($hookmanager))
207
+                {
208
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
+                    $hookmanager=new HookManager($this->db);
210
+                }
211
+                $hookmanager->initHooks(array('pdfgeneration'));
212
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
213
+                global $action;
214
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
215 215
 
216
-				// Create pdf instance
217
-				$pdf=pdf_getInstance($this->format);
218
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
219
-				$pdf->SetAutoPageBreak(1,0);
216
+                // Create pdf instance
217
+                $pdf=pdf_getInstance($this->format);
218
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
219
+                $pdf->SetAutoPageBreak(1,0);
220 220
 
221
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
222
-		        $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
223
-		        $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22);	// Height reserved to output the footer (value include bottom margin)
221
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
222
+                $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
223
+                $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22);	// Height reserved to output the footer (value include bottom margin)
224 224
 
225 225
                 if (class_exists('TCPDF'))
226 226
                 {
@@ -235,540 +235,540 @@  discard block
 block discarded – undo
235 235
                     $tplidx = $pdf->importPage(1);
236 236
                 }
237 237
 
238
-				$pdf->Open();
239
-				$pagenb=0;
240
-				$pdf->SetDrawColor(128,128,128);
241
-
242
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243
-				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
247
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
248
-
249
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250
-
251
-				/// Does we have at least one line with discount $this->atleastonediscount
252
-				foreach ($object->lines as $line) {
253
-				    if ($line->remise_percent){
254
-				        $this->atleastonediscount = true;
255
-				        break;
256
-				    }
257
-				}
238
+                $pdf->Open();
239
+                $pagenb=0;
240
+                $pdf->SetDrawColor(128,128,128);
241
+
242
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243
+                $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
245
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
247
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
248
+
249
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250
+
251
+                /// Does we have at least one line with discount $this->atleastonediscount
252
+                foreach ($object->lines as $line) {
253
+                    if ($line->remise_percent){
254
+                        $this->atleastonediscount = true;
255
+                        break;
256
+                    }
257
+                }
258 258
 
259
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
260
-				{
261
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
262
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
263
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
264
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
265
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
266
-					//$this->postotalht;
267
-				}
259
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
260
+                {
261
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
262
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
263
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
264
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
265
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
266
+                    //$this->postotalht;
267
+                }
268 268
 
269
-				// New page
270
-				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
272
-				$pagenb++;
273
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274
-				$pdf->SetFont('','', $default_font_size - 1);
275
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
276
-				$pdf->SetTextColor(0,0,0);
269
+                // New page
270
+                $pdf->AddPage();
271
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
272
+                $pagenb++;
273
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274
+                $pdf->SetFont('','', $default_font_size - 1);
275
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
276
+                $pdf->SetTextColor(0,0,0);
277 277
 
278 278
 
279
-				$tab_top = 90+$top_shift;
280
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
279
+                $tab_top = 90+$top_shift;
280
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
281 281
 
282
-				// Incoterm
283
-				if ($conf->incoterm->enabled)
284
-				{
285
-					$desc_incoterms = $object->getIncotermsForPDF();
286
-					if ($desc_incoterms)
287
-					{
288
-						$tab_top -= 2;
289
-
290
-						$pdf->SetFont('','', $default_font_size - 1);
291
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
292
-						$nexY = $pdf->GetY();
293
-						$height_incoterms=$nexY-$tab_top;
294
-
295
-						// Rect prend une longueur en 3eme param
296
-						$pdf->SetDrawColor(192,192,192);
297
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
298
-
299
-						$tab_top = $nexY+6;
300
-					}
301
-				}
282
+                // Incoterm
283
+                if ($conf->incoterm->enabled)
284
+                {
285
+                    $desc_incoterms = $object->getIncotermsForPDF();
286
+                    if ($desc_incoterms)
287
+                    {
288
+                        $tab_top -= 2;
289
+
290
+                        $pdf->SetFont('','', $default_font_size - 1);
291
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
292
+                        $nexY = $pdf->GetY();
293
+                        $height_incoterms=$nexY-$tab_top;
294
+
295
+                        // Rect prend une longueur en 3eme param
296
+                        $pdf->SetDrawColor(192,192,192);
297
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
298
+
299
+                        $tab_top = $nexY+6;
300
+                    }
301
+                }
302 302
 
303
-				// Affiche notes
304
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
305
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306
-				{
307
-					// Get first sale rep
308
-					if (is_object($object->thirdparty))
309
-					{
310
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
-						$salerepobj=new User($this->db);
312
-						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
314
-					}
315
-				}
303
+                // Affiche notes
304
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
305
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306
+                {
307
+                    // Get first sale rep
308
+                    if (is_object($object->thirdparty))
309
+                    {
310
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
+                        $salerepobj=new User($this->db);
312
+                        $salerepobj->fetch($salereparray[0]['id']);
313
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
314
+                    }
315
+                }
316 316
 
317
-				$pagenb = $pdf->getPage();
318
-				if ($notetoshow)
319
-				{
320
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
321
-				    $pageposbeforenote = $pagenb;
322
-
323
-				    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
324
-				    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325
-				    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326
-
327
-					$tab_top -= 2;
328
-
329
-				    $pdf->startTransaction();
330
-
331
-				    $pdf->SetFont('','', $default_font_size - 1);
332
-				    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333
-				    // Description
334
-				    $pageposafternote=$pdf->getPage();
335
-				    $posyafter = $pdf->GetY();
336
-
337
-				    if($pageposafternote>$pageposbeforenote )
338
-				    {
339
-				        $pdf->rollbackTransaction(true);
340
-
341
-				        // prepar pages to receive notes
342
-				        while ($pagenb < $pageposafternote) {
343
-				            $pdf->AddPage();
344
-				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347
-				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348
-				            $pdf->setTopMargin($tab_top_newpage);
349
-				            // The only function to edit the bottom margin of current page to set it.
350
-				            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
351
-				        }
352
-
353
-				        // back to start
354
-				        $pdf->setPage($pageposbeforenote);
355
-				        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
356
-				        $pdf->SetFont('','', $default_font_size - 1);
357
-				        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
-				        $pageposafternote=$pdf->getPage();
359
-
360
-				        $posyafter = $pdf->GetY();
361
-
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
363
-				        {
364
-				            $pdf->AddPage('','',true);
365
-				            $pagenb++;
366
-				            $pageposafternote++;
367
-				            $pdf->setPage($pageposafternote);
368
-				            $pdf->setTopMargin($tab_top_newpage);
369
-				            // The only function to edit the bottom margin of current page to set it.
370
-				            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
371
-				            //$posyafter = $tab_top_newpage;
372
-				        }
373
-
374
-
375
-				        // apply note frame to previus pages
376
-				        $i = $pageposbeforenote;
377
-				        while ($i < $pageposafternote) {
378
-				            $pdf->setPage($i);
379
-
380
-
381
-				            $pdf->SetDrawColor(128,128,128);
382
-				            // Draw note frame
383
-				            if($i>$pageposbeforenote){
384
-				                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385
-				                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
386
-				            }
387
-				            else{
388
-				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
-				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390
-				            }
391
-
392
-				            // Add footer
393
-				            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
394
-				            $this->_pagefoot($pdf,$object,$outputlangs,1);
395
-
396
-				            $i++;
397
-				        }
398
-
399
-				        // apply note frame to last page
400
-				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
-				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
403
-				        $height_note=$posyafter-$tab_top_newpage;
404
-				        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
405
-				    }
406
-				    else // No pagebreak
407
-				    {
408
-				        $pdf->commitTransaction();
409
-				        $posyafter = $pdf->GetY();
410
-				        $height_note=$posyafter-$tab_top;
411
-				        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
412
-
413
-
414
-				        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
415
-				        {
416
-				            // not enough space, need to add page
417
-				            $pdf->AddPage('','',true);
418
-				            $pagenb++;
419
-				            $pageposafternote++;
420
-				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423
-
424
-				            $posyafter = $tab_top_newpage;
425
-				        }
426
-				    }
427
-
428
-				    $tab_height = $tab_height - $height_note;
429
-				    $tab_top = $posyafter +6;
430
-				}
431
-				else
432
-				{
433
-					$height_note=0;
434
-				}
317
+                $pagenb = $pdf->getPage();
318
+                if ($notetoshow)
319
+                {
320
+                    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
321
+                    $pageposbeforenote = $pagenb;
322
+
323
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
324
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326
+
327
+                    $tab_top -= 2;
328
+
329
+                    $pdf->startTransaction();
330
+
331
+                    $pdf->SetFont('','', $default_font_size - 1);
332
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333
+                    // Description
334
+                    $pageposafternote=$pdf->getPage();
335
+                    $posyafter = $pdf->GetY();
336
+
337
+                    if($pageposafternote>$pageposbeforenote )
338
+                    {
339
+                        $pdf->rollbackTransaction(true);
340
+
341
+                        // prepar pages to receive notes
342
+                        while ($pagenb < $pageposafternote) {
343
+                            $pdf->AddPage();
344
+                            $pagenb++;
345
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347
+                            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348
+                            $pdf->setTopMargin($tab_top_newpage);
349
+                            // The only function to edit the bottom margin of current page to set it.
350
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
351
+                        }
352
+
353
+                        // back to start
354
+                        $pdf->setPage($pageposbeforenote);
355
+                        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
356
+                        $pdf->SetFont('','', $default_font_size - 1);
357
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
+                        $pageposafternote=$pdf->getPage();
359
+
360
+                        $posyafter = $pdf->GetY();
361
+
362
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
363
+                        {
364
+                            $pdf->AddPage('','',true);
365
+                            $pagenb++;
366
+                            $pageposafternote++;
367
+                            $pdf->setPage($pageposafternote);
368
+                            $pdf->setTopMargin($tab_top_newpage);
369
+                            // The only function to edit the bottom margin of current page to set it.
370
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
371
+                            //$posyafter = $tab_top_newpage;
372
+                        }
373
+
374
+
375
+                        // apply note frame to previus pages
376
+                        $i = $pageposbeforenote;
377
+                        while ($i < $pageposafternote) {
378
+                            $pdf->setPage($i);
379
+
380
+
381
+                            $pdf->SetDrawColor(128,128,128);
382
+                            // Draw note frame
383
+                            if($i>$pageposbeforenote){
384
+                                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385
+                                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
386
+                            }
387
+                            else{
388
+                                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
+                                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390
+                            }
391
+
392
+                            // Add footer
393
+                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
394
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
395
+
396
+                            $i++;
397
+                        }
398
+
399
+                        // apply note frame to last page
400
+                        $pdf->setPage($pageposafternote);
401
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
403
+                        $height_note=$posyafter-$tab_top_newpage;
404
+                        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
405
+                    }
406
+                    else // No pagebreak
407
+                    {
408
+                        $pdf->commitTransaction();
409
+                        $posyafter = $pdf->GetY();
410
+                        $height_note=$posyafter-$tab_top;
411
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
412
+
413
+
414
+                        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
415
+                        {
416
+                            // not enough space, need to add page
417
+                            $pdf->AddPage('','',true);
418
+                            $pagenb++;
419
+                            $pageposafternote++;
420
+                            $pdf->setPage($pageposafternote);
421
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423
+
424
+                            $posyafter = $tab_top_newpage;
425
+                        }
426
+                    }
427
+
428
+                    $tab_height = $tab_height - $height_note;
429
+                    $tab_top = $posyafter +6;
430
+                }
431
+                else
432
+                {
433
+                    $height_note=0;
434
+                }
435 435
 
436
-				$iniY = $tab_top + 7;
437
-				$curY = $tab_top + 7;
438
-				$nexY = $tab_top + 7;
436
+                $iniY = $tab_top + 7;
437
+                $curY = $tab_top + 7;
438
+                $nexY = $tab_top + 7;
439 439
 
440
-				// Use new auto collum system
441
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
440
+                // Use new auto collum system
441
+                $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
442 442
 
443
-				// Loop on each lines
444
-				$pageposbeforeprintlines=$pdf->getPage();
445
-				$pagenb = $pageposbeforeprintlines;
446
-				for ($i = 0 ; $i < $nblignes ; $i++)
447
-				{
448
-					$curY = $nexY;
449
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
-					$pdf->SetTextColor(0,0,0);
451
-
452
-					$pdf->setTopMargin($tab_top_newpage);
453
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
454
-					$pageposbefore=$pdf->getPage();
455
-
456
-					// Description of product line
457
-					$curX = $this->posxdesc-1;
458
-
459
-					$showpricebeforepagebreak=1;
460
-
461
-					if($this->getColumnStatus('desc'))
462
-					{
463
-    					$pdf->startTransaction();
464
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
-    					$pageposafter=$pdf->getPage();
466
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
467
-    					{
468
-    						$pdf->rollbackTransaction(true);
469
-    						$pageposafter=$pageposbefore;
470
-    						//print $pageposafter.'-'.$pageposbefore;exit;
471
-    						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472
-    						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473
-    						$pageposafter=$pdf->getPage();
474
-    						$posyafter=$pdf->GetY();
475
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
476
-    						{
477
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478
-    							{
479
-    								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
481
-    								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
-    								$pdf->setPage($pageposafter+1);
483
-    							}
484
-    						}
485
-    						else
486
-    						{
487
-    							// We found a page break
488
-    							$showpricebeforepagebreak=0;
489
-    						}
490
-    					}
491
-    					else	// No pagebreak
492
-    					{
493
-    						$pdf->commitTransaction();
494
-    					}
495
-    					$posYAfterDescription=$pdf->GetY();
496
-					}
497
-
498
-					$nexY = $pdf->GetY();
499
-					$pageposafter=$pdf->getPage();
500
-
501
-					$pdf->setPage($pageposbefore);
502
-					$pdf->setTopMargin($this->marge_haute);
503
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
504
-
505
-					// We suppose that a too long description is moved completely on next page
506
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508
-					}
509
-
510
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
511
-
512
-					// VAT Rate
513
-					if ($this->getColumnStatus('vat'))
514
-					{
515
-					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516
-					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
-					    $nexY = max($pdf->GetY(),$nexY);
518
-					}
519
-
520
-					// Unit price before discount
521
-					if ($this->getColumnStatus('subprice'))
522
-					{
523
-					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524
-					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
-					    $nexY = max($pdf->GetY(),$nexY);
526
-					}
527
-
528
-					// Quantity
529
-					// Enough for 6 chars
530
-					if ($this->getColumnStatus('qty'))
531
-					{
532
-					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533
-					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
-					    $nexY = max($pdf->GetY(),$nexY);
535
-					}
536
-
537
-
538
-					// Unit
539
-					if ($this->getColumnStatus('unit'))
540
-					{
541
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542
-					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
-					    $nexY = max($pdf->GetY(),$nexY);
544
-					}
545
-
546
-					// Discount on line
547
-					if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
548
-					{
549
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550
-					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
-					    $nexY = max($pdf->GetY(),$nexY);
552
-					}
553
-
554
-					// Total HT line
555
-					if ($this->getColumnStatus('totalexcltax'))
556
-					{
557
-					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558
-					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
-					    $nexY = max($pdf->GetY(),$nexY);
560
-					}
561
-
562
-
563
-					$parameters=array(
564
-					    'object' => $object,
565
-					    'i' => $i,
566
-					    'pdf' =>& $pdf,
567
-					    'curY' =>& $curY,
568
-					    'nexY' =>& $nexY,
569
-					    'outputlangs' => $outputlangs,
570
-					    'hidedetails' => $hidedetails
571
-					);
572
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
573
-
574
-
575
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
577
-					else $tvaligne=$object->lines[$i]->total_tva;
578
-
579
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
580
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
581
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
582
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
583
-					$localtax1_type=$object->lines[$i]->localtax1_type;
584
-					$localtax2_type=$object->lines[$i]->localtax2_type;
585
-
586
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
587
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
588
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
589
-
590
-					$vatrate=(string) $object->lines[$i]->tva_tx;
591
-
592
-					// Retrieve type from database for backward compatibility with old records
593
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
594
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
595
-					{
596
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
597
-						$localtax1_type = $localtaxtmp_array[0];
598
-						$localtax2_type = $localtaxtmp_array[2];
599
-					}
600
-
601
-				    // retrieve global local tax
602
-					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
-					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
606
-
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
609
-					$this->tva[$vatrate] += $tvaligne;
610
-
611
-					// Add line
612
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613
-					{
614
-						$pdf->setPage($pageposafter);
615
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
616
-						//$pdf->SetDrawColor(190,190,200);
617
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
618
-						$pdf->SetLineStyle(array('dash'=>0));
619
-					}
620
-
621
-					$nexY+=2;    // Passe espace entre les lignes
622
-
623
-					// Detect if some page were added automatically and output _tableau for past pages
624
-					while ($pagenb < $pageposafter)
625
-					{
626
-						$pdf->setPage($pagenb);
627
-						if ($pagenb == $pageposbeforeprintlines)
628
-						{
629
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
-						}
631
-						else
632
-						{
633
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634
-						}
635
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
636
-						$pagenb++;
637
-						$pdf->setPage($pagenb);
638
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640
-					}
641
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642
-					{
643
-					    if ($pagenb == $pageposafter)
644
-						{
645
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
-						}
647
-						else
648
-						{
649
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650
-						}
651
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
652
-						// New page
653
-						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
655
-						$pagenb++;
656
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657
-					}
658
-				}
443
+                // Loop on each lines
444
+                $pageposbeforeprintlines=$pdf->getPage();
445
+                $pagenb = $pageposbeforeprintlines;
446
+                for ($i = 0 ; $i < $nblignes ; $i++)
447
+                {
448
+                    $curY = $nexY;
449
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
+                    $pdf->SetTextColor(0,0,0);
451
+
452
+                    $pdf->setTopMargin($tab_top_newpage);
453
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
454
+                    $pageposbefore=$pdf->getPage();
455
+
456
+                    // Description of product line
457
+                    $curX = $this->posxdesc-1;
458
+
459
+                    $showpricebeforepagebreak=1;
460
+
461
+                    if($this->getColumnStatus('desc'))
462
+                    {
463
+                        $pdf->startTransaction();
464
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
+                        $pageposafter=$pdf->getPage();
466
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
467
+                        {
468
+                            $pdf->rollbackTransaction(true);
469
+                            $pageposafter=$pageposbefore;
470
+                            //print $pageposafter.'-'.$pageposbefore;exit;
471
+                            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472
+                            pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473
+                            $pageposafter=$pdf->getPage();
474
+                            $posyafter=$pdf->GetY();
475
+                            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
476
+                            {
477
+                                if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478
+                                {
479
+                                    $pdf->AddPage('','',true);
480
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
481
+                                    //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
+                                    $pdf->setPage($pageposafter+1);
483
+                                }
484
+                            }
485
+                            else
486
+                            {
487
+                                // We found a page break
488
+                                $showpricebeforepagebreak=0;
489
+                            }
490
+                        }
491
+                        else	// No pagebreak
492
+                        {
493
+                            $pdf->commitTransaction();
494
+                        }
495
+                        $posYAfterDescription=$pdf->GetY();
496
+                    }
497
+
498
+                    $nexY = $pdf->GetY();
499
+                    $pageposafter=$pdf->getPage();
500
+
501
+                    $pdf->setPage($pageposbefore);
502
+                    $pdf->setTopMargin($this->marge_haute);
503
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
504
+
505
+                    // We suppose that a too long description is moved completely on next page
506
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508
+                    }
509
+
510
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
511
+
512
+                    // VAT Rate
513
+                    if ($this->getColumnStatus('vat'))
514
+                    {
515
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516
+                        $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
+                        $nexY = max($pdf->GetY(),$nexY);
518
+                    }
519
+
520
+                    // Unit price before discount
521
+                    if ($this->getColumnStatus('subprice'))
522
+                    {
523
+                        $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524
+                        $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
+                        $nexY = max($pdf->GetY(),$nexY);
526
+                    }
527
+
528
+                    // Quantity
529
+                    // Enough for 6 chars
530
+                    if ($this->getColumnStatus('qty'))
531
+                    {
532
+                        $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533
+                        $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
+                        $nexY = max($pdf->GetY(),$nexY);
535
+                    }
536
+
537
+
538
+                    // Unit
539
+                    if ($this->getColumnStatus('unit'))
540
+                    {
541
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542
+                        $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
+                        $nexY = max($pdf->GetY(),$nexY);
544
+                    }
545
+
546
+                    // Discount on line
547
+                    if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
548
+                    {
549
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550
+                        $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
+                        $nexY = max($pdf->GetY(),$nexY);
552
+                    }
553
+
554
+                    // Total HT line
555
+                    if ($this->getColumnStatus('totalexcltax'))
556
+                    {
557
+                        $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558
+                        $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
+                        $nexY = max($pdf->GetY(),$nexY);
560
+                    }
561
+
562
+
563
+                    $parameters=array(
564
+                        'object' => $object,
565
+                        'i' => $i,
566
+                        'pdf' =>& $pdf,
567
+                        'curY' =>& $curY,
568
+                        'nexY' =>& $nexY,
569
+                        'outputlangs' => $outputlangs,
570
+                        'hidedetails' => $hidedetails
571
+                    );
572
+                    $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
573
+
574
+
575
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
577
+                    else $tvaligne=$object->lines[$i]->total_tva;
578
+
579
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
580
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
581
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
582
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
583
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
584
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
585
+
586
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
587
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
588
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
589
+
590
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
591
+
592
+                    // Retrieve type from database for backward compatibility with old records
593
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
594
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
595
+                    {
596
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
597
+                        $localtax1_type = $localtaxtmp_array[0];
598
+                        $localtax2_type = $localtaxtmp_array[2];
599
+                    }
600
+
601
+                    // retrieve global local tax
602
+                    if ($localtax1_type && $localtax1ligne != 0)
603
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
+                    if ($localtax2_type && $localtax2ligne != 0)
605
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
606
+
607
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
609
+                    $this->tva[$vatrate] += $tvaligne;
610
+
611
+                    // Add line
612
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613
+                    {
614
+                        $pdf->setPage($pageposafter);
615
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
616
+                        //$pdf->SetDrawColor(190,190,200);
617
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
618
+                        $pdf->SetLineStyle(array('dash'=>0));
619
+                    }
620
+
621
+                    $nexY+=2;    // Passe espace entre les lignes
622
+
623
+                    // Detect if some page were added automatically and output _tableau for past pages
624
+                    while ($pagenb < $pageposafter)
625
+                    {
626
+                        $pdf->setPage($pagenb);
627
+                        if ($pagenb == $pageposbeforeprintlines)
628
+                        {
629
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
+                        }
631
+                        else
632
+                        {
633
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634
+                        }
635
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
636
+                        $pagenb++;
637
+                        $pdf->setPage($pagenb);
638
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640
+                    }
641
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642
+                    {
643
+                        if ($pagenb == $pageposafter)
644
+                        {
645
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
+                        }
647
+                        else
648
+                        {
649
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650
+                        }
651
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
652
+                        // New page
653
+                        $pdf->AddPage();
654
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
655
+                        $pagenb++;
656
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657
+                    }
658
+                }
659 659
 
660
-				// Show square
661
-				if ($pagenb == $pageposbeforeprintlines)
662
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
-				else
664
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
665
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
660
+                // Show square
661
+                if ($pagenb == $pageposbeforeprintlines)
662
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
+                else
664
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
665
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 666
 
667
-				// Affiche zone infos
668
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
667
+                // Affiche zone infos
668
+                $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
669 669
 
670
-				// Affiche zone totaux
671
-				$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
670
+                // Affiche zone totaux
671
+                $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
672 672
 
673
-				// Affiche zone versements
674
-				/*
673
+                // Affiche zone versements
674
+                /*
675 675
 				if ($deja_regle)
676 676
 				{
677 677
 					$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
678 678
 				}
679 679
 				*/
680 680
 
681
-				// Pied de page
682
-				$this->_pagefoot($pdf, $object, $outputlangs);
683
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
681
+                // Pied de page
682
+                $this->_pagefoot($pdf, $object, $outputlangs);
683
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
684 684
 
685
-				$pdf->Close();
685
+                $pdf->Close();
686 686
 
687
-				$pdf->Output($file, 'F');
687
+                $pdf->Output($file, 'F');
688 688
 
689
-				// Add pdfgeneration hook
690
-				$hookmanager->initHooks(array('pdfgeneration'));
691
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692
-				global $action;
693
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
689
+                // Add pdfgeneration hook
690
+                $hookmanager->initHooks(array('pdfgeneration'));
691
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692
+                global $action;
693
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
694 694
 
695
-				if (! empty($conf->global->MAIN_UMASK))
696
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
695
+                if (! empty($conf->global->MAIN_UMASK))
696
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
697 697
 
698
-				$this->result = array('fullpath'=>$file);
698
+                $this->result = array('fullpath'=>$file);
699 699
 
700
-				return 1;   // Pas d'erreur
701
-			}
702
-			else
703
-			{
704
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705
-				return 0;
706
-			}
707
-		}
708
-		else
709
-		{
710
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711
-			return 0;
712
-		}
713
-	}
714
-
715
-	/**
716
-	 *  Show payments table
717
-   *
718
-	 *  @param	TCPDF		$pdf     		Object PDF
719
-	 *  @param  Object		$object			Object order
720
-	 *	@param	int			$posy			Position y in PDF
721
-	 *	@param	Translate	$outputlangs	Object langs for output
722
-	 *	@return int							<0 if KO, >0 if OK
723
-	 */
724
-	private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
725
-	{
726
-	}
727
-
728
-	/**
729
-	 *   Show miscellaneous information (payment mode, payment term, ...)
730
-	 *
731
-	 *   @param		TCPDF		$pdf     		Object PDF
732
-	 *   @param		Object		$object			Object to show
733
-	 *   @param		int			$posy			Y
734
-	 *   @param		Translate	$outputlangs	Langs object
735
-	 *   @return	void
736
-	 */
737
-	private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
738
-	{
739
-		global $conf;
740
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
741
-
742
-		$pdf->SetFont('','', $default_font_size - 1);
700
+                return 1;   // Pas d'erreur
701
+            }
702
+            else
703
+            {
704
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705
+                return 0;
706
+            }
707
+        }
708
+        else
709
+        {
710
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711
+            return 0;
712
+        }
713
+    }
714
+
715
+    /**
716
+     *  Show payments table
717
+     *
718
+     *  @param	TCPDF		$pdf     		Object PDF
719
+     *  @param  Object		$object			Object order
720
+     *	@param	int			$posy			Position y in PDF
721
+     *	@param	Translate	$outputlangs	Object langs for output
722
+     *	@return int							<0 if KO, >0 if OK
723
+     */
724
+    private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
725
+    {
726
+    }
727
+
728
+    /**
729
+     *   Show miscellaneous information (payment mode, payment term, ...)
730
+     *
731
+     *   @param		TCPDF		$pdf     		Object PDF
732
+     *   @param		Object		$object			Object to show
733
+     *   @param		int			$posy			Y
734
+     *   @param		Translate	$outputlangs	Langs object
735
+     *   @return	void
736
+     */
737
+    private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
738
+    {
739
+        global $conf;
740
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
741
+
742
+        $pdf->SetFont('','', $default_font_size - 1);
743 743
 
744 744
         // If France, show VAT mention if not applicable
745
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746
-		{
747
-			$pdf->SetFont('','B', $default_font_size - 2);
748
-			$pdf->SetXY($this->marge_gauche, $posy);
749
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
745
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746
+        {
747
+            $pdf->SetFont('','B', $default_font_size - 2);
748
+            $pdf->SetXY($this->marge_gauche, $posy);
749
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
750 750
 
751
-			$posy=$pdf->GetY()+4;
752
-		}
751
+            $posy=$pdf->GetY()+4;
752
+        }
753 753
 
754
-		$posxval=52;
754
+        $posxval=52;
755 755
 
756
-		// Show payments conditions
757
-		if ($object->cond_reglement_code || $object->cond_reglement)
758
-		{
759
-			$pdf->SetFont('','B', $default_font_size - 2);
760
-			$pdf->SetXY($this->marge_gauche, $posy);
761
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
762
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
756
+        // Show payments conditions
757
+        if ($object->cond_reglement_code || $object->cond_reglement)
758
+        {
759
+            $pdf->SetFont('','B', $default_font_size - 2);
760
+            $pdf->SetXY($this->marge_gauche, $posy);
761
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
762
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
763 763
 
764
-			$pdf->SetFont('','', $default_font_size - 2);
765
-			$pdf->SetXY($posxval, $posy);
766
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
768
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
764
+            $pdf->SetFont('','', $default_font_size - 2);
765
+            $pdf->SetXY($posxval, $posy);
766
+            $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
768
+            $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
769 769
 
770
-			$posy=$pdf->GetY()+3;
771
-		}
770
+            $posy=$pdf->GetY()+3;
771
+        }
772 772
 
773 773
         // Check a payment mode is defined
774 774
         /* Not used with orders
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
             $posy=$pdf->GetY()+1;
786 786
         }
787 787
 		*/
788
-		/* TODO
788
+        /* TODO
789 789
 		else if (! empty($object->availability_code))
790 790
 		{
791 791
             $pdf->SetXY($this->marge_gauche, $posy);
@@ -797,707 +797,707 @@  discard block
 block discarded – undo
797 797
             $posy=$pdf->GetY()+1;
798 798
 		}*/
799 799
 
800
-	    // Show planed date of delivery
800
+        // Show planed date of delivery
801 801
         if (! empty($object->date_livraison))
802
-		{
802
+        {
803 803
             $outputlangs->load("sendings");
804
-			$pdf->SetFont('','B', $default_font_size - 2);
805
-			$pdf->SetXY($this->marge_gauche, $posy);
806
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
808
-			$pdf->SetFont('','', $default_font_size - 2);
809
-			$pdf->SetXY($posxval, $posy);
810
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
811
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
804
+            $pdf->SetFont('','B', $default_font_size - 2);
805
+            $pdf->SetXY($this->marge_gauche, $posy);
806
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
808
+            $pdf->SetFont('','', $default_font_size - 2);
809
+            $pdf->SetXY($posxval, $posy);
810
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
811
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 812
 
813 813
             $posy=$pdf->GetY()+1;
814
-		}
814
+        }
815 815
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
816
-		{
817
-			$pdf->SetFont('','B', $default_font_size - 2);
818
-			$pdf->SetXY($this->marge_gauche, $posy);
819
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
821
-			$pdf->SetTextColor(0,0,0);
822
-			$pdf->SetFont('','', $default_font_size - 2);
823
-			$pdf->SetXY($posxval, $posy);
824
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
825
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
826
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827
-
828
-			$posy=$pdf->GetY()+1;
829
-		}
830
-
831
-      	// Show payment mode
816
+        {
817
+            $pdf->SetFont('','B', $default_font_size - 2);
818
+            $pdf->SetXY($this->marge_gauche, $posy);
819
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
821
+            $pdf->SetTextColor(0,0,0);
822
+            $pdf->SetFont('','', $default_font_size - 2);
823
+            $pdf->SetXY($posxval, $posy);
824
+            $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
825
+            $lib_availability=str_replace('\n',"\n",$lib_availability);
826
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827
+
828
+            $posy=$pdf->GetY()+1;
829
+        }
830
+
831
+            // Show payment mode
832 832
         if ($object->mode_reglement_code
833
-        	 && $object->mode_reglement_code != 'CHQ'
834
-           	 && $object->mode_reglement_code != 'VIR')
835
-           	 {
836
-	            $pdf->SetFont('','B', $default_font_size - 2);
837
-	            $pdf->SetXY($this->marge_gauche, $posy);
838
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
839
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
840
-
841
-				$pdf->SetFont('','', $default_font_size - 2);
842
-	            $pdf->SetXY($posxval, $posy);
843
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
844
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
845
-
846
-	            $posy=$pdf->GetY()+2;
847
-           	 }
848
-
849
-		// Show payment mode CHQ
833
+             && $object->mode_reglement_code != 'CHQ'
834
+                && $object->mode_reglement_code != 'VIR')
835
+                {
836
+                $pdf->SetFont('','B', $default_font_size - 2);
837
+                $pdf->SetXY($this->marge_gauche, $posy);
838
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
839
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
840
+
841
+                $pdf->SetFont('','', $default_font_size - 2);
842
+                $pdf->SetXY($posxval, $posy);
843
+                $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
844
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
845
+
846
+                $posy=$pdf->GetY()+2;
847
+                }
848
+
849
+        // Show payment mode CHQ
850 850
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
851 851
         {
852
-        	// Si mode reglement non force ou si force a CHQ
853
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
854
-	        {
855
-	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856
-	            {
857
-	                $account = new Account($this->db);
858
-	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859
-
860
-	                $pdf->SetXY($this->marge_gauche, $posy);
861
-	                $pdf->SetFont('','B', $default_font_size - 3);
862
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
863
-		            $posy=$pdf->GetY()+1;
864
-
865
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866
-		            {
867
-		                $pdf->SetXY($this->marge_gauche, $posy);
868
-		                $pdf->SetFont('','', $default_font_size - 3);
869
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
-			            $posy=$pdf->GetY()+2;
871
-		            }
872
-	            }
873
-	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874
-	            {
875
-	                $pdf->SetXY($this->marge_gauche, $posy);
876
-	                $pdf->SetFont('','B', $default_font_size - 3);
877
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
878
-		            $posy=$pdf->GetY()+1;
879
-
880
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881
-		            {
882
-			            $pdf->SetXY($this->marge_gauche, $posy);
883
-		                $pdf->SetFont('','', $default_font_size - 3);
884
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
-			            $posy=$pdf->GetY()+2;
886
-		            }
887
-	            }
888
-	        }
889
-		}
852
+            // Si mode reglement non force ou si force a CHQ
853
+            if (! empty($conf->global->FACTURE_CHQ_NUMBER))
854
+            {
855
+                if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856
+                {
857
+                    $account = new Account($this->db);
858
+                    $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859
+
860
+                    $pdf->SetXY($this->marge_gauche, $posy);
861
+                    $pdf->SetFont('','B', $default_font_size - 3);
862
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
863
+                    $posy=$pdf->GetY()+1;
864
+
865
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866
+                    {
867
+                        $pdf->SetXY($this->marge_gauche, $posy);
868
+                        $pdf->SetFont('','', $default_font_size - 3);
869
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
+                        $posy=$pdf->GetY()+2;
871
+                    }
872
+                }
873
+                if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874
+                {
875
+                    $pdf->SetXY($this->marge_gauche, $posy);
876
+                    $pdf->SetFont('','B', $default_font_size - 3);
877
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
878
+                    $posy=$pdf->GetY()+1;
879
+
880
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881
+                    {
882
+                        $pdf->SetXY($this->marge_gauche, $posy);
883
+                        $pdf->SetFont('','', $default_font_size - 3);
884
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
+                        $posy=$pdf->GetY()+2;
886
+                    }
887
+                }
888
+            }
889
+        }
890 890
 
891 891
         // If payment mode not forced or forced to VIR, show payment with BAN
892 892
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
893 893
         {
894
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
895
-			{
896
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
897
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
898
-				$account = new Account($this->db);
899
-				$account->fetch($bankid);
894
+            if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
895
+            {
896
+                $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
897
+                if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
898
+                $account = new Account($this->db);
899
+                $account->fetch($bankid);
900 900
 
901
-				$curx=$this->marge_gauche;
902
-				$cury=$posy;
901
+                $curx=$this->marge_gauche;
902
+                $cury=$posy;
903 903
 
904
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
904
+                $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
905 905
 
906
-				$posy+=2;
907
-			}
906
+                $posy+=2;
907
+            }
908 908
         }
909 909
 
910
-		return $posy;
911
-	}
910
+        return $posy;
911
+    }
912 912
 
913 913
 
914
-	/**
915
-	 *	Show total to pay
916
-	 *
917
-	 *	@param	TCPDF		$pdf           Object PDF
918
-	 *	@param  Facture		$object         Object invoice
919
-	 *	@param  int			$deja_regle     Montant deja regle
920
-	 *	@param	int			$posy			Position depart
921
-	 *	@param	Translate	$outputlangs	Objet langs
922
-	 *	@return int							Position pour suite
923
-	 */
924
-	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925
-	{
926
-	    global $conf,$mysoc;
914
+    /**
915
+     *	Show total to pay
916
+     *
917
+     *	@param	TCPDF		$pdf           Object PDF
918
+     *	@param  Facture		$object         Object invoice
919
+     *	@param  int			$deja_regle     Montant deja regle
920
+     *	@param	int			$posy			Position depart
921
+     *	@param	Translate	$outputlangs	Objet langs
922
+     *	@return int							Position pour suite
923
+     */
924
+    private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925
+    {
926
+        global $conf,$mysoc;
927 927
 
928
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
928
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
929 929
 
930
-		$tab2_top = $posy;
931
-		$tab2_hl = 4;
932
-		$pdf->SetFont('','', $default_font_size - 1);
930
+        $tab2_top = $posy;
931
+        $tab2_hl = 4;
932
+        $pdf->SetFont('','', $default_font_size - 1);
933 933
 
934
-		// Tableau total
934
+        // Tableau total
935 935
         $col1x = 120; $col2x = 170;
936
-		if ($this->page_largeur < 210) // To work with US executive format
937
-		{
938
-			$col2x-=20;
939
-		}
940
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
936
+        if ($this->page_largeur < 210) // To work with US executive format
937
+        {
938
+            $col2x-=20;
939
+        }
940
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 941
 
942
-		$useborder=0;
943
-		$index = 0;
942
+        $useborder=0;
943
+        $index = 0;
944 944
 
945
-		// Total HT
946
-		$pdf->SetFillColor(255,255,255);
947
-		$pdf->SetXY($col1x, $tab2_top + 0);
948
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
945
+        // Total HT
946
+        $pdf->SetFillColor(255,255,255);
947
+        $pdf->SetXY($col1x, $tab2_top + 0);
948
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
949 949
 
950
-		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
951
-		$pdf->SetXY($col2x, $tab2_top + 0);
952
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
950
+        $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
951
+        $pdf->SetXY($col2x, $tab2_top + 0);
952
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
953 953
 
954
-		// Show VAT by rates and total
955
-		$pdf->SetFillColor(248,248,248);
954
+        // Show VAT by rates and total
955
+        $pdf->SetFillColor(248,248,248);
956 956
 
957
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
957
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
958 958
 
959
-		$this->atleastoneratenotnull=0;
960
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
961
-		{
962
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964
-			{
965
-				// Nothing to do
966
-			}
967
-			else
968
-			{
969
-				//Local tax 1 before VAT
970
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971
-				//{
972
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973
-					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
-						foreach( $localtax_rate as $tvakey => $tvaval )
976
-						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
978
-							{
979
-								//$this->atleastoneratenotnull++;
980
-
981
-								$index++;
982
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983
-
984
-								$tvacompl='';
985
-								if (preg_match('/\*/',$tvakey))
986
-								{
987
-									$tvakey=str_replace('*','',$tvakey);
988
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
989
-								}
990
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
991
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
992
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
993
-
994
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
996
-							}
997
-						}
998
-					}
999
-	      		//}
1000
-				//Local tax 2 before VAT
1001
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002
-				//{
1003
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004
-					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
-						foreach( $localtax_rate as $tvakey => $tvaval )
1007
-						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1009
-							{
1010
-								//$this->atleastoneratenotnull++;
1011
-
1012
-
1013
-
1014
-								$index++;
1015
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016
-
1017
-								$tvacompl='';
1018
-								if (preg_match('/\*/',$tvakey))
1019
-								{
1020
-									$tvakey=str_replace('*','',$tvakey);
1021
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1022
-								}
1023
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
-
1027
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1029
-							}
1030
-						}
1031
-					}
1032
-				//}
1033
-				// VAT
1034
-				foreach($this->tva as $tvakey => $tvaval)
1035
-				{
1036
-					if ($tvakey != 0)    // On affiche pas taux 0
1037
-					{
1038
-						$this->atleastoneratenotnull++;
1039
-
1040
-						$index++;
1041
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042
-
1043
-						$tvacompl='';
1044
-						if (preg_match('/\*/',$tvakey))
1045
-						{
1046
-							$tvakey=str_replace('*','',$tvakey);
1047
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1048
-						}
1049
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1050
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1051
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1052
-
1053
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1055
-					}
1056
-				}
959
+        $this->atleastoneratenotnull=0;
960
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
961
+        {
962
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964
+            {
965
+                // Nothing to do
966
+            }
967
+            else
968
+            {
969
+                //Local tax 1 before VAT
970
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971
+                //{
972
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973
+                    {
974
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
+                        foreach( $localtax_rate as $tvakey => $tvaval )
976
+                        {
977
+                            if ($tvakey!=0)    // On affiche pas taux 0
978
+                            {
979
+                                //$this->atleastoneratenotnull++;
980
+
981
+                                $index++;
982
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983
+
984
+                                $tvacompl='';
985
+                                if (preg_match('/\*/',$tvakey))
986
+                                {
987
+                                    $tvakey=str_replace('*','',$tvakey);
988
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
989
+                                }
990
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
991
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
992
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
993
+
994
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
996
+                            }
997
+                        }
998
+                    }
999
+                    //}
1000
+                //Local tax 2 before VAT
1001
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002
+                //{
1003
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004
+                    {
1005
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1007
+                        {
1008
+                            if ($tvakey!=0)    // On affiche pas taux 0
1009
+                            {
1010
+                                //$this->atleastoneratenotnull++;
1011
+
1012
+
1013
+
1014
+                                $index++;
1015
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016
+
1017
+                                $tvacompl='';
1018
+                                if (preg_match('/\*/',$tvakey))
1019
+                                {
1020
+                                    $tvakey=str_replace('*','',$tvakey);
1021
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1022
+                                }
1023
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1024
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
+
1027
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1029
+                            }
1030
+                        }
1031
+                    }
1032
+                //}
1033
+                // VAT
1034
+                foreach($this->tva as $tvakey => $tvaval)
1035
+                {
1036
+                    if ($tvakey != 0)    // On affiche pas taux 0
1037
+                    {
1038
+                        $this->atleastoneratenotnull++;
1039
+
1040
+                        $index++;
1041
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042
+
1043
+                        $tvacompl='';
1044
+                        if (preg_match('/\*/',$tvakey))
1045
+                        {
1046
+                            $tvakey=str_replace('*','',$tvakey);
1047
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1048
+                        }
1049
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1050
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
1051
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1052
+
1053
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1055
+                    }
1056
+                }
1057 1057
 
1058
-				//Local tax 1 after VAT
1059
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060
-				//{
1061
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062
-					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1064
-
1065
-						foreach( $localtax_rate as $tvakey => $tvaval )
1066
-						{
1067
-							if ($tvakey != 0)    // On affiche pas taux 0
1068
-							{
1069
-								//$this->atleastoneratenotnull++;
1070
-
1071
-								$index++;
1072
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073
-
1074
-								$tvacompl='';
1075
-								if (preg_match('/\*/',$tvakey))
1076
-								{
1077
-									$tvakey=str_replace('*','',$tvakey);
1078
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079
-								}
1080
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1081
-
1082
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086
-							}
1087
-						}
1088
-					}
1089
-	      		//}
1090
-				//Local tax 2 after VAT
1091
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092
-				//{
1093
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094
-					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1096
-
1097
-						foreach( $localtax_rate as $tvakey => $tvaval )
1098
-						{
1099
-							if ($tvakey != 0)    // On affiche pas taux 0
1100
-							{
1101
-								//$this->atleastoneratenotnull++;
1102
-
1103
-								$index++;
1104
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105
-
1106
-								$tvacompl='';
1107
-								if (preg_match('/\*/',$tvakey))
1108
-								{
1109
-									$tvakey=str_replace('*','',$tvakey);
1110
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111
-								}
1112
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1113
-
1114
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116
-
1117
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1119
-							}
1120
-						}
1121
-					}
1122
-				//}
1123
-
1124
-				// Total TTC
1125
-				$index++;
1126
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127
-				$pdf->SetTextColor(0,0,60);
1128
-				$pdf->SetFillColor(224,224,224);
1129
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1130
-
1131
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133
-			}
1134
-		}
1135
-
1136
-		$pdf->SetTextColor(0,0,0);
1058
+                //Local tax 1 after VAT
1059
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060
+                //{
1061
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062
+                    {
1063
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1064
+
1065
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1066
+                        {
1067
+                            if ($tvakey != 0)    // On affiche pas taux 0
1068
+                            {
1069
+                                //$this->atleastoneratenotnull++;
1070
+
1071
+                                $index++;
1072
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073
+
1074
+                                $tvacompl='';
1075
+                                if (preg_match('/\*/',$tvakey))
1076
+                                {
1077
+                                    $tvakey=str_replace('*','',$tvakey);
1078
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079
+                                }
1080
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1081
+
1082
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086
+                            }
1087
+                        }
1088
+                    }
1089
+                    //}
1090
+                //Local tax 2 after VAT
1091
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092
+                //{
1093
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094
+                    {
1095
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1096
+
1097
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1098
+                        {
1099
+                            if ($tvakey != 0)    // On affiche pas taux 0
1100
+                            {
1101
+                                //$this->atleastoneratenotnull++;
1102
+
1103
+                                $index++;
1104
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105
+
1106
+                                $tvacompl='';
1107
+                                if (preg_match('/\*/',$tvakey))
1108
+                                {
1109
+                                    $tvakey=str_replace('*','',$tvakey);
1110
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111
+                                }
1112
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1113
+
1114
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116
+
1117
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1119
+                            }
1120
+                        }
1121
+                    }
1122
+                //}
1123
+
1124
+                // Total TTC
1125
+                $index++;
1126
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127
+                $pdf->SetTextColor(0,0,60);
1128
+                $pdf->SetFillColor(224,224,224);
1129
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1130
+
1131
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133
+            }
1134
+        }
1135
+
1136
+        $pdf->SetTextColor(0,0,0);
1137 1137
 
1138 1138
         $creditnoteamount=0;
1139 1139
         $depositsamount=0;
1140
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
1141
-		//$depositsamount=$object->getSumDepositsUsed();
1142
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1140
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
1141
+        //$depositsamount=$object->getSumDepositsUsed();
1142
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
1143
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
+        if (! empty($object->paye)) $resteapayer=0;
1145 1145
 
1146
-		if ($deja_regle > 0)
1147
-		{
1148
-			// Already paid + Deposits
1149
-			$index++;
1150
-
1151
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1155
-
1156
-			$index++;
1157
-			$pdf->SetTextColor(0,0,60);
1158
-			$pdf->SetFillColor(224,224,224);
1159
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1161
-
1162
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1164
-
1165
-			$pdf->SetFont('','', $default_font_size - 1);
1166
-			$pdf->SetTextColor(0,0,0);
1167
-		}
1168
-
1169
-		$index++;
1170
-		return ($tab2_top + ($tab2_hl * $index));
1171
-	}
1172
-
1173
-	/**
1174
-	 *   Show table for lines
1175
-	 *
1176
-	 *   @param		TCPDF		$pdf     		Object PDF
1177
-	 *   @param		string		$tab_top		Top position of table
1178
-	 *   @param		string		$tab_height		Height of table (rectangle)
1179
-	 *   @param		int			$nexY			Y (not used)
1180
-	 *   @param		Translate	$outputlangs	Langs object
1181
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1182
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1183
-	 *   @param		string		$currency		Currency code
1184
-	 *   @return	void
1185
-	 */
1186
-	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1187
-	{
1188
-		global $conf;
1189
-
1190
-		// Force to disable hidetop and hidebottom
1191
-		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1193
-
1194
-		$currency = !empty($currency) ? $currency : $conf->currency;
1195
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1196
-
1197
-		// Amount in (at tab_top - 1)
1198
-		$pdf->SetTextColor(0,0,0);
1199
-		$pdf->SetFont('','', $default_font_size - 2);
1200
-
1201
-		if (empty($hidetop))
1202
-		{
1203
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1205
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1146
+        if ($deja_regle > 0)
1147
+        {
1148
+            // Already paid + Deposits
1149
+            $index++;
1206 1150
 
1207
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1208
-			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));
1209
-		}
1151
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1210 1155
 
1211
-		$pdf->SetDrawColor(128,128,128);
1212
-		$pdf->SetFont('','', $default_font_size - 1);
1156
+            $index++;
1157
+            $pdf->SetTextColor(0,0,60);
1158
+            $pdf->SetFillColor(224,224,224);
1159
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1213 1161
 
1214
-		// Output Rect
1215
-		$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
1162
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1216 1164
 
1165
+            $pdf->SetFont('','', $default_font_size - 1);
1166
+            $pdf->SetTextColor(0,0,0);
1167
+        }
1217 1168
 
1218
-		foreach ($this->cols as $colKey => $colDef)
1219
-		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1221
-
1222
-		    // get title label
1223
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1224
-
1225
-		    // Add column separator
1226
-		    if(!empty($colDef['border-left'])){
1227
-		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228
-		    }
1229
-
1230
-		    if (empty($hidetop))
1231
-		    {
1232
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1233
-
1234
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1236
-		    }
1237
-		}
1238
-
1239
-		if (empty($hidetop)){
1240
-			$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
1241
-		}
1242
-	}
1243
-
1244
-	/**
1245
-	 *  Show top header of page.
1246
-	 *
1247
-	 *  @param	TCPDF		$pdf     		Object PDF
1248
-	 *  @param  Object		$object     	Object to show
1249
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1250
-	 *  @param  Translate	$outputlangs	Object lang for output
1251
-	 *  @param	string		$titlekey		Translation key to show as title of document
1252
-	 *  @return	void
1253
-	 */
1254
-	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1255
-	{
1256
-		global $conf,$langs,$hookmanager;
1257
-
1258
-		// Translations
1259
-		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260
-
1261
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1262
-
1263
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1264
-
1265
-		// Show Draft Watermark
1266
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1267
-		{
1169
+        $index++;
1170
+        return ($tab2_top + ($tab2_hl * $index));
1171
+    }
1172
+
1173
+    /**
1174
+     *   Show table for lines
1175
+     *
1176
+     *   @param		TCPDF		$pdf     		Object PDF
1177
+     *   @param		string		$tab_top		Top position of table
1178
+     *   @param		string		$tab_height		Height of table (rectangle)
1179
+     *   @param		int			$nexY			Y (not used)
1180
+     *   @param		Translate	$outputlangs	Langs object
1181
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1182
+     *   @param		int			$hidebottom		Hide bottom bar of array
1183
+     *   @param		string		$currency		Currency code
1184
+     *   @return	void
1185
+     */
1186
+    private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1187
+    {
1188
+        global $conf;
1189
+
1190
+        // Force to disable hidetop and hidebottom
1191
+        $hidebottom=0;
1192
+        if ($hidetop) $hidetop=-1;
1193
+
1194
+        $currency = !empty($currency) ? $currency : $conf->currency;
1195
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1196
+
1197
+        // Amount in (at tab_top - 1)
1198
+        $pdf->SetTextColor(0,0,0);
1199
+        $pdf->SetFont('','', $default_font_size - 2);
1200
+
1201
+        if (empty($hidetop))
1202
+        {
1203
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1205
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206
+
1207
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1208
+            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));
1209
+        }
1210
+
1211
+        $pdf->SetDrawColor(128,128,128);
1212
+        $pdf->SetFont('','', $default_font_size - 1);
1213
+
1214
+        // Output Rect
1215
+        $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
1216
+
1217
+
1218
+        foreach ($this->cols as $colKey => $colDef)
1219
+        {
1220
+            if(!$this->getColumnStatus($colKey)) continue;
1221
+
1222
+            // get title label
1223
+            $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1224
+
1225
+            // Add column separator
1226
+            if(!empty($colDef['border-left'])){
1227
+                $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228
+            }
1229
+
1230
+            if (empty($hidetop))
1231
+            {
1232
+                $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1233
+
1234
+                $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
+                $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1236
+            }
1237
+        }
1238
+
1239
+        if (empty($hidetop)){
1240
+            $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
1241
+        }
1242
+    }
1243
+
1244
+    /**
1245
+     *  Show top header of page.
1246
+     *
1247
+     *  @param	TCPDF		$pdf     		Object PDF
1248
+     *  @param  Object		$object     	Object to show
1249
+     *  @param  int	    	$showaddress    0=no, 1=yes
1250
+     *  @param  Translate	$outputlangs	Object lang for output
1251
+     *  @param	string		$titlekey		Translation key to show as title of document
1252
+     *  @return	void
1253
+     */
1254
+    private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1255
+    {
1256
+        global $conf,$langs,$hookmanager;
1257
+
1258
+        // Translations
1259
+        $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260
+
1261
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1262
+
1263
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1264
+
1265
+        // Show Draft Watermark
1266
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1267
+        {
1268 1268
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1269
-		}
1269
+        }
1270 1270
 
1271
-		$pdf->SetTextColor(0,0,60);
1272
-		$pdf->SetFont('','B', $default_font_size + 3);
1271
+        $pdf->SetTextColor(0,0,60);
1272
+        $pdf->SetFont('','B', $default_font_size + 3);
1273 1273
 
1274
-		$posy=$this->marge_haute;
1275
-		$posx=$this->page_largeur-$this->marge_droite-100;
1274
+        $posy=$this->marge_haute;
1275
+        $posx=$this->page_largeur-$this->marge_droite-100;
1276 1276
 
1277
-		$pdf->SetXY($this->marge_gauche,$posy);
1277
+        $pdf->SetXY($this->marge_gauche,$posy);
1278 1278
 
1279
-		// Logo
1280
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281
-		{
1282
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283
-			if ($this->emetteur->logo)
1284
-			{
1285
-				if (is_readable($logo))
1286
-				{
1287
-				    $height=pdf_getHeightForLogo($logo);
1288
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
-				}
1290
-				else
1291
-				{
1292
-					$pdf->SetTextColor(200,0,0);
1293
-					$pdf->SetFont('','B', $default_font_size -2);
1294
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1295
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296
-				}
1297
-			}
1298
-			else
1299
-			{
1300
-				$text=$this->emetteur->name;
1301
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302
-			}
1303
-		}
1304
-
1305
-		$pdf->SetFont('','B', $default_font_size + 3);
1306
-		$pdf->SetXY($posx,$posy);
1307
-		$pdf->SetTextColor(0,0,60);
1308
-		$title=$outputlangs->transnoentities($titlekey);
1309
-		$pdf->MultiCell(100, 3, $title, '', 'R');
1310
-
1311
-		$pdf->SetFont('','B',$default_font_size);
1312
-
1313
-		$posy+=5;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1317
-
1318
-		$posy+=1;
1319
-		$pdf->SetFont('','', $default_font_size - 1);
1320
-
1321
-		if ($object->ref_client)
1322
-		{
1323
-			$posy+=5;
1324
-			$pdf->SetXY($posx,$posy);
1325
-			$pdf->SetTextColor(0,0,60);
1326
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1327
-		}
1328
-
1329
-		$posy+=4;
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1333
-
1334
-		// Get contact
1335
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336
-		{
1337
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1338
-		    if (count($arrayidcontact) > 0)
1339
-		    {
1279
+        // Logo
1280
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281
+        {
1282
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283
+            if ($this->emetteur->logo)
1284
+            {
1285
+                if (is_readable($logo))
1286
+                {
1287
+                    $height=pdf_getHeightForLogo($logo);
1288
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
+                }
1290
+                else
1291
+                {
1292
+                    $pdf->SetTextColor(200,0,0);
1293
+                    $pdf->SetFont('','B', $default_font_size -2);
1294
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1295
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296
+                }
1297
+            }
1298
+            else
1299
+            {
1300
+                $text=$this->emetteur->name;
1301
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302
+            }
1303
+        }
1304
+
1305
+        $pdf->SetFont('','B', $default_font_size + 3);
1306
+        $pdf->SetXY($posx,$posy);
1307
+        $pdf->SetTextColor(0,0,60);
1308
+        $title=$outputlangs->transnoentities($titlekey);
1309
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1310
+
1311
+        $pdf->SetFont('','B',$default_font_size);
1312
+
1313
+        $posy+=5;
1314
+        $pdf->SetXY($posx,$posy);
1315
+        $pdf->SetTextColor(0,0,60);
1316
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1317
+
1318
+        $posy+=1;
1319
+        $pdf->SetFont('','', $default_font_size - 1);
1320
+
1321
+        if ($object->ref_client)
1322
+        {
1323
+            $posy+=5;
1324
+            $pdf->SetXY($posx,$posy);
1325
+            $pdf->SetTextColor(0,0,60);
1326
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1327
+        }
1328
+
1329
+        $posy+=4;
1330
+        $pdf->SetXY($posx,$posy);
1331
+        $pdf->SetTextColor(0,0,60);
1332
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1333
+
1334
+        // Get contact
1335
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336
+        {
1337
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1338
+            if (count($arrayidcontact) > 0)
1339
+            {
1340 1340
                 $usertmp=new User($this->db);
1341
-		        $usertmp->fetch($arrayidcontact[0]);
1341
+                $usertmp->fetch($arrayidcontact[0]);
1342 1342
                 $posy+=4;
1343 1343
                 $pdf->SetXY($posx,$posy);
1344
-		        $pdf->SetTextColor(0,0,60);
1345
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346
-		    }
1347
-		}
1348
-
1349
-		$posy+=2;
1350
-
1351
-		$top_shift = 0;
1352
-		// Show list of linked objects
1353
-		$current_y = $pdf->getY();
1354
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1355
-		if ($current_y < $pdf->getY())
1356
-		{
1357
-			$top_shift = $pdf->getY() - $current_y;
1358
-		}
1344
+                $pdf->SetTextColor(0,0,60);
1345
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346
+            }
1347
+        }
1359 1348
 
1360
-		if ($showaddress)
1361
-		{
1362
-			// Sender properties
1363
-			$carac_emetteur='';
1364
-		 	// Add internal contact of proposal if defined
1365
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1366
-		 	if (count($arrayidcontact) > 0)
1367
-		 	{
1368
-		 		$object->fetch_user($arrayidcontact[0]);
1369
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1370
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1371
-		 	}
1372
-
1373
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374
-
1375
-			// Show sender
1376
-			$posy=42+$top_shift;
1377
-			$posx=$this->marge_gauche;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1379
-			$hautcadre=40;
1380
-
1381
-			// Show sender frame
1382
-			$pdf->SetTextColor(0,0,0);
1383
-			$pdf->SetFont('','', $default_font_size - 2);
1384
-			$pdf->SetXY($posx,$posy-5);
1385
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
-			$pdf->SetXY($posx,$posy);
1387
-			$pdf->SetFillColor(230,230,230);
1388
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
-			$pdf->SetTextColor(0,0,60);
1390
-
1391
-			// Show sender name
1392
-			$pdf->SetXY($posx+2,$posy+3);
1393
-			$pdf->SetFont('','B', $default_font_size);
1394
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
-			$posy=$pdf->getY();
1396
-
1397
-			// Show sender information
1398
-			$pdf->SetXY($posx+2,$posy);
1399
-			$pdf->SetFont('','', $default_font_size - 1);
1400
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401
-
1402
-
1403
-
1404
-			// If CUSTOMER contact defined on order, we use it
1405
-			$usecontact=false;
1406
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1407
-			if (count($arrayidcontact) > 0)
1408
-			{
1409
-				$usecontact=true;
1410
-				$result=$object->fetch_contact($arrayidcontact[0]);
1411
-			}
1412
-
1413
-			//Recipient name
1414
-			// On peut utiliser le nom de la societe du contact
1415
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1416
-				$thirdparty = $object->contact;
1417
-			} else {
1418
-				$thirdparty = $object->thirdparty;
1419
-			}
1420
-
1421
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422
-
1423
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1424
-
1425
-			// Show recipient
1426
-			$widthrecbox=100;
1427
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1428
-			$posy=42+$top_shift;
1429
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1431
-
1432
-			// Show recipient frame
1433
-			$pdf->SetTextColor(0,0,0);
1434
-			$pdf->SetFont('','', $default_font_size - 2);
1435
-			$pdf->SetXY($posx+2,$posy-5);
1436
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1437
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438
-
1439
-			// Show recipient name
1440
-			$pdf->SetXY($posx+2,$posy+3);
1441
-			$pdf->SetFont('','B', $default_font_size);
1442
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443
-
1444
-			$posy = $pdf->getY();
1445
-
1446
-			// Show recipient information
1447
-			$pdf->SetFont('','', $default_font_size - 1);
1448
-			$pdf->SetXY($posx+2,$posy);
1449
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450
-		}
1451
-
1452
-		$pdf->SetTextColor(0,0,0);
1453
-		return $top_shift;
1454
-	}
1455
-
1456
-	/**
1457
-	 *   	Show footer of page. Need this->emetteur object
1349
+        $posy+=2;
1350
+
1351
+        $top_shift = 0;
1352
+        // Show list of linked objects
1353
+        $current_y = $pdf->getY();
1354
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1355
+        if ($current_y < $pdf->getY())
1356
+        {
1357
+            $top_shift = $pdf->getY() - $current_y;
1358
+        }
1359
+
1360
+        if ($showaddress)
1361
+        {
1362
+            // Sender properties
1363
+            $carac_emetteur='';
1364
+                // Add internal contact of proposal if defined
1365
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1366
+                if (count($arrayidcontact) > 0)
1367
+                {
1368
+                    $object->fetch_user($arrayidcontact[0]);
1369
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1370
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1371
+                }
1372
+
1373
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374
+
1375
+            // Show sender
1376
+            $posy=42+$top_shift;
1377
+            $posx=$this->marge_gauche;
1378
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1379
+            $hautcadre=40;
1380
+
1381
+            // Show sender frame
1382
+            $pdf->SetTextColor(0,0,0);
1383
+            $pdf->SetFont('','', $default_font_size - 2);
1384
+            $pdf->SetXY($posx,$posy-5);
1385
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
+            $pdf->SetXY($posx,$posy);
1387
+            $pdf->SetFillColor(230,230,230);
1388
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
+            $pdf->SetTextColor(0,0,60);
1390
+
1391
+            // Show sender name
1392
+            $pdf->SetXY($posx+2,$posy+3);
1393
+            $pdf->SetFont('','B', $default_font_size);
1394
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
+            $posy=$pdf->getY();
1396
+
1397
+            // Show sender information
1398
+            $pdf->SetXY($posx+2,$posy);
1399
+            $pdf->SetFont('','', $default_font_size - 1);
1400
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401
+
1402
+
1403
+
1404
+            // If CUSTOMER contact defined on order, we use it
1405
+            $usecontact=false;
1406
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1407
+            if (count($arrayidcontact) > 0)
1408
+            {
1409
+                $usecontact=true;
1410
+                $result=$object->fetch_contact($arrayidcontact[0]);
1411
+            }
1412
+
1413
+            //Recipient name
1414
+            // On peut utiliser le nom de la societe du contact
1415
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1416
+                $thirdparty = $object->contact;
1417
+            } else {
1418
+                $thirdparty = $object->thirdparty;
1419
+            }
1420
+
1421
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422
+
1423
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1424
+
1425
+            // Show recipient
1426
+            $widthrecbox=100;
1427
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1428
+            $posy=42+$top_shift;
1429
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1431
+
1432
+            // Show recipient frame
1433
+            $pdf->SetTextColor(0,0,0);
1434
+            $pdf->SetFont('','', $default_font_size - 2);
1435
+            $pdf->SetXY($posx+2,$posy-5);
1436
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1437
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438
+
1439
+            // Show recipient name
1440
+            $pdf->SetXY($posx+2,$posy+3);
1441
+            $pdf->SetFont('','B', $default_font_size);
1442
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443
+
1444
+            $posy = $pdf->getY();
1445
+
1446
+            // Show recipient information
1447
+            $pdf->SetFont('','', $default_font_size - 1);
1448
+            $pdf->SetXY($posx+2,$posy);
1449
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450
+        }
1451
+
1452
+        $pdf->SetTextColor(0,0,0);
1453
+        return $top_shift;
1454
+    }
1455
+
1456
+    /**
1457
+     *   	Show footer of page. Need this->emetteur object
1458
+     *
1459
+     *   	@param	TCPDF		$pdf     			PDF
1460
+     * 		@param	Object		$object				Object to show
1461
+     *      @param	Translate	$outputlangs		Object lang for output
1462
+     *      @param	int			$hidefreetext		1=Hide free text
1463
+     *      @return	int								Return height of bottom margin including footer text
1464
+     */
1465
+    private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1466
+    {
1467
+        global $conf;
1468
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
+        return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1470
+    }
1471
+
1472
+
1473
+
1474
+    /**
1475
+     *   	Define Array Column Field
1458 1476
      *
1459
-	 *   	@param	TCPDF		$pdf     			PDF
1460
-	 * 		@param	Object		$object				Object to show
1461
-	 *      @param	Translate	$outputlangs		Object lang for output
1462
-	 *      @param	int			$hidefreetext		1=Hide free text
1463
-	 *      @return	int								Return height of bottom margin including footer text
1464
-	 */
1465
-	private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1466
-	{
1467
-		global $conf;
1468
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1470
-	}
1471
-
1472
-
1473
-
1474
-	/**
1475
-	 *   	Define Array Column Field
1476
-	 *
1477
-	 *   	@param	object			$object    		common object
1478
-	 *   	@param	Translate		$outputlangs    langs
1479
-	 *      @param	int				$hidedetails	Do not show line details
1480
-	 *      @param	int				$hidedesc		Do not show desc
1481
-	 *      @param	int				$hideref		Do not show ref
1482
-	 *      @return	null
1483
-	 */
1477
+     *   	@param	object			$object    		common object
1478
+     *   	@param	Translate		$outputlangs    langs
1479
+     *      @param	int				$hidedetails	Do not show line details
1480
+     *      @param	int				$hidedesc		Do not show desc
1481
+     *      @param	int				$hideref		Do not show ref
1482
+     *      @return	null
1483
+     */
1484 1484
     public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1485 1485
     {
1486
-	    global $conf, $hookmanager;
1486
+        global $conf, $hookmanager;
1487 1487
 
1488
-	    // Default field style for content
1489
-	    $this->defaultContentsFieldsStyle = array(
1490
-	        'align' => 'R', // R,C,L
1491
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1492
-	    );
1488
+        // Default field style for content
1489
+        $this->defaultContentsFieldsStyle = array(
1490
+            'align' => 'R', // R,C,L
1491
+            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1492
+        );
1493 1493
 
1494
-	    // Default field style for content
1495
-	    $this->defaultTitlesFieldsStyle = array(
1496
-	        'align' => 'C', // R,C,L
1497
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1498
-	    );
1494
+        // Default field style for content
1495
+        $this->defaultTitlesFieldsStyle = array(
1496
+            'align' => 'C', // R,C,L
1497
+            'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1498
+        );
1499 1499
 
1500
-	    /*
1500
+        /*
1501 1501
 	     * For exemple
1502 1502
 	     $this->cols['theColKey'] = array(
1503 1503
 	     'rank' => $rank, // int : use for ordering columns
@@ -1515,158 +1515,158 @@  discard block
 block discarded – undo
1515 1515
 	     );
1516 1516
 	     */
1517 1517
 
1518
-	    $rank=0; // do not use negative rank
1519
-	    $this->cols['desc'] = array(
1520
-	        'rank' => $rank,
1521
-	        'width' => false, // only for desc
1522
-	        'status' => true,
1523
-	        'title' => array(
1524
-	            'textkey' => 'Designation', // use lang key is usefull in somme case with module
1525
-	            'align' => 'L',
1526
-	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1527
-	            // 'label' => ' ', // the final label
1528
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1529
-	        ),
1530
-	        'content' => array(
1531
-	            'align' => 'L',
1532
-	        ),
1533
-	    );
1534
-
1535
-	    $rank = $rank + 10;
1536
-	    $this->cols['photo'] = array(
1537
-	        'rank' => $rank,
1538
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539
-	        'status' => false,
1540
-	        'title' => array(
1541
-	            'textkey' => 'Photo',
1542
-	            'label' => ' '
1543
-	        ),
1544
-	        'content' => array(
1545
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546
-	        ),
1547
-	        'border-left' => false, // remove left line separator
1548
-	    );
1549
-
1550
-	    if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551
-	    {
1552
-	        $this->cols['photo']['status'] = true;
1553
-	    }
1554
-
1555
-
1556
-	    $rank = $rank + 10;
1557
-	    $this->cols['vat'] = array(
1558
-	        'rank' => $rank,
1559
-	        'status' => false,
1560
-	        'width' => 16, // in mm
1561
-	        'title' => array(
1562
-	            'textkey' => 'VAT'
1563
-	        ),
1564
-	        'border-left' => true, // add left line separator
1565
-	    );
1566
-
1567
-	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1568
-	    {
1569
-	        $this->cols['vat']['status'] = true;
1570
-	    }
1571
-
1572
-	    $rank = $rank + 10;
1573
-	    $this->cols['subprice'] = array(
1574
-	        'rank' => $rank,
1575
-	        'width' => 19, // in mm
1576
-	        'status' => true,
1577
-	        'title' => array(
1578
-	            'textkey' => 'PriceUHT'
1579
-	        ),
1580
-	        'border-left' => true, // add left line separator
1581
-	    );
1582
-
1583
-	    $rank = $rank + 10;
1584
-	    $this->cols['qty'] = array(
1585
-	        'rank' => $rank,
1586
-	        'width' => 16, // in mm
1587
-	        'status' => true,
1588
-	        'title' => array(
1589
-	            'textkey' => 'Qty'
1590
-	        ),
1591
-	        'border-left' => true, // add left line separator
1592
-	    );
1593
-
1594
-	    $rank = $rank + 10;
1595
-	    $this->cols['progress'] = array(
1596
-	        'rank' => $rank,
1597
-	        'width' => 19, // in mm
1598
-	        'status' => false,
1599
-	        'title' => array(
1600
-	            'textkey' => 'Progress'
1601
-	        ),
1602
-	        'border-left' => false, // add left line separator
1603
-	    );
1604
-
1605
-	    if($this->situationinvoice)
1606
-	    {
1607
-	        $this->cols['progress']['status'] = true;
1608
-	    }
1609
-
1610
-	    $rank = $rank + 10;
1611
-	    $this->cols['unit'] = array(
1612
-	        'rank' => $rank,
1613
-	        'width' => 11, // in mm
1614
-	        'status' => false,
1615
-	        'title' => array(
1616
-	            'textkey' => 'Unit'
1617
-	        ),
1618
-	        'border-left' => true, // add left line separator
1619
-	    );
1620
-	    if($conf->global->PRODUCT_USE_UNITS){
1621
-	        $this->cols['unit']['status'] = true;
1622
-	    }
1623
-
1624
-	    $rank = $rank + 10;
1625
-	    $this->cols['discount'] = array(
1626
-	        'rank' => $rank,
1627
-	        'width' => 13, // in mm
1628
-	        'status' => false,
1629
-	        'title' => array(
1630
-	            'textkey' => 'ReductionShort'
1631
-	        ),
1632
-	        'border-left' => true, // add left line separator
1633
-	    );
1634
-	    if ($this->atleastonediscount){
1635
-	        $this->cols['discount']['status'] = true;
1636
-	    }
1637
-
1638
-	    $rank = $rank + 10;
1639
-	    $this->cols['totalexcltax'] = array(
1640
-	        'rank' => $rank,
1641
-	        'width' => 26, // in mm
1642
-	        'status' => true,
1643
-	        'title' => array(
1644
-	            'textkey' => 'TotalHT'
1645
-	        ),
1646
-	        'border-left' => true, // add left line separator
1647
-	    );
1648
-
1649
-
1650
-	    $parameters=array(
1651
-	        'object' => $object,
1652
-	        'outputlangs' => $outputlangs,
1653
-	        'hidedetails' => $hidedetails,
1654
-	        'hidedesc' => $hidedesc,
1655
-	        'hideref' => $hideref
1656
-	    );
1657
-
1658
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1659
-	    if ($reshook < 0)
1660
-	    {
1661
-	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
-	    }
1663
-	    elseif (empty($reshook))
1664
-	    {
1665
-	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
-	    }
1667
-	    else
1668
-	    {
1669
-	        $this->cols = $hookmanager->resArray;
1670
-	    }
1671
-	}
1518
+        $rank=0; // do not use negative rank
1519
+        $this->cols['desc'] = array(
1520
+            'rank' => $rank,
1521
+            'width' => false, // only for desc
1522
+            'status' => true,
1523
+            'title' => array(
1524
+                'textkey' => 'Designation', // use lang key is usefull in somme case with module
1525
+                'align' => 'L',
1526
+                // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1527
+                // 'label' => ' ', // the final label
1528
+                'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1529
+            ),
1530
+            'content' => array(
1531
+                'align' => 'L',
1532
+            ),
1533
+        );
1534
+
1535
+        $rank = $rank + 10;
1536
+        $this->cols['photo'] = array(
1537
+            'rank' => $rank,
1538
+            'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539
+            'status' => false,
1540
+            'title' => array(
1541
+                'textkey' => 'Photo',
1542
+                'label' => ' '
1543
+            ),
1544
+            'content' => array(
1545
+                'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546
+            ),
1547
+            'border-left' => false, // remove left line separator
1548
+        );
1549
+
1550
+        if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551
+        {
1552
+            $this->cols['photo']['status'] = true;
1553
+        }
1554
+
1555
+
1556
+        $rank = $rank + 10;
1557
+        $this->cols['vat'] = array(
1558
+            'rank' => $rank,
1559
+            'status' => false,
1560
+            'width' => 16, // in mm
1561
+            'title' => array(
1562
+                'textkey' => 'VAT'
1563
+            ),
1564
+            'border-left' => true, // add left line separator
1565
+        );
1566
+
1567
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1568
+        {
1569
+            $this->cols['vat']['status'] = true;
1570
+        }
1571
+
1572
+        $rank = $rank + 10;
1573
+        $this->cols['subprice'] = array(
1574
+            'rank' => $rank,
1575
+            'width' => 19, // in mm
1576
+            'status' => true,
1577
+            'title' => array(
1578
+                'textkey' => 'PriceUHT'
1579
+            ),
1580
+            'border-left' => true, // add left line separator
1581
+        );
1582
+
1583
+        $rank = $rank + 10;
1584
+        $this->cols['qty'] = array(
1585
+            'rank' => $rank,
1586
+            'width' => 16, // in mm
1587
+            'status' => true,
1588
+            'title' => array(
1589
+                'textkey' => 'Qty'
1590
+            ),
1591
+            'border-left' => true, // add left line separator
1592
+        );
1593
+
1594
+        $rank = $rank + 10;
1595
+        $this->cols['progress'] = array(
1596
+            'rank' => $rank,
1597
+            'width' => 19, // in mm
1598
+            'status' => false,
1599
+            'title' => array(
1600
+                'textkey' => 'Progress'
1601
+            ),
1602
+            'border-left' => false, // add left line separator
1603
+        );
1604
+
1605
+        if($this->situationinvoice)
1606
+        {
1607
+            $this->cols['progress']['status'] = true;
1608
+        }
1609
+
1610
+        $rank = $rank + 10;
1611
+        $this->cols['unit'] = array(
1612
+            'rank' => $rank,
1613
+            'width' => 11, // in mm
1614
+            'status' => false,
1615
+            'title' => array(
1616
+                'textkey' => 'Unit'
1617
+            ),
1618
+            'border-left' => true, // add left line separator
1619
+        );
1620
+        if($conf->global->PRODUCT_USE_UNITS){
1621
+            $this->cols['unit']['status'] = true;
1622
+        }
1623
+
1624
+        $rank = $rank + 10;
1625
+        $this->cols['discount'] = array(
1626
+            'rank' => $rank,
1627
+            'width' => 13, // in mm
1628
+            'status' => false,
1629
+            'title' => array(
1630
+                'textkey' => 'ReductionShort'
1631
+            ),
1632
+            'border-left' => true, // add left line separator
1633
+        );
1634
+        if ($this->atleastonediscount){
1635
+            $this->cols['discount']['status'] = true;
1636
+        }
1637
+
1638
+        $rank = $rank + 10;
1639
+        $this->cols['totalexcltax'] = array(
1640
+            'rank' => $rank,
1641
+            'width' => 26, // in mm
1642
+            'status' => true,
1643
+            'title' => array(
1644
+                'textkey' => 'TotalHT'
1645
+            ),
1646
+            'border-left' => true, // add left line separator
1647
+        );
1648
+
1649
+
1650
+        $parameters=array(
1651
+            'object' => $object,
1652
+            'outputlangs' => $outputlangs,
1653
+            'hidedetails' => $hidedetails,
1654
+            'hidedesc' => $hidedesc,
1655
+            'hideref' => $hideref
1656
+        );
1657
+
1658
+        $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1659
+        if ($reshook < 0)
1660
+        {
1661
+            setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
+        }
1663
+        elseif (empty($reshook))
1664
+        {
1665
+            $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
+        }
1667
+        else
1668
+        {
1669
+            $this->cols = $hookmanager->resArray;
1670
+        }
1671
+    }
1672 1672
 }
Please login to merge, or discard this patch.
Spacing   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	public $marge_haute;
88 88
 	public $marge_basse;
89 89
 
90
-    public $emetteur;	// Objet societe qui emet
90
+    public $emetteur; // Objet societe qui emet
91 91
 
92 92
 
93 93
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function __construct($db)
99 99
 	{
100
-		global $conf,$langs,$mysoc;
100
+		global $conf, $langs, $mysoc;
101 101
 
102 102
 		// Translations
103 103
 		$langs->loadLangs(array("main", "bills", "products"));
@@ -105,45 +105,45 @@  discard block
 block discarded – undo
105 105
 		$this->db = $db;
106 106
 		$this->name = "eratosthene";
107 107
 		$this->description = $langs->trans('PDFEratostheneDescription');
108
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
108
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
109 109
 
110 110
 		// Dimension page
111 111
 		$this->type = 'pdf';
112
-		$formatarray=pdf_getFormat();
112
+		$formatarray = pdf_getFormat();
113 113
 		$this->page_largeur = $formatarray['width'];
114 114
 		$this->page_hauteur = $formatarray['height'];
115
-		$this->format = array($this->page_largeur,$this->page_hauteur);
116
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
117
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
118
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
119
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
120
-
121
-		$this->option_logo = 1;                    // Affiche logo
122
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
123
-		$this->option_modereg = 1;                 // Affiche mode reglement
124
-		$this->option_condreg = 1;                 // Affiche conditions reglement
125
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
126
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
127
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
128
-		$this->option_credit_note = 0;             // Support credit notes
129
-		$this->option_freetext = 1;				   // Support add of a personalised text
130
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
131
-
132
-		$this->franchise=!$mysoc->tva_assuj;
115
+		$this->format = array($this->page_largeur, $this->page_hauteur);
116
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
117
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
118
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
119
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
120
+
121
+		$this->option_logo = 1; // Affiche logo
122
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
123
+		$this->option_modereg = 1; // Affiche mode reglement
124
+		$this->option_condreg = 1; // Affiche conditions reglement
125
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
126
+		$this->option_multilang = 1; // Dispo en plusieurs langues
127
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
128
+		$this->option_credit_note = 0; // Support credit notes
129
+		$this->option_freetext = 1; // Support add of a personalised text
130
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
131
+
132
+		$this->franchise = !$mysoc->tva_assuj;
133 133
 
134 134
 		// Get source company
135
-		$this->emetteur=$mysoc;
136
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
135
+		$this->emetteur = $mysoc;
136
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
137 137
 
138 138
 		// Define position of columns
139
-		$this->posxdesc=$this->marge_gauche+1;
139
+		$this->posxdesc = $this->marge_gauche + 1;
140 140
 
141 141
 
142
-		$this->tva=array();
143
-		$this->localtax1=array();
144
-		$this->localtax2=array();
145
-		$this->atleastoneratenotnull=0;
146
-		$this->atleastonediscount=0;
142
+		$this->tva = array();
143
+		$this->localtax1 = array();
144
+		$this->localtax2 = array();
145
+		$this->atleastoneratenotnull = 0;
146
+		$this->atleastonediscount = 0;
147 147
 	}
148 148
 
149 149
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
      *  @param		int			$hideref			Do not show ref
159 159
      *  @return     int             			    1=OK, 0=KO
160 160
 	 */
161
-	public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
161
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
162 162
 	{
163 163
 	    // phpcs:enable
164 164
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 165
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
166
+		if (!is_object($outputlangs)) $outputlangs = $langs;
167 167
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
168
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
168
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
169 169
 
170 170
 		// Translations
171 171
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
 			if ($object->specimen)
183 183
 			{
184 184
 				$dir = $conf->commande->dir_output;
185
-				$file = $dir . "/SPECIMEN.pdf";
185
+				$file = $dir."/SPECIMEN.pdf";
186 186
 			}
187 187
 			else
188 188
 			{
189 189
 				$objectref = dol_sanitizeFileName($object->ref);
190
-				$dir = $conf->commande->dir_output . "/" . $objectref;
191
-				$file = $dir . "/" . $objectref . ".pdf";
190
+				$dir = $conf->commande->dir_output."/".$objectref;
191
+				$file = $dir."/".$objectref.".pdf";
192 192
 			}
193 193
 
194
-			if (! file_exists($dir))
194
+			if (!file_exists($dir))
195 195
 			{
196 196
 				if (dol_mkdir($dir) < 0)
197 197
 				{
198
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
198
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
199 199
 					return 0;
200 200
 				}
201 201
 			}
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
 			if (file_exists($dir))
204 204
 			{
205 205
 				// Add pdfgeneration hook
206
-				if (! is_object($hookmanager))
206
+				if (!is_object($hookmanager))
207 207
 				{
208 208
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
-					$hookmanager=new HookManager($this->db);
209
+					$hookmanager = new HookManager($this->db);
210 210
 				}
211 211
 				$hookmanager->initHooks(array('pdfgeneration'));
212
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
212
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
213 213
 				global $action;
214
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
214
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
215 215
 
216 216
 				// Create pdf instance
217
-				$pdf=pdf_getInstance($this->format);
218
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
219
-				$pdf->SetAutoPageBreak(1,0);
217
+				$pdf = pdf_getInstance($this->format);
218
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
219
+				$pdf->SetAutoPageBreak(1, 0);
220 220
 
221
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
222
-		        $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
223
-		        $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22);	// Height reserved to output the footer (value include bottom margin)
221
+				$heightforinfotot = 40; // Height reserved to output the info and total part
222
+		        $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
223
+		        $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
224 224
 
225 225
                 if (class_exists('TCPDF'))
226 226
                 {
@@ -229,28 +229,28 @@  discard block
 block discarded – undo
229 229
                 }
230 230
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
231 231
                 // Set path to the background PDF File
232
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
232
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
233 233
                 {
234 234
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
235 235
                     $tplidx = $pdf->importPage(1);
236 236
                 }
237 237
 
238 238
 				$pdf->Open();
239
-				$pagenb=0;
240
-				$pdf->SetDrawColor(128,128,128);
239
+				$pagenb = 0;
240
+				$pdf->SetDrawColor(128, 128, 128);
241 241
 
242 242
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243 243
 				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244 244
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245 245
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246 246
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
247
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
247
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
248 248
 
249
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
249
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
250 250
 
251 251
 				/// Does we have at least one line with discount $this->atleastonediscount
252 252
 				foreach ($object->lines as $line) {
253
-				    if ($line->remise_percent){
253
+				    if ($line->remise_percent) {
254 254
 				        $this->atleastonediscount = true;
255 255
 				        break;
256 256
 				    }
@@ -258,26 +258,26 @@  discard block
 block discarded – undo
258 258
 
259 259
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
260 260
 				{
261
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
262
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
263
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
264
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
265
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
261
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
262
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
263
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
264
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
265
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
266 266
 					//$this->postotalht;
267 267
 				}
268 268
 
269 269
 				// New page
270 270
 				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
271
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
272 272
 				$pagenb++;
273 273
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274
-				$pdf->SetFont('','', $default_font_size - 1);
275
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
276
-				$pdf->SetTextColor(0,0,0);
274
+				$pdf->SetFont('', '', $default_font_size - 1);
275
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
276
+				$pdf->SetTextColor(0, 0, 0);
277 277
 
278 278
 
279
-				$tab_top = 90+$top_shift;
280
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
279
+				$tab_top = 90 + $top_shift;
280
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
281 281
 
282 282
 				// Incoterm
283 283
 				if ($conf->incoterm->enabled)
@@ -287,40 +287,40 @@  discard block
 block discarded – undo
287 287
 					{
288 288
 						$tab_top -= 2;
289 289
 
290
-						$pdf->SetFont('','', $default_font_size - 1);
291
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
290
+						$pdf->SetFont('', '', $default_font_size - 1);
291
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
292 292
 						$nexY = $pdf->GetY();
293
-						$height_incoterms=$nexY-$tab_top;
293
+						$height_incoterms = $nexY - $tab_top;
294 294
 
295 295
 						// Rect prend une longueur en 3eme param
296
-						$pdf->SetDrawColor(192,192,192);
297
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
296
+						$pdf->SetDrawColor(192, 192, 192);
297
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
298 298
 
299
-						$tab_top = $nexY+6;
299
+						$tab_top = $nexY + 6;
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Affiche notes
304
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
305
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
304
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
305
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306 306
 				{
307 307
 					// Get first sale rep
308 308
 					if (is_object($object->thirdparty))
309 309
 					{
310
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
-						$salerepobj=new User($this->db);
310
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
311
+						$salerepobj = new User($this->db);
312 312
 						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
313
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
314 314
 					}
315 315
 				}
316 316
 
317 317
 				$pagenb = $pdf->getPage();
318 318
 				if ($notetoshow)
319 319
 				{
320
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
320
+				    $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
321 321
 				    $pageposbeforenote = $pagenb;
322 322
 
323
-				    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
323
+				    $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
324 324
 				    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325 325
 				    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326 326
 
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 
329 329
 				    $pdf->startTransaction();
330 330
 
331
-				    $pdf->SetFont('','', $default_font_size - 1);
332
-				    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
331
+				    $pdf->SetFont('', '', $default_font_size - 1);
332
+				    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333 333
 				    // Description
334
-				    $pageposafternote=$pdf->getPage();
334
+				    $pageposafternote = $pdf->getPage();
335 335
 				    $posyafter = $pdf->GetY();
336 336
 
337
-				    if($pageposafternote>$pageposbeforenote )
337
+				    if ($pageposafternote > $pageposbeforenote)
338 338
 				    {
339 339
 				        $pdf->rollbackTransaction(true);
340 340
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				        while ($pagenb < $pageposafternote) {
343 343
 				            $pdf->AddPage();
344 344
 				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
345
+				            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
346 346
 				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347 347
 				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348 348
 				            $pdf->setTopMargin($tab_top_newpage);
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
 				        // back to start
354 354
 				        $pdf->setPage($pageposbeforenote);
355 355
 				        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
356
-				        $pdf->SetFont('','', $default_font_size - 1);
357
-				        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
-				        $pageposafternote=$pdf->getPage();
356
+				        $pdf->SetFont('', '', $default_font_size - 1);
357
+				        $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
+				        $pageposafternote = $pdf->getPage();
359 359
 
360 360
 				        $posyafter = $pdf->GetY();
361 361
 
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
362
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
363 363
 				        {
364
-				            $pdf->AddPage('','',true);
364
+				            $pdf->AddPage('', '', true);
365 365
 				            $pagenb++;
366 366
 				            $pageposafternote++;
367 367
 				            $pdf->setPage($pageposafternote);
@@ -378,47 +378,47 @@  discard block
 block discarded – undo
378 378
 				            $pdf->setPage($i);
379 379
 
380 380
 
381
-				            $pdf->SetDrawColor(128,128,128);
381
+				            $pdf->SetDrawColor(128, 128, 128);
382 382
 				            // Draw note frame
383
-				            if($i>$pageposbeforenote){
383
+				            if ($i > $pageposbeforenote) {
384 384
 				                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385
-				                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
385
+				                $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
386 386
 				            }
387
-				            else{
387
+				            else {
388 388
 				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
-				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
389
+				                $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
390 390
 				            }
391 391
 
392 392
 				            // Add footer
393
-				            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
394
-				            $this->_pagefoot($pdf,$object,$outputlangs,1);
393
+				            $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
394
+				            $this->_pagefoot($pdf, $object, $outputlangs, 1);
395 395
 
396 396
 				            $i++;
397 397
 				        }
398 398
 
399 399
 				        // apply note frame to last page
400 400
 				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
401
+				        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
402 402
 				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
403
-				        $height_note=$posyafter-$tab_top_newpage;
404
-				        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
403
+				        $height_note = $posyafter - $tab_top_newpage;
404
+				        $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
405 405
 				    }
406 406
 				    else // No pagebreak
407 407
 				    {
408 408
 				        $pdf->commitTransaction();
409 409
 				        $posyafter = $pdf->GetY();
410
-				        $height_note=$posyafter-$tab_top;
411
-				        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
410
+				        $height_note = $posyafter - $tab_top;
411
+				        $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
412 412
 
413 413
 
414
-				        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
414
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
415 415
 				        {
416 416
 				            // not enough space, need to add page
417
-				            $pdf->AddPage('','',true);
417
+				            $pdf->AddPage('', '', true);
418 418
 				            $pagenb++;
419 419
 				            $pageposafternote++;
420 420
 				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
421
+				            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
422 422
 				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423 423
 
424 424
 				            $posyafter = $tab_top_newpage;
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 				    }
427 427
 
428 428
 				    $tab_height = $tab_height - $height_note;
429
-				    $tab_top = $posyafter +6;
429
+				    $tab_top = $posyafter + 6;
430 430
 				}
431 431
 				else
432 432
 				{
433
-					$height_note=0;
433
+					$height_note = 0;
434 434
 				}
435 435
 
436 436
 				$iniY = $tab_top + 7;
@@ -438,83 +438,83 @@  discard block
 block discarded – undo
438 438
 				$nexY = $tab_top + 7;
439 439
 
440 440
 				// Use new auto collum system
441
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
441
+				$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
442 442
 
443 443
 				// Loop on each lines
444
-				$pageposbeforeprintlines=$pdf->getPage();
444
+				$pageposbeforeprintlines = $pdf->getPage();
445 445
 				$pagenb = $pageposbeforeprintlines;
446
-				for ($i = 0 ; $i < $nblignes ; $i++)
446
+				for ($i = 0; $i < $nblignes; $i++)
447 447
 				{
448 448
 					$curY = $nexY;
449
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
-					$pdf->SetTextColor(0,0,0);
449
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
450
+					$pdf->SetTextColor(0, 0, 0);
451 451
 
452 452
 					$pdf->setTopMargin($tab_top_newpage);
453
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
454
-					$pageposbefore=$pdf->getPage();
453
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
454
+					$pageposbefore = $pdf->getPage();
455 455
 
456 456
 					// Description of product line
457
-					$curX = $this->posxdesc-1;
457
+					$curX = $this->posxdesc - 1;
458 458
 
459
-					$showpricebeforepagebreak=1;
459
+					$showpricebeforepagebreak = 1;
460 460
 
461
-					if($this->getColumnStatus('desc'))
461
+					if ($this->getColumnStatus('desc'))
462 462
 					{
463 463
     					$pdf->startTransaction();
464
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
-    					$pageposafter=$pdf->getPage();
464
+    					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
465
+    					$pageposafter = $pdf->getPage();
466 466
     					if ($pageposafter > $pageposbefore)	// There is a pagebreak
467 467
     					{
468 468
     						$pdf->rollbackTransaction(true);
469
-    						$pageposafter=$pageposbefore;
469
+    						$pageposafter = $pageposbefore;
470 470
     						//print $pageposafter.'-'.$pageposbefore;exit;
471
-    						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472
-    						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473
-    						$pageposafter=$pdf->getPage();
474
-    						$posyafter=$pdf->GetY();
475
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
471
+    						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
472
+    						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
473
+    						$pageposafter = $pdf->getPage();
474
+    						$posyafter = $pdf->GetY();
475
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
476 476
     						{
477
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
477
+    							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
478 478
     							{
479
-    								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
479
+    								$pdf->AddPage('', '', true);
480
+    								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
481 481
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
-    								$pdf->setPage($pageposafter+1);
482
+    								$pdf->setPage($pageposafter + 1);
483 483
     							}
484 484
     						}
485 485
     						else
486 486
     						{
487 487
     							// We found a page break
488
-    							$showpricebeforepagebreak=0;
488
+    							$showpricebeforepagebreak = 0;
489 489
     						}
490 490
     					}
491 491
     					else	// No pagebreak
492 492
     					{
493 493
     						$pdf->commitTransaction();
494 494
     					}
495
-    					$posYAfterDescription=$pdf->GetY();
495
+    					$posYAfterDescription = $pdf->GetY();
496 496
 					}
497 497
 
498 498
 					$nexY = $pdf->GetY();
499
-					$pageposafter=$pdf->getPage();
499
+					$pageposafter = $pdf->getPage();
500 500
 
501 501
 					$pdf->setPage($pageposbefore);
502 502
 					$pdf->setTopMargin($this->marge_haute);
503
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
503
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
504 504
 
505 505
 					// We suppose that a too long description is moved completely on next page
506 506
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507 507
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508 508
 					}
509 509
 
510
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
510
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
511 511
 
512 512
 					// VAT Rate
513 513
 					if ($this->getColumnStatus('vat'))
514 514
 					{
515 515
 					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516 516
 					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
-					    $nexY = max($pdf->GetY(),$nexY);
517
+					    $nexY = max($pdf->GetY(), $nexY);
518 518
 					}
519 519
 
520 520
 					// Unit price before discount
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 					{
523 523
 					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524 524
 					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
-					    $nexY = max($pdf->GetY(),$nexY);
525
+					    $nexY = max($pdf->GetY(), $nexY);
526 526
 					}
527 527
 
528 528
 					// Quantity
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 					{
532 532
 					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533 533
 					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
-					    $nexY = max($pdf->GetY(),$nexY);
534
+					    $nexY = max($pdf->GetY(), $nexY);
535 535
 					}
536 536
 
537 537
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 					{
541 541
 					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542 542
 					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
-					    $nexY = max($pdf->GetY(),$nexY);
543
+					    $nexY = max($pdf->GetY(), $nexY);
544 544
 					}
545 545
 
546 546
 					// Discount on line
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 					{
549 549
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550 550
 					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
-					    $nexY = max($pdf->GetY(),$nexY);
551
+					    $nexY = max($pdf->GetY(), $nexY);
552 552
 					}
553 553
 
554 554
 					// Total HT line
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
 					{
557 557
 					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558 558
 					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
-					    $nexY = max($pdf->GetY(),$nexY);
559
+					    $nexY = max($pdf->GetY(), $nexY);
560 560
 					}
561 561
 
562 562
 
563
-					$parameters=array(
563
+					$parameters = array(
564 564
 					    'object' => $object,
565 565
 					    'i' => $i,
566 566
 					    'pdf' =>& $pdf,
@@ -569,56 +569,56 @@  discard block
 block discarded – undo
569 569
 					    'outputlangs' => $outputlangs,
570 570
 					    'hidedetails' => $hidedetails
571 571
 					);
572
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
572
+					$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
573 573
 
574 574
 
575 575
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
577
-					else $tvaligne=$object->lines[$i]->total_tva;
576
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
577
+					else $tvaligne = $object->lines[$i]->total_tva;
578 578
 
579
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
580
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
581
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
582
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
583
-					$localtax1_type=$object->lines[$i]->localtax1_type;
584
-					$localtax2_type=$object->lines[$i]->localtax2_type;
579
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
580
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
581
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
582
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
583
+					$localtax1_type = $object->lines[$i]->localtax1_type;
584
+					$localtax2_type = $object->lines[$i]->localtax2_type;
585 585
 
586
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
587
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
588
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
586
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
587
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
588
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
589 589
 
590
-					$vatrate=(string) $object->lines[$i]->tva_tx;
590
+					$vatrate = (string) $object->lines[$i]->tva_tx;
591 591
 
592 592
 					// Retrieve type from database for backward compatibility with old records
593
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
594
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
593
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
594
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
595 595
 					{
596
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
596
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
597 597
 						$localtax1_type = $localtaxtmp_array[0];
598 598
 						$localtax2_type = $localtaxtmp_array[2];
599 599
 					}
600 600
 
601 601
 				    // retrieve global local tax
602 602
 					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
603
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
604 604
 					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
605
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
606 606
 
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
607
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
608
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
609 609
 					$this->tva[$vatrate] += $tvaligne;
610 610
 
611 611
 					// Add line
612
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
612
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613 613
 					{
614 614
 						$pdf->setPage($pageposafter);
615
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
615
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
616 616
 						//$pdf->SetDrawColor(190,190,200);
617
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
617
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
618 618
 						$pdf->SetLineStyle(array('dash'=>0));
619 619
 					}
620 620
 
621
-					$nexY+=2;    // Passe espace entre les lignes
621
+					$nexY += 2; // Passe espace entre les lignes
622 622
 
623 623
 					// Detect if some page were added automatically and output _tableau for past pages
624 624
 					while ($pagenb < $pageposafter)
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
 						{
633 633
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 634
 						}
635
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
635
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
636 636
 						$pagenb++;
637 637
 						$pdf->setPage($pagenb);
638
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
638
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
639 639
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640 640
 					}
641
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
641
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
642 642
 					{
643 643
 					    if ($pagenb == $pageposafter)
644 644
 						{
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
 						{
649 649
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650 650
 						}
651
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
651
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
652 652
 						// New page
653 653
 						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
654
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
655 655
 						$pagenb++;
656 656
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657 657
 					}
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663 663
 				else
664 664
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
665
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
665
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 666
 
667 667
 				// Affiche zone infos
668
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
668
+				$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
669 669
 
670 670
 				// Affiche zone totaux
671
-				$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
671
+				$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
672 672
 
673 673
 				// Affiche zone versements
674 674
 				/*
@@ -688,26 +688,26 @@  discard block
 block discarded – undo
688 688
 
689 689
 				// Add pdfgeneration hook
690 690
 				$hookmanager->initHooks(array('pdfgeneration'));
691
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
691
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692 692
 				global $action;
693
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
693
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
694 694
 
695
-				if (! empty($conf->global->MAIN_UMASK))
695
+				if (!empty($conf->global->MAIN_UMASK))
696 696
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
697 697
 
698 698
 				$this->result = array('fullpath'=>$file);
699 699
 
700
-				return 1;   // Pas d'erreur
700
+				return 1; // Pas d'erreur
701 701
 			}
702 702
 			else
703 703
 			{
704
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
704
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
705 705
 				return 0;
706 706
 			}
707 707
 		}
708 708
 		else
709 709
 		{
710
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
710
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
711 711
 			return 0;
712 712
 		}
713 713
 	}
@@ -739,35 +739,35 @@  discard block
 block discarded – undo
739 739
 		global $conf;
740 740
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
741 741
 
742
-		$pdf->SetFont('','', $default_font_size - 1);
742
+		$pdf->SetFont('', '', $default_font_size - 1);
743 743
 
744 744
         // If France, show VAT mention if not applicable
745 745
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746 746
 		{
747
-			$pdf->SetFont('','B', $default_font_size - 2);
747
+			$pdf->SetFont('', 'B', $default_font_size - 2);
748 748
 			$pdf->SetXY($this->marge_gauche, $posy);
749 749
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
750 750
 
751
-			$posy=$pdf->GetY()+4;
751
+			$posy = $pdf->GetY() + 4;
752 752
 		}
753 753
 
754
-		$posxval=52;
754
+		$posxval = 52;
755 755
 
756 756
 		// Show payments conditions
757 757
 		if ($object->cond_reglement_code || $object->cond_reglement)
758 758
 		{
759
-			$pdf->SetFont('','B', $default_font_size - 2);
759
+			$pdf->SetFont('', 'B', $default_font_size - 2);
760 760
 			$pdf->SetXY($this->marge_gauche, $posy);
761 761
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
762 762
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
763 763
 
764
-			$pdf->SetFont('','', $default_font_size - 2);
764
+			$pdf->SetFont('', '', $default_font_size - 2);
765 765
 			$pdf->SetXY($posxval, $posy);
766
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
768
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
766
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
768
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
769 769
 
770
-			$posy=$pdf->GetY()+3;
770
+			$posy = $pdf->GetY() + 3;
771 771
 		}
772 772
 
773 773
         // Check a payment mode is defined
@@ -798,34 +798,34 @@  discard block
 block discarded – undo
798 798
 		}*/
799 799
 
800 800
 	    // Show planed date of delivery
801
-        if (! empty($object->date_livraison))
801
+        if (!empty($object->date_livraison))
802 802
 		{
803 803
             $outputlangs->load("sendings");
804
-			$pdf->SetFont('','B', $default_font_size - 2);
804
+			$pdf->SetFont('', 'B', $default_font_size - 2);
805 805
 			$pdf->SetXY($this->marge_gauche, $posy);
806 806
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807 807
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
808
-			$pdf->SetFont('','', $default_font_size - 2);
808
+			$pdf->SetFont('', '', $default_font_size - 2);
809 809
 			$pdf->SetXY($posxval, $posy);
810
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
810
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
811 811
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 812
 
813
-            $posy=$pdf->GetY()+1;
813
+            $posy = $pdf->GetY() + 1;
814 814
 		}
815 815
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
816 816
 		{
817
-			$pdf->SetFont('','B', $default_font_size - 2);
817
+			$pdf->SetFont('', 'B', $default_font_size - 2);
818 818
 			$pdf->SetXY($this->marge_gauche, $posy);
819 819
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820 820
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
821
-			$pdf->SetTextColor(0,0,0);
822
-			$pdf->SetFont('','', $default_font_size - 2);
821
+			$pdf->SetTextColor(0, 0, 0);
822
+			$pdf->SetFont('', '', $default_font_size - 2);
823 823
 			$pdf->SetXY($posxval, $posy);
824
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
825
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
824
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
825
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
826 826
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827 827
 
828
-			$posy=$pdf->GetY()+1;
828
+			$posy = $pdf->GetY() + 1;
829 829
 		}
830 830
 
831 831
       	// Show payment mode
@@ -833,24 +833,24 @@  discard block
 block discarded – undo
833 833
         	 && $object->mode_reglement_code != 'CHQ'
834 834
            	 && $object->mode_reglement_code != 'VIR')
835 835
            	 {
836
-	            $pdf->SetFont('','B', $default_font_size - 2);
836
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
837 837
 	            $pdf->SetXY($this->marge_gauche, $posy);
838 838
 	            $titre = $outputlangs->transnoentities("PaymentMode").':';
839 839
 	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
840 840
 
841
-				$pdf->SetFont('','', $default_font_size - 2);
841
+				$pdf->SetFont('', '', $default_font_size - 2);
842 842
 	            $pdf->SetXY($posxval, $posy);
843
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
844
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
843
+	            $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
844
+	            $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
845 845
 
846
-	            $posy=$pdf->GetY()+2;
846
+	            $posy = $pdf->GetY() + 2;
847 847
            	 }
848 848
 
849 849
 		// Show payment mode CHQ
850 850
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
851 851
         {
852 852
         	// Si mode reglement non force ou si force a CHQ
853
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
853
+	        if (!empty($conf->global->FACTURE_CHQ_NUMBER))
854 854
 	        {
855 855
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856 856
 	            {
@@ -858,31 +858,31 @@  discard block
 block discarded – undo
858 858
 	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859 859
 
860 860
 	                $pdf->SetXY($this->marge_gauche, $posy);
861
-	                $pdf->SetFont('','B', $default_font_size - 3);
862
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
863
-		            $posy=$pdf->GetY()+1;
861
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
862
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
863
+		            $posy = $pdf->GetY() + 1;
864 864
 
865 865
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866 866
 		            {
867 867
 		                $pdf->SetXY($this->marge_gauche, $posy);
868
-		                $pdf->SetFont('','', $default_font_size - 3);
868
+		                $pdf->SetFont('', '', $default_font_size - 3);
869 869
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
-			            $posy=$pdf->GetY()+2;
870
+			            $posy = $pdf->GetY() + 2;
871 871
 		            }
872 872
 	            }
873 873
 	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874 874
 	            {
875 875
 	                $pdf->SetXY($this->marge_gauche, $posy);
876
-	                $pdf->SetFont('','B', $default_font_size - 3);
877
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
878
-		            $posy=$pdf->GetY()+1;
876
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
877
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
878
+		            $posy = $pdf->GetY() + 1;
879 879
 
880 880
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881 881
 		            {
882 882
 			            $pdf->SetXY($this->marge_gauche, $posy);
883
-		                $pdf->SetFont('','', $default_font_size - 3);
883
+		                $pdf->SetFont('', '', $default_font_size - 3);
884 884
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
-			            $posy=$pdf->GetY()+2;
885
+			            $posy = $pdf->GetY() + 2;
886 886
 		            }
887 887
 	            }
888 888
 	        }
@@ -891,19 +891,19 @@  discard block
 block discarded – undo
891 891
         // If payment mode not forced or forced to VIR, show payment with BAN
892 892
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
893 893
         {
894
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
894
+			if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
895 895
 			{
896
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
897
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
896
+				$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
897
+				if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
898 898
 				$account = new Account($this->db);
899 899
 				$account->fetch($bankid);
900 900
 
901
-				$curx=$this->marge_gauche;
902
-				$cury=$posy;
901
+				$curx = $this->marge_gauche;
902
+				$cury = $posy;
903 903
 
904
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
904
+				$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
905 905
 
906
-				$posy+=2;
906
+				$posy += 2;
907 907
 			}
908 908
         }
909 909
 
@@ -923,44 +923,44 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925 925
 	{
926
-	    global $conf,$mysoc;
926
+	    global $conf, $mysoc;
927 927
 
928 928
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
929 929
 
930 930
 		$tab2_top = $posy;
931 931
 		$tab2_hl = 4;
932
-		$pdf->SetFont('','', $default_font_size - 1);
932
+		$pdf->SetFont('', '', $default_font_size - 1);
933 933
 
934 934
 		// Tableau total
935 935
         $col1x = 120; $col2x = 170;
936 936
 		if ($this->page_largeur < 210) // To work with US executive format
937 937
 		{
938
-			$col2x-=20;
938
+			$col2x -= 20;
939 939
 		}
940 940
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 941
 
942
-		$useborder=0;
942
+		$useborder = 0;
943 943
 		$index = 0;
944 944
 
945 945
 		// Total HT
946
-		$pdf->SetFillColor(255,255,255);
946
+		$pdf->SetFillColor(255, 255, 255);
947 947
 		$pdf->SetXY($col1x, $tab2_top + 0);
948
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
948
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
949 949
 
950 950
 		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
951 951
 		$pdf->SetXY($col2x, $tab2_top + 0);
952
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
952
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
953 953
 
954 954
 		// Show VAT by rates and total
955
-		$pdf->SetFillColor(248,248,248);
955
+		$pdf->SetFillColor(248, 248, 248);
956 956
 
957 957
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
958 958
 
959
-		$this->atleastoneratenotnull=0;
959
+		$this->atleastoneratenotnull = 0;
960 960
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
961 961
 		{
962
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
962
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964 964
 			{
965 965
 				// Nothing to do
966 966
 			}
@@ -969,27 +969,27 @@  discard block
 block discarded – undo
969 969
 				//Local tax 1 before VAT
970 970
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971 971
 				//{
972
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
972
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
973 973
 					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
-						foreach( $localtax_rate as $tvakey => $tvaval )
974
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
975
+						foreach ($localtax_rate as $tvakey => $tvaval)
976 976
 						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
977
+							if ($tvakey != 0)    // On affiche pas taux 0
978 978
 							{
979 979
 								//$this->atleastoneratenotnull++;
980 980
 
981 981
 								$index++;
982 982
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 983
 
984
-								$tvacompl='';
985
-								if (preg_match('/\*/',$tvakey))
984
+								$tvacompl = '';
985
+								if (preg_match('/\*/', $tvakey))
986 986
 								{
987
-									$tvakey=str_replace('*','',$tvakey);
987
+									$tvakey = str_replace('*', '', $tvakey);
988 988
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
989 989
 								}
990
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
991
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
992
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
990
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
991
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
992
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
993 993
 
994 994
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995 995
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1000,12 +1000,12 @@  discard block
 block discarded – undo
1000 1000
 				//Local tax 2 before VAT
1001 1001
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002 1002
 				//{
1003
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1003
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1004 1004
 					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
-						foreach( $localtax_rate as $tvakey => $tvaval )
1005
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1006
+						foreach ($localtax_rate as $tvakey => $tvaval)
1007 1007
 						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1008
+							if ($tvakey != 0)    // On affiche pas taux 0
1009 1009
 							{
1010 1010
 								//$this->atleastoneratenotnull++;
1011 1011
 
@@ -1014,15 +1014,15 @@  discard block
 block discarded – undo
1014 1014
 								$index++;
1015 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 1016
 
1017
-								$tvacompl='';
1018
-								if (preg_match('/\*/',$tvakey))
1017
+								$tvacompl = '';
1018
+								if (preg_match('/\*/', $tvakey))
1019 1019
 								{
1020
-									$tvakey=str_replace('*','',$tvakey);
1020
+									$tvakey = str_replace('*', '', $tvakey);
1021 1021
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1022 1022
 								}
1023
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1023
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1024
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1025
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026 1026
 
1027 1027
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028 1028
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 					}
1032 1032
 				//}
1033 1033
 				// VAT
1034
-				foreach($this->tva as $tvakey => $tvaval)
1034
+				foreach ($this->tva as $tvakey => $tvaval)
1035 1035
 				{
1036 1036
 					if ($tvakey != 0)    // On affiche pas taux 0
1037 1037
 					{
@@ -1040,15 +1040,15 @@  discard block
 block discarded – undo
1040 1040
 						$index++;
1041 1041
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042 1042
 
1043
-						$tvacompl='';
1044
-						if (preg_match('/\*/',$tvakey))
1043
+						$tvacompl = '';
1044
+						if (preg_match('/\*/', $tvakey))
1045 1045
 						{
1046
-							$tvakey=str_replace('*','',$tvakey);
1046
+							$tvakey = str_replace('*', '', $tvakey);
1047 1047
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1048 1048
 						}
1049
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1050
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1051
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1049
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1050
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1051
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1052 1052
 
1053 1053
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054 1054
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1058,11 +1058,11 @@  discard block
 block discarded – undo
1058 1058
 				//Local tax 1 after VAT
1059 1059
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060 1060
 				//{
1061
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1061
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1062 1062
 					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1063
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1064 1064
 
1065
-						foreach( $localtax_rate as $tvakey => $tvaval )
1065
+						foreach ($localtax_rate as $tvakey => $tvaval)
1066 1066
 						{
1067 1067
 							if ($tvakey != 0)    // On affiche pas taux 0
1068 1068
 							{
@@ -1071,16 +1071,16 @@  discard block
 block discarded – undo
1071 1071
 								$index++;
1072 1072
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073 1073
 
1074
-								$tvacompl='';
1075
-								if (preg_match('/\*/',$tvakey))
1074
+								$tvacompl = '';
1075
+								if (preg_match('/\*/', $tvakey))
1076 1076
 								{
1077
-									$tvakey=str_replace('*','',$tvakey);
1077
+									$tvakey = str_replace('*', '', $tvakey);
1078 1078
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079 1079
 								}
1080
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1080
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1081 1081
 
1082
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1082
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1083
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084 1084
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085 1085
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086 1086
 							}
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
 				//Local tax 2 after VAT
1091 1091
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092 1092
 				//{
1093
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1093
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1094 1094
 					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1095
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1096 1096
 
1097
-						foreach( $localtax_rate as $tvakey => $tvaval )
1097
+						foreach ($localtax_rate as $tvakey => $tvaval)
1098 1098
 						{
1099 1099
 							if ($tvakey != 0)    // On affiche pas taux 0
1100 1100
 							{
@@ -1103,16 +1103,16 @@  discard block
 block discarded – undo
1103 1103
 								$index++;
1104 1104
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 1105
 
1106
-								$tvacompl='';
1107
-								if (preg_match('/\*/',$tvakey))
1106
+								$tvacompl = '';
1107
+								if (preg_match('/\*/', $tvakey))
1108 1108
 								{
1109
-									$tvakey=str_replace('*','',$tvakey);
1109
+									$tvakey = str_replace('*', '', $tvakey);
1110 1110
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111 1111
 								}
1112
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1112
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1113 1113
 
1114
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1114
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1115
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116 1116
 
1117 1117
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118 1118
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1124,24 +1124,24 @@  discard block
 block discarded – undo
1124 1124
 				// Total TTC
1125 1125
 				$index++;
1126 1126
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127
-				$pdf->SetTextColor(0,0,60);
1128
-				$pdf->SetFillColor(224,224,224);
1129
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1127
+				$pdf->SetTextColor(0, 0, 60);
1128
+				$pdf->SetFillColor(224, 224, 224);
1129
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1130 1130
 
1131 1131
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132 1132
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133 1133
 			}
1134 1134
 		}
1135 1135
 
1136
-		$pdf->SetTextColor(0,0,0);
1136
+		$pdf->SetTextColor(0, 0, 0);
1137 1137
 
1138
-        $creditnoteamount=0;
1139
-        $depositsamount=0;
1138
+        $creditnoteamount = 0;
1139
+        $depositsamount = 0;
1140 1140
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1141 1141
 		//$depositsamount=$object->getSumDepositsUsed();
1142 1142
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143 1143
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1144
+		if (!empty($object->paye)) $resteapayer = 0;
1145 1145
 
1146 1146
 		if ($deja_regle > 0)
1147 1147
 		{
@@ -1149,21 +1149,21 @@  discard block
 block discarded – undo
1149 1149
 			$index++;
1150 1150
 
1151 1151
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1152
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153 1153
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154 1154
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1155 1155
 
1156 1156
 			$index++;
1157
-			$pdf->SetTextColor(0,0,60);
1158
-			$pdf->SetFillColor(224,224,224);
1157
+			$pdf->SetTextColor(0, 0, 60);
1158
+			$pdf->SetFillColor(224, 224, 224);
1159 1159
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1160
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1161 1161
 
1162 1162
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163 1163
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1164 1164
 
1165
-			$pdf->SetFont('','', $default_font_size - 1);
1166
-			$pdf->SetTextColor(0,0,0);
1165
+			$pdf->SetFont('', '', $default_font_size - 1);
1166
+			$pdf->SetTextColor(0, 0, 0);
1167 1167
 		}
1168 1168
 
1169 1169
 		$index++;
@@ -1183,61 +1183,61 @@  discard block
 block discarded – undo
1183 1183
 	 *   @param		string		$currency		Currency code
1184 1184
 	 *   @return	void
1185 1185
 	 */
1186
-	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1186
+	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1187 1187
 	{
1188 1188
 		global $conf;
1189 1189
 
1190 1190
 		// Force to disable hidetop and hidebottom
1191
-		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1191
+		$hidebottom = 0;
1192
+		if ($hidetop) $hidetop = -1;
1193 1193
 
1194 1194
 		$currency = !empty($currency) ? $currency : $conf->currency;
1195 1195
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1196 1196
 
1197 1197
 		// Amount in (at tab_top - 1)
1198
-		$pdf->SetTextColor(0,0,0);
1199
-		$pdf->SetFont('','', $default_font_size - 2);
1198
+		$pdf->SetTextColor(0, 0, 0);
1199
+		$pdf->SetFont('', '', $default_font_size - 2);
1200 1200
 
1201 1201
 		if (empty($hidetop))
1202 1202
 		{
1203
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1203
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1205 1205
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206 1206
 
1207 1207
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1208
-			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));
1208
+			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));
1209 1209
 		}
1210 1210
 
1211
-		$pdf->SetDrawColor(128,128,128);
1212
-		$pdf->SetFont('','', $default_font_size - 1);
1211
+		$pdf->SetDrawColor(128, 128, 128);
1212
+		$pdf->SetFont('', '', $default_font_size - 1);
1213 1213
 
1214 1214
 		// Output Rect
1215
-		$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
1215
+		$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
1216 1216
 
1217 1217
 
1218 1218
 		foreach ($this->cols as $colKey => $colDef)
1219 1219
 		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1220
+		    if (!$this->getColumnStatus($colKey)) continue;
1221 1221
 
1222 1222
 		    // get title label
1223
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1223
+		    $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
1224 1224
 
1225 1225
 		    // Add column separator
1226
-		    if(!empty($colDef['border-left'])){
1226
+		    if (!empty($colDef['border-left'])) {
1227 1227
 		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228 1228
 		    }
1229 1229
 
1230 1230
 		    if (empty($hidetop))
1231 1231
 		    {
1232
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1232
+		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
1233 1233
 
1234
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1234
+		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
1235
+		      $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
1236 1236
 		    }
1237 1237
 		}
1238 1238
 
1239
-		if (empty($hidetop)){
1240
-			$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
1239
+		if (empty($hidetop)) {
1240
+			$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
1241 1241
 		}
1242 1242
 	}
1243 1243
 
@@ -1251,102 +1251,102 @@  discard block
 block discarded – undo
1251 1251
 	 *  @param	string		$titlekey		Translation key to show as title of document
1252 1252
 	 *  @return	void
1253 1253
 	 */
1254
-	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1254
+	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
1255 1255
 	{
1256
-		global $conf,$langs,$hookmanager;
1256
+		global $conf, $langs, $hookmanager;
1257 1257
 
1258 1258
 		// Translations
1259 1259
 		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260 1260
 
1261 1261
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1262 1262
 
1263
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1263
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1264 1264
 
1265 1265
 		// Show Draft Watermark
1266
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1266
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1267 1267
 		{
1268
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1268
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1269 1269
 		}
1270 1270
 
1271
-		$pdf->SetTextColor(0,0,60);
1272
-		$pdf->SetFont('','B', $default_font_size + 3);
1271
+		$pdf->SetTextColor(0, 0, 60);
1272
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1273 1273
 
1274
-		$posy=$this->marge_haute;
1275
-		$posx=$this->page_largeur-$this->marge_droite-100;
1274
+		$posy = $this->marge_haute;
1275
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1276 1276
 
1277
-		$pdf->SetXY($this->marge_gauche,$posy);
1277
+		$pdf->SetXY($this->marge_gauche, $posy);
1278 1278
 
1279 1279
 		// Logo
1280 1280
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281 1281
 		{
1282
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1282
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283 1283
 			if ($this->emetteur->logo)
1284 1284
 			{
1285 1285
 				if (is_readable($logo))
1286 1286
 				{
1287
-				    $height=pdf_getHeightForLogo($logo);
1288
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1287
+				    $height = pdf_getHeightForLogo($logo);
1288
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1289 1289
 				}
1290 1290
 				else
1291 1291
 				{
1292
-					$pdf->SetTextColor(200,0,0);
1293
-					$pdf->SetFont('','B', $default_font_size -2);
1294
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1292
+					$pdf->SetTextColor(200, 0, 0);
1293
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1294
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1295 1295
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296 1296
 				}
1297 1297
 			}
1298 1298
 			else
1299 1299
 			{
1300
-				$text=$this->emetteur->name;
1300
+				$text = $this->emetteur->name;
1301 1301
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302 1302
 			}
1303 1303
 		}
1304 1304
 
1305
-		$pdf->SetFont('','B', $default_font_size + 3);
1306
-		$pdf->SetXY($posx,$posy);
1307
-		$pdf->SetTextColor(0,0,60);
1308
-		$title=$outputlangs->transnoentities($titlekey);
1305
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1306
+		$pdf->SetXY($posx, $posy);
1307
+		$pdf->SetTextColor(0, 0, 60);
1308
+		$title = $outputlangs->transnoentities($titlekey);
1309 1309
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1310 1310
 
1311
-		$pdf->SetFont('','B',$default_font_size);
1311
+		$pdf->SetFont('', 'B', $default_font_size);
1312 1312
 
1313
-		$posy+=5;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1313
+		$posy += 5;
1314
+		$pdf->SetXY($posx, $posy);
1315
+		$pdf->SetTextColor(0, 0, 60);
1316
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1317 1317
 
1318
-		$posy+=1;
1319
-		$pdf->SetFont('','', $default_font_size - 1);
1318
+		$posy += 1;
1319
+		$pdf->SetFont('', '', $default_font_size - 1);
1320 1320
 
1321 1321
 		if ($object->ref_client)
1322 1322
 		{
1323
-			$posy+=5;
1324
-			$pdf->SetXY($posx,$posy);
1325
-			$pdf->SetTextColor(0,0,60);
1326
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1323
+			$posy += 5;
1324
+			$pdf->SetXY($posx, $posy);
1325
+			$pdf->SetTextColor(0, 0, 60);
1326
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1327 1327
 		}
1328 1328
 
1329
-		$posy+=4;
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1329
+		$posy += 4;
1330
+		$pdf->SetXY($posx, $posy);
1331
+		$pdf->SetTextColor(0, 0, 60);
1332
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
1333 1333
 
1334 1334
 		// Get contact
1335 1335
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336 1336
 		{
1337
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1337
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1338 1338
 		    if (count($arrayidcontact) > 0)
1339 1339
 		    {
1340
-                $usertmp=new User($this->db);
1340
+                $usertmp = new User($this->db);
1341 1341
 		        $usertmp->fetch($arrayidcontact[0]);
1342
-                $posy+=4;
1343
-                $pdf->SetXY($posx,$posy);
1344
-		        $pdf->SetTextColor(0,0,60);
1342
+                $posy += 4;
1343
+                $pdf->SetXY($posx, $posy);
1344
+		        $pdf->SetTextColor(0, 0, 60);
1345 1345
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346 1346
 		    }
1347 1347
 		}
1348 1348
 
1349
-		$posy+=2;
1349
+		$posy += 2;
1350 1350
 
1351 1351
 		$top_shift = 0;
1352 1352
 		// Show list of linked objects
@@ -1360,54 +1360,54 @@  discard block
 block discarded – undo
1360 1360
 		if ($showaddress)
1361 1361
 		{
1362 1362
 			// Sender properties
1363
-			$carac_emetteur='';
1363
+			$carac_emetteur = '';
1364 1364
 		 	// Add internal contact of proposal if defined
1365
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1365
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1366 1366
 		 	if (count($arrayidcontact) > 0)
1367 1367
 		 	{
1368 1368
 		 		$object->fetch_user($arrayidcontact[0]);
1369
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1370
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1369
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1370
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1371 1371
 		 	}
1372 1372
 
1373 1373
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374 1374
 
1375 1375
 			// Show sender
1376
-			$posy=42+$top_shift;
1377
-			$posx=$this->marge_gauche;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1379
-			$hautcadre=40;
1376
+			$posy = 42 + $top_shift;
1377
+			$posx = $this->marge_gauche;
1378
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1379
+			$hautcadre = 40;
1380 1380
 
1381 1381
 			// Show sender frame
1382
-			$pdf->SetTextColor(0,0,0);
1383
-			$pdf->SetFont('','', $default_font_size - 2);
1384
-			$pdf->SetXY($posx,$posy-5);
1385
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
-			$pdf->SetXY($posx,$posy);
1387
-			$pdf->SetFillColor(230,230,230);
1382
+			$pdf->SetTextColor(0, 0, 0);
1383
+			$pdf->SetFont('', '', $default_font_size - 2);
1384
+			$pdf->SetXY($posx, $posy - 5);
1385
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
+			$pdf->SetXY($posx, $posy);
1387
+			$pdf->SetFillColor(230, 230, 230);
1388 1388
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
-			$pdf->SetTextColor(0,0,60);
1389
+			$pdf->SetTextColor(0, 0, 60);
1390 1390
 
1391 1391
 			// Show sender name
1392
-			$pdf->SetXY($posx+2,$posy+3);
1393
-			$pdf->SetFont('','B', $default_font_size);
1392
+			$pdf->SetXY($posx + 2, $posy + 3);
1393
+			$pdf->SetFont('', 'B', $default_font_size);
1394 1394
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
-			$posy=$pdf->getY();
1395
+			$posy = $pdf->getY();
1396 1396
 
1397 1397
 			// Show sender information
1398
-			$pdf->SetXY($posx+2,$posy);
1399
-			$pdf->SetFont('','', $default_font_size - 1);
1398
+			$pdf->SetXY($posx + 2, $posy);
1399
+			$pdf->SetFont('', '', $default_font_size - 1);
1400 1400
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401 1401
 
1402 1402
 
1403 1403
 
1404 1404
 			// If CUSTOMER contact defined on order, we use it
1405
-			$usecontact=false;
1406
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1405
+			$usecontact = false;
1406
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1407 1407
 			if (count($arrayidcontact) > 0)
1408 1408
 			{
1409
-				$usecontact=true;
1410
-				$result=$object->fetch_contact($arrayidcontact[0]);
1409
+				$usecontact = true;
1410
+				$result = $object->fetch_contact($arrayidcontact[0]);
1411 1411
 			}
1412 1412
 
1413 1413
 			//Recipient name
@@ -1418,38 +1418,38 @@  discard block
 block discarded – undo
1418 1418
 				$thirdparty = $object->thirdparty;
1419 1419
 			}
1420 1420
 
1421
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1421
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422 1422
 
1423
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1423
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1424 1424
 
1425 1425
 			// Show recipient
1426
-			$widthrecbox=100;
1427
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1428
-			$posy=42+$top_shift;
1429
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1426
+			$widthrecbox = 100;
1427
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1428
+			$posy = 42 + $top_shift;
1429
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1430
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1431 1431
 
1432 1432
 			// Show recipient frame
1433
-			$pdf->SetTextColor(0,0,0);
1434
-			$pdf->SetFont('','', $default_font_size - 2);
1435
-			$pdf->SetXY($posx+2,$posy-5);
1436
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1433
+			$pdf->SetTextColor(0, 0, 0);
1434
+			$pdf->SetFont('', '', $default_font_size - 2);
1435
+			$pdf->SetXY($posx + 2, $posy - 5);
1436
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1437 1437
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438 1438
 
1439 1439
 			// Show recipient name
1440
-			$pdf->SetXY($posx+2,$posy+3);
1441
-			$pdf->SetFont('','B', $default_font_size);
1440
+			$pdf->SetXY($posx + 2, $posy + 3);
1441
+			$pdf->SetFont('', 'B', $default_font_size);
1442 1442
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443 1443
 
1444 1444
 			$posy = $pdf->getY();
1445 1445
 
1446 1446
 			// Show recipient information
1447
-			$pdf->SetFont('','', $default_font_size - 1);
1448
-			$pdf->SetXY($posx+2,$posy);
1447
+			$pdf->SetFont('', '', $default_font_size - 1);
1448
+			$pdf->SetXY($posx + 2, $posy);
1449 1449
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450 1450
 		}
1451 1451
 
1452
-		$pdf->SetTextColor(0,0,0);
1452
+		$pdf->SetTextColor(0, 0, 0);
1453 1453
 		return $top_shift;
1454 1454
 	}
1455 1455
 
@@ -1462,11 +1462,11 @@  discard block
 block discarded – undo
1462 1462
 	 *      @param	int			$hidefreetext		1=Hide free text
1463 1463
 	 *      @return	int								Return height of bottom margin including footer text
1464 1464
 	 */
1465
-	private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1465
+	private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1466 1466
 	{
1467 1467
 		global $conf;
1468
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1468
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
+		return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1470 1470
 	}
1471 1471
 
1472 1472
 
@@ -1481,20 +1481,20 @@  discard block
 block discarded – undo
1481 1481
 	 *      @param	int				$hideref		Do not show ref
1482 1482
 	 *      @return	null
1483 1483
 	 */
1484
-    public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1484
+    public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1485 1485
     {
1486 1486
 	    global $conf, $hookmanager;
1487 1487
 
1488 1488
 	    // Default field style for content
1489 1489
 	    $this->defaultContentsFieldsStyle = array(
1490 1490
 	        'align' => 'R', // R,C,L
1491
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1491
+	        'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1492 1492
 	    );
1493 1493
 
1494 1494
 	    // Default field style for content
1495 1495
 	    $this->defaultTitlesFieldsStyle = array(
1496 1496
 	        'align' => 'C', // R,C,L
1497
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1497
+	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1498 1498
 	    );
1499 1499
 
1500 1500
 	    /*
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 	     );
1516 1516
 	     */
1517 1517
 
1518
-	    $rank=0; // do not use negative rank
1518
+	    $rank = 0; // do not use negative rank
1519 1519
 	    $this->cols['desc'] = array(
1520 1520
 	        'rank' => $rank,
1521 1521
 	        'width' => false, // only for desc
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
 	            'align' => 'L',
1526 1526
 	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1527 1527
 	            // 'label' => ' ', // the final label
1528
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1528
+	            'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1529 1529
 	        ),
1530 1530
 	        'content' => array(
1531 1531
 	            'align' => 'L',
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
 	    $rank = $rank + 10;
1536 1536
 	    $this->cols['photo'] = array(
1537 1537
 	        'rank' => $rank,
1538
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1538
+	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539 1539
 	        'status' => false,
1540 1540
 	        'title' => array(
1541 1541
 	            'textkey' => 'Photo',
1542 1542
 	            'label' => ' '
1543 1543
 	        ),
1544 1544
 	        'content' => array(
1545
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1545
+	            'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546 1546
 	        ),
1547 1547
 	        'border-left' => false, // remove left line separator
1548 1548
 	    );
1549 1549
 
1550
-	    if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1550
+	    if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551 1551
 	    {
1552 1552
 	        $this->cols['photo']['status'] = true;
1553 1553
 	    }
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 	        'border-left' => false, // add left line separator
1603 1603
 	    );
1604 1604
 
1605
-	    if($this->situationinvoice)
1605
+	    if ($this->situationinvoice)
1606 1606
 	    {
1607 1607
 	        $this->cols['progress']['status'] = true;
1608 1608
 	    }
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 	        ),
1618 1618
 	        'border-left' => true, // add left line separator
1619 1619
 	    );
1620
-	    if($conf->global->PRODUCT_USE_UNITS){
1620
+	    if ($conf->global->PRODUCT_USE_UNITS) {
1621 1621
 	        $this->cols['unit']['status'] = true;
1622 1622
 	    }
1623 1623
 
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	        ),
1632 1632
 	        'border-left' => true, // add left line separator
1633 1633
 	    );
1634
-	    if ($this->atleastonediscount){
1634
+	    if ($this->atleastonediscount) {
1635 1635
 	        $this->cols['discount']['status'] = true;
1636 1636
 	    }
1637 1637
 
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 	    );
1648 1648
 
1649 1649
 
1650
-	    $parameters=array(
1650
+	    $parameters = array(
1651 1651
 	        'object' => $object,
1652 1652
 	        'outputlangs' => $outputlangs,
1653 1653
 	        'hidedetails' => $hidedetails,
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 	        'hideref' => $hideref
1656 1656
 	    );
1657 1657
 
1658
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1658
+	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1659 1659
 	    if ($reshook < 0)
1660 1660
 	    {
1661 1661
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Please login to merge, or discard this patch.
Braces   +172 added lines, -88 removed lines patch added patch discarded remove patch
@@ -133,7 +133,10 @@  discard block
 block discarded – undo
133 133
 
134 134
 		// Get source company
135 135
 		$this->emetteur=$mysoc;
136
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
136
+		if (empty($this->emetteur->country_code)) {
137
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
138
+		}
139
+		// By default, if was not defined
137 140
 
138 141
 		// Define position of columns
139 142
 		$this->posxdesc=$this->marge_gauche+1;
@@ -163,9 +166,13 @@  discard block
 block discarded – undo
163 166
 	    // phpcs:enable
164 167
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 168
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
169
+		if (! is_object($outputlangs)) {
170
+		    $outputlangs=$langs;
171
+		}
167 172
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
168
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
173
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
174
+		    $outputlangs->charset_output='ISO-8859-1';
175
+		}
169 176
 
170 177
 		// Translations
171 178
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -183,8 +190,7 @@  discard block
 block discarded – undo
183 190
 			{
184 191
 				$dir = $conf->commande->dir_output;
185 192
 				$file = $dir . "/SPECIMEN.pdf";
186
-			}
187
-			else
193
+			} else
188 194
 			{
189 195
 				$objectref = dol_sanitizeFileName($object->ref);
190 196
 				$dir = $conf->commande->dir_output . "/" . $objectref;
@@ -244,7 +250,9 @@  discard block
 block discarded – undo
244 250
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245 251
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246 252
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
247
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
253
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
254
+				    $pdf->SetCompression(false);
255
+				}
248 256
 
249 257
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250 258
 
@@ -268,7 +276,9 @@  discard block
 block discarded – undo
268 276
 
269 277
 				// New page
270 278
 				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
279
+				if (! empty($tplidx)) {
280
+				    $pdf->useTemplate($tplidx);
281
+				}
272 282
 				$pagenb++;
273 283
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274 284
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -310,7 +320,9 @@  discard block
 block discarded – undo
310 320
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311 321
 						$salerepobj=new User($this->db);
312 322
 						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
323
+						if (! empty($salerepobj->signature)) {
324
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
325
+						}
314 326
 					}
315 327
 				}
316 328
 
@@ -342,8 +354,12 @@  discard block
 block discarded – undo
342 354
 				        while ($pagenb < $pageposafternote) {
343 355
 				            $pdf->AddPage();
344 356
 				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
357
+				            if (! empty($tplidx)) {
358
+				                $pdf->useTemplate($tplidx);
359
+				            }
360
+				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
361
+				                $this->_pagehead($pdf, $object, 0, $outputlangs);
362
+				            }
347 363
 				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348 364
 				            $pdf->setTopMargin($tab_top_newpage);
349 365
 				            // The only function to edit the bottom margin of current page to set it.
@@ -359,9 +375,11 @@  discard block
 block discarded – undo
359 375
 
360 376
 				        $posyafter = $pdf->GetY();
361 377
 
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
378
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) {
379
+				            // There is no space left for total+free text
363 380
 				        {
364 381
 				            $pdf->AddPage('','',true);
382
+				        }
365 383
 				            $pagenb++;
366 384
 				            $pageposafternote++;
367 385
 				            $pdf->setPage($pageposafternote);
@@ -383,8 +401,7 @@  discard block
 block discarded – undo
383 401
 				            if($i>$pageposbeforenote){
384 402
 				                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385 403
 				                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
386
-				            }
387
-				            else{
404
+				            } else{
388 405
 				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389 406
 				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390 407
 				            }
@@ -398,12 +415,15 @@  discard block
 block discarded – undo
398 415
 
399 416
 				        // apply note frame to last page
400 417
 				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
-				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
418
+				        if (! empty($tplidx)) {
419
+				            $pdf->useTemplate($tplidx);
420
+				        }
421
+				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
422
+				            $this->_pagehead($pdf, $object, 0, $outputlangs);
423
+				        }
403 424
 				        $height_note=$posyafter-$tab_top_newpage;
404 425
 				        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
405
-				    }
406
-				    else // No pagebreak
426
+				    } else // No pagebreak
407 427
 				    {
408 428
 				        $pdf->commitTransaction();
409 429
 				        $posyafter = $pdf->GetY();
@@ -418,8 +438,12 @@  discard block
 block discarded – undo
418 438
 				            $pagenb++;
419 439
 				            $pageposafternote++;
420 440
 				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
441
+				            if (! empty($tplidx)) {
442
+				                $pdf->useTemplate($tplidx);
443
+				            }
444
+				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
445
+				                $this->_pagehead($pdf, $object, 0, $outputlangs);
446
+				            }
423 447
 
424 448
 				            $posyafter = $tab_top_newpage;
425 449
 				        }
@@ -427,8 +451,7 @@  discard block
 block discarded – undo
427 451
 
428 452
 				    $tab_height = $tab_height - $height_note;
429 453
 				    $tab_top = $posyafter +6;
430
-				}
431
-				else
454
+				} else
432 455
 				{
433 456
 					$height_note=0;
434 457
 				}
@@ -463,32 +486,36 @@  discard block
 block discarded – undo
463 486
     					$pdf->startTransaction();
464 487
     					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465 488
     					$pageposafter=$pdf->getPage();
466
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
489
+    					if ($pageposafter > $pageposbefore) {
490
+    					    // There is a pagebreak
467 491
     					{
468 492
     						$pdf->rollbackTransaction(true);
493
+    					}
469 494
     						$pageposafter=$pageposbefore;
470 495
     						//print $pageposafter.'-'.$pageposbefore;exit;
471 496
     						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472 497
     						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473 498
     						$pageposafter=$pdf->getPage();
474 499
     						$posyafter=$pdf->GetY();
475
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
500
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
501
+    						    // There is no space left for total+free text
476 502
     						{
477 503
     							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478 504
     							{
479 505
     								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
506
+    						}
507
+    								if (! empty($tplidx)) {
508
+    								    $pdf->useTemplate($tplidx);
509
+    								}
481 510
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482 511
     								$pdf->setPage($pageposafter+1);
483 512
     							}
484
-    						}
485
-    						else
513
+    						} else
486 514
     						{
487 515
     							// We found a page break
488 516
     							$showpricebeforepagebreak=0;
489 517
     						}
490
-    					}
491
-    					else	// No pagebreak
518
+    					} else	// No pagebreak
492 519
     					{
493 520
     						$pdf->commitTransaction();
494 521
     					}
@@ -573,8 +600,11 @@  discard block
 block discarded – undo
573 600
 
574 601
 
575 602
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
577
-					else $tvaligne=$object->lines[$i]->total_tva;
603
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
604
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
605
+					} else {
606
+					    $tvaligne=$object->lines[$i]->total_tva;
607
+					}
578 608
 
579 609
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
580 610
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -583,29 +613,43 @@  discard block
 block discarded – undo
583 613
 					$localtax1_type=$object->lines[$i]->localtax1_type;
584 614
 					$localtax2_type=$object->lines[$i]->localtax2_type;
585 615
 
586
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
587
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
588
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
616
+					if ($object->remise_percent) {
617
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
618
+					}
619
+					if ($object->remise_percent) {
620
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
+					}
622
+					if ($object->remise_percent) {
623
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
624
+					}
589 625
 
590 626
 					$vatrate=(string) $object->lines[$i]->tva_tx;
591 627
 
592 628
 					// Retrieve type from database for backward compatibility with old records
593 629
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
594
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
630
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
631
+					    // and there is local tax
595 632
 					{
596 633
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
634
+					}
597 635
 						$localtax1_type = $localtaxtmp_array[0];
598 636
 						$localtax2_type = $localtaxtmp_array[2];
599 637
 					}
600 638
 
601 639
 				    // retrieve global local tax
602
-					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
-					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
640
+					if ($localtax1_type && $localtax1ligne != 0) {
641
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
642
+					}
643
+					if ($localtax2_type && $localtax2ligne != 0) {
644
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
645
+					}
606 646
 
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
647
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
648
+					    $vatrate.='*';
649
+					}
650
+					if (! isset($this->tva[$vatrate])) {
651
+					    $this->tva[$vatrate]=0;
652
+					}
609 653
 					$this->tva[$vatrate] += $tvaligne;
610 654
 
611 655
 					// Add line
@@ -627,8 +671,7 @@  discard block
 block discarded – undo
627 671
 						if ($pagenb == $pageposbeforeprintlines)
628 672
 						{
629 673
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
-						}
631
-						else
674
+						} else
632 675
 						{
633 676
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 677
 						}
@@ -636,32 +679,38 @@  discard block
 block discarded – undo
636 679
 						$pagenb++;
637 680
 						$pdf->setPage($pagenb);
638 681
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
682
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
683
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
684
+						}
640 685
 					}
641 686
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642 687
 					{
643 688
 					    if ($pagenb == $pageposafter)
644 689
 						{
645 690
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
-						}
647
-						else
691
+						} else
648 692
 						{
649 693
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650 694
 						}
651 695
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
652 696
 						// New page
653 697
 						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
698
+						if (! empty($tplidx)) {
699
+						    $pdf->useTemplate($tplidx);
700
+						}
655 701
 						$pagenb++;
656
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
702
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
703
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
704
+						}
657 705
 					}
658 706
 				}
659 707
 
660 708
 				// Show square
661
-				if ($pagenb == $pageposbeforeprintlines)
662
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
-				else
664
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
709
+				if ($pagenb == $pageposbeforeprintlines) {
710
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
711
+				} else {
712
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
713
+				}
665 714
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 715
 
667 716
 				// Affiche zone infos
@@ -680,7 +729,9 @@  discard block
 block discarded – undo
680 729
 
681 730
 				// Pied de page
682 731
 				$this->_pagefoot($pdf, $object, $outputlangs);
683
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
732
+				if (method_exists($pdf, 'AliasNbPages')) {
733
+				    $pdf->AliasNbPages();
734
+				}
684 735
 
685 736
 				$pdf->Close();
686 737
 
@@ -692,20 +743,19 @@  discard block
 block discarded – undo
692 743
 				global $action;
693 744
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
694 745
 
695
-				if (! empty($conf->global->MAIN_UMASK))
696
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
746
+				if (! empty($conf->global->MAIN_UMASK)) {
747
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
748
+				}
697 749
 
698 750
 				$this->result = array('fullpath'=>$file);
699 751
 
700 752
 				return 1;   // Pas d'erreur
701
-			}
702
-			else
753
+			} else
703 754
 			{
704 755
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705 756
 				return 0;
706 757
 			}
707
-		}
708
-		else
758
+		} else
709 759
 		{
710 760
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711 761
 			return 0;
@@ -811,10 +861,11 @@  discard block
 block discarded – undo
811 861
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 862
 
813 863
             $posy=$pdf->GetY()+1;
814
-		}
815
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
864
+		} elseif ($object->availability_code || $object->availability) {
865
+            // Show availability conditions
816 866
 		{
817 867
 			$pdf->SetFont('','B', $default_font_size - 2);
868
+        }
818 869
 			$pdf->SetXY($this->marge_gauche, $posy);
819 870
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820 871
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -894,7 +945,10 @@  discard block
 block discarded – undo
894 945
 			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
895 946
 			{
896 947
 				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
897
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
948
+				if (! empty($object->fk_bank)) {
949
+				    $bankid=$object->fk_bank;
950
+				}
951
+				// For backward compatibility when object->fk_account is forced with object->fk_bank
898 952
 				$account = new Account($this->db);
899 953
 				$account->fetch($bankid);
900 954
 
@@ -933,10 +987,12 @@  discard block
 block discarded – undo
933 987
 
934 988
 		// Tableau total
935 989
         $col1x = 120; $col2x = 170;
936
-		if ($this->page_largeur < 210) // To work with US executive format
990
+		if ($this->page_largeur < 210) {
991
+		    // To work with US executive format
937 992
 		{
938 993
 			$col2x-=20;
939 994
 		}
995
+		}
940 996
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 997
 
942 998
 		$useborder=0;
@@ -963,22 +1019,25 @@  discard block
 block discarded – undo
963 1019
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964 1020
 			{
965 1021
 				// Nothing to do
966
-			}
967
-			else
1022
+			} else
968 1023
 			{
969 1024
 				//Local tax 1 before VAT
970 1025
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971 1026
 				//{
972 1027
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973 1028
 					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1029
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1030
+						    continue;
1031
+						}
975 1032
 						foreach( $localtax_rate as $tvakey => $tvaval )
976 1033
 						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
1034
+							if ($tvakey!=0) {
1035
+							    // On affiche pas taux 0
978 1036
 							{
979 1037
 								//$this->atleastoneratenotnull++;
980 1038
 
981 1039
 								$index++;
1040
+							}
982 1041
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 1042
 
984 1043
 								$tvacompl='';
@@ -1002,16 +1061,20 @@  discard block
 block discarded – undo
1002 1061
 				//{
1003 1062
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004 1063
 					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1064
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1065
+						    continue;
1066
+						}
1006 1067
 						foreach( $localtax_rate as $tvakey => $tvaval )
1007 1068
 						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1069
+							if ($tvakey!=0) {
1070
+							    // On affiche pas taux 0
1009 1071
 							{
1010 1072
 								//$this->atleastoneratenotnull++;
1011 1073
 
1012 1074
 
1013 1075
 
1014 1076
 								$index++;
1077
+							}
1015 1078
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 1079
 
1017 1080
 								$tvacompl='';
@@ -1033,9 +1096,11 @@  discard block
 block discarded – undo
1033 1096
 				// VAT
1034 1097
 				foreach($this->tva as $tvakey => $tvaval)
1035 1098
 				{
1036
-					if ($tvakey != 0)    // On affiche pas taux 0
1099
+					if ($tvakey != 0) {
1100
+					    // On affiche pas taux 0
1037 1101
 					{
1038 1102
 						$this->atleastoneratenotnull++;
1103
+					}
1039 1104
 
1040 1105
 						$index++;
1041 1106
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1060,15 +1125,19 @@  discard block
 block discarded – undo
1060 1125
 				//{
1061 1126
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062 1127
 					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1128
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1129
+						    continue;
1130
+						}
1064 1131
 
1065 1132
 						foreach( $localtax_rate as $tvakey => $tvaval )
1066 1133
 						{
1067
-							if ($tvakey != 0)    // On affiche pas taux 0
1134
+							if ($tvakey != 0) {
1135
+							    // On affiche pas taux 0
1068 1136
 							{
1069 1137
 								//$this->atleastoneratenotnull++;
1070 1138
 
1071 1139
 								$index++;
1140
+							}
1072 1141
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073 1142
 
1074 1143
 								$tvacompl='';
@@ -1092,15 +1161,19 @@  discard block
 block discarded – undo
1092 1161
 				//{
1093 1162
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094 1163
 					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1164
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1165
+						    continue;
1166
+						}
1096 1167
 
1097 1168
 						foreach( $localtax_rate as $tvakey => $tvaval )
1098 1169
 						{
1099
-							if ($tvakey != 0)    // On affiche pas taux 0
1170
+							if ($tvakey != 0) {
1171
+							    // On affiche pas taux 0
1100 1172
 							{
1101 1173
 								//$this->atleastoneratenotnull++;
1102 1174
 
1103 1175
 								$index++;
1176
+							}
1104 1177
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 1178
 
1106 1179
 								$tvacompl='';
@@ -1141,7 +1214,9 @@  discard block
 block discarded – undo
1141 1214
 		//$depositsamount=$object->getSumDepositsUsed();
1142 1215
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143 1216
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1217
+		if (! empty($object->paye)) {
1218
+		    $resteapayer=0;
1219
+		}
1145 1220
 
1146 1221
 		if ($deja_regle > 0)
1147 1222
 		{
@@ -1189,7 +1264,9 @@  discard block
 block discarded – undo
1189 1264
 
1190 1265
 		// Force to disable hidetop and hidebottom
1191 1266
 		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1267
+		if ($hidetop) {
1268
+		    $hidetop=-1;
1269
+		}
1193 1270
 
1194 1271
 		$currency = !empty($currency) ? $currency : $conf->currency;
1195 1272
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1205,7 +1282,9 @@  discard block
 block discarded – undo
1205 1282
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206 1283
 
1207 1284
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1208
-			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));
1285
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1286
+			    $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));
1287
+			}
1209 1288
 		}
1210 1289
 
1211 1290
 		$pdf->SetDrawColor(128,128,128);
@@ -1217,7 +1296,9 @@  discard block
 block discarded – undo
1217 1296
 
1218 1297
 		foreach ($this->cols as $colKey => $colDef)
1219 1298
 		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1299
+		    if(!$this->getColumnStatus($colKey)) {
1300
+		        continue;
1301
+		    }
1221 1302
 
1222 1303
 		    // get title label
1223 1304
 		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
@@ -1286,16 +1367,14 @@  discard block
 block discarded – undo
1286 1367
 				{
1287 1368
 				    $height=pdf_getHeightForLogo($logo);
1288 1369
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
-				}
1290
-				else
1370
+				} else
1291 1371
 				{
1292 1372
 					$pdf->SetTextColor(200,0,0);
1293 1373
 					$pdf->SetFont('','B', $default_font_size -2);
1294 1374
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1295 1375
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296 1376
 				}
1297
-			}
1298
-			else
1377
+			} else
1299 1378
 			{
1300 1379
 				$text=$this->emetteur->name;
1301 1380
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1375,7 +1454,9 @@  discard block
 block discarded – undo
1375 1454
 			// Show sender
1376 1455
 			$posy=42+$top_shift;
1377 1456
 			$posx=$this->marge_gauche;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1457
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1458
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1459
+			}
1379 1460
 			$hautcadre=40;
1380 1461
 
1381 1462
 			// Show sender frame
@@ -1424,10 +1505,15 @@  discard block
 block discarded – undo
1424 1505
 
1425 1506
 			// Show recipient
1426 1507
 			$widthrecbox=100;
1427
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1508
+			if ($this->page_largeur < 210) {
1509
+			    $widthrecbox=84;
1510
+			}
1511
+			// To work with US executive format
1428 1512
 			$posy=42+$top_shift;
1429 1513
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1514
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1515
+			    $posx=$this->marge_gauche;
1516
+			}
1431 1517
 
1432 1518
 			// Show recipient frame
1433 1519
 			$pdf->SetTextColor(0,0,0);
@@ -1659,12 +1745,10 @@  discard block
 block discarded – undo
1659 1745
 	    if ($reshook < 0)
1660 1746
 	    {
1661 1747
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
-	    }
1663
-	    elseif (empty($reshook))
1748
+	    } elseif (empty($reshook))
1664 1749
 	    {
1665 1750
 	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
-	    }
1667
-	    else
1751
+	    } else
1668 1752
 	    {
1669 1753
 	        $this->cols = $hookmanager->resArray;
1670 1754
 	    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php 3 patches
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -40,480 +40,480 @@
 block discarded – undo
40 40
  */
41 41
 class doc_generic_order_odt extends ModelePDFCommandes
42 42
 {
43
-	/**
44
-	 * Issuer
45
-	 * @var Societe
46
-	 */
47
-	public $emetteur;
48
-
49
-	/**
50
-   * @var array Minimum version of PHP required by module.
51
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
52
-   */
53
-	public $phpmin = array(5, 4);
54
-
55
-	/**
43
+    /**
44
+     * Issuer
45
+     * @var Societe
46
+     */
47
+    public $emetteur;
48
+
49
+    /**
50
+     * @var array Minimum version of PHP required by module.
51
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
52
+     */
53
+    public $phpmin = array(5, 4);
54
+
55
+    /**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';
59
+    public $version = 'dolibarr';
60 60
 
61 61
 
62
-	/**
63
-	 *	Constructor
64
-	 *
65
-	 *  @param		DoliDB		$db      Database handler
66
-	 */
67
-	function __construct($db)
68
-	{
69
-		global $conf, $langs, $mysoc;
62
+    /**
63
+     *	Constructor
64
+     *
65
+     *  @param		DoliDB		$db      Database handler
66
+     */
67
+    function __construct($db)
68
+    {
69
+        global $conf, $langs, $mysoc;
70 70
 
71
-		// Load translation files required by the page
71
+        // Load translation files required by the page
72 72
         $langs->loadLangs(array("main","companies"));
73 73
 
74
-		$this->db = $db;
75
-		$this->name = "ODT templates";
76
-		$this->description = $langs->trans("DocumentModelOdt");
77
-		$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
78
-
79
-		// Dimension page pour format A4
80
-		$this->type = 'odt';
81
-		$this->page_largeur = 0;
82
-		$this->page_hauteur = 0;
83
-		$this->format = array($this->page_largeur,$this->page_hauteur);
84
-		$this->marge_gauche=0;
85
-		$this->marge_droite=0;
86
-		$this->marge_haute=0;
87
-		$this->marge_basse=0;
88
-
89
-		$this->option_logo = 1;                    // Affiche logo
90
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
91
-		$this->option_modereg = 0;                 // Affiche mode reglement
92
-		$this->option_condreg = 0;                 // Affiche conditions reglement
93
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
94
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
95
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
96
-		$this->option_credit_note = 0;             // Support credit notes
97
-		$this->option_freetext = 1;				   // Support add of a personalised text
98
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
99
-
100
-		// Recupere emetteur
101
-		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
103
-	}
104
-
105
-
106
-	/**
107
-	 *	Return description of a module
108
-	 *
109
-	 *	@param	Translate	$langs      Lang object to use for output
110
-	 *	@return string       			Description
111
-	 */
112
-	function info($langs)
113
-	{
114
-		global $conf,$langs;
115
-
116
-		// Load translation files required by the page
74
+        $this->db = $db;
75
+        $this->name = "ODT templates";
76
+        $this->description = $langs->trans("DocumentModelOdt");
77
+        $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
78
+
79
+        // Dimension page pour format A4
80
+        $this->type = 'odt';
81
+        $this->page_largeur = 0;
82
+        $this->page_hauteur = 0;
83
+        $this->format = array($this->page_largeur,$this->page_hauteur);
84
+        $this->marge_gauche=0;
85
+        $this->marge_droite=0;
86
+        $this->marge_haute=0;
87
+        $this->marge_basse=0;
88
+
89
+        $this->option_logo = 1;                    // Affiche logo
90
+        $this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
91
+        $this->option_modereg = 0;                 // Affiche mode reglement
92
+        $this->option_condreg = 0;                 // Affiche conditions reglement
93
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
94
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
95
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
96
+        $this->option_credit_note = 0;             // Support credit notes
97
+        $this->option_freetext = 1;				   // Support add of a personalised text
98
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
99
+
100
+        // Recupere emetteur
101
+        $this->emetteur=$mysoc;
102
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
103
+    }
104
+
105
+
106
+    /**
107
+     *	Return description of a module
108
+     *
109
+     *	@param	Translate	$langs      Lang object to use for output
110
+     *	@return string       			Description
111
+     */
112
+    function info($langs)
113
+    {
114
+        global $conf,$langs;
115
+
116
+        // Load translation files required by the page
117 117
         $langs->loadLangs(array("errors","companies"));
118 118
 
119
-		$form = new Form($this->db);
120
-
121
-		$texte = $this->description.".<br>\n";
122
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
-		$texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
-		$texte.= '<table class="nobordernopadding" width="100%">';
127
-
128
-		// List of directories area
129
-		$texte.= '<tr><td>';
130
-		$texttitle=$langs->trans("ListOfDirectories");
131
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
-		$listoffiles=array();
133
-		foreach($listofdir as $key=>$tmpdir)
134
-		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
138
-				unset($listofdir[$key]); continue;
139
-			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
142
-			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
-			}
146
-		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
148
-		// Add list of substitution keys
149
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
-
152
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
155
-		$texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
-		$texte.= '</textarea>';
157
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
-		$texte.= '<br></div></div>';
160
-
161
-		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164
-		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
168
-			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
170
-		}
171
-
172
-		if ($nbofiles)
173
-		{
174
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
-   			foreach($listoffiles as $file)
176
-   			{
119
+        $form = new Form($this->db);
120
+
121
+        $texte = $this->description.".<br>\n";
122
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
+        $texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
+        $texte.= '<table class="nobordernopadding" width="100%">';
127
+
128
+        // List of directories area
129
+        $texte.= '<tr><td>';
130
+        $texttitle=$langs->trans("ListOfDirectories");
131
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
+        $listoffiles=array();
133
+        foreach($listofdir as $key=>$tmpdir)
134
+        {
135
+            $tmpdir=trim($tmpdir);
136
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
+            if (! $tmpdir) {
138
+                unset($listofdir[$key]); continue;
139
+            }
140
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
+            else
142
+            {
143
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
+            }
146
+        }
147
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
148
+        // Add list of substitution keys
149
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
+
152
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
155
+        $texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
+        $texte.= '</textarea>';
157
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
+        $texte.= '<br></div></div>';
160
+
161
+        // Scan directories
162
+        $nbofiles=count($listoffiles);
163
+        if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164
+        {
165
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
+            $texte.=count($listoffiles);
168
+            //$texte.=$nbofiles?'</a>':'';
169
+            $texte.='</b>';
170
+        }
171
+
172
+        if ($nbofiles)
173
+        {
174
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
+                foreach($listoffiles as $file)
176
+                {
177 177
                 $texte.=$file['name'].'<br>';
178
-   			}
179
-   			$texte.='<div id="div_'.get_class($this).'">';
180
-		}
178
+                }
179
+                $texte.='<div id="div_'.get_class($this).'">';
180
+        }
181 181
 
182
-		$texte.= '</td>';
182
+        $texte.= '</td>';
183 183
 
184
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
186
-		$texte.= '</td>';
187
-		$texte.= '</tr>';
184
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
186
+        $texte.= '</td>';
187
+        $texte.= '</tr>';
188 188
 
189
-		$texte.= '</table>';
190
-		$texte.= '</form>';
189
+        $texte.= '</table>';
190
+        $texte.= '</form>';
191 191
 
192
-		return $texte;
193
-	}
192
+        return $texte;
193
+    }
194 194
 
195 195
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
196
-	/**
197
-	 *	Function to build a document on disk using the generic odt module.
198
-	 *
199
-	 *	@param		Commande	$object				Object source to build document
200
-	 *	@param		Translate	$outputlangs		Lang output object
201
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
202
-	 *  @param		int			$hidedetails		Do not show line details
203
-	 *  @param		int			$hidedesc			Do not show desc
204
-	 *  @param		int			$hideref			Do not show ref
205
-	 *	@return		int         					1 if OK, <=0 if KO
206
-	 */
207
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
208
-	{
196
+    /**
197
+     *	Function to build a document on disk using the generic odt module.
198
+     *
199
+     *	@param		Commande	$object				Object source to build document
200
+     *	@param		Translate	$outputlangs		Lang output object
201
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
202
+     *  @param		int			$hidedetails		Do not show line details
203
+     *  @param		int			$hidedesc			Do not show desc
204
+     *  @param		int			$hideref			Do not show ref
205
+     *	@return		int         					1 if OK, <=0 if KO
206
+     */
207
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
208
+    {
209 209
         // phpcs:enable
210
-		global $user,$langs,$conf,$mysoc,$hookmanager;
211
-
212
-		if (empty($srctemplatepath))
213
-		{
214
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
215
-			return -1;
216
-		}
217
-
218
-		// Add odtgeneration hook
219
-		if (! is_object($hookmanager))
220
-		{
221
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
-			$hookmanager=new HookManager($this->db);
223
-		}
224
-		$hookmanager->initHooks(array('odtgeneration'));
225
-		global $action;
226
-
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
228
-		$sav_charset_output=$outputlangs->charset_output;
229
-		$outputlangs->charset_output='UTF-8';
230
-
231
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
-
233
-		if ($conf->commande->dir_output)
234
-		{
235
-			// If $object is id instead of object
236
-			if (! is_object($object))
237
-			{
238
-				$id = $object;
239
-				$object = new Commande($this->db);
240
-				$result=$object->fetch($id);
241
-				if ($result < 0)
242
-				{
243
-					dol_print_error($this->db,$object->error);
244
-					return -1;
245
-				}
246
-			}
247
-
248
-			$dir = $conf->commande->dir_output;
249
-			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
252
-
253
-			if (! file_exists($dir))
254
-			{
255
-				if (dol_mkdir($dir) < 0)
256
-				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
-					return -1;
259
-				}
260
-			}
261
-
262
-			if (file_exists($dir))
263
-			{
264
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
265
-				$newfile=basename($srctemplatepath);
266
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
270
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
-				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274
-				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
280
-				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
282
-				}
283
-				$file=$dir.'/'.$filename;
284
-				//print "newdir=".$dir;
285
-				//print "newfile=".$newfile;
286
-				//print "file=".$file;
287
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
-
289
-				dol_mkdir($conf->commande->dir_temp);
290
-
291
-
292
-				// If CUSTOMER contact defined on order, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
295
-				if (count($arrayidcontact) > 0)
296
-				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
299
-				}
300
-
301
-				// Recipient name
302
-				$contactobject=null;
303
-				if (! empty($usecontact))
304
-				{
305
-					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307
-					else {
210
+        global $user,$langs,$conf,$mysoc,$hookmanager;
211
+
212
+        if (empty($srctemplatepath))
213
+        {
214
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
215
+            return -1;
216
+        }
217
+
218
+        // Add odtgeneration hook
219
+        if (! is_object($hookmanager))
220
+        {
221
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
+            $hookmanager=new HookManager($this->db);
223
+        }
224
+        $hookmanager->initHooks(array('odtgeneration'));
225
+        global $action;
226
+
227
+        if (! is_object($outputlangs)) $outputlangs=$langs;
228
+        $sav_charset_output=$outputlangs->charset_output;
229
+        $outputlangs->charset_output='UTF-8';
230
+
231
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
+
233
+        if ($conf->commande->dir_output)
234
+        {
235
+            // If $object is id instead of object
236
+            if (! is_object($object))
237
+            {
238
+                $id = $object;
239
+                $object = new Commande($this->db);
240
+                $result=$object->fetch($id);
241
+                if ($result < 0)
242
+                {
243
+                    dol_print_error($this->db,$object->error);
244
+                    return -1;
245
+                }
246
+            }
247
+
248
+            $dir = $conf->commande->dir_output;
249
+            $objectref = dol_sanitizeFileName($object->ref);
250
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
+            $file = $dir . "/" . $objectref . ".odt";
252
+
253
+            if (! file_exists($dir))
254
+            {
255
+                if (dol_mkdir($dir) < 0)
256
+                {
257
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
+                    return -1;
259
+                }
260
+            }
261
+
262
+            if (file_exists($dir))
263
+            {
264
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
265
+                $newfile=basename($srctemplatepath);
266
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
+                $newfiletmp=$objectref.'_'.$newfiletmp;
270
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
+                // Get extension (ods or odt)
272
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274
+                {
275
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
277
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
+                }
279
+                else
280
+                {
281
+                    $filename=$newfiletmp.'.'.$newfileformat;
282
+                }
283
+                $file=$dir.'/'.$filename;
284
+                //print "newdir=".$dir;
285
+                //print "newfile=".$newfile;
286
+                //print "file=".$file;
287
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
+
289
+                dol_mkdir($conf->commande->dir_temp);
290
+
291
+
292
+                // If CUSTOMER contact defined on order, we use it
293
+                $usecontact=false;
294
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
295
+                if (count($arrayidcontact) > 0)
296
+                {
297
+                    $usecontact=true;
298
+                    $result=$object->fetch_contact($arrayidcontact[0]);
299
+                }
300
+
301
+                // Recipient name
302
+                $contactobject=null;
303
+                if (! empty($usecontact))
304
+                {
305
+                    // On peut utiliser le nom de la societe du contact
306
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307
+                    else {
308 308
                         $socobject = $object->thirdparty;
309
-               			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310
-            			$contactobject = $object->contact;
309
+                            // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310
+                        $contactobject = $object->contact;
311 311
                     }
312
-				}
313
-				else
314
-				{
315
-					$socobject=$object->thirdparty;
316
-				}
317
-
318
-				// Make substitution
319
-				$substitutionarray=array(
320
-				'__FROM_NAME__' => $this->emetteur->name,
321
-				'__FROM_EMAIL__' => $this->emetteur->email,
322
-				'__TOTAL_TTC__' => $object->total_ttc,
323
-				'__TOTAL_HT__' => $object->total_ht,
324
-				'__TOTAL_VAT__' => $object->total_vat
325
-				);
326
-				complete_substitutions_array($substitutionarray, $langs, $object);
327
-				// Call the ODTSubstitution hook
328
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
329
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
330
-
331
-				// Line of free text
332
-				$newfreetext='';
333
-				$paramfreetext='ORDER_FREE_TEXT';
334
-				if (! empty($conf->global->$paramfreetext))
335
-				{
336
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
337
-				}
338
-
339
-				// Open and load template
340
-				require_once ODTPHP_PATH.'odf.php';
341
-				try {
342
-					$odfHandler = new odf(
343
-						$srctemplatepath,
344
-						array(
345
-						'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347
-						'DELIMITER_LEFT'  => '{',
348
-						'DELIMITER_RIGHT' => '}'
349
-						)
350
-					);
351
-				}
352
-				catch(Exception $e)
353
-				{
354
-					$this->error=$e->getMessage();
355
-					dol_syslog($e->getMessage(), LOG_INFO);
356
-					return -1;
357
-				}
358
-				// After construction $odfHandler->contentXml contains content and
359
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
360
-				// [!-- BEGIN lines --]*[!-- END lines --]
361
-				//print html_entity_decode($odfHandler->__toString());
362
-				//print exit;
363
-
364
-
365
-				// Make substitutions into odt of freetext
366
-				try {
367
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
-				}
369
-				catch(OdfException $e)
370
-				{
312
+                }
313
+                else
314
+                {
315
+                    $socobject=$object->thirdparty;
316
+                }
317
+
318
+                // Make substitution
319
+                $substitutionarray=array(
320
+                '__FROM_NAME__' => $this->emetteur->name,
321
+                '__FROM_EMAIL__' => $this->emetteur->email,
322
+                '__TOTAL_TTC__' => $object->total_ttc,
323
+                '__TOTAL_HT__' => $object->total_ht,
324
+                '__TOTAL_VAT__' => $object->total_vat
325
+                );
326
+                complete_substitutions_array($substitutionarray, $langs, $object);
327
+                // Call the ODTSubstitution hook
328
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
329
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
330
+
331
+                // Line of free text
332
+                $newfreetext='';
333
+                $paramfreetext='ORDER_FREE_TEXT';
334
+                if (! empty($conf->global->$paramfreetext))
335
+                {
336
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
337
+                }
338
+
339
+                // Open and load template
340
+                require_once ODTPHP_PATH.'odf.php';
341
+                try {
342
+                    $odfHandler = new odf(
343
+                        $srctemplatepath,
344
+                        array(
345
+                        'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347
+                        'DELIMITER_LEFT'  => '{',
348
+                        'DELIMITER_RIGHT' => '}'
349
+                        )
350
+                    );
351
+                }
352
+                catch(Exception $e)
353
+                {
354
+                    $this->error=$e->getMessage();
371 355
                     dol_syslog($e->getMessage(), LOG_INFO);
372
-				}
373
-
374
-				// Define substitution array
375
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
376
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
377
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
378
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
379
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
380
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
381
-				$array_other=$this->get_substitutionarray_other($outputlangs);
382
-				// retrieve contact information for use in object as contact_xxx tags
383
-				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
385
-
386
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387
-				complete_substitutions_array($tmparray, $outputlangs, $object);
388
-
389
-				// Call the ODTSubstitution hook
390
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
391
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
392
-
393
-				foreach($tmparray as $key=>$value)
394
-				{
395
-					try {
396
-						if (preg_match('/logo$/',$key)) // Image
397
-						{
398
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
399
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
-						}
401
-						else    // Text
402
-						{
403
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
404
-						}
405
-					}
406
-					catch(OdfException $e)
407
-					{
356
+                    return -1;
357
+                }
358
+                // After construction $odfHandler->contentXml contains content and
359
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
360
+                // [!-- BEGIN lines --]*[!-- END lines --]
361
+                //print html_entity_decode($odfHandler->__toString());
362
+                //print exit;
363
+
364
+
365
+                // Make substitutions into odt of freetext
366
+                try {
367
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
+                }
369
+                catch(OdfException $e)
370
+                {
371
+                    dol_syslog($e->getMessage(), LOG_INFO);
372
+                }
373
+
374
+                // Define substitution array
375
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
376
+                $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
377
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
378
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
379
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
380
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
381
+                $array_other=$this->get_substitutionarray_other($outputlangs);
382
+                // retrieve contact information for use in object as contact_xxx tags
383
+                $array_thirdparty_contact = array();
384
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
385
+
386
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387
+                complete_substitutions_array($tmparray, $outputlangs, $object);
388
+
389
+                // Call the ODTSubstitution hook
390
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
391
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
392
+
393
+                foreach($tmparray as $key=>$value)
394
+                {
395
+                    try {
396
+                        if (preg_match('/logo$/',$key)) // Image
397
+                        {
398
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
399
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
+                        }
401
+                        else    // Text
402
+                        {
403
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
404
+                        }
405
+                    }
406
+                    catch(OdfException $e)
407
+                    {
408 408
                         dol_syslog($e->getMessage(), LOG_INFO);
409
-					}
410
-				}
411
-				// Replace tags of lines
412
-				try
413
-				{
414
-					$foundtagforlines = 1;
415
-					try {
416
-						$listlines = $odfHandler->setSegment('lines');
417
-					}
418
-					catch(OdfException $e)
419
-					{
420
-						// We may arrive here if tags for lines not present into template
421
-						$foundtagforlines = 0;
422
-						dol_syslog($e->getMessage(), LOG_INFO);
423
-					}
424
-					if ($foundtagforlines)
425
-					{
426
-						foreach ($object->lines as $line)
427
-						{
428
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
429
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
430
-							// Call the ODTSubstitutionLine hook
431
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
432
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
433
-							foreach($tmparray as $key => $val)
434
-							{
435
-								try
436
-								{
437
-									$listlines->setVars($key, $val, true, 'UTF-8');
438
-								}
439
-								catch(OdfException $e)
440
-								{
409
+                    }
410
+                }
411
+                // Replace tags of lines
412
+                try
413
+                {
414
+                    $foundtagforlines = 1;
415
+                    try {
416
+                        $listlines = $odfHandler->setSegment('lines');
417
+                    }
418
+                    catch(OdfException $e)
419
+                    {
420
+                        // We may arrive here if tags for lines not present into template
421
+                        $foundtagforlines = 0;
422
+                        dol_syslog($e->getMessage(), LOG_INFO);
423
+                    }
424
+                    if ($foundtagforlines)
425
+                    {
426
+                        foreach ($object->lines as $line)
427
+                        {
428
+                            $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
429
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
430
+                            // Call the ODTSubstitutionLine hook
431
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
432
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
433
+                            foreach($tmparray as $key => $val)
434
+                            {
435
+                                try
436
+                                {
437
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
438
+                                }
439
+                                catch(OdfException $e)
440
+                                {
441 441
                                     dol_syslog($e->getMessage(), LOG_INFO);
442
-								}
443
-								catch(SegmentException $e)
444
-								{
442
+                                }
443
+                                catch(SegmentException $e)
444
+                                {
445 445
                                     dol_syslog($e->getMessage(), LOG_INFO);
446
-								}
447
-							}
448
-							$listlines->merge();
449
-						}
450
-						$odfHandler->mergeSegment($listlines);
451
-					}
452
-				}
453
-				catch(OdfException $e)
454
-				{
455
-					$this->error=$e->getMessage();
456
-					dol_syslog($this->error, LOG_WARNING);
457
-					return -1;
458
-				}
459
-
460
-				// Replace labels translated
461
-				$tmparray=$outputlangs->get_translations_for_substitutions();
462
-				foreach($tmparray as $key=>$value)
463
-				{
464
-					try {
465
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
466
-					}
467
-					catch(OdfException $e)
468
-					{
446
+                                }
447
+                            }
448
+                            $listlines->merge();
449
+                        }
450
+                        $odfHandler->mergeSegment($listlines);
451
+                    }
452
+                }
453
+                catch(OdfException $e)
454
+                {
455
+                    $this->error=$e->getMessage();
456
+                    dol_syslog($this->error, LOG_WARNING);
457
+                    return -1;
458
+                }
459
+
460
+                // Replace labels translated
461
+                $tmparray=$outputlangs->get_translations_for_substitutions();
462
+                foreach($tmparray as $key=>$value)
463
+                {
464
+                    try {
465
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
466
+                    }
467
+                    catch(OdfException $e)
468
+                    {
469 469
                         dol_syslog($e->getMessage(), LOG_INFO);
470
-					}
471
-				}
470
+                    }
471
+                }
472 472
 
473
-				// Call the beforeODTSave hook
473
+                // Call the beforeODTSave hook
474 474
 
475
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
476
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
475
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
476
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
477 477
 
478
-				// Write new file
479
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480
-					try {
481
-						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
478
+                // Write new file
479
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480
+                    try {
481
+                        $odfHandler->exportAsAttachedPDF($file);
482
+                    }catch (Exception $e){
483 483
                         $this->error=$e->getMessage();
484 484
                         dol_syslog($e->getMessage(), LOG_INFO);
485
-						return -1;
486
-					}
487
-				}
488
-				else {
489
-					try {
490
-					$odfHandler->saveToDisk($file);
491
-					} catch (Exception $e) {
485
+                        return -1;
486
+                    }
487
+                }
488
+                else {
489
+                    try {
490
+                    $odfHandler->saveToDisk($file);
491
+                    } catch (Exception $e) {
492 492
                         $this->error=$e->getMessage();
493 493
                         dol_syslog($e->getMessage(), LOG_INFO);
494
-						return -1;
495
-					}
496
-				}
494
+                        return -1;
495
+                    }
496
+                }
497 497
 
498
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
500 500
 
501
-				if (! empty($conf->global->MAIN_UMASK))
502
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
501
+                if (! empty($conf->global->MAIN_UMASK))
502
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
503 503
 
504
-				$odfHandler=null;	// Destroy object
504
+                $odfHandler=null;	// Destroy object
505 505
 
506
-				$this->result = array('fullpath'=>$file);
506
+                $this->result = array('fullpath'=>$file);
507 507
 
508
-				return 1;   // Success
509
-			}
510
-			else
511
-			{
512
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513
-				return -1;
514
-			}
515
-		}
508
+                return 1;   // Success
509
+            }
510
+            else
511
+            {
512
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513
+                return -1;
514
+            }
515
+        }
516 516
 
517
-		return -1;
518
-	}
517
+        return -1;
518
+    }
519 519
 }
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 		global $conf, $langs, $mysoc;
70 70
 
71 71
 		// Load translation files required by the page
72
-        $langs->loadLangs(array("main","companies"));
72
+        $langs->loadLangs(array("main", "companies"));
73 73
 
74 74
 		$this->db = $db;
75 75
 		$this->name = "ODT templates";
76 76
 		$this->description = $langs->trans("DocumentModelOdt");
77
-		$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
77
+		$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
78 78
 
79 79
 		// Dimension page pour format A4
80 80
 		$this->type = 'odt';
81 81
 		$this->page_largeur = 0;
82 82
 		$this->page_hauteur = 0;
83
-		$this->format = array($this->page_largeur,$this->page_hauteur);
84
-		$this->marge_gauche=0;
85
-		$this->marge_droite=0;
86
-		$this->marge_haute=0;
87
-		$this->marge_basse=0;
88
-
89
-		$this->option_logo = 1;                    // Affiche logo
90
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
91
-		$this->option_modereg = 0;                 // Affiche mode reglement
92
-		$this->option_condreg = 0;                 // Affiche conditions reglement
93
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
94
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
95
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
96
-		$this->option_credit_note = 0;             // Support credit notes
97
-		$this->option_freetext = 1;				   // Support add of a personalised text
98
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
83
+		$this->format = array($this->page_largeur, $this->page_hauteur);
84
+		$this->marge_gauche = 0;
85
+		$this->marge_droite = 0;
86
+		$this->marge_haute = 0;
87
+		$this->marge_basse = 0;
88
+
89
+		$this->option_logo = 1; // Affiche logo
90
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
91
+		$this->option_modereg = 0; // Affiche mode reglement
92
+		$this->option_condreg = 0; // Affiche conditions reglement
93
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
94
+		$this->option_multilang = 1; // Dispo en plusieurs langues
95
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
96
+		$this->option_credit_note = 0; // Support credit notes
97
+		$this->option_freetext = 1; // Support add of a personalised text
98
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
99 99
 
100 100
 		// Recupere emetteur
101
-		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+		$this->emetteur = $mysoc;
102
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
103 103
 	}
104 104
 
105 105
 
@@ -111,83 +111,83 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	function info($langs)
113 113
 	{
114
-		global $conf,$langs;
114
+		global $conf, $langs;
115 115
 
116 116
 		// Load translation files required by the page
117
-        $langs->loadLangs(array("errors","companies"));
117
+        $langs->loadLangs(array("errors", "companies"));
118 118
 
119 119
 		$form = new Form($this->db);
120 120
 
121 121
 		$texte = $this->description.".<br>\n";
122
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
-		$texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
-		$texte.= '<table class="nobordernopadding" width="100%">';
122
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
125
+		$texte .= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
+		$texte .= '<table class="nobordernopadding" width="100%">';
127 127
 
128 128
 		// List of directories area
129
-		$texte.= '<tr><td>';
130
-		$texttitle=$langs->trans("ListOfDirectories");
131
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
-		$listoffiles=array();
133
-		foreach($listofdir as $key=>$tmpdir)
129
+		$texte .= '<tr><td>';
130
+		$texttitle = $langs->trans("ListOfDirectories");
131
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
+		$listoffiles = array();
133
+		foreach ($listofdir as $key=>$tmpdir)
134 134
 		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
135
+			$tmpdir = trim($tmpdir);
136
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
137
+			if (!$tmpdir) {
138 138
 				unset($listofdir[$key]); continue;
139 139
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
140
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
141 141
 			else
142 142
 			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
143
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
144
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
145 145
 			}
146 146
 		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
147
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
148 148
 		// Add list of substitution keys
149
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
-
152
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
155
-		$texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
-		$texte.= '</textarea>';
157
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
-		$texte.= '<br></div></div>';
149
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
151
+
152
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
153
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
155
+		$texte .= $conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
+		$texte .= '</textarea>';
157
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
158
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
+		$texte .= '<br></div></div>';
160 160
 
161 161
 		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
162
+		$nbofiles = count($listoffiles);
163
+		if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164 164
 		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
165
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
166 166
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
167
+			$texte .= count($listoffiles);
168 168
 			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
169
+			$texte .= '</b>';
170 170
 		}
171 171
 
172 172
 		if ($nbofiles)
173 173
 		{
174
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
-   			foreach($listoffiles as $file)
174
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
175
+   			foreach ($listoffiles as $file)
176 176
    			{
177
-                $texte.=$file['name'].'<br>';
177
+                $texte .= $file['name'].'<br>';
178 178
    			}
179
-   			$texte.='<div id="div_'.get_class($this).'">';
179
+   			$texte .= '<div id="div_'.get_class($this).'">';
180 180
 		}
181 181
 
182
-		$texte.= '</td>';
182
+		$texte .= '</td>';
183 183
 
184
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
186
-		$texte.= '</td>';
187
-		$texte.= '</tr>';
184
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
186
+		$texte .= '</td>';
187
+		$texte .= '</tr>';
188 188
 
189
-		$texte.= '</table>';
190
-		$texte.= '</form>';
189
+		$texte .= '</table>';
190
+		$texte .= '</form>';
191 191
 
192 192
 		return $texte;
193 193
 	}
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	 *  @param		int			$hideref			Do not show ref
205 205
 	 *	@return		int         					1 if OK, <=0 if KO
206 206
 	 */
207
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
207
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
208 208
 	{
209 209
         // phpcs:enable
210
-		global $user,$langs,$conf,$mysoc,$hookmanager;
210
+		global $user, $langs, $conf, $mysoc, $hookmanager;
211 211
 
212 212
 		if (empty($srctemplatepath))
213 213
 		{
@@ -216,45 +216,45 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 
218 218
 		// Add odtgeneration hook
219
-		if (! is_object($hookmanager))
219
+		if (!is_object($hookmanager))
220 220
 		{
221 221
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
-			$hookmanager=new HookManager($this->db);
222
+			$hookmanager = new HookManager($this->db);
223 223
 		}
224 224
 		$hookmanager->initHooks(array('odtgeneration'));
225 225
 		global $action;
226 226
 
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
228
-		$sav_charset_output=$outputlangs->charset_output;
229
-		$outputlangs->charset_output='UTF-8';
227
+		if (!is_object($outputlangs)) $outputlangs = $langs;
228
+		$sav_charset_output = $outputlangs->charset_output;
229
+		$outputlangs->charset_output = 'UTF-8';
230 230
 
231 231
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232 232
 
233 233
 		if ($conf->commande->dir_output)
234 234
 		{
235 235
 			// If $object is id instead of object
236
-			if (! is_object($object))
236
+			if (!is_object($object))
237 237
 			{
238 238
 				$id = $object;
239 239
 				$object = new Commande($this->db);
240
-				$result=$object->fetch($id);
240
+				$result = $object->fetch($id);
241 241
 				if ($result < 0)
242 242
 				{
243
-					dol_print_error($this->db,$object->error);
243
+					dol_print_error($this->db, $object->error);
244 244
 					return -1;
245 245
 				}
246 246
 			}
247 247
 
248 248
 			$dir = $conf->commande->dir_output;
249 249
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
250
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
251
+			$file = $dir."/".$objectref.".odt";
252 252
 
253
-			if (! file_exists($dir))
253
+			if (!file_exists($dir))
254 254
 			{
255 255
 				if (dol_mkdir($dir) < 0)
256 256
 				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
257
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
258 258
 					return -1;
259 259
 				}
260 260
 			}
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
 			if (file_exists($dir))
263 263
 			{
264 264
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
265
-				$newfile=basename($srctemplatepath);
266
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
265
+				$newfile = basename($srctemplatepath);
266
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
267
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
268
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
269
+				$newfiletmp = $objectref.'_'.$newfiletmp;
270 270
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271 271
 				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
272
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
273
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
274 274
 				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
275
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
276
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
277
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
281
+					$filename = $newfiletmp.'.'.$newfileformat;
282 282
 				}
283
-				$file=$dir.'/'.$filename;
283
+				$file = $dir.'/'.$filename;
284 284
 				//print "newdir=".$dir;
285 285
 				//print "newfile=".$newfile;
286 286
 				//print "file=".$file;
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
 
291 291
 
292 292
 				// If CUSTOMER contact defined on order, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
293
+				$usecontact = false;
294
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
295 295
 				if (count($arrayidcontact) > 0)
296 296
 				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
297
+					$usecontact = true;
298
+					$result = $object->fetch_contact($arrayidcontact[0]);
299 299
 				}
300 300
 
301 301
 				// Recipient name
302
-				$contactobject=null;
303
-				if (! empty($usecontact))
302
+				$contactobject = null;
303
+				if (!empty($usecontact))
304 304
 				{
305 305
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
306
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307 307
 					else {
308 308
                         $socobject = $object->thirdparty;
309 309
                			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 				}
313 313
 				else
314 314
 				{
315
-					$socobject=$object->thirdparty;
315
+					$socobject = $object->thirdparty;
316 316
 				}
317 317
 
318 318
 				// Make substitution
319
-				$substitutionarray=array(
319
+				$substitutionarray = array(
320 320
 				'__FROM_NAME__' => $this->emetteur->name,
321 321
 				'__FROM_EMAIL__' => $this->emetteur->email,
322 322
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 				);
326 326
 				complete_substitutions_array($substitutionarray, $langs, $object);
327 327
 				// Call the ODTSubstitution hook
328
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
329
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
329
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
330 330
 
331 331
 				// Line of free text
332
-				$newfreetext='';
333
-				$paramfreetext='ORDER_FREE_TEXT';
334
-				if (! empty($conf->global->$paramfreetext))
332
+				$newfreetext = '';
333
+				$paramfreetext = 'ORDER_FREE_TEXT';
334
+				if (!empty($conf->global->$paramfreetext))
335 335
 				{
336
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
336
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
337 337
 				}
338 338
 
339 339
 				// Open and load template
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 						$srctemplatepath,
344 344
 						array(
345 345
 						'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
346
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347 347
 						'DELIMITER_LEFT'  => '{',
348 348
 						'DELIMITER_RIGHT' => '}'
349 349
 						)
350 350
 					);
351 351
 				}
352
-				catch(Exception $e)
352
+				catch (Exception $e)
353 353
 				{
354
-					$this->error=$e->getMessage();
354
+					$this->error = $e->getMessage();
355 355
 					dol_syslog($e->getMessage(), LOG_INFO);
356 356
 					return -1;
357 357
 				}
@@ -366,34 +366,34 @@  discard block
 block discarded – undo
366 366
 				try {
367 367
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368 368
 				}
369
-				catch(OdfException $e)
369
+				catch (OdfException $e)
370 370
 				{
371 371
                     dol_syslog($e->getMessage(), LOG_INFO);
372 372
 				}
373 373
 
374 374
 				// Define substitution array
375 375
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
376
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
377
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
378
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
379
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
380
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
381
-				$array_other=$this->get_substitutionarray_other($outputlangs);
376
+				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
377
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
378
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
379
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
380
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
381
+				$array_other = $this->get_substitutionarray_other($outputlangs);
382 382
 				// retrieve contact information for use in object as contact_xxx tags
383 383
 				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
384
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
385 385
 
386
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
386
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
387 387
 				complete_substitutions_array($tmparray, $outputlangs, $object);
388 388
 
389 389
 				// Call the ODTSubstitution hook
390
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
391
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
390
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
391
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
392 392
 
393
-				foreach($tmparray as $key=>$value)
393
+				foreach ($tmparray as $key=>$value)
394 394
 				{
395 395
 					try {
396
-						if (preg_match('/logo$/',$key)) // Image
396
+						if (preg_match('/logo$/', $key)) // Image
397 397
 						{
398 398
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
399 399
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
404 404
 						}
405 405
 					}
406
-					catch(OdfException $e)
406
+					catch (OdfException $e)
407 407
 					{
408 408
                         dol_syslog($e->getMessage(), LOG_INFO);
409 409
 					}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					try {
416 416
 						$listlines = $odfHandler->setSegment('lines');
417 417
 					}
418
-					catch(OdfException $e)
418
+					catch (OdfException $e)
419 419
 					{
420 420
 						// We may arrive here if tags for lines not present into template
421 421
 						$foundtagforlines = 0;
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 					{
426 426
 						foreach ($object->lines as $line)
427 427
 						{
428
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
428
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
429 429
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
430 430
 							// Call the ODTSubstitutionLine hook
431
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
432
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
433
-							foreach($tmparray as $key => $val)
431
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
432
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
433
+							foreach ($tmparray as $key => $val)
434 434
 							{
435 435
 								try
436 436
 								{
437 437
 									$listlines->setVars($key, $val, true, 'UTF-8');
438 438
 								}
439
-								catch(OdfException $e)
439
+								catch (OdfException $e)
440 440
 								{
441 441
                                     dol_syslog($e->getMessage(), LOG_INFO);
442 442
 								}
443
-								catch(SegmentException $e)
443
+								catch (SegmentException $e)
444 444
 								{
445 445
                                     dol_syslog($e->getMessage(), LOG_INFO);
446 446
 								}
@@ -450,21 +450,21 @@  discard block
 block discarded – undo
450 450
 						$odfHandler->mergeSegment($listlines);
451 451
 					}
452 452
 				}
453
-				catch(OdfException $e)
453
+				catch (OdfException $e)
454 454
 				{
455
-					$this->error=$e->getMessage();
455
+					$this->error = $e->getMessage();
456 456
 					dol_syslog($this->error, LOG_WARNING);
457 457
 					return -1;
458 458
 				}
459 459
 
460 460
 				// Replace labels translated
461
-				$tmparray=$outputlangs->get_translations_for_substitutions();
462
-				foreach($tmparray as $key=>$value)
461
+				$tmparray = $outputlangs->get_translations_for_substitutions();
462
+				foreach ($tmparray as $key=>$value)
463 463
 				{
464 464
 					try {
465 465
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
466 466
 					}
467
-					catch(OdfException $e)
467
+					catch (OdfException $e)
468 468
 					{
469 469
                         dol_syslog($e->getMessage(), LOG_INFO);
470 470
 					}
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 
473 473
 				// Call the beforeODTSave hook
474 474
 
475
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
476
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
475
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
476
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
477 477
 
478 478
 				// Write new file
479 479
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480 480
 					try {
481 481
 						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
483
-                        $this->error=$e->getMessage();
482
+					} catch (Exception $e) {
483
+                        $this->error = $e->getMessage();
484 484
                         dol_syslog($e->getMessage(), LOG_INFO);
485 485
 						return -1;
486 486
 					}
@@ -489,27 +489,27 @@  discard block
 block discarded – undo
489 489
 					try {
490 490
 					$odfHandler->saveToDisk($file);
491 491
 					} catch (Exception $e) {
492
-                        $this->error=$e->getMessage();
492
+                        $this->error = $e->getMessage();
493 493
                         dol_syslog($e->getMessage(), LOG_INFO);
494 494
 						return -1;
495 495
 					}
496 496
 				}
497 497
 
498
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
499
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
500 500
 
501
-				if (! empty($conf->global->MAIN_UMASK))
501
+				if (!empty($conf->global->MAIN_UMASK))
502 502
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
503 503
 
504
-				$odfHandler=null;	// Destroy object
504
+				$odfHandler = null; // Destroy object
505 505
 
506 506
 				$this->result = array('fullpath'=>$file);
507 507
 
508
-				return 1;   // Success
508
+				return 1; // Success
509 509
 			}
510 510
 			else
511 511
 			{
512
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
512
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
513 513
 				return -1;
514 514
 			}
515 515
 		}
Please login to merge, or discard this patch.
Braces   +47 added lines, -41 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Recupere emetteur
101 101
 		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
102
+		if (! $this->emetteur->country_code) {
103
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
104
+		}
105
+		// By default if not defined
103 106
 	}
104 107
 
105 108
 
@@ -137,11 +140,14 @@  discard block
 block discarded – undo
137 140
 			if (! $tmpdir) {
138 141
 				unset($listofdir[$key]); continue;
139 142
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
143
+			if (! is_dir($tmpdir)) {
144
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+			} else
142 146
 			{
143 147
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+				if (count($tmpfiles)) {
149
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
150
+				}
145 151
 			}
146 152
 		}
147 153
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -224,7 +230,9 @@  discard block
 block discarded – undo
224 230
 		$hookmanager->initHooks(array('odtgeneration'));
225 231
 		global $action;
226 232
 
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
233
+		if (! is_object($outputlangs)) {
234
+		    $outputlangs=$langs;
235
+		}
228 236
 		$sav_charset_output=$outputlangs->charset_output;
229 237
 		$outputlangs->charset_output='UTF-8';
230 238
 
@@ -247,7 +255,9 @@  discard block
 block discarded – undo
247 255
 
248 256
 			$dir = $conf->commande->dir_output;
249 257
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
258
+			if (! preg_match('/specimen/i',$objectref)) {
259
+			    $dir.= "/" . $objectref;
260
+			}
251 261
 			$file = $dir . "/" . $objectref . ".odt";
252 262
 
253 263
 			if (! file_exists($dir))
@@ -273,10 +283,11 @@  discard block
 block discarded – undo
273 283
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274 284
 				{
275 285
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
286
+				    if ($format == '1') {
287
+				        $format='%Y%m%d%H%M%S';
288
+				    }
277 289
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
290
+				} else
280 291
 				{
281 292
 					$filename=$newfiletmp.'.'.$newfileformat;
282 293
 				}
@@ -303,14 +314,14 @@  discard block
 block discarded – undo
303 314
 				if (! empty($usecontact))
304 315
 				{
305 316
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307
-					else {
317
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
318
+					    $socobject = $object->contact;
319
+					} else {
308 320
                         $socobject = $object->thirdparty;
309 321
                			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310 322
             			$contactobject = $object->contact;
311 323
                     }
312
-				}
313
-				else
324
+				} else
314 325
 				{
315 326
 					$socobject=$object->thirdparty;
316 327
 				}
@@ -348,8 +359,7 @@  discard block
 block discarded – undo
348 359
 						'DELIMITER_RIGHT' => '}'
349 360
 						)
350 361
 					);
351
-				}
352
-				catch(Exception $e)
362
+				} catch(Exception $e)
353 363
 				{
354 364
 					$this->error=$e->getMessage();
355 365
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -365,8 +375,7 @@  discard block
 block discarded – undo
365 375
 				// Make substitutions into odt of freetext
366 376
 				try {
367 377
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
-				}
369
-				catch(OdfException $e)
378
+				} catch(OdfException $e)
370 379
 				{
371 380
                     dol_syslog($e->getMessage(), LOG_INFO);
372 381
 				}
@@ -381,7 +390,9 @@  discard block
 block discarded – undo
381 390
 				$array_other=$this->get_substitutionarray_other($outputlangs);
382 391
 				// retrieve contact information for use in object as contact_xxx tags
383 392
 				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
393
+				if ($usecontact && is_object($contactobject)) {
394
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
395
+				}
385 396
 
386 397
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387 398
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -393,17 +404,18 @@  discard block
 block discarded – undo
393 404
 				foreach($tmparray as $key=>$value)
394 405
 				{
395 406
 					try {
396
-						if (preg_match('/logo$/',$key)) // Image
407
+						if (preg_match('/logo$/',$key)) {
408
+						    // Image
397 409
 						{
398 410
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
399
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
-						}
401
-						else    // Text
411
+						} else {
412
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
413
+							}
414
+						} else    // Text
402 415
 						{
403 416
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
404 417
 						}
405
-					}
406
-					catch(OdfException $e)
418
+					} catch(OdfException $e)
407 419
 					{
408 420
                         dol_syslog($e->getMessage(), LOG_INFO);
409 421
 					}
@@ -414,8 +426,7 @@  discard block
 block discarded – undo
414 426
 					$foundtagforlines = 1;
415 427
 					try {
416 428
 						$listlines = $odfHandler->setSegment('lines');
417
-					}
418
-					catch(OdfException $e)
429
+					} catch(OdfException $e)
419 430
 					{
420 431
 						// We may arrive here if tags for lines not present into template
421 432
 						$foundtagforlines = 0;
@@ -435,12 +446,10 @@  discard block
 block discarded – undo
435 446
 								try
436 447
 								{
437 448
 									$listlines->setVars($key, $val, true, 'UTF-8');
438
-								}
439
-								catch(OdfException $e)
449
+								} catch(OdfException $e)
440 450
 								{
441 451
                                     dol_syslog($e->getMessage(), LOG_INFO);
442
-								}
443
-								catch(SegmentException $e)
452
+								} catch(SegmentException $e)
444 453
 								{
445 454
                                     dol_syslog($e->getMessage(), LOG_INFO);
446 455
 								}
@@ -449,8 +458,7 @@  discard block
 block discarded – undo
449 458
 						}
450 459
 						$odfHandler->mergeSegment($listlines);
451 460
 					}
452
-				}
453
-				catch(OdfException $e)
461
+				} catch(OdfException $e)
454 462
 				{
455 463
 					$this->error=$e->getMessage();
456 464
 					dol_syslog($this->error, LOG_WARNING);
@@ -463,8 +471,7 @@  discard block
 block discarded – undo
463 471
 				{
464 472
 					try {
465 473
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
466
-					}
467
-					catch(OdfException $e)
474
+					} catch(OdfException $e)
468 475
 					{
469 476
                         dol_syslog($e->getMessage(), LOG_INFO);
470 477
 					}
@@ -479,13 +486,12 @@  discard block
 block discarded – undo
479 486
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480 487
 					try {
481 488
 						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
489
+					} catch (Exception $e){
483 490
                         $this->error=$e->getMessage();
484 491
                         dol_syslog($e->getMessage(), LOG_INFO);
485 492
 						return -1;
486 493
 					}
487
-				}
488
-				else {
494
+				} else {
489 495
 					try {
490 496
 					$odfHandler->saveToDisk($file);
491 497
 					} catch (Exception $e) {
@@ -498,16 +504,16 @@  discard block
 block discarded – undo
498 504
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499 505
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
500 506
 
501
-				if (! empty($conf->global->MAIN_UMASK))
502
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
507
+				if (! empty($conf->global->MAIN_UMASK)) {
508
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
509
+				}
503 510
 
504 511
 				$odfHandler=null;	// Destroy object
505 512
 
506 513
 				$this->result = array('fullpath'=>$file);
507 514
 
508 515
 				return 1;   // Success
509
-			}
510
-			else
516
+			} else
511 517
 			{
512 518
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513 519
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_einstein.modules.php 3 patches
Indentation   +1186 added lines, -1186 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public $db;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model name
52 52
      */
53 53
     public $name;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string model description (short text)
57 57
      */
58 58
     public $description;
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public $update_main_doc_field;
64 64
 
65
-	/**
65
+    /**
66 66
      * @var string document type
67 67
      */
68 68
     public $type;
69 69
 
70
-	/**
70
+    /**
71 71
      * @var array() Minimum version of PHP required by module.
72
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
72
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
73 73
      */
74
-	public $phpmin = array(5, 4);
74
+    public $phpmin = array(5, 4);
75 75
 
76
-	/**
76
+    /**
77 77
      * Dolibarr version of the loaded document
78 78
      * @public string
79 79
      */
80
-	public $version = 'dolibarr';
80
+    public $version = 'dolibarr';
81 81
 
82
-	/**
82
+    /**
83 83
      * @var int page_largeur
84 84
      */
85 85
     public $page_largeur;
@@ -97,111 +97,111 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      * @var int marge_gauche
99 99
      */
100
-	public $marge_gauche;
100
+    public $marge_gauche;
101 101
 
102
-	/**
102
+    /**
103 103
      * @var int marge_droite
104 104
      */
105
-	public $marge_droite;
105
+    public $marge_droite;
106 106
 
107
-	/**
107
+    /**
108 108
      * @var int marge_haute
109 109
      */
110
-	public $marge_haute;
110
+    public $marge_haute;
111 111
 
112
-	/**
112
+    /**
113 113
      * @var int marge_basse
114 114
      */
115
-	public $marge_basse;
115
+    public $marge_basse;
116 116
 
117
-	/**
118
-	 * Issuer
119
-	 * @var Company object that emits
120
-	 */
117
+    /**
118
+     * Issuer
119
+     * @var Company object that emits
120
+     */
121 121
     public $emetteur;
122 122
 
123 123
 
124
-	/**
125
-	 *	Constructor
126
-	 *
127
-	 *  @param		DoliDB		$db      Database handler
128
-	 */
129
-	public function __construct($db)
130
-	{
131
-		global $conf,$langs,$mysoc;
132
-
133
-		// Translations
134
-		$langs->loadLangs(array("main", "bills", "products"));
135
-
136
-		$this->db = $db;
137
-		$this->name = "einstein";
138
-		$this->description = $langs->trans('PDFEinsteinDescription');
139
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
140
-
141
-		// Dimension page
142
-		$this->type = 'pdf';
143
-		$formatarray=pdf_getFormat();
144
-		$this->page_largeur = $formatarray['width'];
145
-		$this->page_hauteur = $formatarray['height'];
146
-		$this->format = array($this->page_largeur,$this->page_hauteur);
147
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
148
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
149
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
150
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
151
-
152
-		$this->option_logo = 1;                    // Display logo
153
-		$this->option_tva = 1;                     // Manage the vat option FACTURE_TVAOPTION
154
-		$this->option_modereg = 1;                 // Display payment mode
155
-		$this->option_condreg = 1;                 // Display payment terms
156
-		$this->option_codeproduitservice = 1;      // Display product-service code
157
-		$this->option_multilang = 1;               // Available in several languages
158
-		$this->option_escompte = 0;                // Displays if there has been a discount
159
-		$this->option_credit_note = 0;             // Support credit notes
160
-		$this->option_freetext = 1;				   // Support add of a personalised text
161
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
162
-
163
-		$this->franchise=!$mysoc->tva_assuj;
164
-
165
-		// Get source company
166
-		$this->emetteur=$mysoc;
167
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
168
-
169
-		// Define position of columns
170
-		$this->posxdesc=$this->marge_gauche+1;
171
-		if($conf->global->PRODUCT_USE_UNITS)
172
-		{
173
-			$this->posxtva=101;
174
-			$this->posxup=118;
175
-			$this->posxqty=135;
176
-			$this->posxunit=151;
177
-		}
178
-		else
179
-		{
180
-			$this->posxtva=110;
181
-			$this->posxup=126;
182
-			$this->posxqty=145;
183
-		}
184
-		$this->posxdiscount=162;
185
-		$this->postotalht=174;
186
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
187
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
188
-		if ($this->page_largeur < 210) // To work with US executive format
189
-		{
190
-			$this->posxpicture-=20;
191
-			$this->posxtva-=20;
192
-			$this->posxup-=20;
193
-			$this->posxqty-=20;
194
-			$this->posxunit-=20;
195
-			$this->posxdiscount-=20;
196
-			$this->postotalht-=20;
197
-		}
198
-
199
-		$this->tva=array();
200
-		$this->localtax1=array();
201
-		$this->localtax2=array();
202
-		$this->atleastoneratenotnull=0;
203
-		$this->atleastonediscount=0;
204
-	}
124
+    /**
125
+     *	Constructor
126
+     *
127
+     *  @param		DoliDB		$db      Database handler
128
+     */
129
+    public function __construct($db)
130
+    {
131
+        global $conf,$langs,$mysoc;
132
+
133
+        // Translations
134
+        $langs->loadLangs(array("main", "bills", "products"));
135
+
136
+        $this->db = $db;
137
+        $this->name = "einstein";
138
+        $this->description = $langs->trans('PDFEinsteinDescription');
139
+        $this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
140
+
141
+        // Dimension page
142
+        $this->type = 'pdf';
143
+        $formatarray=pdf_getFormat();
144
+        $this->page_largeur = $formatarray['width'];
145
+        $this->page_hauteur = $formatarray['height'];
146
+        $this->format = array($this->page_largeur,$this->page_hauteur);
147
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
148
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
149
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
150
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
151
+
152
+        $this->option_logo = 1;                    // Display logo
153
+        $this->option_tva = 1;                     // Manage the vat option FACTURE_TVAOPTION
154
+        $this->option_modereg = 1;                 // Display payment mode
155
+        $this->option_condreg = 1;                 // Display payment terms
156
+        $this->option_codeproduitservice = 1;      // Display product-service code
157
+        $this->option_multilang = 1;               // Available in several languages
158
+        $this->option_escompte = 0;                // Displays if there has been a discount
159
+        $this->option_credit_note = 0;             // Support credit notes
160
+        $this->option_freetext = 1;				   // Support add of a personalised text
161
+        $this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
162
+
163
+        $this->franchise=!$mysoc->tva_assuj;
164
+
165
+        // Get source company
166
+        $this->emetteur=$mysoc;
167
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
168
+
169
+        // Define position of columns
170
+        $this->posxdesc=$this->marge_gauche+1;
171
+        if($conf->global->PRODUCT_USE_UNITS)
172
+        {
173
+            $this->posxtva=101;
174
+            $this->posxup=118;
175
+            $this->posxqty=135;
176
+            $this->posxunit=151;
177
+        }
178
+        else
179
+        {
180
+            $this->posxtva=110;
181
+            $this->posxup=126;
182
+            $this->posxqty=145;
183
+        }
184
+        $this->posxdiscount=162;
185
+        $this->postotalht=174;
186
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
187
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
188
+        if ($this->page_largeur < 210) // To work with US executive format
189
+        {
190
+            $this->posxpicture-=20;
191
+            $this->posxtva-=20;
192
+            $this->posxup-=20;
193
+            $this->posxqty-=20;
194
+            $this->posxunit-=20;
195
+            $this->posxdiscount-=20;
196
+            $this->postotalht-=20;
197
+        }
198
+
199
+        $this->tva=array();
200
+        $this->localtax1=array();
201
+        $this->localtax2=array();
202
+        $this->atleastoneratenotnull=0;
203
+        $this->atleastonediscount=0;
204
+    }
205 205
 
206 206
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
207 207
     /**
@@ -214,71 +214,71 @@  discard block
 block discarded – undo
214 214
      *  @param		int			$hidedesc			Do not show desc
215 215
      *  @param		int			$hideref			Do not show ref
216 216
      *  @return     int             			    1=OK, 0=KO
217
-	 */
218
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
219
-	{
217
+     */
218
+    function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
219
+    {
220 220
         // phpcs:enable
221
-		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
221
+        global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 222
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
224
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
223
+        if (! is_object($outputlangs)) $outputlangs=$langs;
224
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
226 226
 
227
-		// Load translation files required by the page
228
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
227
+        // Load translation files required by the page
228
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
229 229
 
230
-		$nblignes = count($object->lines);
230
+        $nblignes = count($object->lines);
231 231
 
232
-		if ($conf->commande->dir_output)
233
-		{
232
+        if ($conf->commande->dir_output)
233
+        {
234 234
             $object->fetch_thirdparty();
235 235
 
236 236
             $deja_regle = 0;
237 237
 
238 238
             // Definition of $dir and $file
239
-			if ($object->specimen)
240
-			{
241
-				$dir = $conf->commande->dir_output;
242
-				$file = $dir . "/SPECIMEN.pdf";
243
-			}
244
-			else
245
-			{
246
-				$objectref = dol_sanitizeFileName($object->ref);
247
-				$dir = $conf->commande->dir_output . "/" . $objectref;
248
-				$file = $dir . "/" . $objectref . ".pdf";
249
-			}
250
-
251
-			if (! file_exists($dir))
252
-			{
253
-				if (dol_mkdir($dir) < 0)
254
-				{
255
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
256
-					return 0;
257
-				}
258
-			}
239
+            if ($object->specimen)
240
+            {
241
+                $dir = $conf->commande->dir_output;
242
+                $file = $dir . "/SPECIMEN.pdf";
243
+            }
244
+            else
245
+            {
246
+                $objectref = dol_sanitizeFileName($object->ref);
247
+                $dir = $conf->commande->dir_output . "/" . $objectref;
248
+                $file = $dir . "/" . $objectref . ".pdf";
249
+            }
250
+
251
+            if (! file_exists($dir))
252
+            {
253
+                if (dol_mkdir($dir) < 0)
254
+                {
255
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
256
+                    return 0;
257
+                }
258
+            }
259 259
 
260
-			if (file_exists($dir))
261
-			{
262
-				// Add pdfgeneration hook
263
-				if (! is_object($hookmanager))
264
-				{
265
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
-					$hookmanager=new HookManager($this->db);
267
-				}
268
-				$hookmanager->initHooks(array('pdfgeneration'));
269
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
270
-				global $action;
271
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
260
+            if (file_exists($dir))
261
+            {
262
+                // Add pdfgeneration hook
263
+                if (! is_object($hookmanager))
264
+                {
265
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
+                    $hookmanager=new HookManager($this->db);
267
+                }
268
+                $hookmanager->initHooks(array('pdfgeneration'));
269
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
270
+                global $action;
271
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
272 272
 
273
-				// Create pdf instance
274
-				$pdf=pdf_getInstance($this->format);
275
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
276
-				$pdf->SetAutoPageBreak(1,0);
273
+                // Create pdf instance
274
+                $pdf=pdf_getInstance($this->format);
275
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
276
+                $pdf->SetAutoPageBreak(1,0);
277 277
 
278
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
279
-		        $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
280
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
281
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
278
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
279
+                $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
280
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
281
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
282 282
 
283 283
                 if (class_exists('TCPDF'))
284 284
                 {
@@ -293,422 +293,422 @@  discard block
 block discarded – undo
293 293
                     $tplidx = $pdf->importPage(1);
294 294
                 }
295 295
 
296
-				$pdf->Open();
297
-				$pagenb=0;
298
-				$pdf->SetDrawColor(128,128,128);
296
+                $pdf->Open();
297
+                $pagenb=0;
298
+                $pdf->SetDrawColor(128,128,128);
299 299
 
300
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301
-				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
305
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
300
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301
+                $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
303
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
305
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
306 306
 
307
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
307
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
308 308
 
309
-				// Positionne $this->atleastonediscount si on a au moins une remise
310
-				for ($i = 0 ; $i < $nblignes ; $i++)
311
-				{
312
-					if ($object->lines[$i]->remise_percent)
313
-					{
314
-						$this->atleastonediscount++;
315
-					}
316
-				}
317
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
318
-				{
319
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
320
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
321
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
322
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
323
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
324
-					//$this->postotalht;
325
-				}
309
+                // Positionne $this->atleastonediscount si on a au moins une remise
310
+                for ($i = 0 ; $i < $nblignes ; $i++)
311
+                {
312
+                    if ($object->lines[$i]->remise_percent)
313
+                    {
314
+                        $this->atleastonediscount++;
315
+                    }
316
+                }
317
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
318
+                {
319
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
320
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
321
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
322
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
323
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
324
+                    //$this->postotalht;
325
+                }
326 326
 
327
-				// New page
328
-				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
330
-				$pagenb++;
331
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332
-				$pdf->SetFont('','', $default_font_size - 1);
333
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
334
-				$pdf->SetTextColor(0,0,0);
327
+                // New page
328
+                $pdf->AddPage();
329
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
330
+                $pagenb++;
331
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332
+                $pdf->SetFont('','', $default_font_size - 1);
333
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
334
+                $pdf->SetTextColor(0,0,0);
335 335
 
336 336
 
337
-				$tab_top = 90+$top_shift;
338
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
337
+                $tab_top = 90+$top_shift;
338
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
339 339
 
340
-				// Incoterm
341
-				if ($conf->incoterm->enabled)
342
-				{
343
-					$desc_incoterms = $object->getIncotermsForPDF();
344
-					if ($desc_incoterms)
345
-					{
346
-						$tab_top -= 2;
347
-
348
-						$pdf->SetFont('','', $default_font_size - 1);
349
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350
-						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
352
-
353
-						// Rect prend une longueur en 3eme param
354
-						$pdf->SetDrawColor(192,192,192);
355
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
356
-
357
-						$tab_top = $nexY+6;
358
-					}
359
-				}
340
+                // Incoterm
341
+                if ($conf->incoterm->enabled)
342
+                {
343
+                    $desc_incoterms = $object->getIncotermsForPDF();
344
+                    if ($desc_incoterms)
345
+                    {
346
+                        $tab_top -= 2;
347
+
348
+                        $pdf->SetFont('','', $default_font_size - 1);
349
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350
+                        $nexY = $pdf->GetY();
351
+                        $height_incoterms=$nexY-$tab_top;
352
+
353
+                        // Rect prend une longueur en 3eme param
354
+                        $pdf->SetDrawColor(192,192,192);
355
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
356
+
357
+                        $tab_top = $nexY+6;
358
+                    }
359
+                }
360 360
 
361
-				// Affiche notes
362
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
363
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364
-				{
365
-					// Get first sale rep
366
-					if (is_object($object->thirdparty))
367
-					{
368
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
-						$salerepobj=new User($this->db);
370
-						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
372
-					}
373
-				}
374
-				if ($notetoshow)
375
-				{
376
-					$tab_top -= 2;
361
+                // Affiche notes
362
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
363
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364
+                {
365
+                    // Get first sale rep
366
+                    if (is_object($object->thirdparty))
367
+                    {
368
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
+                        $salerepobj=new User($this->db);
370
+                        $salerepobj->fetch($salereparray[0]['id']);
371
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
372
+                    }
373
+                }
374
+                if ($notetoshow)
375
+                {
376
+                    $tab_top -= 2;
377 377
 
378
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
379
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
380
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
378
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
379
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
380
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
381 381
 
382
-					$pdf->SetFont('','', $default_font_size - 1);
383
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
384
-					$nexY = $pdf->GetY();
385
-					$height_note=$nexY-$tab_top;
382
+                    $pdf->SetFont('','', $default_font_size - 1);
383
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
384
+                    $nexY = $pdf->GetY();
385
+                    $height_note=$nexY-$tab_top;
386 386
 
387
-					// Rect prend une longueur en 3eme param
388
-					$pdf->SetDrawColor(192,192,192);
389
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
387
+                    // Rect prend une longueur en 3eme param
388
+                    $pdf->SetDrawColor(192,192,192);
389
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
390 390
 
391
-					$tab_top = $nexY+6;
392
-				}
391
+                    $tab_top = $nexY+6;
392
+                }
393 393
 
394
-				$iniY = $tab_top + 7;
395
-				$curY = $tab_top + 7;
396
-				$nexY = $tab_top + 7;
394
+                $iniY = $tab_top + 7;
395
+                $curY = $tab_top + 7;
396
+                $nexY = $tab_top + 7;
397 397
 
398
-				// Loop on each lines
399
-				for ($i = 0 ; $i < $nblignes ; $i++)
400
-				{
401
-					$curY = $nexY;
402
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
-					$pdf->SetTextColor(0,0,0);
404
-
405
-					$pdf->setTopMargin($tab_top_newpage);
406
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
407
-					$pageposbefore=$pdf->getPage();
408
-
409
-					// Description of product line
410
-					$curX = $this->posxdesc-1;
411
-
412
-					$showpricebeforepagebreak=1;
413
-
414
-					$pdf->startTransaction();
415
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
-					$pageposafter=$pdf->getPage();
417
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
418
-					{
419
-						$pdf->rollbackTransaction(true);
420
-						$pageposafter=$pageposbefore;
421
-						//print $pageposafter.'-'.$pageposbefore;exit;
422
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424
-						$pageposafter=$pdf->getPage();
425
-						$posyafter=$pdf->GetY();
426
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
427
-						{
428
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429
-							{
430
-								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
-								$pdf->setPage($pageposafter+1);
434
-							}
435
-						}
436
-						else
437
-						{
438
-							// We found a page break
439
-							$showpricebeforepagebreak=0;
440
-						}
441
-					}
442
-					else	// No pagebreak
443
-					{
444
-						$pdf->commitTransaction();
445
-					}
446
-					$posYAfterDescription=$pdf->GetY();
447
-
448
-					$nexY = $pdf->GetY();
449
-					$pageposafter=$pdf->getPage();
450
-
451
-					$pdf->setPage($pageposbefore);
452
-					$pdf->setTopMargin($this->marge_haute);
453
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
454
-
455
-					// We suppose that a too long description is moved completely on next page
456
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458
-					}
459
-
460
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
461
-
462
-					// VAT Rate
463
-					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464
-					{
465
-						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
466
-						$pdf->SetXY($this->posxtva-5, $curY);
467
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
468
-					}
469
-
470
-					// Unit price before discount
471
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472
-					$pdf->SetXY($this->posxup, $curY);
473
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
474
-
475
-					// Quantity
476
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477
-					$pdf->SetXY($this->posxqty, $curY);
478
-					// Enough for 6 chars
479
-					if($conf->global->PRODUCT_USE_UNITS)
480
-					{
481
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
-					}
483
-					else
484
-					{
485
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486
-					}
487
-
488
-					// Unit
489
-					if($conf->global->PRODUCT_USE_UNITS)
490
-					{
491
-						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492
-						$pdf->SetXY($this->posxunit, $curY);
493
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
494
-					}
495
-
496
-					// Discount on line
497
-					$pdf->SetXY($this->posxdiscount, $curY);
498
-					if ($object->lines[$i]->remise_percent)
499
-					{
500
-						$pdf->SetXY($this->posxdiscount-2, $curY);
501
-						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
503
-					}
504
-
505
-					// Total HT line
506
-					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507
-					$pdf->SetXY($this->postotalht, $curY);
508
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509
-
510
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
511
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
512
-					else $tvaligne=$object->lines[$i]->total_tva;
513
-
514
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
515
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
516
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
517
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
518
-					$localtax1_type=$object->lines[$i]->localtax1_type;
519
-					$localtax2_type=$object->lines[$i]->localtax2_type;
520
-
521
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
522
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
523
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
524
-
525
-					$vatrate=(string) $object->lines[$i]->tva_tx;
526
-
527
-					// Retrieve type from database for backward compatibility with old records
528
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
529
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
530
-					{
531
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
532
-						$localtax1_type = $localtaxtmp_array[0];
533
-						$localtax2_type = $localtaxtmp_array[2];
534
-					}
535
-
536
-				    // retrieve global local tax
537
-					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
-					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
541
-
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
544
-					$this->tva[$vatrate] += $tvaligne;
545
-
546
-					// Add line
547
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548
-					{
549
-						$pdf->setPage($pageposafter);
550
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
551
-						//$pdf->SetDrawColor(190,190,200);
552
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
553
-						$pdf->SetLineStyle(array('dash'=>0));
554
-					}
555
-
556
-					$nexY+=2;    // Passe espace entre les lignes
557
-
558
-					// Detect if some page were added automatically and output _tableau for past pages
559
-					while ($pagenb < $pageposafter)
560
-					{
561
-						$pdf->setPage($pagenb);
562
-						if ($pagenb == 1)
563
-						{
564
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
-						}
566
-						else
567
-						{
568
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569
-						}
570
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
571
-						$pagenb++;
572
-						$pdf->setPage($pagenb);
573
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575
-					}
576
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577
-					{
578
-						if ($pagenb == 1)
579
-						{
580
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
-						}
582
-						else
583
-						{
584
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585
-						}
586
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
587
-						// New page
588
-						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
590
-						$pagenb++;
591
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592
-					}
593
-				}
398
+                // Loop on each lines
399
+                for ($i = 0 ; $i < $nblignes ; $i++)
400
+                {
401
+                    $curY = $nexY;
402
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
+                    $pdf->SetTextColor(0,0,0);
404
+
405
+                    $pdf->setTopMargin($tab_top_newpage);
406
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
407
+                    $pageposbefore=$pdf->getPage();
408
+
409
+                    // Description of product line
410
+                    $curX = $this->posxdesc-1;
411
+
412
+                    $showpricebeforepagebreak=1;
413
+
414
+                    $pdf->startTransaction();
415
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
+                    $pageposafter=$pdf->getPage();
417
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
418
+                    {
419
+                        $pdf->rollbackTransaction(true);
420
+                        $pageposafter=$pageposbefore;
421
+                        //print $pageposafter.'-'.$pageposbefore;exit;
422
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424
+                        $pageposafter=$pdf->getPage();
425
+                        $posyafter=$pdf->GetY();
426
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
427
+                        {
428
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429
+                            {
430
+                                $pdf->AddPage('','',true);
431
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
+                                $pdf->setPage($pageposafter+1);
434
+                            }
435
+                        }
436
+                        else
437
+                        {
438
+                            // We found a page break
439
+                            $showpricebeforepagebreak=0;
440
+                        }
441
+                    }
442
+                    else	// No pagebreak
443
+                    {
444
+                        $pdf->commitTransaction();
445
+                    }
446
+                    $posYAfterDescription=$pdf->GetY();
447
+
448
+                    $nexY = $pdf->GetY();
449
+                    $pageposafter=$pdf->getPage();
450
+
451
+                    $pdf->setPage($pageposbefore);
452
+                    $pdf->setTopMargin($this->marge_haute);
453
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
454
+
455
+                    // We suppose that a too long description is moved completely on next page
456
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458
+                    }
459
+
460
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
461
+
462
+                    // VAT Rate
463
+                    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464
+                    {
465
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
466
+                        $pdf->SetXY($this->posxtva-5, $curY);
467
+                        $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
468
+                    }
469
+
470
+                    // Unit price before discount
471
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472
+                    $pdf->SetXY($this->posxup, $curY);
473
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
474
+
475
+                    // Quantity
476
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477
+                    $pdf->SetXY($this->posxqty, $curY);
478
+                    // Enough for 6 chars
479
+                    if($conf->global->PRODUCT_USE_UNITS)
480
+                    {
481
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
+                    }
483
+                    else
484
+                    {
485
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486
+                    }
487
+
488
+                    // Unit
489
+                    if($conf->global->PRODUCT_USE_UNITS)
490
+                    {
491
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492
+                        $pdf->SetXY($this->posxunit, $curY);
493
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
494
+                    }
495
+
496
+                    // Discount on line
497
+                    $pdf->SetXY($this->posxdiscount, $curY);
498
+                    if ($object->lines[$i]->remise_percent)
499
+                    {
500
+                        $pdf->SetXY($this->posxdiscount-2, $curY);
501
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
503
+                    }
504
+
505
+                    // Total HT line
506
+                    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507
+                    $pdf->SetXY($this->postotalht, $curY);
508
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509
+
510
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
511
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
512
+                    else $tvaligne=$object->lines[$i]->total_tva;
513
+
514
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
515
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
516
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
517
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
518
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
519
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
520
+
521
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
522
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
523
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
524
+
525
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
526
+
527
+                    // Retrieve type from database for backward compatibility with old records
528
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
529
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
530
+                    {
531
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
532
+                        $localtax1_type = $localtaxtmp_array[0];
533
+                        $localtax2_type = $localtaxtmp_array[2];
534
+                    }
535
+
536
+                    // retrieve global local tax
537
+                    if ($localtax1_type && $localtax1ligne != 0)
538
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
+                    if ($localtax2_type && $localtax2ligne != 0)
540
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
541
+
542
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
544
+                    $this->tva[$vatrate] += $tvaligne;
545
+
546
+                    // Add line
547
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548
+                    {
549
+                        $pdf->setPage($pageposafter);
550
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
551
+                        //$pdf->SetDrawColor(190,190,200);
552
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
553
+                        $pdf->SetLineStyle(array('dash'=>0));
554
+                    }
555
+
556
+                    $nexY+=2;    // Passe espace entre les lignes
557
+
558
+                    // Detect if some page were added automatically and output _tableau for past pages
559
+                    while ($pagenb < $pageposafter)
560
+                    {
561
+                        $pdf->setPage($pagenb);
562
+                        if ($pagenb == 1)
563
+                        {
564
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
+                        }
566
+                        else
567
+                        {
568
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569
+                        }
570
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
571
+                        $pagenb++;
572
+                        $pdf->setPage($pagenb);
573
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575
+                    }
576
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577
+                    {
578
+                        if ($pagenb == 1)
579
+                        {
580
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
+                        }
582
+                        else
583
+                        {
584
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585
+                        }
586
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
587
+                        // New page
588
+                        $pdf->AddPage();
589
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
590
+                        $pagenb++;
591
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592
+                    }
593
+                }
594 594
 
595
-				// Show square
596
-				if ($pagenb == 1)
597
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
-				else
599
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
600
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
595
+                // Show square
596
+                if ($pagenb == 1)
597
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
+                else
599
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
600
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 601
 
602
-				// Affiche zone infos
603
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
602
+                // Affiche zone infos
603
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
604 604
 
605
-				// Affiche zone totaux
606
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
605
+                // Affiche zone totaux
606
+                $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
607 607
 
608
-				// Affiche zone versements
609
-				/*
608
+                // Affiche zone versements
609
+                /*
610 610
 				if ($deja_regle)
611 611
 				{
612 612
 					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
613 613
 				}
614 614
 				*/
615 615
 
616
-				// Pied de page
617
-				$this->_pagefoot($pdf, $object, $outputlangs);
618
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
616
+                // Pied de page
617
+                $this->_pagefoot($pdf, $object, $outputlangs);
618
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
619 619
 
620
-				$pdf->Close();
620
+                $pdf->Close();
621 621
 
622
-				$pdf->Output($file, 'F');
622
+                $pdf->Output($file, 'F');
623 623
 
624
-				// Add pdfgeneration hook
625
-				$hookmanager->initHooks(array('pdfgeneration'));
626
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627
-				global $action;
628
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
624
+                // Add pdfgeneration hook
625
+                $hookmanager->initHooks(array('pdfgeneration'));
626
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627
+                global $action;
628
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
629 629
 
630
-				if (! empty($conf->global->MAIN_UMASK))
631
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
630
+                if (! empty($conf->global->MAIN_UMASK))
631
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
632 632
 
633
-				$this->result = array('fullpath'=>$file);
633
+                $this->result = array('fullpath'=>$file);
634 634
 
635
-				return 1;   // Pas d'erreur
636
-			}
637
-			else
638
-			{
639
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640
-				return 0;
641
-			}
642
-		}
643
-		else
644
-		{
645
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646
-			return 0;
647
-		}
648
-	}
635
+                return 1;   // Pas d'erreur
636
+            }
637
+            else
638
+            {
639
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640
+                return 0;
641
+            }
642
+        }
643
+        else
644
+        {
645
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646
+            return 0;
647
+        }
648
+    }
649 649
 
650 650
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
651
-	/**
652
-	 *  Show payments table
651
+    /**
652
+     *  Show payments table
653 653
      *
654
-	 *  @param	TCPDF		$pdf     		Object PDF
655
-	 *  @param  Object		$object			Object order
656
-	 *	@param	int			$posy			Position y in PDF
657
-	 *	@param	Translate	$outputlangs	Object langs for output
658
-	 *	@return int							<0 if KO, >0 if OK
659
-	 */
660
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
661
-	{
654
+     *  @param	TCPDF		$pdf     		Object PDF
655
+     *  @param  Object		$object			Object order
656
+     *	@param	int			$posy			Position y in PDF
657
+     *	@param	Translate	$outputlangs	Object langs for output
658
+     *	@return int							<0 if KO, >0 if OK
659
+     */
660
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
661
+    {
662 662
         // phpcs:enable
663
-	}
663
+    }
664 664
 
665 665
 
666 666
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
667
-	/**
668
-	 *   Show miscellaneous information (payment mode, payment term, ...)
669
-	 *
670
-	 *   @param		TCPDF		$pdf     		Object PDF
671
-	 *   @param		Object		$object			Object to show
672
-	 *   @param		int			$posy			Y
673
-	 *   @param		Translate	$outputlangs	Langs object
674
-	 *   @return	void
675
-	 */
676
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
677
-	{
667
+    /**
668
+     *   Show miscellaneous information (payment mode, payment term, ...)
669
+     *
670
+     *   @param		TCPDF		$pdf     		Object PDF
671
+     *   @param		Object		$object			Object to show
672
+     *   @param		int			$posy			Y
673
+     *   @param		Translate	$outputlangs	Langs object
674
+     *   @return	void
675
+     */
676
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
677
+    {
678 678
         // phpcs:enable
679
-		global $conf;
680
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
679
+        global $conf;
680
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
681 681
 
682
-		$pdf->SetFont('','', $default_font_size - 1);
682
+        $pdf->SetFont('','', $default_font_size - 1);
683 683
 
684 684
         // If France, show VAT mention if not applicable
685
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686
-		{
687
-			$pdf->SetFont('','B', $default_font_size - 2);
688
-			$pdf->SetXY($this->marge_gauche, $posy);
689
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
685
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686
+        {
687
+            $pdf->SetFont('','B', $default_font_size - 2);
688
+            $pdf->SetXY($this->marge_gauche, $posy);
689
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
690 690
 
691
-			$posy=$pdf->GetY()+4;
692
-		}
691
+            $posy=$pdf->GetY()+4;
692
+        }
693 693
 
694
-		$posxval=52;
694
+        $posxval=52;
695 695
 
696
-		// Show payments conditions
697
-		if ($object->cond_reglement_code || $object->cond_reglement)
698
-		{
699
-			$pdf->SetFont('','B', $default_font_size - 2);
700
-			$pdf->SetXY($this->marge_gauche, $posy);
701
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
702
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
696
+        // Show payments conditions
697
+        if ($object->cond_reglement_code || $object->cond_reglement)
698
+        {
699
+            $pdf->SetFont('','B', $default_font_size - 2);
700
+            $pdf->SetXY($this->marge_gauche, $posy);
701
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
702
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
703 703
 
704
-			$pdf->SetFont('','', $default_font_size - 2);
705
-			$pdf->SetXY($posxval, $posy);
706
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
708
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
704
+            $pdf->SetFont('','', $default_font_size - 2);
705
+            $pdf->SetXY($posxval, $posy);
706
+            $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
708
+            $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
709 709
 
710
-			$posy=$pdf->GetY()+3;
711
-		}
710
+            $posy=$pdf->GetY()+3;
711
+        }
712 712
 
713 713
         // Check a payment mode is defined
714 714
         /* Not used with orders
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
             $posy=$pdf->GetY()+1;
726 726
         }
727 727
 		*/
728
-		/* TODO
728
+        /* TODO
729 729
 		else if (! empty($object->availability_code))
730 730
 		{
731 731
             $pdf->SetXY($this->marge_gauche, $posy);
@@ -737,719 +737,719 @@  discard block
 block discarded – undo
737 737
             $posy=$pdf->GetY()+1;
738 738
 		}*/
739 739
 
740
-	    // Show planed date of delivery
740
+        // Show planed date of delivery
741 741
         if (! empty($object->date_livraison))
742
-		{
742
+        {
743 743
             $outputlangs->load("sendings");
744
-			$pdf->SetFont('','B', $default_font_size - 2);
745
-			$pdf->SetXY($this->marge_gauche, $posy);
746
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
748
-			$pdf->SetFont('','', $default_font_size - 2);
749
-			$pdf->SetXY($posxval, $posy);
750
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
751
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
744
+            $pdf->SetFont('','B', $default_font_size - 2);
745
+            $pdf->SetXY($this->marge_gauche, $posy);
746
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
748
+            $pdf->SetFont('','', $default_font_size - 2);
749
+            $pdf->SetXY($posxval, $posy);
750
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
751
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 752
 
753 753
             $posy=$pdf->GetY()+1;
754
-		}
754
+        }
755 755
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
756
-		{
757
-			$pdf->SetFont('','B', $default_font_size - 2);
758
-			$pdf->SetXY($this->marge_gauche, $posy);
759
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
761
-			$pdf->SetTextColor(0,0,0);
762
-			$pdf->SetFont('','', $default_font_size - 2);
763
-			$pdf->SetXY($posxval, $posy);
764
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
765
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
766
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767
-
768
-			$posy=$pdf->GetY()+1;
769
-		}
770
-
771
-      	// Show payment mode
756
+        {
757
+            $pdf->SetFont('','B', $default_font_size - 2);
758
+            $pdf->SetXY($this->marge_gauche, $posy);
759
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
761
+            $pdf->SetTextColor(0,0,0);
762
+            $pdf->SetFont('','', $default_font_size - 2);
763
+            $pdf->SetXY($posxval, $posy);
764
+            $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
765
+            $lib_availability=str_replace('\n',"\n",$lib_availability);
766
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767
+
768
+            $posy=$pdf->GetY()+1;
769
+        }
770
+
771
+            // Show payment mode
772 772
         if ($object->mode_reglement_code
773
-        	 && $object->mode_reglement_code != 'CHQ'
774
-           	 && $object->mode_reglement_code != 'VIR')
775
-           	 {
776
-	            $pdf->SetFont('','B', $default_font_size - 2);
777
-	            $pdf->SetXY($this->marge_gauche, $posy);
778
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
779
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
780
-
781
-				$pdf->SetFont('','', $default_font_size - 2);
782
-	            $pdf->SetXY($posxval, $posy);
783
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
784
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
785
-
786
-	            $posy=$pdf->GetY()+2;
787
-           	 }
788
-
789
-		// Show payment mode CHQ
773
+             && $object->mode_reglement_code != 'CHQ'
774
+                && $object->mode_reglement_code != 'VIR')
775
+                {
776
+                $pdf->SetFont('','B', $default_font_size - 2);
777
+                $pdf->SetXY($this->marge_gauche, $posy);
778
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
779
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
780
+
781
+                $pdf->SetFont('','', $default_font_size - 2);
782
+                $pdf->SetXY($posxval, $posy);
783
+                $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
784
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
785
+
786
+                $posy=$pdf->GetY()+2;
787
+                }
788
+
789
+        // Show payment mode CHQ
790 790
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
791 791
         {
792
-        	// Si mode reglement non force ou si force a CHQ
793
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
794
-	        {
795
-	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796
-	            {
797
-	                $account = new Account($this->db);
798
-	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799
-
800
-	                $pdf->SetXY($this->marge_gauche, $posy);
801
-	                $pdf->SetFont('','B', $default_font_size - 3);
802
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
803
-		            $posy=$pdf->GetY()+1;
804
-
805
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806
-		            {
807
-		                $pdf->SetXY($this->marge_gauche, $posy);
808
-		                $pdf->SetFont('','', $default_font_size - 3);
809
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
-			            $posy=$pdf->GetY()+2;
811
-		            }
812
-	            }
813
-	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814
-	            {
815
-	                $pdf->SetXY($this->marge_gauche, $posy);
816
-	                $pdf->SetFont('','B', $default_font_size - 3);
817
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
818
-		            $posy=$pdf->GetY()+1;
819
-
820
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821
-		            {
822
-			            $pdf->SetXY($this->marge_gauche, $posy);
823
-		                $pdf->SetFont('','', $default_font_size - 3);
824
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
-			            $posy=$pdf->GetY()+2;
826
-		            }
827
-	            }
828
-	        }
829
-		}
792
+            // Si mode reglement non force ou si force a CHQ
793
+            if (! empty($conf->global->FACTURE_CHQ_NUMBER))
794
+            {
795
+                if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796
+                {
797
+                    $account = new Account($this->db);
798
+                    $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799
+
800
+                    $pdf->SetXY($this->marge_gauche, $posy);
801
+                    $pdf->SetFont('','B', $default_font_size - 3);
802
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
803
+                    $posy=$pdf->GetY()+1;
804
+
805
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806
+                    {
807
+                        $pdf->SetXY($this->marge_gauche, $posy);
808
+                        $pdf->SetFont('','', $default_font_size - 3);
809
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
+                        $posy=$pdf->GetY()+2;
811
+                    }
812
+                }
813
+                if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814
+                {
815
+                    $pdf->SetXY($this->marge_gauche, $posy);
816
+                    $pdf->SetFont('','B', $default_font_size - 3);
817
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
818
+                    $posy=$pdf->GetY()+1;
819
+
820
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821
+                    {
822
+                        $pdf->SetXY($this->marge_gauche, $posy);
823
+                        $pdf->SetFont('','', $default_font_size - 3);
824
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
+                        $posy=$pdf->GetY()+2;
826
+                    }
827
+                }
828
+            }
829
+        }
830 830
 
831 831
         // If payment mode not forced or forced to VIR, show payment with BAN
832 832
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
833 833
         {
834
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
835
-			{
836
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
837
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
838
-				$account = new Account($this->db);
839
-				$account->fetch($bankid);
834
+            if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
835
+            {
836
+                $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
837
+                if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
838
+                $account = new Account($this->db);
839
+                $account->fetch($bankid);
840 840
 
841
-				$curx=$this->marge_gauche;
842
-				$cury=$posy;
841
+                $curx=$this->marge_gauche;
842
+                $cury=$posy;
843 843
 
844
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
844
+                $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
845 845
 
846
-				$posy+=2;
847
-			}
846
+                $posy+=2;
847
+            }
848 848
         }
849 849
 
850
-		return $posy;
851
-	}
850
+        return $posy;
851
+    }
852 852
 
853 853
 
854 854
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
855
-	/**
856
-	 *	Show total to pay
857
-	 *
858
-	 *	@param	TCPDF		$pdf           Object PDF
859
-	 *	@param  Facture		$object         Object invoice
860
-	 *	@param  int			$deja_regle     Montant deja regle
861
-	 *	@param	int			$posy			Position depart
862
-	 *	@param	Translate	$outputlangs	Objet langs
863
-	 *	@return int							Position pour suite
864
-	 */
865
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866
-	{
855
+    /**
856
+     *	Show total to pay
857
+     *
858
+     *	@param	TCPDF		$pdf           Object PDF
859
+     *	@param  Facture		$object         Object invoice
860
+     *	@param  int			$deja_regle     Montant deja regle
861
+     *	@param	int			$posy			Position depart
862
+     *	@param	Translate	$outputlangs	Objet langs
863
+     *	@return int							Position pour suite
864
+     */
865
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866
+    {
867 867
         // phpcs:enable
868
-	    global $conf,$mysoc;
868
+        global $conf,$mysoc;
869 869
 
870
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
870
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
872
-		$tab2_top = $posy;
873
-		$tab2_hl = 4;
874
-		$pdf->SetFont('','', $default_font_size - 1);
872
+        $tab2_top = $posy;
873
+        $tab2_hl = 4;
874
+        $pdf->SetFont('','', $default_font_size - 1);
875 875
 
876
-		// Tableau total
876
+        // Tableau total
877 877
         $col1x = 120; $col2x = 170;
878
-		if ($this->page_largeur < 210) // To work with US executive format
879
-		{
880
-			$col2x-=20;
881
-		}
882
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
878
+        if ($this->page_largeur < 210) // To work with US executive format
879
+        {
880
+            $col2x-=20;
881
+        }
882
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 883
 
884
-		$useborder=0;
885
-		$index = 0;
884
+        $useborder=0;
885
+        $index = 0;
886 886
 
887
-		// Total HT
888
-		$pdf->SetFillColor(255,255,255);
889
-		$pdf->SetXY($col1x, $tab2_top + 0);
890
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
887
+        // Total HT
888
+        $pdf->SetFillColor(255,255,255);
889
+        $pdf->SetXY($col1x, $tab2_top + 0);
890
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
891 891
 
892
-		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
893
-		$pdf->SetXY($col2x, $tab2_top + 0);
894
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
892
+        $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
893
+        $pdf->SetXY($col2x, $tab2_top + 0);
894
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
895 895
 
896
-		// Show VAT by rates and total
897
-		$pdf->SetFillColor(248,248,248);
896
+        // Show VAT by rates and total
897
+        $pdf->SetFillColor(248,248,248);
898 898
 
899
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
899
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
900 900
 
901
-		$this->atleastoneratenotnull=0;
902
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
903
-		{
904
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906
-			{
907
-				// Nothing to do
908
-			}
909
-			else
910
-			{
911
-				//Local tax 1 before VAT
912
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913
-				//{
914
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915
-					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
-						foreach( $localtax_rate as $tvakey => $tvaval )
918
-						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
920
-							{
921
-								//$this->atleastoneratenotnull++;
922
-
923
-								$index++;
924
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925
-
926
-								$tvacompl='';
927
-								if (preg_match('/\*/',$tvakey))
928
-								{
929
-									$tvakey=str_replace('*','',$tvakey);
930
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
931
-								}
932
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
933
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
934
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
935
-
936
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
938
-							}
939
-						}
940
-					}
941
-	      		//}
942
-				//Local tax 2 before VAT
943
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944
-				//{
945
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946
-					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
-						foreach( $localtax_rate as $tvakey => $tvaval )
949
-						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
951
-							{
952
-								//$this->atleastoneratenotnull++;
953
-
954
-
955
-
956
-								$index++;
957
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958
-
959
-								$tvacompl='';
960
-								if (preg_match('/\*/',$tvakey))
961
-								{
962
-									$tvakey=str_replace('*','',$tvakey);
963
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
964
-								}
965
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
966
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
967
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
968
-
969
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
971
-							}
972
-						}
973
-					}
974
-				//}
975
-				// VAT
976
-				foreach($this->tva as $tvakey => $tvaval)
977
-				{
978
-					if ($tvakey != 0)    // On affiche pas taux 0
979
-					{
980
-						$this->atleastoneratenotnull++;
981
-
982
-						$index++;
983
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984
-
985
-						$tvacompl='';
986
-						if (preg_match('/\*/',$tvakey))
987
-						{
988
-							$tvakey=str_replace('*','',$tvakey);
989
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
990
-						}
991
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
992
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
993
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
994
-
995
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
997
-					}
998
-				}
901
+        $this->atleastoneratenotnull=0;
902
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
903
+        {
904
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906
+            {
907
+                // Nothing to do
908
+            }
909
+            else
910
+            {
911
+                //Local tax 1 before VAT
912
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913
+                //{
914
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915
+                    {
916
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
+                        foreach( $localtax_rate as $tvakey => $tvaval )
918
+                        {
919
+                            if ($tvakey!=0)    // On affiche pas taux 0
920
+                            {
921
+                                //$this->atleastoneratenotnull++;
922
+
923
+                                $index++;
924
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925
+
926
+                                $tvacompl='';
927
+                                if (preg_match('/\*/',$tvakey))
928
+                                {
929
+                                    $tvakey=str_replace('*','',$tvakey);
930
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
931
+                                }
932
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
933
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
934
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
935
+
936
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
938
+                            }
939
+                        }
940
+                    }
941
+                    //}
942
+                //Local tax 2 before VAT
943
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944
+                //{
945
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946
+                    {
947
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
+                        foreach( $localtax_rate as $tvakey => $tvaval )
949
+                        {
950
+                            if ($tvakey!=0)    // On affiche pas taux 0
951
+                            {
952
+                                //$this->atleastoneratenotnull++;
953
+
954
+
955
+
956
+                                $index++;
957
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958
+
959
+                                $tvacompl='';
960
+                                if (preg_match('/\*/',$tvakey))
961
+                                {
962
+                                    $tvakey=str_replace('*','',$tvakey);
963
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
964
+                                }
965
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
966
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
967
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
968
+
969
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
971
+                            }
972
+                        }
973
+                    }
974
+                //}
975
+                // VAT
976
+                foreach($this->tva as $tvakey => $tvaval)
977
+                {
978
+                    if ($tvakey != 0)    // On affiche pas taux 0
979
+                    {
980
+                        $this->atleastoneratenotnull++;
981
+
982
+                        $index++;
983
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984
+
985
+                        $tvacompl='';
986
+                        if (preg_match('/\*/',$tvakey))
987
+                        {
988
+                            $tvakey=str_replace('*','',$tvakey);
989
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
990
+                        }
991
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
992
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
993
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
994
+
995
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
997
+                    }
998
+                }
999
+
1000
+                //Local tax 1 after VAT
1001
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002
+                //{
1003
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004
+                    {
1005
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1006
+
1007
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1008
+                        {
1009
+                            if ($tvakey != 0)    // On affiche pas taux 0
1010
+                            {
1011
+                                //$this->atleastoneratenotnull++;
1012
+
1013
+                                $index++;
1014
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015
+
1016
+                                $tvacompl='';
1017
+                                if (preg_match('/\*/',$tvakey))
1018
+                                {
1019
+                                    $tvakey=str_replace('*','',$tvakey);
1020
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021
+                                }
1022
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1023
+
1024
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028
+                            }
1029
+                        }
1030
+                    }
1031
+                    //}
1032
+                //Local tax 2 after VAT
1033
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034
+                //{
1035
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036
+                    {
1037
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1038
+
1039
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1040
+                        {
1041
+                            if ($tvakey != 0)    // On affiche pas taux 0
1042
+                            {
1043
+                                //$this->atleastoneratenotnull++;
1044
+
1045
+                                $index++;
1046
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047
+
1048
+                                $tvacompl='';
1049
+                                if (preg_match('/\*/',$tvakey))
1050
+                                {
1051
+                                    $tvakey=str_replace('*','',$tvakey);
1052
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053
+                                }
1054
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1055
+
1056
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058
+
1059
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1061
+                            }
1062
+                        }
1063
+                    }
1064
+                //}
1065
+
1066
+                // Total TTC
1067
+                $index++;
1068
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069
+                $pdf->SetTextColor(0,0,60);
1070
+                $pdf->SetFillColor(224,224,224);
1071
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1072
+
1073
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075
+            }
1076
+        }
999 1077
 
1000
-				//Local tax 1 after VAT
1001
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002
-				//{
1003
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004
-					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1006
-
1007
-						foreach( $localtax_rate as $tvakey => $tvaval )
1008
-						{
1009
-							if ($tvakey != 0)    // On affiche pas taux 0
1010
-							{
1011
-								//$this->atleastoneratenotnull++;
1012
-
1013
-								$index++;
1014
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015
-
1016
-								$tvacompl='';
1017
-								if (preg_match('/\*/',$tvakey))
1018
-								{
1019
-									$tvakey=str_replace('*','',$tvakey);
1020
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021
-								}
1022
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1023
-
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028
-							}
1029
-						}
1030
-					}
1031
-	      		//}
1032
-				//Local tax 2 after VAT
1033
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034
-				//{
1035
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036
-					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1038
-
1039
-						foreach( $localtax_rate as $tvakey => $tvaval )
1040
-						{
1041
-							if ($tvakey != 0)    // On affiche pas taux 0
1042
-							{
1043
-								//$this->atleastoneratenotnull++;
1044
-
1045
-								$index++;
1046
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047
-
1048
-								$tvacompl='';
1049
-								if (preg_match('/\*/',$tvakey))
1050
-								{
1051
-									$tvakey=str_replace('*','',$tvakey);
1052
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053
-								}
1054
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1055
-
1056
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058
-
1059
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1061
-							}
1062
-						}
1063
-					}
1064
-				//}
1065
-
1066
-				// Total TTC
1067
-				$index++;
1068
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069
-				$pdf->SetTextColor(0,0,60);
1070
-				$pdf->SetFillColor(224,224,224);
1071
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1072
-
1073
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075
-			}
1076
-		}
1077
-
1078
-		$pdf->SetTextColor(0,0,0);
1078
+        $pdf->SetTextColor(0,0,0);
1079 1079
 
1080 1080
         $creditnoteamount=0;
1081 1081
         $depositsamount=0;
1082
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
1083
-		//$depositsamount=$object->getSumDepositsUsed();
1084
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1082
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
1083
+        //$depositsamount=$object->getSumDepositsUsed();
1084
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
1085
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
+        if (! empty($object->paye)) $resteapayer=0;
1087 1087
 
1088
-		if ($deja_regle > 0)
1089
-		{
1090
-			// Already paid + Deposits
1091
-			$index++;
1092
-
1093
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1097
-
1098
-			$index++;
1099
-			$pdf->SetTextColor(0,0,60);
1100
-			$pdf->SetFillColor(224,224,224);
1101
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1103
-
1104
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1106
-
1107
-			$pdf->SetFont('','', $default_font_size - 1);
1108
-			$pdf->SetTextColor(0,0,0);
1109
-		}
1110
-
1111
-		$index++;
1112
-		return ($tab2_top + ($tab2_hl * $index));
1113
-	}
1114
-
1115
-	/**
1116
-	 *   Show table for lines
1117
-	 *
1118
-	 *   @param		TCPDF		$pdf     		Object PDF
1119
-	 *   @param		string		$tab_top		Top position of table
1120
-	 *   @param		string		$tab_height		Height of table (rectangle)
1121
-	 *   @param		int			$nexY			Y (not used)
1122
-	 *   @param		Translate	$outputlangs	Langs object
1123
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1124
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1125
-	 *   @param		string		$currency		Currency code
1126
-	 *   @return	void
1127
-	 */
1128
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1129
-	{
1130
-		global $conf;
1131
-
1132
-		// Force to disable hidetop and hidebottom
1133
-		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1135
-
1136
-		$currency = !empty($currency) ? $currency : $conf->currency;
1137
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1138
-
1139
-		// Amount in (at tab_top - 1)
1140
-		$pdf->SetTextColor(0,0,0);
1141
-		$pdf->SetFont('','', $default_font_size - 2);
1142
-
1143
-		if (empty($hidetop))
1144
-		{
1145
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1147
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1088
+        if ($deja_regle > 0)
1089
+        {
1090
+            // Already paid + Deposits
1091
+            $index++;
1148 1092
 
1149
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1150
-			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));
1151
-		}
1093
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1152 1097
 
1153
-		$pdf->SetDrawColor(128,128,128);
1154
-		$pdf->SetFont('','', $default_font_size - 1);
1098
+            $index++;
1099
+            $pdf->SetTextColor(0,0,60);
1100
+            $pdf->SetFillColor(224,224,224);
1101
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1155 1103
 
1156
-		// Output Rect
1157
-		$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
1104
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1158 1106
 
1159
-		if (empty($hidetop))
1160
-		{
1161
-			$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
1107
+            $pdf->SetFont('','', $default_font_size - 1);
1108
+            $pdf->SetTextColor(0,0,0);
1109
+        }
1162 1110
 
1163
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1165
-		}
1111
+        $index++;
1112
+        return ($tab2_top + ($tab2_hl * $index));
1113
+    }
1166 1114
 
1167
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168
-		{
1169
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1170
-			if (empty($hidetop))
1171
-			{
1172
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1174
-			}
1175
-		}
1176
-
1177
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1178
-		if (empty($hidetop))
1179
-		{
1180
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1181
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1182
-		}
1115
+    /**
1116
+     *   Show table for lines
1117
+     *
1118
+     *   @param		TCPDF		$pdf     		Object PDF
1119
+     *   @param		string		$tab_top		Top position of table
1120
+     *   @param		string		$tab_height		Height of table (rectangle)
1121
+     *   @param		int			$nexY			Y (not used)
1122
+     *   @param		Translate	$outputlangs	Langs object
1123
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1124
+     *   @param		int			$hidebottom		Hide bottom bar of array
1125
+     *   @param		string		$currency		Currency code
1126
+     *   @return	void
1127
+     */
1128
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1129
+    {
1130
+        global $conf;
1183 1131
 
1184
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1185
-		if (empty($hidetop))
1186
-		{
1187
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
-			if($conf->global->PRODUCT_USE_UNITS)
1189
-			{
1190
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
-			}
1192
-			else
1193
-			{
1194
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195
-			}
1196
-		}
1197
-
1198
-		if($conf->global->PRODUCT_USE_UNITS) {
1199
-			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200
-			if (empty($hidetop)) {
1201
-				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1202
-				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1203
-					'C');
1204
-			}
1205
-		}
1206
-
1207
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1208
-		if (empty($hidetop))
1209
-		{
1210
-			if ($this->atleastonediscount)
1211
-			{
1212
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1214
-			}
1215
-		}
1216
-
1217
-		if ($this->atleastonediscount)
1218
-		{
1219
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1220
-		}
1221
-		if (empty($hidetop))
1222
-		{
1223
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1225
-		}
1226
-	}
1227
-
1228
-	/**
1229
-	 *  Show top header of page.
1230
-	 *
1231
-	 *  @param	TCPDF		$pdf     		Object PDF
1232
-	 *  @param  Object		$object     	Object to show
1233
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1234
-	 *  @param  Translate	$outputlangs	Object lang for output
1235
-	 *  @param	string		$titlekey		Translation key to show as title of document
1236
-	 *  @return	void
1237
-	 */
1238
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1239
-	{
1240
-		global $conf,$langs,$hookmanager;
1241
-
1242
-		// Load traductions files requiredby by page
1243
-		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244
-
1245
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1246
-
1247
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1248
-
1249
-		// Show Draft Watermark
1250
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1251
-		{
1132
+        // Force to disable hidetop and hidebottom
1133
+        $hidebottom=0;
1134
+        if ($hidetop) $hidetop=-1;
1135
+
1136
+        $currency = !empty($currency) ? $currency : $conf->currency;
1137
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1138
+
1139
+        // Amount in (at tab_top - 1)
1140
+        $pdf->SetTextColor(0,0,0);
1141
+        $pdf->SetFont('','', $default_font_size - 2);
1142
+
1143
+        if (empty($hidetop))
1144
+        {
1145
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1147
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148
+
1149
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1150
+            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));
1151
+        }
1152
+
1153
+        $pdf->SetDrawColor(128,128,128);
1154
+        $pdf->SetFont('','', $default_font_size - 1);
1155
+
1156
+        // Output Rect
1157
+        $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
1158
+
1159
+        if (empty($hidetop))
1160
+        {
1161
+            $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
1162
+
1163
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1165
+        }
1166
+
1167
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168
+        {
1169
+            $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1170
+            if (empty($hidetop))
1171
+            {
1172
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1174
+            }
1175
+        }
1176
+
1177
+        $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1178
+        if (empty($hidetop))
1179
+        {
1180
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1181
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1182
+        }
1183
+
1184
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1185
+        if (empty($hidetop))
1186
+        {
1187
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
+            if($conf->global->PRODUCT_USE_UNITS)
1189
+            {
1190
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
+            }
1192
+            else
1193
+            {
1194
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195
+            }
1196
+        }
1197
+
1198
+        if($conf->global->PRODUCT_USE_UNITS) {
1199
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200
+            if (empty($hidetop)) {
1201
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1202
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1203
+                    'C');
1204
+            }
1205
+        }
1206
+
1207
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1208
+        if (empty($hidetop))
1209
+        {
1210
+            if ($this->atleastonediscount)
1211
+            {
1212
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1214
+            }
1215
+        }
1216
+
1217
+        if ($this->atleastonediscount)
1218
+        {
1219
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1220
+        }
1221
+        if (empty($hidetop))
1222
+        {
1223
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1225
+        }
1226
+    }
1227
+
1228
+    /**
1229
+     *  Show top header of page.
1230
+     *
1231
+     *  @param	TCPDF		$pdf     		Object PDF
1232
+     *  @param  Object		$object     	Object to show
1233
+     *  @param  int	    	$showaddress    0=no, 1=yes
1234
+     *  @param  Translate	$outputlangs	Object lang for output
1235
+     *  @param	string		$titlekey		Translation key to show as title of document
1236
+     *  @return	void
1237
+     */
1238
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1239
+    {
1240
+        global $conf,$langs,$hookmanager;
1241
+
1242
+        // Load traductions files requiredby by page
1243
+        $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244
+
1245
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1246
+
1247
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1248
+
1249
+        // Show Draft Watermark
1250
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1251
+        {
1252 1252
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1253
-		}
1253
+        }
1254 1254
 
1255
-		$pdf->SetTextColor(0,0,60);
1256
-		$pdf->SetFont('','B', $default_font_size + 3);
1255
+        $pdf->SetTextColor(0,0,60);
1256
+        $pdf->SetFont('','B', $default_font_size + 3);
1257 1257
 
1258
-		$posy=$this->marge_haute;
1259
-		$posx=$this->page_largeur-$this->marge_droite-100;
1258
+        $posy=$this->marge_haute;
1259
+        $posx=$this->page_largeur-$this->marge_droite-100;
1260 1260
 
1261
-		$pdf->SetXY($this->marge_gauche,$posy);
1261
+        $pdf->SetXY($this->marge_gauche,$posy);
1262 1262
 
1263
-		// Logo
1264
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265
-		{
1266
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267
-			if ($this->emetteur->logo)
1268
-			{
1269
-				if (is_readable($logo))
1270
-				{
1271
-				    $height=pdf_getHeightForLogo($logo);
1272
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
-				}
1274
-				else
1275
-				{
1276
-					$pdf->SetTextColor(200,0,0);
1277
-					$pdf->SetFont('','B', $default_font_size -2);
1278
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1279
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280
-				}
1281
-			}
1282
-			else
1283
-			{
1284
-				$text=$this->emetteur->name;
1285
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286
-			}
1287
-		}
1288
-
1289
-		$pdf->SetFont('','B', $default_font_size + 3);
1290
-		$pdf->SetXY($posx,$posy);
1291
-		$pdf->SetTextColor(0,0,60);
1292
-		$title=$outputlangs->transnoentities($titlekey);
1293
-		$pdf->MultiCell(100, 3, $title, '', 'R');
1294
-
1295
-		$pdf->SetFont('','B',$default_font_size);
1296
-
1297
-		$posy+=5;
1298
-		$pdf->SetXY($posx,$posy);
1299
-		$pdf->SetTextColor(0,0,60);
1300
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1301
-
1302
-		$posy+=1;
1303
-		$pdf->SetFont('','', $default_font_size - 1);
1304
-
1305
-		if ($object->ref_client)
1306
-		{
1307
-			$posy+=5;
1308
-			$pdf->SetXY($posx,$posy);
1309
-			$pdf->SetTextColor(0,0,60);
1310
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1311
-		}
1312
-
1313
-		$posy+=4;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1317
-
1318
-		// Get contact
1319
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320
-		{
1321
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1322
-		    if (count($arrayidcontact) > 0)
1323
-		    {
1263
+        // Logo
1264
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265
+        {
1266
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267
+            if ($this->emetteur->logo)
1268
+            {
1269
+                if (is_readable($logo))
1270
+                {
1271
+                    $height=pdf_getHeightForLogo($logo);
1272
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
+                }
1274
+                else
1275
+                {
1276
+                    $pdf->SetTextColor(200,0,0);
1277
+                    $pdf->SetFont('','B', $default_font_size -2);
1278
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1279
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280
+                }
1281
+            }
1282
+            else
1283
+            {
1284
+                $text=$this->emetteur->name;
1285
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286
+            }
1287
+        }
1288
+
1289
+        $pdf->SetFont('','B', $default_font_size + 3);
1290
+        $pdf->SetXY($posx,$posy);
1291
+        $pdf->SetTextColor(0,0,60);
1292
+        $title=$outputlangs->transnoentities($titlekey);
1293
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1294
+
1295
+        $pdf->SetFont('','B',$default_font_size);
1296
+
1297
+        $posy+=5;
1298
+        $pdf->SetXY($posx,$posy);
1299
+        $pdf->SetTextColor(0,0,60);
1300
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1301
+
1302
+        $posy+=1;
1303
+        $pdf->SetFont('','', $default_font_size - 1);
1304
+
1305
+        if ($object->ref_client)
1306
+        {
1307
+            $posy+=5;
1308
+            $pdf->SetXY($posx,$posy);
1309
+            $pdf->SetTextColor(0,0,60);
1310
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1311
+        }
1312
+
1313
+        $posy+=4;
1314
+        $pdf->SetXY($posx,$posy);
1315
+        $pdf->SetTextColor(0,0,60);
1316
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1317
+
1318
+        // Get contact
1319
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320
+        {
1321
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1322
+            if (count($arrayidcontact) > 0)
1323
+            {
1324 1324
                 $usertmp=new User($this->db);
1325
-		        $usertmp->fetch($arrayidcontact[0]);
1325
+                $usertmp->fetch($arrayidcontact[0]);
1326 1326
                 $posy+=4;
1327 1327
                 $pdf->SetXY($posx,$posy);
1328
-		        $pdf->SetTextColor(0,0,60);
1329
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330
-		    }
1331
-		}
1332
-
1333
-		$posy+=2;
1334
-
1335
-		$top_shift = 0;
1336
-		// Show list of linked objects
1337
-		$current_y = $pdf->getY();
1338
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1339
-		if ($current_y < $pdf->getY())
1340
-		{
1341
-			$top_shift = $pdf->getY() - $current_y;
1342
-		}
1328
+                $pdf->SetTextColor(0,0,60);
1329
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330
+            }
1331
+        }
1343 1332
 
1344
-		if ($showaddress)
1345
-		{
1346
-			// Sender properties
1347
-			$carac_emetteur='';
1348
-		 	// Add internal contact of proposal if defined
1349
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1350
-		 	if (count($arrayidcontact) > 0)
1351
-		 	{
1352
-		 		$object->fetch_user($arrayidcontact[0]);
1353
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1354
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1355
-		 	}
1356
-
1357
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358
-
1359
-			// Show sender
1360
-			$posy=42+$top_shift;
1361
-			$posx=$this->marge_gauche;
1362
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1363
-			$hautcadre=40;
1364
-
1365
-			// Show sender frame
1366
-			$pdf->SetTextColor(0,0,0);
1367
-			$pdf->SetFont('','', $default_font_size - 2);
1368
-			$pdf->SetXY($posx,$posy-5);
1369
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
-			$pdf->SetXY($posx,$posy);
1371
-			$pdf->SetFillColor(230,230,230);
1372
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
-			$pdf->SetTextColor(0,0,60);
1374
-
1375
-			// Show sender name
1376
-			$pdf->SetXY($posx+2,$posy+3);
1377
-			$pdf->SetFont('','B', $default_font_size);
1378
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
-			$posy=$pdf->getY();
1380
-
1381
-			// Show sender information
1382
-			$pdf->SetXY($posx+2,$posy);
1383
-			$pdf->SetFont('','', $default_font_size - 1);
1384
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385
-
1386
-
1387
-
1388
-			// If CUSTOMER contact defined on order, we use it
1389
-			$usecontact=false;
1390
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1391
-			if (count($arrayidcontact) > 0)
1392
-			{
1393
-				$usecontact=true;
1394
-				$result=$object->fetch_contact($arrayidcontact[0]);
1395
-			}
1396
-
1397
-			//Recipient name
1398
-			// On peut utiliser le nom de la societe du contact
1399
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1400
-				$thirdparty = $object->contact;
1401
-			} else {
1402
-				$thirdparty = $object->thirdparty;
1403
-			}
1404
-
1405
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406
-
1407
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1408
-
1409
-			// Show recipient
1410
-			$widthrecbox=100;
1411
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1412
-			$posy=42+$top_shift;
1413
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1415
-
1416
-			// Show recipient frame
1417
-			$pdf->SetTextColor(0,0,0);
1418
-			$pdf->SetFont('','', $default_font_size - 2);
1419
-			$pdf->SetXY($posx+2,$posy-5);
1420
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1421
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422
-
1423
-			// Show recipient name
1424
-			$pdf->SetXY($posx+2,$posy+3);
1425
-			$pdf->SetFont('','B', $default_font_size);
1426
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427
-
1428
-			$posy = $pdf->getY();
1429
-
1430
-			// Show recipient information
1431
-			$pdf->SetFont('','', $default_font_size - 1);
1432
-			$pdf->SetXY($posx+2,$posy);
1433
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434
-		}
1435
-
1436
-		$pdf->SetTextColor(0,0,0);
1437
-		return $top_shift;
1438
-	}
1439
-
1440
-	/**
1441
-	 *   	Show footer of page. Need this->emetteur object
1333
+        $posy+=2;
1334
+
1335
+        $top_shift = 0;
1336
+        // Show list of linked objects
1337
+        $current_y = $pdf->getY();
1338
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1339
+        if ($current_y < $pdf->getY())
1340
+        {
1341
+            $top_shift = $pdf->getY() - $current_y;
1342
+        }
1343
+
1344
+        if ($showaddress)
1345
+        {
1346
+            // Sender properties
1347
+            $carac_emetteur='';
1348
+                // Add internal contact of proposal if defined
1349
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1350
+                if (count($arrayidcontact) > 0)
1351
+                {
1352
+                    $object->fetch_user($arrayidcontact[0]);
1353
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1354
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1355
+                }
1356
+
1357
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358
+
1359
+            // Show sender
1360
+            $posy=42+$top_shift;
1361
+            $posx=$this->marge_gauche;
1362
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1363
+            $hautcadre=40;
1364
+
1365
+            // Show sender frame
1366
+            $pdf->SetTextColor(0,0,0);
1367
+            $pdf->SetFont('','', $default_font_size - 2);
1368
+            $pdf->SetXY($posx,$posy-5);
1369
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
+            $pdf->SetXY($posx,$posy);
1371
+            $pdf->SetFillColor(230,230,230);
1372
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
+            $pdf->SetTextColor(0,0,60);
1374
+
1375
+            // Show sender name
1376
+            $pdf->SetXY($posx+2,$posy+3);
1377
+            $pdf->SetFont('','B', $default_font_size);
1378
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
+            $posy=$pdf->getY();
1380
+
1381
+            // Show sender information
1382
+            $pdf->SetXY($posx+2,$posy);
1383
+            $pdf->SetFont('','', $default_font_size - 1);
1384
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385
+
1386
+
1387
+
1388
+            // If CUSTOMER contact defined on order, we use it
1389
+            $usecontact=false;
1390
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1391
+            if (count($arrayidcontact) > 0)
1392
+            {
1393
+                $usecontact=true;
1394
+                $result=$object->fetch_contact($arrayidcontact[0]);
1395
+            }
1396
+
1397
+            //Recipient name
1398
+            // On peut utiliser le nom de la societe du contact
1399
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1400
+                $thirdparty = $object->contact;
1401
+            } else {
1402
+                $thirdparty = $object->thirdparty;
1403
+            }
1404
+
1405
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406
+
1407
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1408
+
1409
+            // Show recipient
1410
+            $widthrecbox=100;
1411
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1412
+            $posy=42+$top_shift;
1413
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1415
+
1416
+            // Show recipient frame
1417
+            $pdf->SetTextColor(0,0,0);
1418
+            $pdf->SetFont('','', $default_font_size - 2);
1419
+            $pdf->SetXY($posx+2,$posy-5);
1420
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1421
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422
+
1423
+            // Show recipient name
1424
+            $pdf->SetXY($posx+2,$posy+3);
1425
+            $pdf->SetFont('','B', $default_font_size);
1426
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427
+
1428
+            $posy = $pdf->getY();
1429
+
1430
+            // Show recipient information
1431
+            $pdf->SetFont('','', $default_font_size - 1);
1432
+            $pdf->SetXY($posx+2,$posy);
1433
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434
+        }
1435
+
1436
+        $pdf->SetTextColor(0,0,0);
1437
+        return $top_shift;
1438
+    }
1439
+
1440
+    /**
1441
+     *   	Show footer of page. Need this->emetteur object
1442 1442
      *
1443
-	 *   	@param	TCPDF		$pdf     			PDF
1444
-	 * 		@param	Object		$object				Object to show
1445
-	 *      @param	Translate	$outputlangs		Object lang for output
1446
-	 *      @param	int			$hidefreetext		1=Hide free text
1447
-	 *      @return	int								Return height of bottom margin including footer text
1448
-	 */
1449
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1450
-	{
1451
-		global $conf;
1452
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1454
-	}
1443
+     *   	@param	TCPDF		$pdf     			PDF
1444
+     * 		@param	Object		$object				Object to show
1445
+     *      @param	Translate	$outputlangs		Object lang for output
1446
+     *      @param	int			$hidefreetext		1=Hide free text
1447
+     *      @return	int								Return height of bottom margin including footer text
1448
+     */
1449
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1450
+    {
1451
+        global $conf;
1452
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
+        return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1454
+    }
1455 1455
 }
Please login to merge, or discard this patch.
Spacing   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function __construct($db)
130 130
 	{
131
-		global $conf,$langs,$mysoc;
131
+		global $conf, $langs, $mysoc;
132 132
 
133 133
 		// Translations
134 134
 		$langs->loadLangs(array("main", "bills", "products"));
@@ -136,71 +136,71 @@  discard block
 block discarded – undo
136 136
 		$this->db = $db;
137 137
 		$this->name = "einstein";
138 138
 		$this->description = $langs->trans('PDFEinsteinDescription');
139
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
139
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
140 140
 
141 141
 		// Dimension page
142 142
 		$this->type = 'pdf';
143
-		$formatarray=pdf_getFormat();
143
+		$formatarray = pdf_getFormat();
144 144
 		$this->page_largeur = $formatarray['width'];
145 145
 		$this->page_hauteur = $formatarray['height'];
146
-		$this->format = array($this->page_largeur,$this->page_hauteur);
147
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
148
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
149
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
150
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
151
-
152
-		$this->option_logo = 1;                    // Display logo
153
-		$this->option_tva = 1;                     // Manage the vat option FACTURE_TVAOPTION
154
-		$this->option_modereg = 1;                 // Display payment mode
155
-		$this->option_condreg = 1;                 // Display payment terms
156
-		$this->option_codeproduitservice = 1;      // Display product-service code
157
-		$this->option_multilang = 1;               // Available in several languages
158
-		$this->option_escompte = 0;                // Displays if there has been a discount
159
-		$this->option_credit_note = 0;             // Support credit notes
160
-		$this->option_freetext = 1;				   // Support add of a personalised text
161
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
162
-
163
-		$this->franchise=!$mysoc->tva_assuj;
146
+		$this->format = array($this->page_largeur, $this->page_hauteur);
147
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
148
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
149
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
150
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
151
+
152
+		$this->option_logo = 1; // Display logo
153
+		$this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
154
+		$this->option_modereg = 1; // Display payment mode
155
+		$this->option_condreg = 1; // Display payment terms
156
+		$this->option_codeproduitservice = 1; // Display product-service code
157
+		$this->option_multilang = 1; // Available in several languages
158
+		$this->option_escompte = 0; // Displays if there has been a discount
159
+		$this->option_credit_note = 0; // Support credit notes
160
+		$this->option_freetext = 1; // Support add of a personalised text
161
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
162
+
163
+		$this->franchise = !$mysoc->tva_assuj;
164 164
 
165 165
 		// Get source company
166
-		$this->emetteur=$mysoc;
167
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
166
+		$this->emetteur = $mysoc;
167
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
168 168
 
169 169
 		// Define position of columns
170
-		$this->posxdesc=$this->marge_gauche+1;
171
-		if($conf->global->PRODUCT_USE_UNITS)
170
+		$this->posxdesc = $this->marge_gauche + 1;
171
+		if ($conf->global->PRODUCT_USE_UNITS)
172 172
 		{
173
-			$this->posxtva=101;
174
-			$this->posxup=118;
175
-			$this->posxqty=135;
176
-			$this->posxunit=151;
173
+			$this->posxtva = 101;
174
+			$this->posxup = 118;
175
+			$this->posxqty = 135;
176
+			$this->posxunit = 151;
177 177
 		}
178 178
 		else
179 179
 		{
180
-			$this->posxtva=110;
181
-			$this->posxup=126;
182
-			$this->posxqty=145;
180
+			$this->posxtva = 110;
181
+			$this->posxup = 126;
182
+			$this->posxqty = 145;
183 183
 		}
184
-		$this->posxdiscount=162;
185
-		$this->postotalht=174;
186
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
187
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
184
+		$this->posxdiscount = 162;
185
+		$this->postotalht = 174;
186
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
187
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
188 188
 		if ($this->page_largeur < 210) // To work with US executive format
189 189
 		{
190
-			$this->posxpicture-=20;
191
-			$this->posxtva-=20;
192
-			$this->posxup-=20;
193
-			$this->posxqty-=20;
194
-			$this->posxunit-=20;
195
-			$this->posxdiscount-=20;
196
-			$this->postotalht-=20;
190
+			$this->posxpicture -= 20;
191
+			$this->posxtva -= 20;
192
+			$this->posxup -= 20;
193
+			$this->posxqty -= 20;
194
+			$this->posxunit -= 20;
195
+			$this->posxdiscount -= 20;
196
+			$this->postotalht -= 20;
197 197
 		}
198 198
 
199
-		$this->tva=array();
200
-		$this->localtax1=array();
201
-		$this->localtax2=array();
202
-		$this->atleastoneratenotnull=0;
203
-		$this->atleastonediscount=0;
199
+		$this->tva = array();
200
+		$this->localtax1 = array();
201
+		$this->localtax2 = array();
202
+		$this->atleastoneratenotnull = 0;
203
+		$this->atleastonediscount = 0;
204 204
 	}
205 205
 
206 206
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
      *  @param		int			$hideref			Do not show ref
216 216
      *  @return     int             			    1=OK, 0=KO
217 217
 	 */
218
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
218
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
219 219
 	{
220 220
         // phpcs:enable
221 221
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 222
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
223
+		if (!is_object($outputlangs)) $outputlangs = $langs;
224 224
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
225
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
226 226
 
227 227
 		// Load translation files required by the page
228 228
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
 			if ($object->specimen)
240 240
 			{
241 241
 				$dir = $conf->commande->dir_output;
242
-				$file = $dir . "/SPECIMEN.pdf";
242
+				$file = $dir."/SPECIMEN.pdf";
243 243
 			}
244 244
 			else
245 245
 			{
246 246
 				$objectref = dol_sanitizeFileName($object->ref);
247
-				$dir = $conf->commande->dir_output . "/" . $objectref;
248
-				$file = $dir . "/" . $objectref . ".pdf";
247
+				$dir = $conf->commande->dir_output."/".$objectref;
248
+				$file = $dir."/".$objectref.".pdf";
249 249
 			}
250 250
 
251
-			if (! file_exists($dir))
251
+			if (!file_exists($dir))
252 252
 			{
253 253
 				if (dol_mkdir($dir) < 0)
254 254
 				{
255
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
255
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
256 256
 					return 0;
257 257
 				}
258 258
 			}
@@ -260,25 +260,25 @@  discard block
 block discarded – undo
260 260
 			if (file_exists($dir))
261 261
 			{
262 262
 				// Add pdfgeneration hook
263
-				if (! is_object($hookmanager))
263
+				if (!is_object($hookmanager))
264 264
 				{
265 265
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
-					$hookmanager=new HookManager($this->db);
266
+					$hookmanager = new HookManager($this->db);
267 267
 				}
268 268
 				$hookmanager->initHooks(array('pdfgeneration'));
269
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
269
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
270 270
 				global $action;
271
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
271
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
272 272
 
273 273
 				// Create pdf instance
274
-				$pdf=pdf_getInstance($this->format);
275
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
276
-				$pdf->SetAutoPageBreak(1,0);
274
+				$pdf = pdf_getInstance($this->format);
275
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
276
+				$pdf->SetAutoPageBreak(1, 0);
277 277
 
278
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
279
-		        $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
280
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
281
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
278
+				$heightforinfotot = 40; // Height reserved to output the info and total part
279
+		        $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
280
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
281
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
282 282
 
283 283
                 if (class_exists('TCPDF'))
284 284
                 {
@@ -287,27 +287,27 @@  discard block
 block discarded – undo
287 287
                 }
288 288
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
289 289
                 // Set path to the background PDF File
290
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
290
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
291 291
                 {
292 292
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
293 293
                     $tplidx = $pdf->importPage(1);
294 294
                 }
295 295
 
296 296
 				$pdf->Open();
297
-				$pagenb=0;
298
-				$pdf->SetDrawColor(128,128,128);
297
+				$pagenb = 0;
298
+				$pdf->SetDrawColor(128, 128, 128);
299 299
 
300 300
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301 301
 				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302 302
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303 303
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304 304
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
305
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
305
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
306 306
 
307
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
307
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
308 308
 
309 309
 				// Positionne $this->atleastonediscount si on a au moins une remise
310
-				for ($i = 0 ; $i < $nblignes ; $i++)
310
+				for ($i = 0; $i < $nblignes; $i++)
311 311
 				{
312 312
 					if ($object->lines[$i]->remise_percent)
313 313
 					{
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
 				}
317 317
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
318 318
 				{
319
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
320
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
321
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
322
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
323
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
319
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
320
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
321
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
322
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
323
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
324 324
 					//$this->postotalht;
325 325
 				}
326 326
 
327 327
 				// New page
328 328
 				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
329
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
330 330
 				$pagenb++;
331 331
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332
-				$pdf->SetFont('','', $default_font_size - 1);
333
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
334
-				$pdf->SetTextColor(0,0,0);
332
+				$pdf->SetFont('', '', $default_font_size - 1);
333
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
334
+				$pdf->SetTextColor(0, 0, 0);
335 335
 
336 336
 
337
-				$tab_top = 90+$top_shift;
338
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
337
+				$tab_top = 90 + $top_shift;
338
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
339 339
 
340 340
 				// Incoterm
341 341
 				if ($conf->incoterm->enabled)
@@ -345,50 +345,50 @@  discard block
 block discarded – undo
345 345
 					{
346 346
 						$tab_top -= 2;
347 347
 
348
-						$pdf->SetFont('','', $default_font_size - 1);
349
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
348
+						$pdf->SetFont('', '', $default_font_size - 1);
349
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350 350
 						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
351
+						$height_incoterms = $nexY - $tab_top;
352 352
 
353 353
 						// Rect prend une longueur en 3eme param
354
-						$pdf->SetDrawColor(192,192,192);
355
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
354
+						$pdf->SetDrawColor(192, 192, 192);
355
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
356 356
 
357
-						$tab_top = $nexY+6;
357
+						$tab_top = $nexY + 6;
358 358
 					}
359 359
 				}
360 360
 
361 361
 				// Affiche notes
362
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
363
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
362
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
363
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364 364
 				{
365 365
 					// Get first sale rep
366 366
 					if (is_object($object->thirdparty))
367 367
 					{
368
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
-						$salerepobj=new User($this->db);
368
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
369
+						$salerepobj = new User($this->db);
370 370
 						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
371
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
372 372
 					}
373 373
 				}
374 374
 				if ($notetoshow)
375 375
 				{
376 376
 					$tab_top -= 2;
377 377
 
378
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
378
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
379 379
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
380 380
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
381 381
 
382
-					$pdf->SetFont('','', $default_font_size - 1);
383
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
382
+					$pdf->SetFont('', '', $default_font_size - 1);
383
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
384 384
 					$nexY = $pdf->GetY();
385
-					$height_note=$nexY-$tab_top;
385
+					$height_note = $nexY - $tab_top;
386 386
 
387 387
 					// Rect prend une longueur en 3eme param
388
-					$pdf->SetDrawColor(192,192,192);
389
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
388
+					$pdf->SetDrawColor(192, 192, 192);
389
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
390 390
 
391
-					$tab_top = $nexY+6;
391
+					$tab_top = $nexY + 6;
392 392
 				}
393 393
 
394 394
 				$iniY = $tab_top + 7;
@@ -396,164 +396,164 @@  discard block
 block discarded – undo
396 396
 				$nexY = $tab_top + 7;
397 397
 
398 398
 				// Loop on each lines
399
-				for ($i = 0 ; $i < $nblignes ; $i++)
399
+				for ($i = 0; $i < $nblignes; $i++)
400 400
 				{
401 401
 					$curY = $nexY;
402
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
-					$pdf->SetTextColor(0,0,0);
402
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
403
+					$pdf->SetTextColor(0, 0, 0);
404 404
 
405 405
 					$pdf->setTopMargin($tab_top_newpage);
406
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
407
-					$pageposbefore=$pdf->getPage();
406
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
407
+					$pageposbefore = $pdf->getPage();
408 408
 
409 409
 					// Description of product line
410
-					$curX = $this->posxdesc-1;
410
+					$curX = $this->posxdesc - 1;
411 411
 
412
-					$showpricebeforepagebreak=1;
412
+					$showpricebeforepagebreak = 1;
413 413
 
414 414
 					$pdf->startTransaction();
415
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
-					$pageposafter=$pdf->getPage();
415
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
416
+					$pageposafter = $pdf->getPage();
417 417
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
418 418
 					{
419 419
 						$pdf->rollbackTransaction(true);
420
-						$pageposafter=$pageposbefore;
420
+						$pageposafter = $pageposbefore;
421 421
 						//print $pageposafter.'-'.$pageposbefore;exit;
422
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424
-						$pageposafter=$pdf->getPage();
425
-						$posyafter=$pdf->GetY();
426
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
422
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
423
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
424
+						$pageposafter = $pdf->getPage();
425
+						$posyafter = $pdf->GetY();
426
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
427 427
 						{
428
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
428
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
429 429
 							{
430
-								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
430
+								$pdf->AddPage('', '', true);
431
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
432 432
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
-								$pdf->setPage($pageposafter+1);
433
+								$pdf->setPage($pageposafter + 1);
434 434
 							}
435 435
 						}
436 436
 						else
437 437
 						{
438 438
 							// We found a page break
439
-							$showpricebeforepagebreak=0;
439
+							$showpricebeforepagebreak = 0;
440 440
 						}
441 441
 					}
442 442
 					else	// No pagebreak
443 443
 					{
444 444
 						$pdf->commitTransaction();
445 445
 					}
446
-					$posYAfterDescription=$pdf->GetY();
446
+					$posYAfterDescription = $pdf->GetY();
447 447
 
448 448
 					$nexY = $pdf->GetY();
449
-					$pageposafter=$pdf->getPage();
449
+					$pageposafter = $pdf->getPage();
450 450
 
451 451
 					$pdf->setPage($pageposbefore);
452 452
 					$pdf->setTopMargin($this->marge_haute);
453
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
453
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
454 454
 
455 455
 					// We suppose that a too long description is moved completely on next page
456 456
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457 457
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458 458
 					}
459 459
 
460
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
460
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
461 461
 
462 462
 					// VAT Rate
463 463
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464 464
 					{
465 465
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
466
-						$pdf->SetXY($this->posxtva-5, $curY);
467
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
466
+						$pdf->SetXY($this->posxtva - 5, $curY);
467
+						$pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
468 468
 					}
469 469
 
470 470
 					// Unit price before discount
471 471
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472 472
 					$pdf->SetXY($this->posxup, $curY);
473
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
473
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
474 474
 
475 475
 					// Quantity
476 476
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477 477
 					$pdf->SetXY($this->posxqty, $curY);
478 478
 					// Enough for 6 chars
479
-					if($conf->global->PRODUCT_USE_UNITS)
479
+					if ($conf->global->PRODUCT_USE_UNITS)
480 480
 					{
481
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
481
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
482 482
 					}
483 483
 					else
484 484
 					{
485
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
485
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
486 486
 					}
487 487
 
488 488
 					// Unit
489
-					if($conf->global->PRODUCT_USE_UNITS)
489
+					if ($conf->global->PRODUCT_USE_UNITS)
490 490
 					{
491 491
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492 492
 						$pdf->SetXY($this->posxunit, $curY);
493
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
493
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
494 494
 					}
495 495
 
496 496
 					// Discount on line
497 497
 					$pdf->SetXY($this->posxdiscount, $curY);
498 498
 					if ($object->lines[$i]->remise_percent)
499 499
 					{
500
-						$pdf->SetXY($this->posxdiscount-2, $curY);
500
+						$pdf->SetXY($this->posxdiscount - 2, $curY);
501 501
 						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
502
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
503 503
 					}
504 504
 
505 505
 					// Total HT line
506 506
 					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507 507
 					$pdf->SetXY($this->postotalht, $curY);
508
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
508
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509 509
 
510 510
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
511
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
512
-					else $tvaligne=$object->lines[$i]->total_tva;
511
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
512
+					else $tvaligne = $object->lines[$i]->total_tva;
513 513
 
514
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
515
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
516
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
517
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
518
-					$localtax1_type=$object->lines[$i]->localtax1_type;
519
-					$localtax2_type=$object->lines[$i]->localtax2_type;
514
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
515
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
516
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
517
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
518
+					$localtax1_type = $object->lines[$i]->localtax1_type;
519
+					$localtax2_type = $object->lines[$i]->localtax2_type;
520 520
 
521
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
522
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
523
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
521
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
522
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
523
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
524 524
 
525
-					$vatrate=(string) $object->lines[$i]->tva_tx;
525
+					$vatrate = (string) $object->lines[$i]->tva_tx;
526 526
 
527 527
 					// Retrieve type from database for backward compatibility with old records
528
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
529
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
528
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
529
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
530 530
 					{
531
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
531
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
532 532
 						$localtax1_type = $localtaxtmp_array[0];
533 533
 						$localtax2_type = $localtaxtmp_array[2];
534 534
 					}
535 535
 
536 536
 				    // retrieve global local tax
537 537
 					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
538
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
539 539
 					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
540
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
541 541
 
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
542
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
543
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
544 544
 					$this->tva[$vatrate] += $tvaligne;
545 545
 
546 546
 					// Add line
547
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
547
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548 548
 					{
549 549
 						$pdf->setPage($pageposafter);
550
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
550
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
551 551
 						//$pdf->SetDrawColor(190,190,200);
552
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
552
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
553 553
 						$pdf->SetLineStyle(array('dash'=>0));
554 554
 					}
555 555
 
556
-					$nexY+=2;    // Passe espace entre les lignes
556
+					$nexY += 2; // Passe espace entre les lignes
557 557
 
558 558
 					// Detect if some page were added automatically and output _tableau for past pages
559 559
 					while ($pagenb < $pageposafter)
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
 						{
568 568
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569 569
 						}
570
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
570
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
571 571
 						$pagenb++;
572 572
 						$pdf->setPage($pagenb);
573
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
573
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
574 574
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575 575
 					}
576
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
576
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
577 577
 					{
578 578
 						if ($pagenb == 1)
579 579
 						{
@@ -583,10 +583,10 @@  discard block
 block discarded – undo
583 583
 						{
584 584
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585 585
 						}
586
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
586
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
587 587
 						// New page
588 588
 						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
589
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
590 590
 						$pagenb++;
591 591
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592 592
 					}
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598 598
 				else
599 599
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
600
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
600
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 601
 
602 602
 				// Affiche zone infos
603
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
603
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
604 604
 
605 605
 				// Affiche zone totaux
606
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
606
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
607 607
 
608 608
 				// Affiche zone versements
609 609
 				/*
@@ -623,26 +623,26 @@  discard block
 block discarded – undo
623 623
 
624 624
 				// Add pdfgeneration hook
625 625
 				$hookmanager->initHooks(array('pdfgeneration'));
626
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
626
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627 627
 				global $action;
628
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
628
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
629 629
 
630
-				if (! empty($conf->global->MAIN_UMASK))
630
+				if (!empty($conf->global->MAIN_UMASK))
631 631
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
632 632
 
633 633
 				$this->result = array('fullpath'=>$file);
634 634
 
635
-				return 1;   // Pas d'erreur
635
+				return 1; // Pas d'erreur
636 636
 			}
637 637
 			else
638 638
 			{
639
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
639
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
640 640
 				return 0;
641 641
 			}
642 642
 		}
643 643
 		else
644 644
 		{
645
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
645
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
646 646
 			return 0;
647 647
 		}
648 648
 	}
@@ -679,35 +679,35 @@  discard block
 block discarded – undo
679 679
 		global $conf;
680 680
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
681 681
 
682
-		$pdf->SetFont('','', $default_font_size - 1);
682
+		$pdf->SetFont('', '', $default_font_size - 1);
683 683
 
684 684
         // If France, show VAT mention if not applicable
685 685
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686 686
 		{
687
-			$pdf->SetFont('','B', $default_font_size - 2);
687
+			$pdf->SetFont('', 'B', $default_font_size - 2);
688 688
 			$pdf->SetXY($this->marge_gauche, $posy);
689 689
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
690 690
 
691
-			$posy=$pdf->GetY()+4;
691
+			$posy = $pdf->GetY() + 4;
692 692
 		}
693 693
 
694
-		$posxval=52;
694
+		$posxval = 52;
695 695
 
696 696
 		// Show payments conditions
697 697
 		if ($object->cond_reglement_code || $object->cond_reglement)
698 698
 		{
699
-			$pdf->SetFont('','B', $default_font_size - 2);
699
+			$pdf->SetFont('', 'B', $default_font_size - 2);
700 700
 			$pdf->SetXY($this->marge_gauche, $posy);
701 701
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
702 702
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
703 703
 
704
-			$pdf->SetFont('','', $default_font_size - 2);
704
+			$pdf->SetFont('', '', $default_font_size - 2);
705 705
 			$pdf->SetXY($posxval, $posy);
706
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
708
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
706
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
708
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
709 709
 
710
-			$posy=$pdf->GetY()+3;
710
+			$posy = $pdf->GetY() + 3;
711 711
 		}
712 712
 
713 713
         // Check a payment mode is defined
@@ -738,34 +738,34 @@  discard block
 block discarded – undo
738 738
 		}*/
739 739
 
740 740
 	    // Show planed date of delivery
741
-        if (! empty($object->date_livraison))
741
+        if (!empty($object->date_livraison))
742 742
 		{
743 743
             $outputlangs->load("sendings");
744
-			$pdf->SetFont('','B', $default_font_size - 2);
744
+			$pdf->SetFont('', 'B', $default_font_size - 2);
745 745
 			$pdf->SetXY($this->marge_gauche, $posy);
746 746
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747 747
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
748
-			$pdf->SetFont('','', $default_font_size - 2);
748
+			$pdf->SetFont('', '', $default_font_size - 2);
749 749
 			$pdf->SetXY($posxval, $posy);
750
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
750
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
751 751
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 752
 
753
-            $posy=$pdf->GetY()+1;
753
+            $posy = $pdf->GetY() + 1;
754 754
 		}
755 755
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
756 756
 		{
757
-			$pdf->SetFont('','B', $default_font_size - 2);
757
+			$pdf->SetFont('', 'B', $default_font_size - 2);
758 758
 			$pdf->SetXY($this->marge_gauche, $posy);
759 759
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760 760
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
761
-			$pdf->SetTextColor(0,0,0);
762
-			$pdf->SetFont('','', $default_font_size - 2);
761
+			$pdf->SetTextColor(0, 0, 0);
762
+			$pdf->SetFont('', '', $default_font_size - 2);
763 763
 			$pdf->SetXY($posxval, $posy);
764
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
765
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
764
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
765
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
766 766
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767 767
 
768
-			$posy=$pdf->GetY()+1;
768
+			$posy = $pdf->GetY() + 1;
769 769
 		}
770 770
 
771 771
       	// Show payment mode
@@ -773,24 +773,24 @@  discard block
 block discarded – undo
773 773
         	 && $object->mode_reglement_code != 'CHQ'
774 774
            	 && $object->mode_reglement_code != 'VIR')
775 775
            	 {
776
-	            $pdf->SetFont('','B', $default_font_size - 2);
776
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
777 777
 	            $pdf->SetXY($this->marge_gauche, $posy);
778 778
 	            $titre = $outputlangs->transnoentities("PaymentMode").':';
779 779
 	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
780 780
 
781
-				$pdf->SetFont('','', $default_font_size - 2);
781
+				$pdf->SetFont('', '', $default_font_size - 2);
782 782
 	            $pdf->SetXY($posxval, $posy);
783
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
784
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
783
+	            $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
784
+	            $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
785 785
 
786
-	            $posy=$pdf->GetY()+2;
786
+	            $posy = $pdf->GetY() + 2;
787 787
            	 }
788 788
 
789 789
 		// Show payment mode CHQ
790 790
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
791 791
         {
792 792
         	// Si mode reglement non force ou si force a CHQ
793
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
793
+	        if (!empty($conf->global->FACTURE_CHQ_NUMBER))
794 794
 	        {
795 795
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796 796
 	            {
@@ -798,31 +798,31 @@  discard block
 block discarded – undo
798 798
 	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799 799
 
800 800
 	                $pdf->SetXY($this->marge_gauche, $posy);
801
-	                $pdf->SetFont('','B', $default_font_size - 3);
802
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
803
-		            $posy=$pdf->GetY()+1;
801
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
802
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
803
+		            $posy = $pdf->GetY() + 1;
804 804
 
805 805
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806 806
 		            {
807 807
 		                $pdf->SetXY($this->marge_gauche, $posy);
808
-		                $pdf->SetFont('','', $default_font_size - 3);
808
+		                $pdf->SetFont('', '', $default_font_size - 3);
809 809
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
-			            $posy=$pdf->GetY()+2;
810
+			            $posy = $pdf->GetY() + 2;
811 811
 		            }
812 812
 	            }
813 813
 	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814 814
 	            {
815 815
 	                $pdf->SetXY($this->marge_gauche, $posy);
816
-	                $pdf->SetFont('','B', $default_font_size - 3);
817
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
818
-		            $posy=$pdf->GetY()+1;
816
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
817
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
818
+		            $posy = $pdf->GetY() + 1;
819 819
 
820 820
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821 821
 		            {
822 822
 			            $pdf->SetXY($this->marge_gauche, $posy);
823
-		                $pdf->SetFont('','', $default_font_size - 3);
823
+		                $pdf->SetFont('', '', $default_font_size - 3);
824 824
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
-			            $posy=$pdf->GetY()+2;
825
+			            $posy = $pdf->GetY() + 2;
826 826
 		            }
827 827
 	            }
828 828
 	        }
@@ -831,19 +831,19 @@  discard block
 block discarded – undo
831 831
         // If payment mode not forced or forced to VIR, show payment with BAN
832 832
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
833 833
         {
834
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
834
+			if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
835 835
 			{
836
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
837
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
836
+				$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
837
+				if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
838 838
 				$account = new Account($this->db);
839 839
 				$account->fetch($bankid);
840 840
 
841
-				$curx=$this->marge_gauche;
842
-				$cury=$posy;
841
+				$curx = $this->marge_gauche;
842
+				$cury = $posy;
843 843
 
844
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
844
+				$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
845 845
 
846
-				$posy+=2;
846
+				$posy += 2;
847 847
 			}
848 848
         }
849 849
 
@@ -865,44 +865,44 @@  discard block
 block discarded – undo
865 865
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866 866
 	{
867 867
         // phpcs:enable
868
-	    global $conf,$mysoc;
868
+	    global $conf, $mysoc;
869 869
 
870 870
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
872 872
 		$tab2_top = $posy;
873 873
 		$tab2_hl = 4;
874
-		$pdf->SetFont('','', $default_font_size - 1);
874
+		$pdf->SetFont('', '', $default_font_size - 1);
875 875
 
876 876
 		// Tableau total
877 877
         $col1x = 120; $col2x = 170;
878 878
 		if ($this->page_largeur < 210) // To work with US executive format
879 879
 		{
880
-			$col2x-=20;
880
+			$col2x -= 20;
881 881
 		}
882 882
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 883
 
884
-		$useborder=0;
884
+		$useborder = 0;
885 885
 		$index = 0;
886 886
 
887 887
 		// Total HT
888
-		$pdf->SetFillColor(255,255,255);
888
+		$pdf->SetFillColor(255, 255, 255);
889 889
 		$pdf->SetXY($col1x, $tab2_top + 0);
890
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
890
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
891 891
 
892 892
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
893 893
 		$pdf->SetXY($col2x, $tab2_top + 0);
894
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
894
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
895 895
 
896 896
 		// Show VAT by rates and total
897
-		$pdf->SetFillColor(248,248,248);
897
+		$pdf->SetFillColor(248, 248, 248);
898 898
 
899 899
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
900 900
 
901
-		$this->atleastoneratenotnull=0;
901
+		$this->atleastoneratenotnull = 0;
902 902
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
903 903
 		{
904
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
904
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906 906
 			{
907 907
 				// Nothing to do
908 908
 			}
@@ -911,27 +911,27 @@  discard block
 block discarded – undo
911 911
 				//Local tax 1 before VAT
912 912
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913 913
 				//{
914
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
914
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
915 915
 					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
-						foreach( $localtax_rate as $tvakey => $tvaval )
916
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
917
+						foreach ($localtax_rate as $tvakey => $tvaval)
918 918
 						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
919
+							if ($tvakey != 0)    // On affiche pas taux 0
920 920
 							{
921 921
 								//$this->atleastoneratenotnull++;
922 922
 
923 923
 								$index++;
924 924
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 925
 
926
-								$tvacompl='';
927
-								if (preg_match('/\*/',$tvakey))
926
+								$tvacompl = '';
927
+								if (preg_match('/\*/', $tvakey))
928 928
 								{
929
-									$tvakey=str_replace('*','',$tvakey);
929
+									$tvakey = str_replace('*', '', $tvakey);
930 930
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
931 931
 								}
932
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
933
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
934
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
932
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
933
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
934
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
935 935
 
936 936
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937 937
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -942,12 +942,12 @@  discard block
 block discarded – undo
942 942
 				//Local tax 2 before VAT
943 943
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944 944
 				//{
945
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
945
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
946 946
 					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
-						foreach( $localtax_rate as $tvakey => $tvaval )
947
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
948
+						foreach ($localtax_rate as $tvakey => $tvaval)
949 949
 						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
950
+							if ($tvakey != 0)    // On affiche pas taux 0
951 951
 							{
952 952
 								//$this->atleastoneratenotnull++;
953 953
 
@@ -956,15 +956,15 @@  discard block
 block discarded – undo
956 956
 								$index++;
957 957
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958 958
 
959
-								$tvacompl='';
960
-								if (preg_match('/\*/',$tvakey))
959
+								$tvacompl = '';
960
+								if (preg_match('/\*/', $tvakey))
961 961
 								{
962
-									$tvakey=str_replace('*','',$tvakey);
962
+									$tvakey = str_replace('*', '', $tvakey);
963 963
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
964 964
 								}
965
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
966
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
967
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
965
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
966
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
967
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
968 968
 
969 969
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970 970
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 					}
974 974
 				//}
975 975
 				// VAT
976
-				foreach($this->tva as $tvakey => $tvaval)
976
+				foreach ($this->tva as $tvakey => $tvaval)
977 977
 				{
978 978
 					if ($tvakey != 0)    // On affiche pas taux 0
979 979
 					{
@@ -982,15 +982,15 @@  discard block
 block discarded – undo
982 982
 						$index++;
983 983
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984 984
 
985
-						$tvacompl='';
986
-						if (preg_match('/\*/',$tvakey))
985
+						$tvacompl = '';
986
+						if (preg_match('/\*/', $tvakey))
987 987
 						{
988
-							$tvakey=str_replace('*','',$tvakey);
988
+							$tvakey = str_replace('*', '', $tvakey);
989 989
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
990 990
 						}
991
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
992
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
993
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
991
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
992
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
993
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
994 994
 
995 995
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996 996
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 				//Local tax 1 after VAT
1001 1001
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002 1002
 				//{
1003
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1003
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1004 1004
 					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1005
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1006 1006
 
1007
-						foreach( $localtax_rate as $tvakey => $tvaval )
1007
+						foreach ($localtax_rate as $tvakey => $tvaval)
1008 1008
 						{
1009 1009
 							if ($tvakey != 0)    // On affiche pas taux 0
1010 1010
 							{
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
 								$index++;
1014 1014
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015 1015
 
1016
-								$tvacompl='';
1017
-								if (preg_match('/\*/',$tvakey))
1016
+								$tvacompl = '';
1017
+								if (preg_match('/\*/', $tvakey))
1018 1018
 								{
1019
-									$tvakey=str_replace('*','',$tvakey);
1019
+									$tvakey = str_replace('*', '', $tvakey);
1020 1020
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021 1021
 								}
1022
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1022
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1023 1023
 
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1025
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026 1026
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027 1027
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028 1028
 							}
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
 				//Local tax 2 after VAT
1033 1033
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034 1034
 				//{
1035
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1035
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1036 1036
 					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1037
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1038 1038
 
1039
-						foreach( $localtax_rate as $tvakey => $tvaval )
1039
+						foreach ($localtax_rate as $tvakey => $tvaval)
1040 1040
 						{
1041 1041
 							if ($tvakey != 0)    // On affiche pas taux 0
1042 1042
 							{
@@ -1045,16 +1045,16 @@  discard block
 block discarded – undo
1045 1045
 								$index++;
1046 1046
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047 1047
 
1048
-								$tvacompl='';
1049
-								if (preg_match('/\*/',$tvakey))
1048
+								$tvacompl = '';
1049
+								if (preg_match('/\*/', $tvakey))
1050 1050
 								{
1051
-									$tvakey=str_replace('*','',$tvakey);
1051
+									$tvakey = str_replace('*', '', $tvakey);
1052 1052
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053 1053
 								}
1054
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1054
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1055 1055
 
1056
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1057
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058 1058
 
1059 1059
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060 1060
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1066,24 +1066,24 @@  discard block
 block discarded – undo
1066 1066
 				// Total TTC
1067 1067
 				$index++;
1068 1068
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069
-				$pdf->SetTextColor(0,0,60);
1070
-				$pdf->SetFillColor(224,224,224);
1071
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1069
+				$pdf->SetTextColor(0, 0, 60);
1070
+				$pdf->SetFillColor(224, 224, 224);
1071
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1072 1072
 
1073 1073
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074 1074
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075 1075
 			}
1076 1076
 		}
1077 1077
 
1078
-		$pdf->SetTextColor(0,0,0);
1078
+		$pdf->SetTextColor(0, 0, 0);
1079 1079
 
1080
-        $creditnoteamount=0;
1081
-        $depositsamount=0;
1080
+        $creditnoteamount = 0;
1081
+        $depositsamount = 0;
1082 1082
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1083 1083
 		//$depositsamount=$object->getSumDepositsUsed();
1084 1084
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085 1085
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1086
+		if (!empty($object->paye)) $resteapayer = 0;
1087 1087
 
1088 1088
 		if ($deja_regle > 0)
1089 1089
 		{
@@ -1091,21 +1091,21 @@  discard block
 block discarded – undo
1091 1091
 			$index++;
1092 1092
 
1093 1093
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1094
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095 1095
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096 1096
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1097 1097
 
1098 1098
 			$index++;
1099
-			$pdf->SetTextColor(0,0,60);
1100
-			$pdf->SetFillColor(224,224,224);
1099
+			$pdf->SetTextColor(0, 0, 60);
1100
+			$pdf->SetFillColor(224, 224, 224);
1101 1101
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1102
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1103 1103
 
1104 1104
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 1105
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1106 1106
 
1107
-			$pdf->SetFont('','', $default_font_size - 1);
1108
-			$pdf->SetTextColor(0,0,0);
1107
+			$pdf->SetFont('', '', $default_font_size - 1);
1108
+			$pdf->SetTextColor(0, 0, 0);
1109 1109
 		}
1110 1110
 
1111 1111
 		$index++;
@@ -1125,77 +1125,77 @@  discard block
 block discarded – undo
1125 1125
 	 *   @param		string		$currency		Currency code
1126 1126
 	 *   @return	void
1127 1127
 	 */
1128
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1128
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1129 1129
 	{
1130 1130
 		global $conf;
1131 1131
 
1132 1132
 		// Force to disable hidetop and hidebottom
1133
-		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1133
+		$hidebottom = 0;
1134
+		if ($hidetop) $hidetop = -1;
1135 1135
 
1136 1136
 		$currency = !empty($currency) ? $currency : $conf->currency;
1137 1137
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1138 1138
 
1139 1139
 		// Amount in (at tab_top - 1)
1140
-		$pdf->SetTextColor(0,0,0);
1141
-		$pdf->SetFont('','', $default_font_size - 2);
1140
+		$pdf->SetTextColor(0, 0, 0);
1141
+		$pdf->SetFont('', '', $default_font_size - 2);
1142 1142
 
1143 1143
 		if (empty($hidetop))
1144 1144
 		{
1145
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1145
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1147 1147
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148 1148
 
1149 1149
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1150
-			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));
1150
+			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));
1151 1151
 		}
1152 1152
 
1153
-		$pdf->SetDrawColor(128,128,128);
1154
-		$pdf->SetFont('','', $default_font_size - 1);
1153
+		$pdf->SetDrawColor(128, 128, 128);
1154
+		$pdf->SetFont('', '', $default_font_size - 1);
1155 1155
 
1156 1156
 		// Output Rect
1157
-		$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
1157
+		$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
1158 1158
 
1159 1159
 		if (empty($hidetop))
1160 1160
 		{
1161
-			$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
1161
+			$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
1162 1162
 
1163
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1163
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1164
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1165 1165
 		}
1166 1166
 
1167 1167
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168 1168
 		{
1169
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1169
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1170 1170
 			if (empty($hidetop))
1171 1171
 			{
1172
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1172
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1173
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1174 1174
 			}
1175 1175
 		}
1176 1176
 
1177
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1177
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1178 1178
 		if (empty($hidetop))
1179 1179
 		{
1180
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1181
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1180
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1181
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1182 1182
 		}
1183 1183
 
1184
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1184
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1185 1185
 		if (empty($hidetop))
1186 1186
 		{
1187
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
-			if($conf->global->PRODUCT_USE_UNITS)
1187
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1188
+			if ($conf->global->PRODUCT_USE_UNITS)
1189 1189
 			{
1190
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1190
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1191 1191
 			}
1192 1192
 			else
1193 1193
 			{
1194
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1194
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1195 1195
 			}
1196 1196
 		}
1197 1197
 
1198
-		if($conf->global->PRODUCT_USE_UNITS) {
1198
+		if ($conf->global->PRODUCT_USE_UNITS) {
1199 1199
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200 1200
 			if (empty($hidetop)) {
1201 1201
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1204,13 +1204,13 @@  discard block
 block discarded – undo
1204 1204
 			}
1205 1205
 		}
1206 1206
 
1207
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1207
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1208 1208
 		if (empty($hidetop))
1209 1209
 		{
1210 1210
 			if ($this->atleastonediscount)
1211 1211
 			{
1212
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1212
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1213
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1214 1214
 			}
1215 1215
 		}
1216 1216
 
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 		}
1221 1221
 		if (empty($hidetop))
1222 1222
 		{
1223
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1223
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1224
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1225 1225
 		}
1226 1226
 	}
1227 1227
 
@@ -1235,102 +1235,102 @@  discard block
 block discarded – undo
1235 1235
 	 *  @param	string		$titlekey		Translation key to show as title of document
1236 1236
 	 *  @return	void
1237 1237
 	 */
1238
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1238
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
1239 1239
 	{
1240
-		global $conf,$langs,$hookmanager;
1240
+		global $conf, $langs, $hookmanager;
1241 1241
 
1242 1242
 		// Load traductions files requiredby by page
1243 1243
 		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244 1244
 
1245 1245
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1246 1246
 
1247
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1247
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1248 1248
 
1249 1249
 		// Show Draft Watermark
1250
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1250
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1251 1251
 		{
1252
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1252
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1253 1253
 		}
1254 1254
 
1255
-		$pdf->SetTextColor(0,0,60);
1256
-		$pdf->SetFont('','B', $default_font_size + 3);
1255
+		$pdf->SetTextColor(0, 0, 60);
1256
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1257 1257
 
1258
-		$posy=$this->marge_haute;
1259
-		$posx=$this->page_largeur-$this->marge_droite-100;
1258
+		$posy = $this->marge_haute;
1259
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1260 1260
 
1261
-		$pdf->SetXY($this->marge_gauche,$posy);
1261
+		$pdf->SetXY($this->marge_gauche, $posy);
1262 1262
 
1263 1263
 		// Logo
1264 1264
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265 1265
 		{
1266
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1266
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267 1267
 			if ($this->emetteur->logo)
1268 1268
 			{
1269 1269
 				if (is_readable($logo))
1270 1270
 				{
1271
-				    $height=pdf_getHeightForLogo($logo);
1272
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1271
+				    $height = pdf_getHeightForLogo($logo);
1272
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1273 1273
 				}
1274 1274
 				else
1275 1275
 				{
1276
-					$pdf->SetTextColor(200,0,0);
1277
-					$pdf->SetFont('','B', $default_font_size -2);
1278
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1276
+					$pdf->SetTextColor(200, 0, 0);
1277
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1278
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1279 1279
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280 1280
 				}
1281 1281
 			}
1282 1282
 			else
1283 1283
 			{
1284
-				$text=$this->emetteur->name;
1284
+				$text = $this->emetteur->name;
1285 1285
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286 1286
 			}
1287 1287
 		}
1288 1288
 
1289
-		$pdf->SetFont('','B', $default_font_size + 3);
1290
-		$pdf->SetXY($posx,$posy);
1291
-		$pdf->SetTextColor(0,0,60);
1292
-		$title=$outputlangs->transnoentities($titlekey);
1289
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1290
+		$pdf->SetXY($posx, $posy);
1291
+		$pdf->SetTextColor(0, 0, 60);
1292
+		$title = $outputlangs->transnoentities($titlekey);
1293 1293
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1294 1294
 
1295
-		$pdf->SetFont('','B',$default_font_size);
1295
+		$pdf->SetFont('', 'B', $default_font_size);
1296 1296
 
1297
-		$posy+=5;
1298
-		$pdf->SetXY($posx,$posy);
1299
-		$pdf->SetTextColor(0,0,60);
1300
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1297
+		$posy += 5;
1298
+		$pdf->SetXY($posx, $posy);
1299
+		$pdf->SetTextColor(0, 0, 60);
1300
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1301 1301
 
1302
-		$posy+=1;
1303
-		$pdf->SetFont('','', $default_font_size - 1);
1302
+		$posy += 1;
1303
+		$pdf->SetFont('', '', $default_font_size - 1);
1304 1304
 
1305 1305
 		if ($object->ref_client)
1306 1306
 		{
1307
-			$posy+=5;
1308
-			$pdf->SetXY($posx,$posy);
1309
-			$pdf->SetTextColor(0,0,60);
1310
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1307
+			$posy += 5;
1308
+			$pdf->SetXY($posx, $posy);
1309
+			$pdf->SetTextColor(0, 0, 60);
1310
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1311 1311
 		}
1312 1312
 
1313
-		$posy+=4;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1313
+		$posy += 4;
1314
+		$pdf->SetXY($posx, $posy);
1315
+		$pdf->SetTextColor(0, 0, 60);
1316
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
1317 1317
 
1318 1318
 		// Get contact
1319 1319
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320 1320
 		{
1321
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1321
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1322 1322
 		    if (count($arrayidcontact) > 0)
1323 1323
 		    {
1324
-                $usertmp=new User($this->db);
1324
+                $usertmp = new User($this->db);
1325 1325
 		        $usertmp->fetch($arrayidcontact[0]);
1326
-                $posy+=4;
1327
-                $pdf->SetXY($posx,$posy);
1328
-		        $pdf->SetTextColor(0,0,60);
1326
+                $posy += 4;
1327
+                $pdf->SetXY($posx, $posy);
1328
+		        $pdf->SetTextColor(0, 0, 60);
1329 1329
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330 1330
 		    }
1331 1331
 		}
1332 1332
 
1333
-		$posy+=2;
1333
+		$posy += 2;
1334 1334
 
1335 1335
 		$top_shift = 0;
1336 1336
 		// Show list of linked objects
@@ -1344,54 +1344,54 @@  discard block
 block discarded – undo
1344 1344
 		if ($showaddress)
1345 1345
 		{
1346 1346
 			// Sender properties
1347
-			$carac_emetteur='';
1347
+			$carac_emetteur = '';
1348 1348
 		 	// Add internal contact of proposal if defined
1349
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1349
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1350 1350
 		 	if (count($arrayidcontact) > 0)
1351 1351
 		 	{
1352 1352
 		 		$object->fetch_user($arrayidcontact[0]);
1353
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1354
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1353
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1354
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1355 1355
 		 	}
1356 1356
 
1357 1357
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358 1358
 
1359 1359
 			// Show sender
1360
-			$posy=42+$top_shift;
1361
-			$posx=$this->marge_gauche;
1362
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1363
-			$hautcadre=40;
1360
+			$posy = 42 + $top_shift;
1361
+			$posx = $this->marge_gauche;
1362
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1363
+			$hautcadre = 40;
1364 1364
 
1365 1365
 			// Show sender frame
1366
-			$pdf->SetTextColor(0,0,0);
1367
-			$pdf->SetFont('','', $default_font_size - 2);
1368
-			$pdf->SetXY($posx,$posy-5);
1369
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
-			$pdf->SetXY($posx,$posy);
1371
-			$pdf->SetFillColor(230,230,230);
1366
+			$pdf->SetTextColor(0, 0, 0);
1367
+			$pdf->SetFont('', '', $default_font_size - 2);
1368
+			$pdf->SetXY($posx, $posy - 5);
1369
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
+			$pdf->SetXY($posx, $posy);
1371
+			$pdf->SetFillColor(230, 230, 230);
1372 1372
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
-			$pdf->SetTextColor(0,0,60);
1373
+			$pdf->SetTextColor(0, 0, 60);
1374 1374
 
1375 1375
 			// Show sender name
1376
-			$pdf->SetXY($posx+2,$posy+3);
1377
-			$pdf->SetFont('','B', $default_font_size);
1376
+			$pdf->SetXY($posx + 2, $posy + 3);
1377
+			$pdf->SetFont('', 'B', $default_font_size);
1378 1378
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
-			$posy=$pdf->getY();
1379
+			$posy = $pdf->getY();
1380 1380
 
1381 1381
 			// Show sender information
1382
-			$pdf->SetXY($posx+2,$posy);
1383
-			$pdf->SetFont('','', $default_font_size - 1);
1382
+			$pdf->SetXY($posx + 2, $posy);
1383
+			$pdf->SetFont('', '', $default_font_size - 1);
1384 1384
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385 1385
 
1386 1386
 
1387 1387
 
1388 1388
 			// If CUSTOMER contact defined on order, we use it
1389
-			$usecontact=false;
1390
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1389
+			$usecontact = false;
1390
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1391 1391
 			if (count($arrayidcontact) > 0)
1392 1392
 			{
1393
-				$usecontact=true;
1394
-				$result=$object->fetch_contact($arrayidcontact[0]);
1393
+				$usecontact = true;
1394
+				$result = $object->fetch_contact($arrayidcontact[0]);
1395 1395
 			}
1396 1396
 
1397 1397
 			//Recipient name
@@ -1402,38 +1402,38 @@  discard block
 block discarded – undo
1402 1402
 				$thirdparty = $object->thirdparty;
1403 1403
 			}
1404 1404
 
1405
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1405
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406 1406
 
1407
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1407
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1408 1408
 
1409 1409
 			// Show recipient
1410
-			$widthrecbox=100;
1411
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1412
-			$posy=42+$top_shift;
1413
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1410
+			$widthrecbox = 100;
1411
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1412
+			$posy = 42 + $top_shift;
1413
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1414
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1415 1415
 
1416 1416
 			// Show recipient frame
1417
-			$pdf->SetTextColor(0,0,0);
1418
-			$pdf->SetFont('','', $default_font_size - 2);
1419
-			$pdf->SetXY($posx+2,$posy-5);
1420
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1417
+			$pdf->SetTextColor(0, 0, 0);
1418
+			$pdf->SetFont('', '', $default_font_size - 2);
1419
+			$pdf->SetXY($posx + 2, $posy - 5);
1420
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1421 1421
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422 1422
 
1423 1423
 			// Show recipient name
1424
-			$pdf->SetXY($posx+2,$posy+3);
1425
-			$pdf->SetFont('','B', $default_font_size);
1424
+			$pdf->SetXY($posx + 2, $posy + 3);
1425
+			$pdf->SetFont('', 'B', $default_font_size);
1426 1426
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427 1427
 
1428 1428
 			$posy = $pdf->getY();
1429 1429
 
1430 1430
 			// Show recipient information
1431
-			$pdf->SetFont('','', $default_font_size - 1);
1432
-			$pdf->SetXY($posx+2,$posy);
1431
+			$pdf->SetFont('', '', $default_font_size - 1);
1432
+			$pdf->SetXY($posx + 2, $posy);
1433 1433
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434 1434
 		}
1435 1435
 
1436
-		$pdf->SetTextColor(0,0,0);
1436
+		$pdf->SetTextColor(0, 0, 0);
1437 1437
 		return $top_shift;
1438 1438
 	}
1439 1439
 
@@ -1446,10 +1446,10 @@  discard block
 block discarded – undo
1446 1446
 	 *      @param	int			$hidefreetext		1=Hide free text
1447 1447
 	 *      @return	int								Return height of bottom margin including footer text
1448 1448
 	 */
1449
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1449
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1450 1450
 	{
1451 1451
 		global $conf;
1452
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1452
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
+		return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1454 1454
 	}
1455 1455
 }
Please login to merge, or discard this patch.
Braces   +158 added lines, -80 removed lines patch added patch discarded remove patch
@@ -164,7 +164,10 @@  discard block
 block discarded – undo
164 164
 
165 165
 		// Get source company
166 166
 		$this->emetteur=$mysoc;
167
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
167
+		if (empty($this->emetteur->country_code)) {
168
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
169
+		}
170
+		// By default, if was not defined
168 171
 
169 172
 		// Define position of columns
170 173
 		$this->posxdesc=$this->marge_gauche+1;
@@ -174,8 +177,7 @@  discard block
 block discarded – undo
174 177
 			$this->posxup=118;
175 178
 			$this->posxqty=135;
176 179
 			$this->posxunit=151;
177
-		}
178
-		else
180
+		} else
179 181
 		{
180 182
 			$this->posxtva=110;
181 183
 			$this->posxup=126;
@@ -183,11 +185,15 @@  discard block
 block discarded – undo
183 185
 		}
184 186
 		$this->posxdiscount=162;
185 187
 		$this->postotalht=174;
186
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
188
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
189
+		    $this->posxtva=$this->posxup;
190
+		}
187 191
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
188
-		if ($this->page_largeur < 210) // To work with US executive format
192
+		if ($this->page_largeur < 210) {
193
+		    // To work with US executive format
189 194
 		{
190 195
 			$this->posxpicture-=20;
196
+		}
191 197
 			$this->posxtva-=20;
192 198
 			$this->posxup-=20;
193 199
 			$this->posxqty-=20;
@@ -220,9 +226,13 @@  discard block
 block discarded – undo
220 226
         // phpcs:enable
221 227
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 228
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
229
+		if (! is_object($outputlangs)) {
230
+		    $outputlangs=$langs;
231
+		}
224 232
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
233
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
234
+		    $outputlangs->charset_output='ISO-8859-1';
235
+		}
226 236
 
227 237
 		// Load translation files required by the page
228 238
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -240,8 +250,7 @@  discard block
 block discarded – undo
240 250
 			{
241 251
 				$dir = $conf->commande->dir_output;
242 252
 				$file = $dir . "/SPECIMEN.pdf";
243
-			}
244
-			else
253
+			} else
245 254
 			{
246 255
 				$objectref = dol_sanitizeFileName($object->ref);
247 256
 				$dir = $conf->commande->dir_output . "/" . $objectref;
@@ -278,7 +287,9 @@  discard block
 block discarded – undo
278 287
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
279 288
 		        $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
280 289
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
281
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
290
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
291
+	                $heightforfooter+= 6;
292
+	            }
282 293
 
283 294
                 if (class_exists('TCPDF'))
284 295
                 {
@@ -302,7 +313,9 @@  discard block
 block discarded – undo
302 313
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303 314
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304 315
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
305
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
316
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
317
+				    $pdf->SetCompression(false);
318
+				}
306 319
 
307 320
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
308 321
 
@@ -326,7 +339,9 @@  discard block
 block discarded – undo
326 339
 
327 340
 				// New page
328 341
 				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
342
+				if (! empty($tplidx)) {
343
+				    $pdf->useTemplate($tplidx);
344
+				}
330 345
 				$pagenb++;
331 346
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332 347
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -368,7 +383,9 @@  discard block
 block discarded – undo
368 383
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369 384
 						$salerepobj=new User($this->db);
370 385
 						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
386
+						if (! empty($salerepobj->signature)) {
387
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
388
+						}
372 389
 					}
373 390
 				}
374 391
 				if ($notetoshow)
@@ -414,32 +431,38 @@  discard block
 block discarded – undo
414 431
 					$pdf->startTransaction();
415 432
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416 433
 					$pageposafter=$pdf->getPage();
417
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
434
+					if ($pageposafter > $pageposbefore) {
435
+					    // There is a pagebreak
418 436
 					{
419 437
 						$pdf->rollbackTransaction(true);
438
+					}
420 439
 						$pageposafter=$pageposbefore;
421 440
 						//print $pageposafter.'-'.$pageposbefore;exit;
422 441
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423 442
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424 443
 						$pageposafter=$pdf->getPage();
425 444
 						$posyafter=$pdf->GetY();
426
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
445
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
446
+						    // There is no space left for total+free text
427 447
 						{
428 448
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429 449
 							{
430 450
 								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451
+						}
452
+								if (! empty($tplidx)) {
453
+								    $pdf->useTemplate($tplidx);
454
+								}
455
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
456
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
457
+								}
433 458
 								$pdf->setPage($pageposafter+1);
434 459
 							}
435
-						}
436
-						else
460
+						} else
437 461
 						{
438 462
 							// We found a page break
439 463
 							$showpricebeforepagebreak=0;
440 464
 						}
441
-					}
442
-					else	// No pagebreak
465
+					} else	// No pagebreak
443 466
 					{
444 467
 						$pdf->commitTransaction();
445 468
 					}
@@ -479,8 +502,7 @@  discard block
 block discarded – undo
479 502
 					if($conf->global->PRODUCT_USE_UNITS)
480 503
 					{
481 504
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
-					}
483
-					else
505
+					} else
484 506
 					{
485 507
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486 508
 					}
@@ -508,8 +530,11 @@  discard block
 block discarded – undo
508 530
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509 531
 
510 532
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
511
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
512
-					else $tvaligne=$object->lines[$i]->total_tva;
533
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
534
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
535
+					} else {
536
+					    $tvaligne=$object->lines[$i]->total_tva;
537
+					}
513 538
 
514 539
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
515 540
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -518,29 +543,43 @@  discard block
 block discarded – undo
518 543
 					$localtax1_type=$object->lines[$i]->localtax1_type;
519 544
 					$localtax2_type=$object->lines[$i]->localtax2_type;
520 545
 
521
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
522
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
523
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
546
+					if ($object->remise_percent) {
547
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
548
+					}
549
+					if ($object->remise_percent) {
550
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
551
+					}
552
+					if ($object->remise_percent) {
553
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
554
+					}
524 555
 
525 556
 					$vatrate=(string) $object->lines[$i]->tva_tx;
526 557
 
527 558
 					// Retrieve type from database for backward compatibility with old records
528 559
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
529
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
560
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
561
+					    // and there is local tax
530 562
 					{
531 563
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
564
+					}
532 565
 						$localtax1_type = $localtaxtmp_array[0];
533 566
 						$localtax2_type = $localtaxtmp_array[2];
534 567
 					}
535 568
 
536 569
 				    // retrieve global local tax
537
-					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
-					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
570
+					if ($localtax1_type && $localtax1ligne != 0) {
571
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
572
+					}
573
+					if ($localtax2_type && $localtax2ligne != 0) {
574
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
575
+					}
541 576
 
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
577
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
578
+					    $vatrate.='*';
579
+					}
580
+					if (! isset($this->tva[$vatrate])) {
581
+					    $this->tva[$vatrate]=0;
582
+					}
544 583
 					$this->tva[$vatrate] += $tvaligne;
545 584
 
546 585
 					// Add line
@@ -562,8 +601,7 @@  discard block
 block discarded – undo
562 601
 						if ($pagenb == 1)
563 602
 						{
564 603
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
-						}
566
-						else
604
+						} else
567 605
 						{
568 606
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569 607
 						}
@@ -571,32 +609,38 @@  discard block
 block discarded – undo
571 609
 						$pagenb++;
572 610
 						$pdf->setPage($pagenb);
573 611
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
612
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
613
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
614
+						}
575 615
 					}
576 616
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577 617
 					{
578 618
 						if ($pagenb == 1)
579 619
 						{
580 620
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
-						}
582
-						else
621
+						} else
583 622
 						{
584 623
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585 624
 						}
586 625
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
587 626
 						// New page
588 627
 						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
628
+						if (! empty($tplidx)) {
629
+						    $pdf->useTemplate($tplidx);
630
+						}
590 631
 						$pagenb++;
591
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
632
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
633
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
634
+						}
592 635
 					}
593 636
 				}
594 637
 
595 638
 				// Show square
596
-				if ($pagenb == 1)
597
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
-				else
599
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
639
+				if ($pagenb == 1) {
640
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
641
+				} else {
642
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
643
+				}
600 644
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 645
 
602 646
 				// Affiche zone infos
@@ -615,7 +659,9 @@  discard block
 block discarded – undo
615 659
 
616 660
 				// Pied de page
617 661
 				$this->_pagefoot($pdf, $object, $outputlangs);
618
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
662
+				if (method_exists($pdf, 'AliasNbPages')) {
663
+				    $pdf->AliasNbPages();
664
+				}
619 665
 
620 666
 				$pdf->Close();
621 667
 
@@ -627,20 +673,19 @@  discard block
 block discarded – undo
627 673
 				global $action;
628 674
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
629 675
 
630
-				if (! empty($conf->global->MAIN_UMASK))
631
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
676
+				if (! empty($conf->global->MAIN_UMASK)) {
677
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
678
+				}
632 679
 
633 680
 				$this->result = array('fullpath'=>$file);
634 681
 
635 682
 				return 1;   // Pas d'erreur
636
-			}
637
-			else
683
+			} else
638 684
 			{
639 685
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640 686
 				return 0;
641 687
 			}
642
-		}
643
-		else
688
+		} else
644 689
 		{
645 690
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646 691
 			return 0;
@@ -751,10 +796,11 @@  discard block
 block discarded – undo
751 796
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 797
 
753 798
             $posy=$pdf->GetY()+1;
754
-		}
755
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
799
+		} elseif ($object->availability_code || $object->availability) {
800
+            // Show availability conditions
756 801
 		{
757 802
 			$pdf->SetFont('','B', $default_font_size - 2);
803
+        }
758 804
 			$pdf->SetXY($this->marge_gauche, $posy);
759 805
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760 806
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -834,7 +880,10 @@  discard block
 block discarded – undo
834 880
 			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
835 881
 			{
836 882
 				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
837
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
883
+				if (! empty($object->fk_bank)) {
884
+				    $bankid=$object->fk_bank;
885
+				}
886
+				// For backward compatibility when object->fk_account is forced with object->fk_bank
838 887
 				$account = new Account($this->db);
839 888
 				$account->fetch($bankid);
840 889
 
@@ -875,10 +924,12 @@  discard block
 block discarded – undo
875 924
 
876 925
 		// Tableau total
877 926
         $col1x = 120; $col2x = 170;
878
-		if ($this->page_largeur < 210) // To work with US executive format
927
+		if ($this->page_largeur < 210) {
928
+		    // To work with US executive format
879 929
 		{
880 930
 			$col2x-=20;
881 931
 		}
932
+		}
882 933
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 934
 
884 935
 		$useborder=0;
@@ -905,22 +956,25 @@  discard block
 block discarded – undo
905 956
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906 957
 			{
907 958
 				// Nothing to do
908
-			}
909
-			else
959
+			} else
910 960
 			{
911 961
 				//Local tax 1 before VAT
912 962
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913 963
 				//{
914 964
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915 965
 					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
966
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
967
+						    continue;
968
+						}
917 969
 						foreach( $localtax_rate as $tvakey => $tvaval )
918 970
 						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
971
+							if ($tvakey!=0) {
972
+							    // On affiche pas taux 0
920 973
 							{
921 974
 								//$this->atleastoneratenotnull++;
922 975
 
923 976
 								$index++;
977
+							}
924 978
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 979
 
926 980
 								$tvacompl='';
@@ -944,16 +998,20 @@  discard block
 block discarded – undo
944 998
 				//{
945 999
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946 1000
 					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1001
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1002
+						    continue;
1003
+						}
948 1004
 						foreach( $localtax_rate as $tvakey => $tvaval )
949 1005
 						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
1006
+							if ($tvakey!=0) {
1007
+							    // On affiche pas taux 0
951 1008
 							{
952 1009
 								//$this->atleastoneratenotnull++;
953 1010
 
954 1011
 
955 1012
 
956 1013
 								$index++;
1014
+							}
957 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958 1016
 
959 1017
 								$tvacompl='';
@@ -975,9 +1033,11 @@  discard block
 block discarded – undo
975 1033
 				// VAT
976 1034
 				foreach($this->tva as $tvakey => $tvaval)
977 1035
 				{
978
-					if ($tvakey != 0)    // On affiche pas taux 0
1036
+					if ($tvakey != 0) {
1037
+					    // On affiche pas taux 0
979 1038
 					{
980 1039
 						$this->atleastoneratenotnull++;
1040
+					}
981 1041
 
982 1042
 						$index++;
983 1043
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1002,15 +1062,19 @@  discard block
 block discarded – undo
1002 1062
 				//{
1003 1063
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004 1064
 					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1065
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1066
+						    continue;
1067
+						}
1006 1068
 
1007 1069
 						foreach( $localtax_rate as $tvakey => $tvaval )
1008 1070
 						{
1009
-							if ($tvakey != 0)    // On affiche pas taux 0
1071
+							if ($tvakey != 0) {
1072
+							    // On affiche pas taux 0
1010 1073
 							{
1011 1074
 								//$this->atleastoneratenotnull++;
1012 1075
 
1013 1076
 								$index++;
1077
+							}
1014 1078
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015 1079
 
1016 1080
 								$tvacompl='';
@@ -1034,15 +1098,19 @@  discard block
 block discarded – undo
1034 1098
 				//{
1035 1099
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036 1100
 					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1101
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1102
+						    continue;
1103
+						}
1038 1104
 
1039 1105
 						foreach( $localtax_rate as $tvakey => $tvaval )
1040 1106
 						{
1041
-							if ($tvakey != 0)    // On affiche pas taux 0
1107
+							if ($tvakey != 0) {
1108
+							    // On affiche pas taux 0
1042 1109
 							{
1043 1110
 								//$this->atleastoneratenotnull++;
1044 1111
 
1045 1112
 								$index++;
1113
+							}
1046 1114
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047 1115
 
1048 1116
 								$tvacompl='';
@@ -1083,7 +1151,9 @@  discard block
 block discarded – undo
1083 1151
 		//$depositsamount=$object->getSumDepositsUsed();
1084 1152
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085 1153
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1154
+		if (! empty($object->paye)) {
1155
+		    $resteapayer=0;
1156
+		}
1087 1157
 
1088 1158
 		if ($deja_regle > 0)
1089 1159
 		{
@@ -1131,7 +1201,9 @@  discard block
 block discarded – undo
1131 1201
 
1132 1202
 		// Force to disable hidetop and hidebottom
1133 1203
 		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1204
+		if ($hidetop) {
1205
+		    $hidetop=-1;
1206
+		}
1135 1207
 
1136 1208
 		$currency = !empty($currency) ? $currency : $conf->currency;
1137 1209
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1147,7 +1219,9 @@  discard block
 block discarded – undo
1147 1219
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148 1220
 
1149 1221
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1150
-			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));
1222
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1223
+			    $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));
1224
+			}
1151 1225
 		}
1152 1226
 
1153 1227
 		$pdf->SetDrawColor(128,128,128);
@@ -1188,8 +1262,7 @@  discard block
 block discarded – undo
1188 1262
 			if($conf->global->PRODUCT_USE_UNITS)
1189 1263
 			{
1190 1264
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
-			}
1192
-			else
1265
+			} else
1193 1266
 			{
1194 1267
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195 1268
 			}
@@ -1270,16 +1343,14 @@  discard block
 block discarded – undo
1270 1343
 				{
1271 1344
 				    $height=pdf_getHeightForLogo($logo);
1272 1345
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
-				}
1274
-				else
1346
+				} else
1275 1347
 				{
1276 1348
 					$pdf->SetTextColor(200,0,0);
1277 1349
 					$pdf->SetFont('','B', $default_font_size -2);
1278 1350
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1279 1351
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280 1352
 				}
1281
-			}
1282
-			else
1353
+			} else
1283 1354
 			{
1284 1355
 				$text=$this->emetteur->name;
1285 1356
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1359,7 +1430,9 @@  discard block
 block discarded – undo
1359 1430
 			// Show sender
1360 1431
 			$posy=42+$top_shift;
1361 1432
 			$posx=$this->marge_gauche;
1362
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1433
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1434
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1435
+			}
1363 1436
 			$hautcadre=40;
1364 1437
 
1365 1438
 			// Show sender frame
@@ -1408,10 +1481,15 @@  discard block
 block discarded – undo
1408 1481
 
1409 1482
 			// Show recipient
1410 1483
 			$widthrecbox=100;
1411
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1484
+			if ($this->page_largeur < 210) {
1485
+			    $widthrecbox=84;
1486
+			}
1487
+			// To work with US executive format
1412 1488
 			$posy=42+$top_shift;
1413 1489
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1490
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1491
+			    $posx=$this->marge_gauche;
1492
+			}
1415 1493
 
1416 1494
 			// Show recipient frame
1417 1495
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_proforma.modules.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -41,36 +41,36 @@
 block discarded – undo
41 41
 class pdf_proforma extends pdf_einstein
42 42
 {
43 43
 
44
-	/**
45
-	 *	Constructor
46
-	 *
47
-	 *  @param		DoliDB		$db      Database handler
48
-	 */
49
-	function __construct($db)
50
-	{
51
-		global $conf,$langs,$mysoc;
44
+    /**
45
+     *	Constructor
46
+     *
47
+     *  @param		DoliDB		$db      Database handler
48
+     */
49
+    function __construct($db)
50
+    {
51
+        global $conf,$langs,$mysoc;
52 52
 
53
-		parent::__construct($db);
53
+        parent::__construct($db);
54 54
 
55
-		$this->name = "proforma";
56
-		$this->description = $langs->trans('PDFProformaDescription');
57
-	}
55
+        $this->name = "proforma";
56
+        $this->description = $langs->trans('PDFProformaDescription');
57
+    }
58 58
 
59 59
 
60
-	/**
61
-	 *  Show top header of page.
62
-	 *
63
-	 *  @param	TCPDF		$pdf     		Object PDF
64
-	 *  @param  Object		$object     	Object to show
65
-	 *  @param  int	    	$showaddress    0=no, 1=yes
66
-	 *  @param  Translate	$outputlangs	Object lang for output
67
-	 *  @param	string		$titlekey		Translation key to show as title of document
68
-	 *  @return	void
69
-	 */
70
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma")
71
-	{
72
-		global $conf,$langs,$hookmanager;
60
+    /**
61
+     *  Show top header of page.
62
+     *
63
+     *  @param	TCPDF		$pdf     		Object PDF
64
+     *  @param  Object		$object     	Object to show
65
+     *  @param  int	    	$showaddress    0=no, 1=yes
66
+     *  @param  Translate	$outputlangs	Object lang for output
67
+     *  @param	string		$titlekey		Translation key to show as title of document
68
+     *  @return	void
69
+     */
70
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma")
71
+    {
72
+        global $conf,$langs,$hookmanager;
73 73
 
74
-		parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
75
-	}
74
+        parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
75
+    }
76 76
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	function __construct($db)
50 50
 	{
51
-		global $conf,$langs,$mysoc;
51
+		global $conf, $langs, $mysoc;
52 52
 
53 53
 		parent::__construct($db);
54 54
 
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 *  @param	string		$titlekey		Translation key to show as title of document
68 68
 	 *  @return	void
69 69
 	 */
70
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma")
70
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma")
71 71
 	{
72
-		global $conf,$langs,$hookmanager;
72
+		global $conf, $langs, $hookmanager;
73 73
 
74 74
 		parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
75 75
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/modules_commande.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
      *  @param	DoliDB	$db     			Database handler
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50
-	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
52
-	{
50
+     */
51
+    static function liste_modeles($db, $maxfilenamelength=0)
52
+    {
53 53
         // phpcs:enable
54
-		global $conf;
54
+        global $conf;
55 55
 
56
-		$type = 'order';
57
-		$list = array();
56
+        $type = 'order';
57
+        $list = array();
58 58
 
59
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$list = getListOfModels($db, $type, $maxfilenamelength);
59
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
+        $list = getListOfModels($db, $type, $maxfilenamelength);
61 61
 
62
-		return $list;
63
-	}
62
+        return $list;
63
+    }
64 64
 }
65 65
 
66 66
 
@@ -72,82 +72,82 @@  discard block
 block discarded – undo
72 72
 
73 73
 abstract class ModeleNumRefCommandes
74 74
 {
75
-	/**
76
-	 * @var string Error code (or message)
77
-	 */
78
-	public $error='';
79
-
80
-	/**
81
-	 *	Return if a module can be used or not
82
-	 *
83
-	 *	@return		boolean     true if module can be used
84
-	 */
85
-	function isEnabled()
86
-	{
87
-		return true;
88
-	}
89
-
90
-	/**
91
-	 *	Renvoie la description par defaut du modele de numerotation
92
-	 *
93
-	 *	@return     string      Texte descripif
94
-	 */
95
-	function info()
96
-	{
97
-		global $langs;
98
-		$langs->load("orders");
99
-		return $langs->trans("NoDescription");
100
-	}
101
-
102
-	/**
103
-	 *	Renvoie un exemple de numerotation
104
-	 *
105
-	 *	@return     string      Example
106
-	 */
107
-	function getExample()
108
-	{
109
-		global $langs;
110
-		$langs->load("orders");
111
-		return $langs->trans("NoExample");
112
-	}
113
-
114
-	/**
115
-	 *	Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
116
-	 *
117
-	 *	@return     boolean     false si conflit, true si ok
118
-	 */
119
-	function canBeActivated()
120
-	{
121
-		return true;
122
-	}
123
-
124
-	/**
125
-	 *	Renvoie prochaine valeur attribuee
126
-	 *
127
-	 *	@param	Societe		$objsoc     Object thirdparty
128
-	 *	@param	Object		$object		Object we need next value for
129
-	 *	@return	string      Valeur
130
-	 */
131
-	function getNextValue($objsoc,$object)
132
-	{
133
-		global $langs;
134
-		return $langs->trans("NotAvailable");
135
-	}
136
-
137
-	/**
138
-	 *	Renvoie version du module numerotation
139
-	 *
140
-	 *	@return     string      Valeur
141
-	 */
142
-	function getVersion()
143
-	{
144
-		global $langs;
145
-		$langs->load("admin");
146
-
147
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
-		if ($this->version == 'dolibarr') return DOL_VERSION;
150
-		if ($this->version) return $this->version;
151
-		return $langs->trans("NotAvailable");
152
-	}
75
+    /**
76
+     * @var string Error code (or message)
77
+     */
78
+    public $error='';
79
+
80
+    /**
81
+     *	Return if a module can be used or not
82
+     *
83
+     *	@return		boolean     true if module can be used
84
+     */
85
+    function isEnabled()
86
+    {
87
+        return true;
88
+    }
89
+
90
+    /**
91
+     *	Renvoie la description par defaut du modele de numerotation
92
+     *
93
+     *	@return     string      Texte descripif
94
+     */
95
+    function info()
96
+    {
97
+        global $langs;
98
+        $langs->load("orders");
99
+        return $langs->trans("NoDescription");
100
+    }
101
+
102
+    /**
103
+     *	Renvoie un exemple de numerotation
104
+     *
105
+     *	@return     string      Example
106
+     */
107
+    function getExample()
108
+    {
109
+        global $langs;
110
+        $langs->load("orders");
111
+        return $langs->trans("NoExample");
112
+    }
113
+
114
+    /**
115
+     *	Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
116
+     *
117
+     *	@return     boolean     false si conflit, true si ok
118
+     */
119
+    function canBeActivated()
120
+    {
121
+        return true;
122
+    }
123
+
124
+    /**
125
+     *	Renvoie prochaine valeur attribuee
126
+     *
127
+     *	@param	Societe		$objsoc     Object thirdparty
128
+     *	@param	Object		$object		Object we need next value for
129
+     *	@return	string      Valeur
130
+     */
131
+    function getNextValue($objsoc,$object)
132
+    {
133
+        global $langs;
134
+        return $langs->trans("NotAvailable");
135
+    }
136
+
137
+    /**
138
+     *	Renvoie version du module numerotation
139
+     *
140
+     *	@return     string      Valeur
141
+     */
142
+    function getVersion()
143
+    {
144
+        global $langs;
145
+        $langs->load("admin");
146
+
147
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
+        if ($this->version == 'dolibarr') return DOL_VERSION;
150
+        if ($this->version) return $this->version;
151
+        return $langs->trans("NotAvailable");
152
+    }
153 153
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
33
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';	// required for use by classes that inherit
33
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
35 35
 
36 36
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50 50
 	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
51
+	static function liste_modeles($db, $maxfilenamelength = 0)
52 52
 	{
53 53
         // phpcs:enable
54 54
 		global $conf;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @var string Error code (or message)
77 77
 	 */
78
-	public $error='';
78
+	public $error = '';
79 79
 
80 80
 	/**
81 81
 	 *	Return if a module can be used or not
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 *	@param	Object		$object		Object we need next value for
129 129
 	 *	@return	string      Valeur
130 130
 	 */
131
-	function getNextValue($objsoc,$object)
131
+	function getNextValue($objsoc, $object)
132 132
 	{
133 133
 		global $langs;
134 134
 		return $langs->trans("NotAvailable");
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/mod_commande_saphir.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_commande_saphir extends ModeleNumRefCommandes
35 35
 {
36
-	/**
36
+    /**
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
41 41
 
42
-	/**
43
-	 * @var string Error message
44
-	 */
45
-	public $error = '';
42
+    /**
43
+     * @var string Error message
44
+     */
45
+    public $error = '';
46 46
 
47
-	/**
48
-	 * @var string nom
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Saphir';
47
+    /**
48
+     * @var string nom
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Saphir';
53 53
 
54
-	/**
55
-	 * @var string name
56
-	 */
57
-	public $name='Saphir';
54
+    /**
55
+     * @var string name
56
+     */
57
+    public $name='Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -62,39 +62,39 @@  discard block
 block discarded – undo
62 62
      *
63 63
      *  @return     string      Texte descripif
64 64
      */
65
-	function info()
65
+    function info()
66 66
     {
67
-    	global $conf, $langs;
67
+        global $conf, $langs;
68 68
 
69
-		$langs->load("bills");
69
+        $langs->load("bills");
70 70
 
71
-		$form = new Form($this->db);
71
+        $form = new Form($this->db);
72 72
 
73
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
73
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
77
+        $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
+        $texte.= '<table class="nobordernopadding" width="100%">';
79 79
 
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes2");
82
+        $tooltip.=$langs->trans("GenericMaskCodes3");
83
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
+        $tooltip.=$langs->trans("GenericMaskCodes5");
85 85
 
86
-		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
86
+        // Parametrage du prefix
87
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+        $texte.= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+        $texte.= '</table>';
95
+        $texte.= '</form>';
96 96
 
97
-		return $texte;
97
+        return $texte;
98 98
     }
99 99
 
100 100
     /**
@@ -104,60 +104,60 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
108
-
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$old_code_type=$mysoc->typent_code;
111
-    	$mysoc->code_client='CCCCCCCCCC';
112
-    	$mysoc->typent_code='TTTTTTTTTT';
113
-     	$numExample = $this->getNextValue($mysoc,'');
114
-		$mysoc->code_client=$old_code_client;
115
-		$mysoc->typent_code=$old_code_type;
116
-
117
-		if (! $numExample)
118
-		{
119
-			$numExample = $langs->trans('NotConfigured');
120
-		}
121
-		return $numExample;
107
+            global $conf,$langs,$mysoc;
108
+
109
+        $old_code_client=$mysoc->code_client;
110
+        $old_code_type=$mysoc->typent_code;
111
+        $mysoc->code_client='CCCCCCCCCC';
112
+        $mysoc->typent_code='TTTTTTTTTT';
113
+            $numExample = $this->getNextValue($mysoc,'');
114
+        $mysoc->code_client=$old_code_client;
115
+        $mysoc->typent_code=$old_code_type;
116
+
117
+        if (! $numExample)
118
+        {
119
+            $numExample = $langs->trans('NotConfigured');
120
+        }
121
+        return $numExample;
122 122
     }
123 123
 
124
-	/**
125
-	 * 	Return next free value
126
-	 *
127
-	 *  @param	Societe		$objsoc     Object thirdparty
128
-	 *  @param  Object		$object		Object we need next value for
129
-	 *  @return string      			Value if KO, <0 if KO
130
-	 */
124
+    /**
125
+     * 	Return next free value
126
+     *
127
+     *  @param	Societe		$objsoc     Object thirdparty
128
+     *  @param  Object		$object		Object we need next value for
129
+     *  @return string      			Value if KO, <0 if KO
130
+     */
131 131
     function getNextValue($objsoc,$object)
132 132
     {
133
-		global $db,$conf;
133
+        global $db,$conf;
134 134
 
135
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
135
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
136 136
 
137
-		// We get cursor rule
138
-		$mask=$conf->global->COMMANDE_SAPHIR_MASK;
137
+        // We get cursor rule
138
+        $mask=$conf->global->COMMANDE_SAPHIR_MASK;
139 139
 
140
-		if (! $mask)
141
-		{
142
-			$this->error='NotConfigured';
143
-			return 0;
144
-		}
140
+        if (! $mask)
141
+        {
142
+            $this->error='NotConfigured';
143
+            return 0;
144
+        }
145 145
 
146
-		$date = ($object->date_commande ? $object->date_commande : $object->date);
146
+        $date = ($object->date_commande ? $object->date_commande : $object->date);
147 147
 
148
-		$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
148
+        $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
149 149
 
150
-		return  $numFinal;
151
-	}
150
+        return  $numFinal;
151
+    }
152 152
 
153 153
 
154 154
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155
-	/**
156
-	 *  Return next free value
157
-	 *
158
-	 *  @param	Societe		$objsoc     Object third party
159
-	 *  @param	string		$objforref	Object for number to search
160
-	 *  @return string      			Next free value
155
+    /**
156
+     *  Return next free value
157
+     *
158
+     *  @param	Societe		$objsoc     Object third party
159
+     *  @param	string		$objforref	Object for number to search
160
+     *  @return string      			Next free value
161 161
      */
162 162
     function commande_get_num($objsoc,$objforref)
163 163
     {
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * \brief      Fichier contenant la classe du modele de numerotation de reference de commande Saphir
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
29 29
 
30 30
 
31 31
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
41 41
 
42 42
 	/**
43 43
 	 * @var string Error message
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Saphir';
52
+	public $nom = 'Saphir';
53 53
 
54 54
 	/**
55 55
 	 * @var string name
56 56
 	 */
57
-	public $name='Saphir';
57
+	public $name = 'Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -71,28 +71,28 @@  discard block
 block discarded – undo
71 71
 		$form = new Form($this->db);
72 72
 
73 73
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
79
-
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
74
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
77
+		$texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
+		$texte .= '<table class="nobordernopadding" width="100%">';
79
+
80
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes2");
82
+		$tooltip .= $langs->trans("GenericMaskCodes3");
83
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
84
+		$tooltip .= $langs->trans("GenericMaskCodes5");
85 85
 
86 86
 		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
87
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+		$texte .= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+		$texte .= '</table>';
95
+		$texte .= '</form>';
96 96
 
97 97
 		return $texte;
98 98
     }
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
107
+     	global $conf, $langs, $mysoc;
108 108
 
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$old_code_type=$mysoc->typent_code;
111
-    	$mysoc->code_client='CCCCCCCCCC';
112
-    	$mysoc->typent_code='TTTTTTTTTT';
113
-     	$numExample = $this->getNextValue($mysoc,'');
114
-		$mysoc->code_client=$old_code_client;
115
-		$mysoc->typent_code=$old_code_type;
109
+    	$old_code_client = $mysoc->code_client;
110
+    	$old_code_type = $mysoc->typent_code;
111
+    	$mysoc->code_client = 'CCCCCCCCCC';
112
+    	$mysoc->typent_code = 'TTTTTTTTTT';
113
+     	$numExample = $this->getNextValue($mysoc, '');
114
+		$mysoc->code_client = $old_code_client;
115
+		$mysoc->typent_code = $old_code_type;
116 116
 
117
-		if (! $numExample)
117
+		if (!$numExample)
118 118
 		{
119 119
 			$numExample = $langs->trans('NotConfigured');
120 120
 		}
@@ -128,24 +128,24 @@  discard block
 block discarded – undo
128 128
 	 *  @param  Object		$object		Object we need next value for
129 129
 	 *  @return string      			Value if KO, <0 if KO
130 130
 	 */
131
-    function getNextValue($objsoc,$object)
131
+    function getNextValue($objsoc, $object)
132 132
     {
133
-		global $db,$conf;
133
+		global $db, $conf;
134 134
 
135
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
135
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
136 136
 
137 137
 		// We get cursor rule
138
-		$mask=$conf->global->COMMANDE_SAPHIR_MASK;
138
+		$mask = $conf->global->COMMANDE_SAPHIR_MASK;
139 139
 
140
-		if (! $mask)
140
+		if (!$mask)
141 141
 		{
142
-			$this->error='NotConfigured';
142
+			$this->error = 'NotConfigured';
143 143
 			return 0;
144 144
 		}
145 145
 
146 146
 		$date = ($object->date_commande ? $object->date_commande : $object->date);
147 147
 
148
-		$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
148
+		$numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date);
149 149
 
150 150
 		return  $numFinal;
151 151
 	}
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 *  @param	string		$objforref	Object for number to search
160 160
 	 *  @return string      			Next free value
161 161
      */
162
-    function commande_get_num($objsoc,$objforref)
162
+    function commande_get_num($objsoc, $objforref)
163 163
     {
164 164
         // phpcs:enable
165
-        return $this->getNextValue($objsoc,$objforref);
165
+        return $this->getNextValue($objsoc, $objforref);
166 166
     }
167 167
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/mod_commande_marbre.php 3 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class mod_commande_marbre extends ModeleNumRefCommandes
31 31
 {
32
-	/**
32
+    /**
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
36
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37 37
 
38
-	public $prefix='CO';
38
+    public $prefix='CO';
39 39
 
40
-	/**
41
-	 * @var string Error code (or message)
42
-	 */
43
-	public $error='';
40
+    /**
41
+     * @var string Error code (or message)
42
+     */
43
+    public $error='';
44 44
 
45
-	/**
46
-	 * @var string
47
-	 * @deprecated
48
-	 * @see name
49
-	 */
50
-	public $nom='Marbre';
45
+    /**
46
+     * @var string
47
+     * @deprecated
48
+     * @see name
49
+     */
50
+    public $nom='Marbre';
51 51
 
52
-	/**
53
-	 * @var string name
54
-	 */
55
-	public $name='Marbre';
52
+    /**
53
+     * @var string name
54
+     */
55
+    public $name='Marbre';
56 56
 
57 57
 
58 58
     /**
@@ -62,110 +62,110 @@  discard block
 block discarded – undo
62 62
      */
63 63
     function info()
64 64
     {
65
-    	global $langs;
66
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
65
+        global $langs;
66
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67 67
     }
68 68
 
69 69
 
70
-	/**
71
-	 *  Renvoi un exemple de numerotation
72
-	 *
73
-	 *  @return     string      Example
74
-	 */
75
-	function getExample()
76
-	{
77
-		return $this->prefix."0501-0001";
78
-	}
79
-
80
-
81
-	/**
82
-	 *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
83
-	 *  de conflits qui empechera cette numerotation de fonctionner.
84
-	 *
85
-	 *  @return     boolean     false si conflit, true si ok
86
-	 */
87
-	function canBeActivated()
88
-	{
89
-		global $conf,$langs,$db;
90
-
91
-		$coyymm=''; $max='';
92
-
93
-		$posindice=8;
94
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
-		$sql.= " AND entity = ".$conf->entity;
98
-
99
-		$resql=$db->query($sql);
100
-		if ($resql)
101
-		{
102
-			$row = $db->fetch_row($resql);
103
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
-		}
105
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
-		{
107
-			$langs->load("errors");
108
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
109
-			return false;
110
-		}
111
-
112
-		return true;
113
-	}
114
-
115
-	/**
116
-	 * 	Return next free value
117
-	 *
118
-	 *  @param	Societe		$objsoc     Object thirdparty
119
-	 *  @param  Object		$object		Object we need next value for
120
-	 *  @return string      			Value if KO, <0 if KO
121
-	 */
122
-	function getNextValue($objsoc,$object)
123
-	{
124
-		global $db,$conf;
125
-
126
-		// D'abord on recupere la valeur max
127
-		$posindice=8;
128
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
-		$sql.= " AND entity = ".$conf->entity;
132
-
133
-		$resql=$db->query($sql);
134
-		if ($resql)
135
-		{
136
-			$obj = $db->fetch_object($resql);
137
-			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
139
-		}
140
-		else
141
-		{
142
-			dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143
-			return -1;
144
-		}
145
-
146
-		//$date=time();
147
-		$date=$object->date;
148
-		$yymm = strftime("%y%m",$date);
149
-
150
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
151
-    	else $num = sprintf("%04s", $max+1);
152
-
153
-		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154
-		return $this->prefix.$yymm."-".$num;
155
-	}
70
+    /**
71
+     *  Renvoi un exemple de numerotation
72
+     *
73
+     *  @return     string      Example
74
+     */
75
+    function getExample()
76
+    {
77
+        return $this->prefix."0501-0001";
78
+    }
79
+
80
+
81
+    /**
82
+     *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
83
+     *  de conflits qui empechera cette numerotation de fonctionner.
84
+     *
85
+     *  @return     boolean     false si conflit, true si ok
86
+     */
87
+    function canBeActivated()
88
+    {
89
+        global $conf,$langs,$db;
90
+
91
+        $coyymm=''; $max='';
92
+
93
+        $posindice=8;
94
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
+        $sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
+        $sql.= " AND entity = ".$conf->entity;
98
+
99
+        $resql=$db->query($sql);
100
+        if ($resql)
101
+        {
102
+            $row = $db->fetch_row($resql);
103
+            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
+        }
105
+        if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
+        {
107
+            $langs->load("errors");
108
+            $this->error=$langs->trans('ErrorNumRefModel', $max);
109
+            return false;
110
+        }
111
+
112
+        return true;
113
+    }
114
+
115
+    /**
116
+     * 	Return next free value
117
+     *
118
+     *  @param	Societe		$objsoc     Object thirdparty
119
+     *  @param  Object		$object		Object we need next value for
120
+     *  @return string      			Value if KO, <0 if KO
121
+     */
122
+    function getNextValue($objsoc,$object)
123
+    {
124
+        global $db,$conf;
125
+
126
+        // D'abord on recupere la valeur max
127
+        $posindice=8;
128
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
+        $sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
+        $sql.= " AND entity = ".$conf->entity;
132
+
133
+        $resql=$db->query($sql);
134
+        if ($resql)
135
+        {
136
+            $obj = $db->fetch_object($resql);
137
+            if ($obj) $max = intval($obj->max);
138
+            else $max=0;
139
+        }
140
+        else
141
+        {
142
+            dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143
+            return -1;
144
+        }
145
+
146
+        //$date=time();
147
+        $date=$object->date;
148
+        $yymm = strftime("%y%m",$date);
149
+
150
+        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
151
+        else $num = sprintf("%04s", $max+1);
152
+
153
+        dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154
+        return $this->prefix.$yymm."-".$num;
155
+    }
156 156
 
157 157
 
158 158
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
159
-	/**
160
-	 *  Return next free value
161
-	 *
162
-	 *  @param	Societe		$objsoc     Object third party
163
-	 * 	@param	string		$objforref	Object for number to search
164
-	 *  @return string      			Next free value
165
-	 */
166
-	function commande_get_num($objsoc,$objforref)
167
-	{
159
+    /**
160
+     *  Return next free value
161
+     *
162
+     *  @param	Societe		$objsoc     Object third party
163
+     * 	@param	string		$objforref	Object for number to search
164
+     *  @return string      			Next free value
165
+     */
166
+    function commande_get_num($objsoc,$objforref)
167
+    {
168 168
         // phpcs:enable
169
-		return $this->getNextValue($objsoc,$objforref);
170
-	}
169
+        return $this->getNextValue($objsoc,$objforref);
170
+    }
171 171
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \ingroup    commande
23 23
  *  \brief      File of class to manage customer order numbering rules Marbre
24 24
  */
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
26 26
 
27 27
 /**
28 28
  *	Class to manage customer order numbering rules Marbre
@@ -33,26 +33,26 @@  discard block
 block discarded – undo
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
36
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
37 37
 
38
-	public $prefix='CO';
38
+	public $prefix = 'CO';
39 39
 
40 40
 	/**
41 41
 	 * @var string Error code (or message)
42 42
 	 */
43
-	public $error='';
43
+	public $error = '';
44 44
 
45 45
 	/**
46 46
 	 * @var string
47 47
 	 * @deprecated
48 48
 	 * @see name
49 49
 	 */
50
-	public $nom='Marbre';
50
+	public $nom = 'Marbre';
51 51
 
52 52
 	/**
53 53
 	 * @var string name
54 54
 	 */
55
-	public $name='Marbre';
55
+	public $name = 'Marbre';
56 56
 
57 57
 
58 58
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     function info()
64 64
     {
65 65
     	global $langs;
66
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
66
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
67 67
     }
68 68
 
69 69
 
@@ -86,26 +86,26 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	function canBeActivated()
88 88
 	{
89
-		global $conf,$langs,$db;
89
+		global $conf, $langs, $db;
90 90
 
91
-		$coyymm=''; $max='';
91
+		$coyymm = ''; $max = '';
92 92
 
93
-		$posindice=8;
93
+		$posindice = 8;
94 94
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
-		$sql.= " AND entity = ".$conf->entity;
95
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
96
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
+		$sql .= " AND entity = ".$conf->entity;
98 98
 
99
-		$resql=$db->query($sql);
99
+		$resql = $db->query($sql);
100 100
 		if ($resql)
101 101
 		{
102 102
 			$row = $db->fetch_row($resql);
103
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
103
+			if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
104 104
 		}
105
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
105
+		if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
106 106
 		{
107 107
 			$langs->load("errors");
108
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
108
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
109 109
 			return false;
110 110
 		}
111 111
 
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 *  @param  Object		$object		Object we need next value for
120 120
 	 *  @return string      			Value if KO, <0 if KO
121 121
 	 */
122
-	function getNextValue($objsoc,$object)
122
+	function getNextValue($objsoc, $object)
123 123
 	{
124
-		global $db,$conf;
124
+		global $db, $conf;
125 125
 
126 126
 		// D'abord on recupere la valeur max
127
-		$posindice=8;
127
+		$posindice = 8;
128 128
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
-		$sql.= " AND entity = ".$conf->entity;
129
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
130
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
+		$sql .= " AND entity = ".$conf->entity;
132 132
 
133
-		$resql=$db->query($sql);
133
+		$resql = $db->query($sql);
134 134
 		if ($resql)
135 135
 		{
136 136
 			$obj = $db->fetch_object($resql);
137 137
 			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
138
+			else $max = 0;
139 139
 		}
140 140
 		else
141 141
 		{
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 
146 146
 		//$date=time();
147
-		$date=$object->date;
148
-		$yymm = strftime("%y%m",$date);
147
+		$date = $object->date;
148
+		$yymm = strftime("%y%m", $date);
149 149
 
150
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
151
-    	else $num = sprintf("%04s", $max+1);
150
+    	if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
151
+    	else $num = sprintf("%04s", $max + 1);
152 152
 
153 153
 		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154 154
 		return $this->prefix.$yymm."-".$num;
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 * 	@param	string		$objforref	Object for number to search
164 164
 	 *  @return string      			Next free value
165 165
 	 */
166
-	function commande_get_num($objsoc,$objforref)
166
+	function commande_get_num($objsoc, $objforref)
167 167
 	{
168 168
         // phpcs:enable
169
-		return $this->getNextValue($objsoc,$objforref);
169
+		return $this->getNextValue($objsoc, $objforref);
170 170
 	}
171 171
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -134,10 +134,12 @@  discard block
 block discarded – undo
134 134
 		if ($resql)
135 135
 		{
136 136
 			$obj = $db->fetch_object($resql);
137
-			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
139
-		}
140
-		else
137
+			if ($obj) {
138
+			    $max = intval($obj->max);
139
+			} else {
140
+			    $max=0;
141
+			}
142
+		} else
141 143
 		{
142 144
 			dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143 145
 			return -1;
@@ -147,8 +149,13 @@  discard block
 block discarded – undo
147 149
 		$date=$object->date;
148 150
 		$yymm = strftime("%y%m",$date);
149 151
 
150
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
151
-    	else $num = sprintf("%04s", $max+1);
152
+    	if ($max >= (pow(10, 4) - 1)) {
153
+    	    $num=$max+1;
154
+    	}
155
+    	// If counter > 9999, we do not format on 4 chars, we take number as it is
156
+    	else {
157
+    	    $num = sprintf("%04s", $max+1);
158
+    	}
152 159
 
153 160
 		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154 161
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modTakePos.class.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -32,131 +32,131 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class modTakePos extends DolibarrModules
34 34
 {
35
-	/**
36
-	 * Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 * @param DoliDB $db Database handler
39
-	 */
40
-	public function __construct($db)
41
-	{
35
+    /**
36
+     * Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     * @param DoliDB $db Database handler
39
+     */
40
+    public function __construct($db)
41
+    {
42 42
         global $langs,$conf;
43 43
 
44 44
         $this->db = $db;
45 45
 
46
-		// Id for module (must be unique).
47
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
-		$this->numero = 50150;
49
-		// Key text used to identify module (for permissions, menus, etc...)
50
-		$this->rights_class = 'takepos';
51
-
52
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
-		// It is used to group modules by family in module setup page
54
-		$this->family = "portal";
55
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
56
-		$this->module_position = '60';
57
-		// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
-
60
-		// Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
62
-		// Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63
-		$this->description = "Point of sales module (Touch Screen POS)";
64
-		// Used only if file README.md and README-LL.md not found.
65
-		$this->descriptionlong = "Point Of Sales (compliant with touch screen)";
66
-
67
-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
-		$this->version = 'experimental';
69
-		// Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase)
70
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
-		// Name of image file used for this module.
72
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='list';
75
-
76
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
-		// for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78
-		// for specific path of parts (eg: /takepos/core/modules/barcode)
79
-		// for specific css file (eg: /takepos/css/takepos.css.php)
80
-		$this->module_parts = array(
81
-		                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
-									'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
-									'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
-									'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
-									'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
-		                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
-									'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
-									'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
89
-									'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90
-		                        );
91
-
92
-		// Data directories to create when module is enabled.
93
-		// Example: this->dirs = array("/takepos/temp","/takepos/subdir");
94
-		$this->dirs = array();
95
-
96
-		// Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module.
97
-		$this->config_page_url = array("setup.php@takepos");
98
-
99
-		// Dependencies
100
-		$this->hidden = false;			// A condition to hide module
101
-		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
103
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
104
-		$this->langfiles = array("cashdesk");
105
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
-		$this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
-		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109
-		//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110
-		//$this->always_enabled = true;								// If true, can't be disabled
111
-
112
-		// Constants
113
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
114
-		// Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
115
-		//                             1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
116
-		// );
117
-		$this->const = array(
118
-			//1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
119
-		);
120
-
121
-
122
-		if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
123
-		{
124
-			$conf->takepos=new stdClass();
125
-			$conf->takepos->enabled=0;
126
-		}
127
-
128
-
129
-		// Array to add new pages in new tabs
46
+        // Id for module (must be unique).
47
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
+        $this->numero = 50150;
49
+        // Key text used to identify module (for permissions, menus, etc...)
50
+        $this->rights_class = 'takepos';
51
+
52
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
+        // It is used to group modules by family in module setup page
54
+        $this->family = "portal";
55
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
56
+        $this->module_position = '60';
57
+        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
+
60
+        // Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
+        $this->name = preg_replace('/^mod/i','',get_class($this));
62
+        // Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63
+        $this->description = "Point of sales module (Touch Screen POS)";
64
+        // Used only if file README.md and README-LL.md not found.
65
+        $this->descriptionlong = "Point Of Sales (compliant with touch screen)";
66
+
67
+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
+        $this->version = 'experimental';
69
+        // Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase)
70
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
+        // Name of image file used for this module.
72
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
+        $this->picto='list';
75
+
76
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
+        // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78
+        // for specific path of parts (eg: /takepos/core/modules/barcode)
79
+        // for specific css file (eg: /takepos/css/takepos.css.php)
80
+        $this->module_parts = array(
81
+                                    'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
+                                    'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
+                                    'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
+                                    'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
+                                    'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
+                                    'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
+                                    'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
+                                    'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
89
+                                    'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90
+                                );
91
+
92
+        // Data directories to create when module is enabled.
93
+        // Example: this->dirs = array("/takepos/temp","/takepos/subdir");
94
+        $this->dirs = array();
95
+
96
+        // Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module.
97
+        $this->config_page_url = array("setup.php@takepos");
98
+
99
+        // Dependencies
100
+        $this->hidden = false;			// A condition to hide module
101
+        $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
103
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
104
+        $this->langfiles = array("cashdesk");
105
+        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
+        $this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
+        $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
+        $this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109
+        //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110
+        //$this->always_enabled = true;								// If true, can't be disabled
111
+
112
+        // Constants
113
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
114
+        // Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
115
+        //                             1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
116
+        // );
117
+        $this->const = array(
118
+            //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
119
+        );
120
+
121
+
122
+        if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
123
+        {
124
+            $conf->takepos=new stdClass();
125
+            $conf->takepos->enabled=0;
126
+        }
127
+
128
+
129
+        // Array to add new pages in new tabs
130 130
         $this->tabs = array();
131
-		// Example:
132
-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
131
+        // Example:
132
+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
133 133
         // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
134 134
         // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
135 135
         //
136 136
         // Where objecttype can be
137
-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
138
-		// 'contact'          to add a tab in contact view
139
-		// 'contract'         to add a tab in contract view
140
-		// 'group'            to add a tab in group view
141
-		// 'intervention'     to add a tab in intervention view
142
-		// 'invoice'          to add a tab in customer invoice view
143
-		// 'invoice_supplier' to add a tab in supplier invoice view
144
-		// 'member'           to add a tab in fundation member view
145
-		// 'opensurveypoll'	  to add a tab in opensurvey poll view
146
-		// 'order'            to add a tab in customer order view
147
-		// 'order_supplier'   to add a tab in supplier order view
148
-		// 'payment'		  to add a tab in payment view
149
-		// 'payment_supplier' to add a tab in supplier payment view
150
-		// 'product'          to add a tab in product view
151
-		// 'propal'           to add a tab in propal view
152
-		// 'project'          to add a tab in project view
153
-		// 'stock'            to add a tab in stock view
154
-		// 'thirdparty'       to add a tab in third party view
155
-		// 'user'             to add a tab in user view
137
+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
138
+        // 'contact'          to add a tab in contact view
139
+        // 'contract'         to add a tab in contract view
140
+        // 'group'            to add a tab in group view
141
+        // 'intervention'     to add a tab in intervention view
142
+        // 'invoice'          to add a tab in customer invoice view
143
+        // 'invoice_supplier' to add a tab in supplier invoice view
144
+        // 'member'           to add a tab in fundation member view
145
+        // 'opensurveypoll'	  to add a tab in opensurvey poll view
146
+        // 'order'            to add a tab in customer order view
147
+        // 'order_supplier'   to add a tab in supplier order view
148
+        // 'payment'		  to add a tab in payment view
149
+        // 'payment_supplier' to add a tab in supplier payment view
150
+        // 'product'          to add a tab in product view
151
+        // 'propal'           to add a tab in propal view
152
+        // 'project'          to add a tab in project view
153
+        // 'stock'            to add a tab in stock view
154
+        // 'thirdparty'       to add a tab in third party view
155
+        // 'user'             to add a tab in user view
156 156
 
157 157
 
158 158
         // Dictionaries
159
-		$this->dictionaries=array();
159
+        $this->dictionaries=array();
160 160
         /* Example:
161 161
         $this->dictionaries=array(
162 162
             'langs'=>'mylangfile@takepos',
@@ -174,60 +174,60 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
         // Boxes/Widgets
177
-		// Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget.
177
+        // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget.
178 178
         $this->boxes = array(
179
-        	//0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),
180
-        	//1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),
181
-        	//2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')
179
+            //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),
180
+            //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),
181
+            //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')
182 182
         );
183 183
 
184 184
 
185
-		// Cronjobs (List of cron jobs entries to add when module is enabled)
186
-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
187
-		$this->cronjobs = array(
188
-			//0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
189
-		);
190
-		// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
191
-		//                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
192
-		// );
185
+        // Cronjobs (List of cron jobs entries to add when module is enabled)
186
+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
187
+        $this->cronjobs = array(
188
+            //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
189
+        );
190
+        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
191
+        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
192
+        // );
193 193
 
194 194
 
195
-		// Permissions
196
-		$this->rights = array();		// Permission array used by this module
195
+        // Permissions
196
+        $this->rights = array();		// Permission array used by this module
197 197
 
198
-		$r=0;
198
+        $r=0;
199 199
 
200
-		$r++;
201
-		$this->rights[$r][0] = 50151;
202
-		$this->rights[$r][1] = 'Use point of sale';
203
-		$this->rights[$r][2] = 'a';
204
-		$this->rights[$r][3] = 0;
205
-		$this->rights[$r][4] = 'use';
200
+        $r++;
201
+        $this->rights[$r][0] = 50151;
202
+        $this->rights[$r][1] = 'Use point of sale';
203
+        $this->rights[$r][2] = 'a';
204
+        $this->rights[$r][3] = 0;
205
+        $this->rights[$r][4] = 'use';
206 206
 
207 207
 
208
-		// Main menu entries
209
-		$this->menu = array();			// List of menus to add
210
-		$r=0;
208
+        // Main menu entries
209
+        $this->menu = array();			// List of menus to add
210
+        $r=0;
211 211
 
212
-		// Add here entries to declare new menus
212
+        // Add here entries to declare new menus
213 213
 
214
-		/* BEGIN MODULEBUILDER TOPMENU */
215
-		$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
-								'type'=>'top',			                // This is a Top menu entry
217
-								'titre'=>'PointOfSaleShort',
218
-								'mainmenu'=>'takepos',
219
-								'leftmenu'=>'',
220
-								'url'=>'/takepos/takepos.php',
221
-								'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
-								'position'=>1000+$r,
223
-								'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
-								'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225
-								'target'=>'takepos',
226
-								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
214
+        /* BEGIN MODULEBUILDER TOPMENU */
215
+        $this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
+                                'type'=>'top',			                // This is a Top menu entry
217
+                                'titre'=>'PointOfSaleShort',
218
+                                'mainmenu'=>'takepos',
219
+                                'leftmenu'=>'',
220
+                                'url'=>'/takepos/takepos.php',
221
+                                'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
+                                'position'=>1000+$r,
223
+                                'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
+                                'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225
+                                'target'=>'takepos',
226
+                                'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
227 227
 
228
-		/* END MODULEBUILDER TOPMENU */
228
+        /* END MODULEBUILDER TOPMENU */
229 229
 
230
-		/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
230
+        /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
231 231
 		$this->menu[$r++]=array(	'fk_menu'=>'fk_mainmenu=takepos',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
232 232
 								'type'=>'left',			                // This is a Left menu entry
233 233
 								'titre'=>'List MyObject',
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 		END MODULEBUILDER LEFTMENU MYOBJECT */
256 256
 
257 257
 
258
-		// Exports
259
-		$r=1;
258
+        // Exports
259
+        $r=1;
260 260
 
261
-		/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262
-		/*
261
+        /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262
+        /*
263 263
 		$langs->load("cashdesk");
264 264
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
265 265
 		$this->export_label[$r]='MyObjectLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
@@ -274,41 +274,41 @@  discard block
 block discarded – undo
274 274
 		$this->export_sql_end[$r] .=' WHERE 1 = 1';
275 275
 		$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
276 276
 		$r++; */
277
-		/* END MODULEBUILDER EXPORT MYOBJECT */
278
-	}
279
-
280
-	/**
281
-	 *	Function called when module is enabled.
282
-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
283
-	 *	It also creates data directories
284
-	 *
277
+        /* END MODULEBUILDER EXPORT MYOBJECT */
278
+    }
279
+
280
+    /**
281
+     *	Function called when module is enabled.
282
+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
283
+     *	It also creates data directories
284
+     *
285
+     *	@param      string	$options    Options when enabling module ('', 'noboxes')
286
+     *	@return     int             	1 if OK, 0 if KO
287
+     */
288
+    public function init($options='')
289
+    {
290
+        $this->_load_tables('/takepos/sql/');
291
+
292
+        $sql = array();
293
+
294
+        // Remove permissions and default values
295
+        $this->remove($options);
296
+
297
+        return $this->_init($sql, $options);
298
+    }
299
+
300
+    /**
301
+     *	Function called when module is disabled.
302
+     *	Remove from database constants, boxes and permissions from Dolibarr database.
303
+     *	Data directories are not deleted
304
+     *
285 305
      *	@param      string	$options    Options when enabling module ('', 'noboxes')
286
-	 *	@return     int             	1 if OK, 0 if KO
287
-	 */
288
-	public function init($options='')
289
-	{
290
-		$this->_load_tables('/takepos/sql/');
291
-
292
-		$sql = array();
293
-
294
-		// Remove permissions and default values
295
-		$this->remove($options);
296
-
297
-		return $this->_init($sql, $options);
298
-	}
299
-
300
-	/**
301
-	 *	Function called when module is disabled.
302
-	 *	Remove from database constants, boxes and permissions from Dolibarr database.
303
-	 *	Data directories are not deleted
304
-	 *
305
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')
306
-	 *	@return     int             	1 if OK, 0 if KO
307
-	 */
308
-	public function remove($options = '')
309
-	{
310
-		$sql = array();
311
-
312
-		return $this->_remove($sql, $options);
313
-	}
306
+     *	@return     int             	1 if OK, 0 if KO
307
+     */
308
+    public function remove($options = '')
309
+    {
310
+        $sql = array();
311
+
312
+        return $this->_remove($sql, $options);
313
+    }
314 314
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *  \ingroup    takepos
25 25
  *  \brief      Description and activation file for module TakePos
26 26
  */
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct($db)
41 41
 	{
42
-        global $langs,$conf;
42
+        global $langs, $conf;
43 43
 
44 44
         $this->db = $db;
45 45
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59 59
 
60 60
 		// Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
61
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
62 62
 		// Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63 63
 		$this->description = "Point of sales module (Touch Screen POS)";
64 64
 		// Used only if file README.md and README-LL.md not found.
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 		// Name of image file used for this module.
72 72
 		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73 73
 		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='list';
74
+		$this->picto = 'list';
75 75
 
76 76
 		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77 77
 		// for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78 78
 		// for specific path of parts (eg: /takepos/core/modules/barcode)
79 79
 		// for specific css file (eg: /takepos/css/takepos.css.php)
80 80
 		$this->module_parts = array(
81
-		                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
-									'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
-									'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
-									'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
-									'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
-		                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
-									'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
-									'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
81
+		                        	'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
82
+									'login' => 0, // Set this to 1 if module has its own login method file (core/login)
83
+									'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions)
84
+									'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
85
+									'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
86
+		                        	'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
87
+									'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
+									'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
89 89
 									'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90 90
 		                        );
91 91
 
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 		$this->config_page_url = array("setup.php@takepos");
98 98
 
99 99
 		// Dependencies
100
-		$this->hidden = false;			// A condition to hide module
101
-		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
103
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
100
+		$this->hidden = false; // A condition to hide module
101
+		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled
102
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
103
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
104 104
 		$this->langfiles = array("cashdesk");
105
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
-		$this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
-		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
105
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
106
+		$this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module
107
+		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
+		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109 109
 		//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110 110
 		//$this->always_enabled = true;								// If true, can't be disabled
111 111
 
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 		);
120 120
 
121 121
 
122
-		if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
122
+		if (!isset($conf->takepos) || !isset($conf->takepos->enabled))
123 123
 		{
124
-			$conf->takepos=new stdClass();
125
-			$conf->takepos->enabled=0;
124
+			$conf->takepos = new stdClass();
125
+			$conf->takepos->enabled = 0;
126 126
 		}
127 127
 
128 128
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 
158 158
         // Dictionaries
159
-		$this->dictionaries=array();
159
+		$this->dictionaries = array();
160 160
         /* Example:
161 161
         $this->dictionaries=array(
162 162
             'langs'=>'mylangfile@takepos',
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 
194 194
 
195 195
 		// Permissions
196
-		$this->rights = array();		// Permission array used by this module
196
+		$this->rights = array(); // Permission array used by this module
197 197
 
198
-		$r=0;
198
+		$r = 0;
199 199
 
200 200
 		$r++;
201 201
 		$this->rights[$r][0] = 50151;
@@ -206,24 +206,24 @@  discard block
 block discarded – undo
206 206
 
207 207
 
208 208
 		// Main menu entries
209
-		$this->menu = array();			// List of menus to add
210
-		$r=0;
209
+		$this->menu = array(); // List of menus to add
210
+		$r = 0;
211 211
 
212 212
 		// Add here entries to declare new menus
213 213
 
214 214
 		/* BEGIN MODULEBUILDER TOPMENU */
215
-		$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
-								'type'=>'top',			                // This is a Top menu entry
215
+		$this->menu[$r++] = array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
+								'type'=>'top', // This is a Top menu entry
217 217
 								'titre'=>'PointOfSaleShort',
218 218
 								'mainmenu'=>'takepos',
219 219
 								'leftmenu'=>'',
220 220
 								'url'=>'/takepos/takepos.php',
221
-								'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
-								'position'=>1000+$r,
223
-								'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
-								'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
221
+								'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
+								'position'=>1000 + $r,
223
+								'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
+								'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225 225
 								'target'=>'takepos',
226
-								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
226
+								'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
227 227
 
228 228
 		/* END MODULEBUILDER TOPMENU */
229 229
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 
258 258
 		// Exports
259
-		$r=1;
259
+		$r = 1;
260 260
 
261 261
 		/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262 262
 		/*
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      *	@param      string	$options    Options when enabling module ('', 'noboxes')
286 286
 	 *	@return     int             	1 if OK, 0 if KO
287 287
 	 */
288
-	public function init($options='')
288
+	public function init($options = '')
289 289
 	{
290 290
 		$this->_load_tables('/takepos/sql/');
291 291
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/doc/pdf_baleine.modules.php 3 patches
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -38,193 +38,193 @@  discard block
 block discarded – undo
38 38
 
39 39
 class pdf_baleine extends ModelePDFProjects
40 40
 {
41
-	/**
41
+    /**
42 42
      * @var DoliDb Database handler
43 43
      */
44 44
     public $db;
45 45
 
46
-	/**
46
+    /**
47 47
      * @var string model name
48 48
      */
49 49
     public $name;
50 50
 
51
-	/**
51
+    /**
52 52
      * @var string model description (short text)
53 53
      */
54 54
     public $description;
55 55
 
56
-	/**
56
+    /**
57 57
      * @var string document type
58 58
      */
59 59
     public $type;
60 60
 
61 61
     /**
62 62
      * @var array() Minimum version of PHP required by module.
63
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
63
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
64 64
      */
65
-	public $phpmin = array(5, 4);
65
+    public $phpmin = array(5, 4);
66 66
 
67
-	/**
67
+    /**
68 68
      * Dolibarr version of the loaded document
69 69
      * @public string
70 70
      */
71
-	public $version = 'dolibarr';
71
+    public $version = 'dolibarr';
72 72
 
73
-	/**
73
+    /**
74 74
      * @var int page_largeur
75 75
      */
76 76
     public $page_largeur;
77 77
 
78
-	/**
78
+    /**
79 79
      * @var int page_hauteur
80 80
      */
81 81
     public $page_hauteur;
82 82
 
83
-	/**
83
+    /**
84 84
      * @var array format
85 85
      */
86 86
     public $format;
87 87
 
88
-	/**
88
+    /**
89 89
      * @var int marge_gauche
90 90
      */
91
-	public $marge_gauche;
91
+    public $marge_gauche;
92 92
 
93
-	/**
93
+    /**
94 94
      * @var int marge_droite
95 95
      */
96
-	public $marge_droite;
96
+    public $marge_droite;
97 97
 
98
-	/**
98
+    /**
99 99
      * @var int marge_haute
100 100
      */
101
-	public $marge_haute;
101
+    public $marge_haute;
102 102
 
103
-	/**
103
+    /**
104 104
      * @var int marge_basse
105 105
      */
106
-	public $marge_basse;
107
-
108
-	/**
109
-	 * Issuer
110
-	 * @var Company object that emits
111
-	 */
112
-	public $emetteur;
113
-
114
-	/**
115
-	 *	Constructor
116
-	 *
117
-	 *  @param		DoliDB		$db      Database handler
118
-	 */
119
-	function __construct($db)
120
-	{
121
-		global $conf,$langs,$mysoc;
122
-
123
-		// Translations
124
-		$langs->loadLangs(array("main", "projects", "companies"));
125
-
126
-		$this->db = $db;
127
-		$this->name = "baleine";
128
-		$this->description = $langs->trans("DocumentModelBaleine");
129
-
130
-		// Dimension page pour format A4
131
-		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
133
-		$this->page_largeur = $formatarray['width'];
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;
140
-
141
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
142
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
144
-
145
-		// Recupere emmetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
-
149
-		// Defini position des colonnes
150
-		$this->posxref=$this->marge_gauche+1;
151
-		$this->posxlabel=$this->marge_gauche+25;
152
-		$this->posxworkload=$this->marge_gauche+120;
153
-		$this->posxprogress=$this->marge_gauche+140;
154
-		$this->posxdatestart=$this->marge_gauche+152;
155
-		$this->posxdateend=$this->marge_gauche+170;
156
-		if ($this->page_largeur < 210) // To work with US executive format
157
-		{
158
-			$this->posxref-=20;
159
-			$this->posxlabel-=20;
160
-			$this->posxworkload-=20;
161
-			$this->posxprogress-=20;
162
-			$this->posxdatestart-=20;
163
-			$this->posxdateend-=20;
164
-		}
165
-	}
106
+    public $marge_basse;
107
+
108
+    /**
109
+     * Issuer
110
+     * @var Company object that emits
111
+     */
112
+    public $emetteur;
113
+
114
+    /**
115
+     *	Constructor
116
+     *
117
+     *  @param		DoliDB		$db      Database handler
118
+     */
119
+    function __construct($db)
120
+    {
121
+        global $conf,$langs,$mysoc;
122
+
123
+        // Translations
124
+        $langs->loadLangs(array("main", "projects", "companies"));
125
+
126
+        $this->db = $db;
127
+        $this->name = "baleine";
128
+        $this->description = $langs->trans("DocumentModelBaleine");
129
+
130
+        // Dimension page pour format A4
131
+        $this->type = 'pdf';
132
+        $formatarray=pdf_getFormat();
133
+        $this->page_largeur = $formatarray['width'];
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;
140
+
141
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
142
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
144
+
145
+        // Recupere emmetteur
146
+        $this->emetteur=$mysoc;
147
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
+
149
+        // Defini position des colonnes
150
+        $this->posxref=$this->marge_gauche+1;
151
+        $this->posxlabel=$this->marge_gauche+25;
152
+        $this->posxworkload=$this->marge_gauche+120;
153
+        $this->posxprogress=$this->marge_gauche+140;
154
+        $this->posxdatestart=$this->marge_gauche+152;
155
+        $this->posxdateend=$this->marge_gauche+170;
156
+        if ($this->page_largeur < 210) // To work with US executive format
157
+        {
158
+            $this->posxref-=20;
159
+            $this->posxlabel-=20;
160
+            $this->posxworkload-=20;
161
+            $this->posxprogress-=20;
162
+            $this->posxdatestart-=20;
163
+            $this->posxdateend-=20;
164
+        }
165
+    }
166 166
 
167 167
 
168 168
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
169
-	/**
170
-	 *  Fonction generant le projet sur le disque
171
-	 *
172
-	 *	@param	Project		$object   		Object project a generer
173
-	 *	@param	Translate	$outputlangs	Lang output object
174
-	 *	@return	int         				1 if OK, <=0 if KO
175
-	 */
176
-	function write_file($object,$outputlangs)
177
-	{
169
+    /**
170
+     *  Fonction generant le projet sur le disque
171
+     *
172
+     *	@param	Project		$object   		Object project a generer
173
+     *	@param	Translate	$outputlangs	Lang output object
174
+     *	@return	int         				1 if OK, <=0 if KO
175
+     */
176
+    function write_file($object,$outputlangs)
177
+    {
178 178
         // phpcs:enable
179
-		global $conf, $hookmanager, $langs, $user;
180
-
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
182
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
184
-
185
-		// Load traductions files requiredby by page
186
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
187
-
188
-		if ($conf->projet->dir_output)
189
-		{
190
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
191
-
192
-			$objectref = dol_sanitizeFileName($object->ref);
193
-			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
-			$file = $dir . "/" . $objectref . ".pdf";
196
-
197
-			if (! file_exists($dir))
198
-			{
199
-				if (dol_mkdir($dir) < 0)
200
-				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
-					return 0;
203
-				}
204
-			}
205
-
206
-			if (file_exists($dir))
207
-			{
208
-				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
210
-				{
211
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
213
-				}
214
-				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
-				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
-
219
-				// Create pdf instance
220
-				$pdf=pdf_getInstance($this->format);
221
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
-				$pdf->SetAutoPageBreak(1,0);
223
-
224
-				$heightforinfotot = 40;	// 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
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
179
+        global $conf, $hookmanager, $langs, $user;
180
+
181
+        if (! is_object($outputlangs)) $outputlangs=$langs;
182
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
184
+
185
+        // Load traductions files requiredby by page
186
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
187
+
188
+        if ($conf->projet->dir_output)
189
+        {
190
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
191
+
192
+            $objectref = dol_sanitizeFileName($object->ref);
193
+            $dir = $conf->projet->dir_output;
194
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
+            $file = $dir . "/" . $objectref . ".pdf";
196
+
197
+            if (! file_exists($dir))
198
+            {
199
+                if (dol_mkdir($dir) < 0)
200
+                {
201
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
+                    return 0;
203
+                }
204
+            }
205
+
206
+            if (file_exists($dir))
207
+            {
208
+                // Add pdfgeneration hook
209
+                if (! is_object($hookmanager))
210
+                {
211
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
+                    $hookmanager=new HookManager($this->db);
213
+                }
214
+                $hookmanager->initHooks(array('pdfgeneration'));
215
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
+                global $action;
217
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
+
219
+                // Create pdf instance
220
+                $pdf=pdf_getInstance($this->format);
221
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
+                $pdf->SetAutoPageBreak(1,0);
223
+
224
+                $heightforinfotot = 40;	// 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
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -239,403 +239,403 @@  discard block
 block discarded – undo
239 239
                     $tplidx = $pdf->importPage(1);
240 240
                 }
241 241
 
242
-				// Complete object by loading several other informations
243
-				$task = new Task($this->db);
244
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
245
-
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
247
-				{
248
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249
-				}
250
-
251
-				$object->lines=$tasksarray;
252
-				$nblignes=count($object->lines);
253
-
254
-				$pdf->Open();
255
-				$pagenb=0;
256
-				$pdf->SetDrawColor(128,128,128);
257
-
258
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259
-				$pdf->SetSubject($outputlangs->transnoentities("Project"));
260
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264
-
265
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266
-
267
-				// New page
268
-				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
270
-				$pagenb++;
271
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
272
-				$pdf->SetFont('','', $default_font_size - 1);
273
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
274
-				$pdf->SetTextColor(0,0,0);
275
-
276
-				$tab_top = 50;
277
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
278
-				$tab_height = 170;
279
-				$tab_height_newpage = 190;
280
-
281
-				// Show public note
282
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
283
-				if ($notetoshow)
284
-				{
285
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
286
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
287
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288
-
289
-					$tab_top -= 2;
290
-
291
-					$pdf->SetFont('','', $default_font_size - 1);
292
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
293
-					$nexY = $pdf->GetY();
294
-					$height_note=$nexY-$tab_top;
295
-
296
-					// Rect prend une longueur en 3eme param
297
-					$pdf->SetDrawColor(192,192,192);
298
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
299
-
300
-					$tab_height = $tab_height - $height_note;
301
-					$tab_top = $nexY+6;
302
-				}
303
-				else
304
-				{
305
-					$height_note=0;
306
-				}
307
-
308
-				$heightoftitleline = 10;
309
-				$iniY = $tab_top + $heightoftitleline + 1;
310
-				$curY = $tab_top + $heightoftitleline + 1;
311
-				$nexY = $tab_top + $heightoftitleline + 1;
312
-
313
-				// Loop on each lines
314
-				for ($i = 0 ; $i < $nblignes ; $i++)
315
-				{
316
-					$curY = $nexY;
317
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
-					$pdf->SetTextColor(0,0,0);
319
-
320
-					$pdf->setTopMargin($tab_top_newpage);
321
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
-					$pageposbefore=$pdf->getPage();
323
-
324
-					// Description of line
325
-					$ref=$object->lines[$i]->ref;
326
-					$libelleline=$object->lines[$i]->label;
327
-					$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
-					$planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
331
-
332
-					$showpricebeforepagebreak=1;
333
-
334
-					$pdf->startTransaction();
335
-					// Label
336
-					$pdf->SetXY($this->posxlabel, $curY);
337
-					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
-					$pageposafter=$pdf->getPage();
339
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
340
-					{
341
-						$pdf->rollbackTransaction(true);
342
-						$pageposafter=$pageposbefore;
343
-						//print $pageposafter.'-'.$pageposbefore;exit;
344
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
345
-						// Label
346
-						$pdf->SetXY($this->posxlabel, $curY);
347
-						$posybefore=$pdf->GetY();
348
-						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
-						$pageposafter=$pdf->getPage();
350
-						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
352
-						{
353
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354
-							{
355
-								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
-								$pdf->setPage($pageposafter+1);
359
-							}
360
-						}
361
-						else
362
-						{
363
-							// We found a page break
364
-							$showpricebeforepagebreak=0;
365
-							$forcedesconsamepage=1;
366
-							if ($forcedesconsamepage)
367
-							{
368
-								$pdf->rollbackTransaction(true);
369
-								$pageposafter=$pageposbefore;
370
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
-
372
-								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
-								$pdf->setPage($pageposafter+1);
376
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
378
-								$pdf->SetTextColor(0,0,0);
379
-
380
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
381
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
382
-
383
-								// Label
384
-								$pdf->SetXY($this->posxlabel, $curY);
385
-								$posybefore=$pdf->GetY();
386
-								$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
-								$pageposafter=$pdf->getPage();
388
-								$posyafter=$pdf->GetY();
389
-							}
390
-						}
391
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
-					}
393
-					else	// No pagebreak
394
-					{
395
-						$pdf->commitTransaction();
396
-					}
397
-					$posYAfterDescription=$pdf->GetY();
398
-
399
-					$nexY = $pdf->GetY();
400
-					$pageposafter=$pdf->getPage();
401
-					$pdf->setPage($pageposbefore);
402
-					$pdf->setTopMargin($this->marge_haute);
403
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
404
-
405
-					// We suppose that a too long description is moved completely on next page
406
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
407
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
408
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409
-					}
410
-
411
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
412
-
413
-					// Ref of task
414
-					$pdf->SetXY($this->posxref, $curY);
415
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416
-					// Workload
417
-					$pdf->SetXY($this->posxworkload, $curY);
418
-					$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
419
-					// Progress
420
-					$pdf->SetXY($this->posxprogress, $curY);
421
-					$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
422
-					// Date
423
-					$pdf->SetXY($this->posxdatestart, $curY);
424
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
425
-					$pdf->SetXY($this->posxdateend, $curY);
426
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
427
-
428
-					// Add line
429
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430
-					{
431
-						$pdf->setPage($pageposafter);
432
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
433
-						//$pdf->SetDrawColor(190,190,200);
434
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
435
-						$pdf->SetLineStyle(array('dash'=>0));
436
-					}
437
-
438
-					$nexY+=2;    // Passe espace entre les lignes
439
-
440
-					// Detect if some page were added automatically and output _tableau for past pages
441
-					while ($pagenb < $pageposafter)
442
-					{
443
-						$pdf->setPage($pagenb);
444
-						if ($pagenb == 1)
445
-						{
446
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
-						}
448
-						else
449
-						{
450
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451
-						}
452
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
453
-						$pagenb++;
454
-						$pdf->setPage($pagenb);
455
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457
-					}
458
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459
-					{
460
-						if ($pagenb == 1)
461
-						{
462
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
-						}
464
-						else
465
-						{
466
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467
-						}
468
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
469
-						// New page
470
-						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-						$pagenb++;
473
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474
-					}
475
-				}
476
-
477
-				// Show square
478
-				if ($pagenb == 1)
479
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
-				else
481
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483
-
484
-				// Pied de page
485
-				$this->_pagefoot($pdf, $object, $outputlangs);
486
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
487
-
488
-				$pdf->Close();
489
-
490
-				$pdf->Output($file, 'F');
491
-
492
-				// Add pdfgeneration hook
493
-				$hookmanager->initHooks(array('pdfgeneration'));
494
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495
-				global $action;
496
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497
-
498
-				if (! empty($conf->global->MAIN_UMASK))
499
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
500
-
501
-				$this->result = array('fullpath'=>$file);
502
-
503
-				return 1;   // Pas d'erreur
504
-			}
505
-			else
506
-			{
507
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508
-				return 0;
509
-			}
510
-		}
511
-		else
512
-		{
513
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514
-			return 0;
515
-		}
516
-	}
517
-
518
-
519
-	/**
520
-	 *   Show table for lines
521
-	 *
522
-	 *   @param		PDF			$pdf     		Object PDF
523
-	 *   @param		string		$tab_top		Top position of table
524
-	 *   @param		string		$tab_height		Height of table (rectangle)
525
-	 *   @param		int			$nexY			Y
526
-	 *   @param		Translate	$outputlangs	Langs object
527
-	 *   @param		int			$hidetop		Hide top bar of array
528
-	 *   @param		int			$hidebottom		Hide bottom bar of array
529
-	 *   @return	void
530
-	 */
531
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
532
-	{
533
-		global $conf,$mysoc;
534
-
535
-		$heightoftitleline = 10;
536
-
537
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
538
-
539
-		$pdf->SetDrawColor(128,128,128);
540
-
541
-		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
543
-
544
-		// line prend une position y en 3eme param
545
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
546
-
547
-		$pdf->SetTextColor(0,0,0);
548
-		$pdf->SetFont('','', $default_font_size);
549
-
550
-		$pdf->SetXY($this->posxref, $tab_top+1);
551
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
552
-
553
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
554
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555
-
556
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
557
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558
-
559
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
560
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
561
-
562
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
563
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
564
-
565
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
566
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567
-	}
568
-
569
-	/**
570
-	 *  Show top header of page.
571
-	 *
572
-	 *  @param	PDF			$pdf     		Object PDF
573
-	 *  @param  Project		$object     	Object to show
574
-	 *  @param  int	    	$showaddress    0=no, 1=yes
575
-	 *  @param  Translate	$outputlangs	Object lang for output
576
-	 *  @return	void
577
-	 */
578
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579
-	{
580
-		global $langs,$conf,$mysoc;
581
-
582
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
242
+                // Complete object by loading several other informations
243
+                $task = new Task($this->db);
244
+                $tasksarray = $task->getTasksArray(0,0,$object->id);
245
+
246
+                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
247
+                {
248
+                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249
+                }
250
+
251
+                $object->lines=$tasksarray;
252
+                $nblignes=count($object->lines);
253
+
254
+                $pdf->Open();
255
+                $pagenb=0;
256
+                $pdf->SetDrawColor(128,128,128);
257
+
258
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259
+                $pdf->SetSubject($outputlangs->transnoentities("Project"));
260
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
261
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264
+
265
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266
+
267
+                // New page
268
+                $pdf->AddPage();
269
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
270
+                $pagenb++;
271
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
272
+                $pdf->SetFont('','', $default_font_size - 1);
273
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
274
+                $pdf->SetTextColor(0,0,0);
275
+
276
+                $tab_top = 50;
277
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
278
+                $tab_height = 170;
279
+                $tab_height_newpage = 190;
280
+
281
+                // Show public note
282
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
283
+                if ($notetoshow)
284
+                {
285
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
286
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
287
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288
+
289
+                    $tab_top -= 2;
583 290
 
584
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
585
-
586
-		$pdf->SetTextColor(0,0,60);
587
-		$pdf->SetFont('','B', $default_font_size + 3);
291
+                    $pdf->SetFont('','', $default_font_size - 1);
292
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
293
+                    $nexY = $pdf->GetY();
294
+                    $height_note=$nexY-$tab_top;
295
+
296
+                    // Rect prend une longueur en 3eme param
297
+                    $pdf->SetDrawColor(192,192,192);
298
+                    $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
299
+
300
+                    $tab_height = $tab_height - $height_note;
301
+                    $tab_top = $nexY+6;
302
+                }
303
+                else
304
+                {
305
+                    $height_note=0;
306
+                }
307
+
308
+                $heightoftitleline = 10;
309
+                $iniY = $tab_top + $heightoftitleline + 1;
310
+                $curY = $tab_top + $heightoftitleline + 1;
311
+                $nexY = $tab_top + $heightoftitleline + 1;
312
+
313
+                // Loop on each lines
314
+                for ($i = 0 ; $i < $nblignes ; $i++)
315
+                {
316
+                    $curY = $nexY;
317
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
+                    $pdf->SetTextColor(0,0,0);
319
+
320
+                    $pdf->setTopMargin($tab_top_newpage);
321
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
+                    $pageposbefore=$pdf->getPage();
323
+
324
+                    // Description of line
325
+                    $ref=$object->lines[$i]->ref;
326
+                    $libelleline=$object->lines[$i]->label;
327
+                    $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
+                    $datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
+                    $dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
+                    $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
331
+
332
+                    $showpricebeforepagebreak=1;
333
+
334
+                    $pdf->startTransaction();
335
+                    // Label
336
+                    $pdf->SetXY($this->posxlabel, $curY);
337
+                    $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
+                    $pageposafter=$pdf->getPage();
339
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
340
+                    {
341
+                        $pdf->rollbackTransaction(true);
342
+                        $pageposafter=$pageposbefore;
343
+                        //print $pageposafter.'-'.$pageposbefore;exit;
344
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
345
+                        // Label
346
+                        $pdf->SetXY($this->posxlabel, $curY);
347
+                        $posybefore=$pdf->GetY();
348
+                        $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
+                        $pageposafter=$pdf->getPage();
350
+                        $posyafter=$pdf->GetY();
351
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
352
+                        {
353
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354
+                            {
355
+                                $pdf->AddPage('','',true);
356
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
+                                $pdf->setPage($pageposafter+1);
359
+                            }
360
+                        }
361
+                        else
362
+                        {
363
+                            // We found a page break
364
+                            $showpricebeforepagebreak=0;
365
+                            $forcedesconsamepage=1;
366
+                            if ($forcedesconsamepage)
367
+                            {
368
+                                $pdf->rollbackTransaction(true);
369
+                                $pageposafter=$pageposbefore;
370
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
+
372
+                                $pdf->AddPage('','',true);
373
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
+                                $pdf->setPage($pageposafter+1);
376
+                                $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
+                                $pdf->MultiCell(0, 3, '');		// Set interline to 3
378
+                                $pdf->SetTextColor(0,0,0);
379
+
380
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
381
+                                $curY = $tab_top_newpage + $heightoftitleline + 1;
382
+
383
+                                // Label
384
+                                $pdf->SetXY($this->posxlabel, $curY);
385
+                                $posybefore=$pdf->GetY();
386
+                                $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
+                                $pageposafter=$pdf->getPage();
388
+                                $posyafter=$pdf->GetY();
389
+                            }
390
+                        }
391
+                        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
+                    }
393
+                    else	// No pagebreak
394
+                    {
395
+                        $pdf->commitTransaction();
396
+                    }
397
+                    $posYAfterDescription=$pdf->GetY();
398
+
399
+                    $nexY = $pdf->GetY();
400
+                    $pageposafter=$pdf->getPage();
401
+                    $pdf->setPage($pageposbefore);
402
+                    $pdf->setTopMargin($this->marge_haute);
403
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
404
+
405
+                    // We suppose that a too long description is moved completely on next page
406
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
407
+                        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
408
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409
+                    }
410
+
411
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
412
+
413
+                    // Ref of task
414
+                    $pdf->SetXY($this->posxref, $curY);
415
+                    $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416
+                    // Workload
417
+                    $pdf->SetXY($this->posxworkload, $curY);
418
+                    $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
419
+                    // Progress
420
+                    $pdf->SetXY($this->posxprogress, $curY);
421
+                    $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
422
+                    // Date
423
+                    $pdf->SetXY($this->posxdatestart, $curY);
424
+                    $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
425
+                    $pdf->SetXY($this->posxdateend, $curY);
426
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
427
+
428
+                    // Add line
429
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430
+                    {
431
+                        $pdf->setPage($pageposafter);
432
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
433
+                        //$pdf->SetDrawColor(190,190,200);
434
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
435
+                        $pdf->SetLineStyle(array('dash'=>0));
436
+                    }
437
+
438
+                    $nexY+=2;    // Passe espace entre les lignes
439
+
440
+                    // Detect if some page were added automatically and output _tableau for past pages
441
+                    while ($pagenb < $pageposafter)
442
+                    {
443
+                        $pdf->setPage($pagenb);
444
+                        if ($pagenb == 1)
445
+                        {
446
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
+                        }
448
+                        else
449
+                        {
450
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451
+                        }
452
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
453
+                        $pagenb++;
454
+                        $pdf->setPage($pagenb);
455
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457
+                    }
458
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459
+                    {
460
+                        if ($pagenb == 1)
461
+                        {
462
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
+                        }
464
+                        else
465
+                        {
466
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467
+                        }
468
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
469
+                        // New page
470
+                        $pdf->AddPage();
471
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
+                        $pagenb++;
473
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474
+                    }
475
+                }
476
+
477
+                // Show square
478
+                if ($pagenb == 1)
479
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
+                else
481
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483
+
484
+                // Pied de page
485
+                $this->_pagefoot($pdf, $object, $outputlangs);
486
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
487
+
488
+                $pdf->Close();
489
+
490
+                $pdf->Output($file, 'F');
491
+
492
+                // Add pdfgeneration hook
493
+                $hookmanager->initHooks(array('pdfgeneration'));
494
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495
+                global $action;
496
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497
+
498
+                if (! empty($conf->global->MAIN_UMASK))
499
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
500
+
501
+                $this->result = array('fullpath'=>$file);
502
+
503
+                return 1;   // Pas d'erreur
504
+            }
505
+            else
506
+            {
507
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508
+                return 0;
509
+            }
510
+        }
511
+        else
512
+        {
513
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514
+            return 0;
515
+        }
516
+    }
517
+
518
+
519
+    /**
520
+     *   Show table for lines
521
+     *
522
+     *   @param		PDF			$pdf     		Object PDF
523
+     *   @param		string		$tab_top		Top position of table
524
+     *   @param		string		$tab_height		Height of table (rectangle)
525
+     *   @param		int			$nexY			Y
526
+     *   @param		Translate	$outputlangs	Langs object
527
+     *   @param		int			$hidetop		Hide top bar of array
528
+     *   @param		int			$hidebottom		Hide bottom bar of array
529
+     *   @return	void
530
+     */
531
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
532
+    {
533
+        global $conf,$mysoc;
534
+
535
+        $heightoftitleline = 10;
536
+
537
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
538
+
539
+        $pdf->SetDrawColor(128,128,128);
540
+
541
+        // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
+        $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
543
+
544
+        // line prend une position y en 3eme param
545
+        $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
546
+
547
+        $pdf->SetTextColor(0,0,0);
548
+        $pdf->SetFont('','', $default_font_size);
549
+
550
+        $pdf->SetXY($this->posxref, $tab_top+1);
551
+        $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
552
+
553
+        $pdf->SetXY($this->posxlabel, $tab_top+1);
554
+        $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555
+
556
+        $pdf->SetXY($this->posxworkload, $tab_top+1);
557
+        $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558
+
559
+        $pdf->SetXY($this->posxprogress, $tab_top+1);
560
+        $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
561
+
562
+        $pdf->SetXY($this->posxdatestart, $tab_top+1);
563
+        $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
564
+
565
+        $pdf->SetXY($this->posxdateend, $tab_top+1);
566
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567
+    }
568
+
569
+    /**
570
+     *  Show top header of page.
571
+     *
572
+     *  @param	PDF			$pdf     		Object PDF
573
+     *  @param  Project		$object     	Object to show
574
+     *  @param  int	    	$showaddress    0=no, 1=yes
575
+     *  @param  Translate	$outputlangs	Object lang for output
576
+     *  @return	void
577
+     */
578
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579
+    {
580
+        global $langs,$conf,$mysoc;
581
+
582
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
583
+
584
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
585
+
586
+        $pdf->SetTextColor(0,0,60);
587
+        $pdf->SetFont('','B', $default_font_size + 3);
588 588
 
589 589
         $posx=$this->page_largeur-$this->marge_droite-100;
590
-		$posy=$this->marge_haute;
591
-
592
-		$pdf->SetXY($this->marge_gauche,$posy);
593
-
594
-		// Logo
595
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596
-		if ($mysoc->logo)
597
-		{
598
-			if (is_readable($logo))
599
-			{
600
-			    $height=pdf_getHeightForLogo($logo);
601
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
-			}
603
-			else
604
-			{
605
-				$pdf->SetTextColor(200,0,0);
606
-				$pdf->SetFont('','B', $default_font_size - 2);
607
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609
-			}
610
-		}
611
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612
-
613
-		$pdf->SetFont('','B', $default_font_size + 3);
614
-		$pdf->SetXY($posx,$posy);
615
-		$pdf->SetTextColor(0,0,60);
616
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
-		$pdf->SetFont('','', $default_font_size + 2);
618
-
619
-		$posy+=6;
620
-		$pdf->SetXY($posx,$posy);
621
-		$pdf->SetTextColor(0,0,60);
622
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
623
-
624
-		$posy+=6;
625
-		$pdf->SetXY($posx,$posy);
626
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
627
-
628
-		if (is_object($object->thirdparty))
629
-		{
630
-			$posy+=6;
631
-			$pdf->SetXY($posx,$posy);
632
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
633
-		}
634
-
635
-		$pdf->SetTextColor(0,0,60);
636
-
637
-		// Add list of linked objects
638
-		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
590
+        $posy=$this->marge_haute;
591
+
592
+        $pdf->SetXY($this->marge_gauche,$posy);
593
+
594
+        // Logo
595
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596
+        if ($mysoc->logo)
597
+        {
598
+            if (is_readable($logo))
599
+            {
600
+                $height=pdf_getHeightForLogo($logo);
601
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
+            }
603
+            else
604
+            {
605
+                $pdf->SetTextColor(200,0,0);
606
+                $pdf->SetFont('','B', $default_font_size - 2);
607
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609
+            }
610
+        }
611
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612
+
613
+        $pdf->SetFont('','B', $default_font_size + 3);
614
+        $pdf->SetXY($posx,$posy);
615
+        $pdf->SetTextColor(0,0,60);
616
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
+        $pdf->SetFont('','', $default_font_size + 2);
618
+
619
+        $posy+=6;
620
+        $pdf->SetXY($posx,$posy);
621
+        $pdf->SetTextColor(0,0,60);
622
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
623
+
624
+        $posy+=6;
625
+        $pdf->SetXY($posx,$posy);
626
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
627
+
628
+        if (is_object($object->thirdparty))
629
+        {
630
+            $posy+=6;
631
+            $pdf->SetXY($posx,$posy);
632
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
633
+        }
634
+
635
+        $pdf->SetTextColor(0,0,60);
636
+
637
+        // Add list of linked objects
638
+        /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
639 639
 		$object->fetchObjectLinked();
640 640
 
641 641
 	    foreach($object->linkedObjects as $objecttype => $objects)
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
 	    	}
658 658
 	    }
659 659
         */
660
-	}
660
+    }
661 661
 
662
-	/**
663
-	 *   	Show footer of page. Need this->emetteur object
662
+    /**
663
+     *   	Show footer of page. Need this->emetteur object
664 664
      *
665
-	 *   	@param	PDF			$pdf     			PDF
666
-	 * 		@param	Project		$object				Object to show
667
-	 *      @param	Translate	$outputlangs		Object lang for output
668
-	 *      @param	int			$hidefreetext		1=Hide free text
669
-	 *      @return	integer
670
-	 */
671
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
672
-	{
673
-		global $conf;
674
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
676
-	}
665
+     *   	@param	PDF			$pdf     			PDF
666
+     * 		@param	Project		$object				Object to show
667
+     *      @param	Translate	$outputlangs		Object lang for output
668
+     *      @param	int			$hidefreetext		1=Hide free text
669
+     *      @return	integer
670
+     */
671
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
672
+    {
673
+        global $conf;
674
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
+        return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
676
+    }
677 677
 }
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	function __construct($db)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		// Translations
124 124
 		$langs->loadLangs(array("main", "projects", "companies"));
@@ -129,38 +129,38 @@  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 FAC_PDF_LOGO
142
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
141
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
142
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
143
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
144 144
 
145 145
 		// Recupere emmetteur
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
 		// Defini position des colonnes
150
-		$this->posxref=$this->marge_gauche+1;
151
-		$this->posxlabel=$this->marge_gauche+25;
152
-		$this->posxworkload=$this->marge_gauche+120;
153
-		$this->posxprogress=$this->marge_gauche+140;
154
-		$this->posxdatestart=$this->marge_gauche+152;
155
-		$this->posxdateend=$this->marge_gauche+170;
150
+		$this->posxref = $this->marge_gauche + 1;
151
+		$this->posxlabel = $this->marge_gauche + 25;
152
+		$this->posxworkload = $this->marge_gauche + 120;
153
+		$this->posxprogress = $this->marge_gauche + 140;
154
+		$this->posxdatestart = $this->marge_gauche + 152;
155
+		$this->posxdateend = $this->marge_gauche + 170;
156 156
 		if ($this->page_largeur < 210) // To work with US executive format
157 157
 		{
158
-			$this->posxref-=20;
159
-			$this->posxlabel-=20;
160
-			$this->posxworkload-=20;
161
-			$this->posxprogress-=20;
162
-			$this->posxdatestart-=20;
163
-			$this->posxdateend-=20;
158
+			$this->posxref -= 20;
159
+			$this->posxlabel -= 20;
160
+			$this->posxworkload -= 20;
161
+			$this->posxprogress -= 20;
162
+			$this->posxdatestart -= 20;
163
+			$this->posxdateend -= 20;
164 164
 		}
165 165
 	}
166 166
 
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 	 *	@param	Translate	$outputlangs	Lang output object
174 174
 	 *	@return	int         				1 if OK, <=0 if KO
175 175
 	 */
176
-	function write_file($object,$outputlangs)
176
+	function write_file($object, $outputlangs)
177 177
 	{
178 178
         // phpcs:enable
179 179
 		global $conf, $hookmanager, $langs, $user;
180 180
 
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
181
+		if (!is_object($outputlangs)) $outputlangs = $langs;
182 182
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
183
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
184 184
 
185 185
 		// Load traductions files requiredby by page
186 186
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 
192 192
 			$objectref = dol_sanitizeFileName($object->ref);
193 193
 			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
-			$file = $dir . "/" . $objectref . ".pdf";
194
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
195
+			$file = $dir."/".$objectref.".pdf";
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
 				// Create pdf instance
220
-				$pdf=pdf_getInstance($this->format);
221
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
-				$pdf->SetAutoPageBreak(1,0);
220
+				$pdf = pdf_getInstance($this->format);
221
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
222
+				$pdf->SetAutoPageBreak(1, 0);
223 223
 
224
-				$heightforinfotot = 40;	// 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
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
224
+				$heightforinfotot = 40; // 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
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -233,7 +233,7 @@  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_ADD_PDF_BACKGROUND))
236
+                if (!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);
@@ -241,68 +241,68 @@  discard block
 block discarded – undo
241 241
 
242 242
 				// Complete object by loading several other informations
243 243
 				$task = new Task($this->db);
244
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
244
+				$tasksarray = $task->getTasksArray(0, 0, $object->id);
245 245
 
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
246
+				if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
247 247
 				{
248
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
248
+					$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
249 249
 				}
250 250
 
251
-				$object->lines=$tasksarray;
252
-				$nblignes=count($object->lines);
251
+				$object->lines = $tasksarray;
252
+				$nblignes = count($object->lines);
253 253
 
254 254
 				$pdf->Open();
255
-				$pagenb=0;
256
-				$pdf->SetDrawColor(128,128,128);
255
+				$pagenb = 0;
256
+				$pdf->SetDrawColor(128, 128, 128);
257 257
 
258 258
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259 259
 				$pdf->SetSubject($outputlangs->transnoentities("Project"));
260 260
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261 261
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262 262
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
263
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264 264
 
265
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
265
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
266 266
 
267 267
 				// New page
268 268
 				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
269
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
270 270
 				$pagenb++;
271 271
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
272
-				$pdf->SetFont('','', $default_font_size - 1);
273
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
274
-				$pdf->SetTextColor(0,0,0);
272
+				$pdf->SetFont('', '', $default_font_size - 1);
273
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
274
+				$pdf->SetTextColor(0, 0, 0);
275 275
 
276 276
 				$tab_top = 50;
277
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
277
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
278 278
 				$tab_height = 170;
279 279
 				$tab_height_newpage = 190;
280 280
 
281 281
 				// Show public note
282
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
282
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
283 283
 				if ($notetoshow)
284 284
 				{
285
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
285
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
286 286
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
287 287
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288 288
 
289 289
 					$tab_top -= 2;
290 290
 
291
-					$pdf->SetFont('','', $default_font_size - 1);
292
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
291
+					$pdf->SetFont('', '', $default_font_size - 1);
292
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
293 293
 					$nexY = $pdf->GetY();
294
-					$height_note=$nexY-$tab_top;
294
+					$height_note = $nexY - $tab_top;
295 295
 
296 296
 					// Rect prend une longueur en 3eme param
297
-					$pdf->SetDrawColor(192,192,192);
298
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
297
+					$pdf->SetDrawColor(192, 192, 192);
298
+					$pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2);
299 299
 
300 300
 					$tab_height = $tab_height - $height_note;
301
-					$tab_top = $nexY+6;
301
+					$tab_top = $nexY + 6;
302 302
 				}
303 303
 				else
304 304
 				{
305
-					$height_note=0;
305
+					$height_note = 0;
306 306
 				}
307 307
 
308 308
 				$heightoftitleline = 10;
@@ -311,81 +311,81 @@  discard block
 block discarded – undo
311 311
 				$nexY = $tab_top + $heightoftitleline + 1;
312 312
 
313 313
 				// Loop on each lines
314
-				for ($i = 0 ; $i < $nblignes ; $i++)
314
+				for ($i = 0; $i < $nblignes; $i++)
315 315
 				{
316 316
 					$curY = $nexY;
317
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
-					$pdf->SetTextColor(0,0,0);
317
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
318
+					$pdf->SetTextColor(0, 0, 0);
319 319
 
320 320
 					$pdf->setTopMargin($tab_top_newpage);
321
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
-					$pageposbefore=$pdf->getPage();
321
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
322
+					$pageposbefore = $pdf->getPage();
323 323
 
324 324
 					// Description of line
325
-					$ref=$object->lines[$i]->ref;
326
-					$libelleline=$object->lines[$i]->label;
327
-					$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
-					$planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
325
+					$ref = $object->lines[$i]->ref;
326
+					$libelleline = $object->lines[$i]->label;
327
+					$progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
328
+					$datestart = dol_print_date($object->lines[$i]->date_start, 'day');
329
+					$dateend = dol_print_date($object->lines[$i]->date_end, 'day');
330
+					$planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
331 331
 
332
-					$showpricebeforepagebreak=1;
332
+					$showpricebeforepagebreak = 1;
333 333
 
334 334
 					$pdf->startTransaction();
335 335
 					// Label
336 336
 					$pdf->SetXY($this->posxlabel, $curY);
337
-					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
-					$pageposafter=$pdf->getPage();
337
+					$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
+					$pageposafter = $pdf->getPage();
339 339
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
340 340
 					{
341 341
 						$pdf->rollbackTransaction(true);
342
-						$pageposafter=$pageposbefore;
342
+						$pageposafter = $pageposbefore;
343 343
 						//print $pageposafter.'-'.$pageposbefore;exit;
344
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
344
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
345 345
 						// Label
346 346
 						$pdf->SetXY($this->posxlabel, $curY);
347
-						$posybefore=$pdf->GetY();
348
-						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
-						$pageposafter=$pdf->getPage();
350
-						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
347
+						$posybefore = $pdf->GetY();
348
+						$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
+						$pageposafter = $pdf->getPage();
350
+						$posyafter = $pdf->GetY();
351
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
352 352
 						{
353
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
353
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
354 354
 							{
355
-								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
+								$pdf->AddPage('', '', true);
356
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
357 357
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
-								$pdf->setPage($pageposafter+1);
358
+								$pdf->setPage($pageposafter + 1);
359 359
 							}
360 360
 						}
361 361
 						else
362 362
 						{
363 363
 							// We found a page break
364
-							$showpricebeforepagebreak=0;
365
-							$forcedesconsamepage=1;
364
+							$showpricebeforepagebreak = 0;
365
+							$forcedesconsamepage = 1;
366 366
 							if ($forcedesconsamepage)
367 367
 							{
368 368
 								$pdf->rollbackTransaction(true);
369
-								$pageposafter=$pageposbefore;
370
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
369
+								$pageposafter = $pageposbefore;
370
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371 371
 
372
-								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
372
+								$pdf->AddPage('', '', true);
373
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
374 374
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
-								$pdf->setPage($pageposafter+1);
376
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
378
-								$pdf->SetTextColor(0,0,0);
375
+								$pdf->setPage($pageposafter + 1);
376
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
377
+								$pdf->MultiCell(0, 3, ''); // Set interline to 3
378
+								$pdf->SetTextColor(0, 0, 0);
379 379
 
380
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
380
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
381 381
 								$curY = $tab_top_newpage + $heightoftitleline + 1;
382 382
 
383 383
 								// Label
384 384
 								$pdf->SetXY($this->posxlabel, $curY);
385
-								$posybefore=$pdf->GetY();
386
-								$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
-								$pageposafter=$pdf->getPage();
388
-								$posyafter=$pdf->GetY();
385
+								$posybefore = $pdf->GetY();
386
+								$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
+								$pageposafter = $pdf->getPage();
388
+								$posyafter = $pdf->GetY();
389 389
 							}
390 390
 						}
391 391
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 					{
395 395
 						$pdf->commitTransaction();
396 396
 					}
397
-					$posYAfterDescription=$pdf->GetY();
397
+					$posYAfterDescription = $pdf->GetY();
398 398
 
399 399
 					$nexY = $pdf->GetY();
400
-					$pageposafter=$pdf->getPage();
400
+					$pageposafter = $pdf->getPage();
401 401
 					$pdf->setPage($pageposbefore);
402 402
 					$pdf->setTopMargin($this->marge_haute);
403
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
403
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
404 404
 
405 405
 					// We suppose that a too long description is moved completely on next page
406 406
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -408,34 +408,34 @@  discard block
 block discarded – undo
408 408
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409 409
 					}
410 410
 
411
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
411
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
412 412
 
413 413
 					// Ref of task
414 414
 					$pdf->SetXY($this->posxref, $curY);
415
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
415
+					$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416 416
 					// Workload
417 417
 					$pdf->SetXY($this->posxworkload, $curY);
418
-					$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
418
+					$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
419 419
 					// Progress
420 420
 					$pdf->SetXY($this->posxprogress, $curY);
421
-					$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
421
+					$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
422 422
 					// Date
423 423
 					$pdf->SetXY($this->posxdatestart, $curY);
424
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
424
+					$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
425 425
 					$pdf->SetXY($this->posxdateend, $curY);
426
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
426
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
427 427
 
428 428
 					// Add line
429
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
429
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430 430
 					{
431 431
 						$pdf->setPage($pageposafter);
432
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
432
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
433 433
 						//$pdf->SetDrawColor(190,190,200);
434
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
434
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
435 435
 						$pdf->SetLineStyle(array('dash'=>0));
436 436
 					}
437 437
 
438
-					$nexY+=2;    // Passe espace entre les lignes
438
+					$nexY += 2; // Passe espace entre les lignes
439 439
 
440 440
 					// Detect if some page were added automatically and output _tableau for past pages
441 441
 					while ($pagenb < $pageposafter)
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 						{
450 450
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451 451
 						}
452
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
452
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
453 453
 						$pagenb++;
454 454
 						$pdf->setPage($pagenb);
455
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
455
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
456 456
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457 457
 					}
458
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
458
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
459 459
 					{
460 460
 						if ($pagenb == 1)
461 461
 						{
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 						{
466 466
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467 467
 						}
468
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
468
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
469 469
 						// New page
470 470
 						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
471
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
472 472
 						$pagenb++;
473 473
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474 474
 					}
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480 480
 				else
481 481
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
482
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 483
 
484 484
 				// Pied de page
485 485
 				$this->_pagefoot($pdf, $object, $outputlangs);
@@ -491,26 +491,26 @@  discard block
 block discarded – undo
491 491
 
492 492
 				// Add pdfgeneration hook
493 493
 				$hookmanager->initHooks(array('pdfgeneration'));
494
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
494
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495 495
 				global $action;
496
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
496
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
497 497
 
498
-				if (! empty($conf->global->MAIN_UMASK))
498
+				if (!empty($conf->global->MAIN_UMASK))
499 499
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
500 500
 
501 501
 				$this->result = array('fullpath'=>$file);
502 502
 
503
-				return 1;   // Pas d'erreur
503
+				return 1; // Pas d'erreur
504 504
 			}
505 505
 			else
506 506
 			{
507
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
507
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
508 508
 				return 0;
509 509
 			}
510 510
 		}
511 511
 		else
512 512
 		{
513
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
513
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
514 514
 			return 0;
515 515
 		}
516 516
 	}
@@ -528,41 +528,41 @@  discard block
 block discarded – undo
528 528
 	 *   @param		int			$hidebottom		Hide bottom bar of array
529 529
 	 *   @return	void
530 530
 	 */
531
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
531
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
532 532
 	{
533
-		global $conf,$mysoc;
533
+		global $conf, $mysoc;
534 534
 
535 535
 		$heightoftitleline = 10;
536 536
 
537 537
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
538 538
 
539
-		$pdf->SetDrawColor(128,128,128);
539
+		$pdf->SetDrawColor(128, 128, 128);
540 540
 
541 541
 		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
542
+		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
543 543
 
544 544
 		// line prend une position y en 3eme param
545
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
545
+		$pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
546 546
 
547
-		$pdf->SetTextColor(0,0,0);
548
-		$pdf->SetFont('','', $default_font_size);
547
+		$pdf->SetTextColor(0, 0, 0);
548
+		$pdf->SetFont('', '', $default_font_size);
549 549
 
550
-		$pdf->SetXY($this->posxref, $tab_top+1);
551
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
550
+		$pdf->SetXY($this->posxref, $tab_top + 1);
551
+		$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
552 552
 
553
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
554
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
553
+		$pdf->SetXY($this->posxlabel, $tab_top + 1);
554
+		$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555 555
 
556
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
557
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
556
+		$pdf->SetXY($this->posxworkload, $tab_top + 1);
557
+		$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558 558
 
559
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
560
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
559
+		$pdf->SetXY($this->posxprogress, $tab_top + 1);
560
+		$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
561 561
 
562
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
563
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
562
+		$pdf->SetXY($this->posxdatestart, $tab_top + 1);
563
+		$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C');
564 564
 
565
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
565
+		$pdf->SetXY($this->posxdateend, $tab_top + 1);
566 566
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567 567
 	}
568 568
 
@@ -577,62 +577,62 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579 579
 	{
580
-		global $langs,$conf,$mysoc;
580
+		global $langs, $conf, $mysoc;
581 581
 
582 582
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
583 583
 
584
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
584
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
585 585
 
586
-		$pdf->SetTextColor(0,0,60);
587
-		$pdf->SetFont('','B', $default_font_size + 3);
586
+		$pdf->SetTextColor(0, 0, 60);
587
+		$pdf->SetFont('', 'B', $default_font_size + 3);
588 588
 
589
-        $posx=$this->page_largeur-$this->marge_droite-100;
590
-		$posy=$this->marge_haute;
589
+        $posx = $this->page_largeur - $this->marge_droite - 100;
590
+		$posy = $this->marge_haute;
591 591
 
592
-		$pdf->SetXY($this->marge_gauche,$posy);
592
+		$pdf->SetXY($this->marge_gauche, $posy);
593 593
 
594 594
 		// Logo
595
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
595
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596 596
 		if ($mysoc->logo)
597 597
 		{
598 598
 			if (is_readable($logo))
599 599
 			{
600
-			    $height=pdf_getHeightForLogo($logo);
601
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
600
+			    $height = pdf_getHeightForLogo($logo);
601
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
602 602
 			}
603 603
 			else
604 604
 			{
605
-				$pdf->SetTextColor(200,0,0);
606
-				$pdf->SetFont('','B', $default_font_size - 2);
607
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
605
+				$pdf->SetTextColor(200, 0, 0);
606
+				$pdf->SetFont('', 'B', $default_font_size - 2);
607
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
608 608
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609 609
 			}
610 610
 		}
611 611
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 612
 
613
-		$pdf->SetFont('','B', $default_font_size + 3);
614
-		$pdf->SetXY($posx,$posy);
615
-		$pdf->SetTextColor(0,0,60);
613
+		$pdf->SetFont('', 'B', $default_font_size + 3);
614
+		$pdf->SetXY($posx, $posy);
615
+		$pdf->SetTextColor(0, 0, 60);
616 616
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
-		$pdf->SetFont('','', $default_font_size + 2);
617
+		$pdf->SetFont('', '', $default_font_size + 2);
618 618
 
619
-		$posy+=6;
620
-		$pdf->SetXY($posx,$posy);
621
-		$pdf->SetTextColor(0,0,60);
622
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
619
+		$posy += 6;
620
+		$pdf->SetXY($posx, $posy);
621
+		$pdf->SetTextColor(0, 0, 60);
622
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
623 623
 
624
-		$posy+=6;
625
-		$pdf->SetXY($posx,$posy);
626
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
624
+		$posy += 6;
625
+		$pdf->SetXY($posx, $posy);
626
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
627 627
 
628 628
 		if (is_object($object->thirdparty))
629 629
 		{
630
-			$posy+=6;
631
-			$pdf->SetXY($posx,$posy);
632
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
630
+			$posy += 6;
631
+			$pdf->SetXY($posx, $posy);
632
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
633 633
 		}
634 634
 
635
-		$pdf->SetTextColor(0,0,60);
635
+		$pdf->SetTextColor(0, 0, 60);
636 636
 
637 637
 		// Add list of linked objects
638 638
 		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
 	 *      @param	int			$hidefreetext		1=Hide free text
669 669
 	 *      @return	integer
670 670
 	 */
671
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
671
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
672 672
 	{
673 673
 		global $conf;
674
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
674
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
676 676
 	}
677 677
 }
Please login to merge, or discard this patch.
Braces   +76 added lines, -42 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere emmetteur
146 146
 		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
147
+		if (! $this->emetteur->country_code) {
148
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
149
+		}
150
+		// By default if not defined
148 151
 
149 152
 		// Defini position des colonnes
150 153
 		$this->posxref=$this->marge_gauche+1;
@@ -153,9 +156,11 @@  discard block
 block discarded – undo
153 156
 		$this->posxprogress=$this->marge_gauche+140;
154 157
 		$this->posxdatestart=$this->marge_gauche+152;
155 158
 		$this->posxdateend=$this->marge_gauche+170;
156
-		if ($this->page_largeur < 210) // To work with US executive format
159
+		if ($this->page_largeur < 210) {
160
+		    // To work with US executive format
157 161
 		{
158 162
 			$this->posxref-=20;
163
+		}
159 164
 			$this->posxlabel-=20;
160 165
 			$this->posxworkload-=20;
161 166
 			$this->posxprogress-=20;
@@ -178,9 +183,13 @@  discard block
 block discarded – undo
178 183
         // phpcs:enable
179 184
 		global $conf, $hookmanager, $langs, $user;
180 185
 
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
186
+		if (! is_object($outputlangs)) {
187
+		    $outputlangs=$langs;
188
+		}
182 189
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
190
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
191
+		    $outputlangs->charset_output='ISO-8859-1';
192
+		}
184 193
 
185 194
 		// Load traductions files requiredby by page
186 195
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -191,7 +200,9 @@  discard block
 block discarded – undo
191 200
 
192 201
 			$objectref = dol_sanitizeFileName($object->ref);
193 202
 			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
203
+			if (! preg_match('/specimen/i',$objectref)) {
204
+			    $dir.= "/" . $objectref;
205
+			}
195 206
 			$file = $dir . "/" . $objectref . ".pdf";
196 207
 
197 208
 			if (! file_exists($dir))
@@ -224,7 +235,9 @@  discard block
 block discarded – undo
224 235
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
225 236
 		        $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 237
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
238
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
239
+	                $heightforfooter+= 6;
240
+	            }
228 241
 
229 242
                 if (class_exists('TCPDF'))
230 243
                 {
@@ -243,10 +256,12 @@  discard block
 block discarded – undo
243 256
 				$task = new Task($this->db);
244 257
 				$tasksarray = $task->getTasksArray(0,0,$object->id);
245 258
 
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
259
+				if (! $object->id > 0) {
260
+				    // Special case when used with object = specimen, we may return all lines
247 261
 				{
248 262
 					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249 263
 				}
264
+				}
250 265
 
251 266
 				$object->lines=$tasksarray;
252 267
 				$nblignes=count($object->lines);
@@ -260,13 +275,17 @@  discard block
 block discarded – undo
260 275
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261 276
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262 277
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
278
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
279
+				    $pdf->SetCompression(false);
280
+				}
264 281
 
265 282
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266 283
 
267 284
 				// New page
268 285
 				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
286
+				if (! empty($tplidx)) {
287
+				    $pdf->useTemplate($tplidx);
288
+				}
270 289
 				$pagenb++;
271 290
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
272 291
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -299,8 +318,7 @@  discard block
 block discarded – undo
299 318
 
300 319
 					$tab_height = $tab_height - $height_note;
301 320
 					$tab_top = $nexY+6;
302
-				}
303
-				else
321
+				} else
304 322
 				{
305 323
 					$height_note=0;
306 324
 				}
@@ -336,9 +354,11 @@  discard block
 block discarded – undo
336 354
 					$pdf->SetXY($this->posxlabel, $curY);
337 355
 					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338 356
 					$pageposafter=$pdf->getPage();
339
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
357
+					if ($pageposafter > $pageposbefore) {
358
+					    // There is a pagebreak
340 359
 					{
341 360
 						$pdf->rollbackTransaction(true);
361
+					}
342 362
 						$pageposafter=$pageposbefore;
343 363
 						//print $pageposafter.'-'.$pageposbefore;exit;
344 364
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -348,17 +368,22 @@  discard block
 block discarded – undo
348 368
 						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349 369
 						$pageposafter=$pdf->getPage();
350 370
 						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
371
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
372
+						    // There is no space left for total+free text
352 373
 						{
353 374
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354 375
 							{
355 376
 								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
377
+						}
378
+								if (! empty($tplidx)) {
379
+								    $pdf->useTemplate($tplidx);
380
+								}
381
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
382
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
383
+								}
358 384
 								$pdf->setPage($pageposafter+1);
359 385
 							}
360
-						}
361
-						else
386
+						} else
362 387
 						{
363 388
 							// We found a page break
364 389
 							$showpricebeforepagebreak=0;
@@ -370,8 +395,12 @@  discard block
 block discarded – undo
370 395
 								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371 396
 
372 397
 								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
398
+								if (! empty($tplidx)) {
399
+								    $pdf->useTemplate($tplidx);
400
+								}
401
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
402
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
403
+								}
375 404
 								$pdf->setPage($pageposafter+1);
376 405
 								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377 406
 								$pdf->MultiCell(0, 3, '');		// Set interline to 3
@@ -389,8 +418,7 @@  discard block
 block discarded – undo
389 418
 							}
390 419
 						}
391 420
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
-					}
393
-					else	// No pagebreak
421
+					} else	// No pagebreak
394 422
 					{
395 423
 						$pdf->commitTransaction();
396 424
 					}
@@ -444,8 +472,7 @@  discard block
 block discarded – undo
444 472
 						if ($pagenb == 1)
445 473
 						{
446 474
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
-						}
448
-						else
475
+						} else
449 476
 						{
450 477
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451 478
 						}
@@ -453,37 +480,45 @@  discard block
 block discarded – undo
453 480
 						$pagenb++;
454 481
 						$pdf->setPage($pagenb);
455 482
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
483
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
484
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
485
+						}
457 486
 					}
458 487
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459 488
 					{
460 489
 						if ($pagenb == 1)
461 490
 						{
462 491
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
-						}
464
-						else
492
+						} else
465 493
 						{
466 494
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467 495
 						}
468 496
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
469 497
 						// New page
470 498
 						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
499
+						if (! empty($tplidx)) {
500
+						    $pdf->useTemplate($tplidx);
501
+						}
472 502
 						$pagenb++;
473
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
503
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
504
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
505
+						}
474 506
 					}
475 507
 				}
476 508
 
477 509
 				// Show square
478
-				if ($pagenb == 1)
479
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
-				else
481
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
510
+				if ($pagenb == 1) {
511
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
512
+				} else {
513
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
514
+				}
482 515
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 516
 
484 517
 				// Pied de page
485 518
 				$this->_pagefoot($pdf, $object, $outputlangs);
486
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
519
+				if (method_exists($pdf, 'AliasNbPages')) {
520
+				    $pdf->AliasNbPages();
521
+				}
487 522
 
488 523
 				$pdf->Close();
489 524
 
@@ -495,20 +530,19 @@  discard block
 block discarded – undo
495 530
 				global $action;
496 531
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497 532
 
498
-				if (! empty($conf->global->MAIN_UMASK))
499
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
533
+				if (! empty($conf->global->MAIN_UMASK)) {
534
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
535
+				}
500 536
 
501 537
 				$this->result = array('fullpath'=>$file);
502 538
 
503 539
 				return 1;   // Pas d'erreur
504
-			}
505
-			else
540
+			} else
506 541
 			{
507 542
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508 543
 				return 0;
509 544
 			}
510
-		}
511
-		else
545
+		} else
512 546
 		{
513 547
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514 548
 			return 0;
@@ -599,16 +633,16 @@  discard block
 block discarded – undo
599 633
 			{
600 634
 			    $height=pdf_getHeightForLogo($logo);
601 635
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
-			}
603
-			else
636
+			} else
604 637
 			{
605 638
 				$pdf->SetTextColor(200,0,0);
606 639
 				$pdf->SetFont('','B', $default_font_size - 2);
607 640
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608 641
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609 642
 			}
643
+		} else {
644
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
610 645
 		}
611
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 646
 
613 647
 		$pdf->SetFont('','B', $default_font_size + 3);
614 648
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.