Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/propale/doc/pdf_azur.modules.php 3 patches
Indentation   +1446 added lines, -1446 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class pdf_azur extends ModelePDFPropales
43 43
 {
44
-	/**
44
+    /**
45 45
      * @var DoliDb Database handler
46 46
      */
47 47
     public $db;
48 48
 
49
-	/**
49
+    /**
50 50
      * @var string model name
51 51
      */
52 52
     public $name;
53 53
 
54
-	/**
54
+    /**
55 55
      * @var string model description (short text)
56 56
      */
57 57
     public $description;
@@ -59,151 +59,151 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @var string Save the name of generated file as the main doc when generating a doc with this template
61 61
      */
62
-	public $update_main_doc_field;
62
+    public $update_main_doc_field;
63 63
 
64
-	/**
64
+    /**
65 65
      * @var string document type
66 66
      */
67 67
     public $type;
68 68
 
69 69
     /**
70 70
      * @var array() Minimum version of PHP required by module.
71
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
71
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
72 72
      */
73
-	public $phpmin = array(5, 4);
73
+    public $phpmin = array(5, 4);
74 74
 
75
-	/**
75
+    /**
76 76
      * Dolibarr version of the loaded document
77 77
      * @public string
78 78
      */
79
-	public $version = 'dolibarr';
79
+    public $version = 'dolibarr';
80 80
 
81
-	/**
81
+    /**
82 82
      * @var int page_largeur
83 83
      */
84 84
     public $page_largeur;
85 85
 
86
-	/**
86
+    /**
87 87
      * @var int page_hauteur
88 88
      */
89 89
     public $page_hauteur;
90 90
 
91
-	/**
91
+    /**
92 92
      * @var array format
93 93
      */
94 94
     public $format;
95 95
 
96
-	/**
96
+    /**
97 97
      * @var int marge_gauche
98 98
      */
99
-	public $marge_gauche;
99
+    public $marge_gauche;
100 100
 
101
-	/**
101
+    /**
102 102
      * @var int marge_droite
103 103
      */
104
-	public $marge_droite;
104
+    public $marge_droite;
105 105
 
106
-	/**
106
+    /**
107 107
      * @var int marge_haute
108 108
      */
109
-	public $marge_haute;
109
+    public $marge_haute;
110 110
 
111
-	/**
111
+    /**
112 112
      * @var int marge_basse
113 113
      */
114
-	public $marge_basse;
115
-
116
-	/**
117
-	 * Issuer
118
-	 * @var Company object that emits
119
-	 */
120
-	public $emetteur;
121
-
122
-
123
-	/**
124
-	 *	Constructor
125
-	 *
126
-	 *  @param		DoliDB		$db      Database handler
127
-	 */
128
-	function __construct($db)
129
-	{
130
-		global $conf,$langs,$mysoc;
131
-
132
-		// Translations
133
-		$langs->loadLangs(array("main", "bills"));
134
-
135
-		$this->db = $db;
136
-		$this->name = "azur";
137
-		$this->description = $langs->trans('DocModelAzurDescription');
138
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
139
-
140
-		// Dimension page
141
-		$this->type = 'pdf';
142
-		$formatarray=pdf_getFormat();
143
-		$this->page_largeur = $formatarray['width'];
144
-		$this->page_hauteur = $formatarray['height'];
145
-		$this->format = array($this->page_largeur,$this->page_hauteur);
146
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
147
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
148
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
149
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
150
-
151
-		$this->option_logo = 1;                    // Affiche logo
152
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
153
-		$this->option_modereg = 1;                 // Affiche mode reglement
154
-		$this->option_condreg = 1;                 // Affiche conditions reglement
155
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
156
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
157
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
158
-		$this->option_credit_note = 0;             // Support credit notes
159
-		$this->option_freetext = 1;				   // Support add of a personalised text
160
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
161
-
162
-		$this->franchise=!$mysoc->tva_assuj;
163
-
164
-		// Get source company
165
-		$this->emetteur=$mysoc;
166
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
167
-
168
-		// Define position of columns
169
-		$this->posxdesc=$this->marge_gauche+1;
170
-		if($conf->global->PRODUCT_USE_UNITS)
171
-		{
172
-			$this->posxtva=101;
173
-			$this->posxup=118;
174
-			$this->posxqty=135;
175
-			$this->posxunit=151;
176
-		}
177
-		else
178
-		{
179
-			$this->posxtva=110;
180
-			$this->posxup=126;
181
-			$this->posxqty=145;
182
-		}
183
-		$this->posxdiscount=162;
184
-		$this->postotalht=174;
185
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
186
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
187
-		if ($this->page_largeur < 210) // To work with US executive format
188
-		{
189
-			$this->posxpicture-=20;
190
-			$this->posxtva-=20;
191
-			$this->posxup-=20;
192
-			$this->posxqty-=20;
193
-			$this->posxunit-=20;
194
-			$this->posxdiscount-=20;
195
-			$this->postotalht-=20;
196
-		}
197
-
198
-		$this->tva=array();
199
-		$this->localtax1=array();
200
-		$this->localtax2=array();
201
-		$this->atleastoneratenotnull=0;
202
-		$this->atleastonediscount=0;
203
-	}
114
+    public $marge_basse;
115
+
116
+    /**
117
+     * Issuer
118
+     * @var Company object that emits
119
+     */
120
+    public $emetteur;
121
+
122
+
123
+    /**
124
+     *	Constructor
125
+     *
126
+     *  @param		DoliDB		$db      Database handler
127
+     */
128
+    function __construct($db)
129
+    {
130
+        global $conf,$langs,$mysoc;
131
+
132
+        // Translations
133
+        $langs->loadLangs(array("main", "bills"));
134
+
135
+        $this->db = $db;
136
+        $this->name = "azur";
137
+        $this->description = $langs->trans('DocModelAzurDescription');
138
+        $this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
139
+
140
+        // Dimension page
141
+        $this->type = 'pdf';
142
+        $formatarray=pdf_getFormat();
143
+        $this->page_largeur = $formatarray['width'];
144
+        $this->page_hauteur = $formatarray['height'];
145
+        $this->format = array($this->page_largeur,$this->page_hauteur);
146
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
147
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
148
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
149
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
150
+
151
+        $this->option_logo = 1;                    // Affiche logo
152
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
153
+        $this->option_modereg = 1;                 // Affiche mode reglement
154
+        $this->option_condreg = 1;                 // Affiche conditions reglement
155
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
156
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
157
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
158
+        $this->option_credit_note = 0;             // Support credit notes
159
+        $this->option_freetext = 1;				   // Support add of a personalised text
160
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
161
+
162
+        $this->franchise=!$mysoc->tva_assuj;
163
+
164
+        // Get source company
165
+        $this->emetteur=$mysoc;
166
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
167
+
168
+        // Define position of columns
169
+        $this->posxdesc=$this->marge_gauche+1;
170
+        if($conf->global->PRODUCT_USE_UNITS)
171
+        {
172
+            $this->posxtva=101;
173
+            $this->posxup=118;
174
+            $this->posxqty=135;
175
+            $this->posxunit=151;
176
+        }
177
+        else
178
+        {
179
+            $this->posxtva=110;
180
+            $this->posxup=126;
181
+            $this->posxqty=145;
182
+        }
183
+        $this->posxdiscount=162;
184
+        $this->postotalht=174;
185
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
186
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
187
+        if ($this->page_largeur < 210) // To work with US executive format
188
+        {
189
+            $this->posxpicture-=20;
190
+            $this->posxtva-=20;
191
+            $this->posxup-=20;
192
+            $this->posxqty-=20;
193
+            $this->posxunit-=20;
194
+            $this->posxdiscount-=20;
195
+            $this->postotalht-=20;
196
+        }
197
+
198
+        $this->tva=array();
199
+        $this->localtax1=array();
200
+        $this->localtax2=array();
201
+        $this->atleastoneratenotnull=0;
202
+        $this->atleastonediscount=0;
203
+    }
204 204
 
205 205
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
206
-	/**
206
+    /**
207 207
      *  Function to build pdf onto disk
208 208
      *
209 209
      *  @param		Object		$object				Object to generate
@@ -213,126 +213,126 @@  discard block
 block discarded – undo
213 213
      *  @param		int			$hidedesc			Do not show desc
214 214
      *  @param		int			$hideref			Do not show ref
215 215
      *  @return     int             				1=OK, 0=KO
216
-	 */
217
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
218
-	{
216
+     */
217
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
218
+    {
219 219
         // phpcs:enable
220
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
220
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
221 221
 
222
-		if (! is_object($outputlangs)) $outputlangs=$langs;
223
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
224
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
222
+        if (! is_object($outputlangs)) $outputlangs=$langs;
223
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
224
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
225 225
 
226
-		// Load traductions files requiredby by page
227
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products"));
226
+        // Load traductions files requiredby by page
227
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products"));
228 228
 
229
-		$nblignes = count($object->lines);
229
+        $nblignes = count($object->lines);
230 230
 
231
-		// Loop on each lines to detect if there is at least one image to show
232
-		$realpatharray=array();
233
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
234
-		{
235
-			$objphoto = new Product($this->db);
231
+        // Loop on each lines to detect if there is at least one image to show
232
+        $realpatharray=array();
233
+        if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
234
+        {
235
+            $objphoto = new Product($this->db);
236 236
 
237
-			for ($i = 0 ; $i < $nblignes ; $i++)
238
-			{
239
-				if (empty($object->lines[$i]->fk_product)) continue;
237
+            for ($i = 0 ; $i < $nblignes ; $i++)
238
+            {
239
+                if (empty($object->lines[$i]->fk_product)) continue;
240 240
 
241
-				$objphoto->fetch($object->lines[$i]->fk_product);
241
+                $objphoto->fetch($object->lines[$i]->fk_product);
242 242
                 //var_dump($objphoto->ref);exit;
243
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
244
-				{
245
-					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
246
-					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
247
-				}
248
-				else
249
-				{
250
-					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
251
-					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
252
-				}
253
-
254
-				$arephoto = false;
255
-				foreach ($pdir as $midir)
256
-				{
257
-					if (! $arephoto)
258
-					{
259
-						$dir = $conf->product->dir_output.'/'.$midir;
260
-
261
-						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
262
-						{
263
-							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
264
-							{
265
-								if ($obj['photo_vignette'])
266
-								{
267
-									$filename= $obj['photo_vignette'];
268
-								}
269
-								else
270
-								{
271
-									$filename=$obj['photo'];
272
-								}
273
-							}
274
-							else
275
-							{
276
-								$filename=$obj['photo'];
277
-							}
278
-
279
-							$realpath = $dir.$filename;
280
-							$arephoto = true;
281
-						}
282
-					}
283
-				}
284
-
285
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
286
-			}
287
-		}
288
-
289
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
290
-
291
-		if ($conf->propal->multidir_output[$conf->entity])
292
-		{
293
-			$object->fetch_thirdparty();
294
-
295
-			$deja_regle = 0;
243
+                if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
244
+                {
245
+                    $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
246
+                    $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
247
+                }
248
+                else
249
+                {
250
+                    $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
251
+                    $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
252
+                }
296 253
 
297
-			// Definition of $dir and $file
298
-			if ($object->specimen)
299
-			{
300
-				$dir = $conf->propal->multidir_output[$conf->entity];
301
-				$file = $dir . "/SPECIMEN.pdf";
302
-			}
303
-			else
304
-			{
305
-				$objectref = dol_sanitizeFileName($object->ref);
306
-				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
307
-				$file = $dir . "/" . $objectref . ".pdf";
308
-			}
254
+                $arephoto = false;
255
+                foreach ($pdir as $midir)
256
+                {
257
+                    if (! $arephoto)
258
+                    {
259
+                        $dir = $conf->product->dir_output.'/'.$midir;
260
+
261
+                        foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
262
+                        {
263
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
264
+                            {
265
+                                if ($obj['photo_vignette'])
266
+                                {
267
+                                    $filename= $obj['photo_vignette'];
268
+                                }
269
+                                else
270
+                                {
271
+                                    $filename=$obj['photo'];
272
+                                }
273
+                            }
274
+                            else
275
+                            {
276
+                                $filename=$obj['photo'];
277
+                            }
278
+
279
+                            $realpath = $dir.$filename;
280
+                            $arephoto = true;
281
+                        }
282
+                    }
283
+                }
309 284
 
310
-			if (! file_exists($dir))
311
-			{
312
-				if (dol_mkdir($dir) < 0)
313
-				{
314
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
315
-					return 0;
316
-				}
317
-			}
285
+                if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
286
+            }
287
+        }
288
+
289
+        if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
290
+
291
+        if ($conf->propal->multidir_output[$conf->entity])
292
+        {
293
+            $object->fetch_thirdparty();
294
+
295
+            $deja_regle = 0;
296
+
297
+            // Definition of $dir and $file
298
+            if ($object->specimen)
299
+            {
300
+                $dir = $conf->propal->multidir_output[$conf->entity];
301
+                $file = $dir . "/SPECIMEN.pdf";
302
+            }
303
+            else
304
+            {
305
+                $objectref = dol_sanitizeFileName($object->ref);
306
+                $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
307
+                $file = $dir . "/" . $objectref . ".pdf";
308
+            }
309
+
310
+            if (! file_exists($dir))
311
+            {
312
+                if (dol_mkdir($dir) < 0)
313
+                {
314
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
315
+                    return 0;
316
+                }
317
+            }
318 318
 
319
-			if (file_exists($dir))
320
-			{
321
-				// Add pdfgeneration hook
322
-				if (! is_object($hookmanager))
323
-				{
324
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
325
-					$hookmanager=new HookManager($this->db);
326
-				}
327
-				$hookmanager->initHooks(array('pdfgeneration'));
328
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
329
-				global $action;
330
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
319
+            if (file_exists($dir))
320
+            {
321
+                // Add pdfgeneration hook
322
+                if (! is_object($hookmanager))
323
+                {
324
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
325
+                    $hookmanager=new HookManager($this->db);
326
+                }
327
+                $hookmanager->initHooks(array('pdfgeneration'));
328
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
329
+                global $action;
330
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
331 331
 
332
-				// Create pdf instance
332
+                // Create pdf instance
333 333
                 $pdf=pdf_getInstance($this->format);
334 334
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
335
-	            $pdf->SetAutoPageBreak(1,0);
335
+                $pdf->SetAutoPageBreak(1,0);
336 336
 
337 337
                 if (class_exists('TCPDF'))
338 338
                 {
@@ -347,589 +347,589 @@  discard block
 block discarded – undo
347 347
                     $tplidx = $pdf->importPage(1);
348 348
                 }
349 349
 
350
-				$pdf->Open();
351
-				$pagenb=0;
352
-				$pdf->SetDrawColor(128,128,128);
350
+                $pdf->Open();
351
+                $pagenb=0;
352
+                $pdf->SetDrawColor(128,128,128);
353 353
 
354
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
355
-				$pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
356
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
357
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
358
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
359
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
354
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
355
+                $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
356
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
357
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
358
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
359
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
360 360
 
361
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
361
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
362 362
 
363
-				// Positionne $this->atleastonediscount si on a au moins une remise
364
-				for ($i = 0 ; $i < $nblignes ; $i++)
365
-				{
366
-					if ($object->lines[$i]->remise_percent)
367
-					{
368
-						$this->atleastonediscount++;
369
-					}
370
-				}
371
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
372
-				{
373
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
374
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
375
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
376
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
377
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
378
-					//$this->postotalht;
379
-				}
363
+                // Positionne $this->atleastonediscount si on a au moins une remise
364
+                for ($i = 0 ; $i < $nblignes ; $i++)
365
+                {
366
+                    if ($object->lines[$i]->remise_percent)
367
+                    {
368
+                        $this->atleastonediscount++;
369
+                    }
370
+                }
371
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
372
+                {
373
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
374
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
375
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
376
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
377
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
378
+                    //$this->postotalht;
379
+                }
380 380
 
381
-				// New page
382
-				$pdf->AddPage();
383
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
384
-				$pagenb++;
381
+                // New page
382
+                $pdf->AddPage();
383
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
384
+                $pagenb++;
385 385
 
386 386
                 $heightforinfotot = 40;	// Height reserved to output the info and total part
387 387
                 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
388 388
                 $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
389
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
390
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
389
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
390
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
391 391
                 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
392 392
 
393
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
394
-				$pdf->SetFont('','', $default_font_size - 1);
395
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
396
-				$pdf->SetTextColor(0,0,0);
393
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
394
+                $pdf->SetFont('','', $default_font_size - 1);
395
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
396
+                $pdf->SetTextColor(0,0,0);
397 397
 
398 398
 
399
-	            $tab_top = 90+$top_shift;
400
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
399
+                $tab_top = 90+$top_shift;
400
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
401 401
 
402
-				// Incoterm
403
-				if ($conf->incoterm->enabled)
404
-				{
405
-					$desc_incoterms = $object->getIncotermsForPDF();
406
-					if ($desc_incoterms)
407
-					{
408
-						$tab_top -= 2;
409
-
410
-						$pdf->SetFont('','', $default_font_size - 1);
411
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
412
-						$nexY = $pdf->GetY();
413
-						$height_incoterms=$nexY-$tab_top;
414
-
415
-						// Rect prend une longueur en 3eme param
416
-						$pdf->SetDrawColor(192,192,192);
417
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
418
-
419
-						$tab_top = $nexY+6;
420
-					}
421
-				}
402
+                // Incoterm
403
+                if ($conf->incoterm->enabled)
404
+                {
405
+                    $desc_incoterms = $object->getIncotermsForPDF();
406
+                    if ($desc_incoterms)
407
+                    {
408
+                        $tab_top -= 2;
409
+
410
+                        $pdf->SetFont('','', $default_font_size - 1);
411
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
412
+                        $nexY = $pdf->GetY();
413
+                        $height_incoterms=$nexY-$tab_top;
414
+
415
+                        // Rect prend une longueur en 3eme param
416
+                        $pdf->SetDrawColor(192,192,192);
417
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
418
+
419
+                        $tab_top = $nexY+6;
420
+                    }
421
+                }
422 422
 
423
-				// Affiche notes
424
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
425
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
426
-				{
427
-					// Get first sale rep
428
-					if (is_object($object->thirdparty))
429
-					{
430
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
431
-						$salerepobj=new User($this->db);
432
-						$salerepobj->fetch($salereparray[0]['id']);
433
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
434
-					}
435
-				}
436
-				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
437
-				{
438
-				    $tmpuser=new User($this->db);
439
-				    $tmpuser->fetch($object->user_author_id);
440
-				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
441
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
442
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
443
-				}
444
-				if ($notetoshow)
445
-				{
446
-					$tab_top -= 2;
423
+                // Affiche notes
424
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
425
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
426
+                {
427
+                    // Get first sale rep
428
+                    if (is_object($object->thirdparty))
429
+                    {
430
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
431
+                        $salerepobj=new User($this->db);
432
+                        $salerepobj->fetch($salereparray[0]['id']);
433
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
434
+                    }
435
+                }
436
+                if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
437
+                {
438
+                    $tmpuser=new User($this->db);
439
+                    $tmpuser->fetch($object->user_author_id);
440
+                    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
441
+                    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
442
+                    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
443
+                }
444
+                if ($notetoshow)
445
+                {
446
+                    $tab_top -= 2;
447 447
 
448
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
449
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
450
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
448
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
449
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
450
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
451 451
 
452
-					$pdf->SetFont('','', $default_font_size - 1);
453
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
454
-					$nexY = $pdf->GetY();
455
-					$height_note=$nexY-$tab_top;
452
+                    $pdf->SetFont('','', $default_font_size - 1);
453
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
454
+                    $nexY = $pdf->GetY();
455
+                    $height_note=$nexY-$tab_top;
456 456
 
457
-					// Rect prend une longueur en 3eme param
458
-					$pdf->SetDrawColor(192,192,192);
459
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
457
+                    // Rect prend une longueur en 3eme param
458
+                    $pdf->SetDrawColor(192,192,192);
459
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
460 460
 
461
-					$tab_top = $nexY+6;
462
-				}
461
+                    $tab_top = $nexY+6;
462
+                }
463 463
 
464
-				$iniY = $tab_top + 7;
465
-				$curY = $tab_top + 7;
466
-				$nexY = $tab_top + 7;
464
+                $iniY = $tab_top + 7;
465
+                $curY = $tab_top + 7;
466
+                $nexY = $tab_top + 7;
467 467
 
468
-				// Loop on each lines
469
-				for ($i = 0; $i < $nblignes; $i++)
470
-				{
471
-					$curY = $nexY;
472
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
473
-					$pdf->SetTextColor(0,0,0);
474
-
475
-					// Define size of image if we need it
476
-					$imglinesize=array();
477
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
478
-
479
-					$pdf->setTopMargin($tab_top_newpage);
480
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
481
-					$pageposbefore=$pdf->getPage();
482
-
483
-					$showpricebeforepagebreak=1;
484
-					$posYAfterImage=0;
485
-					$posYAfterDescription=0;
486
-
487
-					// We start with Photo of product line
488
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
489
-					{
490
-						$pdf->AddPage('','',true);
491
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
492
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
493
-						$pdf->setPage($pageposbefore+1);
494
-
495
-						$curY = $tab_top_newpage;
496
-						$showpricebeforepagebreak=0;
497
-					}
498
-
499
-					if (isset($imglinesize['width']) && isset($imglinesize['height']))
500
-					{
501
-						$curX = $this->posxpicture-1;
502
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
503
-						// $pdf->Image does not increase value return by getY, so we save it manually
504
-						$posYAfterImage=$curY+$imglinesize['height'];
505
-					}
506
-
507
-					// Description of product line
508
-					$curX = $this->posxdesc-1;
509
-
510
-					$pdf->startTransaction();
511
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
512
-					$pageposafter=$pdf->getPage();
513
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
514
-					{
515
-						$pdf->rollbackTransaction(true);
516
-						$pageposafter=$pageposbefore;
517
-						//print $pageposafter.'-'.$pageposbefore;exit;
518
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
519
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
520
-
521
-						$pageposafter=$pdf->getPage();
522
-						$posyafter=$pdf->GetY();
523
-						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
524
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
525
-						{
526
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
527
-							{
528
-								$pdf->AddPage('','',true);
529
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
530
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
-								$pdf->setPage($pageposafter+1);
532
-							}
533
-						}
534
-						else
535
-						{
536
-							// We found a page break
537
-							$showpricebeforepagebreak=0;
538
-						}
539
-					}
540
-					else	// No pagebreak
541
-					{
542
-						$pdf->commitTransaction();
543
-					}
544
-					$posYAfterDescription=$pdf->GetY();
545
-
546
-					$nexY = $pdf->GetY();
547
-					$pageposafter=$pdf->getPage();
548
-
549
-					$pdf->setPage($pageposbefore);
550
-					$pdf->setTopMargin($this->marge_haute);
551
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
552
-
553
-					// We suppose that a too long description or photo were moved completely on next page
554
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
555
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
556
-					}
557
-
558
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
559
-
560
-					// VAT Rate
561
-					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
562
-					{
563
-						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
564
-						$pdf->SetXY($this->posxtva-5, $curY);
565
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
566
-					}
567
-
568
-					// Unit price before discount
569
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
570
-					$pdf->SetXY($this->posxup, $curY);
571
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
572
-
573
-					// Quantity
574
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
575
-					$pdf->SetXY($this->posxqty, $curY);
576
-					// Enough for 6 chars
577
-					if($conf->global->PRODUCT_USE_UNITS)
578
-					{
579
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
580
-					}
581
-					else
582
-					{
583
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
584
-					}
585
-
586
-					// Unit
587
-					if($conf->global->PRODUCT_USE_UNITS)
588
-					{
589
-						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
590
-						$pdf->SetXY($this->posxunit, $curY);
591
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
592
-					}
593
-
594
-					// Discount on line
595
-					$pdf->SetXY($this->posxdiscount, $curY);
596
-					if ($object->lines[$i]->remise_percent)
597
-					{
598
-						$pdf->SetXY($this->posxdiscount-2, $curY);
599
-						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
600
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
601
-					}
602
-
603
-					// Total HT line
604
-					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
605
-					$pdf->SetXY($this->postotalht, $curY);
606
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
607
-
608
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
609
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
610
-					else $tvaligne=$object->lines[$i]->total_tva;
611
-
612
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
613
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
614
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
615
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
616
-					$localtax1_type=$object->lines[$i]->localtax1_type;
617
-					$localtax2_type=$object->lines[$i]->localtax2_type;
618
-
619
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
620
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
622
-
623
-					$vatrate=(string) $object->lines[$i]->tva_tx;
624
-
625
-					// Retrieve type from database for backward compatibility with old records
626
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
627
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
628
-					{
629
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
630
-						$localtax1_type = $localtaxtmp_array[0];
631
-						$localtax2_type = $localtaxtmp_array[2];
632
-					}
633
-
634
-				    // retrieve global local tax
635
-					if ($localtax1_type && $localtax1ligne != 0)
636
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
637
-					if ($localtax2_type && $localtax2ligne != 0)
638
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
639
-
640
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
641
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
642
-					$this->tva[$vatrate] += $tvaligne;
643
-
644
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
645
-
646
-					// Add line
647
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
648
-					{
649
-						$pdf->setPage($pageposafter);
650
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
651
-						//$pdf->SetDrawColor(190,190,200);
652
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
653
-						$pdf->SetLineStyle(array('dash'=>0));
654
-					}
655
-
656
-					$nexY+=2;    // Passe espace entre les lignes
657
-
658
-					// Detect if some page were added automatically and output _tableau for past pages
659
-					while ($pagenb < $pageposafter)
660
-					{
661
-						$pdf->setPage($pagenb);
662
-						if ($pagenb == 1)
663
-						{
664
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
665
-						}
666
-						else
667
-						{
668
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
669
-						}
670
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
671
-						$pagenb++;
672
-						$pdf->setPage($pagenb);
673
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
674
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
675
-					}
676
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
677
-					{
678
-						if ($pagenb == 1)
679
-						{
680
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
681
-						}
682
-						else
683
-						{
684
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
685
-						}
686
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
687
-						// New page
688
-						$pdf->AddPage();
689
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
690
-						$pagenb++;
691
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
692
-					}
693
-				}
468
+                // Loop on each lines
469
+                for ($i = 0; $i < $nblignes; $i++)
470
+                {
471
+                    $curY = $nexY;
472
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
473
+                    $pdf->SetTextColor(0,0,0);
474
+
475
+                    // Define size of image if we need it
476
+                    $imglinesize=array();
477
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
478
+
479
+                    $pdf->setTopMargin($tab_top_newpage);
480
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
481
+                    $pageposbefore=$pdf->getPage();
482
+
483
+                    $showpricebeforepagebreak=1;
484
+                    $posYAfterImage=0;
485
+                    $posYAfterDescription=0;
486
+
487
+                    // We start with Photo of product line
488
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
489
+                    {
490
+                        $pdf->AddPage('','',true);
491
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
492
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
493
+                        $pdf->setPage($pageposbefore+1);
494
+
495
+                        $curY = $tab_top_newpage;
496
+                        $showpricebeforepagebreak=0;
497
+                    }
498
+
499
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']))
500
+                    {
501
+                        $curX = $this->posxpicture-1;
502
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
503
+                        // $pdf->Image does not increase value return by getY, so we save it manually
504
+                        $posYAfterImage=$curY+$imglinesize['height'];
505
+                    }
506
+
507
+                    // Description of product line
508
+                    $curX = $this->posxdesc-1;
509
+
510
+                    $pdf->startTransaction();
511
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
512
+                    $pageposafter=$pdf->getPage();
513
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
514
+                    {
515
+                        $pdf->rollbackTransaction(true);
516
+                        $pageposafter=$pageposbefore;
517
+                        //print $pageposafter.'-'.$pageposbefore;exit;
518
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
519
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
520
+
521
+                        $pageposafter=$pdf->getPage();
522
+                        $posyafter=$pdf->GetY();
523
+                        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
524
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
525
+                        {
526
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
527
+                            {
528
+                                $pdf->AddPage('','',true);
529
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
530
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
+                                $pdf->setPage($pageposafter+1);
532
+                            }
533
+                        }
534
+                        else
535
+                        {
536
+                            // We found a page break
537
+                            $showpricebeforepagebreak=0;
538
+                        }
539
+                    }
540
+                    else	// No pagebreak
541
+                    {
542
+                        $pdf->commitTransaction();
543
+                    }
544
+                    $posYAfterDescription=$pdf->GetY();
545
+
546
+                    $nexY = $pdf->GetY();
547
+                    $pageposafter=$pdf->getPage();
548
+
549
+                    $pdf->setPage($pageposbefore);
550
+                    $pdf->setTopMargin($this->marge_haute);
551
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
552
+
553
+                    // We suppose that a too long description or photo were moved completely on next page
554
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
555
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
556
+                    }
557
+
558
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
559
+
560
+                    // VAT Rate
561
+                    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
562
+                    {
563
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
564
+                        $pdf->SetXY($this->posxtva-5, $curY);
565
+                        $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
566
+                    }
567
+
568
+                    // Unit price before discount
569
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
570
+                    $pdf->SetXY($this->posxup, $curY);
571
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
572
+
573
+                    // Quantity
574
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
575
+                    $pdf->SetXY($this->posxqty, $curY);
576
+                    // Enough for 6 chars
577
+                    if($conf->global->PRODUCT_USE_UNITS)
578
+                    {
579
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
580
+                    }
581
+                    else
582
+                    {
583
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
584
+                    }
585
+
586
+                    // Unit
587
+                    if($conf->global->PRODUCT_USE_UNITS)
588
+                    {
589
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
590
+                        $pdf->SetXY($this->posxunit, $curY);
591
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
592
+                    }
593
+
594
+                    // Discount on line
595
+                    $pdf->SetXY($this->posxdiscount, $curY);
596
+                    if ($object->lines[$i]->remise_percent)
597
+                    {
598
+                        $pdf->SetXY($this->posxdiscount-2, $curY);
599
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
600
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
601
+                    }
602
+
603
+                    // Total HT line
604
+                    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
605
+                    $pdf->SetXY($this->postotalht, $curY);
606
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
607
+
608
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
609
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
610
+                    else $tvaligne=$object->lines[$i]->total_tva;
611
+
612
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
613
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
614
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
615
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
616
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
617
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
618
+
619
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
620
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
622
+
623
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
624
+
625
+                    // Retrieve type from database for backward compatibility with old records
626
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
627
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
628
+                    {
629
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
630
+                        $localtax1_type = $localtaxtmp_array[0];
631
+                        $localtax2_type = $localtaxtmp_array[2];
632
+                    }
633
+
634
+                    // retrieve global local tax
635
+                    if ($localtax1_type && $localtax1ligne != 0)
636
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
637
+                    if ($localtax2_type && $localtax2ligne != 0)
638
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
639
+
640
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
641
+                    if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
642
+                    $this->tva[$vatrate] += $tvaligne;
643
+
644
+                    if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
645
+
646
+                    // Add line
647
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
648
+                    {
649
+                        $pdf->setPage($pageposafter);
650
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
651
+                        //$pdf->SetDrawColor(190,190,200);
652
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
653
+                        $pdf->SetLineStyle(array('dash'=>0));
654
+                    }
655
+
656
+                    $nexY+=2;    // Passe espace entre les lignes
657
+
658
+                    // Detect if some page were added automatically and output _tableau for past pages
659
+                    while ($pagenb < $pageposafter)
660
+                    {
661
+                        $pdf->setPage($pagenb);
662
+                        if ($pagenb == 1)
663
+                        {
664
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
665
+                        }
666
+                        else
667
+                        {
668
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
669
+                        }
670
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
671
+                        $pagenb++;
672
+                        $pdf->setPage($pagenb);
673
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
674
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
675
+                    }
676
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
677
+                    {
678
+                        if ($pagenb == 1)
679
+                        {
680
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
681
+                        }
682
+                        else
683
+                        {
684
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
685
+                        }
686
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
687
+                        // New page
688
+                        $pdf->AddPage();
689
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
690
+                        $pagenb++;
691
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
692
+                    }
693
+                }
694 694
 
695
-				// Show square
696
-				if ($pagenb == 1)
697
-				{
698
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
699
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
700
-				}
701
-				else
702
-				{
703
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
704
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
705
-				}
695
+                // Show square
696
+                if ($pagenb == 1)
697
+                {
698
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
699
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
700
+                }
701
+                else
702
+                {
703
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
704
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
705
+                }
706 706
 
707
-				// Affiche zone infos
708
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
707
+                // Affiche zone infos
708
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
709 709
 
710
-				// Affiche zone totaux
711
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
710
+                // Affiche zone totaux
711
+                $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
712 712
 
713
-				// Affiche zone versements
714
-				/*
713
+                // Affiche zone versements
714
+                /*
715 715
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
716 716
 				{
717 717
 					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
718 718
 				}
719 719
 				*/
720 720
 
721
-				// Customer signature area
722
-				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
723
-				{
724
-				    $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
725
-				}
721
+                // Customer signature area
722
+                if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
723
+                {
724
+                    $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
725
+                }
726 726
 
727
-				// Pied de page
728
-				$this->_pagefoot($pdf,$object,$outputlangs);
729
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
727
+                // Pied de page
728
+                $this->_pagefoot($pdf,$object,$outputlangs);
729
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
730 730
 
731
-				//If propal merge product PDF is active
732
-				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
733
-				{
734
-					require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
735
-
736
-					$already_merged = array ();
737
-					foreach ( $object->lines as $line ) {
738
-						if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
739
-							// Find the desire PDF
740
-							$filetomerge = new Propalmergepdfproduct($this->db);
741
-
742
-							if ($conf->global->MAIN_MULTILANGS) {
743
-								$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
744
-							} else {
745
-								$filetomerge->fetch_by_product($line->fk_product);
746
-							}
747
-
748
-							$already_merged[] = $line->fk_product;
749
-
750
-							$product = new Product($this->db);
751
-							$product->fetch($line->fk_product);
752
-
753
-							if ($product->entity!=$conf->entity) {
754
-								$entity_product_file=$product->entity;
755
-							} else {
756
-								$entity_product_file=$conf->entity;
757
-							}
758
-
759
-							// If PDF is selected and file is not empty
760
-							if (count($filetomerge->lines) > 0) {
761
-								foreach ( $filetomerge->lines as $linefile ) {
762
-									if (! empty($linefile->id) && ! empty($linefile->file_name)) {
763
-
764
-
765
-										if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
766
-										{
767
-											if (! empty($conf->product->enabled)) {
768
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
769
-											} elseif (! empty($conf->service->enabled)) {
770
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
771
-											}
772
-										}
773
-										else
774
-										{
775
-											if (! empty($conf->product->enabled)) {
776
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
777
-											} elseif (! empty($conf->service->enabled)) {
778
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
779
-											}
780
-										}
781
-
782
-										dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
783
-
784
-										$infile = $filetomerge_dir . '/' . $linefile->file_name;
785
-										if (file_exists($infile) && is_readable($infile)) {
786
-											$pagecount = $pdf->setSourceFile($infile);
787
-											for($i = 1; $i <= $pagecount; $i ++) {
788
-												$tplIdx = $pdf->importPage($i);
789
-												if ($tplIdx!==false) {
790
-													$s = $pdf->getTemplatesize($tplIdx);
791
-													$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
792
-													$pdf->useTemplate($tplIdx);
793
-												} else {
794
-													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
795
-												}
796
-											}
797
-										}
798
-									}
799
-								}
800
-							}
801
-						}
802
-					}
803
-				}
731
+                //If propal merge product PDF is active
732
+                if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
733
+                {
734
+                    require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
735
+
736
+                    $already_merged = array ();
737
+                    foreach ( $object->lines as $line ) {
738
+                        if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
739
+                            // Find the desire PDF
740
+                            $filetomerge = new Propalmergepdfproduct($this->db);
741
+
742
+                            if ($conf->global->MAIN_MULTILANGS) {
743
+                                $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
744
+                            } else {
745
+                                $filetomerge->fetch_by_product($line->fk_product);
746
+                            }
747
+
748
+                            $already_merged[] = $line->fk_product;
749
+
750
+                            $product = new Product($this->db);
751
+                            $product->fetch($line->fk_product);
752
+
753
+                            if ($product->entity!=$conf->entity) {
754
+                                $entity_product_file=$product->entity;
755
+                            } else {
756
+                                $entity_product_file=$conf->entity;
757
+                            }
758
+
759
+                            // If PDF is selected and file is not empty
760
+                            if (count($filetomerge->lines) > 0) {
761
+                                foreach ( $filetomerge->lines as $linefile ) {
762
+                                    if (! empty($linefile->id) && ! empty($linefile->file_name)) {
763
+
764
+
765
+                                        if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
766
+                                        {
767
+                                            if (! empty($conf->product->enabled)) {
768
+                                                $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
769
+                                            } elseif (! empty($conf->service->enabled)) {
770
+                                                $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
771
+                                            }
772
+                                        }
773
+                                        else
774
+                                        {
775
+                                            if (! empty($conf->product->enabled)) {
776
+                                                $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
777
+                                            } elseif (! empty($conf->service->enabled)) {
778
+                                                $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
779
+                                            }
780
+                                        }
781
+
782
+                                        dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
783
+
784
+                                        $infile = $filetomerge_dir . '/' . $linefile->file_name;
785
+                                        if (file_exists($infile) && is_readable($infile)) {
786
+                                            $pagecount = $pdf->setSourceFile($infile);
787
+                                            for($i = 1; $i <= $pagecount; $i ++) {
788
+                                                $tplIdx = $pdf->importPage($i);
789
+                                                if ($tplIdx!==false) {
790
+                                                    $s = $pdf->getTemplatesize($tplIdx);
791
+                                                    $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
792
+                                                    $pdf->useTemplate($tplIdx);
793
+                                                } else {
794
+                                                    setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
795
+                                                }
796
+                                            }
797
+                                        }
798
+                                    }
799
+                                }
800
+                            }
801
+                        }
802
+                    }
803
+                }
804 804
 
805
-				$pdf->Close();
805
+                $pdf->Close();
806 806
 
807
-				$pdf->Output($file,'F');
807
+                $pdf->Output($file,'F');
808 808
 
809
-				//Add pdfgeneration hook
810
-				$hookmanager->initHooks(array('pdfgeneration'));
811
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
812
-				global $action;
813
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
809
+                //Add pdfgeneration hook
810
+                $hookmanager->initHooks(array('pdfgeneration'));
811
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
812
+                global $action;
813
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
814 814
 
815
-				if (! empty($conf->global->MAIN_UMASK))
816
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
815
+                if (! empty($conf->global->MAIN_UMASK))
816
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
817 817
 
818
-				$this->result = array('fullpath'=>$file);
818
+                $this->result = array('fullpath'=>$file);
819 819
 
820
-				return 1;   // Pas d'erreur
821
-			}
822
-			else
823
-			{
824
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
825
-				return 0;
826
-			}
827
-		}
828
-		else
829
-		{
830
-			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
831
-			return 0;
832
-		}
833
-	}
820
+                return 1;   // Pas d'erreur
821
+            }
822
+            else
823
+            {
824
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
825
+                return 0;
826
+            }
827
+        }
828
+        else
829
+        {
830
+            $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
831
+            return 0;
832
+        }
833
+    }
834 834
 
835 835
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
836
-	/**
837
-	 *  Show payments table
838
-	 *
836
+    /**
837
+     *  Show payments table
838
+     *
839 839
      *  @param	TCPDF		$pdf           Object PDF
840 840
      *  @param  Object		$object         Object proposal
841 841
      *  @param  int			$posy           Position y in PDF
842 842
      *  @param  Translate	$outputlangs    Object langs for output
843 843
      *  @return int             			<0 if KO, >0 if OK
844
-	 */
845
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
846
-	{
844
+     */
845
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
846
+    {
847 847
         // phpcs:enable
848
-	}
848
+    }
849 849
 
850 850
 
851 851
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
852
-	/**
853
-	 *   Show miscellaneous information (payment mode, payment term, ...)
854
-	 *
855
-	 *   @param		TCPDF		$pdf     		Object PDF
856
-	 *   @param		Object		$object			Object to show
857
-	 *   @param		int			$posy			Y
858
-	 *   @param		Translate	$outputlangs	Langs object
859
-	 *   @return	void
860
-	 */
861
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
862
-	{
852
+    /**
853
+     *   Show miscellaneous information (payment mode, payment term, ...)
854
+     *
855
+     *   @param		TCPDF		$pdf     		Object PDF
856
+     *   @param		Object		$object			Object to show
857
+     *   @param		int			$posy			Y
858
+     *   @param		Translate	$outputlangs	Langs object
859
+     *   @return	void
860
+     */
861
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
862
+    {
863 863
         // phpcs:enable
864
-		global $conf;
865
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
864
+        global $conf;
865
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
866 866
 
867
-		$pdf->SetFont('','', $default_font_size - 1);
867
+        $pdf->SetFont('','', $default_font_size - 1);
868 868
 
869
-		// If France, show VAT mention if not applicable
870
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
871
-		{
872
-			$pdf->SetFont('','B', $default_font_size - 2);
873
-			$pdf->SetXY($this->marge_gauche, $posy);
874
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
869
+        // If France, show VAT mention if not applicable
870
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
871
+        {
872
+            $pdf->SetFont('','B', $default_font_size - 2);
873
+            $pdf->SetXY($this->marge_gauche, $posy);
874
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
875 875
 
876
-			$posy=$pdf->GetY()+4;
877
-		}
876
+            $posy=$pdf->GetY()+4;
877
+        }
878 878
 
879
-		$posxval=52;
879
+        $posxval=52;
880 880
 
881 881
         // Show shipping date
882 882
         if (! empty($object->date_livraison))
883
-		{
883
+        {
884 884
             $outputlangs->load("sendings");
885
-			$pdf->SetFont('','B', $default_font_size - 2);
886
-			$pdf->SetXY($this->marge_gauche, $posy);
887
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
888
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
889
-			$pdf->SetFont('','', $default_font_size - 2);
890
-			$pdf->SetXY($posxval, $posy);
891
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
892
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
885
+            $pdf->SetFont('','B', $default_font_size - 2);
886
+            $pdf->SetXY($this->marge_gauche, $posy);
887
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
888
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
889
+            $pdf->SetFont('','', $default_font_size - 2);
890
+            $pdf->SetXY($posxval, $posy);
891
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
892
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
893 893
 
894 894
             $posy=$pdf->GetY()+1;
895
-		}
895
+        }
896 896
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
897
-		{
898
-			$pdf->SetFont('','B', $default_font_size - 2);
899
-			$pdf->SetXY($this->marge_gauche, $posy);
900
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
901
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
902
-			$pdf->SetTextColor(0,0,0);
903
-			$pdf->SetFont('','', $default_font_size - 2);
904
-			$pdf->SetXY($posxval, $posy);
905
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
906
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
907
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
908
-
909
-			$posy=$pdf->GetY()+1;
910
-		}
911
-
912
-		// Show payments conditions
913
-		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
914
-		{
915
-			$pdf->SetFont('','B', $default_font_size - 2);
916
-			$pdf->SetXY($this->marge_gauche, $posy);
917
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
918
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
919
-
920
-			$pdf->SetFont('','', $default_font_size - 2);
921
-			$pdf->SetXY($posxval, $posy);
922
-			$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);
923
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
924
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
925
-
926
-			$posy=$pdf->GetY()+3;
927
-		}
928
-
929
-		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
930
-		{
931
-			// Check a payment mode is defined
932
-			/* Not required on a proposal
897
+        {
898
+            $pdf->SetFont('','B', $default_font_size - 2);
899
+            $pdf->SetXY($this->marge_gauche, $posy);
900
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
901
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
902
+            $pdf->SetTextColor(0,0,0);
903
+            $pdf->SetFont('','', $default_font_size - 2);
904
+            $pdf->SetXY($posxval, $posy);
905
+            $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
906
+            $lib_availability=str_replace('\n',"\n",$lib_availability);
907
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
908
+
909
+            $posy=$pdf->GetY()+1;
910
+        }
911
+
912
+        // Show payments conditions
913
+        if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
914
+        {
915
+            $pdf->SetFont('','B', $default_font_size - 2);
916
+            $pdf->SetXY($this->marge_gauche, $posy);
917
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
918
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
919
+
920
+            $pdf->SetFont('','', $default_font_size - 2);
921
+            $pdf->SetXY($posxval, $posy);
922
+            $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);
923
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
924
+            $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
925
+
926
+            $posy=$pdf->GetY()+3;
927
+        }
928
+
929
+        if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
930
+        {
931
+            // Check a payment mode is defined
932
+            /* Not required on a proposal
933 933
 			if (empty($object->mode_reglement_code)
934 934
 			&& ! $conf->global->FACTURE_CHQ_NUMBER
935 935
 			&& ! $conf->global->FACTURE_RIB_NUMBER)
@@ -944,335 +944,335 @@  discard block
 block discarded – undo
944 944
 			}
945 945
 			*/
946 946
 
947
-			// Show payment mode
948
-			if ($object->mode_reglement_code
949
-			&& $object->mode_reglement_code != 'CHQ'
950
-			&& $object->mode_reglement_code != 'VIR')
951
-			{
952
-				$pdf->SetFont('','B', $default_font_size - 2);
953
-				$pdf->SetXY($this->marge_gauche, $posy);
954
-				$titre = $outputlangs->transnoentities("PaymentMode").':';
955
-				$pdf->MultiCell(80, 5, $titre, 0, 'L');
956
-				$pdf->SetFont('','', $default_font_size - 2);
957
-				$pdf->SetXY($posxval, $posy);
958
-				$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);
959
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
960
-
961
-				$posy=$pdf->GetY()+2;
962
-			}
963
-
964
-			// Show payment mode CHQ
965
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
966
-			{
967
-				// Si mode reglement non force ou si force a CHQ
968
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
969
-				{
970
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
971
-
972
-					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
973
-					{
974
-						$account = new Account($this->db);
975
-						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
976
-
977
-						$pdf->SetXY($this->marge_gauche, $posy);
978
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
979
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
980
-						$posy=$pdf->GetY()+1;
981
-
982
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
983
-			            {
984
-							$pdf->SetXY($this->marge_gauche, $posy);
985
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
986
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
987
-							$posy=$pdf->GetY()+2;
988
-			            }
989
-					}
990
-					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
991
-					{
992
-						$pdf->SetXY($this->marge_gauche, $posy);
993
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
994
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
995
-						$posy=$pdf->GetY()+1;
996
-
997
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
998
-			            {
999
-							$pdf->SetXY($this->marge_gauche, $posy);
1000
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1001
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1002
-							$posy=$pdf->GetY()+2;
1003
-			            }
1004
-					}
1005
-				}
1006
-			}
947
+            // Show payment mode
948
+            if ($object->mode_reglement_code
949
+            && $object->mode_reglement_code != 'CHQ'
950
+            && $object->mode_reglement_code != 'VIR')
951
+            {
952
+                $pdf->SetFont('','B', $default_font_size - 2);
953
+                $pdf->SetXY($this->marge_gauche, $posy);
954
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
955
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
956
+                $pdf->SetFont('','', $default_font_size - 2);
957
+                $pdf->SetXY($posxval, $posy);
958
+                $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);
959
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
960
+
961
+                $posy=$pdf->GetY()+2;
962
+            }
963
+
964
+            // Show payment mode CHQ
965
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
966
+            {
967
+                // Si mode reglement non force ou si force a CHQ
968
+                if (! empty($conf->global->FACTURE_CHQ_NUMBER))
969
+                {
970
+                    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
971
+
972
+                    if ($conf->global->FACTURE_CHQ_NUMBER > 0)
973
+                    {
974
+                        $account = new Account($this->db);
975
+                        $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
976
+
977
+                        $pdf->SetXY($this->marge_gauche, $posy);
978
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
979
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
980
+                        $posy=$pdf->GetY()+1;
981
+
982
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
983
+                        {
984
+                            $pdf->SetXY($this->marge_gauche, $posy);
985
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
986
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
987
+                            $posy=$pdf->GetY()+2;
988
+                        }
989
+                    }
990
+                    if ($conf->global->FACTURE_CHQ_NUMBER == -1)
991
+                    {
992
+                        $pdf->SetXY($this->marge_gauche, $posy);
993
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
994
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
995
+                        $posy=$pdf->GetY()+1;
996
+
997
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
998
+                        {
999
+                            $pdf->SetXY($this->marge_gauche, $posy);
1000
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
1001
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1002
+                            $posy=$pdf->GetY()+2;
1003
+                        }
1004
+                    }
1005
+                }
1006
+            }
1007 1007
 
1008
-			// If payment mode not forced or forced to VIR, show payment with BAN
1009
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1010
-			{
1011
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1012
-				{
1013
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1014
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1015
-					$account = new Account($this->db);
1016
-					$account->fetch($bankid);
1008
+            // If payment mode not forced or forced to VIR, show payment with BAN
1009
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1010
+            {
1011
+                if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1012
+                {
1013
+                    $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1014
+                    if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1015
+                    $account = new Account($this->db);
1016
+                    $account->fetch($bankid);
1017 1017
 
1018
-					$curx=$this->marge_gauche;
1019
-					$cury=$posy;
1018
+                    $curx=$this->marge_gauche;
1019
+                    $cury=$posy;
1020 1020
 
1021
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1021
+                    $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1022 1022
 
1023
-					$posy+=2;
1024
-				}
1025
-			}
1026
-		}
1023
+                    $posy+=2;
1024
+                }
1025
+            }
1026
+        }
1027 1027
 
1028
-		return $posy;
1029
-	}
1028
+        return $posy;
1029
+    }
1030 1030
 
1031 1031
 
1032 1032
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1033
-	/**
1034
-	 *	Show total to pay
1035
-	 *
1036
-	 *	@param	PDF			$pdf            Object PDF
1037
-	 *	@param  Facture		$object         Object invoice
1038
-	 *	@param  int			$deja_regle     Montant deja regle
1039
-	 *	@param	int			$posy			Position depart
1040
-	 *	@param	Translate	$outputlangs	Objet langs
1041
-	 *	@return int							Position pour suite
1042
-	 */
1043
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1044
-	{
1033
+    /**
1034
+     *	Show total to pay
1035
+     *
1036
+     *	@param	PDF			$pdf            Object PDF
1037
+     *	@param  Facture		$object         Object invoice
1038
+     *	@param  int			$deja_regle     Montant deja regle
1039
+     *	@param	int			$posy			Position depart
1040
+     *	@param	Translate	$outputlangs	Objet langs
1041
+     *	@return int							Position pour suite
1042
+     */
1043
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1044
+    {
1045 1045
         // phpcs:enable
1046
-		global $conf,$mysoc;
1047
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1048
-
1049
-		$tab2_top = $posy;
1050
-		$tab2_hl = 4;
1051
-		$pdf->SetFont('','', $default_font_size - 1);
1052
-
1053
-		// Tableau total
1054
-		$col1x = 120; $col2x = 170;
1055
-		if ($this->page_largeur < 210) // To work with US executive format
1056
-		{
1057
-			$col2x-=20;
1058
-		}
1059
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1060
-
1061
-		$useborder=0;
1062
-		$index = 0;
1063
-
1064
-		// Total HT
1065
-		$pdf->SetFillColor(255,255,255);
1066
-		$pdf->SetXY($col1x, $tab2_top + 0);
1067
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1068
-
1069
-		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1070
-		$pdf->SetXY($col2x, $tab2_top + 0);
1071
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1072
-
1073
-		// Show VAT by rates and total
1074
-		$pdf->SetFillColor(248,248,248);
1075
-
1076
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1077
-
1078
-		$this->atleastoneratenotnull=0;
1079
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1080
-		{
1081
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1082
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1083
-			{
1084
-				// Nothing to do
1085
-			}
1086
-			else
1087
-			{
1088
-				//Local tax 1 before VAT
1089
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1090
-				//{
1091
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1092
-					{
1093
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1094
-
1095
-						foreach( $localtax_rate as $tvakey => $tvaval )
1096
-						{
1097
-							if ($tvakey!=0)    // On affiche pas taux 0
1098
-							{
1099
-								//$this->atleastoneratenotnull++;
1100
-
1101
-								$index++;
1102
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103
-
1104
-								$tvacompl='';
1105
-								if (preg_match('/\*/',$tvakey))
1106
-								{
1107
-									$tvakey=str_replace('*','',$tvakey);
1108
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1109
-								}
1110
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1111
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1112
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1113
-
1114
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1115
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1116
-							}
1117
-						}
1118
-					}
1119
-	      		//}
1120
-				//Local tax 2 before VAT
1121
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1122
-				//{
1123
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1124
-					{
1125
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1126
-
1127
-						foreach( $localtax_rate as $tvakey => $tvaval )
1128
-						{
1129
-							if ($tvakey!=0)    // On affiche pas taux 0
1130
-							{
1131
-								//$this->atleastoneratenotnull++;
1132
-
1133
-
1134
-
1135
-								$index++;
1136
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137
-
1138
-								$tvacompl='';
1139
-								if (preg_match('/\*/',$tvakey))
1140
-								{
1141
-									$tvakey=str_replace('*','',$tvakey);
1142
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143
-								}
1144
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1145
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147
-
1148
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1150
-							}
1151
-						}
1152
-					}
1153
-				//}
1154
-				// VAT
1155
-				foreach($this->tva as $tvakey => $tvaval)
1156
-				{
1157
-					if ($tvakey != 0)    // On affiche pas taux 0
1158
-					{
1159
-						$this->atleastoneratenotnull++;
1160
-
1161
-						$index++;
1162
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1163
-
1164
-						$tvacompl='';
1165
-						if (preg_match('/\*/',$tvakey))
1166
-						{
1167
-							$tvakey=str_replace('*','',$tvakey);
1168
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1169
-						}
1170
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1171
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1172
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1173
-
1174
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1175
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1176
-					}
1177
-				}
1178
-
1179
-				//Local tax 1 after VAT
1180
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1181
-				//{
1182
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1183
-					{
1184
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1185
-
1186
-						foreach( $localtax_rate as $tvakey => $tvaval )
1187
-						{
1188
-							if ($tvakey != 0)    // On affiche pas taux 0
1189
-							{
1190
-								//$this->atleastoneratenotnull++;
1191
-
1192
-								$index++;
1193
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1194
-
1195
-								$tvacompl='';
1196
-								if (preg_match('/\*/',$tvakey))
1197
-								{
1198
-									$tvakey=str_replace('*','',$tvakey);
1199
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1200
-								}
1201
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1202
-
1203
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1204
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1205
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1206
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1207
-							}
1208
-						}
1209
-					}
1210
-	      		//}
1211
-				//Local tax 2 after VAT
1212
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1213
-				//{
1214
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1215
-					{
1216
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1217
-
1218
-						foreach( $localtax_rate as $tvakey => $tvaval )
1219
-						{
1220
-						    // retrieve global local tax
1221
-							if ($tvakey != 0)    // On affiche pas taux 0
1222
-							{
1223
-								//$this->atleastoneratenotnull++;
1224
-
1225
-								$index++;
1226
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1227
-
1228
-								$tvacompl='';
1229
-								if (preg_match('/\*/',$tvakey))
1230
-								{
1231
-									$tvakey=str_replace('*','',$tvakey);
1232
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1233
-								}
1234
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1235
-
1236
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1237
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1238
-
1239
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1241
-							}
1242
-						}
1243
-					}
1244
-				//}
1245
-
1246
-				// Total TTC
1247
-				$index++;
1248
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1249
-				$pdf->SetTextColor(0,0,60);
1250
-				$pdf->SetFillColor(224,224,224);
1251
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1252
-
1253
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1254
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1255
-			}
1256
-		}
1257
-
1258
-		$pdf->SetTextColor(0,0,0);
1046
+        global $conf,$mysoc;
1047
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1048
+
1049
+        $tab2_top = $posy;
1050
+        $tab2_hl = 4;
1051
+        $pdf->SetFont('','', $default_font_size - 1);
1052
+
1053
+        // Tableau total
1054
+        $col1x = 120; $col2x = 170;
1055
+        if ($this->page_largeur < 210) // To work with US executive format
1056
+        {
1057
+            $col2x-=20;
1058
+        }
1059
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1060
+
1061
+        $useborder=0;
1062
+        $index = 0;
1063
+
1064
+        // Total HT
1065
+        $pdf->SetFillColor(255,255,255);
1066
+        $pdf->SetXY($col1x, $tab2_top + 0);
1067
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1068
+
1069
+        $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1070
+        $pdf->SetXY($col2x, $tab2_top + 0);
1071
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1072
+
1073
+        // Show VAT by rates and total
1074
+        $pdf->SetFillColor(248,248,248);
1075
+
1076
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1077
+
1078
+        $this->atleastoneratenotnull=0;
1079
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1080
+        {
1081
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1082
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1083
+            {
1084
+                // Nothing to do
1085
+            }
1086
+            else
1087
+            {
1088
+                //Local tax 1 before VAT
1089
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1090
+                //{
1091
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1092
+                    {
1093
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1094
+
1095
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1096
+                        {
1097
+                            if ($tvakey!=0)    // On affiche pas taux 0
1098
+                            {
1099
+                                //$this->atleastoneratenotnull++;
1100
+
1101
+                                $index++;
1102
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103
+
1104
+                                $tvacompl='';
1105
+                                if (preg_match('/\*/',$tvakey))
1106
+                                {
1107
+                                    $tvakey=str_replace('*','',$tvakey);
1108
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1109
+                                }
1110
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1111
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1112
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1113
+
1114
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1115
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1116
+                            }
1117
+                        }
1118
+                    }
1119
+                    //}
1120
+                //Local tax 2 before VAT
1121
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1122
+                //{
1123
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1124
+                    {
1125
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1126
+
1127
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1128
+                        {
1129
+                            if ($tvakey!=0)    // On affiche pas taux 0
1130
+                            {
1131
+                                //$this->atleastoneratenotnull++;
1132
+
1133
+
1134
+
1135
+                                $index++;
1136
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137
+
1138
+                                $tvacompl='';
1139
+                                if (preg_match('/\*/',$tvakey))
1140
+                                {
1141
+                                    $tvakey=str_replace('*','',$tvakey);
1142
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143
+                                }
1144
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1145
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147
+
1148
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1150
+                            }
1151
+                        }
1152
+                    }
1153
+                //}
1154
+                // VAT
1155
+                foreach($this->tva as $tvakey => $tvaval)
1156
+                {
1157
+                    if ($tvakey != 0)    // On affiche pas taux 0
1158
+                    {
1159
+                        $this->atleastoneratenotnull++;
1160
+
1161
+                        $index++;
1162
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1163
+
1164
+                        $tvacompl='';
1165
+                        if (preg_match('/\*/',$tvakey))
1166
+                        {
1167
+                            $tvakey=str_replace('*','',$tvakey);
1168
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1169
+                        }
1170
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1171
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
1172
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1173
+
1174
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1175
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1176
+                    }
1177
+                }
1259 1178
 
1260
-		/*
1179
+                //Local tax 1 after VAT
1180
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1181
+                //{
1182
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1183
+                    {
1184
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1185
+
1186
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1187
+                        {
1188
+                            if ($tvakey != 0)    // On affiche pas taux 0
1189
+                            {
1190
+                                //$this->atleastoneratenotnull++;
1191
+
1192
+                                $index++;
1193
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1194
+
1195
+                                $tvacompl='';
1196
+                                if (preg_match('/\*/',$tvakey))
1197
+                                {
1198
+                                    $tvakey=str_replace('*','',$tvakey);
1199
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1200
+                                }
1201
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1202
+
1203
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1204
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1205
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1206
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1207
+                            }
1208
+                        }
1209
+                    }
1210
+                    //}
1211
+                //Local tax 2 after VAT
1212
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1213
+                //{
1214
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1215
+                    {
1216
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1217
+
1218
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1219
+                        {
1220
+                            // retrieve global local tax
1221
+                            if ($tvakey != 0)    // On affiche pas taux 0
1222
+                            {
1223
+                                //$this->atleastoneratenotnull++;
1224
+
1225
+                                $index++;
1226
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1227
+
1228
+                                $tvacompl='';
1229
+                                if (preg_match('/\*/',$tvakey))
1230
+                                {
1231
+                                    $tvakey=str_replace('*','',$tvakey);
1232
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1233
+                                }
1234
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1235
+
1236
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1237
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1238
+
1239
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1241
+                            }
1242
+                        }
1243
+                    }
1244
+                //}
1245
+
1246
+                // Total TTC
1247
+                $index++;
1248
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1249
+                $pdf->SetTextColor(0,0,60);
1250
+                $pdf->SetFillColor(224,224,224);
1251
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1252
+
1253
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1254
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1255
+            }
1256
+        }
1257
+
1258
+        $pdf->SetTextColor(0,0,0);
1259
+
1260
+        /*
1261 1261
 		$resteapayer = $object->total_ttc - $deja_regle;
1262 1262
 		if (! empty($object->paye)) $resteapayer=0;
1263 1263
 		*/
1264 1264
 
1265
-		if ($deja_regle > 0)
1266
-		{
1267
-			$index++;
1265
+        if ($deja_regle > 0)
1266
+        {
1267
+            $index++;
1268 1268
 
1269
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1270
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1269
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1270
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1271 1271
 
1272
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1273
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1272
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1273
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1274 1274
 
1275
-			/*
1275
+            /*
1276 1276
 			if ($object->close_code == 'discount_vat')
1277 1277
 			{
1278 1278
 				$index++;
@@ -1288,419 +1288,419 @@  discard block
 block discarded – undo
1288 1288
 			}
1289 1289
 			*/
1290 1290
 
1291
-			$index++;
1292
-			$pdf->SetTextColor(0,0,60);
1293
-			$pdf->SetFillColor(224,224,224);
1294
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1295
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1296
-
1297
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1298
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1299
-
1300
-			$pdf->SetFont('','', $default_font_size - 1);
1301
-			$pdf->SetTextColor(0,0,0);
1302
-		}
1303
-
1304
-		$index++;
1305
-		return ($tab2_top + ($tab2_hl * $index));
1306
-	}
1307
-
1308
-	/**
1309
-	 *   Show table for lines
1310
-	 *
1311
-	 *   @param		PDF			$pdf     		Object PDF
1312
-	 *   @param		string		$tab_top		Top position of table
1313
-	 *   @param		string		$tab_height		Height of table (rectangle)
1314
-	 *   @param		int			$nexY			Y (not used)
1315
-	 *   @param		Translate	$outputlangs	Langs object
1316
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1317
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1318
-	 *   @param		string		$currency		Currency code
1319
-	 *   @return	void
1320
-	 */
1321
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1322
-	{
1323
-		global $conf;
1324
-
1325
-		// Force to disable hidetop and hidebottom
1326
-		$hidebottom=0;
1327
-		if ($hidetop) $hidetop=-1;
1328
-
1329
-		$currency = !empty($currency) ? $currency : $conf->currency;
1330
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1331
-
1332
-		// Amount in (at tab_top - 1)
1333
-		$pdf->SetTextColor(0,0,0);
1334
-		$pdf->SetFont('','',$default_font_size - 2);
1335
-
1336
-		if (empty($hidetop))
1337
-		{
1338
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1339
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1340
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1341
-
1342
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1343
-			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));
1344
-		}
1345
-
1346
-		$pdf->SetDrawColor(128,128,128);
1347
-		$pdf->SetFont('','',$default_font_size - 1);
1348
-
1349
-		// Output Rect
1350
-		$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
1351
-
1352
-		if (empty($hidetop))
1353
-		{
1354
-			$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
1355
-
1356
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1357
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1358
-		}
1359
-
1360
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1361
-		{
1362
-			$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1363
-			if (empty($hidetop))
1364
-			{
1365
-				//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
1366
-				//$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
1367
-			}
1368
-		}
1369
-
1370
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1371
-		{
1372
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1373
-			if (empty($hidetop))
1374
-			{
1375
-				// Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax'
1376
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1377
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1378
-			}
1379
-		}
1380
-
1381
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1382
-		if (empty($hidetop))
1383
-		{
1384
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1385
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1386
-		}
1387
-
1388
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1389
-		if (empty($hidetop))
1390
-		{
1391
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1392
-			if($conf->global->PRODUCT_USE_UNITS)
1393
-			{
1394
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1395
-			}
1396
-			else
1397
-			{
1398
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1399
-			}
1400
-		}
1401
-
1402
-		if($conf->global->PRODUCT_USE_UNITS) {
1403
-			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1404
-			if (empty($hidetop)) {
1405
-				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1406
-				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1407
-					'C');
1408
-			}
1409
-		}
1291
+            $index++;
1292
+            $pdf->SetTextColor(0,0,60);
1293
+            $pdf->SetFillColor(224,224,224);
1294
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1295
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1410 1296
 
1411
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1412
-		if (empty($hidetop))
1413
-		{
1414
-			if ($this->atleastonediscount)
1415
-			{
1416
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1417
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1418
-			}
1419
-		}
1420
-		if ($this->atleastonediscount)
1421
-		{
1422
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1423
-		}
1424
-		if (empty($hidetop))
1425
-		{
1426
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1427
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1428
-		}
1429
-	}
1430
-
1431
-	/**
1432
-	 *  Show top header of page.
1433
-	 *
1434
-	 *  @param	PDF			$pdf     		Object PDF
1435
-	 *  @param  Object		$object     	Object to show
1436
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1437
-	 *  @param  Translate	$outputlangs	Object lang for output
1438
-	 *  @return	void
1439
-	 */
1440
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1441
-	{
1442
-		global $conf,$langs;
1443
-
1444
-		// Load traductions files requiredby by page
1445
-		$outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1446
-
1447
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1448
-
1449
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1450
-
1451
-		//  Show Draft Watermark
1452
-		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1453
-		{
1454
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1455
-		}
1297
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1298
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1456 1299
 
1457
-		$pdf->SetTextColor(0,0,60);
1458
-		$pdf->SetFont('','B', $default_font_size + 3);
1300
+            $pdf->SetFont('','', $default_font_size - 1);
1301
+            $pdf->SetTextColor(0,0,0);
1302
+        }
1459 1303
 
1460
-		$posy=$this->marge_haute;
1461
-		$posx=$this->page_largeur-$this->marge_droite-100;
1304
+        $index++;
1305
+        return ($tab2_top + ($tab2_hl * $index));
1306
+    }
1462 1307
 
1463
-		$pdf->SetXY($this->marge_gauche,$posy);
1308
+    /**
1309
+     *   Show table for lines
1310
+     *
1311
+     *   @param		PDF			$pdf     		Object PDF
1312
+     *   @param		string		$tab_top		Top position of table
1313
+     *   @param		string		$tab_height		Height of table (rectangle)
1314
+     *   @param		int			$nexY			Y (not used)
1315
+     *   @param		Translate	$outputlangs	Langs object
1316
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1317
+     *   @param		int			$hidebottom		Hide bottom bar of array
1318
+     *   @param		string		$currency		Currency code
1319
+     *   @return	void
1320
+     */
1321
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1322
+    {
1323
+        global $conf;
1324
+
1325
+        // Force to disable hidetop and hidebottom
1326
+        $hidebottom=0;
1327
+        if ($hidetop) $hidetop=-1;
1328
+
1329
+        $currency = !empty($currency) ? $currency : $conf->currency;
1330
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1331
+
1332
+        // Amount in (at tab_top - 1)
1333
+        $pdf->SetTextColor(0,0,0);
1334
+        $pdf->SetFont('','',$default_font_size - 2);
1335
+
1336
+        if (empty($hidetop))
1337
+        {
1338
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1339
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1340
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1341
+
1342
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1343
+            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));
1344
+        }
1345
+
1346
+        $pdf->SetDrawColor(128,128,128);
1347
+        $pdf->SetFont('','',$default_font_size - 1);
1348
+
1349
+        // Output Rect
1350
+        $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
1351
+
1352
+        if (empty($hidetop))
1353
+        {
1354
+            $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
1355
+
1356
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1357
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1358
+        }
1359
+
1360
+        if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1361
+        {
1362
+            $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1363
+            if (empty($hidetop))
1364
+            {
1365
+                //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
1366
+                //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
1367
+            }
1368
+        }
1369
+
1370
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1371
+        {
1372
+            $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1373
+            if (empty($hidetop))
1374
+            {
1375
+                // Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax'
1376
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
1377
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1378
+            }
1379
+        }
1380
+
1381
+        $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1382
+        if (empty($hidetop))
1383
+        {
1384
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1385
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1386
+        }
1387
+
1388
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1389
+        if (empty($hidetop))
1390
+        {
1391
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1392
+            if($conf->global->PRODUCT_USE_UNITS)
1393
+            {
1394
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1395
+            }
1396
+            else
1397
+            {
1398
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1399
+            }
1400
+        }
1401
+
1402
+        if($conf->global->PRODUCT_USE_UNITS) {
1403
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1404
+            if (empty($hidetop)) {
1405
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1406
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1407
+                    'C');
1408
+            }
1409
+        }
1410
+
1411
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1412
+        if (empty($hidetop))
1413
+        {
1414
+            if ($this->atleastonediscount)
1415
+            {
1416
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1417
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1418
+            }
1419
+        }
1420
+        if ($this->atleastonediscount)
1421
+        {
1422
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1423
+        }
1424
+        if (empty($hidetop))
1425
+        {
1426
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1427
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1428
+        }
1429
+    }
1464 1430
 
1465
-		// Logo
1466
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1467
-		{
1468
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1469
-			if ($this->emetteur->logo)
1470
-			{
1471
-				if (is_readable($logo))
1472
-				{
1473
-				    $height=pdf_getHeightForLogo($logo);
1474
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1475
-				}
1476
-				else
1477
-				{
1478
-					$pdf->SetTextColor(200,0,0);
1479
-					$pdf->SetFont('','B',$default_font_size - 2);
1480
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1481
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1482
-				}
1483
-			}
1484
-			else
1485
-			{
1486
-				$text=$this->emetteur->name;
1487
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1488
-			}
1489
-		}
1490
-
1491
-		$pdf->SetFont('','B',$default_font_size + 3);
1492
-		$pdf->SetXY($posx,$posy);
1493
-		$pdf->SetTextColor(0,0,60);
1494
-		$title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1495
-		$pdf->MultiCell(100, 4, $title, '', 'R');
1496
-
1497
-		$pdf->SetFont('','B',$default_font_size);
1498
-
1499
-		$posy+=5;
1500
-		$pdf->SetXY($posx,$posy);
1501
-		$pdf->SetTextColor(0,0,60);
1502
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1503
-
1504
-		$posy+=1;
1505
-		$pdf->SetFont('','', $default_font_size - 2);
1506
-
1507
-		if ($object->ref_client)
1508
-		{
1509
-			$posy+=4;
1510
-			$pdf->SetXY($posx,$posy);
1511
-			$pdf->SetTextColor(0,0,60);
1512
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1513
-		}
1514
-
1515
-		$posy+=4;
1516
-		$pdf->SetXY($posx,$posy);
1517
-		$pdf->SetTextColor(0,0,60);
1518
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1519
-
1520
-		$posy+=4;
1521
-		$pdf->SetXY($posx,$posy);
1522
-		$pdf->SetTextColor(0,0,60);
1523
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1524
-
1525
-		if ($object->thirdparty->code_client)
1526
-		{
1527
-			$posy+=4;
1528
-			$pdf->SetXY($posx,$posy);
1529
-			$pdf->SetTextColor(0,0,60);
1530
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1531
-		}
1532
-
1533
-		// Get contact
1534
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1535
-		{
1536
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1537
-		    if (count($arrayidcontact) > 0)
1538
-		    {
1539
-		        $usertmp=new User($this->db);
1540
-		        $usertmp->fetch($arrayidcontact[0]);
1541
-                $posy+=4;
1542
-                $pdf->SetXY($posx,$posy);
1543
-		        $pdf->SetTextColor(0,0,60);
1544
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1545
-		    }
1546
-		}
1547
-
1548
-		$posy+=2;
1549
-
1550
-		$top_shift = 0;
1551
-		// Show list of linked objects
1552
-		$current_y = $pdf->getY();
1553
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1554
-		if ($current_y < $pdf->getY())
1555
-		{
1556
-			$top_shift = $pdf->getY() - $current_y;
1557
-		}
1558
-
1559
-		if ($showaddress)
1560
-		{
1561
-			// Sender properties
1562
-			$carac_emetteur='';
1563
-		 	// Add internal contact of proposal if defined
1564
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1565
-		 	if (count($arrayidcontact) > 0)
1566
-		 	{
1567
-		 		$object->fetch_user($arrayidcontact[0]);
1568
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1569
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1570
-		 	}
1571
-
1572
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1573
-
1574
-			// Show sender
1575
-			$posy=42+$top_shift;
1576
-		 	$posx=$this->marge_gauche;
1577
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1578
-			$hautcadre=40;
1579
-
1580
-			// Show sender frame
1581
-			$pdf->SetTextColor(0,0,0);
1582
-			$pdf->SetFont('','', $default_font_size - 2);
1583
-			$pdf->SetXY($posx,$posy-5);
1584
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1585
-			$pdf->SetXY($posx,$posy);
1586
-			$pdf->SetFillColor(230,230,230);
1587
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1588
-			$pdf->SetTextColor(0,0,60);
1589
-
1590
-			// Show sender name
1591
-			$pdf->SetXY($posx+2,$posy+3);
1592
-			$pdf->SetFont('','B', $default_font_size);
1593
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1594
-			$posy=$pdf->getY();
1595
-
1596
-			// Show sender information
1597
-			$pdf->SetXY($posx+2,$posy);
1598
-			$pdf->SetFont('','', $default_font_size - 1);
1599
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1600
-
1601
-
1602
-			// If CUSTOMER contact defined, we use it
1603
-			$usecontact=false;
1604
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1605
-			if (count($arrayidcontact) > 0)
1606
-			{
1607
-				$usecontact=true;
1608
-				$result=$object->fetch_contact($arrayidcontact[0]);
1609
-			}
1431
+    /**
1432
+     *  Show top header of page.
1433
+     *
1434
+     *  @param	PDF			$pdf     		Object PDF
1435
+     *  @param  Object		$object     	Object to show
1436
+     *  @param  int	    	$showaddress    0=no, 1=yes
1437
+     *  @param  Translate	$outputlangs	Object lang for output
1438
+     *  @return	void
1439
+     */
1440
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1441
+    {
1442
+        global $conf,$langs;
1610 1443
 
1611
-			//Recipient name
1612
-			// On peut utiliser le nom de la societe du contact
1613
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1614
-				$thirdparty = $object->contact;
1615
-			} else {
1616
-				$thirdparty = $object->thirdparty;
1617
-			}
1444
+        // Load traductions files requiredby by page
1445
+        $outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1618 1446
 
1619
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1447
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1620 1448
 
1621
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1449
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1622 1450
 
1623
-			// Show recipient
1624
-			$widthrecbox=100;
1625
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1626
-			$posy=42+$top_shift;
1627
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1628
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1451
+        //  Show Draft Watermark
1452
+        if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1453
+        {
1454
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1455
+        }
1629 1456
 
1630
-			// Show recipient frame
1631
-			$pdf->SetTextColor(0,0,0);
1632
-			$pdf->SetFont('','', $default_font_size - 2);
1633
-			$pdf->SetXY($posx+2,$posy-5);
1634
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1635
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1457
+        $pdf->SetTextColor(0,0,60);
1458
+        $pdf->SetFont('','B', $default_font_size + 3);
1636 1459
 
1637
-			// Show recipient name
1638
-			$pdf->SetXY($posx+2,$posy+3);
1639
-			$pdf->SetFont('','B', $default_font_size);
1640
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1460
+        $posy=$this->marge_haute;
1461
+        $posx=$this->page_largeur-$this->marge_droite-100;
1641 1462
 
1642
-			$posy = $pdf->getY();
1463
+        $pdf->SetXY($this->marge_gauche,$posy);
1643 1464
 
1644
-			// Show recipient information
1645
-			$pdf->SetFont('','', $default_font_size - 1);
1646
-			$pdf->SetXY($posx+2,$posy);
1647
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1648
-		}
1465
+        // Logo
1466
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1467
+        {
1468
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1469
+            if ($this->emetteur->logo)
1470
+            {
1471
+                if (is_readable($logo))
1472
+                {
1473
+                    $height=pdf_getHeightForLogo($logo);
1474
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1475
+                }
1476
+                else
1477
+                {
1478
+                    $pdf->SetTextColor(200,0,0);
1479
+                    $pdf->SetFont('','B',$default_font_size - 2);
1480
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1481
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1482
+                }
1483
+            }
1484
+            else
1485
+            {
1486
+                $text=$this->emetteur->name;
1487
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1488
+            }
1489
+        }
1490
+
1491
+        $pdf->SetFont('','B',$default_font_size + 3);
1492
+        $pdf->SetXY($posx,$posy);
1493
+        $pdf->SetTextColor(0,0,60);
1494
+        $title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1495
+        $pdf->MultiCell(100, 4, $title, '', 'R');
1496
+
1497
+        $pdf->SetFont('','B',$default_font_size);
1498
+
1499
+        $posy+=5;
1500
+        $pdf->SetXY($posx,$posy);
1501
+        $pdf->SetTextColor(0,0,60);
1502
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1503
+
1504
+        $posy+=1;
1505
+        $pdf->SetFont('','', $default_font_size - 2);
1506
+
1507
+        if ($object->ref_client)
1508
+        {
1509
+            $posy+=4;
1510
+            $pdf->SetXY($posx,$posy);
1511
+            $pdf->SetTextColor(0,0,60);
1512
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1513
+        }
1514
+
1515
+        $posy+=4;
1516
+        $pdf->SetXY($posx,$posy);
1517
+        $pdf->SetTextColor(0,0,60);
1518
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1519
+
1520
+        $posy+=4;
1521
+        $pdf->SetXY($posx,$posy);
1522
+        $pdf->SetTextColor(0,0,60);
1523
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1524
+
1525
+        if ($object->thirdparty->code_client)
1526
+        {
1527
+            $posy+=4;
1528
+            $pdf->SetXY($posx,$posy);
1529
+            $pdf->SetTextColor(0,0,60);
1530
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1531
+        }
1532
+
1533
+        // Get contact
1534
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1535
+        {
1536
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1537
+            if (count($arrayidcontact) > 0)
1538
+            {
1539
+                $usertmp=new User($this->db);
1540
+                $usertmp->fetch($arrayidcontact[0]);
1541
+                $posy+=4;
1542
+                $pdf->SetXY($posx,$posy);
1543
+                $pdf->SetTextColor(0,0,60);
1544
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1545
+            }
1546
+        }
1547
+
1548
+        $posy+=2;
1549
+
1550
+        $top_shift = 0;
1551
+        // Show list of linked objects
1552
+        $current_y = $pdf->getY();
1553
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1554
+        if ($current_y < $pdf->getY())
1555
+        {
1556
+            $top_shift = $pdf->getY() - $current_y;
1557
+        }
1558
+
1559
+        if ($showaddress)
1560
+        {
1561
+            // Sender properties
1562
+            $carac_emetteur='';
1563
+                // Add internal contact of proposal if defined
1564
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1565
+                if (count($arrayidcontact) > 0)
1566
+                {
1567
+                    $object->fetch_user($arrayidcontact[0]);
1568
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1569
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1570
+                }
1649 1571
 
1650
-		$pdf->SetTextColor(0,0,0);
1651
-		return $top_shift;
1652
-	}
1572
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1573
+
1574
+            // Show sender
1575
+            $posy=42+$top_shift;
1576
+                $posx=$this->marge_gauche;
1577
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1578
+            $hautcadre=40;
1579
+
1580
+            // Show sender frame
1581
+            $pdf->SetTextColor(0,0,0);
1582
+            $pdf->SetFont('','', $default_font_size - 2);
1583
+            $pdf->SetXY($posx,$posy-5);
1584
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1585
+            $pdf->SetXY($posx,$posy);
1586
+            $pdf->SetFillColor(230,230,230);
1587
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1588
+            $pdf->SetTextColor(0,0,60);
1589
+
1590
+            // Show sender name
1591
+            $pdf->SetXY($posx+2,$posy+3);
1592
+            $pdf->SetFont('','B', $default_font_size);
1593
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1594
+            $posy=$pdf->getY();
1595
+
1596
+            // Show sender information
1597
+            $pdf->SetXY($posx+2,$posy);
1598
+            $pdf->SetFont('','', $default_font_size - 1);
1599
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1600
+
1601
+
1602
+            // If CUSTOMER contact defined, we use it
1603
+            $usecontact=false;
1604
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1605
+            if (count($arrayidcontact) > 0)
1606
+            {
1607
+                $usecontact=true;
1608
+                $result=$object->fetch_contact($arrayidcontact[0]);
1609
+            }
1610
+
1611
+            //Recipient name
1612
+            // On peut utiliser le nom de la societe du contact
1613
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1614
+                $thirdparty = $object->contact;
1615
+            } else {
1616
+                $thirdparty = $object->thirdparty;
1617
+            }
1618
+
1619
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1620
+
1621
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1622
+
1623
+            // Show recipient
1624
+            $widthrecbox=100;
1625
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1626
+            $posy=42+$top_shift;
1627
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1628
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1629
+
1630
+            // Show recipient frame
1631
+            $pdf->SetTextColor(0,0,0);
1632
+            $pdf->SetFont('','', $default_font_size - 2);
1633
+            $pdf->SetXY($posx+2,$posy-5);
1634
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1635
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1636
+
1637
+            // Show recipient name
1638
+            $pdf->SetXY($posx+2,$posy+3);
1639
+            $pdf->SetFont('','B', $default_font_size);
1640
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1641
+
1642
+            $posy = $pdf->getY();
1643
+
1644
+            // Show recipient information
1645
+            $pdf->SetFont('','', $default_font_size - 1);
1646
+            $pdf->SetXY($posx+2,$posy);
1647
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1648
+        }
1649
+
1650
+        $pdf->SetTextColor(0,0,0);
1651
+        return $top_shift;
1652
+    }
1653 1653
 
1654
-	/**
1655
-	 *   	Show footer of page. Need this->emetteur object
1654
+    /**
1655
+     *   	Show footer of page. Need this->emetteur object
1656 1656
      *
1657
-	 *   	@param	PDF			$pdf     			PDF
1658
-	 * 		@param	Object		$object				Object to show
1659
-	 *      @param	Translate	$outputlangs		Object lang for output
1660
-	 *      @param	int			$hidefreetext		1=Hide free text
1661
-	 *      @return	int								Return height of bottom margin including footer text
1662
-	 */
1663
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1664
-	{
1665
-		global $conf;
1666
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1667
-		return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1668
-	}
1657
+     *   	@param	PDF			$pdf     			PDF
1658
+     * 		@param	Object		$object				Object to show
1659
+     *      @param	Translate	$outputlangs		Object lang for output
1660
+     *      @param	int			$hidefreetext		1=Hide free text
1661
+     *      @return	int								Return height of bottom margin including footer text
1662
+     */
1663
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1664
+    {
1665
+        global $conf;
1666
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1667
+        return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1668
+    }
1669 1669
 
1670 1670
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1671
-	/**
1672
-	 *	Show area for the customer to sign
1673
-	 *
1674
-	 *	@param	PDF			$pdf            Object PDF
1675
-	 *	@param  Facture		$object         Object invoice
1676
-	 *	@param	int			$posy			Position depart
1677
-	 *	@param	Translate	$outputlangs	Objet langs
1678
-	 *	@return int							Position pour suite
1679
-	 */
1680
-	function _signature_area(&$pdf, $object, $posy, $outputlangs)
1681
-	{
1671
+    /**
1672
+     *	Show area for the customer to sign
1673
+     *
1674
+     *	@param	PDF			$pdf            Object PDF
1675
+     *	@param  Facture		$object         Object invoice
1676
+     *	@param	int			$posy			Position depart
1677
+     *	@param	Translate	$outputlangs	Objet langs
1678
+     *	@return int							Position pour suite
1679
+     */
1680
+    function _signature_area(&$pdf, $object, $posy, $outputlangs)
1681
+    {
1682 1682
         // phpcs:enable
1683
-		global $conf;
1684
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1685
-		$tab_top = $posy + 4;
1686
-		$tab_hl = 4;
1687
-
1688
-		$posx = 120;
1689
-		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
1690
-		$useborder=0;
1691
-		$index = 0;
1692
-		// Total HT
1693
-		$pdf->SetFillColor(255,255,255);
1694
-		$pdf->SetXY($posx, $tab_top + 0);
1695
-		$pdf->SetFont('','', $default_font_size - 2);
1696
-		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1697
-
1698
-		$pdf->SetXY($posx, $tab_top + $tab_hl);
1699
-		$pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1700
-		if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1701
-			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1702
-		}
1703
-
1704
-		return ($tab_hl*7);
1705
-	}
1683
+        global $conf;
1684
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1685
+        $tab_top = $posy + 4;
1686
+        $tab_hl = 4;
1687
+
1688
+        $posx = 120;
1689
+        $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1690
+        $useborder=0;
1691
+        $index = 0;
1692
+        // Total HT
1693
+        $pdf->SetFillColor(255,255,255);
1694
+        $pdf->SetXY($posx, $tab_top + 0);
1695
+        $pdf->SetFont('','', $default_font_size - 2);
1696
+        $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1697
+
1698
+        $pdf->SetXY($posx, $tab_top + $tab_hl);
1699
+        $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1700
+        if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1701
+            $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1702
+        }
1703
+
1704
+        return ($tab_hl*7);
1705
+    }
1706 1706
 }
Please login to merge, or discard this patch.
Spacing   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	function __construct($db)
129 129
 	{
130
-		global $conf,$langs,$mysoc;
130
+		global $conf, $langs, $mysoc;
131 131
 
132 132
 		// Translations
133 133
 		$langs->loadLangs(array("main", "bills"));
@@ -135,71 +135,71 @@  discard block
 block discarded – undo
135 135
 		$this->db = $db;
136 136
 		$this->name = "azur";
137 137
 		$this->description = $langs->trans('DocModelAzurDescription');
138
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
138
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
139 139
 
140 140
 		// Dimension page
141 141
 		$this->type = 'pdf';
142
-		$formatarray=pdf_getFormat();
142
+		$formatarray = pdf_getFormat();
143 143
 		$this->page_largeur = $formatarray['width'];
144 144
 		$this->page_hauteur = $formatarray['height'];
145
-		$this->format = array($this->page_largeur,$this->page_hauteur);
146
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
147
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
148
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
149
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
150
-
151
-		$this->option_logo = 1;                    // Affiche logo
152
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
153
-		$this->option_modereg = 1;                 // Affiche mode reglement
154
-		$this->option_condreg = 1;                 // Affiche conditions reglement
155
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
156
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
157
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
158
-		$this->option_credit_note = 0;             // Support credit notes
159
-		$this->option_freetext = 1;				   // Support add of a personalised text
160
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
161
-
162
-		$this->franchise=!$mysoc->tva_assuj;
145
+		$this->format = array($this->page_largeur, $this->page_hauteur);
146
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
147
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
148
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
149
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
150
+
151
+		$this->option_logo = 1; // Affiche logo
152
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
153
+		$this->option_modereg = 1; // Affiche mode reglement
154
+		$this->option_condreg = 1; // Affiche conditions reglement
155
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
156
+		$this->option_multilang = 1; // Dispo en plusieurs langues
157
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
158
+		$this->option_credit_note = 0; // Support credit notes
159
+		$this->option_freetext = 1; // Support add of a personalised text
160
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
161
+
162
+		$this->franchise = !$mysoc->tva_assuj;
163 163
 
164 164
 		// Get source company
165
-		$this->emetteur=$mysoc;
166
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
165
+		$this->emetteur = $mysoc;
166
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
167 167
 
168 168
 		// Define position of columns
169
-		$this->posxdesc=$this->marge_gauche+1;
170
-		if($conf->global->PRODUCT_USE_UNITS)
169
+		$this->posxdesc = $this->marge_gauche + 1;
170
+		if ($conf->global->PRODUCT_USE_UNITS)
171 171
 		{
172
-			$this->posxtva=101;
173
-			$this->posxup=118;
174
-			$this->posxqty=135;
175
-			$this->posxunit=151;
172
+			$this->posxtva = 101;
173
+			$this->posxup = 118;
174
+			$this->posxqty = 135;
175
+			$this->posxunit = 151;
176 176
 		}
177 177
 		else
178 178
 		{
179
-			$this->posxtva=110;
180
-			$this->posxup=126;
181
-			$this->posxqty=145;
179
+			$this->posxtva = 110;
180
+			$this->posxup = 126;
181
+			$this->posxqty = 145;
182 182
 		}
183
-		$this->posxdiscount=162;
184
-		$this->postotalht=174;
185
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
186
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
183
+		$this->posxdiscount = 162;
184
+		$this->postotalht = 174;
185
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
186
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
187 187
 		if ($this->page_largeur < 210) // To work with US executive format
188 188
 		{
189
-			$this->posxpicture-=20;
190
-			$this->posxtva-=20;
191
-			$this->posxup-=20;
192
-			$this->posxqty-=20;
193
-			$this->posxunit-=20;
194
-			$this->posxdiscount-=20;
195
-			$this->postotalht-=20;
189
+			$this->posxpicture -= 20;
190
+			$this->posxtva -= 20;
191
+			$this->posxup -= 20;
192
+			$this->posxqty -= 20;
193
+			$this->posxunit -= 20;
194
+			$this->posxdiscount -= 20;
195
+			$this->postotalht -= 20;
196 196
 		}
197 197
 
198
-		$this->tva=array();
199
-		$this->localtax1=array();
200
-		$this->localtax2=array();
201
-		$this->atleastoneratenotnull=0;
202
-		$this->atleastonediscount=0;
198
+		$this->tva = array();
199
+		$this->localtax1 = array();
200
+		$this->localtax2 = array();
201
+		$this->atleastoneratenotnull = 0;
202
+		$this->atleastonediscount = 0;
203 203
 	}
204 204
 
205 205
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
      *  @param		int			$hideref			Do not show ref
215 215
      *  @return     int             				1=OK, 0=KO
216 216
 	 */
217
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
217
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
218 218
 	{
219 219
         // phpcs:enable
220
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
220
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
221 221
 
222
-		if (! is_object($outputlangs)) $outputlangs=$langs;
222
+		if (!is_object($outputlangs)) $outputlangs = $langs;
223 223
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
224
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
224
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
225 225
 
226 226
 		// Load traductions files requiredby by page
227 227
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products"));
@@ -229,51 +229,51 @@  discard block
 block discarded – undo
229 229
 		$nblignes = count($object->lines);
230 230
 
231 231
 		// Loop on each lines to detect if there is at least one image to show
232
-		$realpatharray=array();
233
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
232
+		$realpatharray = array();
233
+		if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
234 234
 		{
235 235
 			$objphoto = new Product($this->db);
236 236
 
237
-			for ($i = 0 ; $i < $nblignes ; $i++)
237
+			for ($i = 0; $i < $nblignes; $i++)
238 238
 			{
239 239
 				if (empty($object->lines[$i]->fk_product)) continue;
240 240
 
241 241
 				$objphoto->fetch($object->lines[$i]->fk_product);
242 242
                 //var_dump($objphoto->ref);exit;
243
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
243
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
244 244
 				{
245
-					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
246
-					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
245
+					$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
246
+					$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
247 247
 				}
248 248
 				else
249 249
 				{
250
-					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
251
-					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
250
+					$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
251
+					$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
252 252
 				}
253 253
 
254 254
 				$arephoto = false;
255 255
 				foreach ($pdir as $midir)
256 256
 				{
257
-					if (! $arephoto)
257
+					if (!$arephoto)
258 258
 					{
259 259
 						$dir = $conf->product->dir_output.'/'.$midir;
260 260
 
261
-						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
261
+						foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
262 262
 						{
263 263
 							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
264 264
 							{
265 265
 								if ($obj['photo_vignette'])
266 266
 								{
267
-									$filename= $obj['photo_vignette'];
267
+									$filename = $obj['photo_vignette'];
268 268
 								}
269 269
 								else
270 270
 								{
271
-									$filename=$obj['photo'];
271
+									$filename = $obj['photo'];
272 272
 								}
273 273
 							}
274 274
 							else
275 275
 							{
276
-								$filename=$obj['photo'];
276
+								$filename = $obj['photo'];
277 277
 							}
278 278
 
279 279
 							$realpath = $dir.$filename;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 					}
283 283
 				}
284 284
 
285
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
285
+				if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
286 286
 			}
287 287
 		}
288 288
 
289
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
289
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
290 290
 
291 291
 		if ($conf->propal->multidir_output[$conf->entity])
292 292
 		{
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 			if ($object->specimen)
299 299
 			{
300 300
 				$dir = $conf->propal->multidir_output[$conf->entity];
301
-				$file = $dir . "/SPECIMEN.pdf";
301
+				$file = $dir."/SPECIMEN.pdf";
302 302
 			}
303 303
 			else
304 304
 			{
305 305
 				$objectref = dol_sanitizeFileName($object->ref);
306
-				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
307
-				$file = $dir . "/" . $objectref . ".pdf";
306
+				$dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
307
+				$file = $dir."/".$objectref.".pdf";
308 308
 			}
309 309
 
310
-			if (! file_exists($dir))
310
+			if (!file_exists($dir))
311 311
 			{
312 312
 				if (dol_mkdir($dir) < 0)
313 313
 				{
314
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
314
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
315 315
 					return 0;
316 316
 				}
317 317
 			}
@@ -319,20 +319,20 @@  discard block
 block discarded – undo
319 319
 			if (file_exists($dir))
320 320
 			{
321 321
 				// Add pdfgeneration hook
322
-				if (! is_object($hookmanager))
322
+				if (!is_object($hookmanager))
323 323
 				{
324 324
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
325
-					$hookmanager=new HookManager($this->db);
325
+					$hookmanager = new HookManager($this->db);
326 326
 				}
327 327
 				$hookmanager->initHooks(array('pdfgeneration'));
328
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
328
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
329 329
 				global $action;
330
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
330
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
331 331
 
332 332
 				// Create pdf instance
333
-                $pdf=pdf_getInstance($this->format);
334
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
335
-	            $pdf->SetAutoPageBreak(1,0);
333
+                $pdf = pdf_getInstance($this->format);
334
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
335
+	            $pdf->SetAutoPageBreak(1, 0);
336 336
 
337 337
                 if (class_exists('TCPDF'))
338 338
                 {
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
                 }
342 342
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
343 343
                 // Set path to the background PDF File
344
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
344
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
345 345
                 {
346 346
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
347 347
                     $tplidx = $pdf->importPage(1);
348 348
                 }
349 349
 
350 350
 				$pdf->Open();
351
-				$pagenb=0;
352
-				$pdf->SetDrawColor(128,128,128);
351
+				$pagenb = 0;
352
+				$pdf->SetDrawColor(128, 128, 128);
353 353
 
354 354
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
355 355
 				$pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
356 356
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
357 357
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
358 358
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
359
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
359
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
360 360
 
361
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
361
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
362 362
 
363 363
 				// Positionne $this->atleastonediscount si on a au moins une remise
364
-				for ($i = 0 ; $i < $nblignes ; $i++)
364
+				for ($i = 0; $i < $nblignes; $i++)
365 365
 				{
366 366
 					if ($object->lines[$i]->remise_percent)
367 367
 					{
@@ -370,34 +370,34 @@  discard block
 block discarded – undo
370 370
 				}
371 371
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
372 372
 				{
373
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
374
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
375
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
376
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
377
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
373
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
374
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
375
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
376
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
377
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
378 378
 					//$this->postotalht;
379 379
 				}
380 380
 
381 381
 				// New page
382 382
 				$pdf->AddPage();
383
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
383
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
384 384
 				$pagenb++;
385 385
 
386
-                $heightforinfotot = 40;	// Height reserved to output the info and total part
387
-                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
388
-                $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
389
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
390
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
386
+                $heightforinfotot = 40; // Height reserved to output the info and total part
387
+                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
388
+                $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
389
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
390
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
391 391
                 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
392 392
 
393 393
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
394
-				$pdf->SetFont('','', $default_font_size - 1);
395
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
396
-				$pdf->SetTextColor(0,0,0);
394
+				$pdf->SetFont('', '', $default_font_size - 1);
395
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
396
+				$pdf->SetTextColor(0, 0, 0);
397 397
 
398 398
 
399
-	            $tab_top = 90+$top_shift;
400
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
399
+	            $tab_top = 90 + $top_shift;
400
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
401 401
 
402 402
 				// Incoterm
403 403
 				if ($conf->incoterm->enabled)
@@ -407,58 +407,58 @@  discard block
 block discarded – undo
407 407
 					{
408 408
 						$tab_top -= 2;
409 409
 
410
-						$pdf->SetFont('','', $default_font_size - 1);
411
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
410
+						$pdf->SetFont('', '', $default_font_size - 1);
411
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
412 412
 						$nexY = $pdf->GetY();
413
-						$height_incoterms=$nexY-$tab_top;
413
+						$height_incoterms = $nexY - $tab_top;
414 414
 
415 415
 						// Rect prend une longueur en 3eme param
416
-						$pdf->SetDrawColor(192,192,192);
417
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
416
+						$pdf->SetDrawColor(192, 192, 192);
417
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
418 418
 
419
-						$tab_top = $nexY+6;
419
+						$tab_top = $nexY + 6;
420 420
 					}
421 421
 				}
422 422
 
423 423
 				// Affiche notes
424
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
425
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
424
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
425
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
426 426
 				{
427 427
 					// Get first sale rep
428 428
 					if (is_object($object->thirdparty))
429 429
 					{
430
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
431
-						$salerepobj=new User($this->db);
430
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
431
+						$salerepobj = new User($this->db);
432 432
 						$salerepobj->fetch($salereparray[0]['id']);
433
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
433
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
434 434
 					}
435 435
 				}
436
-				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
436
+				if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
437 437
 				{
438
-				    $tmpuser=new User($this->db);
438
+				    $tmpuser = new User($this->db);
439 439
 				    $tmpuser->fetch($object->user_author_id);
440
-				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
441
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
442
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
440
+				    $notetoshow .= 'Affaire suivi par '.$tmpuser->getFullName($langs);
441
+				    if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
442
+				    if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
443 443
 				}
444 444
 				if ($notetoshow)
445 445
 				{
446 446
 					$tab_top -= 2;
447 447
 
448
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
448
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
449 449
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
450 450
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
451 451
 
452
-					$pdf->SetFont('','', $default_font_size - 1);
453
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
452
+					$pdf->SetFont('', '', $default_font_size - 1);
453
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
454 454
 					$nexY = $pdf->GetY();
455
-					$height_note=$nexY-$tab_top;
455
+					$height_note = $nexY - $tab_top;
456 456
 
457 457
 					// Rect prend une longueur en 3eme param
458
-					$pdf->SetDrawColor(192,192,192);
459
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
458
+					$pdf->SetDrawColor(192, 192, 192);
459
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
460 460
 
461
-					$tab_top = $nexY+6;
461
+					$tab_top = $nexY + 6;
462 462
 				}
463 463
 
464 464
 				$iniY = $tab_top + 7;
@@ -469,191 +469,191 @@  discard block
 block discarded – undo
469 469
 				for ($i = 0; $i < $nblignes; $i++)
470 470
 				{
471 471
 					$curY = $nexY;
472
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
473
-					$pdf->SetTextColor(0,0,0);
472
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
473
+					$pdf->SetTextColor(0, 0, 0);
474 474
 
475 475
 					// Define size of image if we need it
476
-					$imglinesize=array();
477
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
476
+					$imglinesize = array();
477
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
478 478
 
479 479
 					$pdf->setTopMargin($tab_top_newpage);
480
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
481
-					$pageposbefore=$pdf->getPage();
480
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
481
+					$pageposbefore = $pdf->getPage();
482 482
 
483
-					$showpricebeforepagebreak=1;
484
-					$posYAfterImage=0;
485
-					$posYAfterDescription=0;
483
+					$showpricebeforepagebreak = 1;
484
+					$posYAfterImage = 0;
485
+					$posYAfterDescription = 0;
486 486
 
487 487
 					// We start with Photo of product line
488
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
488
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
489 489
 					{
490
-						$pdf->AddPage('','',true);
491
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
490
+						$pdf->AddPage('', '', true);
491
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
492 492
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
493
-						$pdf->setPage($pageposbefore+1);
493
+						$pdf->setPage($pageposbefore + 1);
494 494
 
495 495
 						$curY = $tab_top_newpage;
496
-						$showpricebeforepagebreak=0;
496
+						$showpricebeforepagebreak = 0;
497 497
 					}
498 498
 
499 499
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
500 500
 					{
501
-						$curX = $this->posxpicture-1;
502
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
501
+						$curX = $this->posxpicture - 1;
502
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
503 503
 						// $pdf->Image does not increase value return by getY, so we save it manually
504
-						$posYAfterImage=$curY+$imglinesize['height'];
504
+						$posYAfterImage = $curY + $imglinesize['height'];
505 505
 					}
506 506
 
507 507
 					// Description of product line
508
-					$curX = $this->posxdesc-1;
508
+					$curX = $this->posxdesc - 1;
509 509
 
510 510
 					$pdf->startTransaction();
511
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
512
-					$pageposafter=$pdf->getPage();
511
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
512
+					$pageposafter = $pdf->getPage();
513 513
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
514 514
 					{
515 515
 						$pdf->rollbackTransaction(true);
516
-						$pageposafter=$pageposbefore;
516
+						$pageposafter = $pageposbefore;
517 517
 						//print $pageposafter.'-'.$pageposbefore;exit;
518
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
519
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
518
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
519
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
520 520
 
521
-						$pageposafter=$pdf->getPage();
522
-						$posyafter=$pdf->GetY();
521
+						$pageposafter = $pdf->getPage();
522
+						$posyafter = $pdf->GetY();
523 523
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
524
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
524
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
525 525
 						{
526
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
526
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
527 527
 							{
528
-								$pdf->AddPage('','',true);
529
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
528
+								$pdf->AddPage('', '', true);
529
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
530 530
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
-								$pdf->setPage($pageposafter+1);
531
+								$pdf->setPage($pageposafter + 1);
532 532
 							}
533 533
 						}
534 534
 						else
535 535
 						{
536 536
 							// We found a page break
537
-							$showpricebeforepagebreak=0;
537
+							$showpricebeforepagebreak = 0;
538 538
 						}
539 539
 					}
540 540
 					else	// No pagebreak
541 541
 					{
542 542
 						$pdf->commitTransaction();
543 543
 					}
544
-					$posYAfterDescription=$pdf->GetY();
544
+					$posYAfterDescription = $pdf->GetY();
545 545
 
546 546
 					$nexY = $pdf->GetY();
547
-					$pageposafter=$pdf->getPage();
547
+					$pageposafter = $pdf->getPage();
548 548
 
549 549
 					$pdf->setPage($pageposbefore);
550 550
 					$pdf->setTopMargin($this->marge_haute);
551
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
551
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
552 552
 
553 553
 					// We suppose that a too long description or photo were moved completely on next page
554 554
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
555 555
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
556 556
 					}
557 557
 
558
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
558
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
559 559
 
560 560
 					// VAT Rate
561 561
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
562 562
 					{
563 563
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
564
-						$pdf->SetXY($this->posxtva-5, $curY);
565
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
564
+						$pdf->SetXY($this->posxtva - 5, $curY);
565
+						$pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
566 566
 					}
567 567
 
568 568
 					// Unit price before discount
569 569
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
570 570
 					$pdf->SetXY($this->posxup, $curY);
571
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
571
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
572 572
 
573 573
 					// Quantity
574 574
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
575 575
 					$pdf->SetXY($this->posxqty, $curY);
576 576
 					// Enough for 6 chars
577
-					if($conf->global->PRODUCT_USE_UNITS)
577
+					if ($conf->global->PRODUCT_USE_UNITS)
578 578
 					{
579
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
579
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
580 580
 					}
581 581
 					else
582 582
 					{
583
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
583
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
584 584
 					}
585 585
 
586 586
 					// Unit
587
-					if($conf->global->PRODUCT_USE_UNITS)
587
+					if ($conf->global->PRODUCT_USE_UNITS)
588 588
 					{
589 589
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
590 590
 						$pdf->SetXY($this->posxunit, $curY);
591
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
591
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
592 592
 					}
593 593
 
594 594
 					// Discount on line
595 595
 					$pdf->SetXY($this->posxdiscount, $curY);
596 596
 					if ($object->lines[$i]->remise_percent)
597 597
 					{
598
-						$pdf->SetXY($this->posxdiscount-2, $curY);
598
+						$pdf->SetXY($this->posxdiscount - 2, $curY);
599 599
 						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
600
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
600
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
601 601
 					}
602 602
 
603 603
 					// Total HT line
604 604
 					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
605 605
 					$pdf->SetXY($this->postotalht, $curY);
606
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
606
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
607 607
 
608 608
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
609
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
610
-					else $tvaligne=$object->lines[$i]->total_tva;
609
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
610
+					else $tvaligne = $object->lines[$i]->total_tva;
611 611
 
612
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
613
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
614
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
615
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
616
-					$localtax1_type=$object->lines[$i]->localtax1_type;
617
-					$localtax2_type=$object->lines[$i]->localtax2_type;
612
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
613
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
614
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
615
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
616
+					$localtax1_type = $object->lines[$i]->localtax1_type;
617
+					$localtax2_type = $object->lines[$i]->localtax2_type;
618 618
 
619
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
620
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
619
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
620
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
621
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
622 622
 
623
-					$vatrate=(string) $object->lines[$i]->tva_tx;
623
+					$vatrate = (string) $object->lines[$i]->tva_tx;
624 624
 
625 625
 					// Retrieve type from database for backward compatibility with old records
626
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
627
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
626
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
627
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
628 628
 					{
629
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
629
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
630 630
 						$localtax1_type = $localtaxtmp_array[0];
631 631
 						$localtax2_type = $localtaxtmp_array[2];
632 632
 					}
633 633
 
634 634
 				    // retrieve global local tax
635 635
 					if ($localtax1_type && $localtax1ligne != 0)
636
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
636
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
637 637
 					if ($localtax2_type && $localtax2ligne != 0)
638
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
638
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
639 639
 
640
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
641
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
640
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
641
+					if (!isset($this->tva[$vatrate]))				$this->tva[$vatrate] = 0;
642 642
 					$this->tva[$vatrate] += $tvaligne;
643 643
 
644
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
644
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
645 645
 
646 646
 					// Add line
647
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
647
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
648 648
 					{
649 649
 						$pdf->setPage($pageposafter);
650
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
650
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
651 651
 						//$pdf->SetDrawColor(190,190,200);
652
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
652
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
653 653
 						$pdf->SetLineStyle(array('dash'=>0));
654 654
 					}
655 655
 
656
-					$nexY+=2;    // Passe espace entre les lignes
656
+					$nexY += 2; // Passe espace entre les lignes
657 657
 
658 658
 					// Detect if some page were added automatically and output _tableau for past pages
659 659
 					while ($pagenb < $pageposafter)
@@ -667,13 +667,13 @@  discard block
 block discarded – undo
667 667
 						{
668 668
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
669 669
 						}
670
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
670
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
671 671
 						$pagenb++;
672 672
 						$pdf->setPage($pagenb);
673
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
673
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
674 674
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
675 675
 					}
676
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
676
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
677 677
 					{
678 678
 						if ($pagenb == 1)
679 679
 						{
@@ -683,10 +683,10 @@  discard block
 block discarded – undo
683 683
 						{
684 684
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
685 685
 						}
686
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
686
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
687 687
 						// New page
688 688
 						$pdf->AddPage();
689
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
689
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
690 690
 						$pagenb++;
691 691
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
692 692
 					}
@@ -696,19 +696,19 @@  discard block
 block discarded – undo
696 696
 				if ($pagenb == 1)
697 697
 				{
698 698
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
699
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
699
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
700 700
 				}
701 701
 				else
702 702
 				{
703 703
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
704
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
704
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
705 705
 				}
706 706
 
707 707
 				// Affiche zone infos
708
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
708
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
709 709
 
710 710
 				// Affiche zone totaux
711
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
711
+				$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
712 712
 
713 713
 				// Affiche zone versements
714 714
 				/*
@@ -721,21 +721,21 @@  discard block
 block discarded – undo
721 721
 				// Customer signature area
722 722
 				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
723 723
 				{
724
-				    $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
724
+				    $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
725 725
 				}
726 726
 
727 727
 				// Pied de page
728
-				$this->_pagefoot($pdf,$object,$outputlangs);
729
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
728
+				$this->_pagefoot($pdf, $object, $outputlangs);
729
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
730 730
 
731 731
 				//If propal merge product PDF is active
732 732
 				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
733 733
 				{
734 734
 					require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
735 735
 
736
-					$already_merged = array ();
737
-					foreach ( $object->lines as $line ) {
738
-						if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
736
+					$already_merged = array();
737
+					foreach ($object->lines as $line) {
738
+						if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
739 739
 							// Find the desire PDF
740 740
 							$filetomerge = new Propalmergepdfproduct($this->db);
741 741
 
@@ -750,48 +750,48 @@  discard block
 block discarded – undo
750 750
 							$product = new Product($this->db);
751 751
 							$product->fetch($line->fk_product);
752 752
 
753
-							if ($product->entity!=$conf->entity) {
754
-								$entity_product_file=$product->entity;
753
+							if ($product->entity != $conf->entity) {
754
+								$entity_product_file = $product->entity;
755 755
 							} else {
756
-								$entity_product_file=$conf->entity;
756
+								$entity_product_file = $conf->entity;
757 757
 							}
758 758
 
759 759
 							// If PDF is selected and file is not empty
760 760
 							if (count($filetomerge->lines) > 0) {
761
-								foreach ( $filetomerge->lines as $linefile ) {
762
-									if (! empty($linefile->id) && ! empty($linefile->file_name)) {
761
+								foreach ($filetomerge->lines as $linefile) {
762
+									if (!empty($linefile->id) && !empty($linefile->file_name)) {
763 763
 
764 764
 
765
-										if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
765
+										if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
766 766
 										{
767
-											if (! empty($conf->product->enabled)) {
768
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
769
-											} elseif (! empty($conf->service->enabled)) {
770
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
767
+											if (!empty($conf->product->enabled)) {
768
+												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
769
+											} elseif (!empty($conf->service->enabled)) {
770
+												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
771 771
 											}
772 772
 										}
773 773
 										else
774 774
 										{
775
-											if (! empty($conf->product->enabled)) {
776
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
777
-											} elseif (! empty($conf->service->enabled)) {
778
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
775
+											if (!empty($conf->product->enabled)) {
776
+												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
777
+											} elseif (!empty($conf->service->enabled)) {
778
+												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
779 779
 											}
780 780
 										}
781 781
 
782
-										dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
782
+										dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
783 783
 
784
-										$infile = $filetomerge_dir . '/' . $linefile->file_name;
784
+										$infile = $filetomerge_dir.'/'.$linefile->file_name;
785 785
 										if (file_exists($infile) && is_readable($infile)) {
786 786
 											$pagecount = $pdf->setSourceFile($infile);
787
-											for($i = 1; $i <= $pagecount; $i ++) {
787
+											for ($i = 1; $i <= $pagecount; $i++) {
788 788
 												$tplIdx = $pdf->importPage($i);
789
-												if ($tplIdx!==false) {
789
+												if ($tplIdx !== false) {
790 790
 													$s = $pdf->getTemplatesize($tplIdx);
791 791
 													$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
792 792
 													$pdf->useTemplate($tplIdx);
793 793
 												} else {
794
-													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
794
+													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'), 'warnings');
795 795
 												}
796 796
 											}
797 797
 										}
@@ -804,30 +804,30 @@  discard block
 block discarded – undo
804 804
 
805 805
 				$pdf->Close();
806 806
 
807
-				$pdf->Output($file,'F');
807
+				$pdf->Output($file, 'F');
808 808
 
809 809
 				//Add pdfgeneration hook
810 810
 				$hookmanager->initHooks(array('pdfgeneration'));
811
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
811
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
812 812
 				global $action;
813
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
813
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
814 814
 
815
-				if (! empty($conf->global->MAIN_UMASK))
815
+				if (!empty($conf->global->MAIN_UMASK))
816 816
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
817 817
 
818 818
 				$this->result = array('fullpath'=>$file);
819 819
 
820
-				return 1;   // Pas d'erreur
820
+				return 1; // Pas d'erreur
821 821
 			}
822 822
 			else
823 823
 			{
824
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
824
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
825 825
 				return 0;
826 826
 			}
827 827
 		}
828 828
 		else
829 829
 		{
830
-			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
830
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
831 831
 			return 0;
832 832
 		}
833 833
 	}
@@ -864,66 +864,66 @@  discard block
 block discarded – undo
864 864
 		global $conf;
865 865
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
866 866
 
867
-		$pdf->SetFont('','', $default_font_size - 1);
867
+		$pdf->SetFont('', '', $default_font_size - 1);
868 868
 
869 869
 		// If France, show VAT mention if not applicable
870 870
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
871 871
 		{
872
-			$pdf->SetFont('','B', $default_font_size - 2);
872
+			$pdf->SetFont('', 'B', $default_font_size - 2);
873 873
 			$pdf->SetXY($this->marge_gauche, $posy);
874 874
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
875 875
 
876
-			$posy=$pdf->GetY()+4;
876
+			$posy = $pdf->GetY() + 4;
877 877
 		}
878 878
 
879
-		$posxval=52;
879
+		$posxval = 52;
880 880
 
881 881
         // Show shipping date
882
-        if (! empty($object->date_livraison))
882
+        if (!empty($object->date_livraison))
883 883
 		{
884 884
             $outputlangs->load("sendings");
885
-			$pdf->SetFont('','B', $default_font_size - 2);
885
+			$pdf->SetFont('', 'B', $default_font_size - 2);
886 886
 			$pdf->SetXY($this->marge_gauche, $posy);
887 887
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
888 888
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
889
-			$pdf->SetFont('','', $default_font_size - 2);
889
+			$pdf->SetFont('', '', $default_font_size - 2);
890 890
 			$pdf->SetXY($posxval, $posy);
891
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
891
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
892 892
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
893 893
 
894
-            $posy=$pdf->GetY()+1;
894
+            $posy = $pdf->GetY() + 1;
895 895
 		}
896 896
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
897 897
 		{
898
-			$pdf->SetFont('','B', $default_font_size - 2);
898
+			$pdf->SetFont('', 'B', $default_font_size - 2);
899 899
 			$pdf->SetXY($this->marge_gauche, $posy);
900 900
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
901 901
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
902
-			$pdf->SetTextColor(0,0,0);
903
-			$pdf->SetFont('','', $default_font_size - 2);
902
+			$pdf->SetTextColor(0, 0, 0);
903
+			$pdf->SetFont('', '', $default_font_size - 2);
904 904
 			$pdf->SetXY($posxval, $posy);
905
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
906
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
905
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
906
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
907 907
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
908 908
 
909
-			$posy=$pdf->GetY()+1;
909
+			$posy = $pdf->GetY() + 1;
910 910
 		}
911 911
 
912 912
 		// Show payments conditions
913 913
 		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
914 914
 		{
915
-			$pdf->SetFont('','B', $default_font_size - 2);
915
+			$pdf->SetFont('', 'B', $default_font_size - 2);
916 916
 			$pdf->SetXY($this->marge_gauche, $posy);
917 917
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
918 918
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
919 919
 
920
-			$pdf->SetFont('','', $default_font_size - 2);
920
+			$pdf->SetFont('', '', $default_font_size - 2);
921 921
 			$pdf->SetXY($posxval, $posy);
922
-			$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);
923
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
924
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
922
+			$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);
923
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
924
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
925 925
 
926
-			$posy=$pdf->GetY()+3;
926
+			$posy = $pdf->GetY() + 3;
927 927
 		}
928 928
 
929 929
 		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
@@ -949,25 +949,25 @@  discard block
 block discarded – undo
949 949
 			&& $object->mode_reglement_code != 'CHQ'
950 950
 			&& $object->mode_reglement_code != 'VIR')
951 951
 			{
952
-				$pdf->SetFont('','B', $default_font_size - 2);
952
+				$pdf->SetFont('', 'B', $default_font_size - 2);
953 953
 				$pdf->SetXY($this->marge_gauche, $posy);
954 954
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
955 955
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
956
-				$pdf->SetFont('','', $default_font_size - 2);
956
+				$pdf->SetFont('', '', $default_font_size - 2);
957 957
 				$pdf->SetXY($posxval, $posy);
958
-				$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);
959
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
958
+				$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);
959
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
960 960
 
961
-				$posy=$pdf->GetY()+2;
961
+				$posy = $pdf->GetY() + 2;
962 962
 			}
963 963
 
964 964
 			// Show payment mode CHQ
965 965
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
966 966
 			{
967 967
 				// Si mode reglement non force ou si force a CHQ
968
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
968
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
969 969
 				{
970
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
970
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
971 971
 
972 972
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
973 973
 					{
@@ -975,31 +975,31 @@  discard block
 block discarded – undo
975 975
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
976 976
 
977 977
 						$pdf->SetXY($this->marge_gauche, $posy);
978
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
979
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
980
-						$posy=$pdf->GetY()+1;
978
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
979
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
980
+						$posy = $pdf->GetY() + 1;
981 981
 
982 982
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
983 983
 			            {
984 984
 							$pdf->SetXY($this->marge_gauche, $posy);
985
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
985
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
986 986
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
987
-							$posy=$pdf->GetY()+2;
987
+							$posy = $pdf->GetY() + 2;
988 988
 			            }
989 989
 					}
990 990
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
991 991
 					{
992 992
 						$pdf->SetXY($this->marge_gauche, $posy);
993
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
994
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
995
-						$posy=$pdf->GetY()+1;
993
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
994
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
995
+						$posy = $pdf->GetY() + 1;
996 996
 
997 997
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
998 998
 			            {
999 999
 							$pdf->SetXY($this->marge_gauche, $posy);
1000
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1000
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1001 1001
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1002
-							$posy=$pdf->GetY()+2;
1002
+							$posy = $pdf->GetY() + 2;
1003 1003
 			            }
1004 1004
 					}
1005 1005
 				}
@@ -1008,19 +1008,19 @@  discard block
 block discarded – undo
1008 1008
 			// If payment mode not forced or forced to VIR, show payment with BAN
1009 1009
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1010 1010
 			{
1011
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1011
+				if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
1012 1012
 				{
1013
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1014
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1013
+					$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1014
+					if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1015 1015
 					$account = new Account($this->db);
1016 1016
 					$account->fetch($bankid);
1017 1017
 
1018
-					$curx=$this->marge_gauche;
1019
-					$cury=$posy;
1018
+					$curx = $this->marge_gauche;
1019
+					$cury = $posy;
1020 1020
 
1021
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1021
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1022 1022
 
1023
-					$posy+=2;
1023
+					$posy += 2;
1024 1024
 				}
1025 1025
 			}
1026 1026
 		}
@@ -1043,43 +1043,43 @@  discard block
 block discarded – undo
1043 1043
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1044 1044
 	{
1045 1045
         // phpcs:enable
1046
-		global $conf,$mysoc;
1046
+		global $conf, $mysoc;
1047 1047
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1048 1048
 
1049 1049
 		$tab2_top = $posy;
1050 1050
 		$tab2_hl = 4;
1051
-		$pdf->SetFont('','', $default_font_size - 1);
1051
+		$pdf->SetFont('', '', $default_font_size - 1);
1052 1052
 
1053 1053
 		// Tableau total
1054 1054
 		$col1x = 120; $col2x = 170;
1055 1055
 		if ($this->page_largeur < 210) // To work with US executive format
1056 1056
 		{
1057
-			$col2x-=20;
1057
+			$col2x -= 20;
1058 1058
 		}
1059 1059
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1060 1060
 
1061
-		$useborder=0;
1061
+		$useborder = 0;
1062 1062
 		$index = 0;
1063 1063
 
1064 1064
 		// Total HT
1065
-		$pdf->SetFillColor(255,255,255);
1065
+		$pdf->SetFillColor(255, 255, 255);
1066 1066
 		$pdf->SetXY($col1x, $tab2_top + 0);
1067
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1067
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1068 1068
 
1069 1069
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1070 1070
 		$pdf->SetXY($col2x, $tab2_top + 0);
1071
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1071
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
1072 1072
 
1073 1073
 		// Show VAT by rates and total
1074
-		$pdf->SetFillColor(248,248,248);
1074
+		$pdf->SetFillColor(248, 248, 248);
1075 1075
 
1076 1076
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1077 1077
 
1078
-		$this->atleastoneratenotnull=0;
1078
+		$this->atleastoneratenotnull = 0;
1079 1079
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1080 1080
 		{
1081
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1082
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1081
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1082
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1083 1083
 			{
1084 1084
 				// Nothing to do
1085 1085
 			}
@@ -1088,28 +1088,28 @@  discard block
 block discarded – undo
1088 1088
 				//Local tax 1 before VAT
1089 1089
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1090 1090
 				//{
1091
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1091
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1092 1092
 					{
1093
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1093
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1094 1094
 
1095
-						foreach( $localtax_rate as $tvakey => $tvaval )
1095
+						foreach ($localtax_rate as $tvakey => $tvaval)
1096 1096
 						{
1097
-							if ($tvakey!=0)    // On affiche pas taux 0
1097
+							if ($tvakey != 0)    // On affiche pas taux 0
1098 1098
 							{
1099 1099
 								//$this->atleastoneratenotnull++;
1100 1100
 
1101 1101
 								$index++;
1102 1102
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103 1103
 
1104
-								$tvacompl='';
1105
-								if (preg_match('/\*/',$tvakey))
1104
+								$tvacompl = '';
1105
+								if (preg_match('/\*/', $tvakey))
1106 1106
 								{
1107
-									$tvakey=str_replace('*','',$tvakey);
1107
+									$tvakey = str_replace('*', '', $tvakey);
1108 1108
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1109 1109
 								}
1110
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1111
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1112
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1110
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1111
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1112
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1113 1113
 
1114 1114
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1115 1115
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1120,13 +1120,13 @@  discard block
 block discarded – undo
1120 1120
 				//Local tax 2 before VAT
1121 1121
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1122 1122
 				//{
1123
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1123
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1124 1124
 					{
1125
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1125
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1126 1126
 
1127
-						foreach( $localtax_rate as $tvakey => $tvaval )
1127
+						foreach ($localtax_rate as $tvakey => $tvaval)
1128 1128
 						{
1129
-							if ($tvakey!=0)    // On affiche pas taux 0
1129
+							if ($tvakey != 0)    // On affiche pas taux 0
1130 1130
 							{
1131 1131
 								//$this->atleastoneratenotnull++;
1132 1132
 
@@ -1135,15 +1135,15 @@  discard block
 block discarded – undo
1135 1135
 								$index++;
1136 1136
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 1137
 
1138
-								$tvacompl='';
1139
-								if (preg_match('/\*/',$tvakey))
1138
+								$tvacompl = '';
1139
+								if (preg_match('/\*/', $tvakey))
1140 1140
 								{
1141
-									$tvakey=str_replace('*','',$tvakey);
1141
+									$tvakey = str_replace('*', '', $tvakey);
1142 1142
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143 1143
 								}
1144 1144
 								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1145
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1145
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1146
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147 1147
 
1148 1148
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149 1149
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 					}
1153 1153
 				//}
1154 1154
 				// VAT
1155
-				foreach($this->tva as $tvakey => $tvaval)
1155
+				foreach ($this->tva as $tvakey => $tvaval)
1156 1156
 				{
1157 1157
 					if ($tvakey != 0)    // On affiche pas taux 0
1158 1158
 					{
@@ -1161,15 +1161,15 @@  discard block
 block discarded – undo
1161 1161
 						$index++;
1162 1162
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1163 1163
 
1164
-						$tvacompl='';
1165
-						if (preg_match('/\*/',$tvakey))
1164
+						$tvacompl = '';
1165
+						if (preg_match('/\*/', $tvakey))
1166 1166
 						{
1167
-							$tvakey=str_replace('*','',$tvakey);
1167
+							$tvakey = str_replace('*', '', $tvakey);
1168 1168
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1169 1169
 						}
1170
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1171
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1172
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1170
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1171
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1172
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1173 1173
 
1174 1174
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1175 1175
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1179,11 +1179,11 @@  discard block
 block discarded – undo
1179 1179
 				//Local tax 1 after VAT
1180 1180
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1181 1181
 				//{
1182
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1182
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1183 1183
 					{
1184
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1184
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1185 1185
 
1186
-						foreach( $localtax_rate as $tvakey => $tvaval )
1186
+						foreach ($localtax_rate as $tvakey => $tvaval)
1187 1187
 						{
1188 1188
 							if ($tvakey != 0)    // On affiche pas taux 0
1189 1189
 							{
@@ -1192,16 +1192,16 @@  discard block
 block discarded – undo
1192 1192
 								$index++;
1193 1193
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1194 1194
 
1195
-								$tvacompl='';
1196
-								if (preg_match('/\*/',$tvakey))
1195
+								$tvacompl = '';
1196
+								if (preg_match('/\*/', $tvakey))
1197 1197
 								{
1198
-									$tvakey=str_replace('*','',$tvakey);
1198
+									$tvakey = str_replace('*', '', $tvakey);
1199 1199
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1200 1200
 								}
1201
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1201
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1202 1202
 
1203
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1204
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1203
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1204
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1205 1205
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1206 1206
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1207 1207
 							}
@@ -1211,11 +1211,11 @@  discard block
 block discarded – undo
1211 1211
 				//Local tax 2 after VAT
1212 1212
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1213 1213
 				//{
1214
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1214
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1215 1215
 					{
1216
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1216
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1217 1217
 
1218
-						foreach( $localtax_rate as $tvakey => $tvaval )
1218
+						foreach ($localtax_rate as $tvakey => $tvaval)
1219 1219
 						{
1220 1220
 						    // retrieve global local tax
1221 1221
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1225,16 +1225,16 @@  discard block
 block discarded – undo
1225 1225
 								$index++;
1226 1226
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1227 1227
 
1228
-								$tvacompl='';
1229
-								if (preg_match('/\*/',$tvakey))
1228
+								$tvacompl = '';
1229
+								if (preg_match('/\*/', $tvakey))
1230 1230
 								{
1231
-									$tvakey=str_replace('*','',$tvakey);
1231
+									$tvakey = str_replace('*', '', $tvakey);
1232 1232
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1233 1233
 								}
1234
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1234
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1235 1235
 
1236
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1237
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1236
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1237
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1238 1238
 
1239 1239
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240 1240
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1246,16 +1246,16 @@  discard block
 block discarded – undo
1246 1246
 				// Total TTC
1247 1247
 				$index++;
1248 1248
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1249
-				$pdf->SetTextColor(0,0,60);
1250
-				$pdf->SetFillColor(224,224,224);
1251
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1249
+				$pdf->SetTextColor(0, 0, 60);
1250
+				$pdf->SetFillColor(224, 224, 224);
1251
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1252 1252
 
1253 1253
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1254 1254
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1255 1255
 			}
1256 1256
 		}
1257 1257
 
1258
-		$pdf->SetTextColor(0,0,0);
1258
+		$pdf->SetTextColor(0, 0, 0);
1259 1259
 
1260 1260
 		/*
1261 1261
 		$resteapayer = $object->total_ttc - $deja_regle;
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 			$index++;
1268 1268
 
1269 1269
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1270
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1270
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1271 1271
 
1272 1272
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1273 1273
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1289,16 +1289,16 @@  discard block
 block discarded – undo
1289 1289
 			*/
1290 1290
 
1291 1291
 			$index++;
1292
-			$pdf->SetTextColor(0,0,60);
1293
-			$pdf->SetFillColor(224,224,224);
1292
+			$pdf->SetTextColor(0, 0, 60);
1293
+			$pdf->SetFillColor(224, 224, 224);
1294 1294
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1295
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1295
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1296 1296
 
1297 1297
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1298 1298
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1299 1299
 
1300
-			$pdf->SetFont('','', $default_font_size - 1);
1301
-			$pdf->SetTextColor(0,0,0);
1300
+			$pdf->SetFont('', '', $default_font_size - 1);
1301
+			$pdf->SetTextColor(0, 0, 0);
1302 1302
 		}
1303 1303
 
1304 1304
 		$index++;
@@ -1318,48 +1318,48 @@  discard block
 block discarded – undo
1318 1318
 	 *   @param		string		$currency		Currency code
1319 1319
 	 *   @return	void
1320 1320
 	 */
1321
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1321
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1322 1322
 	{
1323 1323
 		global $conf;
1324 1324
 
1325 1325
 		// Force to disable hidetop and hidebottom
1326
-		$hidebottom=0;
1327
-		if ($hidetop) $hidetop=-1;
1326
+		$hidebottom = 0;
1327
+		if ($hidetop) $hidetop = -1;
1328 1328
 
1329 1329
 		$currency = !empty($currency) ? $currency : $conf->currency;
1330 1330
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1331 1331
 
1332 1332
 		// Amount in (at tab_top - 1)
1333
-		$pdf->SetTextColor(0,0,0);
1334
-		$pdf->SetFont('','',$default_font_size - 2);
1333
+		$pdf->SetTextColor(0, 0, 0);
1334
+		$pdf->SetFont('', '', $default_font_size - 2);
1335 1335
 
1336 1336
 		if (empty($hidetop))
1337 1337
 		{
1338
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1339
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1338
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1339
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1340 1340
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1341 1341
 
1342 1342
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1343
-			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));
1343
+			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));
1344 1344
 		}
1345 1345
 
1346
-		$pdf->SetDrawColor(128,128,128);
1347
-		$pdf->SetFont('','',$default_font_size - 1);
1346
+		$pdf->SetDrawColor(128, 128, 128);
1347
+		$pdf->SetFont('', '', $default_font_size - 1);
1348 1348
 
1349 1349
 		// Output Rect
1350
-		$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
1350
+		$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
1351 1351
 
1352 1352
 		if (empty($hidetop))
1353 1353
 		{
1354
-			$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
1354
+			$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
1355 1355
 
1356
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1357
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1356
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1357
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1358 1358
 		}
1359 1359
 
1360
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1360
+		if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1361 1361
 		{
1362
-			$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1362
+			$pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1363 1363
 			if (empty($hidetop))
1364 1364
 			{
1365 1365
 				//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
@@ -1369,37 +1369,37 @@  discard block
 block discarded – undo
1369 1369
 
1370 1370
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1371 1371
 		{
1372
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1372
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1373 1373
 			if (empty($hidetop))
1374 1374
 			{
1375 1375
 				// Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax'
1376
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1377
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1376
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1377
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1378 1378
 			}
1379 1379
 		}
1380 1380
 
1381
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1381
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1382 1382
 		if (empty($hidetop))
1383 1383
 		{
1384
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1385
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1384
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1385
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1386 1386
 		}
1387 1387
 
1388
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1388
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1389 1389
 		if (empty($hidetop))
1390 1390
 		{
1391
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1392
-			if($conf->global->PRODUCT_USE_UNITS)
1391
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1392
+			if ($conf->global->PRODUCT_USE_UNITS)
1393 1393
 			{
1394
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1394
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1395 1395
 			}
1396 1396
 			else
1397 1397
 			{
1398
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1398
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1399 1399
 			}
1400 1400
 		}
1401 1401
 
1402
-		if($conf->global->PRODUCT_USE_UNITS) {
1402
+		if ($conf->global->PRODUCT_USE_UNITS) {
1403 1403
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1404 1404
 			if (empty($hidetop)) {
1405 1405
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1408,13 +1408,13 @@  discard block
 block discarded – undo
1408 1408
 			}
1409 1409
 		}
1410 1410
 
1411
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1411
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1412 1412
 		if (empty($hidetop))
1413 1413
 		{
1414 1414
 			if ($this->atleastonediscount)
1415 1415
 			{
1416
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1417
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1416
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1417
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1418 1418
 			}
1419 1419
 		}
1420 1420
 		if ($this->atleastonediscount)
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
 		}
1424 1424
 		if (empty($hidetop))
1425 1425
 		{
1426
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1427
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1426
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1427
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1428 1428
 		}
1429 1429
 	}
1430 1430
 
@@ -1439,113 +1439,113 @@  discard block
 block discarded – undo
1439 1439
 	 */
1440 1440
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1441 1441
 	{
1442
-		global $conf,$langs;
1442
+		global $conf, $langs;
1443 1443
 
1444 1444
 		// Load traductions files requiredby by page
1445 1445
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1446 1446
 
1447 1447
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1448 1448
 
1449
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1449
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1450 1450
 
1451 1451
 		//  Show Draft Watermark
1452
-		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1452
+		if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
1453 1453
 		{
1454
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1454
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
1455 1455
 		}
1456 1456
 
1457
-		$pdf->SetTextColor(0,0,60);
1458
-		$pdf->SetFont('','B', $default_font_size + 3);
1457
+		$pdf->SetTextColor(0, 0, 60);
1458
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1459 1459
 
1460
-		$posy=$this->marge_haute;
1461
-		$posx=$this->page_largeur-$this->marge_droite-100;
1460
+		$posy = $this->marge_haute;
1461
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1462 1462
 
1463
-		$pdf->SetXY($this->marge_gauche,$posy);
1463
+		$pdf->SetXY($this->marge_gauche, $posy);
1464 1464
 
1465 1465
 		// Logo
1466 1466
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1467 1467
 		{
1468
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1468
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1469 1469
 			if ($this->emetteur->logo)
1470 1470
 			{
1471 1471
 				if (is_readable($logo))
1472 1472
 				{
1473
-				    $height=pdf_getHeightForLogo($logo);
1474
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1473
+				    $height = pdf_getHeightForLogo($logo);
1474
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1475 1475
 				}
1476 1476
 				else
1477 1477
 				{
1478
-					$pdf->SetTextColor(200,0,0);
1479
-					$pdf->SetFont('','B',$default_font_size - 2);
1480
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1478
+					$pdf->SetTextColor(200, 0, 0);
1479
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1480
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1481 1481
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1482 1482
 				}
1483 1483
 			}
1484 1484
 			else
1485 1485
 			{
1486
-				$text=$this->emetteur->name;
1486
+				$text = $this->emetteur->name;
1487 1487
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1488 1488
 			}
1489 1489
 		}
1490 1490
 
1491
-		$pdf->SetFont('','B',$default_font_size + 3);
1492
-		$pdf->SetXY($posx,$posy);
1493
-		$pdf->SetTextColor(0,0,60);
1494
-		$title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1491
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1492
+		$pdf->SetXY($posx, $posy);
1493
+		$pdf->SetTextColor(0, 0, 60);
1494
+		$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
1495 1495
 		$pdf->MultiCell(100, 4, $title, '', 'R');
1496 1496
 
1497
-		$pdf->SetFont('','B',$default_font_size);
1497
+		$pdf->SetFont('', 'B', $default_font_size);
1498 1498
 
1499
-		$posy+=5;
1500
-		$pdf->SetXY($posx,$posy);
1501
-		$pdf->SetTextColor(0,0,60);
1502
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1499
+		$posy += 5;
1500
+		$pdf->SetXY($posx, $posy);
1501
+		$pdf->SetTextColor(0, 0, 60);
1502
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1503 1503
 
1504
-		$posy+=1;
1505
-		$pdf->SetFont('','', $default_font_size - 2);
1504
+		$posy += 1;
1505
+		$pdf->SetFont('', '', $default_font_size - 2);
1506 1506
 
1507 1507
 		if ($object->ref_client)
1508 1508
 		{
1509
-			$posy+=4;
1510
-			$pdf->SetXY($posx,$posy);
1511
-			$pdf->SetTextColor(0,0,60);
1512
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1509
+			$posy += 4;
1510
+			$pdf->SetXY($posx, $posy);
1511
+			$pdf->SetTextColor(0, 0, 60);
1512
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1513 1513
 		}
1514 1514
 
1515
-		$posy+=4;
1516
-		$pdf->SetXY($posx,$posy);
1517
-		$pdf->SetTextColor(0,0,60);
1518
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1515
+		$posy += 4;
1516
+		$pdf->SetXY($posx, $posy);
1517
+		$pdf->SetTextColor(0, 0, 60);
1518
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1519 1519
 
1520
-		$posy+=4;
1521
-		$pdf->SetXY($posx,$posy);
1522
-		$pdf->SetTextColor(0,0,60);
1523
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1520
+		$posy += 4;
1521
+		$pdf->SetXY($posx, $posy);
1522
+		$pdf->SetTextColor(0, 0, 60);
1523
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
1524 1524
 
1525 1525
 		if ($object->thirdparty->code_client)
1526 1526
 		{
1527
-			$posy+=4;
1528
-			$pdf->SetXY($posx,$posy);
1529
-			$pdf->SetTextColor(0,0,60);
1530
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1527
+			$posy += 4;
1528
+			$pdf->SetXY($posx, $posy);
1529
+			$pdf->SetTextColor(0, 0, 60);
1530
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1531 1531
 		}
1532 1532
 
1533 1533
 		// Get contact
1534 1534
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1535 1535
 		{
1536
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1536
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1537 1537
 		    if (count($arrayidcontact) > 0)
1538 1538
 		    {
1539
-		        $usertmp=new User($this->db);
1539
+		        $usertmp = new User($this->db);
1540 1540
 		        $usertmp->fetch($arrayidcontact[0]);
1541
-                $posy+=4;
1542
-                $pdf->SetXY($posx,$posy);
1543
-		        $pdf->SetTextColor(0,0,60);
1541
+                $posy += 4;
1542
+                $pdf->SetXY($posx, $posy);
1543
+		        $pdf->SetTextColor(0, 0, 60);
1544 1544
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1545 1545
 		    }
1546 1546
 		}
1547 1547
 
1548
-		$posy+=2;
1548
+		$posy += 2;
1549 1549
 
1550 1550
 		$top_shift = 0;
1551 1551
 		// Show list of linked objects
@@ -1559,53 +1559,53 @@  discard block
 block discarded – undo
1559 1559
 		if ($showaddress)
1560 1560
 		{
1561 1561
 			// Sender properties
1562
-			$carac_emetteur='';
1562
+			$carac_emetteur = '';
1563 1563
 		 	// Add internal contact of proposal if defined
1564
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1564
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1565 1565
 		 	if (count($arrayidcontact) > 0)
1566 1566
 		 	{
1567 1567
 		 		$object->fetch_user($arrayidcontact[0]);
1568
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1569
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1568
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1569
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1570 1570
 		 	}
1571 1571
 
1572 1572
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1573 1573
 
1574 1574
 			// Show sender
1575
-			$posy=42+$top_shift;
1576
-		 	$posx=$this->marge_gauche;
1577
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1578
-			$hautcadre=40;
1575
+			$posy = 42 + $top_shift;
1576
+		 	$posx = $this->marge_gauche;
1577
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1578
+			$hautcadre = 40;
1579 1579
 
1580 1580
 			// Show sender frame
1581
-			$pdf->SetTextColor(0,0,0);
1582
-			$pdf->SetFont('','', $default_font_size - 2);
1583
-			$pdf->SetXY($posx,$posy-5);
1584
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1585
-			$pdf->SetXY($posx,$posy);
1586
-			$pdf->SetFillColor(230,230,230);
1581
+			$pdf->SetTextColor(0, 0, 0);
1582
+			$pdf->SetFont('', '', $default_font_size - 2);
1583
+			$pdf->SetXY($posx, $posy - 5);
1584
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1585
+			$pdf->SetXY($posx, $posy);
1586
+			$pdf->SetFillColor(230, 230, 230);
1587 1587
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1588
-			$pdf->SetTextColor(0,0,60);
1588
+			$pdf->SetTextColor(0, 0, 60);
1589 1589
 
1590 1590
 			// Show sender name
1591
-			$pdf->SetXY($posx+2,$posy+3);
1592
-			$pdf->SetFont('','B', $default_font_size);
1591
+			$pdf->SetXY($posx + 2, $posy + 3);
1592
+			$pdf->SetFont('', 'B', $default_font_size);
1593 1593
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1594
-			$posy=$pdf->getY();
1594
+			$posy = $pdf->getY();
1595 1595
 
1596 1596
 			// Show sender information
1597
-			$pdf->SetXY($posx+2,$posy);
1598
-			$pdf->SetFont('','', $default_font_size - 1);
1597
+			$pdf->SetXY($posx + 2, $posy);
1598
+			$pdf->SetFont('', '', $default_font_size - 1);
1599 1599
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1600 1600
 
1601 1601
 
1602 1602
 			// If CUSTOMER contact defined, we use it
1603
-			$usecontact=false;
1604
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1603
+			$usecontact = false;
1604
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1605 1605
 			if (count($arrayidcontact) > 0)
1606 1606
 			{
1607
-				$usecontact=true;
1608
-				$result=$object->fetch_contact($arrayidcontact[0]);
1607
+				$usecontact = true;
1608
+				$result = $object->fetch_contact($arrayidcontact[0]);
1609 1609
 			}
1610 1610
 
1611 1611
 			//Recipient name
@@ -1616,38 +1616,38 @@  discard block
 block discarded – undo
1616 1616
 				$thirdparty = $object->thirdparty;
1617 1617
 			}
1618 1618
 
1619
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1619
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1620 1620
 
1621
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1621
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1622 1622
 
1623 1623
 			// Show recipient
1624
-			$widthrecbox=100;
1625
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1626
-			$posy=42+$top_shift;
1627
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1628
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1624
+			$widthrecbox = 100;
1625
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1626
+			$posy = 42 + $top_shift;
1627
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1628
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1629 1629
 
1630 1630
 			// Show recipient frame
1631
-			$pdf->SetTextColor(0,0,0);
1632
-			$pdf->SetFont('','', $default_font_size - 2);
1633
-			$pdf->SetXY($posx+2,$posy-5);
1631
+			$pdf->SetTextColor(0, 0, 0);
1632
+			$pdf->SetFont('', '', $default_font_size - 2);
1633
+			$pdf->SetXY($posx + 2, $posy - 5);
1634 1634
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1635 1635
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1636 1636
 
1637 1637
 			// Show recipient name
1638
-			$pdf->SetXY($posx+2,$posy+3);
1639
-			$pdf->SetFont('','B', $default_font_size);
1638
+			$pdf->SetXY($posx + 2, $posy + 3);
1639
+			$pdf->SetFont('', 'B', $default_font_size);
1640 1640
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1641 1641
 
1642 1642
 			$posy = $pdf->getY();
1643 1643
 
1644 1644
 			// Show recipient information
1645
-			$pdf->SetFont('','', $default_font_size - 1);
1646
-			$pdf->SetXY($posx+2,$posy);
1645
+			$pdf->SetFont('', '', $default_font_size - 1);
1646
+			$pdf->SetXY($posx + 2, $posy);
1647 1647
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1648 1648
 		}
1649 1649
 
1650
-		$pdf->SetTextColor(0,0,0);
1650
+		$pdf->SetTextColor(0, 0, 0);
1651 1651
 		return $top_shift;
1652 1652
 	}
1653 1653
 
@@ -1660,11 +1660,11 @@  discard block
 block discarded – undo
1660 1660
 	 *      @param	int			$hidefreetext		1=Hide free text
1661 1661
 	 *      @return	int								Return height of bottom margin including footer text
1662 1662
 	 */
1663
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1663
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1664 1664
 	{
1665 1665
 		global $conf;
1666
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1667
-		return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1666
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1667
+		return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1668 1668
 	}
1669 1669
 
1670 1670
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -1687,20 +1687,20 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 		$posx = 120;
1689 1689
 		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
1690
-		$useborder=0;
1690
+		$useborder = 0;
1691 1691
 		$index = 0;
1692 1692
 		// Total HT
1693
-		$pdf->SetFillColor(255,255,255);
1693
+		$pdf->SetFillColor(255, 255, 255);
1694 1694
 		$pdf->SetXY($posx, $tab_top + 0);
1695
-		$pdf->SetFont('','', $default_font_size - 2);
1695
+		$pdf->SetFont('', '', $default_font_size - 2);
1696 1696
 		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1697 1697
 
1698 1698
 		$pdf->SetXY($posx, $tab_top + $tab_hl);
1699
-		$pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1700
-		if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1701
-			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1699
+		$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
1700
+		if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1701
+			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1702 1702
 		}
1703 1703
 
1704
-		return ($tab_hl*7);
1704
+		return ($tab_hl * 7);
1705 1705
 	}
1706 1706
 }
Please login to merge, or discard this patch.
Braces   +188 added lines, -96 removed lines patch added patch discarded remove patch
@@ -163,7 +163,10 @@  discard block
 block discarded – undo
163 163
 
164 164
 		// Get source company
165 165
 		$this->emetteur=$mysoc;
166
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
166
+		if (empty($this->emetteur->country_code)) {
167
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
168
+		}
169
+		// By default, if was not defined
167 170
 
168 171
 		// Define position of columns
169 172
 		$this->posxdesc=$this->marge_gauche+1;
@@ -173,8 +176,7 @@  discard block
 block discarded – undo
173 176
 			$this->posxup=118;
174 177
 			$this->posxqty=135;
175 178
 			$this->posxunit=151;
176
-		}
177
-		else
179
+		} else
178 180
 		{
179 181
 			$this->posxtva=110;
180 182
 			$this->posxup=126;
@@ -182,11 +184,15 @@  discard block
 block discarded – undo
182 184
 		}
183 185
 		$this->posxdiscount=162;
184 186
 		$this->postotalht=174;
185
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
187
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
188
+		    $this->posxtva=$this->posxup;
189
+		}
186 190
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
187
-		if ($this->page_largeur < 210) // To work with US executive format
191
+		if ($this->page_largeur < 210) {
192
+		    // To work with US executive format
188 193
 		{
189 194
 			$this->posxpicture-=20;
195
+		}
190 196
 			$this->posxtva-=20;
191 197
 			$this->posxup-=20;
192 198
 			$this->posxqty-=20;
@@ -219,9 +225,13 @@  discard block
 block discarded – undo
219 225
         // phpcs:enable
220 226
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
221 227
 
222
-		if (! is_object($outputlangs)) $outputlangs=$langs;
228
+		if (! is_object($outputlangs)) {
229
+		    $outputlangs=$langs;
230
+		}
223 231
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
224
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
232
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
233
+		    $outputlangs->charset_output='ISO-8859-1';
234
+		}
225 235
 
226 236
 		// Load traductions files requiredby by page
227 237
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products"));
@@ -236,7 +246,9 @@  discard block
 block discarded – undo
236 246
 
237 247
 			for ($i = 0 ; $i < $nblignes ; $i++)
238 248
 			{
239
-				if (empty($object->lines[$i]->fk_product)) continue;
249
+				if (empty($object->lines[$i]->fk_product)) {
250
+				    continue;
251
+				}
240 252
 
241 253
 				$objphoto->fetch($object->lines[$i]->fk_product);
242 254
                 //var_dump($objphoto->ref);exit;
@@ -244,8 +256,7 @@  discard block
 block discarded – undo
244 256
 				{
245 257
 					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
246 258
 					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
247
-				}
248
-				else
259
+				} else
249 260
 				{
250 261
 					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
251 262
 					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
@@ -260,18 +271,18 @@  discard block
 block discarded – undo
260 271
 
261 272
 						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
262 273
 						{
263
-							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
274
+							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
275
+							    // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
264 276
 							{
265 277
 								if ($obj['photo_vignette'])
266 278
 								{
267 279
 									$filename= $obj['photo_vignette'];
268
-								}
269
-								else
280
+							}
281
+								} else
270 282
 								{
271 283
 									$filename=$obj['photo'];
272 284
 								}
273
-							}
274
-							else
285
+							} else
275 286
 							{
276 287
 								$filename=$obj['photo'];
277 288
 							}
@@ -282,11 +293,15 @@  discard block
 block discarded – undo
282 293
 					}
283 294
 				}
284 295
 
285
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
296
+				if ($realpath && $arephoto) {
297
+				    $realpatharray[$i]=$realpath;
298
+				}
286 299
 			}
287 300
 		}
288 301
 
289
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
302
+		if (count($realpatharray) == 0) {
303
+		    $this->posxpicture=$this->posxtva;
304
+		}
290 305
 
291 306
 		if ($conf->propal->multidir_output[$conf->entity])
292 307
 		{
@@ -299,8 +314,7 @@  discard block
 block discarded – undo
299 314
 			{
300 315
 				$dir = $conf->propal->multidir_output[$conf->entity];
301 316
 				$file = $dir . "/SPECIMEN.pdf";
302
-			}
303
-			else
317
+			} else
304 318
 			{
305 319
 				$objectref = dol_sanitizeFileName($object->ref);
306 320
 				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
@@ -356,7 +370,9 @@  discard block
 block discarded – undo
356 370
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
357 371
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
358 372
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
359
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
373
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
374
+				    $pdf->SetCompression(false);
375
+				}
360 376
 
361 377
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
362 378
 
@@ -380,14 +396,18 @@  discard block
 block discarded – undo
380 396
 
381 397
 				// New page
382 398
 				$pdf->AddPage();
383
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
399
+				if (! empty($tplidx)) {
400
+				    $pdf->useTemplate($tplidx);
401
+				}
384 402
 				$pagenb++;
385 403
 
386 404
                 $heightforinfotot = 40;	// Height reserved to output the info and total part
387 405
                 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
388 406
                 $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
389 407
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
390
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
408
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
409
+				    $heightforfooter+= 6;
410
+				}
391 411
                 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
392 412
 
393 413
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -430,7 +450,9 @@  discard block
 block discarded – undo
430 450
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
431 451
 						$salerepobj=new User($this->db);
432 452
 						$salerepobj->fetch($salereparray[0]['id']);
433
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
453
+						if (! empty($salerepobj->signature)) {
454
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
455
+						}
434 456
 					}
435 457
 				}
436 458
 				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
@@ -438,8 +460,12 @@  discard block
 block discarded – undo
438 460
 				    $tmpuser=new User($this->db);
439 461
 				    $tmpuser->fetch($object->user_author_id);
440 462
 				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
441
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
442
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
463
+				    if ($tmpuser->email) {
464
+				        $notetoshow.=',  Mail: '.$tmpuser->email;
465
+				    }
466
+				    if ($tmpuser->office_phone) {
467
+				        $notetoshow.=', Tel: '.$tmpuser->office_phone;
468
+				    }
443 469
 				}
444 470
 				if ($notetoshow)
445 471
 				{
@@ -474,7 +500,9 @@  discard block
 block discarded – undo
474 500
 
475 501
 					// Define size of image if we need it
476 502
 					$imglinesize=array();
477
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
503
+					if (! empty($realpatharray[$i])) {
504
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
505
+					}
478 506
 
479 507
 					$pdf->setTopMargin($tab_top_newpage);
480 508
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -485,11 +513,17 @@  discard block
 block discarded – undo
485 513
 					$posYAfterDescription=0;
486 514
 
487 515
 					// We start with Photo of product line
488
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
516
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) {
517
+					    // If photo too high, we moved completely on new page
489 518
 					{
490 519
 						$pdf->AddPage('','',true);
491
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
492
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
520
+					}
521
+						if (! empty($tplidx)) {
522
+						    $pdf->useTemplate($tplidx);
523
+						}
524
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
525
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
526
+						}
493 527
 						$pdf->setPage($pageposbefore+1);
494 528
 
495 529
 						$curY = $tab_top_newpage;
@@ -510,9 +544,11 @@  discard block
 block discarded – undo
510 544
 					$pdf->startTransaction();
511 545
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
512 546
 					$pageposafter=$pdf->getPage();
513
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
547
+					if ($pageposafter > $pageposbefore) {
548
+					    // There is a pagebreak
514 549
 					{
515 550
 						$pdf->rollbackTransaction(true);
551
+					}
516 552
 						$pageposafter=$pageposbefore;
517 553
 						//print $pageposafter.'-'.$pageposbefore;exit;
518 554
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -521,23 +557,27 @@  discard block
 block discarded – undo
521 557
 						$pageposafter=$pdf->getPage();
522 558
 						$posyafter=$pdf->GetY();
523 559
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
524
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
560
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) {
561
+						    // There is no space left for total+free text
525 562
 						{
526 563
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
527 564
 							{
528 565
 								$pdf->AddPage('','',true);
529
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
530
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
566
+						}
567
+								if (! empty($tplidx)) {
568
+								    $pdf->useTemplate($tplidx);
569
+								}
570
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
571
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
572
+								}
531 573
 								$pdf->setPage($pageposafter+1);
532 574
 							}
533
-						}
534
-						else
575
+						} else
535 576
 						{
536 577
 							// We found a page break
537 578
 							$showpricebeforepagebreak=0;
538 579
 						}
539
-					}
540
-					else	// No pagebreak
580
+					} else	// No pagebreak
541 581
 					{
542 582
 						$pdf->commitTransaction();
543 583
 					}
@@ -577,8 +617,7 @@  discard block
 block discarded – undo
577 617
 					if($conf->global->PRODUCT_USE_UNITS)
578 618
 					{
579 619
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
580
-					}
581
-					else
620
+					} else
582 621
 					{
583 622
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
584 623
 					}
@@ -606,8 +645,11 @@  discard block
 block discarded – undo
606 645
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
607 646
 
608 647
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
609
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
610
-					else $tvaligne=$object->lines[$i]->total_tva;
648
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
649
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
650
+					} else {
651
+					    $tvaligne=$object->lines[$i]->total_tva;
652
+					}
611 653
 
612 654
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
613 655
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -616,32 +658,48 @@  discard block
 block discarded – undo
616 658
 					$localtax1_type=$object->lines[$i]->localtax1_type;
617 659
 					$localtax2_type=$object->lines[$i]->localtax2_type;
618 660
 
619
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
620
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
661
+					if ($object->remise_percent) {
662
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
663
+					}
664
+					if ($object->remise_percent) {
665
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
666
+					}
667
+					if ($object->remise_percent) {
668
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
669
+					}
622 670
 
623 671
 					$vatrate=(string) $object->lines[$i]->tva_tx;
624 672
 
625 673
 					// Retrieve type from database for backward compatibility with old records
626 674
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
627
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
675
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
676
+					    // and there is local tax
628 677
 					{
629 678
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
679
+					}
630 680
 						$localtax1_type = $localtaxtmp_array[0];
631 681
 						$localtax2_type = $localtaxtmp_array[2];
632 682
 					}
633 683
 
634 684
 				    // retrieve global local tax
635
-					if ($localtax1_type && $localtax1ligne != 0)
636
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
637
-					if ($localtax2_type && $localtax2ligne != 0)
638
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
685
+					if ($localtax1_type && $localtax1ligne != 0) {
686
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
687
+					}
688
+					if ($localtax2_type && $localtax2ligne != 0) {
689
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
690
+					}
639 691
 
640
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
641
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
692
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
693
+					    $vatrate.='*';
694
+					}
695
+					if (! isset($this->tva[$vatrate])) {
696
+					    $this->tva[$vatrate]=0;
697
+					}
642 698
 					$this->tva[$vatrate] += $tvaligne;
643 699
 
644
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
700
+					if ($posYAfterImage > $posYAfterDescription) {
701
+					    $nexY=$posYAfterImage;
702
+					}
645 703
 
646 704
 					// Add line
647 705
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -662,8 +720,7 @@  discard block
 block discarded – undo
662 720
 						if ($pagenb == 1)
663 721
 						{
664 722
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
665
-						}
666
-						else
723
+						} else
667 724
 						{
668 725
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
669 726
 						}
@@ -671,24 +728,29 @@  discard block
 block discarded – undo
671 728
 						$pagenb++;
672 729
 						$pdf->setPage($pagenb);
673 730
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
674
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
731
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
732
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
733
+						}
675 734
 					}
676 735
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
677 736
 					{
678 737
 						if ($pagenb == 1)
679 738
 						{
680 739
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
681
-						}
682
-						else
740
+						} else
683 741
 						{
684 742
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
685 743
 						}
686 744
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
687 745
 						// New page
688 746
 						$pdf->AddPage();
689
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
747
+						if (! empty($tplidx)) {
748
+						    $pdf->useTemplate($tplidx);
749
+						}
690 750
 						$pagenb++;
691
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
751
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
752
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
753
+						}
692 754
 					}
693 755
 				}
694 756
 
@@ -697,8 +759,7 @@  discard block
 block discarded – undo
697 759
 				{
698 760
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
699 761
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
700
-				}
701
-				else
762
+				} else
702 763
 				{
703 764
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
704 765
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
@@ -726,7 +787,9 @@  discard block
 block discarded – undo
726 787
 
727 788
 				// Pied de page
728 789
 				$this->_pagefoot($pdf,$object,$outputlangs);
729
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
790
+				if (method_exists($pdf,'AliasNbPages')) {
791
+				    $pdf->AliasNbPages();
792
+				}
730 793
 
731 794
 				//If propal merge product PDF is active
732 795
 				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
@@ -769,8 +832,7 @@  discard block
 block discarded – undo
769 832
 											} elseif (! empty($conf->service->enabled)) {
770 833
 												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
771 834
 											}
772
-										}
773
-										else
835
+										} else
774 836
 										{
775 837
 											if (! empty($conf->product->enabled)) {
776 838
 												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
@@ -812,20 +874,19 @@  discard block
 block discarded – undo
812 874
 				global $action;
813 875
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
814 876
 
815
-				if (! empty($conf->global->MAIN_UMASK))
816
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
877
+				if (! empty($conf->global->MAIN_UMASK)) {
878
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
879
+				}
817 880
 
818 881
 				$this->result = array('fullpath'=>$file);
819 882
 
820 883
 				return 1;   // Pas d'erreur
821
-			}
822
-			else
884
+			} else
823 885
 			{
824 886
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
825 887
 				return 0;
826 888
 			}
827
-		}
828
-		else
889
+		} else
829 890
 		{
830 891
 			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
831 892
 			return 0;
@@ -892,10 +953,11 @@  discard block
 block discarded – undo
892 953
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
893 954
 
894 955
             $posy=$pdf->GetY()+1;
895
-		}
896
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
956
+		} elseif ($object->availability_code || $object->availability) {
957
+            // Show availability conditions
897 958
 		{
898 959
 			$pdf->SetFont('','B', $default_font_size - 2);
960
+        }
899 961
 			$pdf->SetXY($this->marge_gauche, $posy);
900 962
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
901 963
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -1011,7 +1073,10 @@  discard block
 block discarded – undo
1011 1073
 				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1012 1074
 				{
1013 1075
 					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1014
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1076
+					if (! empty($object->fk_bank)) {
1077
+					    $bankid=$object->fk_bank;
1078
+					}
1079
+					// For backward compatibility when object->fk_account is forced with object->fk_bank
1015 1080
 					$account = new Account($this->db);
1016 1081
 					$account->fetch($bankid);
1017 1082
 
@@ -1052,10 +1117,12 @@  discard block
 block discarded – undo
1052 1117
 
1053 1118
 		// Tableau total
1054 1119
 		$col1x = 120; $col2x = 170;
1055
-		if ($this->page_largeur < 210) // To work with US executive format
1120
+		if ($this->page_largeur < 210) {
1121
+		    // To work with US executive format
1056 1122
 		{
1057 1123
 			$col2x-=20;
1058 1124
 		}
1125
+		}
1059 1126
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1060 1127
 
1061 1128
 		$useborder=0;
@@ -1082,23 +1149,26 @@  discard block
 block discarded – undo
1082 1149
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1083 1150
 			{
1084 1151
 				// Nothing to do
1085
-			}
1086
-			else
1152
+			} else
1087 1153
 			{
1088 1154
 				//Local tax 1 before VAT
1089 1155
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1090 1156
 				//{
1091 1157
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1092 1158
 					{
1093
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1159
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1160
+						    continue;
1161
+						}
1094 1162
 
1095 1163
 						foreach( $localtax_rate as $tvakey => $tvaval )
1096 1164
 						{
1097
-							if ($tvakey!=0)    // On affiche pas taux 0
1165
+							if ($tvakey!=0) {
1166
+							    // On affiche pas taux 0
1098 1167
 							{
1099 1168
 								//$this->atleastoneratenotnull++;
1100 1169
 
1101 1170
 								$index++;
1171
+							}
1102 1172
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103 1173
 
1104 1174
 								$tvacompl='';
@@ -1122,17 +1192,21 @@  discard block
 block discarded – undo
1122 1192
 				//{
1123 1193
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1124 1194
 					{
1125
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1195
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1196
+						    continue;
1197
+						}
1126 1198
 
1127 1199
 						foreach( $localtax_rate as $tvakey => $tvaval )
1128 1200
 						{
1129
-							if ($tvakey!=0)    // On affiche pas taux 0
1201
+							if ($tvakey!=0) {
1202
+							    // On affiche pas taux 0
1130 1203
 							{
1131 1204
 								//$this->atleastoneratenotnull++;
1132 1205
 
1133 1206
 
1134 1207
 
1135 1208
 								$index++;
1209
+							}
1136 1210
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 1211
 
1138 1212
 								$tvacompl='';
@@ -1154,9 +1228,11 @@  discard block
 block discarded – undo
1154 1228
 				// VAT
1155 1229
 				foreach($this->tva as $tvakey => $tvaval)
1156 1230
 				{
1157
-					if ($tvakey != 0)    // On affiche pas taux 0
1231
+					if ($tvakey != 0) {
1232
+					    // On affiche pas taux 0
1158 1233
 					{
1159 1234
 						$this->atleastoneratenotnull++;
1235
+					}
1160 1236
 
1161 1237
 						$index++;
1162 1238
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1181,15 +1257,19 @@  discard block
 block discarded – undo
1181 1257
 				//{
1182 1258
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1183 1259
 					{
1184
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1260
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1261
+						    continue;
1262
+						}
1185 1263
 
1186 1264
 						foreach( $localtax_rate as $tvakey => $tvaval )
1187 1265
 						{
1188
-							if ($tvakey != 0)    // On affiche pas taux 0
1266
+							if ($tvakey != 0) {
1267
+							    // On affiche pas taux 0
1189 1268
 							{
1190 1269
 								//$this->atleastoneratenotnull++;
1191 1270
 
1192 1271
 								$index++;
1272
+							}
1193 1273
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1194 1274
 
1195 1275
 								$tvacompl='';
@@ -1213,16 +1293,20 @@  discard block
 block discarded – undo
1213 1293
 				//{
1214 1294
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1215 1295
 					{
1216
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1296
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1297
+						    continue;
1298
+						}
1217 1299
 
1218 1300
 						foreach( $localtax_rate as $tvakey => $tvaval )
1219 1301
 						{
1220 1302
 						    // retrieve global local tax
1221
-							if ($tvakey != 0)    // On affiche pas taux 0
1303
+							if ($tvakey != 0) {
1304
+							    // On affiche pas taux 0
1222 1305
 							{
1223 1306
 								//$this->atleastoneratenotnull++;
1224 1307
 
1225 1308
 								$index++;
1309
+							}
1226 1310
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1227 1311
 
1228 1312
 								$tvacompl='';
@@ -1324,7 +1408,9 @@  discard block
 block discarded – undo
1324 1408
 
1325 1409
 		// Force to disable hidetop and hidebottom
1326 1410
 		$hidebottom=0;
1327
-		if ($hidetop) $hidetop=-1;
1411
+		if ($hidetop) {
1412
+		    $hidetop=-1;
1413
+		}
1328 1414
 
1329 1415
 		$currency = !empty($currency) ? $currency : $conf->currency;
1330 1416
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1340,7 +1426,9 @@  discard block
 block discarded – undo
1340 1426
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1341 1427
 
1342 1428
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1343
-			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));
1429
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1430
+			    $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));
1431
+			}
1344 1432
 		}
1345 1433
 
1346 1434
 		$pdf->SetDrawColor(128,128,128);
@@ -1392,8 +1480,7 @@  discard block
 block discarded – undo
1392 1480
 			if($conf->global->PRODUCT_USE_UNITS)
1393 1481
 			{
1394 1482
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1395
-			}
1396
-			else
1483
+			} else
1397 1484
 			{
1398 1485
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1399 1486
 			}
@@ -1472,16 +1559,14 @@  discard block
 block discarded – undo
1472 1559
 				{
1473 1560
 				    $height=pdf_getHeightForLogo($logo);
1474 1561
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1475
-				}
1476
-				else
1562
+				} else
1477 1563
 				{
1478 1564
 					$pdf->SetTextColor(200,0,0);
1479 1565
 					$pdf->SetFont('','B',$default_font_size - 2);
1480 1566
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1481 1567
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1482 1568
 				}
1483
-			}
1484
-			else
1569
+			} else
1485 1570
 			{
1486 1571
 				$text=$this->emetteur->name;
1487 1572
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1574,7 +1659,9 @@  discard block
 block discarded – undo
1574 1659
 			// Show sender
1575 1660
 			$posy=42+$top_shift;
1576 1661
 		 	$posx=$this->marge_gauche;
1577
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1662
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1663
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1664
+			}
1578 1665
 			$hautcadre=40;
1579 1666
 
1580 1667
 			// Show sender frame
@@ -1622,10 +1709,15 @@  discard block
 block discarded – undo
1622 1709
 
1623 1710
 			// Show recipient
1624 1711
 			$widthrecbox=100;
1625
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1712
+			if ($this->page_largeur < 210) {
1713
+			    $widthrecbox=84;
1714
+			}
1715
+			// To work with US executive format
1626 1716
 			$posy=42+$top_shift;
1627 1717
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1628
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1718
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1719
+			    $posx=$this->marge_gauche;
1720
+			}
1629 1721
 
1630 1722
 			// Show recipient frame
1631 1723
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/propale/doc/pdf_cyan.modules.php 3 patches
Indentation   +1687 added lines, -1687 removed lines patch added patch discarded remove patch
@@ -41,85 +41,85 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class pdf_cyan extends ModelePDFPropales
43 43
 {
44
-	public $db;
45
-	public $name;
46
-	public $description;
47
-	public $update_main_doc_field;	// Save the name of generated file as the main doc when generating a doc with this template
48
-	public $type;
49
-
50
-	public $phpmin = array(4,3,0); // Minimum version of PHP required by module
51
-	public $version = 'development';
52
-
53
-	public $page_largeur;
54
-	public $page_hauteur;
55
-	public $format;
56
-	public $marge_gauche;
57
-	public	$marge_droite;
58
-	public	$marge_haute;
59
-	public	$marge_basse;
60
-
61
-	public $emetteur;	// Objet societe qui emet
62
-
63
-
64
-	/**
65
-	 *	Constructor
66
-	 *
67
-	 *  @param		DoliDB		$db      Database handler
68
-	 */
69
-	public function __construct($db)
70
-	{
71
-		global $conf,$langs,$mysoc;
72
-
73
-		// Translations
74
-		$langs->loadLangs(array("main", "bills"));
75
-
76
-		$this->db = $db;
77
-		$this->name = "cyan";
78
-		$this->description = $langs->trans('DocModelCyanDescription');
79
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
80
-
81
-		// Dimension page
82
-		$this->type = 'pdf';
83
-		$formatarray=pdf_getFormat();
84
-		$this->page_largeur = $formatarray['width'];
85
-		$this->page_hauteur = $formatarray['height'];
86
-		$this->format = array($this->page_largeur,$this->page_hauteur);
87
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
88
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
89
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
90
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
91
-
92
-		$this->option_logo = 1;                    // Affiche logo
93
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
94
-		$this->option_modereg = 1;                 // Affiche mode reglement
95
-		$this->option_condreg = 1;                 // Affiche conditions reglement
96
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
97
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
98
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
99
-		$this->option_credit_note = 0;             // Support credit notes
100
-		$this->option_freetext = 1;				   // Support add of a personalised text
101
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
102
-
103
-		$this->franchise=!$mysoc->tva_assuj;
104
-
105
-		// Get source company
106
-		$this->emetteur=$mysoc;
107
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
108
-
109
-		// Define position of columns
110
-		$this->posxdesc=$this->marge_gauche+1;
111
-
112
-
113
-
114
-		$this->tva=array();
115
-		$this->localtax1=array();
116
-		$this->localtax2=array();
117
-		$this->atleastoneratenotnull=0;
118
-		$this->atleastonediscount=0;
119
-	}
44
+    public $db;
45
+    public $name;
46
+    public $description;
47
+    public $update_main_doc_field;	// Save the name of generated file as the main doc when generating a doc with this template
48
+    public $type;
49
+
50
+    public $phpmin = array(4,3,0); // Minimum version of PHP required by module
51
+    public $version = 'development';
52
+
53
+    public $page_largeur;
54
+    public $page_hauteur;
55
+    public $format;
56
+    public $marge_gauche;
57
+    public	$marge_droite;
58
+    public	$marge_haute;
59
+    public	$marge_basse;
60
+
61
+    public $emetteur;	// Objet societe qui emet
62
+
63
+
64
+    /**
65
+     *	Constructor
66
+     *
67
+     *  @param		DoliDB		$db      Database handler
68
+     */
69
+    public function __construct($db)
70
+    {
71
+        global $conf,$langs,$mysoc;
72
+
73
+        // Translations
74
+        $langs->loadLangs(array("main", "bills"));
75
+
76
+        $this->db = $db;
77
+        $this->name = "cyan";
78
+        $this->description = $langs->trans('DocModelCyanDescription');
79
+        $this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
80
+
81
+        // Dimension page
82
+        $this->type = 'pdf';
83
+        $formatarray=pdf_getFormat();
84
+        $this->page_largeur = $formatarray['width'];
85
+        $this->page_hauteur = $formatarray['height'];
86
+        $this->format = array($this->page_largeur,$this->page_hauteur);
87
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
88
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
89
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
90
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
91
+
92
+        $this->option_logo = 1;                    // Affiche logo
93
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
94
+        $this->option_modereg = 1;                 // Affiche mode reglement
95
+        $this->option_condreg = 1;                 // Affiche conditions reglement
96
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
97
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
98
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
99
+        $this->option_credit_note = 0;             // Support credit notes
100
+        $this->option_freetext = 1;				   // Support add of a personalised text
101
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
102
+
103
+        $this->franchise=!$mysoc->tva_assuj;
104
+
105
+        // Get source company
106
+        $this->emetteur=$mysoc;
107
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
108
+
109
+        // Define position of columns
110
+        $this->posxdesc=$this->marge_gauche+1;
111
+
112
+
113
+
114
+        $this->tva=array();
115
+        $this->localtax1=array();
116
+        $this->localtax2=array();
117
+        $this->atleastoneratenotnull=0;
118
+        $this->atleastonediscount=0;
119
+    }
120 120
 
121 121
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
122
-	/**
122
+    /**
123 123
      *  Function to build pdf onto disk
124 124
      *
125 125
      *  @param		Object		$object				Object to generate
@@ -129,132 +129,132 @@  discard block
 block discarded – undo
129 129
      *  @param		int			$hidedesc			Do not show desc
130 130
      *  @param		int			$hideref			Do not show ref
131 131
      *  @return     int             				1=OK, 0=KO
132
-	 */
133
-	public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
134
-	{
135
-	  // phpcs:enable
136
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
137
-
138
-		if (! is_object($outputlangs)) $outputlangs=$langs;
139
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
140
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
141
-
142
-		$outputlangs->load("main");
143
-		$outputlangs->load("dict");
144
-		$outputlangs->load("companies");
145
-		$outputlangs->load("bills");
146
-		$outputlangs->load("propal");
147
-		$outputlangs->load("products");
148
-
149
-		$nblignes = count($object->lines);
150
-
151
-		// Loop on each lines to detect if there is at least one image to show
152
-		$realpatharray=array();
153
-		$this->atleastonephoto = false;
154
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
155
-		{
156
-			$objphoto = new Product($this->db);
157
-
158
-			for ($i = 0 ; $i < $nblignes ; $i++)
159
-			{
160
-				if (empty($object->lines[$i]->fk_product)) continue;
161
-
162
-				$objphoto->fetch($object->lines[$i]->fk_product);
132
+     */
133
+    public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
134
+    {
135
+        // phpcs:enable
136
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
137
+
138
+        if (! is_object($outputlangs)) $outputlangs=$langs;
139
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
140
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
141
+
142
+        $outputlangs->load("main");
143
+        $outputlangs->load("dict");
144
+        $outputlangs->load("companies");
145
+        $outputlangs->load("bills");
146
+        $outputlangs->load("propal");
147
+        $outputlangs->load("products");
148
+
149
+        $nblignes = count($object->lines);
150
+
151
+        // Loop on each lines to detect if there is at least one image to show
152
+        $realpatharray=array();
153
+        $this->atleastonephoto = false;
154
+        if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
155
+        {
156
+            $objphoto = new Product($this->db);
157
+
158
+            for ($i = 0 ; $i < $nblignes ; $i++)
159
+            {
160
+                if (empty($object->lines[$i]->fk_product)) continue;
161
+
162
+                $objphoto->fetch($object->lines[$i]->fk_product);
163 163
                 //var_dump($objphoto->ref);exit;
164
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
165
-				{
166
-					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
167
-					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
168
-				}
169
-				else
170
-				{
171
-					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
172
-					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
173
-				}
174
-
175
-				$arephoto = false;
176
-				foreach ($pdir as $midir)
177
-				{
178
-					if (! $arephoto)
179
-					{
180
-						$dir = $conf->product->dir_output.'/'.$midir;
181
-
182
-						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
183
-						{
184
-							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
185
-							{
186
-								if ($obj['photo_vignette'])
187
-								{
188
-									$filename= $obj['photo_vignette'];
189
-								}
190
-								else
191
-								{
192
-									$filename=$obj['photo'];
193
-								}
194
-							}
195
-							else
196
-							{
197
-								$filename=$obj['photo'];
198
-							}
199
-
200
-							$realpath = $dir.$filename;
201
-							$arephoto = true;
202
-							$this->atleastonephoto = true;
203
-						}
204
-					}
205
-				}
206
-
207
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
208
-			}
209
-		}
210
-
211
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
212
-
213
-		if ($conf->propal->multidir_output[$conf->entity])
214
-		{
215
-			$object->fetch_thirdparty();
216
-
217
-			$deja_regle = 0;
164
+                if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
165
+                {
166
+                    $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
167
+                    $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
168
+                }
169
+                else
170
+                {
171
+                    $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
172
+                    $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
173
+                }
218 174
 
219
-			// Definition of $dir and $file
220
-			if ($object->specimen)
221
-			{
222
-				$dir = $conf->propal->multidir_output[$conf->entity];
223
-				$file = $dir . "/SPECIMEN.pdf";
224
-			}
225
-			else
226
-			{
227
-				$objectref = dol_sanitizeFileName($object->ref);
228
-				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
229
-				$file = $dir . "/" . $objectref . ".pdf";
230
-			}
175
+                $arephoto = false;
176
+                foreach ($pdir as $midir)
177
+                {
178
+                    if (! $arephoto)
179
+                    {
180
+                        $dir = $conf->product->dir_output.'/'.$midir;
181
+
182
+                        foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
183
+                        {
184
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
185
+                            {
186
+                                if ($obj['photo_vignette'])
187
+                                {
188
+                                    $filename= $obj['photo_vignette'];
189
+                                }
190
+                                else
191
+                                {
192
+                                    $filename=$obj['photo'];
193
+                                }
194
+                            }
195
+                            else
196
+                            {
197
+                                $filename=$obj['photo'];
198
+                            }
199
+
200
+                            $realpath = $dir.$filename;
201
+                            $arephoto = true;
202
+                            $this->atleastonephoto = true;
203
+                        }
204
+                    }
205
+                }
231 206
 
232
-			if (! file_exists($dir))
233
-			{
234
-				if (dol_mkdir($dir) < 0)
235
-				{
236
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
237
-					return 0;
238
-				}
239
-			}
207
+                if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
208
+            }
209
+        }
210
+
211
+        if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
212
+
213
+        if ($conf->propal->multidir_output[$conf->entity])
214
+        {
215
+            $object->fetch_thirdparty();
216
+
217
+            $deja_regle = 0;
218
+
219
+            // Definition of $dir and $file
220
+            if ($object->specimen)
221
+            {
222
+                $dir = $conf->propal->multidir_output[$conf->entity];
223
+                $file = $dir . "/SPECIMEN.pdf";
224
+            }
225
+            else
226
+            {
227
+                $objectref = dol_sanitizeFileName($object->ref);
228
+                $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
229
+                $file = $dir . "/" . $objectref . ".pdf";
230
+            }
231
+
232
+            if (! file_exists($dir))
233
+            {
234
+                if (dol_mkdir($dir) < 0)
235
+                {
236
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
237
+                    return 0;
238
+                }
239
+            }
240 240
 
241
-			if (file_exists($dir))
242
-			{
243
-				// Add pdfgeneration hook
244
-				if (! is_object($hookmanager))
245
-				{
246
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
247
-					$hookmanager=new HookManager($this->db);
248
-				}
249
-				$hookmanager->initHooks(array('pdfgeneration'));
250
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
251
-				global $action;
252
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
241
+            if (file_exists($dir))
242
+            {
243
+                // Add pdfgeneration hook
244
+                if (! is_object($hookmanager))
245
+                {
246
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
247
+                    $hookmanager=new HookManager($this->db);
248
+                }
249
+                $hookmanager->initHooks(array('pdfgeneration'));
250
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
251
+                global $action;
252
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
253 253
 
254
-				// Create pdf instance
254
+                // Create pdf instance
255 255
                 $pdf=pdf_getInstance($this->format);
256 256
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
257
-	            $pdf->SetAutoPageBreak(1,0);
257
+                $pdf->SetAutoPageBreak(1,0);
258 258
 
259 259
                 if (class_exists('TCPDF'))
260 260
                 {
@@ -269,33 +269,33 @@  discard block
 block discarded – undo
269 269
                     $tplidx = $pdf->importPage(1);
270 270
                 }
271 271
 
272
-				$pdf->Open();
273
-				$pagenb=0;
274
-				$pdf->SetDrawColor(128,128,128);
275
-
276
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
277
-				$pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
278
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
279
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
280
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
281
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
282
-
283
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
284
-
285
-				// Does we have at least one line with discount $this->atleastonediscount
286
-				foreach ($object->lines as $line) {
287
-				    if ($line->remise_percent){
288
-				        $this->atleastonediscount = true;
289
-				        break;
290
-				    }
291
-				}
272
+                $pdf->Open();
273
+                $pagenb=0;
274
+                $pdf->SetDrawColor(128,128,128);
275
+
276
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
277
+                $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
278
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
279
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
280
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
281
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
282
+
283
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
284
+
285
+                // Does we have at least one line with discount $this->atleastonediscount
286
+                foreach ($object->lines as $line) {
287
+                    if ($line->remise_percent){
288
+                        $this->atleastonediscount = true;
289
+                        break;
290
+                    }
291
+                }
292 292
 
293 293
 
294 294
 
295
-				// New page
296
-				$pdf->AddPage();
297
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
298
-				$pagenb++;
295
+                // New page
296
+                $pdf->AddPage();
297
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
298
+                $pagenb++;
299 299
 
300 300
                 $heightforinfotot = 40;	// Height reserved to output the info and total part
301 301
                 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
@@ -303,669 +303,669 @@  discard block
 block discarded – undo
303 303
                 $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)
304 304
                 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
305 305
 
306
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
307
-				$pdf->SetFont('','', $default_font_size - 1);
308
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-				$pdf->SetTextColor(0,0,0);
306
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
307
+                $pdf->SetFont('','', $default_font_size - 1);
308
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
309
+                $pdf->SetTextColor(0,0,0);
310 310
 
311 311
 
312
-	            $tab_top = 90+$top_shift;
313
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
312
+                $tab_top = 90+$top_shift;
313
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
314 314
 
315 315
 
316
-				// Incoterm
317
-				$height_incoterms = 0;
318
-				if ($conf->incoterm->enabled)
319
-				{
320
-					$desc_incoterms = $object->getIncotermsForPDF();
321
-					if ($desc_incoterms)
322
-					{
323
-						$tab_top -= 2;
324
-
325
-						$pdf->SetFont('','', $default_font_size - 1);
326
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
327
-						$nexY = $pdf->GetY();
328
-						$height_incoterms=$nexY-$tab_top;
329
-
330
-						// Rect prend une longueur en 3eme param
331
-						$pdf->SetDrawColor(192,192,192);
332
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
333
-
334
-						$tab_top = $nexY+6;
335
-					}
336
-				}
316
+                // Incoterm
317
+                $height_incoterms = 0;
318
+                if ($conf->incoterm->enabled)
319
+                {
320
+                    $desc_incoterms = $object->getIncotermsForPDF();
321
+                    if ($desc_incoterms)
322
+                    {
323
+                        $tab_top -= 2;
324
+
325
+                        $pdf->SetFont('','', $default_font_size - 1);
326
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
327
+                        $nexY = $pdf->GetY();
328
+                        $height_incoterms=$nexY-$tab_top;
329
+
330
+                        // Rect prend une longueur en 3eme param
331
+                        $pdf->SetDrawColor(192,192,192);
332
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
333
+
334
+                        $tab_top = $nexY+6;
335
+                    }
336
+                }
337 337
 
338
-				// Affiche notes
339
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
340
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
341
-				{
342
-					// Get first sale rep
343
-					if (is_object($object->thirdparty))
344
-					{
345
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
346
-						$salerepobj=new User($this->db);
347
-						$salerepobj->fetch($salereparray[0]['id']);
348
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
349
-					}
350
-				}
351
-				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
352
-				{
353
-				    $tmpuser=new User($this->db);
354
-				    $tmpuser->fetch($object->user_author_id);
355
-				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
356
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
357
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
358
-				}
338
+                // Affiche notes
339
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
340
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
341
+                {
342
+                    // Get first sale rep
343
+                    if (is_object($object->thirdparty))
344
+                    {
345
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
346
+                        $salerepobj=new User($this->db);
347
+                        $salerepobj->fetch($salereparray[0]['id']);
348
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
349
+                    }
350
+                }
351
+                if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
352
+                {
353
+                    $tmpuser=new User($this->db);
354
+                    $tmpuser->fetch($object->user_author_id);
355
+                    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
356
+                    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
357
+                    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
358
+                }
359 359
 
360
-				$pagenb = $pdf->getPage();
361
-				if ($notetoshow)
362
-				{
363
-					$tab_top -= 2;
364
-
365
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
366
-				    $pageposbeforenote = $pagenb;
367
-
368
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
369
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
370
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
371
-
372
-
373
-					$pdf->startTransaction();
374
-
375
-					$pdf->SetFont('','', $default_font_size - 1);
376
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
377
-					// Description
378
-					$pageposafternote=$pdf->getPage();
379
-					$posyafter = $pdf->GetY();
380
-
381
-					if($pageposafternote>$pageposbeforenote )
382
-					{
383
-					    $pdf->rollbackTransaction(true);
384
-
385
-					    // prepar pages to receive notes
386
-					    while ($pagenb < $pageposafternote) {
387
-					        $pdf->AddPage();
388
-					        $pagenb++;
389
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
390
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
391
-					        // $this->_pagefoot($pdf,$object,$outputlangs,1);
392
-					        $pdf->setTopMargin($tab_top_newpage);
393
-					        // The only function to edit the bottom margin of current page to set it.
394
-					        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
395
-					    }
396
-
397
-					    // back to start
398
-					    $pdf->setPage($pageposbeforenote);
399
-					    $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
400
-					    $pdf->SetFont('','', $default_font_size - 1);
401
-					    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
402
-					    $pageposafternote=$pdf->getPage();
403
-
404
-					    $posyafter = $pdf->GetY();
405
-
406
-					    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
407
-					    {
408
-					        $pdf->AddPage('','',true);
409
-					        $pagenb++;
410
-					        $pageposafternote++;
411
-					        $pdf->setPage($pageposafternote);
412
-					        $pdf->setTopMargin($tab_top_newpage);
413
-					        // The only function to edit the bottom margin of current page to set it.
414
-					        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
415
-					        //$posyafter = $tab_top_newpage;
416
-					    }
417
-
418
-
419
-					    // apply note frame to previus pages
420
-					    $i = $pageposbeforenote;
421
-					    while ($i < $pageposafternote) {
422
-					        $pdf->setPage($i);
423
-
424
-
425
-					        $pdf->SetDrawColor(128,128,128);
426
-					        // Draw note frame
427
-					        if($i>$pageposbeforenote){
428
-					            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429
-					            $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
430
-					        }
431
-					        else{
432
-					            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
433
-					            $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
434
-					        }
435
-
436
-					        // Add footer
437
-					        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
438
-					        $this->_pagefoot($pdf,$object,$outputlangs,1);
439
-
440
-					        $i++;
441
-					    }
442
-
443
-					    // apply note frame to last page
444
-					    $pdf->setPage($pageposafternote);
445
-					    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
446
-					    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
447
-					    $height_note=$posyafter-$tab_top_newpage;
448
-					    $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
449
-					}
450
-					else // No pagebreak
451
-					{
452
-					    $pdf->commitTransaction();
453
-					    $posyafter = $pdf->GetY();
454
-					    $height_note=$posyafter-$tab_top;
455
-					    $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
456
-
457
-
458
-					    if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
459
-					    {
460
-					        // not enough space, need to add page
461
-					        $pdf->AddPage('','',true);
462
-					        $pagenb++;
463
-					        $pageposafternote++;
464
-					        $pdf->setPage($pageposafternote);
465
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
466
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
467
-
468
-					        $posyafter = $tab_top_newpage;
469
-					    }
470
-					}
471
-
472
-					$tab_height = $tab_height - $height_note;
473
-					$tab_top = $posyafter +6;
474
-				}
475
-				else
476
-				{
477
-					$height_note=0;
478
-				}
360
+                $pagenb = $pdf->getPage();
361
+                if ($notetoshow)
362
+                {
363
+                    $tab_top -= 2;
364
+
365
+                    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
366
+                    $pageposbeforenote = $pagenb;
367
+
368
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
369
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
370
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
371
+
372
+
373
+                    $pdf->startTransaction();
374
+
375
+                    $pdf->SetFont('','', $default_font_size - 1);
376
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
377
+                    // Description
378
+                    $pageposafternote=$pdf->getPage();
379
+                    $posyafter = $pdf->GetY();
380
+
381
+                    if($pageposafternote>$pageposbeforenote )
382
+                    {
383
+                        $pdf->rollbackTransaction(true);
384
+
385
+                        // prepar pages to receive notes
386
+                        while ($pagenb < $pageposafternote) {
387
+                            $pdf->AddPage();
388
+                            $pagenb++;
389
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
390
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
391
+                            // $this->_pagefoot($pdf,$object,$outputlangs,1);
392
+                            $pdf->setTopMargin($tab_top_newpage);
393
+                            // The only function to edit the bottom margin of current page to set it.
394
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
395
+                        }
396
+
397
+                        // back to start
398
+                        $pdf->setPage($pageposbeforenote);
399
+                        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
400
+                        $pdf->SetFont('','', $default_font_size - 1);
401
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
402
+                        $pageposafternote=$pdf->getPage();
403
+
404
+                        $posyafter = $pdf->GetY();
405
+
406
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
407
+                        {
408
+                            $pdf->AddPage('','',true);
409
+                            $pagenb++;
410
+                            $pageposafternote++;
411
+                            $pdf->setPage($pageposafternote);
412
+                            $pdf->setTopMargin($tab_top_newpage);
413
+                            // The only function to edit the bottom margin of current page to set it.
414
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
415
+                            //$posyafter = $tab_top_newpage;
416
+                        }
417
+
418
+
419
+                        // apply note frame to previus pages
420
+                        $i = $pageposbeforenote;
421
+                        while ($i < $pageposafternote) {
422
+                            $pdf->setPage($i);
423
+
424
+
425
+                            $pdf->SetDrawColor(128,128,128);
426
+                            // Draw note frame
427
+                            if($i>$pageposbeforenote){
428
+                                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429
+                                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
430
+                            }
431
+                            else{
432
+                                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
433
+                                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
434
+                            }
435
+
436
+                            // Add footer
437
+                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
438
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
439
+
440
+                            $i++;
441
+                        }
442
+
443
+                        // apply note frame to last page
444
+                        $pdf->setPage($pageposafternote);
445
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
446
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
447
+                        $height_note=$posyafter-$tab_top_newpage;
448
+                        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
449
+                    }
450
+                    else // No pagebreak
451
+                    {
452
+                        $pdf->commitTransaction();
453
+                        $posyafter = $pdf->GetY();
454
+                        $height_note=$posyafter-$tab_top;
455
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
456
+
457
+
458
+                        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
459
+                        {
460
+                            // not enough space, need to add page
461
+                            $pdf->AddPage('','',true);
462
+                            $pagenb++;
463
+                            $pageposafternote++;
464
+                            $pdf->setPage($pageposafternote);
465
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
466
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
467
+
468
+                            $posyafter = $tab_top_newpage;
469
+                        }
470
+                    }
471
+
472
+                    $tab_height = $tab_height - $height_note;
473
+                    $tab_top = $posyafter +6;
474
+                }
475
+                else
476
+                {
477
+                    $height_note=0;
478
+                }
479 479
 
480
-				$iniY = $tab_top + 7;
481
-				$curY = $tab_top + 7;
482
-				$nexY = $tab_top + 7;
480
+                $iniY = $tab_top + 7;
481
+                $curY = $tab_top + 7;
482
+                $nexY = $tab_top + 7;
483 483
 
484
-				// Use new auto collum system
485
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
484
+                // Use new auto collum system
485
+                $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
486 486
 
487
-				// Loop on each lines
488
-				$pageposbeforeprintlines=$pdf->getPage();
489
-				$pagenb = $pageposbeforeprintlines;
490
-				for ($i = 0; $i < $nblignes; $i++)
491
-				{
492
-					$curY = $nexY;
493
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
494
-					$pdf->SetTextColor(0,0,0);
495
-
496
-					// Define size of image if we need it
497
-					$imglinesize=array();
498
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
499
-
500
-					$pdf->setTopMargin($tab_top_newpage);
501
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
502
-					$pageposbefore=$pdf->getPage();
503
-
504
-					$showpricebeforepagebreak=1;
505
-					$posYAfterImage=0;
506
-					$posYAfterDescription=0;
507
-
508
-					if($this->getColumnStatus('photo'))
509
-					{
510
-    					// We start with Photo of product line
511
-    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
512
-    					{
513
-    						$pdf->AddPage('','',true);
514
-    						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
515
-    						//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
516
-    						$pdf->setPage($pageposbefore+1);
517
-
518
-    						$curY = $tab_top_newpage;
519
-    						$showpricebeforepagebreak=0;
520
-    					}
521
-
522
-
523
-    					if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
524
-    					{
525
-    						$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
526
-    						// $pdf->Image does not increase value return by getY, so we save it manually
527
-    						$posYAfterImage=$curY+$imglinesize['height'];
528
-    					}
529
-					}
530
-
531
-					// Description of product line
532
-					if($this->getColumnStatus('desc'))
533
-					{
534
-    					$pdf->startTransaction();
535
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
536
-    					$pageposafter=$pdf->getPage();
537
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
538
-    					{
539
-    						$pdf->rollbackTransaction(true);
540
-    						$pageposafter=$pageposbefore;
541
-    						//print $pageposafter.'-'.$pageposbefore;exit;
542
-    						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
543
-    						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
544
-
545
-    						$pageposafter=$pdf->getPage();
546
-    						$posyafter=$pdf->GetY();
547
-    						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
548
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
549
-    						{
550
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
551
-    							{
552
-    								$pdf->AddPage('','',true);
553
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
554
-    								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
555
-    								$pdf->setPage($pageposafter+1);
556
-    							}
557
-    						}
558
-    						else
559
-    						{
560
-    							// We found a page break
561
-    							$showpricebeforepagebreak=0;
562
-    						}
563
-    					}
564
-    					else	// No pagebreak
565
-    					{
566
-    						$pdf->commitTransaction();
567
-    					}
568
-    					$posYAfterDescription=$pdf->GetY();
569
-					}
570
-
571
-					$nexY = $pdf->GetY();
572
-					$pageposafter=$pdf->getPage();
573
-
574
-					$pdf->setPage($pageposbefore);
575
-					$pdf->setTopMargin($this->marge_haute);
576
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
577
-
578
-					// We suppose that a too long description or photo were moved completely on next page
579
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
580
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
581
-					}
582
-
583
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
584
-
585
-					// VAT Rate
586
-					if ($this->getColumnStatus('vat'))
587
-					{
588
-					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
589
-					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
590
-					    $nexY = max($pdf->GetY(),$nexY);
591
-					}
592
-
593
-					// Unit price before discount
594
-					if ($this->getColumnStatus('subprice'))
595
-					{
596
-					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
597
-					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
598
-					    $nexY = max($pdf->GetY(),$nexY);
599
-					}
600
-
601
-					// Quantity
602
-					// Enough for 6 chars
603
-					if ($this->getColumnStatus('qty'))
604
-					{
605
-					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
606
-					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
607
-					    $nexY = max($pdf->GetY(),$nexY);
608
-					}
609
-
610
-
611
-					// Unit
612
-					if ($this->getColumnStatus('unit'))
613
-					{
614
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
615
-					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
616
-					    $nexY = max($pdf->GetY(),$nexY);
617
-					}
618
-
619
-					// Discount on line
620
-					if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
621
-					{
622
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
623
-					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
624
-					    $nexY = max($pdf->GetY(),$nexY);
625
-					}
626
-
627
-					// Total HT line
628
-					if ($this->getColumnStatus('totalexcltax'))
629
-					{
630
-					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
631
-					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
632
-					    $nexY = max($pdf->GetY(),$nexY);
633
-					}
634
-
635
-
636
-					$parameters=array(
637
-					    'object' => $object,
638
-					    'i' => $i,
639
-					    'pdf' =>& $pdf,
640
-					    'curY' =>& $curY,
641
-					    'nexY' =>& $nexY,
642
-					    'outputlangs' => $outputlangs,
643
-					    'hidedetails' => $hidedetails
644
-					);
645
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
646
-
647
-
648
-
649
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
650
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
651
-					else $tvaligne=$object->lines[$i]->total_tva;
652
-
653
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
654
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
655
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
656
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
657
-					$localtax1_type=$object->lines[$i]->localtax1_type;
658
-					$localtax2_type=$object->lines[$i]->localtax2_type;
659
-
660
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
661
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
662
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
663
-
664
-					$vatrate=(string) $object->lines[$i]->tva_tx;
665
-
666
-					// Retrieve type from database for backward compatibility with old records
667
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
668
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
669
-					{
670
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
671
-						$localtax1_type = $localtaxtmp_array[0];
672
-						$localtax2_type = $localtaxtmp_array[2];
673
-					}
674
-
675
-				    // retrieve global local tax
676
-					if ($localtax1_type && $localtax1ligne != 0)
677
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
678
-					if ($localtax2_type && $localtax2ligne != 0)
679
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
680
-
681
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
682
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
683
-					$this->tva[$vatrate] += $tvaligne;
684
-
685
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
686
-
687
-					// Add line
688
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
689
-					{
690
-						$pdf->setPage($pageposafter);
691
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
692
-						//$pdf->SetDrawColor(190,190,200);
693
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
694
-						$pdf->SetLineStyle(array('dash'=>0));
695
-					}
696
-
697
-					$nexY+=2;    // Passe espace entre les lignes
698
-
699
-					// Detect if some page were added automatically and output _tableau for past pages
700
-					while ($pagenb < $pageposafter)
701
-					{
702
-						$pdf->setPage($pagenb);
703
-						if ($pagenb == $pageposbeforeprintlines)
704
-						{
705
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
706
-						}
707
-						else
708
-						{
709
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
710
-						}
711
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
712
-						$pagenb++;
713
-						$pdf->setPage($pagenb);
714
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
715
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
716
-					}
717
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
718
-					{
719
-					    if ($pagenb == $pageposafter)
720
-						{
721
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
722
-						}
723
-						else
724
-						{
725
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
726
-						}
727
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
728
-						// New page
729
-						$pdf->AddPage();
730
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
731
-						$pagenb++;
732
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
733
-					}
734
-				}
487
+                // Loop on each lines
488
+                $pageposbeforeprintlines=$pdf->getPage();
489
+                $pagenb = $pageposbeforeprintlines;
490
+                for ($i = 0; $i < $nblignes; $i++)
491
+                {
492
+                    $curY = $nexY;
493
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
494
+                    $pdf->SetTextColor(0,0,0);
495
+
496
+                    // Define size of image if we need it
497
+                    $imglinesize=array();
498
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
499
+
500
+                    $pdf->setTopMargin($tab_top_newpage);
501
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
502
+                    $pageposbefore=$pdf->getPage();
503
+
504
+                    $showpricebeforepagebreak=1;
505
+                    $posYAfterImage=0;
506
+                    $posYAfterDescription=0;
507
+
508
+                    if($this->getColumnStatus('photo'))
509
+                    {
510
+                        // We start with Photo of product line
511
+                        if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
512
+                        {
513
+                            $pdf->AddPage('','',true);
514
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
515
+                            //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
516
+                            $pdf->setPage($pageposbefore+1);
517
+
518
+                            $curY = $tab_top_newpage;
519
+                            $showpricebeforepagebreak=0;
520
+                        }
521
+
522
+
523
+                        if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
524
+                        {
525
+                            $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
526
+                            // $pdf->Image does not increase value return by getY, so we save it manually
527
+                            $posYAfterImage=$curY+$imglinesize['height'];
528
+                        }
529
+                    }
530
+
531
+                    // Description of product line
532
+                    if($this->getColumnStatus('desc'))
533
+                    {
534
+                        $pdf->startTransaction();
535
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
536
+                        $pageposafter=$pdf->getPage();
537
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
538
+                        {
539
+                            $pdf->rollbackTransaction(true);
540
+                            $pageposafter=$pageposbefore;
541
+                            //print $pageposafter.'-'.$pageposbefore;exit;
542
+                            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
543
+                            pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
544
+
545
+                            $pageposafter=$pdf->getPage();
546
+                            $posyafter=$pdf->GetY();
547
+                            //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
548
+                            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
549
+                            {
550
+                                if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
551
+                                {
552
+                                    $pdf->AddPage('','',true);
553
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
554
+                                    //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
555
+                                    $pdf->setPage($pageposafter+1);
556
+                                }
557
+                            }
558
+                            else
559
+                            {
560
+                                // We found a page break
561
+                                $showpricebeforepagebreak=0;
562
+                            }
563
+                        }
564
+                        else	// No pagebreak
565
+                        {
566
+                            $pdf->commitTransaction();
567
+                        }
568
+                        $posYAfterDescription=$pdf->GetY();
569
+                    }
570
+
571
+                    $nexY = $pdf->GetY();
572
+                    $pageposafter=$pdf->getPage();
573
+
574
+                    $pdf->setPage($pageposbefore);
575
+                    $pdf->setTopMargin($this->marge_haute);
576
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
577
+
578
+                    // We suppose that a too long description or photo were moved completely on next page
579
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
580
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
581
+                    }
582
+
583
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
584
+
585
+                    // VAT Rate
586
+                    if ($this->getColumnStatus('vat'))
587
+                    {
588
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
589
+                        $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
590
+                        $nexY = max($pdf->GetY(),$nexY);
591
+                    }
592
+
593
+                    // Unit price before discount
594
+                    if ($this->getColumnStatus('subprice'))
595
+                    {
596
+                        $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
597
+                        $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
598
+                        $nexY = max($pdf->GetY(),$nexY);
599
+                    }
600
+
601
+                    // Quantity
602
+                    // Enough for 6 chars
603
+                    if ($this->getColumnStatus('qty'))
604
+                    {
605
+                        $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
606
+                        $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
607
+                        $nexY = max($pdf->GetY(),$nexY);
608
+                    }
609
+
610
+
611
+                    // Unit
612
+                    if ($this->getColumnStatus('unit'))
613
+                    {
614
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
615
+                        $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
616
+                        $nexY = max($pdf->GetY(),$nexY);
617
+                    }
618
+
619
+                    // Discount on line
620
+                    if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
621
+                    {
622
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
623
+                        $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
624
+                        $nexY = max($pdf->GetY(),$nexY);
625
+                    }
626
+
627
+                    // Total HT line
628
+                    if ($this->getColumnStatus('totalexcltax'))
629
+                    {
630
+                        $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
631
+                        $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
632
+                        $nexY = max($pdf->GetY(),$nexY);
633
+                    }
634
+
635
+
636
+                    $parameters=array(
637
+                        'object' => $object,
638
+                        'i' => $i,
639
+                        'pdf' =>& $pdf,
640
+                        'curY' =>& $curY,
641
+                        'nexY' =>& $nexY,
642
+                        'outputlangs' => $outputlangs,
643
+                        'hidedetails' => $hidedetails
644
+                    );
645
+                    $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
646
+
647
+
648
+
649
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
650
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
651
+                    else $tvaligne=$object->lines[$i]->total_tva;
652
+
653
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
654
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
655
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
656
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
657
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
658
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
659
+
660
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
661
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
662
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
663
+
664
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
665
+
666
+                    // Retrieve type from database for backward compatibility with old records
667
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
668
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
669
+                    {
670
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
671
+                        $localtax1_type = $localtaxtmp_array[0];
672
+                        $localtax2_type = $localtaxtmp_array[2];
673
+                    }
674
+
675
+                    // retrieve global local tax
676
+                    if ($localtax1_type && $localtax1ligne != 0)
677
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
678
+                    if ($localtax2_type && $localtax2ligne != 0)
679
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
680
+
681
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
682
+                    if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
683
+                    $this->tva[$vatrate] += $tvaligne;
684
+
685
+                    if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
686
+
687
+                    // Add line
688
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
689
+                    {
690
+                        $pdf->setPage($pageposafter);
691
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
692
+                        //$pdf->SetDrawColor(190,190,200);
693
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
694
+                        $pdf->SetLineStyle(array('dash'=>0));
695
+                    }
696
+
697
+                    $nexY+=2;    // Passe espace entre les lignes
698
+
699
+                    // Detect if some page were added automatically and output _tableau for past pages
700
+                    while ($pagenb < $pageposafter)
701
+                    {
702
+                        $pdf->setPage($pagenb);
703
+                        if ($pagenb == $pageposbeforeprintlines)
704
+                        {
705
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
706
+                        }
707
+                        else
708
+                        {
709
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
710
+                        }
711
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
712
+                        $pagenb++;
713
+                        $pdf->setPage($pagenb);
714
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
715
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
716
+                    }
717
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
718
+                    {
719
+                        if ($pagenb == $pageposafter)
720
+                        {
721
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
722
+                        }
723
+                        else
724
+                        {
725
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
726
+                        }
727
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
728
+                        // New page
729
+                        $pdf->AddPage();
730
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
731
+                        $pagenb++;
732
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
733
+                    }
734
+                }
735 735
 
736
-				// Show square
737
-				if ($pagenb == $pageposbeforeprintlines)
738
-				{
739
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
740
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
741
-				}
742
-				else
743
-				{
744
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
745
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
746
-				}
736
+                // Show square
737
+                if ($pagenb == $pageposbeforeprintlines)
738
+                {
739
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
740
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
741
+                }
742
+                else
743
+                {
744
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
745
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
746
+                }
747 747
 
748
-				// Affiche zone infos
749
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
748
+                // Affiche zone infos
749
+                $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
750 750
 
751
-				// Affiche zone totaux
752
-				$posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
751
+                // Affiche zone totaux
752
+                $posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
753 753
 
754
-				// Affiche zone versements
755
-				/*
754
+                // Affiche zone versements
755
+                /*
756 756
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
757 757
 				{
758 758
 					$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
759 759
 				}
760 760
 				*/
761 761
 
762
-				// Customer signature area
763
-				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
764
-				{
765
-				    $posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
766
-				}
767
-
768
-				// Pied de page
769
-				$this->_pagefoot($pdf,$object,$outputlangs);
770
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
771
-
772
-				//If propal merge product PDF is active
773
-				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
774
-				{
775
-					require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
776
-
777
-					$already_merged = array ();
778
-					foreach ( $object->lines as $line ) {
779
-						if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
780
-							// Find the desire PDF
781
-							$filetomerge = new Propalmergepdfproduct($this->db);
782
-
783
-							if ($conf->global->MAIN_MULTILANGS) {
784
-								$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
785
-							} else {
786
-								$filetomerge->fetch_by_product($line->fk_product);
787
-							}
788
-
789
-							$already_merged[] = $line->fk_product;
790
-
791
-							$product = new Product($this->db);
792
-							$product->fetch($line->fk_product);
793
-
794
-							if ($product->entity!=$conf->entity) {
795
-								$entity_product_file=$product->entity;
796
-							} else {
797
-								$entity_product_file=$conf->entity;
798
-							}
799
-
800
-							// If PDF is selected and file is not empty
801
-							if (count($filetomerge->lines) > 0) {
802
-								foreach ( $filetomerge->lines as $linefile ) {
803
-									if (! empty($linefile->id) && ! empty($linefile->file_name)) {
804
-
805
-
806
-										if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
807
-										{
808
-											if (! empty($conf->product->enabled)) {
809
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
810
-											} elseif (! empty($conf->service->enabled)) {
811
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
812
-											}
813
-										}
814
-										else
815
-										{
816
-											if (! empty($conf->product->enabled)) {
817
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
818
-											} elseif (! empty($conf->service->enabled)) {
819
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
820
-											}
821
-										}
822
-
823
-										dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
824
-
825
-										$infile = $filetomerge_dir . '/' . $linefile->file_name;
826
-										if (file_exists($infile) && is_readable($infile)) {
827
-											$pagecount = $pdf->setSourceFile($infile);
828
-											for($i = 1; $i <= $pagecount; $i ++) {
829
-												$tplIdx = $pdf->importPage($i);
830
-												if ($tplIdx!==false) {
831
-													$s = $pdf->getTemplatesize($tplIdx);
832
-													$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
833
-													$pdf->useTemplate($tplIdx);
834
-												} else {
835
-													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
836
-												}
837
-											}
838
-										}
839
-									}
840
-								}
841
-							}
842
-						}
843
-					}
844
-				}
845
-
846
-				$pdf->Close();
847
-
848
-				$pdf->Output($file,'F');
849
-
850
-				//Add pdfgeneration hook
851
-				$hookmanager->initHooks(array('pdfgeneration'));
852
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
853
-				global $action;
854
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
762
+                // Customer signature area
763
+                if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
764
+                {
765
+                    $posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
766
+                }
855 767
 
856
-				if (! empty($conf->global->MAIN_UMASK))
857
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
768
+                // Pied de page
769
+                $this->_pagefoot($pdf,$object,$outputlangs);
770
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
858 771
 
859
-				$this->result = array('fullpath'=>$file);
772
+                //If propal merge product PDF is active
773
+                if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
774
+                {
775
+                    require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
776
+
777
+                    $already_merged = array ();
778
+                    foreach ( $object->lines as $line ) {
779
+                        if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
780
+                            // Find the desire PDF
781
+                            $filetomerge = new Propalmergepdfproduct($this->db);
782
+
783
+                            if ($conf->global->MAIN_MULTILANGS) {
784
+                                $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
785
+                            } else {
786
+                                $filetomerge->fetch_by_product($line->fk_product);
787
+                            }
788
+
789
+                            $already_merged[] = $line->fk_product;
790
+
791
+                            $product = new Product($this->db);
792
+                            $product->fetch($line->fk_product);
793
+
794
+                            if ($product->entity!=$conf->entity) {
795
+                                $entity_product_file=$product->entity;
796
+                            } else {
797
+                                $entity_product_file=$conf->entity;
798
+                            }
799
+
800
+                            // If PDF is selected and file is not empty
801
+                            if (count($filetomerge->lines) > 0) {
802
+                                foreach ( $filetomerge->lines as $linefile ) {
803
+                                    if (! empty($linefile->id) && ! empty($linefile->file_name)) {
804
+
805
+
806
+                                        if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
807
+                                        {
808
+                                            if (! empty($conf->product->enabled)) {
809
+                                                $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
810
+                                            } elseif (! empty($conf->service->enabled)) {
811
+                                                $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
812
+                                            }
813
+                                        }
814
+                                        else
815
+                                        {
816
+                                            if (! empty($conf->product->enabled)) {
817
+                                                $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
818
+                                            } elseif (! empty($conf->service->enabled)) {
819
+                                                $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
820
+                                            }
821
+                                        }
822
+
823
+                                        dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
824
+
825
+                                        $infile = $filetomerge_dir . '/' . $linefile->file_name;
826
+                                        if (file_exists($infile) && is_readable($infile)) {
827
+                                            $pagecount = $pdf->setSourceFile($infile);
828
+                                            for($i = 1; $i <= $pagecount; $i ++) {
829
+                                                $tplIdx = $pdf->importPage($i);
830
+                                                if ($tplIdx!==false) {
831
+                                                    $s = $pdf->getTemplatesize($tplIdx);
832
+                                                    $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
833
+                                                    $pdf->useTemplate($tplIdx);
834
+                                                } else {
835
+                                                    setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
836
+                                                }
837
+                                            }
838
+                                        }
839
+                                    }
840
+                                }
841
+                            }
842
+                        }
843
+                    }
844
+                }
860 845
 
861
-				return 1;   // Pas d'erreur
862
-			}
863
-			else
864
-			{
865
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
866
-				return 0;
867
-			}
868
-		}
869
-		else
870
-		{
871
-			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
872
-			return 0;
873
-		}
874
-	}
875
-
876
-	/**
877
-	 *  Show payments table
878
-	 *
846
+                $pdf->Close();
847
+
848
+                $pdf->Output($file,'F');
849
+
850
+                //Add pdfgeneration hook
851
+                $hookmanager->initHooks(array('pdfgeneration'));
852
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
853
+                global $action;
854
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
855
+
856
+                if (! empty($conf->global->MAIN_UMASK))
857
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
858
+
859
+                $this->result = array('fullpath'=>$file);
860
+
861
+                return 1;   // Pas d'erreur
862
+            }
863
+            else
864
+            {
865
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
866
+                return 0;
867
+            }
868
+        }
869
+        else
870
+        {
871
+            $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
872
+            return 0;
873
+        }
874
+    }
875
+
876
+    /**
877
+     *  Show payments table
878
+     *
879 879
      *  @param	TCPDF		$pdf           Object PDF
880 880
      *  @param  Object		$object         Object proposal
881 881
      *  @param  int			$posy           Position y in PDF
882 882
      *  @param  Translate	$outputlangs    Object langs for output
883 883
      *  @return int             			<0 if KO, >0 if OK
884
-	 */
885
-	private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
886
-	{
887
-	}
888
-
889
-	/**
890
-	 *   Show miscellaneous information (payment mode, payment term, ...)
891
-	 *
892
-	 *   @param		TCPDF		$pdf     		Object PDF
893
-	 *   @param		Object		$object			Object to show
894
-	 *   @param		int			$posy			Y
895
-	 *   @param		Translate	$outputlangs	Langs object
896
-	 *   @return	void
897
-	 */
898
-	function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
899
-	{
900
-		global $conf;
901
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
902
-
903
-		$pdf->SetFont('','', $default_font_size - 1);
904
-
905
-		// If France, show VAT mention if not applicable
906
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
907
-		{
908
-			$pdf->SetFont('','B', $default_font_size - 2);
909
-			$pdf->SetXY($this->marge_gauche, $posy);
910
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
911
-
912
-			$posy=$pdf->GetY()+4;
913
-		}
914
-
915
-		$posxval=52;
884
+     */
885
+    private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
886
+    {
887
+    }
888
+
889
+    /**
890
+     *   Show miscellaneous information (payment mode, payment term, ...)
891
+     *
892
+     *   @param		TCPDF		$pdf     		Object PDF
893
+     *   @param		Object		$object			Object to show
894
+     *   @param		int			$posy			Y
895
+     *   @param		Translate	$outputlangs	Langs object
896
+     *   @return	void
897
+     */
898
+    function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
899
+    {
900
+        global $conf;
901
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
902
+
903
+        $pdf->SetFont('','', $default_font_size - 1);
904
+
905
+        // If France, show VAT mention if not applicable
906
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
907
+        {
908
+            $pdf->SetFont('','B', $default_font_size - 2);
909
+            $pdf->SetXY($this->marge_gauche, $posy);
910
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
911
+
912
+            $posy=$pdf->GetY()+4;
913
+        }
914
+
915
+        $posxval=52;
916 916
 
917 917
         // Show shipping date
918 918
         if (! empty($object->date_livraison))
919
-		{
919
+        {
920 920
             $outputlangs->load("sendings");
921
-			$pdf->SetFont('','B', $default_font_size - 2);
922
-			$pdf->SetXY($this->marge_gauche, $posy);
923
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
924
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
925
-			$pdf->SetFont('','', $default_font_size - 2);
926
-			$pdf->SetXY($posxval, $posy);
927
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
928
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
921
+            $pdf->SetFont('','B', $default_font_size - 2);
922
+            $pdf->SetXY($this->marge_gauche, $posy);
923
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
924
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
925
+            $pdf->SetFont('','', $default_font_size - 2);
926
+            $pdf->SetXY($posxval, $posy);
927
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
928
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
929 929
 
930 930
             $posy=$pdf->GetY()+1;
931
-		}
931
+        }
932 932
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
933
-		{
934
-			$pdf->SetFont('','B', $default_font_size - 2);
935
-			$pdf->SetXY($this->marge_gauche, $posy);
936
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
937
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
938
-			$pdf->SetTextColor(0,0,0);
939
-			$pdf->SetFont('','', $default_font_size - 2);
940
-			$pdf->SetXY($posxval, $posy);
941
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
942
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
943
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
944
-
945
-			$posy=$pdf->GetY()+1;
946
-		}
947
-
948
-		// Show payments conditions
949
-		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
950
-		{
951
-			$pdf->SetFont('','B', $default_font_size - 2);
952
-			$pdf->SetXY($this->marge_gauche, $posy);
953
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
954
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
955
-
956
-			$pdf->SetFont('','', $default_font_size - 2);
957
-			$pdf->SetXY($posxval, $posy);
958
-			$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);
959
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
960
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
961
-
962
-			$posy=$pdf->GetY()+3;
963
-		}
964
-
965
-		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
966
-		{
967
-			// Check a payment mode is defined
968
-			/* Not required on a proposal
933
+        {
934
+            $pdf->SetFont('','B', $default_font_size - 2);
935
+            $pdf->SetXY($this->marge_gauche, $posy);
936
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
937
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
938
+            $pdf->SetTextColor(0,0,0);
939
+            $pdf->SetFont('','', $default_font_size - 2);
940
+            $pdf->SetXY($posxval, $posy);
941
+            $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
942
+            $lib_availability=str_replace('\n',"\n",$lib_availability);
943
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
944
+
945
+            $posy=$pdf->GetY()+1;
946
+        }
947
+
948
+        // Show payments conditions
949
+        if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
950
+        {
951
+            $pdf->SetFont('','B', $default_font_size - 2);
952
+            $pdf->SetXY($this->marge_gauche, $posy);
953
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
954
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
955
+
956
+            $pdf->SetFont('','', $default_font_size - 2);
957
+            $pdf->SetXY($posxval, $posy);
958
+            $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);
959
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
960
+            $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
961
+
962
+            $posy=$pdf->GetY()+3;
963
+        }
964
+
965
+        if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
966
+        {
967
+            // Check a payment mode is defined
968
+            /* Not required on a proposal
969 969
 			if (empty($object->mode_reglement_code)
970 970
 			&& ! $conf->global->FACTURE_CHQ_NUMBER
971 971
 			&& ! $conf->global->FACTURE_RIB_NUMBER)
@@ -980,333 +980,333 @@  discard block
 block discarded – undo
980 980
 			}
981 981
 			*/
982 982
 
983
-			// Show payment mode
984
-			if ($object->mode_reglement_code
985
-			&& $object->mode_reglement_code != 'CHQ'
986
-			&& $object->mode_reglement_code != 'VIR')
987
-			{
988
-				$pdf->SetFont('','B', $default_font_size - 2);
989
-				$pdf->SetXY($this->marge_gauche, $posy);
990
-				$titre = $outputlangs->transnoentities("PaymentMode").':';
991
-				$pdf->MultiCell(80, 5, $titre, 0, 'L');
992
-				$pdf->SetFont('','', $default_font_size - 2);
993
-				$pdf->SetXY($posxval, $posy);
994
-				$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);
995
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
996
-
997
-				$posy=$pdf->GetY()+2;
998
-			}
999
-
1000
-			// Show payment mode CHQ
1001
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1002
-			{
1003
-				// Si mode reglement non force ou si force a CHQ
1004
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
1005
-				{
1006
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
1007
-
1008
-					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1009
-					{
1010
-						$account = new Account($this->db);
1011
-						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1012
-
1013
-						$pdf->SetXY($this->marge_gauche, $posy);
1014
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1015
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
1016
-						$posy=$pdf->GetY()+1;
1017
-
1018
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1019
-			            {
1020
-							$pdf->SetXY($this->marge_gauche, $posy);
1021
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1022
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1023
-							$posy=$pdf->GetY()+2;
1024
-			            }
1025
-					}
1026
-					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1027
-					{
1028
-						$pdf->SetXY($this->marge_gauche, $posy);
1029
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1030
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
1031
-						$posy=$pdf->GetY()+1;
1032
-
1033
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1034
-			            {
1035
-							$pdf->SetXY($this->marge_gauche, $posy);
1036
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1037
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1038
-							$posy=$pdf->GetY()+2;
1039
-			            }
1040
-					}
1041
-				}
1042
-			}
983
+            // Show payment mode
984
+            if ($object->mode_reglement_code
985
+            && $object->mode_reglement_code != 'CHQ'
986
+            && $object->mode_reglement_code != 'VIR')
987
+            {
988
+                $pdf->SetFont('','B', $default_font_size - 2);
989
+                $pdf->SetXY($this->marge_gauche, $posy);
990
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
991
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
992
+                $pdf->SetFont('','', $default_font_size - 2);
993
+                $pdf->SetXY($posxval, $posy);
994
+                $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);
995
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
996
+
997
+                $posy=$pdf->GetY()+2;
998
+            }
999
+
1000
+            // Show payment mode CHQ
1001
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1002
+            {
1003
+                // Si mode reglement non force ou si force a CHQ
1004
+                if (! empty($conf->global->FACTURE_CHQ_NUMBER))
1005
+                {
1006
+                    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
1007
+
1008
+                    if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1009
+                    {
1010
+                        $account = new Account($this->db);
1011
+                        $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1012
+
1013
+                        $pdf->SetXY($this->marge_gauche, $posy);
1014
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1015
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
1016
+                        $posy=$pdf->GetY()+1;
1017
+
1018
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1019
+                        {
1020
+                            $pdf->SetXY($this->marge_gauche, $posy);
1021
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
1022
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1023
+                            $posy=$pdf->GetY()+2;
1024
+                        }
1025
+                    }
1026
+                    if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1027
+                    {
1028
+                        $pdf->SetXY($this->marge_gauche, $posy);
1029
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1030
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
1031
+                        $posy=$pdf->GetY()+1;
1032
+
1033
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1034
+                        {
1035
+                            $pdf->SetXY($this->marge_gauche, $posy);
1036
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
1037
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1038
+                            $posy=$pdf->GetY()+2;
1039
+                        }
1040
+                    }
1041
+                }
1042
+            }
1043 1043
 
1044
-			// If payment mode not forced or forced to VIR, show payment with BAN
1045
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1046
-			{
1047
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1048
-				{
1049
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1050
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1051
-					$account = new Account($this->db);
1052
-					$account->fetch($bankid);
1044
+            // If payment mode not forced or forced to VIR, show payment with BAN
1045
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1046
+            {
1047
+                if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1048
+                {
1049
+                    $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1050
+                    if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1051
+                    $account = new Account($this->db);
1052
+                    $account->fetch($bankid);
1053 1053
 
1054
-					$curx=$this->marge_gauche;
1055
-					$cury=$posy;
1054
+                    $curx=$this->marge_gauche;
1055
+                    $cury=$posy;
1056 1056
 
1057
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1057
+                    $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1058 1058
 
1059
-					$posy+=2;
1060
-				}
1061
-			}
1062
-		}
1063
-
1064
-		return $posy;
1065
-	}
1066
-
1067
-
1068
-	/**
1069
-	 *	Show total to pay
1070
-	 *
1071
-	 *	@param	PDF			$pdf            Object PDF
1072
-	 *	@param  Facture		$object         Object invoice
1073
-	 *	@param  int			$deja_regle     Montant deja regle
1074
-	 *	@param	int			$posy			Position depart
1075
-	 *	@param	Translate	$outputlangs	Objet langs
1076
-	 *	@return int							Position pour suite
1077
-	 */
1078
-	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1079
-	{
1080
-		global $conf,$mysoc;
1081
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1082
-
1083
-		$tab2_top = $posy;
1084
-		$tab2_hl = 4;
1085
-		$pdf->SetFont('','', $default_font_size - 1);
1086
-
1087
-		// Tableau total
1088
-		$col1x = 120; $col2x = 170;
1089
-		if ($this->page_largeur < 210) // To work with US executive format
1090
-		{
1091
-			$col2x-=20;
1092
-		}
1093
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1094
-
1095
-		$useborder=0;
1096
-		$index = 0;
1097
-
1098
-		// Total HT
1099
-		$pdf->SetFillColor(255,255,255);
1100
-		$pdf->SetXY($col1x, $tab2_top + 0);
1101
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1102
-
1103
-		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1104
-		$pdf->SetXY($col2x, $tab2_top + 0);
1105
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1106
-
1107
-		// Show VAT by rates and total
1108
-		$pdf->SetFillColor(248,248,248);
1109
-
1110
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1111
-
1112
-		$this->atleastoneratenotnull=0;
1113
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1114
-		{
1115
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1116
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1117
-			{
1118
-				// Nothing to do
1119
-			}
1120
-			else
1121
-			{
1122
-				//Local tax 1 before VAT
1123
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1124
-				//{
1125
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1126
-					{
1127
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1128
-
1129
-						foreach( $localtax_rate as $tvakey => $tvaval )
1130
-						{
1131
-							if ($tvakey!=0)    // On affiche pas taux 0
1132
-							{
1133
-								//$this->atleastoneratenotnull++;
1134
-
1135
-								$index++;
1136
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137
-
1138
-								$tvacompl='';
1139
-								if (preg_match('/\*/',$tvakey))
1140
-								{
1141
-									$tvakey=str_replace('*','',$tvakey);
1142
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143
-								}
1144
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1145
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147
-
1148
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1150
-							}
1151
-						}
1152
-					}
1153
-	      		//}
1154
-				//Local tax 2 before VAT
1155
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1156
-				//{
1157
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1158
-					{
1159
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1160
-
1161
-						foreach( $localtax_rate as $tvakey => $tvaval )
1162
-						{
1163
-							if ($tvakey!=0)    // On affiche pas taux 0
1164
-							{
1165
-								//$this->atleastoneratenotnull++;
1166
-
1167
-
1168
-
1169
-								$index++;
1170
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1171
-
1172
-								$tvacompl='';
1173
-								if (preg_match('/\*/',$tvakey))
1174
-								{
1175
-									$tvakey=str_replace('*','',$tvakey);
1176
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1177
-								}
1178
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1179
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1180
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1181
-
1182
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1183
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1184
-							}
1185
-						}
1186
-					}
1187
-				//}
1188
-				// VAT
1189
-				foreach($this->tva as $tvakey => $tvaval)
1190
-				{
1191
-					if ($tvakey != 0)    // On affiche pas taux 0
1192
-					{
1193
-						$this->atleastoneratenotnull++;
1194
-
1195
-						$index++;
1196
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1197
-
1198
-						$tvacompl='';
1199
-						if (preg_match('/\*/',$tvakey))
1200
-						{
1201
-							$tvakey=str_replace('*','',$tvakey);
1202
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1203
-						}
1204
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1205
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1206
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1207
-
1208
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1209
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1210
-					}
1211
-				}
1059
+                    $posy+=2;
1060
+                }
1061
+            }
1062
+        }
1212 1063
 
1213
-				//Local tax 1 after VAT
1214
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1215
-				//{
1216
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1217
-					{
1218
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1219
-
1220
-						foreach( $localtax_rate as $tvakey => $tvaval )
1221
-						{
1222
-							if ($tvakey != 0)    // On affiche pas taux 0
1223
-							{
1224
-								//$this->atleastoneratenotnull++;
1225
-
1226
-								$index++;
1227
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1228
-
1229
-								$tvacompl='';
1230
-								if (preg_match('/\*/',$tvakey))
1231
-								{
1232
-									$tvakey=str_replace('*','',$tvakey);
1233
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1234
-								}
1235
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1236
-
1237
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1238
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1239
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1241
-							}
1242
-						}
1243
-					}
1244
-	      		//}
1245
-				//Local tax 2 after VAT
1246
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1247
-				//{
1248
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1249
-					{
1250
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1251
-
1252
-						foreach( $localtax_rate as $tvakey => $tvaval )
1253
-						{
1254
-						    // retrieve global local tax
1255
-							if ($tvakey != 0)    // On affiche pas taux 0
1256
-							{
1257
-								//$this->atleastoneratenotnull++;
1258
-
1259
-								$index++;
1260
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1261
-
1262
-								$tvacompl='';
1263
-								if (preg_match('/\*/',$tvakey))
1264
-								{
1265
-									$tvakey=str_replace('*','',$tvakey);
1266
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1267
-								}
1268
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1269
-
1270
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1271
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1272
-
1273
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1274
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1275
-							}
1276
-						}
1277
-					}
1278
-				//}
1279
-
1280
-				// Total TTC
1281
-				$index++;
1282
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1283
-				$pdf->SetTextColor(0,0,60);
1284
-				$pdf->SetFillColor(224,224,224);
1285
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1064
+        return $posy;
1065
+    }
1286 1066
 
1287
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1288
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1289
-			}
1290
-		}
1291 1067
 
1292
-		$pdf->SetTextColor(0,0,0);
1068
+    /**
1069
+     *	Show total to pay
1070
+     *
1071
+     *	@param	PDF			$pdf            Object PDF
1072
+     *	@param  Facture		$object         Object invoice
1073
+     *	@param  int			$deja_regle     Montant deja regle
1074
+     *	@param	int			$posy			Position depart
1075
+     *	@param	Translate	$outputlangs	Objet langs
1076
+     *	@return int							Position pour suite
1077
+     */
1078
+    private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1079
+    {
1080
+        global $conf,$mysoc;
1081
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1082
+
1083
+        $tab2_top = $posy;
1084
+        $tab2_hl = 4;
1085
+        $pdf->SetFont('','', $default_font_size - 1);
1086
+
1087
+        // Tableau total
1088
+        $col1x = 120; $col2x = 170;
1089
+        if ($this->page_largeur < 210) // To work with US executive format
1090
+        {
1091
+            $col2x-=20;
1092
+        }
1093
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1094
+
1095
+        $useborder=0;
1096
+        $index = 0;
1097
+
1098
+        // Total HT
1099
+        $pdf->SetFillColor(255,255,255);
1100
+        $pdf->SetXY($col1x, $tab2_top + 0);
1101
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1102
+
1103
+        $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1104
+        $pdf->SetXY($col2x, $tab2_top + 0);
1105
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1106
+
1107
+        // Show VAT by rates and total
1108
+        $pdf->SetFillColor(248,248,248);
1109
+
1110
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1111
+
1112
+        $this->atleastoneratenotnull=0;
1113
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1114
+        {
1115
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1116
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1117
+            {
1118
+                // Nothing to do
1119
+            }
1120
+            else
1121
+            {
1122
+                //Local tax 1 before VAT
1123
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1124
+                //{
1125
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1126
+                    {
1127
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1128
+
1129
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1130
+                        {
1131
+                            if ($tvakey!=0)    // On affiche pas taux 0
1132
+                            {
1133
+                                //$this->atleastoneratenotnull++;
1134
+
1135
+                                $index++;
1136
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137
+
1138
+                                $tvacompl='';
1139
+                                if (preg_match('/\*/',$tvakey))
1140
+                                {
1141
+                                    $tvakey=str_replace('*','',$tvakey);
1142
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143
+                                }
1144
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1145
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147
+
1148
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1150
+                            }
1151
+                        }
1152
+                    }
1153
+                    //}
1154
+                //Local tax 2 before VAT
1155
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1156
+                //{
1157
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1158
+                    {
1159
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1160
+
1161
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1162
+                        {
1163
+                            if ($tvakey!=0)    // On affiche pas taux 0
1164
+                            {
1165
+                                //$this->atleastoneratenotnull++;
1166
+
1167
+
1168
+
1169
+                                $index++;
1170
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1171
+
1172
+                                $tvacompl='';
1173
+                                if (preg_match('/\*/',$tvakey))
1174
+                                {
1175
+                                    $tvakey=str_replace('*','',$tvakey);
1176
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1177
+                                }
1178
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1179
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1180
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1181
+
1182
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1183
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1184
+                            }
1185
+                        }
1186
+                    }
1187
+                //}
1188
+                // VAT
1189
+                foreach($this->tva as $tvakey => $tvaval)
1190
+                {
1191
+                    if ($tvakey != 0)    // On affiche pas taux 0
1192
+                    {
1193
+                        $this->atleastoneratenotnull++;
1194
+
1195
+                        $index++;
1196
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1197
+
1198
+                        $tvacompl='';
1199
+                        if (preg_match('/\*/',$tvakey))
1200
+                        {
1201
+                            $tvakey=str_replace('*','',$tvakey);
1202
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1203
+                        }
1204
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1205
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
1206
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1207
+
1208
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1209
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1210
+                    }
1211
+                }
1293 1212
 
1294
-		/*
1213
+                //Local tax 1 after VAT
1214
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1215
+                //{
1216
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1217
+                    {
1218
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1219
+
1220
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1221
+                        {
1222
+                            if ($tvakey != 0)    // On affiche pas taux 0
1223
+                            {
1224
+                                //$this->atleastoneratenotnull++;
1225
+
1226
+                                $index++;
1227
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1228
+
1229
+                                $tvacompl='';
1230
+                                if (preg_match('/\*/',$tvakey))
1231
+                                {
1232
+                                    $tvakey=str_replace('*','',$tvakey);
1233
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1234
+                                }
1235
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1236
+
1237
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1238
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1239
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1241
+                            }
1242
+                        }
1243
+                    }
1244
+                    //}
1245
+                //Local tax 2 after VAT
1246
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1247
+                //{
1248
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1249
+                    {
1250
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1251
+
1252
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1253
+                        {
1254
+                            // retrieve global local tax
1255
+                            if ($tvakey != 0)    // On affiche pas taux 0
1256
+                            {
1257
+                                //$this->atleastoneratenotnull++;
1258
+
1259
+                                $index++;
1260
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1261
+
1262
+                                $tvacompl='';
1263
+                                if (preg_match('/\*/',$tvakey))
1264
+                                {
1265
+                                    $tvakey=str_replace('*','',$tvakey);
1266
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1267
+                                }
1268
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1269
+
1270
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1271
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1272
+
1273
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1274
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1275
+                            }
1276
+                        }
1277
+                    }
1278
+                //}
1279
+
1280
+                // Total TTC
1281
+                $index++;
1282
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1283
+                $pdf->SetTextColor(0,0,60);
1284
+                $pdf->SetFillColor(224,224,224);
1285
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1286
+
1287
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1288
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1289
+            }
1290
+        }
1291
+
1292
+        $pdf->SetTextColor(0,0,0);
1293
+
1294
+        /*
1295 1295
 		$resteapayer = $object->total_ttc - $deja_regle;
1296 1296
 		if (! empty($object->paye)) $resteapayer=0;
1297 1297
 		*/
1298 1298
 
1299
-		if ($deja_regle > 0)
1300
-		{
1301
-			$index++;
1299
+        if ($deja_regle > 0)
1300
+        {
1301
+            $index++;
1302 1302
 
1303
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1304
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1303
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1304
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1305 1305
 
1306
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1307
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1306
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1307
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1308 1308
 
1309
-			/*
1309
+            /*
1310 1310
 			if ($object->close_code == 'discount_vat')
1311 1311
 			{
1312 1312
 				$index++;
@@ -1322,398 +1322,398 @@  discard block
 block discarded – undo
1322 1322
 			}
1323 1323
 			*/
1324 1324
 
1325
-			$index++;
1326
-			$pdf->SetTextColor(0,0,60);
1327
-			$pdf->SetFillColor(224,224,224);
1328
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1329
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1330
-
1331
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1332
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1333
-
1334
-			$pdf->SetFont('','', $default_font_size - 1);
1335
-			$pdf->SetTextColor(0,0,0);
1336
-		}
1337
-
1338
-		$index++;
1339
-		return ($tab2_top + ($tab2_hl * $index));
1340
-	}
1341
-
1342
-	/**
1343
-	 *   Show table for lines
1344
-	 *
1345
-	 *   @param		PDF			$pdf     		Object PDF
1346
-	 *   @param		string		$tab_top		Top position of table
1347
-	 *   @param		string		$tab_height		Height of table (rectangle)
1348
-	 *   @param		int			$nexY			Y (not used)
1349
-	 *   @param		Translate	$outputlangs	Langs object
1350
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1351
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1352
-	 *   @param		string		$currency		Currency code
1353
-	 *   @return	void
1354
-	 */
1355
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1356
-	{
1357
-		global $conf;
1358
-
1359
-		// Force to disable hidetop and hidebottom
1360
-		$hidebottom=0;
1361
-		if ($hidetop) $hidetop=-1;
1362
-
1363
-		$currency = !empty($currency) ? $currency : $conf->currency;
1364
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1365
-
1366
-		// Amount in (at tab_top - 1)
1367
-		$pdf->SetTextColor(0,0,0);
1368
-		$pdf->SetFont('','', $default_font_size - 2);
1369
-
1370
-		if (empty($hidetop))
1371
-		{
1372
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1373
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1374
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1375
-
1376
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1377
-			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));
1378
-		}
1379
-
1380
-		$pdf->SetDrawColor(128,128,128);
1381
-		$pdf->SetFont('','', $default_font_size - 1);
1382
-
1383
-		// Output Rect
1384
-		$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
1385
-
1386
-
1387
-		foreach ($this->cols as $colKey => $colDef)
1388
-		{
1389
-		    if(!$this->getColumnStatus($colKey)) continue;
1390
-
1391
-		    // get title label
1392
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1393
-
1394
-		    // Add column separator
1395
-		    if(!empty($colDef['border-left'])){
1396
-		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1397
-		    }
1398
-
1399
-		    if (empty($hidetop))
1400
-		    {
1401
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1402
-
1403
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1404
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1405
-		    }
1406
-		}
1407
-
1408
-		if (empty($hidetop)){
1409
-			$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
1410
-		}
1411
-	}
1412
-
1413
-	/**
1414
-	 *  Show top header of page.
1415
-	 *
1416
-	 *  @param	PDF			$pdf     		Object PDF
1417
-	 *  @param  Object		$object     	Object to show
1418
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1419
-	 *  @param  Translate	$outputlangs	Object lang for output
1420
-	 *  @return	void
1421
-	 */
1422
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1423
-	{
1424
-		global $conf,$langs;
1425
-
1426
-		$outputlangs->load("main");
1427
-		$outputlangs->load("bills");
1428
-		$outputlangs->load("propal");
1429
-		$outputlangs->load("companies");
1430
-
1431
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1432
-
1433
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1434
-
1435
-		//  Show Draft Watermark
1436
-		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1437
-		{
1438
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1439
-		}
1325
+            $index++;
1326
+            $pdf->SetTextColor(0,0,60);
1327
+            $pdf->SetFillColor(224,224,224);
1328
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1329
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1440 1330
 
1441
-		$pdf->SetTextColor(0,0,60);
1442
-		$pdf->SetFont('','B', $default_font_size + 3);
1331
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1332
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1443 1333
 
1444
-		$posy=$this->marge_haute;
1445
-		$posx=$this->page_largeur-$this->marge_droite-100;
1334
+            $pdf->SetFont('','', $default_font_size - 1);
1335
+            $pdf->SetTextColor(0,0,0);
1336
+        }
1446 1337
 
1447
-		$pdf->SetXY($this->marge_gauche,$posy);
1338
+        $index++;
1339
+        return ($tab2_top + ($tab2_hl * $index));
1340
+    }
1448 1341
 
1449
-		// Logo
1450
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1451
-		{
1452
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1453
-			if ($this->emetteur->logo)
1454
-			{
1455
-				if (is_readable($logo))
1456
-				{
1457
-				    $height=pdf_getHeightForLogo($logo);
1458
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1459
-				}
1460
-				else
1461
-				{
1462
-					$pdf->SetTextColor(200,0,0);
1463
-					$pdf->SetFont('','B',$default_font_size - 2);
1464
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1465
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1466
-				}
1467
-			}
1468
-			else
1469
-			{
1470
-				$text=$this->emetteur->name;
1471
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1472
-			}
1473
-		}
1474
-
1475
-		$pdf->SetFont('','B',$default_font_size + 3);
1476
-		$pdf->SetXY($posx,$posy);
1477
-		$pdf->SetTextColor(0,0,60);
1478
-		$title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1479
-		$pdf->MultiCell(100, 4, $title, '', 'R');
1480
-
1481
-		$pdf->SetFont('','B',$default_font_size);
1482
-
1483
-		$posy+=5;
1484
-		$pdf->SetXY($posx,$posy);
1485
-		$pdf->SetTextColor(0,0,60);
1486
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1487
-
1488
-		$posy+=1;
1489
-		$pdf->SetFont('','', $default_font_size - 2);
1490
-
1491
-		if ($object->ref_client)
1492
-		{
1493
-			$posy+=4;
1494
-			$pdf->SetXY($posx,$posy);
1495
-			$pdf->SetTextColor(0,0,60);
1496
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1497
-		}
1498
-
1499
-		$posy+=4;
1500
-		$pdf->SetXY($posx,$posy);
1501
-		$pdf->SetTextColor(0,0,60);
1502
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1503
-
1504
-		$posy+=4;
1505
-		$pdf->SetXY($posx,$posy);
1506
-		$pdf->SetTextColor(0,0,60);
1507
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1508
-
1509
-		if ($object->thirdparty->code_client)
1510
-		{
1511
-			$posy+=4;
1512
-			$pdf->SetXY($posx,$posy);
1513
-			$pdf->SetTextColor(0,0,60);
1514
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1515
-		}
1516
-
1517
-		// Get contact
1518
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1519
-		{
1520
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1521
-		    if (count($arrayidcontact) > 0)
1522
-		    {
1523
-		        $usertmp=new User($this->db);
1524
-		        $usertmp->fetch($arrayidcontact[0]);
1525
-                $posy+=4;
1526
-                $pdf->SetXY($posx,$posy);
1527
-		        $pdf->SetTextColor(0,0,60);
1528
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1529
-		    }
1530
-		}
1531
-
1532
-		$posy+=2;
1533
-
1534
-		$top_shift = 0;
1535
-		// Show list of linked objects
1536
-		$current_y = $pdf->getY();
1537
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1538
-		if ($current_y < $pdf->getY())
1539
-		{
1540
-			$top_shift = $pdf->getY() - $current_y;
1541
-		}
1542
-
1543
-		if ($showaddress)
1544
-		{
1545
-			// Sender properties
1546
-			$carac_emetteur='';
1547
-		 	// Add internal contact of proposal if defined
1548
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1549
-		 	if (count($arrayidcontact) > 0)
1550
-		 	{
1551
-		 		$object->fetch_user($arrayidcontact[0]);
1552
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1553
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1554
-		 	}
1555
-
1556
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1557
-
1558
-			// Show sender
1559
-			$posy=42+$top_shift;
1560
-		 	$posx=$this->marge_gauche;
1561
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1562
-			$hautcadre=40;
1563
-
1564
-			// Show sender frame
1565
-			$pdf->SetTextColor(0,0,0);
1566
-			$pdf->SetFont('','', $default_font_size - 2);
1567
-			$pdf->SetXY($posx,$posy-5);
1568
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1569
-			$pdf->SetXY($posx,$posy);
1570
-			$pdf->SetFillColor(230,230,230);
1571
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1572
-			$pdf->SetTextColor(0,0,60);
1573
-
1574
-			// Show sender name
1575
-			$pdf->SetXY($posx+2,$posy+3);
1576
-			$pdf->SetFont('','B', $default_font_size);
1577
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1578
-			$posy=$pdf->getY();
1579
-
1580
-			// Show sender information
1581
-			$pdf->SetXY($posx+2,$posy);
1582
-			$pdf->SetFont('','', $default_font_size - 1);
1583
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1584
-
1585
-
1586
-			// If CUSTOMER contact defined, we use it
1587
-			$usecontact=false;
1588
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1589
-			if (count($arrayidcontact) > 0)
1590
-			{
1591
-				$usecontact=true;
1592
-				$result=$object->fetch_contact($arrayidcontact[0]);
1593
-			}
1342
+    /**
1343
+     *   Show table for lines
1344
+     *
1345
+     *   @param		PDF			$pdf     		Object PDF
1346
+     *   @param		string		$tab_top		Top position of table
1347
+     *   @param		string		$tab_height		Height of table (rectangle)
1348
+     *   @param		int			$nexY			Y (not used)
1349
+     *   @param		Translate	$outputlangs	Langs object
1350
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1351
+     *   @param		int			$hidebottom		Hide bottom bar of array
1352
+     *   @param		string		$currency		Currency code
1353
+     *   @return	void
1354
+     */
1355
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1356
+    {
1357
+        global $conf;
1594 1358
 
1595
-			//Recipient name
1596
-			// On peut utiliser le nom de la societe du contact
1597
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1598
-				$thirdparty = $object->contact;
1599
-			} else {
1600
-				$thirdparty = $object->thirdparty;
1601
-			}
1359
+        // Force to disable hidetop and hidebottom
1360
+        $hidebottom=0;
1361
+        if ($hidetop) $hidetop=-1;
1362
+
1363
+        $currency = !empty($currency) ? $currency : $conf->currency;
1364
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1365
+
1366
+        // Amount in (at tab_top - 1)
1367
+        $pdf->SetTextColor(0,0,0);
1368
+        $pdf->SetFont('','', $default_font_size - 2);
1369
+
1370
+        if (empty($hidetop))
1371
+        {
1372
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1373
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1374
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1602 1375
 
1603
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1376
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1377
+            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));
1378
+        }
1604 1379
 
1605
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1380
+        $pdf->SetDrawColor(128,128,128);
1381
+        $pdf->SetFont('','', $default_font_size - 1);
1606 1382
 
1607
-			// Show recipient
1608
-			$widthrecbox=100;
1609
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1610
-			$posy=42+$top_shift;
1611
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1612
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1383
+        // Output Rect
1384
+        $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
1613 1385
 
1614
-			// Show recipient frame
1615
-			$pdf->SetTextColor(0,0,0);
1616
-			$pdf->SetFont('','', $default_font_size - 2);
1617
-			$pdf->SetXY($posx+2,$posy-5);
1618
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1619
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1620 1386
 
1621
-			// Show recipient name
1622
-			$pdf->SetXY($posx+2,$posy+3);
1623
-			$pdf->SetFont('','B', $default_font_size);
1624
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1387
+        foreach ($this->cols as $colKey => $colDef)
1388
+        {
1389
+            if(!$this->getColumnStatus($colKey)) continue;
1625 1390
 
1626
-			$posy = $pdf->getY();
1391
+            // get title label
1392
+            $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1627 1393
 
1628
-			// Show recipient information
1629
-			$pdf->SetFont('','', $default_font_size - 1);
1630
-			$pdf->SetXY($posx+2,$posy);
1631
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1632
-		}
1394
+            // Add column separator
1395
+            if(!empty($colDef['border-left'])){
1396
+                $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1397
+            }
1633 1398
 
1634
-		$pdf->SetTextColor(0,0,0);
1635
-		return $top_shift;
1636
-	}
1399
+            if (empty($hidetop))
1400
+            {
1401
+                $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1402
+
1403
+                $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1404
+                $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1405
+            }
1406
+        }
1407
+
1408
+        if (empty($hidetop)){
1409
+            $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
1410
+        }
1411
+    }
1412
+
1413
+    /**
1414
+     *  Show top header of page.
1415
+     *
1416
+     *  @param	PDF			$pdf     		Object PDF
1417
+     *  @param  Object		$object     	Object to show
1418
+     *  @param  int	    	$showaddress    0=no, 1=yes
1419
+     *  @param  Translate	$outputlangs	Object lang for output
1420
+     *  @return	void
1421
+     */
1422
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1423
+    {
1424
+        global $conf,$langs;
1637 1425
 
1638
-	/**
1639
-	 *   	Show footer of page. Need this->emetteur object
1426
+        $outputlangs->load("main");
1427
+        $outputlangs->load("bills");
1428
+        $outputlangs->load("propal");
1429
+        $outputlangs->load("companies");
1430
+
1431
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1432
+
1433
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1434
+
1435
+        //  Show Draft Watermark
1436
+        if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1437
+        {
1438
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1439
+        }
1440
+
1441
+        $pdf->SetTextColor(0,0,60);
1442
+        $pdf->SetFont('','B', $default_font_size + 3);
1443
+
1444
+        $posy=$this->marge_haute;
1445
+        $posx=$this->page_largeur-$this->marge_droite-100;
1446
+
1447
+        $pdf->SetXY($this->marge_gauche,$posy);
1448
+
1449
+        // Logo
1450
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1451
+        {
1452
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1453
+            if ($this->emetteur->logo)
1454
+            {
1455
+                if (is_readable($logo))
1456
+                {
1457
+                    $height=pdf_getHeightForLogo($logo);
1458
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1459
+                }
1460
+                else
1461
+                {
1462
+                    $pdf->SetTextColor(200,0,0);
1463
+                    $pdf->SetFont('','B',$default_font_size - 2);
1464
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1465
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1466
+                }
1467
+            }
1468
+            else
1469
+            {
1470
+                $text=$this->emetteur->name;
1471
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1472
+            }
1473
+        }
1474
+
1475
+        $pdf->SetFont('','B',$default_font_size + 3);
1476
+        $pdf->SetXY($posx,$posy);
1477
+        $pdf->SetTextColor(0,0,60);
1478
+        $title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1479
+        $pdf->MultiCell(100, 4, $title, '', 'R');
1480
+
1481
+        $pdf->SetFont('','B',$default_font_size);
1482
+
1483
+        $posy+=5;
1484
+        $pdf->SetXY($posx,$posy);
1485
+        $pdf->SetTextColor(0,0,60);
1486
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1487
+
1488
+        $posy+=1;
1489
+        $pdf->SetFont('','', $default_font_size - 2);
1490
+
1491
+        if ($object->ref_client)
1492
+        {
1493
+            $posy+=4;
1494
+            $pdf->SetXY($posx,$posy);
1495
+            $pdf->SetTextColor(0,0,60);
1496
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1497
+        }
1498
+
1499
+        $posy+=4;
1500
+        $pdf->SetXY($posx,$posy);
1501
+        $pdf->SetTextColor(0,0,60);
1502
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1503
+
1504
+        $posy+=4;
1505
+        $pdf->SetXY($posx,$posy);
1506
+        $pdf->SetTextColor(0,0,60);
1507
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1508
+
1509
+        if ($object->thirdparty->code_client)
1510
+        {
1511
+            $posy+=4;
1512
+            $pdf->SetXY($posx,$posy);
1513
+            $pdf->SetTextColor(0,0,60);
1514
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1515
+        }
1516
+
1517
+        // Get contact
1518
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1519
+        {
1520
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1521
+            if (count($arrayidcontact) > 0)
1522
+            {
1523
+                $usertmp=new User($this->db);
1524
+                $usertmp->fetch($arrayidcontact[0]);
1525
+                $posy+=4;
1526
+                $pdf->SetXY($posx,$posy);
1527
+                $pdf->SetTextColor(0,0,60);
1528
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1529
+            }
1530
+        }
1531
+
1532
+        $posy+=2;
1533
+
1534
+        $top_shift = 0;
1535
+        // Show list of linked objects
1536
+        $current_y = $pdf->getY();
1537
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1538
+        if ($current_y < $pdf->getY())
1539
+        {
1540
+            $top_shift = $pdf->getY() - $current_y;
1541
+        }
1542
+
1543
+        if ($showaddress)
1544
+        {
1545
+            // Sender properties
1546
+            $carac_emetteur='';
1547
+                // Add internal contact of proposal if defined
1548
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1549
+                if (count($arrayidcontact) > 0)
1550
+                {
1551
+                    $object->fetch_user($arrayidcontact[0]);
1552
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1553
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1554
+                }
1555
+
1556
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1557
+
1558
+            // Show sender
1559
+            $posy=42+$top_shift;
1560
+                $posx=$this->marge_gauche;
1561
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1562
+            $hautcadre=40;
1563
+
1564
+            // Show sender frame
1565
+            $pdf->SetTextColor(0,0,0);
1566
+            $pdf->SetFont('','', $default_font_size - 2);
1567
+            $pdf->SetXY($posx,$posy-5);
1568
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1569
+            $pdf->SetXY($posx,$posy);
1570
+            $pdf->SetFillColor(230,230,230);
1571
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1572
+            $pdf->SetTextColor(0,0,60);
1573
+
1574
+            // Show sender name
1575
+            $pdf->SetXY($posx+2,$posy+3);
1576
+            $pdf->SetFont('','B', $default_font_size);
1577
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1578
+            $posy=$pdf->getY();
1579
+
1580
+            // Show sender information
1581
+            $pdf->SetXY($posx+2,$posy);
1582
+            $pdf->SetFont('','', $default_font_size - 1);
1583
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1584
+
1585
+
1586
+            // If CUSTOMER contact defined, we use it
1587
+            $usecontact=false;
1588
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1589
+            if (count($arrayidcontact) > 0)
1590
+            {
1591
+                $usecontact=true;
1592
+                $result=$object->fetch_contact($arrayidcontact[0]);
1593
+            }
1594
+
1595
+            //Recipient name
1596
+            // On peut utiliser le nom de la societe du contact
1597
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1598
+                $thirdparty = $object->contact;
1599
+            } else {
1600
+                $thirdparty = $object->thirdparty;
1601
+            }
1602
+
1603
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1604
+
1605
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1606
+
1607
+            // Show recipient
1608
+            $widthrecbox=100;
1609
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1610
+            $posy=42+$top_shift;
1611
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1612
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1613
+
1614
+            // Show recipient frame
1615
+            $pdf->SetTextColor(0,0,0);
1616
+            $pdf->SetFont('','', $default_font_size - 2);
1617
+            $pdf->SetXY($posx+2,$posy-5);
1618
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1619
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1620
+
1621
+            // Show recipient name
1622
+            $pdf->SetXY($posx+2,$posy+3);
1623
+            $pdf->SetFont('','B', $default_font_size);
1624
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1625
+
1626
+            $posy = $pdf->getY();
1627
+
1628
+            // Show recipient information
1629
+            $pdf->SetFont('','', $default_font_size - 1);
1630
+            $pdf->SetXY($posx+2,$posy);
1631
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1632
+        }
1633
+
1634
+        $pdf->SetTextColor(0,0,0);
1635
+        return $top_shift;
1636
+    }
1637
+
1638
+    /**
1639
+     *   	Show footer of page. Need this->emetteur object
1640
+     *
1641
+     *   	@param	PDF			$pdf     			PDF
1642
+     * 		@param	Object		$object				Object to show
1643
+     *      @param	Translate	$outputlangs		Object lang for output
1644
+     *      @param	int			$hidefreetext		1=Hide free text
1645
+     *      @return	int								Return height of bottom margin including footer text
1646
+     */
1647
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1648
+    {
1649
+        global $conf;
1650
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1651
+        return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1652
+    }
1653
+
1654
+    /**
1655
+     *	Show area for the customer to sign
1656
+     *
1657
+     *	@param	PDF			$pdf            Object PDF
1658
+     *	@param  Facture		$object         Object invoice
1659
+     *	@param	int			$posy			Position depart
1660
+     *	@param	Translate	$outputlangs	Objet langs
1661
+     *	@return int							Position pour suite
1662
+     */
1663
+    private function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
1664
+    {
1665
+        global $conf;
1666
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1667
+        $tab_top = $posy + 4;
1668
+        $tab_hl = 4;
1669
+
1670
+        $posx = 120;
1671
+        $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1672
+        $useborder=0;
1673
+        $index = 0;
1674
+        // Total HT
1675
+        $pdf->SetFillColor(255,255,255);
1676
+        $pdf->SetXY($posx, $tab_top + 0);
1677
+        $pdf->SetFont('','', $default_font_size - 2);
1678
+        $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1679
+
1680
+        $pdf->SetXY($posx, $tab_top + $tab_hl);
1681
+        $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1682
+        if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1683
+            $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1684
+        }
1685
+
1686
+        return ($tab_hl*7);
1687
+    }
1688
+
1689
+
1690
+    /**
1691
+     *   	Define Array Column Field
1640 1692
      *
1641
-	 *   	@param	PDF			$pdf     			PDF
1642
-	 * 		@param	Object		$object				Object to show
1643
-	 *      @param	Translate	$outputlangs		Object lang for output
1644
-	 *      @param	int			$hidefreetext		1=Hide free text
1645
-	 *      @return	int								Return height of bottom margin including footer text
1646
-	 */
1647
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1648
-	{
1649
-		global $conf;
1650
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1651
-		return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1652
-	}
1653
-
1654
-	/**
1655
-	 *	Show area for the customer to sign
1656
-	 *
1657
-	 *	@param	PDF			$pdf            Object PDF
1658
-	 *	@param  Facture		$object         Object invoice
1659
-	 *	@param	int			$posy			Position depart
1660
-	 *	@param	Translate	$outputlangs	Objet langs
1661
-	 *	@return int							Position pour suite
1662
-	 */
1663
-	private function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
1664
-	{
1665
-		global $conf;
1666
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1667
-		$tab_top = $posy + 4;
1668
-		$tab_hl = 4;
1669
-
1670
-		$posx = 120;
1671
-		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
1672
-		$useborder=0;
1673
-		$index = 0;
1674
-		// Total HT
1675
-		$pdf->SetFillColor(255,255,255);
1676
-		$pdf->SetXY($posx, $tab_top + 0);
1677
-		$pdf->SetFont('','', $default_font_size - 2);
1678
-		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1679
-
1680
-		$pdf->SetXY($posx, $tab_top + $tab_hl);
1681
-		$pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1682
-		if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1683
-			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1684
-		}
1685
-
1686
-		return ($tab_hl*7);
1687
-	}
1688
-
1689
-
1690
-	/**
1691
-	 *   	Define Array Column Field
1692
-	 *
1693
-	 *   	@param	object			$object			common object
1694
-	 *   	@param	Translate		$outputlangs	langs
1695
-	 *      @param	int				$hidedetails	Do not show line details
1696
-	 *      @param	int				$hidedesc		Do not show desc
1697
-	 *      @param	int				$hideref		Do not show ref
1698
-	 *      @return	null
1699
-	 */
1693
+     *   	@param	object			$object			common object
1694
+     *   	@param	Translate		$outputlangs	langs
1695
+     *      @param	int				$hidedetails	Do not show line details
1696
+     *      @param	int				$hidedesc		Do not show desc
1697
+     *      @param	int				$hideref		Do not show ref
1698
+     *      @return	null
1699
+     */
1700 1700
     function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1701 1701
     {
1702
-	    global $conf, $hookmanager;
1702
+        global $conf, $hookmanager;
1703 1703
 
1704
-	    // Default field style for content
1705
-	    $this->defaultContentsFieldsStyle = array(
1706
-	        'align' => 'R', // R,C,L
1707
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1708
-	    );
1704
+        // Default field style for content
1705
+        $this->defaultContentsFieldsStyle = array(
1706
+            'align' => 'R', // R,C,L
1707
+            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1708
+        );
1709 1709
 
1710
-	    // Default field style for content
1711
-	    $this->defaultTitlesFieldsStyle = array(
1712
-	        'align' => 'C', // R,C,L
1713
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1714
-	    );
1710
+        // Default field style for content
1711
+        $this->defaultTitlesFieldsStyle = array(
1712
+            'align' => 'C', // R,C,L
1713
+            'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1714
+        );
1715 1715
 
1716
-	    /*
1716
+        /*
1717 1717
 	     * For exemple
1718 1718
 	     $this->cols['theColKey'] = array(
1719 1719
 	     'rank' => $rank, // int : use for ordering columns
@@ -1731,158 +1731,158 @@  discard block
 block discarded – undo
1731 1731
 	     );
1732 1732
 	     */
1733 1733
 
1734
-	    $rank=0; // do not use negative rank
1735
-	    $this->cols['desc'] = array(
1736
-	        'rank' => $rank,
1737
-	        'width' => false, // only for desc
1738
-	        'status' => true,
1739
-	        'title' => array(
1740
-	            'textkey' => 'Designation', // use lang key is usefull in somme case with module
1741
-	            'align' => 'L',
1742
-	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1743
-	            // 'label' => ' ', // the final label
1744
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1745
-	        ),
1746
-	        'content' => array(
1747
-	            'align' => 'L',
1748
-	        ),
1749
-	    );
1750
-
1751
-	    $rank = $rank + 10;
1752
-	    $this->cols['photo'] = array(
1753
-	        'rank' => $rank,
1754
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1755
-	        'status' => false,
1756
-	        'title' => array(
1757
-	            'textkey' => 'Photo',
1758
-	            'label' => ' '
1759
-	        ),
1760
-	        'content' => array(
1761
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1762
-	        ),
1763
-	        'border-left' => false, // remove left line separator
1764
-	    );
1765
-
1766
-	    if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
1767
-	    {
1768
-	        $this->cols['photo']['status'] = true;
1769
-	    }
1770
-
1771
-
1772
-	    $rank = $rank + 10;
1773
-	    $this->cols['vat'] = array(
1774
-	        'rank' => $rank,
1775
-	        'status' => false,
1776
-	        'width' => 16, // in mm
1777
-	        'title' => array(
1778
-	            'textkey' => 'VAT'
1779
-	        ),
1780
-	        'border-left' => true, // add left line separator
1781
-	    );
1782
-
1783
-	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1784
-	    {
1785
-	        $this->cols['vat']['status'] = true;
1786
-	    }
1787
-
1788
-	    $rank = $rank + 10;
1789
-	    $this->cols['subprice'] = array(
1790
-	        'rank' => $rank,
1791
-	        'width' => 19, // in mm
1792
-	        'status' => true,
1793
-	        'title' => array(
1794
-	            'textkey' => 'PriceUHT'
1795
-	        ),
1796
-	        'border-left' => true, // add left line separator
1797
-	    );
1798
-
1799
-	    $rank = $rank + 10;
1800
-	    $this->cols['qty'] = array(
1801
-	        'rank' => $rank,
1802
-	        'width' => 16, // in mm
1803
-	        'status' => true,
1804
-	        'title' => array(
1805
-	            'textkey' => 'Qty'
1806
-	        ),
1807
-	        'border-left' => true, // add left line separator
1808
-	    );
1809
-
1810
-	    $rank = $rank + 10;
1811
-	    $this->cols['progress'] = array(
1812
-	        'rank' => $rank,
1813
-	        'width' => 19, // in mm
1814
-	        'status' => false,
1815
-	        'title' => array(
1816
-	            'textkey' => 'Progress'
1817
-	        ),
1818
-	        'border-left' => false, // add left line separator
1819
-	    );
1820
-
1821
-	    if($this->situationinvoice)
1822
-	    {
1823
-	        $this->cols['progress']['status'] = true;
1824
-	    }
1825
-
1826
-	    $rank = $rank + 10;
1827
-	    $this->cols['unit'] = array(
1828
-	        'rank' => $rank,
1829
-	        'width' => 11, // in mm
1830
-	        'status' => false,
1831
-	        'title' => array(
1832
-	            'textkey' => 'Unit'
1833
-	        ),
1834
-	        'border-left' => true, // add left line separator
1835
-	    );
1836
-	    if($conf->global->PRODUCT_USE_UNITS){
1837
-	        $this->cols['unit']['status'] = true;
1838
-	    }
1839
-
1840
-	    $rank = $rank + 10;
1841
-	    $this->cols['discount'] = array(
1842
-	        'rank' => $rank,
1843
-	        'width' => 13, // in mm
1844
-	        'status' => false,
1845
-	        'title' => array(
1846
-	            'textkey' => 'ReductionShort'
1847
-	        ),
1848
-	        'border-left' => true, // add left line separator
1849
-	    );
1850
-	    if ($this->atleastonediscount){
1851
-	        $this->cols['discount']['status'] = true;
1852
-	    }
1853
-
1854
-	    $rank = $rank + 10;
1855
-	    $this->cols['totalexcltax'] = array(
1856
-	        'rank' => $rank,
1857
-	        'width' => 26, // in mm
1858
-	        'status' => true,
1859
-	        'title' => array(
1860
-	            'textkey' => 'TotalHT'
1861
-	        ),
1862
-	        'border-left' => true, // add left line separator
1863
-	    );
1864
-
1865
-
1866
-	    $parameters=array(
1867
-	        'object' => $object,
1868
-	        'outputlangs' => $outputlangs,
1869
-	        'hidedetails' => $hidedetails,
1870
-	        'hidedesc' => $hidedesc,
1871
-	        'hideref' => $hideref
1872
-	    );
1873
-
1874
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1875
-	    if ($reshook < 0)
1876
-	    {
1877
-	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1878
-	    }
1879
-	    elseif (empty($reshook))
1880
-	    {
1881
-	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1882
-	    }
1883
-	    else
1884
-	    {
1885
-	        $this->cols = $hookmanager->resArray;
1886
-	    }
1887
-	}
1734
+        $rank=0; // do not use negative rank
1735
+        $this->cols['desc'] = array(
1736
+            'rank' => $rank,
1737
+            'width' => false, // only for desc
1738
+            'status' => true,
1739
+            'title' => array(
1740
+                'textkey' => 'Designation', // use lang key is usefull in somme case with module
1741
+                'align' => 'L',
1742
+                // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1743
+                // 'label' => ' ', // the final label
1744
+                'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1745
+            ),
1746
+            'content' => array(
1747
+                'align' => 'L',
1748
+            ),
1749
+        );
1750
+
1751
+        $rank = $rank + 10;
1752
+        $this->cols['photo'] = array(
1753
+            'rank' => $rank,
1754
+            'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1755
+            'status' => false,
1756
+            'title' => array(
1757
+                'textkey' => 'Photo',
1758
+                'label' => ' '
1759
+            ),
1760
+            'content' => array(
1761
+                'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1762
+            ),
1763
+            'border-left' => false, // remove left line separator
1764
+        );
1765
+
1766
+        if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
1767
+        {
1768
+            $this->cols['photo']['status'] = true;
1769
+        }
1770
+
1771
+
1772
+        $rank = $rank + 10;
1773
+        $this->cols['vat'] = array(
1774
+            'rank' => $rank,
1775
+            'status' => false,
1776
+            'width' => 16, // in mm
1777
+            'title' => array(
1778
+                'textkey' => 'VAT'
1779
+            ),
1780
+            'border-left' => true, // add left line separator
1781
+        );
1782
+
1783
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1784
+        {
1785
+            $this->cols['vat']['status'] = true;
1786
+        }
1787
+
1788
+        $rank = $rank + 10;
1789
+        $this->cols['subprice'] = array(
1790
+            'rank' => $rank,
1791
+            'width' => 19, // in mm
1792
+            'status' => true,
1793
+            'title' => array(
1794
+                'textkey' => 'PriceUHT'
1795
+            ),
1796
+            'border-left' => true, // add left line separator
1797
+        );
1798
+
1799
+        $rank = $rank + 10;
1800
+        $this->cols['qty'] = array(
1801
+            'rank' => $rank,
1802
+            'width' => 16, // in mm
1803
+            'status' => true,
1804
+            'title' => array(
1805
+                'textkey' => 'Qty'
1806
+            ),
1807
+            'border-left' => true, // add left line separator
1808
+        );
1809
+
1810
+        $rank = $rank + 10;
1811
+        $this->cols['progress'] = array(
1812
+            'rank' => $rank,
1813
+            'width' => 19, // in mm
1814
+            'status' => false,
1815
+            'title' => array(
1816
+                'textkey' => 'Progress'
1817
+            ),
1818
+            'border-left' => false, // add left line separator
1819
+        );
1820
+
1821
+        if($this->situationinvoice)
1822
+        {
1823
+            $this->cols['progress']['status'] = true;
1824
+        }
1825
+
1826
+        $rank = $rank + 10;
1827
+        $this->cols['unit'] = array(
1828
+            'rank' => $rank,
1829
+            'width' => 11, // in mm
1830
+            'status' => false,
1831
+            'title' => array(
1832
+                'textkey' => 'Unit'
1833
+            ),
1834
+            'border-left' => true, // add left line separator
1835
+        );
1836
+        if($conf->global->PRODUCT_USE_UNITS){
1837
+            $this->cols['unit']['status'] = true;
1838
+        }
1839
+
1840
+        $rank = $rank + 10;
1841
+        $this->cols['discount'] = array(
1842
+            'rank' => $rank,
1843
+            'width' => 13, // in mm
1844
+            'status' => false,
1845
+            'title' => array(
1846
+                'textkey' => 'ReductionShort'
1847
+            ),
1848
+            'border-left' => true, // add left line separator
1849
+        );
1850
+        if ($this->atleastonediscount){
1851
+            $this->cols['discount']['status'] = true;
1852
+        }
1853
+
1854
+        $rank = $rank + 10;
1855
+        $this->cols['totalexcltax'] = array(
1856
+            'rank' => $rank,
1857
+            'width' => 26, // in mm
1858
+            'status' => true,
1859
+            'title' => array(
1860
+                'textkey' => 'TotalHT'
1861
+            ),
1862
+            'border-left' => true, // add left line separator
1863
+        );
1864
+
1865
+
1866
+        $parameters=array(
1867
+            'object' => $object,
1868
+            'outputlangs' => $outputlangs,
1869
+            'hidedetails' => $hidedetails,
1870
+            'hidedesc' => $hidedesc,
1871
+            'hideref' => $hideref
1872
+        );
1873
+
1874
+        $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1875
+        if ($reshook < 0)
1876
+        {
1877
+            setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1878
+        }
1879
+        elseif (empty($reshook))
1880
+        {
1881
+            $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1882
+        }
1883
+        else
1884
+        {
1885
+            $this->cols = $hookmanager->resArray;
1886
+        }
1887
+    }
1888 1888
 }
Please login to merge, or discard this patch.
Spacing   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	public $db;
45 45
 	public $name;
46 46
 	public $description;
47
-	public $update_main_doc_field;	// Save the name of generated file as the main doc when generating a doc with this template
47
+	public $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
48 48
 	public $type;
49 49
 
50
-	public $phpmin = array(4,3,0); // Minimum version of PHP required by module
50
+	public $phpmin = array(4, 3, 0); // Minimum version of PHP required by module
51 51
 	public $version = 'development';
52 52
 
53 53
 	public $page_largeur;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	public	$marge_haute;
59 59
 	public	$marge_basse;
60 60
 
61
-	public $emetteur;	// Objet societe qui emet
61
+	public $emetteur; // Objet societe qui emet
62 62
 
63 63
 
64 64
 	/**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function __construct($db)
70 70
 	{
71
-		global $conf,$langs,$mysoc;
71
+		global $conf, $langs, $mysoc;
72 72
 
73 73
 		// Translations
74 74
 		$langs->loadLangs(array("main", "bills"));
@@ -76,46 +76,46 @@  discard block
 block discarded – undo
76 76
 		$this->db = $db;
77 77
 		$this->name = "cyan";
78 78
 		$this->description = $langs->trans('DocModelCyanDescription');
79
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
79
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
80 80
 
81 81
 		// Dimension page
82 82
 		$this->type = 'pdf';
83
-		$formatarray=pdf_getFormat();
83
+		$formatarray = pdf_getFormat();
84 84
 		$this->page_largeur = $formatarray['width'];
85 85
 		$this->page_hauteur = $formatarray['height'];
86
-		$this->format = array($this->page_largeur,$this->page_hauteur);
87
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
88
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
89
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
90
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
91
-
92
-		$this->option_logo = 1;                    // Affiche logo
93
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
94
-		$this->option_modereg = 1;                 // Affiche mode reglement
95
-		$this->option_condreg = 1;                 // Affiche conditions reglement
96
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
97
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
98
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
99
-		$this->option_credit_note = 0;             // Support credit notes
100
-		$this->option_freetext = 1;				   // Support add of a personalised text
101
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
102
-
103
-		$this->franchise=!$mysoc->tva_assuj;
86
+		$this->format = array($this->page_largeur, $this->page_hauteur);
87
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
88
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
89
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
90
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
91
+
92
+		$this->option_logo = 1; // Affiche logo
93
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
94
+		$this->option_modereg = 1; // Affiche mode reglement
95
+		$this->option_condreg = 1; // Affiche conditions reglement
96
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
97
+		$this->option_multilang = 1; // Dispo en plusieurs langues
98
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
99
+		$this->option_credit_note = 0; // Support credit notes
100
+		$this->option_freetext = 1; // Support add of a personalised text
101
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
102
+
103
+		$this->franchise = !$mysoc->tva_assuj;
104 104
 
105 105
 		// Get source company
106
-		$this->emetteur=$mysoc;
107
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
106
+		$this->emetteur = $mysoc;
107
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
108 108
 
109 109
 		// Define position of columns
110
-		$this->posxdesc=$this->marge_gauche+1;
110
+		$this->posxdesc = $this->marge_gauche + 1;
111 111
 
112 112
 
113 113
 
114
-		$this->tva=array();
115
-		$this->localtax1=array();
116
-		$this->localtax2=array();
117
-		$this->atleastoneratenotnull=0;
118
-		$this->atleastonediscount=0;
114
+		$this->tva = array();
115
+		$this->localtax1 = array();
116
+		$this->localtax2 = array();
117
+		$this->atleastoneratenotnull = 0;
118
+		$this->atleastonediscount = 0;
119 119
 	}
120 120
 
121 121
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
      *  @param		int			$hideref			Do not show ref
131 131
      *  @return     int             				1=OK, 0=KO
132 132
 	 */
133
-	public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
133
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
134 134
 	{
135 135
 	  // phpcs:enable
136
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
136
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
137 137
 
138
-		if (! is_object($outputlangs)) $outputlangs=$langs;
138
+		if (!is_object($outputlangs)) $outputlangs = $langs;
139 139
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
140
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
140
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
141 141
 
142 142
 		$outputlangs->load("main");
143 143
 		$outputlangs->load("dict");
@@ -149,52 +149,52 @@  discard block
 block discarded – undo
149 149
 		$nblignes = count($object->lines);
150 150
 
151 151
 		// Loop on each lines to detect if there is at least one image to show
152
-		$realpatharray=array();
152
+		$realpatharray = array();
153 153
 		$this->atleastonephoto = false;
154
-		if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
154
+		if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
155 155
 		{
156 156
 			$objphoto = new Product($this->db);
157 157
 
158
-			for ($i = 0 ; $i < $nblignes ; $i++)
158
+			for ($i = 0; $i < $nblignes; $i++)
159 159
 			{
160 160
 				if (empty($object->lines[$i]->fk_product)) continue;
161 161
 
162 162
 				$objphoto->fetch($object->lines[$i]->fk_product);
163 163
                 //var_dump($objphoto->ref);exit;
164
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
164
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
165 165
 				{
166
-					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
167
-					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
166
+					$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
167
+					$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
168 168
 				}
169 169
 				else
170 170
 				{
171
-					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
172
-					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
171
+					$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
172
+					$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
173 173
 				}
174 174
 
175 175
 				$arephoto = false;
176 176
 				foreach ($pdir as $midir)
177 177
 				{
178
-					if (! $arephoto)
178
+					if (!$arephoto)
179 179
 					{
180 180
 						$dir = $conf->product->dir_output.'/'.$midir;
181 181
 
182
-						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
182
+						foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
183 183
 						{
184 184
 							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
185 185
 							{
186 186
 								if ($obj['photo_vignette'])
187 187
 								{
188
-									$filename= $obj['photo_vignette'];
188
+									$filename = $obj['photo_vignette'];
189 189
 								}
190 190
 								else
191 191
 								{
192
-									$filename=$obj['photo'];
192
+									$filename = $obj['photo'];
193 193
 								}
194 194
 							}
195 195
 							else
196 196
 							{
197
-								$filename=$obj['photo'];
197
+								$filename = $obj['photo'];
198 198
 							}
199 199
 
200 200
 							$realpath = $dir.$filename;
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 					}
205 205
 				}
206 206
 
207
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
207
+				if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
208 208
 			}
209 209
 		}
210 210
 
211
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
211
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
212 212
 
213 213
 		if ($conf->propal->multidir_output[$conf->entity])
214 214
 		{
@@ -220,20 +220,20 @@  discard block
 block discarded – undo
220 220
 			if ($object->specimen)
221 221
 			{
222 222
 				$dir = $conf->propal->multidir_output[$conf->entity];
223
-				$file = $dir . "/SPECIMEN.pdf";
223
+				$file = $dir."/SPECIMEN.pdf";
224 224
 			}
225 225
 			else
226 226
 			{
227 227
 				$objectref = dol_sanitizeFileName($object->ref);
228
-				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
229
-				$file = $dir . "/" . $objectref . ".pdf";
228
+				$dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
229
+				$file = $dir."/".$objectref.".pdf";
230 230
 			}
231 231
 
232
-			if (! file_exists($dir))
232
+			if (!file_exists($dir))
233 233
 			{
234 234
 				if (dol_mkdir($dir) < 0)
235 235
 				{
236
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
236
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
237 237
 					return 0;
238 238
 				}
239 239
 			}
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 			if (file_exists($dir))
242 242
 			{
243 243
 				// Add pdfgeneration hook
244
-				if (! is_object($hookmanager))
244
+				if (!is_object($hookmanager))
245 245
 				{
246 246
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
247
-					$hookmanager=new HookManager($this->db);
247
+					$hookmanager = new HookManager($this->db);
248 248
 				}
249 249
 				$hookmanager->initHooks(array('pdfgeneration'));
250
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
250
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
251 251
 				global $action;
252
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
252
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
253 253
 
254 254
 				// Create pdf instance
255
-                $pdf=pdf_getInstance($this->format);
256
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
257
-	            $pdf->SetAutoPageBreak(1,0);
255
+                $pdf = pdf_getInstance($this->format);
256
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
257
+	            $pdf->SetAutoPageBreak(1, 0);
258 258
 
259 259
                 if (class_exists('TCPDF'))
260 260
                 {
@@ -263,28 +263,28 @@  discard block
 block discarded – undo
263 263
                 }
264 264
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
265 265
                 // Set path to the background PDF File
266
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
266
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
267 267
                 {
268 268
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
269 269
                     $tplidx = $pdf->importPage(1);
270 270
                 }
271 271
 
272 272
 				$pdf->Open();
273
-				$pagenb=0;
274
-				$pdf->SetDrawColor(128,128,128);
273
+				$pagenb = 0;
274
+				$pdf->SetDrawColor(128, 128, 128);
275 275
 
276 276
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
277 277
 				$pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
278 278
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
279 279
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
280 280
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
281
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
281
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
282 282
 
283
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
283
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
284 284
 
285 285
 				// Does we have at least one line with discount $this->atleastonediscount
286 286
 				foreach ($object->lines as $line) {
287
-				    if ($line->remise_percent){
287
+				    if ($line->remise_percent) {
288 288
 				        $this->atleastonediscount = true;
289 289
 				        break;
290 290
 				    }
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
 
295 295
 				// New page
296 296
 				$pdf->AddPage();
297
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
297
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
298 298
 				$pagenb++;
299 299
 
300
-                $heightforinfotot = 40;	// Height reserved to output the info and total part
301
-                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
302
-                $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
303
-                $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)
300
+                $heightforinfotot = 40; // Height reserved to output the info and total part
301
+                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
302
+                $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
303
+                $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)
304 304
                 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
305 305
 
306 306
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
307
-				$pdf->SetFont('','', $default_font_size - 1);
308
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-				$pdf->SetTextColor(0,0,0);
307
+				$pdf->SetFont('', '', $default_font_size - 1);
308
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
309
+				$pdf->SetTextColor(0, 0, 0);
310 310
 
311 311
 
312
-	            $tab_top = 90+$top_shift;
313
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
312
+	            $tab_top = 90 + $top_shift;
313
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
314 314
 
315 315
 
316 316
 				// Incoterm
@@ -322,39 +322,39 @@  discard block
 block discarded – undo
322 322
 					{
323 323
 						$tab_top -= 2;
324 324
 
325
-						$pdf->SetFont('','', $default_font_size - 1);
326
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
325
+						$pdf->SetFont('', '', $default_font_size - 1);
326
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
327 327
 						$nexY = $pdf->GetY();
328
-						$height_incoterms=$nexY-$tab_top;
328
+						$height_incoterms = $nexY - $tab_top;
329 329
 
330 330
 						// Rect prend une longueur en 3eme param
331
-						$pdf->SetDrawColor(192,192,192);
332
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
331
+						$pdf->SetDrawColor(192, 192, 192);
332
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
333 333
 
334
-						$tab_top = $nexY+6;
334
+						$tab_top = $nexY + 6;
335 335
 					}
336 336
 				}
337 337
 
338 338
 				// Affiche notes
339
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
340
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
339
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
340
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
341 341
 				{
342 342
 					// Get first sale rep
343 343
 					if (is_object($object->thirdparty))
344 344
 					{
345
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
346
-						$salerepobj=new User($this->db);
345
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
346
+						$salerepobj = new User($this->db);
347 347
 						$salerepobj->fetch($salereparray[0]['id']);
348
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
348
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
349 349
 					}
350 350
 				}
351
-				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
351
+				if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
352 352
 				{
353
-				    $tmpuser=new User($this->db);
353
+				    $tmpuser = new User($this->db);
354 354
 				    $tmpuser->fetch($object->user_author_id);
355
-				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
356
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
357
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
355
+				    $notetoshow .= 'Affaire suivi par '.$tmpuser->getFullName($langs);
356
+				    if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
357
+				    if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
358 358
 				}
359 359
 
360 360
 				$pagenb = $pdf->getPage();
@@ -362,23 +362,23 @@  discard block
 block discarded – undo
362 362
 				{
363 363
 					$tab_top -= 2;
364 364
 
365
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
365
+				    $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
366 366
 				    $pageposbeforenote = $pagenb;
367 367
 
368
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
368
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
369 369
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
370 370
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
371 371
 
372 372
 
373 373
 					$pdf->startTransaction();
374 374
 
375
-					$pdf->SetFont('','', $default_font_size - 1);
376
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
375
+					$pdf->SetFont('', '', $default_font_size - 1);
376
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
377 377
 					// Description
378
-					$pageposafternote=$pdf->getPage();
378
+					$pageposafternote = $pdf->getPage();
379 379
 					$posyafter = $pdf->GetY();
380 380
 
381
-					if($pageposafternote>$pageposbeforenote )
381
+					if ($pageposafternote > $pageposbeforenote)
382 382
 					{
383 383
 					    $pdf->rollbackTransaction(true);
384 384
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 					    while ($pagenb < $pageposafternote) {
387 387
 					        $pdf->AddPage();
388 388
 					        $pagenb++;
389
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
389
+					        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
390 390
 					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
391 391
 					        // $this->_pagefoot($pdf,$object,$outputlangs,1);
392 392
 					        $pdf->setTopMargin($tab_top_newpage);
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
 					    // back to start
398 398
 					    $pdf->setPage($pageposbeforenote);
399 399
 					    $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
400
-					    $pdf->SetFont('','', $default_font_size - 1);
401
-					    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
402
-					    $pageposafternote=$pdf->getPage();
400
+					    $pdf->SetFont('', '', $default_font_size - 1);
401
+					    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
402
+					    $pageposafternote = $pdf->getPage();
403 403
 
404 404
 					    $posyafter = $pdf->GetY();
405 405
 
406
-					    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
406
+					    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
407 407
 					    {
408
-					        $pdf->AddPage('','',true);
408
+					        $pdf->AddPage('', '', true);
409 409
 					        $pagenb++;
410 410
 					        $pageposafternote++;
411 411
 					        $pdf->setPage($pageposafternote);
@@ -422,47 +422,47 @@  discard block
 block discarded – undo
422 422
 					        $pdf->setPage($i);
423 423
 
424 424
 
425
-					        $pdf->SetDrawColor(128,128,128);
425
+					        $pdf->SetDrawColor(128, 128, 128);
426 426
 					        // Draw note frame
427
-					        if($i>$pageposbeforenote){
427
+					        if ($i > $pageposbeforenote) {
428 428
 					            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429
-					            $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
429
+					            $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
430 430
 					        }
431
-					        else{
431
+					        else {
432 432
 					            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
433
-					            $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
433
+					            $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
434 434
 					        }
435 435
 
436 436
 					        // Add footer
437
-					        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
438
-					        $this->_pagefoot($pdf,$object,$outputlangs,1);
437
+					        $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
438
+					        $this->_pagefoot($pdf, $object, $outputlangs, 1);
439 439
 
440 440
 					        $i++;
441 441
 					    }
442 442
 
443 443
 					    // apply note frame to last page
444 444
 					    $pdf->setPage($pageposafternote);
445
-					    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
445
+					    if (!empty($tplidx)) $pdf->useTemplate($tplidx);
446 446
 					    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
447
-					    $height_note=$posyafter-$tab_top_newpage;
448
-					    $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
447
+					    $height_note = $posyafter - $tab_top_newpage;
448
+					    $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
449 449
 					}
450 450
 					else // No pagebreak
451 451
 					{
452 452
 					    $pdf->commitTransaction();
453 453
 					    $posyafter = $pdf->GetY();
454
-					    $height_note=$posyafter-$tab_top;
455
-					    $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
454
+					    $height_note = $posyafter - $tab_top;
455
+					    $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
456 456
 
457 457
 
458
-					    if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
458
+					    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
459 459
 					    {
460 460
 					        // not enough space, need to add page
461
-					        $pdf->AddPage('','',true);
461
+					        $pdf->AddPage('', '', true);
462 462
 					        $pagenb++;
463 463
 					        $pageposafternote++;
464 464
 					        $pdf->setPage($pageposafternote);
465
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
465
+					        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
466 466
 					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
467 467
 
468 468
 					        $posyafter = $tab_top_newpage;
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 					}
471 471
 
472 472
 					$tab_height = $tab_height - $height_note;
473
-					$tab_top = $posyafter +6;
473
+					$tab_top = $posyafter + 6;
474 474
 				}
475 475
 				else
476 476
 				{
477
-					$height_note=0;
477
+					$height_note = 0;
478 478
 				}
479 479
 
480 480
 				$iniY = $tab_top + 7;
@@ -482,112 +482,112 @@  discard block
 block discarded – undo
482 482
 				$nexY = $tab_top + 7;
483 483
 
484 484
 				// Use new auto collum system
485
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
485
+				$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
486 486
 
487 487
 				// Loop on each lines
488
-				$pageposbeforeprintlines=$pdf->getPage();
488
+				$pageposbeforeprintlines = $pdf->getPage();
489 489
 				$pagenb = $pageposbeforeprintlines;
490 490
 				for ($i = 0; $i < $nblignes; $i++)
491 491
 				{
492 492
 					$curY = $nexY;
493
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
494
-					$pdf->SetTextColor(0,0,0);
493
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
494
+					$pdf->SetTextColor(0, 0, 0);
495 495
 
496 496
 					// Define size of image if we need it
497
-					$imglinesize=array();
498
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
497
+					$imglinesize = array();
498
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
499 499
 
500 500
 					$pdf->setTopMargin($tab_top_newpage);
501
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
502
-					$pageposbefore=$pdf->getPage();
501
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
502
+					$pageposbefore = $pdf->getPage();
503 503
 
504
-					$showpricebeforepagebreak=1;
505
-					$posYAfterImage=0;
506
-					$posYAfterDescription=0;
504
+					$showpricebeforepagebreak = 1;
505
+					$posYAfterImage = 0;
506
+					$posYAfterDescription = 0;
507 507
 
508
-					if($this->getColumnStatus('photo'))
508
+					if ($this->getColumnStatus('photo'))
509 509
 					{
510 510
     					// We start with Photo of product line
511
-    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
511
+    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
512 512
     					{
513
-    						$pdf->AddPage('','',true);
514
-    						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
513
+    						$pdf->AddPage('', '', true);
514
+    						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
515 515
     						//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
516
-    						$pdf->setPage($pageposbefore+1);
516
+    						$pdf->setPage($pageposbefore + 1);
517 517
 
518 518
     						$curY = $tab_top_newpage;
519
-    						$showpricebeforepagebreak=0;
519
+    						$showpricebeforepagebreak = 0;
520 520
     					}
521 521
 
522 522
 
523 523
     					if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
524 524
     					{
525
-    						$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
525
+    						$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
526 526
     						// $pdf->Image does not increase value return by getY, so we save it manually
527
-    						$posYAfterImage=$curY+$imglinesize['height'];
527
+    						$posYAfterImage = $curY + $imglinesize['height'];
528 528
     					}
529 529
 					}
530 530
 
531 531
 					// Description of product line
532
-					if($this->getColumnStatus('desc'))
532
+					if ($this->getColumnStatus('desc'))
533 533
 					{
534 534
     					$pdf->startTransaction();
535
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
536
-    					$pageposafter=$pdf->getPage();
535
+    					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
536
+    					$pageposafter = $pdf->getPage();
537 537
     					if ($pageposafter > $pageposbefore)	// There is a pagebreak
538 538
     					{
539 539
     						$pdf->rollbackTransaction(true);
540
-    						$pageposafter=$pageposbefore;
540
+    						$pageposafter = $pageposbefore;
541 541
     						//print $pageposafter.'-'.$pageposbefore;exit;
542
-    						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
543
-    						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
542
+    						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
543
+    						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
544 544
 
545
-    						$pageposafter=$pdf->getPage();
546
-    						$posyafter=$pdf->GetY();
545
+    						$pageposafter = $pdf->getPage();
546
+    						$posyafter = $pdf->GetY();
547 547
     						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
548
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
548
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
549 549
     						{
550
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
550
+    							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
551 551
     							{
552
-    								$pdf->AddPage('','',true);
553
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
552
+    								$pdf->AddPage('', '', true);
553
+    								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
554 554
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
555
-    								$pdf->setPage($pageposafter+1);
555
+    								$pdf->setPage($pageposafter + 1);
556 556
     							}
557 557
     						}
558 558
     						else
559 559
     						{
560 560
     							// We found a page break
561
-    							$showpricebeforepagebreak=0;
561
+    							$showpricebeforepagebreak = 0;
562 562
     						}
563 563
     					}
564 564
     					else	// No pagebreak
565 565
     					{
566 566
     						$pdf->commitTransaction();
567 567
     					}
568
-    					$posYAfterDescription=$pdf->GetY();
568
+    					$posYAfterDescription = $pdf->GetY();
569 569
 					}
570 570
 
571 571
 					$nexY = $pdf->GetY();
572
-					$pageposafter=$pdf->getPage();
572
+					$pageposafter = $pdf->getPage();
573 573
 
574 574
 					$pdf->setPage($pageposbefore);
575 575
 					$pdf->setTopMargin($this->marge_haute);
576
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
576
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
577 577
 
578 578
 					// We suppose that a too long description or photo were moved completely on next page
579 579
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
580 580
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
581 581
 					}
582 582
 
583
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
583
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
584 584
 
585 585
 					// VAT Rate
586 586
 					if ($this->getColumnStatus('vat'))
587 587
 					{
588 588
 					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
589 589
 					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
590
-					    $nexY = max($pdf->GetY(),$nexY);
590
+					    $nexY = max($pdf->GetY(), $nexY);
591 591
 					}
592 592
 
593 593
 					// Unit price before discount
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 					{
596 596
 					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
597 597
 					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
598
-					    $nexY = max($pdf->GetY(),$nexY);
598
+					    $nexY = max($pdf->GetY(), $nexY);
599 599
 					}
600 600
 
601 601
 					// Quantity
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 					{
605 605
 					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
606 606
 					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
607
-					    $nexY = max($pdf->GetY(),$nexY);
607
+					    $nexY = max($pdf->GetY(), $nexY);
608 608
 					}
609 609
 
610 610
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 					{
614 614
 					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
615 615
 					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
616
-					    $nexY = max($pdf->GetY(),$nexY);
616
+					    $nexY = max($pdf->GetY(), $nexY);
617 617
 					}
618 618
 
619 619
 					// Discount on line
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 					{
622 622
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
623 623
 					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
624
-					    $nexY = max($pdf->GetY(),$nexY);
624
+					    $nexY = max($pdf->GetY(), $nexY);
625 625
 					}
626 626
 
627 627
 					// Total HT line
@@ -629,11 +629,11 @@  discard block
 block discarded – undo
629 629
 					{
630 630
 					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
631 631
 					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
632
-					    $nexY = max($pdf->GetY(),$nexY);
632
+					    $nexY = max($pdf->GetY(), $nexY);
633 633
 					}
634 634
 
635 635
 
636
-					$parameters=array(
636
+					$parameters = array(
637 637
 					    'object' => $object,
638 638
 					    'i' => $i,
639 639
 					    'pdf' =>& $pdf,
@@ -642,59 +642,59 @@  discard block
 block discarded – undo
642 642
 					    'outputlangs' => $outputlangs,
643 643
 					    'hidedetails' => $hidedetails
644 644
 					);
645
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
645
+					$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
646 646
 
647 647
 
648 648
 
649 649
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
650
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
651
-					else $tvaligne=$object->lines[$i]->total_tva;
650
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
651
+					else $tvaligne = $object->lines[$i]->total_tva;
652 652
 
653
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
654
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
655
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
656
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
657
-					$localtax1_type=$object->lines[$i]->localtax1_type;
658
-					$localtax2_type=$object->lines[$i]->localtax2_type;
653
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
654
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
655
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
656
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
657
+					$localtax1_type = $object->lines[$i]->localtax1_type;
658
+					$localtax2_type = $object->lines[$i]->localtax2_type;
659 659
 
660
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
661
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
662
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
660
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
661
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
662
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
663 663
 
664
-					$vatrate=(string) $object->lines[$i]->tva_tx;
664
+					$vatrate = (string) $object->lines[$i]->tva_tx;
665 665
 
666 666
 					// Retrieve type from database for backward compatibility with old records
667
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
668
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
667
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
668
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
669 669
 					{
670
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
670
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
671 671
 						$localtax1_type = $localtaxtmp_array[0];
672 672
 						$localtax2_type = $localtaxtmp_array[2];
673 673
 					}
674 674
 
675 675
 				    // retrieve global local tax
676 676
 					if ($localtax1_type && $localtax1ligne != 0)
677
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
677
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
678 678
 					if ($localtax2_type && $localtax2ligne != 0)
679
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
679
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
680 680
 
681
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
682
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
681
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
682
+					if (!isset($this->tva[$vatrate]))				$this->tva[$vatrate] = 0;
683 683
 					$this->tva[$vatrate] += $tvaligne;
684 684
 
685
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
685
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
686 686
 
687 687
 					// Add line
688
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
688
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
689 689
 					{
690 690
 						$pdf->setPage($pageposafter);
691
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
691
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
692 692
 						//$pdf->SetDrawColor(190,190,200);
693
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
693
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
694 694
 						$pdf->SetLineStyle(array('dash'=>0));
695 695
 					}
696 696
 
697
-					$nexY+=2;    // Passe espace entre les lignes
697
+					$nexY += 2; // Passe espace entre les lignes
698 698
 
699 699
 					// Detect if some page were added automatically and output _tableau for past pages
700 700
 					while ($pagenb < $pageposafter)
@@ -708,13 +708,13 @@  discard block
 block discarded – undo
708 708
 						{
709 709
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
710 710
 						}
711
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
711
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
712 712
 						$pagenb++;
713 713
 						$pdf->setPage($pagenb);
714
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
714
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
715 715
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
716 716
 					}
717
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
717
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
718 718
 					{
719 719
 					    if ($pagenb == $pageposafter)
720 720
 						{
@@ -724,10 +724,10 @@  discard block
 block discarded – undo
724 724
 						{
725 725
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
726 726
 						}
727
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
727
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
728 728
 						// New page
729 729
 						$pdf->AddPage();
730
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
730
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
731 731
 						$pagenb++;
732 732
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
733 733
 					}
@@ -737,19 +737,19 @@  discard block
 block discarded – undo
737 737
 				if ($pagenb == $pageposbeforeprintlines)
738 738
 				{
739 739
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
740
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
740
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
741 741
 				}
742 742
 				else
743 743
 				{
744 744
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
745
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
745
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
746 746
 				}
747 747
 
748 748
 				// Affiche zone infos
749
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
749
+				$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
750 750
 
751 751
 				// Affiche zone totaux
752
-				$posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
752
+				$posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
753 753
 
754 754
 				// Affiche zone versements
755 755
 				/*
@@ -762,21 +762,21 @@  discard block
 block discarded – undo
762 762
 				// Customer signature area
763 763
 				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
764 764
 				{
765
-				    $posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
765
+				    $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
766 766
 				}
767 767
 
768 768
 				// Pied de page
769
-				$this->_pagefoot($pdf,$object,$outputlangs);
770
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
769
+				$this->_pagefoot($pdf, $object, $outputlangs);
770
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
771 771
 
772 772
 				//If propal merge product PDF is active
773 773
 				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
774 774
 				{
775 775
 					require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
776 776
 
777
-					$already_merged = array ();
778
-					foreach ( $object->lines as $line ) {
779
-						if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
777
+					$already_merged = array();
778
+					foreach ($object->lines as $line) {
779
+						if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
780 780
 							// Find the desire PDF
781 781
 							$filetomerge = new Propalmergepdfproduct($this->db);
782 782
 
@@ -791,48 +791,48 @@  discard block
 block discarded – undo
791 791
 							$product = new Product($this->db);
792 792
 							$product->fetch($line->fk_product);
793 793
 
794
-							if ($product->entity!=$conf->entity) {
795
-								$entity_product_file=$product->entity;
794
+							if ($product->entity != $conf->entity) {
795
+								$entity_product_file = $product->entity;
796 796
 							} else {
797
-								$entity_product_file=$conf->entity;
797
+								$entity_product_file = $conf->entity;
798 798
 							}
799 799
 
800 800
 							// If PDF is selected and file is not empty
801 801
 							if (count($filetomerge->lines) > 0) {
802
-								foreach ( $filetomerge->lines as $linefile ) {
803
-									if (! empty($linefile->id) && ! empty($linefile->file_name)) {
802
+								foreach ($filetomerge->lines as $linefile) {
803
+									if (!empty($linefile->id) && !empty($linefile->file_name)) {
804 804
 
805 805
 
806
-										if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
806
+										if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
807 807
 										{
808
-											if (! empty($conf->product->enabled)) {
809
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
810
-											} elseif (! empty($conf->service->enabled)) {
811
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
808
+											if (!empty($conf->product->enabled)) {
809
+												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
810
+											} elseif (!empty($conf->service->enabled)) {
811
+												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
812 812
 											}
813 813
 										}
814 814
 										else
815 815
 										{
816
-											if (! empty($conf->product->enabled)) {
817
-												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
818
-											} elseif (! empty($conf->service->enabled)) {
819
-												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
816
+											if (!empty($conf->product->enabled)) {
817
+												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
818
+											} elseif (!empty($conf->service->enabled)) {
819
+												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
820 820
 											}
821 821
 										}
822 822
 
823
-										dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
823
+										dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
824 824
 
825
-										$infile = $filetomerge_dir . '/' . $linefile->file_name;
825
+										$infile = $filetomerge_dir.'/'.$linefile->file_name;
826 826
 										if (file_exists($infile) && is_readable($infile)) {
827 827
 											$pagecount = $pdf->setSourceFile($infile);
828
-											for($i = 1; $i <= $pagecount; $i ++) {
828
+											for ($i = 1; $i <= $pagecount; $i++) {
829 829
 												$tplIdx = $pdf->importPage($i);
830
-												if ($tplIdx!==false) {
830
+												if ($tplIdx !== false) {
831 831
 													$s = $pdf->getTemplatesize($tplIdx);
832 832
 													$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
833 833
 													$pdf->useTemplate($tplIdx);
834 834
 												} else {
835
-													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
835
+													setEventMessages(null, array($infile.' cannot be added, probably protected PDF'), 'warnings');
836 836
 												}
837 837
 											}
838 838
 										}
@@ -845,30 +845,30 @@  discard block
 block discarded – undo
845 845
 
846 846
 				$pdf->Close();
847 847
 
848
-				$pdf->Output($file,'F');
848
+				$pdf->Output($file, 'F');
849 849
 
850 850
 				//Add pdfgeneration hook
851 851
 				$hookmanager->initHooks(array('pdfgeneration'));
852
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
852
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
853 853
 				global $action;
854
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
854
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
855 855
 
856
-				if (! empty($conf->global->MAIN_UMASK))
856
+				if (!empty($conf->global->MAIN_UMASK))
857 857
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
858 858
 
859 859
 				$this->result = array('fullpath'=>$file);
860 860
 
861
-				return 1;   // Pas d'erreur
861
+				return 1; // Pas d'erreur
862 862
 			}
863 863
 			else
864 864
 			{
865
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
865
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
866 866
 				return 0;
867 867
 			}
868 868
 		}
869 869
 		else
870 870
 		{
871
-			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
871
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
872 872
 			return 0;
873 873
 		}
874 874
 	}
@@ -900,66 +900,66 @@  discard block
 block discarded – undo
900 900
 		global $conf;
901 901
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
902 902
 
903
-		$pdf->SetFont('','', $default_font_size - 1);
903
+		$pdf->SetFont('', '', $default_font_size - 1);
904 904
 
905 905
 		// If France, show VAT mention if not applicable
906 906
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
907 907
 		{
908
-			$pdf->SetFont('','B', $default_font_size - 2);
908
+			$pdf->SetFont('', 'B', $default_font_size - 2);
909 909
 			$pdf->SetXY($this->marge_gauche, $posy);
910 910
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
911 911
 
912
-			$posy=$pdf->GetY()+4;
912
+			$posy = $pdf->GetY() + 4;
913 913
 		}
914 914
 
915
-		$posxval=52;
915
+		$posxval = 52;
916 916
 
917 917
         // Show shipping date
918
-        if (! empty($object->date_livraison))
918
+        if (!empty($object->date_livraison))
919 919
 		{
920 920
             $outputlangs->load("sendings");
921
-			$pdf->SetFont('','B', $default_font_size - 2);
921
+			$pdf->SetFont('', 'B', $default_font_size - 2);
922 922
 			$pdf->SetXY($this->marge_gauche, $posy);
923 923
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
924 924
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
925
-			$pdf->SetFont('','', $default_font_size - 2);
925
+			$pdf->SetFont('', '', $default_font_size - 2);
926 926
 			$pdf->SetXY($posxval, $posy);
927
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
927
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
928 928
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
929 929
 
930
-            $posy=$pdf->GetY()+1;
930
+            $posy = $pdf->GetY() + 1;
931 931
 		}
932 932
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
933 933
 		{
934
-			$pdf->SetFont('','B', $default_font_size - 2);
934
+			$pdf->SetFont('', 'B', $default_font_size - 2);
935 935
 			$pdf->SetXY($this->marge_gauche, $posy);
936 936
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
937 937
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
938
-			$pdf->SetTextColor(0,0,0);
939
-			$pdf->SetFont('','', $default_font_size - 2);
938
+			$pdf->SetTextColor(0, 0, 0);
939
+			$pdf->SetFont('', '', $default_font_size - 2);
940 940
 			$pdf->SetXY($posxval, $posy);
941
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
942
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
941
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
942
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
943 943
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
944 944
 
945
-			$posy=$pdf->GetY()+1;
945
+			$posy = $pdf->GetY() + 1;
946 946
 		}
947 947
 
948 948
 		// Show payments conditions
949 949
 		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
950 950
 		{
951
-			$pdf->SetFont('','B', $default_font_size - 2);
951
+			$pdf->SetFont('', 'B', $default_font_size - 2);
952 952
 			$pdf->SetXY($this->marge_gauche, $posy);
953 953
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
954 954
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
955 955
 
956
-			$pdf->SetFont('','', $default_font_size - 2);
956
+			$pdf->SetFont('', '', $default_font_size - 2);
957 957
 			$pdf->SetXY($posxval, $posy);
958
-			$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);
959
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
960
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
958
+			$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);
959
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
960
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
961 961
 
962
-			$posy=$pdf->GetY()+3;
962
+			$posy = $pdf->GetY() + 3;
963 963
 		}
964 964
 
965 965
 		if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
@@ -985,25 +985,25 @@  discard block
 block discarded – undo
985 985
 			&& $object->mode_reglement_code != 'CHQ'
986 986
 			&& $object->mode_reglement_code != 'VIR')
987 987
 			{
988
-				$pdf->SetFont('','B', $default_font_size - 2);
988
+				$pdf->SetFont('', 'B', $default_font_size - 2);
989 989
 				$pdf->SetXY($this->marge_gauche, $posy);
990 990
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
991 991
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
992
-				$pdf->SetFont('','', $default_font_size - 2);
992
+				$pdf->SetFont('', '', $default_font_size - 2);
993 993
 				$pdf->SetXY($posxval, $posy);
994
-				$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);
995
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
994
+				$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);
995
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
996 996
 
997
-				$posy=$pdf->GetY()+2;
997
+				$posy = $pdf->GetY() + 2;
998 998
 			}
999 999
 
1000 1000
 			// Show payment mode CHQ
1001 1001
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1002 1002
 			{
1003 1003
 				// Si mode reglement non force ou si force a CHQ
1004
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
1004
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1005 1005
 				{
1006
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
1006
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1007 1007
 
1008 1008
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1009 1009
 					{
@@ -1011,31 +1011,31 @@  discard block
 block discarded – undo
1011 1011
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1012 1012
 
1013 1013
 						$pdf->SetXY($this->marge_gauche, $posy);
1014
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1015
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
1016
-						$posy=$pdf->GetY()+1;
1014
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1015
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1016
+						$posy = $pdf->GetY() + 1;
1017 1017
 
1018 1018
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1019 1019
 			            {
1020 1020
 							$pdf->SetXY($this->marge_gauche, $posy);
1021
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1021
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1022 1022
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1023
-							$posy=$pdf->GetY()+2;
1023
+							$posy = $pdf->GetY() + 2;
1024 1024
 			            }
1025 1025
 					}
1026 1026
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1027 1027
 					{
1028 1028
 						$pdf->SetXY($this->marge_gauche, $posy);
1029
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1030
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
1031
-						$posy=$pdf->GetY()+1;
1029
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1030
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1031
+						$posy = $pdf->GetY() + 1;
1032 1032
 
1033 1033
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1034 1034
 			            {
1035 1035
 							$pdf->SetXY($this->marge_gauche, $posy);
1036
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1036
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1037 1037
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1038
-							$posy=$pdf->GetY()+2;
1038
+							$posy = $pdf->GetY() + 2;
1039 1039
 			            }
1040 1040
 					}
1041 1041
 				}
@@ -1044,19 +1044,19 @@  discard block
 block discarded – undo
1044 1044
 			// If payment mode not forced or forced to VIR, show payment with BAN
1045 1045
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1046 1046
 			{
1047
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1047
+				if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
1048 1048
 				{
1049
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1050
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1049
+					$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1050
+					if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1051 1051
 					$account = new Account($this->db);
1052 1052
 					$account->fetch($bankid);
1053 1053
 
1054
-					$curx=$this->marge_gauche;
1055
-					$cury=$posy;
1054
+					$curx = $this->marge_gauche;
1055
+					$cury = $posy;
1056 1056
 
1057
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1057
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1058 1058
 
1059
-					$posy+=2;
1059
+					$posy += 2;
1060 1060
 				}
1061 1061
 			}
1062 1062
 		}
@@ -1077,43 +1077,43 @@  discard block
 block discarded – undo
1077 1077
 	 */
1078 1078
 	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1079 1079
 	{
1080
-		global $conf,$mysoc;
1080
+		global $conf, $mysoc;
1081 1081
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1082 1082
 
1083 1083
 		$tab2_top = $posy;
1084 1084
 		$tab2_hl = 4;
1085
-		$pdf->SetFont('','', $default_font_size - 1);
1085
+		$pdf->SetFont('', '', $default_font_size - 1);
1086 1086
 
1087 1087
 		// Tableau total
1088 1088
 		$col1x = 120; $col2x = 170;
1089 1089
 		if ($this->page_largeur < 210) // To work with US executive format
1090 1090
 		{
1091
-			$col2x-=20;
1091
+			$col2x -= 20;
1092 1092
 		}
1093 1093
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1094 1094
 
1095
-		$useborder=0;
1095
+		$useborder = 0;
1096 1096
 		$index = 0;
1097 1097
 
1098 1098
 		// Total HT
1099
-		$pdf->SetFillColor(255,255,255);
1099
+		$pdf->SetFillColor(255, 255, 255);
1100 1100
 		$pdf->SetXY($col1x, $tab2_top + 0);
1101
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1101
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1102 1102
 
1103 1103
 		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1104 1104
 		$pdf->SetXY($col2x, $tab2_top + 0);
1105
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1105
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
1106 1106
 
1107 1107
 		// Show VAT by rates and total
1108
-		$pdf->SetFillColor(248,248,248);
1108
+		$pdf->SetFillColor(248, 248, 248);
1109 1109
 
1110 1110
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1111 1111
 
1112
-		$this->atleastoneratenotnull=0;
1112
+		$this->atleastoneratenotnull = 0;
1113 1113
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1114 1114
 		{
1115
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1116
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1115
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1116
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1117 1117
 			{
1118 1118
 				// Nothing to do
1119 1119
 			}
@@ -1122,28 +1122,28 @@  discard block
 block discarded – undo
1122 1122
 				//Local tax 1 before VAT
1123 1123
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1124 1124
 				//{
1125
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1125
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1126 1126
 					{
1127
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1127
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1128 1128
 
1129
-						foreach( $localtax_rate as $tvakey => $tvaval )
1129
+						foreach ($localtax_rate as $tvakey => $tvaval)
1130 1130
 						{
1131
-							if ($tvakey!=0)    // On affiche pas taux 0
1131
+							if ($tvakey != 0)    // On affiche pas taux 0
1132 1132
 							{
1133 1133
 								//$this->atleastoneratenotnull++;
1134 1134
 
1135 1135
 								$index++;
1136 1136
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 1137
 
1138
-								$tvacompl='';
1139
-								if (preg_match('/\*/',$tvakey))
1138
+								$tvacompl = '';
1139
+								if (preg_match('/\*/', $tvakey))
1140 1140
 								{
1141
-									$tvakey=str_replace('*','',$tvakey);
1141
+									$tvakey = str_replace('*', '', $tvakey);
1142 1142
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1143 1143
 								}
1144
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1145
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1144
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1145
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1146
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147 1147
 
1148 1148
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149 1149
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1154,13 +1154,13 @@  discard block
 block discarded – undo
1154 1154
 				//Local tax 2 before VAT
1155 1155
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1156 1156
 				//{
1157
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1157
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1158 1158
 					{
1159
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1159
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1160 1160
 
1161
-						foreach( $localtax_rate as $tvakey => $tvaval )
1161
+						foreach ($localtax_rate as $tvakey => $tvaval)
1162 1162
 						{
1163
-							if ($tvakey!=0)    // On affiche pas taux 0
1163
+							if ($tvakey != 0)    // On affiche pas taux 0
1164 1164
 							{
1165 1165
 								//$this->atleastoneratenotnull++;
1166 1166
 
@@ -1169,15 +1169,15 @@  discard block
 block discarded – undo
1169 1169
 								$index++;
1170 1170
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1171 1171
 
1172
-								$tvacompl='';
1173
-								if (preg_match('/\*/',$tvakey))
1172
+								$tvacompl = '';
1173
+								if (preg_match('/\*/', $tvakey))
1174 1174
 								{
1175
-									$tvakey=str_replace('*','',$tvakey);
1175
+									$tvakey = str_replace('*', '', $tvakey);
1176 1176
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1177 1177
 								}
1178 1178
 								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1179
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1180
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1179
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1180
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1181 1181
 
1182 1182
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1183 1183
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 					}
1187 1187
 				//}
1188 1188
 				// VAT
1189
-				foreach($this->tva as $tvakey => $tvaval)
1189
+				foreach ($this->tva as $tvakey => $tvaval)
1190 1190
 				{
1191 1191
 					if ($tvakey != 0)    // On affiche pas taux 0
1192 1192
 					{
@@ -1195,15 +1195,15 @@  discard block
 block discarded – undo
1195 1195
 						$index++;
1196 1196
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1197 1197
 
1198
-						$tvacompl='';
1199
-						if (preg_match('/\*/',$tvakey))
1198
+						$tvacompl = '';
1199
+						if (preg_match('/\*/', $tvakey))
1200 1200
 						{
1201
-							$tvakey=str_replace('*','',$tvakey);
1201
+							$tvakey = str_replace('*', '', $tvakey);
1202 1202
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1203 1203
 						}
1204
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1205
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1206
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1204
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1205
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1206
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1207 1207
 
1208 1208
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1209 1209
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1213,11 +1213,11 @@  discard block
 block discarded – undo
1213 1213
 				//Local tax 1 after VAT
1214 1214
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1215 1215
 				//{
1216
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1216
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1217 1217
 					{
1218
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1218
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1219 1219
 
1220
-						foreach( $localtax_rate as $tvakey => $tvaval )
1220
+						foreach ($localtax_rate as $tvakey => $tvaval)
1221 1221
 						{
1222 1222
 							if ($tvakey != 0)    // On affiche pas taux 0
1223 1223
 							{
@@ -1226,16 +1226,16 @@  discard block
 block discarded – undo
1226 1226
 								$index++;
1227 1227
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1228 1228
 
1229
-								$tvacompl='';
1230
-								if (preg_match('/\*/',$tvakey))
1229
+								$tvacompl = '';
1230
+								if (preg_match('/\*/', $tvakey))
1231 1231
 								{
1232
-									$tvakey=str_replace('*','',$tvakey);
1232
+									$tvakey = str_replace('*', '', $tvakey);
1233 1233
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1234 1234
 								}
1235
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1235
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1236 1236
 
1237
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1238
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1237
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1238
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1239 1239
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240 1240
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1241 1241
 							}
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 				//Local tax 2 after VAT
1246 1246
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1247 1247
 				//{
1248
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1248
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1249 1249
 					{
1250
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1250
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1251 1251
 
1252
-						foreach( $localtax_rate as $tvakey => $tvaval )
1252
+						foreach ($localtax_rate as $tvakey => $tvaval)
1253 1253
 						{
1254 1254
 						    // retrieve global local tax
1255 1255
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1259,16 +1259,16 @@  discard block
 block discarded – undo
1259 1259
 								$index++;
1260 1260
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1261 1261
 
1262
-								$tvacompl='';
1263
-								if (preg_match('/\*/',$tvakey))
1262
+								$tvacompl = '';
1263
+								if (preg_match('/\*/', $tvakey))
1264 1264
 								{
1265
-									$tvakey=str_replace('*','',$tvakey);
1265
+									$tvakey = str_replace('*', '', $tvakey);
1266 1266
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1267 1267
 								}
1268
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1268
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1269 1269
 
1270
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1271
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1270
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1271
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1272 1272
 
1273 1273
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1274 1274
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1280,16 +1280,16 @@  discard block
 block discarded – undo
1280 1280
 				// Total TTC
1281 1281
 				$index++;
1282 1282
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1283
-				$pdf->SetTextColor(0,0,60);
1284
-				$pdf->SetFillColor(224,224,224);
1285
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1283
+				$pdf->SetTextColor(0, 0, 60);
1284
+				$pdf->SetFillColor(224, 224, 224);
1285
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1286 1286
 
1287 1287
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1288 1288
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1289 1289
 			}
1290 1290
 		}
1291 1291
 
1292
-		$pdf->SetTextColor(0,0,0);
1292
+		$pdf->SetTextColor(0, 0, 0);
1293 1293
 
1294 1294
 		/*
1295 1295
 		$resteapayer = $object->total_ttc - $deja_regle;
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 			$index++;
1302 1302
 
1303 1303
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1304
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1304
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1305 1305
 
1306 1306
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1307 1307
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1323,16 +1323,16 @@  discard block
 block discarded – undo
1323 1323
 			*/
1324 1324
 
1325 1325
 			$index++;
1326
-			$pdf->SetTextColor(0,0,60);
1327
-			$pdf->SetFillColor(224,224,224);
1326
+			$pdf->SetTextColor(0, 0, 60);
1327
+			$pdf->SetFillColor(224, 224, 224);
1328 1328
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1329
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1329
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1330 1330
 
1331 1331
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1332 1332
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1333 1333
 
1334
-			$pdf->SetFont('','', $default_font_size - 1);
1335
-			$pdf->SetTextColor(0,0,0);
1334
+			$pdf->SetFont('', '', $default_font_size - 1);
1335
+			$pdf->SetTextColor(0, 0, 0);
1336 1336
 		}
1337 1337
 
1338 1338
 		$index++;
@@ -1352,61 +1352,61 @@  discard block
 block discarded – undo
1352 1352
 	 *   @param		string		$currency		Currency code
1353 1353
 	 *   @return	void
1354 1354
 	 */
1355
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1355
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1356 1356
 	{
1357 1357
 		global $conf;
1358 1358
 
1359 1359
 		// Force to disable hidetop and hidebottom
1360
-		$hidebottom=0;
1361
-		if ($hidetop) $hidetop=-1;
1360
+		$hidebottom = 0;
1361
+		if ($hidetop) $hidetop = -1;
1362 1362
 
1363 1363
 		$currency = !empty($currency) ? $currency : $conf->currency;
1364 1364
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1365 1365
 
1366 1366
 		// Amount in (at tab_top - 1)
1367
-		$pdf->SetTextColor(0,0,0);
1368
-		$pdf->SetFont('','', $default_font_size - 2);
1367
+		$pdf->SetTextColor(0, 0, 0);
1368
+		$pdf->SetFont('', '', $default_font_size - 2);
1369 1369
 
1370 1370
 		if (empty($hidetop))
1371 1371
 		{
1372
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1373
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1372
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1373
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1374 1374
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1375 1375
 
1376 1376
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1377
-			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));
1377
+			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));
1378 1378
 		}
1379 1379
 
1380
-		$pdf->SetDrawColor(128,128,128);
1381
-		$pdf->SetFont('','', $default_font_size - 1);
1380
+		$pdf->SetDrawColor(128, 128, 128);
1381
+		$pdf->SetFont('', '', $default_font_size - 1);
1382 1382
 
1383 1383
 		// Output Rect
1384
-		$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
1384
+		$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
1385 1385
 
1386 1386
 
1387 1387
 		foreach ($this->cols as $colKey => $colDef)
1388 1388
 		{
1389
-		    if(!$this->getColumnStatus($colKey)) continue;
1389
+		    if (!$this->getColumnStatus($colKey)) continue;
1390 1390
 
1391 1391
 		    // get title label
1392
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1392
+		    $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
1393 1393
 
1394 1394
 		    // Add column separator
1395
-		    if(!empty($colDef['border-left'])){
1395
+		    if (!empty($colDef['border-left'])) {
1396 1396
 		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1397 1397
 		    }
1398 1398
 
1399 1399
 		    if (empty($hidetop))
1400 1400
 		    {
1401
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1401
+		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
1402 1402
 
1403
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1404
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1403
+		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
1404
+		      $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
1405 1405
 		    }
1406 1406
 		}
1407 1407
 
1408
-		if (empty($hidetop)){
1409
-			$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
1408
+		if (empty($hidetop)) {
1409
+			$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
1410 1410
 		}
1411 1411
 	}
1412 1412
 
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 	 */
1422 1422
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1423 1423
 	{
1424
-		global $conf,$langs;
1424
+		global $conf, $langs;
1425 1425
 
1426 1426
 		$outputlangs->load("main");
1427 1427
 		$outputlangs->load("bills");
@@ -1430,106 +1430,106 @@  discard block
 block discarded – undo
1430 1430
 
1431 1431
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1432 1432
 
1433
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1433
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1434 1434
 
1435 1435
 		//  Show Draft Watermark
1436
-		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1436
+		if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
1437 1437
 		{
1438
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1438
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
1439 1439
 		}
1440 1440
 
1441
-		$pdf->SetTextColor(0,0,60);
1442
-		$pdf->SetFont('','B', $default_font_size + 3);
1441
+		$pdf->SetTextColor(0, 0, 60);
1442
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1443 1443
 
1444
-		$posy=$this->marge_haute;
1445
-		$posx=$this->page_largeur-$this->marge_droite-100;
1444
+		$posy = $this->marge_haute;
1445
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1446 1446
 
1447
-		$pdf->SetXY($this->marge_gauche,$posy);
1447
+		$pdf->SetXY($this->marge_gauche, $posy);
1448 1448
 
1449 1449
 		// Logo
1450 1450
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1451 1451
 		{
1452
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1452
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1453 1453
 			if ($this->emetteur->logo)
1454 1454
 			{
1455 1455
 				if (is_readable($logo))
1456 1456
 				{
1457
-				    $height=pdf_getHeightForLogo($logo);
1458
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1457
+				    $height = pdf_getHeightForLogo($logo);
1458
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1459 1459
 				}
1460 1460
 				else
1461 1461
 				{
1462
-					$pdf->SetTextColor(200,0,0);
1463
-					$pdf->SetFont('','B',$default_font_size - 2);
1464
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1462
+					$pdf->SetTextColor(200, 0, 0);
1463
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1464
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1465 1465
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1466 1466
 				}
1467 1467
 			}
1468 1468
 			else
1469 1469
 			{
1470
-				$text=$this->emetteur->name;
1470
+				$text = $this->emetteur->name;
1471 1471
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1472 1472
 			}
1473 1473
 		}
1474 1474
 
1475
-		$pdf->SetFont('','B',$default_font_size + 3);
1476
-		$pdf->SetXY($posx,$posy);
1477
-		$pdf->SetTextColor(0,0,60);
1478
-		$title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1475
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1476
+		$pdf->SetXY($posx, $posy);
1477
+		$pdf->SetTextColor(0, 0, 60);
1478
+		$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
1479 1479
 		$pdf->MultiCell(100, 4, $title, '', 'R');
1480 1480
 
1481
-		$pdf->SetFont('','B',$default_font_size);
1481
+		$pdf->SetFont('', 'B', $default_font_size);
1482 1482
 
1483
-		$posy+=5;
1484
-		$pdf->SetXY($posx,$posy);
1485
-		$pdf->SetTextColor(0,0,60);
1486
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1483
+		$posy += 5;
1484
+		$pdf->SetXY($posx, $posy);
1485
+		$pdf->SetTextColor(0, 0, 60);
1486
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1487 1487
 
1488
-		$posy+=1;
1489
-		$pdf->SetFont('','', $default_font_size - 2);
1488
+		$posy += 1;
1489
+		$pdf->SetFont('', '', $default_font_size - 2);
1490 1490
 
1491 1491
 		if ($object->ref_client)
1492 1492
 		{
1493
-			$posy+=4;
1494
-			$pdf->SetXY($posx,$posy);
1495
-			$pdf->SetTextColor(0,0,60);
1496
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1493
+			$posy += 4;
1494
+			$pdf->SetXY($posx, $posy);
1495
+			$pdf->SetTextColor(0, 0, 60);
1496
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1497 1497
 		}
1498 1498
 
1499
-		$posy+=4;
1500
-		$pdf->SetXY($posx,$posy);
1501
-		$pdf->SetTextColor(0,0,60);
1502
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1499
+		$posy += 4;
1500
+		$pdf->SetXY($posx, $posy);
1501
+		$pdf->SetTextColor(0, 0, 60);
1502
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1503 1503
 
1504
-		$posy+=4;
1505
-		$pdf->SetXY($posx,$posy);
1506
-		$pdf->SetTextColor(0,0,60);
1507
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1504
+		$posy += 4;
1505
+		$pdf->SetXY($posx, $posy);
1506
+		$pdf->SetTextColor(0, 0, 60);
1507
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
1508 1508
 
1509 1509
 		if ($object->thirdparty->code_client)
1510 1510
 		{
1511
-			$posy+=4;
1512
-			$pdf->SetXY($posx,$posy);
1513
-			$pdf->SetTextColor(0,0,60);
1514
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1511
+			$posy += 4;
1512
+			$pdf->SetXY($posx, $posy);
1513
+			$pdf->SetTextColor(0, 0, 60);
1514
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1515 1515
 		}
1516 1516
 
1517 1517
 		// Get contact
1518 1518
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1519 1519
 		{
1520
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1520
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1521 1521
 		    if (count($arrayidcontact) > 0)
1522 1522
 		    {
1523
-		        $usertmp=new User($this->db);
1523
+		        $usertmp = new User($this->db);
1524 1524
 		        $usertmp->fetch($arrayidcontact[0]);
1525
-                $posy+=4;
1526
-                $pdf->SetXY($posx,$posy);
1527
-		        $pdf->SetTextColor(0,0,60);
1525
+                $posy += 4;
1526
+                $pdf->SetXY($posx, $posy);
1527
+		        $pdf->SetTextColor(0, 0, 60);
1528 1528
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1529 1529
 		    }
1530 1530
 		}
1531 1531
 
1532
-		$posy+=2;
1532
+		$posy += 2;
1533 1533
 
1534 1534
 		$top_shift = 0;
1535 1535
 		// Show list of linked objects
@@ -1543,53 +1543,53 @@  discard block
 block discarded – undo
1543 1543
 		if ($showaddress)
1544 1544
 		{
1545 1545
 			// Sender properties
1546
-			$carac_emetteur='';
1546
+			$carac_emetteur = '';
1547 1547
 		 	// Add internal contact of proposal if defined
1548
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1548
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1549 1549
 		 	if (count($arrayidcontact) > 0)
1550 1550
 		 	{
1551 1551
 		 		$object->fetch_user($arrayidcontact[0]);
1552
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1553
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1552
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1553
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1554 1554
 		 	}
1555 1555
 
1556 1556
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1557 1557
 
1558 1558
 			// Show sender
1559
-			$posy=42+$top_shift;
1560
-		 	$posx=$this->marge_gauche;
1561
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1562
-			$hautcadre=40;
1559
+			$posy = 42 + $top_shift;
1560
+		 	$posx = $this->marge_gauche;
1561
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1562
+			$hautcadre = 40;
1563 1563
 
1564 1564
 			// Show sender frame
1565
-			$pdf->SetTextColor(0,0,0);
1566
-			$pdf->SetFont('','', $default_font_size - 2);
1567
-			$pdf->SetXY($posx,$posy-5);
1568
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1569
-			$pdf->SetXY($posx,$posy);
1570
-			$pdf->SetFillColor(230,230,230);
1565
+			$pdf->SetTextColor(0, 0, 0);
1566
+			$pdf->SetFont('', '', $default_font_size - 2);
1567
+			$pdf->SetXY($posx, $posy - 5);
1568
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1569
+			$pdf->SetXY($posx, $posy);
1570
+			$pdf->SetFillColor(230, 230, 230);
1571 1571
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1572
-			$pdf->SetTextColor(0,0,60);
1572
+			$pdf->SetTextColor(0, 0, 60);
1573 1573
 
1574 1574
 			// Show sender name
1575
-			$pdf->SetXY($posx+2,$posy+3);
1576
-			$pdf->SetFont('','B', $default_font_size);
1575
+			$pdf->SetXY($posx + 2, $posy + 3);
1576
+			$pdf->SetFont('', 'B', $default_font_size);
1577 1577
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1578
-			$posy=$pdf->getY();
1578
+			$posy = $pdf->getY();
1579 1579
 
1580 1580
 			// Show sender information
1581
-			$pdf->SetXY($posx+2,$posy);
1582
-			$pdf->SetFont('','', $default_font_size - 1);
1581
+			$pdf->SetXY($posx + 2, $posy);
1582
+			$pdf->SetFont('', '', $default_font_size - 1);
1583 1583
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1584 1584
 
1585 1585
 
1586 1586
 			// If CUSTOMER contact defined, we use it
1587
-			$usecontact=false;
1588
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1587
+			$usecontact = false;
1588
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1589 1589
 			if (count($arrayidcontact) > 0)
1590 1590
 			{
1591
-				$usecontact=true;
1592
-				$result=$object->fetch_contact($arrayidcontact[0]);
1591
+				$usecontact = true;
1592
+				$result = $object->fetch_contact($arrayidcontact[0]);
1593 1593
 			}
1594 1594
 
1595 1595
 			//Recipient name
@@ -1600,38 +1600,38 @@  discard block
 block discarded – undo
1600 1600
 				$thirdparty = $object->thirdparty;
1601 1601
 			}
1602 1602
 
1603
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1603
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1604 1604
 
1605
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1605
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1606 1606
 
1607 1607
 			// Show recipient
1608
-			$widthrecbox=100;
1609
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1610
-			$posy=42+$top_shift;
1611
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1612
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1608
+			$widthrecbox = 100;
1609
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1610
+			$posy = 42 + $top_shift;
1611
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1612
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1613 1613
 
1614 1614
 			// Show recipient frame
1615
-			$pdf->SetTextColor(0,0,0);
1616
-			$pdf->SetFont('','', $default_font_size - 2);
1617
-			$pdf->SetXY($posx+2,$posy-5);
1615
+			$pdf->SetTextColor(0, 0, 0);
1616
+			$pdf->SetFont('', '', $default_font_size - 2);
1617
+			$pdf->SetXY($posx + 2, $posy - 5);
1618 1618
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1619 1619
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1620 1620
 
1621 1621
 			// Show recipient name
1622
-			$pdf->SetXY($posx+2,$posy+3);
1623
-			$pdf->SetFont('','B', $default_font_size);
1622
+			$pdf->SetXY($posx + 2, $posy + 3);
1623
+			$pdf->SetFont('', 'B', $default_font_size);
1624 1624
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1625 1625
 
1626 1626
 			$posy = $pdf->getY();
1627 1627
 
1628 1628
 			// Show recipient information
1629
-			$pdf->SetFont('','', $default_font_size - 1);
1630
-			$pdf->SetXY($posx+2,$posy);
1629
+			$pdf->SetFont('', '', $default_font_size - 1);
1630
+			$pdf->SetXY($posx + 2, $posy);
1631 1631
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1632 1632
 		}
1633 1633
 
1634
-		$pdf->SetTextColor(0,0,0);
1634
+		$pdf->SetTextColor(0, 0, 0);
1635 1635
 		return $top_shift;
1636 1636
 	}
1637 1637
 
@@ -1644,11 +1644,11 @@  discard block
 block discarded – undo
1644 1644
 	 *      @param	int			$hidefreetext		1=Hide free text
1645 1645
 	 *      @return	int								Return height of bottom margin including footer text
1646 1646
 	 */
1647
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1647
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1648 1648
 	{
1649 1649
 		global $conf;
1650
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1651
-		return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1650
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1651
+		return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1652 1652
 	}
1653 1653
 
1654 1654
 	/**
@@ -1669,21 +1669,21 @@  discard block
 block discarded – undo
1669 1669
 
1670 1670
 		$posx = 120;
1671 1671
 		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
1672
-		$useborder=0;
1672
+		$useborder = 0;
1673 1673
 		$index = 0;
1674 1674
 		// Total HT
1675
-		$pdf->SetFillColor(255,255,255);
1675
+		$pdf->SetFillColor(255, 255, 255);
1676 1676
 		$pdf->SetXY($posx, $tab_top + 0);
1677
-		$pdf->SetFont('','', $default_font_size - 2);
1677
+		$pdf->SetFont('', '', $default_font_size - 2);
1678 1678
 		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1679 1679
 
1680 1680
 		$pdf->SetXY($posx, $tab_top + $tab_hl);
1681
-		$pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1682
-		if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1683
-			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3);
1681
+		$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
1682
+		if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1683
+			$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1684 1684
 		}
1685 1685
 
1686
-		return ($tab_hl*7);
1686
+		return ($tab_hl * 7);
1687 1687
 	}
1688 1688
 
1689 1689
 
@@ -1697,20 +1697,20 @@  discard block
 block discarded – undo
1697 1697
 	 *      @param	int				$hideref		Do not show ref
1698 1698
 	 *      @return	null
1699 1699
 	 */
1700
-    function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1700
+    function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1701 1701
     {
1702 1702
 	    global $conf, $hookmanager;
1703 1703
 
1704 1704
 	    // Default field style for content
1705 1705
 	    $this->defaultContentsFieldsStyle = array(
1706 1706
 	        'align' => 'R', // R,C,L
1707
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1707
+	        'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1708 1708
 	    );
1709 1709
 
1710 1710
 	    // Default field style for content
1711 1711
 	    $this->defaultTitlesFieldsStyle = array(
1712 1712
 	        'align' => 'C', // R,C,L
1713
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1713
+	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1714 1714
 	    );
1715 1715
 
1716 1716
 	    /*
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	     );
1732 1732
 	     */
1733 1733
 
1734
-	    $rank=0; // do not use negative rank
1734
+	    $rank = 0; // do not use negative rank
1735 1735
 	    $this->cols['desc'] = array(
1736 1736
 	        'rank' => $rank,
1737 1737
 	        'width' => false, // only for desc
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 	            'align' => 'L',
1742 1742
 	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1743 1743
 	            // 'label' => ' ', // the final label
1744
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1744
+	            'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1745 1745
 	        ),
1746 1746
 	        'content' => array(
1747 1747
 	            'align' => 'L',
@@ -1751,19 +1751,19 @@  discard block
 block discarded – undo
1751 1751
 	    $rank = $rank + 10;
1752 1752
 	    $this->cols['photo'] = array(
1753 1753
 	        'rank' => $rank,
1754
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1754
+	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1755 1755
 	        'status' => false,
1756 1756
 	        'title' => array(
1757 1757
 	            'textkey' => 'Photo',
1758 1758
 	            'label' => ' '
1759 1759
 	        ),
1760 1760
 	        'content' => array(
1761
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1761
+	            'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1762 1762
 	        ),
1763 1763
 	        'border-left' => false, // remove left line separator
1764 1764
 	    );
1765 1765
 
1766
-	    if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
1766
+	    if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
1767 1767
 	    {
1768 1768
 	        $this->cols['photo']['status'] = true;
1769 1769
 	    }
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
 	        'border-left' => false, // add left line separator
1819 1819
 	    );
1820 1820
 
1821
-	    if($this->situationinvoice)
1821
+	    if ($this->situationinvoice)
1822 1822
 	    {
1823 1823
 	        $this->cols['progress']['status'] = true;
1824 1824
 	    }
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 	        ),
1834 1834
 	        'border-left' => true, // add left line separator
1835 1835
 	    );
1836
-	    if($conf->global->PRODUCT_USE_UNITS){
1836
+	    if ($conf->global->PRODUCT_USE_UNITS) {
1837 1837
 	        $this->cols['unit']['status'] = true;
1838 1838
 	    }
1839 1839
 
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
 	        ),
1848 1848
 	        'border-left' => true, // add left line separator
1849 1849
 	    );
1850
-	    if ($this->atleastonediscount){
1850
+	    if ($this->atleastonediscount) {
1851 1851
 	        $this->cols['discount']['status'] = true;
1852 1852
 	    }
1853 1853
 
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
 	    );
1864 1864
 
1865 1865
 
1866
-	    $parameters=array(
1866
+	    $parameters = array(
1867 1867
 	        'object' => $object,
1868 1868
 	        'outputlangs' => $outputlangs,
1869 1869
 	        'hidedetails' => $hidedetails,
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 	        'hideref' => $hideref
1872 1872
 	    );
1873 1873
 
1874
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1874
+	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1875 1875
 	    if ($reshook < 0)
1876 1876
 	    {
1877 1877
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Please login to merge, or discard this patch.
Braces   +199 added lines, -103 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@  discard block
 block discarded – undo
104 104
 
105 105
 		// Get source company
106 106
 		$this->emetteur=$mysoc;
107
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
107
+		if (empty($this->emetteur->country_code)) {
108
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
109
+		}
110
+		// By default, if was not defined
108 111
 
109 112
 		// Define position of columns
110 113
 		$this->posxdesc=$this->marge_gauche+1;
@@ -135,9 +138,13 @@  discard block
 block discarded – undo
135 138
 	  // phpcs:enable
136 139
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
137 140
 
138
-		if (! is_object($outputlangs)) $outputlangs=$langs;
141
+		if (! is_object($outputlangs)) {
142
+		    $outputlangs=$langs;
143
+		}
139 144
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
140
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
145
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
146
+		    $outputlangs->charset_output='ISO-8859-1';
147
+		}
141 148
 
142 149
 		$outputlangs->load("main");
143 150
 		$outputlangs->load("dict");
@@ -157,7 +164,9 @@  discard block
 block discarded – undo
157 164
 
158 165
 			for ($i = 0 ; $i < $nblignes ; $i++)
159 166
 			{
160
-				if (empty($object->lines[$i]->fk_product)) continue;
167
+				if (empty($object->lines[$i]->fk_product)) {
168
+				    continue;
169
+				}
161 170
 
162 171
 				$objphoto->fetch($object->lines[$i]->fk_product);
163 172
                 //var_dump($objphoto->ref);exit;
@@ -165,8 +174,7 @@  discard block
 block discarded – undo
165 174
 				{
166 175
 					$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
167 176
 					$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
168
-				}
169
-				else
177
+				} else
170 178
 				{
171 179
 					$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
172 180
 					$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
@@ -181,18 +189,18 @@  discard block
 block discarded – undo
181 189
 
182 190
 						foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
183 191
 						{
184
-							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
192
+							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
193
+							    // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
185 194
 							{
186 195
 								if ($obj['photo_vignette'])
187 196
 								{
188 197
 									$filename= $obj['photo_vignette'];
189
-								}
190
-								else
198
+							}
199
+								} else
191 200
 								{
192 201
 									$filename=$obj['photo'];
193 202
 								}
194
-							}
195
-							else
203
+							} else
196 204
 							{
197 205
 								$filename=$obj['photo'];
198 206
 							}
@@ -204,11 +212,15 @@  discard block
 block discarded – undo
204 212
 					}
205 213
 				}
206 214
 
207
-				if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
215
+				if ($realpath && $arephoto) {
216
+				    $realpatharray[$i]=$realpath;
217
+				}
208 218
 			}
209 219
 		}
210 220
 
211
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
221
+		if (count($realpatharray) == 0) {
222
+		    $this->posxpicture=$this->posxtva;
223
+		}
212 224
 
213 225
 		if ($conf->propal->multidir_output[$conf->entity])
214 226
 		{
@@ -221,8 +233,7 @@  discard block
 block discarded – undo
221 233
 			{
222 234
 				$dir = $conf->propal->multidir_output[$conf->entity];
223 235
 				$file = $dir . "/SPECIMEN.pdf";
224
-			}
225
-			else
236
+			} else
226 237
 			{
227 238
 				$objectref = dol_sanitizeFileName($object->ref);
228 239
 				$dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref;
@@ -278,7 +289,9 @@  discard block
 block discarded – undo
278 289
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
279 290
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
280 291
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
281
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
292
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
293
+				    $pdf->SetCompression(false);
294
+				}
282 295
 
283 296
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
284 297
 
@@ -294,7 +307,9 @@  discard block
 block discarded – undo
294 307
 
295 308
 				// New page
296 309
 				$pdf->AddPage();
297
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
310
+				if (! empty($tplidx)) {
311
+				    $pdf->useTemplate($tplidx);
312
+				}
298 313
 				$pagenb++;
299 314
 
300 315
                 $heightforinfotot = 40;	// Height reserved to output the info and total part
@@ -345,7 +360,9 @@  discard block
 block discarded – undo
345 360
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
346 361
 						$salerepobj=new User($this->db);
347 362
 						$salerepobj->fetch($salereparray[0]['id']);
348
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
363
+						if (! empty($salerepobj->signature)) {
364
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
365
+						}
349 366
 					}
350 367
 				}
351 368
 				if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
@@ -353,8 +370,12 @@  discard block
 block discarded – undo
353 370
 				    $tmpuser=new User($this->db);
354 371
 				    $tmpuser->fetch($object->user_author_id);
355 372
 				    $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
356
-				    if ($tmpuser->email) $notetoshow.=',  Mail: '.$tmpuser->email;
357
-				    if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
373
+				    if ($tmpuser->email) {
374
+				        $notetoshow.=',  Mail: '.$tmpuser->email;
375
+				    }
376
+				    if ($tmpuser->office_phone) {
377
+				        $notetoshow.=', Tel: '.$tmpuser->office_phone;
378
+				    }
358 379
 				}
359 380
 
360 381
 				$pagenb = $pdf->getPage();
@@ -386,8 +407,12 @@  discard block
 block discarded – undo
386 407
 					    while ($pagenb < $pageposafternote) {
387 408
 					        $pdf->AddPage();
388 409
 					        $pagenb++;
389
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
390
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
410
+					        if (! empty($tplidx)) {
411
+					            $pdf->useTemplate($tplidx);
412
+					        }
413
+					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
414
+					            $this->_pagehead($pdf, $object, 0, $outputlangs);
415
+					        }
391 416
 					        // $this->_pagefoot($pdf,$object,$outputlangs,1);
392 417
 					        $pdf->setTopMargin($tab_top_newpage);
393 418
 					        // The only function to edit the bottom margin of current page to set it.
@@ -403,9 +428,11 @@  discard block
 block discarded – undo
403 428
 
404 429
 					    $posyafter = $pdf->GetY();
405 430
 
406
-					    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
431
+					    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) {
432
+					        // There is no space left for total+free text
407 433
 					    {
408 434
 					        $pdf->AddPage('','',true);
435
+					    }
409 436
 					        $pagenb++;
410 437
 					        $pageposafternote++;
411 438
 					        $pdf->setPage($pageposafternote);
@@ -427,8 +454,7 @@  discard block
 block discarded – undo
427 454
 					        if($i>$pageposbeforenote){
428 455
 					            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429 456
 					            $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
430
-					        }
431
-					        else{
457
+					        } else{
432 458
 					            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
433 459
 					            $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
434 460
 					        }
@@ -442,12 +468,15 @@  discard block
 block discarded – undo
442 468
 
443 469
 					    // apply note frame to last page
444 470
 					    $pdf->setPage($pageposafternote);
445
-					    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
446
-					    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
471
+					    if (! empty($tplidx)) {
472
+					        $pdf->useTemplate($tplidx);
473
+					    }
474
+					    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
475
+					        $this->_pagehead($pdf, $object, 0, $outputlangs);
476
+					    }
447 477
 					    $height_note=$posyafter-$tab_top_newpage;
448 478
 					    $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
449
-					}
450
-					else // No pagebreak
479
+					} else // No pagebreak
451 480
 					{
452 481
 					    $pdf->commitTransaction();
453 482
 					    $posyafter = $pdf->GetY();
@@ -462,8 +491,12 @@  discard block
 block discarded – undo
462 491
 					        $pagenb++;
463 492
 					        $pageposafternote++;
464 493
 					        $pdf->setPage($pageposafternote);
465
-					        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
466
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
494
+					        if (! empty($tplidx)) {
495
+					            $pdf->useTemplate($tplidx);
496
+					        }
497
+					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
498
+					            $this->_pagehead($pdf, $object, 0, $outputlangs);
499
+					        }
467 500
 
468 501
 					        $posyafter = $tab_top_newpage;
469 502
 					    }
@@ -471,8 +504,7 @@  discard block
 block discarded – undo
471 504
 
472 505
 					$tab_height = $tab_height - $height_note;
473 506
 					$tab_top = $posyafter +6;
474
-				}
475
-				else
507
+				} else
476 508
 				{
477 509
 					$height_note=0;
478 510
 				}
@@ -495,7 +527,9 @@  discard block
 block discarded – undo
495 527
 
496 528
 					// Define size of image if we need it
497 529
 					$imglinesize=array();
498
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
530
+					if (! empty($realpatharray[$i])) {
531
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
532
+					}
499 533
 
500 534
 					$pdf->setTopMargin($tab_top_newpage);
501 535
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -508,10 +542,14 @@  discard block
 block discarded – undo
508 542
 					if($this->getColumnStatus('photo'))
509 543
 					{
510 544
     					// We start with Photo of product line
511
-    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// If photo too high, we moved completely on new page
545
+    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) {
546
+    					    // If photo too high, we moved completely on new page
512 547
     					{
513 548
     						$pdf->AddPage('','',true);
514
-    						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
549
+    					}
550
+    						if (! empty($tplidx)) {
551
+    						    $pdf->useTemplate($tplidx);
552
+    						}
515 553
     						//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
516 554
     						$pdf->setPage($pageposbefore+1);
517 555
 
@@ -534,9 +572,11 @@  discard block
 block discarded – undo
534 572
     					$pdf->startTransaction();
535 573
     					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
536 574
     					$pageposafter=$pdf->getPage();
537
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
575
+    					if ($pageposafter > $pageposbefore) {
576
+    					    // There is a pagebreak
538 577
     					{
539 578
     						$pdf->rollbackTransaction(true);
579
+    					}
540 580
     						$pageposafter=$pageposbefore;
541 581
     						//print $pageposafter.'-'.$pageposbefore;exit;
542 582
     						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -545,23 +585,25 @@  discard block
 block discarded – undo
545 585
     						$pageposafter=$pdf->getPage();
546 586
     						$posyafter=$pdf->GetY();
547 587
     						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
548
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot)))	// There is no space left for total+free text
588
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) {
589
+    						    // There is no space left for total+free text
549 590
     						{
550 591
     							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
551 592
     							{
552 593
     								$pdf->AddPage('','',true);
553
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
594
+    						}
595
+    								if (! empty($tplidx)) {
596
+    								    $pdf->useTemplate($tplidx);
597
+    								}
554 598
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
555 599
     								$pdf->setPage($pageposafter+1);
556 600
     							}
557
-    						}
558
-    						else
601
+    						} else
559 602
     						{
560 603
     							// We found a page break
561 604
     							$showpricebeforepagebreak=0;
562 605
     						}
563
-    					}
564
-    					else	// No pagebreak
606
+    					} else	// No pagebreak
565 607
     					{
566 608
     						$pdf->commitTransaction();
567 609
     					}
@@ -647,8 +689,11 @@  discard block
 block discarded – undo
647 689
 
648 690
 
649 691
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
650
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
651
-					else $tvaligne=$object->lines[$i]->total_tva;
692
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
693
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
694
+					} else {
695
+					    $tvaligne=$object->lines[$i]->total_tva;
696
+					}
652 697
 
653 698
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
654 699
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -657,32 +702,48 @@  discard block
 block discarded – undo
657 702
 					$localtax1_type=$object->lines[$i]->localtax1_type;
658 703
 					$localtax2_type=$object->lines[$i]->localtax2_type;
659 704
 
660
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
661
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
662
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
705
+					if ($object->remise_percent) {
706
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
707
+					}
708
+					if ($object->remise_percent) {
709
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
710
+					}
711
+					if ($object->remise_percent) {
712
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
713
+					}
663 714
 
664 715
 					$vatrate=(string) $object->lines[$i]->tva_tx;
665 716
 
666 717
 					// Retrieve type from database for backward compatibility with old records
667 718
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
668
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
719
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
720
+					    // and there is local tax
669 721
 					{
670 722
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
723
+					}
671 724
 						$localtax1_type = $localtaxtmp_array[0];
672 725
 						$localtax2_type = $localtaxtmp_array[2];
673 726
 					}
674 727
 
675 728
 				    // retrieve global local tax
676
-					if ($localtax1_type && $localtax1ligne != 0)
677
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
678
-					if ($localtax2_type && $localtax2ligne != 0)
679
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
729
+					if ($localtax1_type && $localtax1ligne != 0) {
730
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
731
+					}
732
+					if ($localtax2_type && $localtax2ligne != 0) {
733
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
734
+					}
680 735
 
681
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
682
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
736
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
737
+					    $vatrate.='*';
738
+					}
739
+					if (! isset($this->tva[$vatrate])) {
740
+					    $this->tva[$vatrate]=0;
741
+					}
683 742
 					$this->tva[$vatrate] += $tvaligne;
684 743
 
685
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
744
+					if ($posYAfterImage > $posYAfterDescription) {
745
+					    $nexY=$posYAfterImage;
746
+					}
686 747
 
687 748
 					// Add line
688 749
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -703,8 +764,7 @@  discard block
 block discarded – undo
703 764
 						if ($pagenb == $pageposbeforeprintlines)
704 765
 						{
705 766
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
706
-						}
707
-						else
767
+						} else
708 768
 						{
709 769
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
710 770
 						}
@@ -712,24 +772,29 @@  discard block
 block discarded – undo
712 772
 						$pagenb++;
713 773
 						$pdf->setPage($pagenb);
714 774
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
715
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
775
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
776
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
777
+						}
716 778
 					}
717 779
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
718 780
 					{
719 781
 					    if ($pagenb == $pageposafter)
720 782
 						{
721 783
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
722
-						}
723
-						else
784
+						} else
724 785
 						{
725 786
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
726 787
 						}
727 788
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
728 789
 						// New page
729 790
 						$pdf->AddPage();
730
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
791
+						if (! empty($tplidx)) {
792
+						    $pdf->useTemplate($tplidx);
793
+						}
731 794
 						$pagenb++;
732
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
795
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
796
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
797
+						}
733 798
 					}
734 799
 				}
735 800
 
@@ -738,8 +803,7 @@  discard block
 block discarded – undo
738 803
 				{
739 804
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
740 805
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
741
-				}
742
-				else
806
+				} else
743 807
 				{
744 808
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
745 809
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
@@ -767,7 +831,9 @@  discard block
 block discarded – undo
767 831
 
768 832
 				// Pied de page
769 833
 				$this->_pagefoot($pdf,$object,$outputlangs);
770
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
834
+				if (method_exists($pdf,'AliasNbPages')) {
835
+				    $pdf->AliasNbPages();
836
+				}
771 837
 
772 838
 				//If propal merge product PDF is active
773 839
 				if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
@@ -810,8 +876,7 @@  discard block
 block discarded – undo
810 876
 											} elseif (! empty($conf->service->enabled)) {
811 877
 												$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
812 878
 											}
813
-										}
814
-										else
879
+										} else
815 880
 										{
816 881
 											if (! empty($conf->product->enabled)) {
817 882
 												$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
@@ -853,20 +918,19 @@  discard block
 block discarded – undo
853 918
 				global $action;
854 919
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
855 920
 
856
-				if (! empty($conf->global->MAIN_UMASK))
857
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
921
+				if (! empty($conf->global->MAIN_UMASK)) {
922
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
923
+				}
858 924
 
859 925
 				$this->result = array('fullpath'=>$file);
860 926
 
861 927
 				return 1;   // Pas d'erreur
862
-			}
863
-			else
928
+			} else
864 929
 			{
865 930
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
866 931
 				return 0;
867 932
 			}
868
-		}
869
-		else
933
+		} else
870 934
 		{
871 935
 			$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
872 936
 			return 0;
@@ -928,10 +992,11 @@  discard block
 block discarded – undo
928 992
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
929 993
 
930 994
             $posy=$pdf->GetY()+1;
931
-		}
932
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
995
+		} elseif ($object->availability_code || $object->availability) {
996
+            // Show availability conditions
933 997
 		{
934 998
 			$pdf->SetFont('','B', $default_font_size - 2);
999
+        }
935 1000
 			$pdf->SetXY($this->marge_gauche, $posy);
936 1001
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
937 1002
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -1047,7 +1112,10 @@  discard block
 block discarded – undo
1047 1112
 				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1048 1113
 				{
1049 1114
 					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1050
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1115
+					if (! empty($object->fk_bank)) {
1116
+					    $bankid=$object->fk_bank;
1117
+					}
1118
+					// For backward compatibility when object->fk_account is forced with object->fk_bank
1051 1119
 					$account = new Account($this->db);
1052 1120
 					$account->fetch($bankid);
1053 1121
 
@@ -1086,10 +1154,12 @@  discard block
 block discarded – undo
1086 1154
 
1087 1155
 		// Tableau total
1088 1156
 		$col1x = 120; $col2x = 170;
1089
-		if ($this->page_largeur < 210) // To work with US executive format
1157
+		if ($this->page_largeur < 210) {
1158
+		    // To work with US executive format
1090 1159
 		{
1091 1160
 			$col2x-=20;
1092 1161
 		}
1162
+		}
1093 1163
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1094 1164
 
1095 1165
 		$useborder=0;
@@ -1116,23 +1186,26 @@  discard block
 block discarded – undo
1116 1186
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1117 1187
 			{
1118 1188
 				// Nothing to do
1119
-			}
1120
-			else
1189
+			} else
1121 1190
 			{
1122 1191
 				//Local tax 1 before VAT
1123 1192
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1124 1193
 				//{
1125 1194
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1126 1195
 					{
1127
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1196
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1197
+						    continue;
1198
+						}
1128 1199
 
1129 1200
 						foreach( $localtax_rate as $tvakey => $tvaval )
1130 1201
 						{
1131
-							if ($tvakey!=0)    // On affiche pas taux 0
1202
+							if ($tvakey!=0) {
1203
+							    // On affiche pas taux 0
1132 1204
 							{
1133 1205
 								//$this->atleastoneratenotnull++;
1134 1206
 
1135 1207
 								$index++;
1208
+							}
1136 1209
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 1210
 
1138 1211
 								$tvacompl='';
@@ -1156,17 +1229,21 @@  discard block
 block discarded – undo
1156 1229
 				//{
1157 1230
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1158 1231
 					{
1159
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1232
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1233
+						    continue;
1234
+						}
1160 1235
 
1161 1236
 						foreach( $localtax_rate as $tvakey => $tvaval )
1162 1237
 						{
1163
-							if ($tvakey!=0)    // On affiche pas taux 0
1238
+							if ($tvakey!=0) {
1239
+							    // On affiche pas taux 0
1164 1240
 							{
1165 1241
 								//$this->atleastoneratenotnull++;
1166 1242
 
1167 1243
 
1168 1244
 
1169 1245
 								$index++;
1246
+							}
1170 1247
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1171 1248
 
1172 1249
 								$tvacompl='';
@@ -1188,9 +1265,11 @@  discard block
 block discarded – undo
1188 1265
 				// VAT
1189 1266
 				foreach($this->tva as $tvakey => $tvaval)
1190 1267
 				{
1191
-					if ($tvakey != 0)    // On affiche pas taux 0
1268
+					if ($tvakey != 0) {
1269
+					    // On affiche pas taux 0
1192 1270
 					{
1193 1271
 						$this->atleastoneratenotnull++;
1272
+					}
1194 1273
 
1195 1274
 						$index++;
1196 1275
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1215,15 +1294,19 @@  discard block
 block discarded – undo
1215 1294
 				//{
1216 1295
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1217 1296
 					{
1218
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1297
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1298
+						    continue;
1299
+						}
1219 1300
 
1220 1301
 						foreach( $localtax_rate as $tvakey => $tvaval )
1221 1302
 						{
1222
-							if ($tvakey != 0)    // On affiche pas taux 0
1303
+							if ($tvakey != 0) {
1304
+							    // On affiche pas taux 0
1223 1305
 							{
1224 1306
 								//$this->atleastoneratenotnull++;
1225 1307
 
1226 1308
 								$index++;
1309
+							}
1227 1310
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1228 1311
 
1229 1312
 								$tvacompl='';
@@ -1247,16 +1330,20 @@  discard block
 block discarded – undo
1247 1330
 				//{
1248 1331
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1249 1332
 					{
1250
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1333
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1334
+						    continue;
1335
+						}
1251 1336
 
1252 1337
 						foreach( $localtax_rate as $tvakey => $tvaval )
1253 1338
 						{
1254 1339
 						    // retrieve global local tax
1255
-							if ($tvakey != 0)    // On affiche pas taux 0
1340
+							if ($tvakey != 0) {
1341
+							    // On affiche pas taux 0
1256 1342
 							{
1257 1343
 								//$this->atleastoneratenotnull++;
1258 1344
 
1259 1345
 								$index++;
1346
+							}
1260 1347
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1261 1348
 
1262 1349
 								$tvacompl='';
@@ -1358,7 +1445,9 @@  discard block
 block discarded – undo
1358 1445
 
1359 1446
 		// Force to disable hidetop and hidebottom
1360 1447
 		$hidebottom=0;
1361
-		if ($hidetop) $hidetop=-1;
1448
+		if ($hidetop) {
1449
+		    $hidetop=-1;
1450
+		}
1362 1451
 
1363 1452
 		$currency = !empty($currency) ? $currency : $conf->currency;
1364 1453
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1374,7 +1463,9 @@  discard block
 block discarded – undo
1374 1463
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1375 1464
 
1376 1465
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1377
-			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));
1466
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1467
+			    $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));
1468
+			}
1378 1469
 		}
1379 1470
 
1380 1471
 		$pdf->SetDrawColor(128,128,128);
@@ -1386,7 +1477,9 @@  discard block
 block discarded – undo
1386 1477
 
1387 1478
 		foreach ($this->cols as $colKey => $colDef)
1388 1479
 		{
1389
-		    if(!$this->getColumnStatus($colKey)) continue;
1480
+		    if(!$this->getColumnStatus($colKey)) {
1481
+		        continue;
1482
+		    }
1390 1483
 
1391 1484
 		    // get title label
1392 1485
 		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
@@ -1456,16 +1549,14 @@  discard block
 block discarded – undo
1456 1549
 				{
1457 1550
 				    $height=pdf_getHeightForLogo($logo);
1458 1551
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1459
-				}
1460
-				else
1552
+				} else
1461 1553
 				{
1462 1554
 					$pdf->SetTextColor(200,0,0);
1463 1555
 					$pdf->SetFont('','B',$default_font_size - 2);
1464 1556
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1465 1557
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1466 1558
 				}
1467
-			}
1468
-			else
1559
+			} else
1469 1560
 			{
1470 1561
 				$text=$this->emetteur->name;
1471 1562
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1558,7 +1649,9 @@  discard block
 block discarded – undo
1558 1649
 			// Show sender
1559 1650
 			$posy=42+$top_shift;
1560 1651
 		 	$posx=$this->marge_gauche;
1561
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1652
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1653
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1654
+			}
1562 1655
 			$hautcadre=40;
1563 1656
 
1564 1657
 			// Show sender frame
@@ -1606,10 +1699,15 @@  discard block
 block discarded – undo
1606 1699
 
1607 1700
 			// Show recipient
1608 1701
 			$widthrecbox=100;
1609
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1702
+			if ($this->page_largeur < 210) {
1703
+			    $widthrecbox=84;
1704
+			}
1705
+			// To work with US executive format
1610 1706
 			$posy=42+$top_shift;
1611 1707
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1612
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1708
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1709
+			    $posx=$this->marge_gauche;
1710
+			}
1613 1711
 
1614 1712
 			// Show recipient frame
1615 1713
 			$pdf->SetTextColor(0,0,0);
@@ -1875,12 +1973,10 @@  discard block
 block discarded – undo
1875 1973
 	    if ($reshook < 0)
1876 1974
 	    {
1877 1975
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1878
-	    }
1879
-	    elseif (empty($reshook))
1976
+	    } elseif (empty($reshook))
1880 1977
 	    {
1881 1978
 	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1882
-	    }
1883
-	    else
1979
+	    } else
1884 1980
 	    {
1885 1981
 	        $this->cols = $hookmanager->resArray;
1886 1982
 	    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/propale/modules_propale.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePDFPropales extends CommonDocGenerator
38 38
 {
39
-	/**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
39
+    /**
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44 44
 
45 45
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
46
-	/**
47
-	 *  Return list of active generation modules
48
-	 *
46
+    /**
47
+     *  Return list of active generation modules
48
+     *
49 49
      *  @param	DoliDB	$db     			Database handler
50 50
      *  @param  integer	$maxfilenamelength  Max length of value to show
51 51
      *  @return	array						List of templates
52
-	 */
53
-	static function liste_modeles($db,$maxfilenamelength=0)
54
-	{
52
+     */
53
+    static function liste_modeles($db,$maxfilenamelength=0)
54
+    {
55 55
         // phpcs:enable
56
-		global $conf;
56
+        global $conf;
57 57
 
58
-		$type='propal';
59
-		$liste=array();
58
+        $type='propal';
59
+        $liste=array();
60 60
 
61
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
61
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
63 63
 
64
-		return $liste;
65
-	}
64
+        return $liste;
65
+    }
66 66
 }
67 67
 
68 68
 
@@ -71,83 +71,83 @@  discard block
 block discarded – undo
71 71
  */
72 72
 abstract class ModeleNumRefPropales
73 73
 {
74
-	/**
75
-	 * @var string Error code (or message)
76
-	 */
77
-	public $error='';
78
-
79
-	/**
80
-	 * Return if a module can be used or not
81
-	 *
82
-	 * @return	boolean     true if module can be used
83
-	 */
84
-	function isEnabled()
85
-	{
86
-		return true;
87
-	}
88
-
89
-	/**
90
-	 *  Renvoi la description par defaut du modele de numerotation
91
-	 *
92
-	 * 	@return     string      Texte descripif
93
-	 */
94
-	function info()
95
-	{
96
-		global $langs;
97
-		$langs->load("propale");
98
-		return $langs->trans("NoDescription");
99
-	}
100
-
101
-	/**
102
-	 * 	Renvoi un exemple de numerotation
103
-	 *
104
-	 *  @return     string      Example
105
-	 */
106
-	function getExample()
107
-	{
108
-		global $langs;
109
-		$langs->load("propale");
110
-		return $langs->trans("NoExample");
111
-	}
112
-
113
-	/**
114
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
115
-	 *  de conflits qui empechera 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
-	 * 	Renvoi prochaine valeur attribuee
126
-	 *
127
-	 *	@param		Societe		$objsoc     Object third party
128
-	 *	@param		Propal		$propal		Object commercial proposal
129
-	 *	@return     string      Valeur
130
-	 */
131
-	function getNextValue($objsoc,$propal)
132
-	{
133
-		global $langs;
134
-		return $langs->trans("NotAvailable");
135
-	}
136
-
137
-	/**
138
-	 *  Renvoi 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
-	}
74
+    /**
75
+     * @var string Error code (or message)
76
+     */
77
+    public $error='';
78
+
79
+    /**
80
+     * Return if a module can be used or not
81
+     *
82
+     * @return	boolean     true if module can be used
83
+     */
84
+    function isEnabled()
85
+    {
86
+        return true;
87
+    }
88
+
89
+    /**
90
+     *  Renvoi la description par defaut du modele de numerotation
91
+     *
92
+     * 	@return     string      Texte descripif
93
+     */
94
+    function info()
95
+    {
96
+        global $langs;
97
+        $langs->load("propale");
98
+        return $langs->trans("NoDescription");
99
+    }
100
+
101
+    /**
102
+     * 	Renvoi un exemple de numerotation
103
+     *
104
+     *  @return     string      Example
105
+     */
106
+    function getExample()
107
+    {
108
+        global $langs;
109
+        $langs->load("propale");
110
+        return $langs->trans("NoExample");
111
+    }
112
+
113
+    /**
114
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
115
+     *  de conflits qui empechera 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
+     * 	Renvoi prochaine valeur attribuee
126
+     *
127
+     *	@param		Societe		$objsoc     Object third party
128
+     *	@param		Propal		$propal		Object commercial proposal
129
+     *	@return     string      Valeur
130
+     */
131
+    function getNextValue($objsoc,$propal)
132
+    {
133
+        global $langs;
134
+        return $langs->trans("NotAvailable");
135
+    }
136
+
137
+    /**
138
+     *  Renvoi 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   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';   // Requis car utilise dans les classes qui heritent
31
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
32 32
 
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @var string Error code (or message)
41 41
 	 */
42
-	public $error='';
42
+	public $error = '';
43 43
 
44 44
 
45 45
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
      *  @param  integer	$maxfilenamelength  Max length of value to show
51 51
      *  @return	array						List of templates
52 52
 	 */
53
-	static function liste_modeles($db,$maxfilenamelength=0)
53
+	static function liste_modeles($db, $maxfilenamelength = 0)
54 54
 	{
55 55
         // phpcs:enable
56 56
 		global $conf;
57 57
 
58
-		$type='propal';
59
-		$liste=array();
58
+		$type = 'propal';
59
+		$liste = array();
60 60
 
61 61
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
62
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
63 63
 
64 64
 		return $liste;
65 65
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @var string Error code (or message)
76 76
 	 */
77
-	public $error='';
77
+	public $error = '';
78 78
 
79 79
 	/**
80 80
 	 * Return if a module can be used or not
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 *	@param		Propal		$propal		Object commercial proposal
129 129
 	 *	@return     string      Valeur
130 130
 	 */
131
-	function getNextValue($objsoc,$propal)
131
+	function getNextValue($objsoc, $propal)
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/propale/mod_propale_saphir.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_propale_saphir extends ModeleNumRefPropales
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
-	/**
42
+    /**
43 43
      * @var string Error code (or message)
44 44
      */
45 45
     public $error = '';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Saphir';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Saphir';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Saphir';
54
+    /**
55
+     * @var string model 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="maskconstpropal" value="PROPALE_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="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
78
+        $texte.= '<table class="nobordernopadding" width="100%">';
79 79
 
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes2");
82
+        $tooltip.=$langs->trans("GenericMaskCodes3");
83
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
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="maskpropal" value="'.$conf->global->PROPALE_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="maskpropal" value="'.$conf->global->PROPALE_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,52 +104,52 @@  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 = '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 = 'NotConfigured';
120
+        }
121
+        return $numExample;
122 122
     }
123 123
 
124
-	/**
125
-	 *  Return next value
126
-	 *
127
-	 *  @param	Societe		$objsoc     Object third party
128
-	 * 	@param	Propal		$propal		Object commercial proposal
129
-	 *  @return string      			Value if OK, 0 if KO
130
-	 */
131
-	function getNextValue($objsoc,$propal)
132
-	{
133
-		global $db,$conf;
124
+    /**
125
+     *  Return next value
126
+     *
127
+     *  @param	Societe		$objsoc     Object third party
128
+     * 	@param	Propal		$propal		Object commercial proposal
129
+     *  @return string      			Value if OK, 0 if KO
130
+     */
131
+    function getNextValue($objsoc,$propal)
132
+    {
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
-		// On defini critere recherche compteur
138
-		$mask = $conf->global->PROPALE_SAPHIR_MASK;
137
+        // On defini critere recherche compteur
138
+        $mask = $conf->global->PROPALE_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
-		// Get entities
147
-		$entity = getEntity('proposalnumber', 1, $propal);
146
+        // Get entities
147
+        $entity = getEntity('proposalnumber', 1, $propal);
148 148
 
149
-		$date = $propal->date;
149
+        $date = $propal->date;
150 150
 
151
-		$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity);
151
+        $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity);
152 152
 
153
-		return  $numFinal;
154
-	}
153
+        return  $numFinal;
154
+    }
155 155
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * \brief      File that contains the numbering module rules Saphir
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.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 code (or 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 model 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="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
79
-
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
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="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
78
+		$texte .= '<table class="nobordernopadding" width="100%">';
79
+
80
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes2");
82
+		$tooltip .= $langs->trans("GenericMaskCodes3");
83
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
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="maskpropal" value="'.$conf->global->PROPALE_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="maskpropal" value="'.$conf->global->PROPALE_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 = 'NotConfigured';
120 120
 		}
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 	 * 	@param	Propal		$propal		Object commercial proposal
129 129
 	 *  @return string      			Value if OK, 0 if KO
130 130
 	 */
131
-	function getNextValue($objsoc,$propal)
131
+	function getNextValue($objsoc, $propal)
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
 		// On defini critere recherche compteur
138 138
 		$mask = $conf->global->PROPALE_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
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		$date = $propal->date;
150 150
 
151
-		$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity);
151
+		$numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
152 152
 
153 153
 		return  $numFinal;
154 154
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/propale/mod_propale_marbre.php 3 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_propale_marbre extends ModeleNumRefPropales
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='PR';
40
+    public $prefix='PR';
41 41
 
42
-	/**
43
-	 * @var string Error code (or message)
44
-	 */
45
-	public $error='';
42
+    /**
43
+     * @var string Error code (or message)
44
+     */
45
+    public $error='';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Marbre';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Marbre';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Marbre';
54
+    /**
55
+     * @var string model name
56
+     */
57
+    public $name='Marbre';
58 58
 
59 59
 
60 60
     /**
@@ -64,109 +64,109 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function info()
66 66
     {
67
-    	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+        global $langs;
68
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
69
+    }
70
+
71
+
72
+    /**
73
+     *  Return an example of numbering module values
74
+     *
75
+     *  @return     string      Example
76
+     */
77
+    function getExample()
78
+    {
79
+        return $this->prefix."0501-0001";
69 80
     }
70 81
 
71 82
 
72
-	/**
73
-	 *  Return an example of numbering module values
74
-	 *
75
-	 *  @return     string      Example
76
-	 */
77
-	function getExample()
78
-	{
79
-		return $this->prefix."0501-0001";
80
-	}
81
-
82
-
83
-	/**
84
-	 *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
85
-	 *  de conflits qui empechera cette numerotation de fonctionner.
86
-	 *
87
-	 *  @return     boolean     false si conflit, true si ok
88
-	 */
89
-	function canBeActivated()
90
-	{
91
-		global $conf,$langs,$db;
92
-
93
-		$pryymm=''; $max='';
94
-
95
-		$posindice=8;
96
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
-		$sql.= " FROM ".MAIN_DB_PREFIX."propal";
98
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
-		$sql.= " AND entity = ".$conf->entity;
100
-
101
-		$resql=$db->query($sql);
102
-		if ($resql)
103
-		{
104
-			$row = $db->fetch_row($resql);
105
-			if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
106
-		}
107
-
108
-		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109
-		{
110
-			return true;
111
-		}
112
-		else
113
-		{
114
-			$langs->load("errors");
115
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
116
-			return false;
117
-		}
118
-	}
119
-
120
-	/**
121
-	 *  Return next value
122
-	 *
123
-	 *  @param	Societe		$objsoc     Object third party
124
-	 * 	@param	Propal		$propal		Object commercial proposal
125
-	 *  @return string      			Next value
126
-	 */
127
-	function getNextValue($objsoc,$propal)
128
-	{
129
-		global $db,$conf;
130
-
131
-		// D'abord on recupere la valeur max
132
-		$posindice=8;
133
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
-		$sql.= " FROM ".MAIN_DB_PREFIX."propal";
135
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
-		$sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
137
-
138
-		$resql=$db->query($sql);
139
-		if ($resql)
140
-		{
141
-			$obj = $db->fetch_object($resql);
142
-			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
144
-		}
145
-		else
146
-		{
147
-			dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148
-			return -1;
149
-		}
150
-
151
-		$date = time();
152
-		$yymm = strftime("%y%m",$date);
153
-
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
156
-
157
-		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158
-		return $this->prefix.$yymm."-".$num;
159
-	}
160
-
161
-	/**
162
-	 *  Return next free value
163
-	 *
164
-	 *  @param	Societe		$objsoc      	Object third party
165
-	 * 	@param	Object		$objforref		Object for number to search
166
-	 *  @return string      				Next free value
167
-	 */
168
-	function getNumRef($objsoc,$objforref)
169
-	{
170
-		return $this->getNextValue($objsoc,$objforref);
171
-	}
83
+    /**
84
+     *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
85
+     *  de conflits qui empechera cette numerotation de fonctionner.
86
+     *
87
+     *  @return     boolean     false si conflit, true si ok
88
+     */
89
+    function canBeActivated()
90
+    {
91
+        global $conf,$langs,$db;
92
+
93
+        $pryymm=''; $max='';
94
+
95
+        $posindice=8;
96
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
+        $sql.= " FROM ".MAIN_DB_PREFIX."propal";
98
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+        $sql.= " AND entity = ".$conf->entity;
100
+
101
+        $resql=$db->query($sql);
102
+        if ($resql)
103
+        {
104
+            $row = $db->fetch_row($resql);
105
+            if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
106
+        }
107
+
108
+        if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109
+        {
110
+            return true;
111
+        }
112
+        else
113
+        {
114
+            $langs->load("errors");
115
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
116
+            return false;
117
+        }
118
+    }
119
+
120
+    /**
121
+     *  Return next value
122
+     *
123
+     *  @param	Societe		$objsoc     Object third party
124
+     * 	@param	Propal		$propal		Object commercial proposal
125
+     *  @return string      			Next value
126
+     */
127
+    function getNextValue($objsoc,$propal)
128
+    {
129
+        global $db,$conf;
130
+
131
+        // D'abord on recupere la valeur max
132
+        $posindice=8;
133
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
+        $sql.= " FROM ".MAIN_DB_PREFIX."propal";
135
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
+        $sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
137
+
138
+        $resql=$db->query($sql);
139
+        if ($resql)
140
+        {
141
+            $obj = $db->fetch_object($resql);
142
+            if ($obj) $max = intval($obj->max);
143
+            else $max=0;
144
+        }
145
+        else
146
+        {
147
+            dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148
+            return -1;
149
+        }
150
+
151
+        $date = time();
152
+        $yymm = strftime("%y%m",$date);
153
+
154
+        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
155
+        else $num = sprintf("%04s",$max+1);
156
+
157
+        dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158
+        return $this->prefix.$yymm."-".$num;
159
+    }
160
+
161
+    /**
162
+     *  Return next free value
163
+     *
164
+     *  @param	Societe		$objsoc      	Object third party
165
+     * 	@param	Object		$objforref		Object for number to search
166
+     *  @return string      				Next free value
167
+     */
168
+    function getNumRef($objsoc,$objforref)
169
+    {
170
+        return $this->getNextValue($objsoc,$objforref);
171
+    }
172 172
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\brief      File of class to manage commercial proposal numbering rules Marbre
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='PR';
40
+	public $prefix = 'PR';
41 41
 
42 42
 	/**
43 43
 	 * @var string Error code (or message)
44 44
 	 */
45
-	public $error='';
45
+	public $error = '';
46 46
 
47 47
 	/**
48 48
 	 * @var string Nom du modele
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Marbre';
52
+	public $nom = 'Marbre';
53 53
 
54 54
 	/**
55 55
 	 * @var string model name
56 56
 	 */
57
-	public $name='Marbre';
57
+	public $name = 'Marbre';
58 58
 
59 59
 
60 60
     /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     function info()
66 66
     {
67 67
     	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -88,31 +88,31 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	function canBeActivated()
90 90
 	{
91
-		global $conf,$langs,$db;
91
+		global $conf, $langs, $db;
92 92
 
93
-		$pryymm=''; $max='';
93
+		$pryymm = ''; $max = '';
94 94
 
95
-		$posindice=8;
95
+		$posindice = 8;
96 96
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
-		$sql.= " FROM ".MAIN_DB_PREFIX."propal";
98
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
-		$sql.= " AND entity = ".$conf->entity;
97
+		$sql .= " FROM ".MAIN_DB_PREFIX."propal";
98
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+		$sql .= " AND entity = ".$conf->entity;
100 100
 
101
-		$resql=$db->query($sql);
101
+		$resql = $db->query($sql);
102 102
 		if ($resql)
103 103
 		{
104 104
 			$row = $db->fetch_row($resql);
105
-			if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
105
+			if ($row) { $pryymm = substr($row[0], 0, 6); $max = $row[0]; }
106 106
 		}
107 107
 
108
-		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
108
+		if (!$pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $pryymm))
109 109
 		{
110 110
 			return true;
111 111
 		}
112 112
 		else
113 113
 		{
114 114
 			$langs->load("errors");
115
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
115
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
116 116
 			return false;
117 117
 		}
118 118
 	}
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
 	 * 	@param	Propal		$propal		Object commercial proposal
125 125
 	 *  @return string      			Next value
126 126
 	 */
127
-	function getNextValue($objsoc,$propal)
127
+	function getNextValue($objsoc, $propal)
128 128
 	{
129
-		global $db,$conf;
129
+		global $db, $conf;
130 130
 
131 131
 		// D'abord on recupere la valeur max
132
-		$posindice=8;
133
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
-		$sql.= " FROM ".MAIN_DB_PREFIX."propal";
135
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
-		$sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
132
+		$posindice = 8;
133
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
134
+		$sql .= " FROM ".MAIN_DB_PREFIX."propal";
135
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
+		$sql .= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
137 137
 
138
-		$resql=$db->query($sql);
138
+		$resql = $db->query($sql);
139 139
 		if ($resql)
140 140
 		{
141 141
 			$obj = $db->fetch_object($resql);
142 142
 			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
143
+			else $max = 0;
144 144
 		}
145 145
 		else
146 146
 		{
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 
151 151
 		$date = time();
152
-		$yymm = strftime("%y%m",$date);
152
+		$yymm = strftime("%y%m", $date);
153 153
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
154
+		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
155
+		else $num = sprintf("%04s", $max + 1);
156 156
 
157 157
 		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158 158
 		return $this->prefix.$yymm."-".$num;
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 * 	@param	Object		$objforref		Object for number to search
166 166
 	 *  @return string      				Next free value
167 167
 	 */
168
-	function getNumRef($objsoc,$objforref)
168
+	function getNumRef($objsoc, $objforref)
169 169
 	{
170
-		return $this->getNextValue($objsoc,$objforref);
170
+		return $this->getNextValue($objsoc, $objforref);
171 171
 	}
172 172
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109 109
 		{
110 110
 			return true;
111
-		}
112
-		else
111
+		} else
113 112
 		{
114 113
 			$langs->load("errors");
115 114
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -139,10 +138,12 @@  discard block
 block discarded – undo
139 138
 		if ($resql)
140 139
 		{
141 140
 			$obj = $db->fetch_object($resql);
142
-			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
144
-		}
145
-		else
141
+			if ($obj) {
142
+			    $max = intval($obj->max);
143
+			} else {
144
+			    $max=0;
145
+			}
146
+		} else
146 147
 		{
147 148
 			dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148 149
 			return -1;
@@ -151,8 +152,13 @@  discard block
 block discarded – undo
151 152
 		$date = time();
152 153
 		$yymm = strftime("%y%m",$date);
153 154
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
155
+		if ($max >= (pow(10, 4) - 1)) {
156
+		    $num=$max+1;
157
+		}
158
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
159
+		else {
160
+		    $num = sprintf("%04s",$max+1);
161
+		}
156 162
 
157 163
 		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158 164
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modGeoIPMaxmind.class.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -32,57 +32,57 @@
 block discarded – undo
32 32
 class modGeoIPMaxmind extends DolibarrModules
33 33
 {
34 34
 
35
-	/**
36
-	 *   Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 *   @param      DoliDB		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-		$this->db = $db;
43
-		$this->numero = 2900;
35
+    /**
36
+     *   Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     *   @param      DoliDB		$db      Database handler
39
+     */
40
+    function __construct($db)
41
+    {
42
+        $this->db = $db;
43
+        $this->numero = 2900;
44 44
 
45
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
-		// It is used to group modules in module setup page
47
-		$this->family = "interface";
48
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->description = "GeoIP Maxmind conversions capabilities";
52
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
-		$this->version = 'dolibarr';
54
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
55
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
-		// Name of image file used for this module.
57
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
58
-		// If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
59
-		$this->picto = 'globe';
45
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
+        // It is used to group modules in module setup page
47
+        $this->family = "interface";
48
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51
+        $this->description = "GeoIP Maxmind conversions capabilities";
52
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
+        $this->version = 'dolibarr';
54
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
55
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
+        // Name of image file used for this module.
57
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
58
+        // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
59
+        $this->picto = 'globe';
60 60
 
61
-		// Data directories to create when module is enabled
62
-		$this->dirs = array("/geoipmaxmind");
61
+        // Data directories to create when module is enabled
62
+        $this->dirs = array("/geoipmaxmind");
63 63
 
64
-		// Config pages
65
-		$this->config_page_url = array("geoipmaxmind.php");
64
+        // Config pages
65
+        $this->config_page_url = array("geoipmaxmind.php");
66 66
 
67
-		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);
73
-		$this->phpmax = array();
74
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
75
-		$this->need_javascript_ajax = 1;
67
+        // Dependencies
68
+        $this->hidden = false;			// A condition to hide module
69
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
70
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
71
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
+        $this->phpmin = array(5,4);
73
+        $this->phpmax = array();
74
+        $this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
75
+        $this->need_javascript_ajax = 1;
76 76
 
77
-		// Constants
78
-		$this->const = array();
77
+        // Constants
78
+        $this->const = array();
79 79
 
80
-		// Boxes
81
-		$this->boxes = array();
80
+        // Boxes
81
+        $this->boxes = array();
82 82
 
83
-		// Permissions
84
-		$this->rights = array();
85
-		$this->rights_class = 'geoipmaxmind';
86
-		$r=0;
87
-	}
83
+        // Permissions
84
+        $this->rights = array();
85
+        $this->rights_class = 'geoipmaxmind';
86
+        $r=0;
87
+    }
88 88
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\brief      File of geoipmaxmind module descriptor
24 24
  */
25 25
 
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 
29 29
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		// It is used to group modules in module setup page
47 47
 		$this->family = "interface";
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51 51
 		$this->description = "GeoIP Maxmind conversions capabilities";
52 52
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 		$this->config_page_url = array("geoipmaxmind.php");
66 66
 
67 67
 		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);
68
+		$this->hidden = false; // A condition to hide module
69
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
70
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
71
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
72
+		$this->phpmin = array(5, 4);
73 73
 		$this->phpmax = array();
74
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
74
+		$this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module
75 75
 		$this->need_javascript_ajax = 1;
76 76
 
77 77
 		// Constants
@@ -83,6 +83,6 @@  discard block
 block discarded – undo
83 83
 		// Permissions
84 84
 		$this->rights = array();
85 85
 		$this->rights_class = 'geoipmaxmind';
86
-		$r=0;
86
+		$r = 0;
87 87
 	}
88 88
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/dons/modules_don.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 abstract class ModeleDon extends CommonDocGenerator
36 36
 {
37 37
     /**
38
-	 * @var string Error code (or message)
39
-	 */
40
-	public $error='';
38
+     * @var string Error code (or message)
39
+     */
40
+    public $error='';
41 41
 
42 42
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
43 43
     /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 abstract class ModeleNumRefDons
70 70
 {
71 71
     /**
72
-	 * @var string Error code (or message)
73
-	 */
74
-	public $error='';
72
+     * @var string Error code (or message)
73
+     */
74
+    public $error='';
75 75
 
76 76
     /**
77 77
      * 	Return if a module can be used or not
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * @var string Error code (or message)
39 39
 	 */
40
-	public $error='';
40
+	public $error = '';
41 41
 
42 42
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
43 43
     /**
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
      *  @param  integer $maxfilenamelength  Max length of value to show
48 48
      *  @return	array						List of templates
49 49
      */
50
-    static function liste_modeles($db,$maxfilenamelength=0)
50
+    static function liste_modeles($db, $maxfilenamelength = 0)
51 51
     {
52 52
         // phpcs:enable
53 53
         global $conf;
54 54
 
55
-        $type='donation';
56
-        $liste=array();
55
+        $type = 'donation';
56
+        $liste = array();
57 57
 
58 58
         include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
59
-        $liste=getListOfModels($db,$type,$maxfilenamelength);
59
+        $liste = getListOfModels($db, $type, $maxfilenamelength);
60 60
 
61 61
         return $liste;
62 62
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     /**
72 72
 	 * @var string Error code (or message)
73 73
 	 */
74
-	public $error='';
74
+	public $error = '';
75 75
 
76 76
     /**
77 77
      * 	Return if a module can be used or not
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -139,10 +139,18 @@
 block discarded – undo
139 139
         global $langs;
140 140
         $langs->load("admin");
141 141
 
142
-        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
143
-        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
144
-        if ($this->version == 'dolibarr') return DOL_VERSION;
145
-        if ($this->version) return $this->version;
142
+        if ($this->version == 'development') {
143
+            return $langs->trans("VersionDevelopment");
144
+        }
145
+        if ($this->version == 'experimental') {
146
+            return $langs->trans("VersionExperimental");
147
+        }
148
+        if ($this->version == 'dolibarr') {
149
+            return DOL_VERSION;
150
+        }
151
+        if ($this->version) {
152
+            return $this->version;
153
+        }
146 154
         return $langs->trans("NotAvailable");
147 155
     }
148 156
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/dons/html_cerfafr.modules.php 3 patches
Indentation   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -35,119 +35,119 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class html_cerfafr extends ModeleDon
37 37
 {
38
-	/**
39
-	 *  Constructor
40
-	 *
41
-	 *  @param      DoliDb      $db      Database handler
42
-	 */
43
-	function __construct($db)
44
-	{
45
-		global $conf,$langs;
46
-
47
-		$this->db = $db;
48
-		$this->name = "cerfafr";
49
-		$this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03';
50
-
51
-		// Dimension page for size A4
52
-		$this->type = 'html';
53
-	}
54
-
55
-
56
-	/**
57
-	 * 	Return if a module can be used or not
58
-	 *
59
-	 *  @return	boolean     true if module can be used
60
-	 */
61
-	function isEnabled()
62
-	{
63
-		return true;
64
-	}
38
+    /**
39
+     *  Constructor
40
+     *
41
+     *  @param      DoliDb      $db      Database handler
42
+     */
43
+    function __construct($db)
44
+    {
45
+        global $conf,$langs;
46
+
47
+        $this->db = $db;
48
+        $this->name = "cerfafr";
49
+        $this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03';
50
+
51
+        // Dimension page for size A4
52
+        $this->type = 'html';
53
+    }
54
+
55
+
56
+    /**
57
+     * 	Return if a module can be used or not
58
+     *
59
+     *  @return	boolean     true if module can be used
60
+     */
61
+    function isEnabled()
62
+    {
63
+        return true;
64
+    }
65 65
 
66 66
 
67 67
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
68
-	/**
69
-	 *  Write the object to document file to disk
70
-	 *
71
-	 *	@param	Don			$don	        Donation object
72
-	 *  @param  Translate	$outputlangs    Lang object for output language
73
-	 *  @param	string		$currency		Currency code
74
-	 *	@return	int             			>0 if OK, <0 if KO
75
-	 */
76
-	function write_file($don,$outputlangs,$currency='')
77
-	{
68
+    /**
69
+     *  Write the object to document file to disk
70
+     *
71
+     *	@param	Don			$don	        Donation object
72
+     *  @param  Translate	$outputlangs    Lang object for output language
73
+     *  @param	string		$currency		Currency code
74
+     *	@return	int             			>0 if OK, <0 if KO
75
+     */
76
+    function write_file($don,$outputlangs,$currency='')
77
+    {
78 78
         // phpcs:enable
79
-		global $user,$conf,$langs,$mysoc;
80
-
81
-		$now=dol_now();
82
-		$id = (! is_object($don)?$don:'');
83
-
84
-		if (! is_object($outputlangs)) $outputlangs=$langs;
85
-
86
-		// Load traductions files requiredby by page
87
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations"));
88
-
89
-		$currency = !empty($currency) ? $currency : $conf->currency;
90
-
91
-		if (! empty($conf->don->dir_output))
92
-		{
93
-			// Definition of the object don (for upward compatibility)
94
-			if (! is_object($don))
95
-			{
96
-				$don = new Don($this->db);
97
-				$ret=$don->fetch($id);
98
-				$id=$don->id;
99
-			}
100
-
101
-			// Definition of $dir and $file
102
-			if (! empty($don->specimen))
103
-			{
104
-				$dir = $conf->don->dir_output;
105
-				$file = $dir . "/SPECIMEN.html";
106
-			}
107
-			else
108
-			{
109
-				$donref = dol_sanitizeFileName($don->ref);
110
-				$dir = $conf->don->dir_output . "/" . $donref;
111
-				$file = $dir . "/" . $donref . ".html";
112
-			}
113
-
114
-			if (! file_exists($dir))
115
-			{
116
-				if (dol_mkdir($dir) < 0)
117
-				{
118
-					$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
119
-					return -1;
120
-				}
121
-			}
122
-
123
-			if (file_exists($dir))
124
-			{
125
-				$formclass = new Form($this->db);
126
-
127
-				// This is not the proper way to do it but $formclass->form_modes_reglement
128
-				// prints the translation instead of returning it
129
-				if ($don->modepaiementid)
130
-				{
131
-					$formclass->load_cache_types_paiements();
132
-					$paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
133
-				}
134
-				else $paymentmode = '';
135
-
136
-				if ($don->modepaymentcode=='CHQ'){
137
-					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
138
-				}
139
-				else if ($don->modepaymentcode=='LIQ'){
140
-					$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
141
-				}
142
-				else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
143
-					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
144
-				}
145
-				else
146
-				{
147
-					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
148
-				}
149
-
150
-				/*
79
+        global $user,$conf,$langs,$mysoc;
80
+
81
+        $now=dol_now();
82
+        $id = (! is_object($don)?$don:'');
83
+
84
+        if (! is_object($outputlangs)) $outputlangs=$langs;
85
+
86
+        // Load traductions files requiredby by page
87
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations"));
88
+
89
+        $currency = !empty($currency) ? $currency : $conf->currency;
90
+
91
+        if (! empty($conf->don->dir_output))
92
+        {
93
+            // Definition of the object don (for upward compatibility)
94
+            if (! is_object($don))
95
+            {
96
+                $don = new Don($this->db);
97
+                $ret=$don->fetch($id);
98
+                $id=$don->id;
99
+            }
100
+
101
+            // Definition of $dir and $file
102
+            if (! empty($don->specimen))
103
+            {
104
+                $dir = $conf->don->dir_output;
105
+                $file = $dir . "/SPECIMEN.html";
106
+            }
107
+            else
108
+            {
109
+                $donref = dol_sanitizeFileName($don->ref);
110
+                $dir = $conf->don->dir_output . "/" . $donref;
111
+                $file = $dir . "/" . $donref . ".html";
112
+            }
113
+
114
+            if (! file_exists($dir))
115
+            {
116
+                if (dol_mkdir($dir) < 0)
117
+                {
118
+                    $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
119
+                    return -1;
120
+                }
121
+            }
122
+
123
+            if (file_exists($dir))
124
+            {
125
+                $formclass = new Form($this->db);
126
+
127
+                // This is not the proper way to do it but $formclass->form_modes_reglement
128
+                // prints the translation instead of returning it
129
+                if ($don->modepaiementid)
130
+                {
131
+                    $formclass->load_cache_types_paiements();
132
+                    $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
133
+                }
134
+                else $paymentmode = '';
135
+
136
+                if ($don->modepaymentcode=='CHQ'){
137
+                    $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
138
+                }
139
+                else if ($don->modepaymentcode=='LIQ'){
140
+                    $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
141
+                }
142
+                else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
143
+                    $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
144
+                }
145
+                else
146
+                {
147
+                    $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
148
+                }
149
+
150
+                /*
151 151
 				if (empty($don->societe))
152 152
 				{
153 153
 					$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" checked="checked" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>';
@@ -158,279 +158,279 @@  discard block
 block discarded – undo
158 158
 				}
159 159
 				*/
160 160
 
161
-				// Define contents
162
-				$donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
163
-				$form = implode('', file($donmodel));
164
-				$form = str_replace('__REF__',$don->id,$form);
165
-				$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
166
-				//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
167
-				$form = str_replace('__AMOUNT__', price($don->amount), $form);
168
-				$form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form);
169
-				$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
170
-				$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
171
-				$form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form);
172
-				$form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form);
173
-				$form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form);
174
-				$form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form);
175
-				$form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form);
176
-				$form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form);
177
-				$form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form);
178
-				$form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form);
179
-				$form = str_replace('__DONATOR_STATUT__',$don->statut,$form);
180
-				$form = str_replace('__DONATOR_ADDRESS__',$don->address,$form);
181
-				$form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
182
-				$form = str_replace('__DONATOR_TOWN__',$don->town,$form);
183
-				$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
184
-				$form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
185
-				$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
186
-				$form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form);
187
-				$form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
188
-				$form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
189
-				$form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form);
190
-				$form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form);
191
-				// $form = str_replace('__CodeDon__',$CodeDon,$form);
192
-				$form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
193
-				$form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
194
-				$form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
195
-				$form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
196
-				$form = str_replace('__Object__',$outputlangs->trans("Object"),$form);
197
-				$form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
198
-				$form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
199
-				$form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
200
-				$form = str_replace('__Message__',$outputlangs->trans("Message"),$form);
201
-				$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
202
-				$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
203
-
204
-				$form = str_replace('__ModePaiement__', $ModePaiement,$form);
205
-
206
-				$frencharticle='';
207
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
208
-				$form = str_replace('__FrenchArticle__',$frencharticle,$form);
209
-
210
-				$frencheligibility='';
211
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
212
-				$form = str_replace('__FrenchEligibility__',$frencheligibility,$form);
213
-
214
-				$art200='';
215
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
216
-					if ($conf->global->DONATION_ART200 >= 1)
217
-					{
218
-						$art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
219
-					}
220
-					else
221
-					{
222
-						$art200='<input type="checkbox" disabled="true">200 du CGI';
223
-					}
224
-				}
225
-				$form = str_replace('__ARTICLE200__',$art200,$form);
226
-
227
-				$art238='';
228
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
229
-					if ($conf->global->DONATION_ART238 >= 1)
230
-					{
231
-						$art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
232
-					}
233
-					else
234
-					{
235
-						$art238='<input type="checkbox" disabled="true">238 bis du CGI';
236
-					}
237
-				}
238
-				$form = str_replace('__ARTICLE238__',$art238,$form);
239
-
240
-				$art885='';
241
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
242
-					if ($conf->global->DONATION_ART885 >= 1)
243
-					{
244
-						$art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI';
245
-					}
246
-					else
247
-					{
248
-						$art885='<input type="checkbox" disabled="true">885-0 V bis du CGI';
249
-					}
250
-				}
251
-				$form = str_replace('__ARTICLE885__',$art885,$form);
252
-
253
-				// Save file on disk
254
-				dol_syslog("html_cerfafr::write_file $file");
255
-				$handle=fopen($file,"w");
256
-				fwrite($handle,$form);
257
-				fclose($handle);
258
-				if (! empty($conf->global->MAIN_UMASK))
259
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
260
-
261
-				$this->result = array('fullpath'=>$file);
262
-
263
-				return 1;
264
-			}
265
-			else
266
-			{
267
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
268
-				return 0;
269
-			}
270
-		}
271
-		else
272
-		{
273
-			$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
274
-			return 0;
275
-		}
276
-	}
277
-
278
-	/**
279
-	 * numbers to letters
280
-	 *
281
-	 * @param   mixed   $montant    amount
282
-	 * @param   mixed   $devise1    devise 1 ex: euro
283
-	 * @param   mixed   $devise2    devise 2 ex: centimes
284
-	 * @return string               amount in letters
285
-	 */
286
-	private function amountToLetters($montant, $devise1='', $devise2='')
287
-	{
288
-		$unite = array();
289
-		$dix = array();
290
-		$cent = array();
291
-		if(empty($devise1)) $dev1='euros';
292
-		else $dev1=$devise1;
293
-		if(empty($devise2)) $dev2='centimes';
294
-		else $dev2=$devise2;
295
-		$valeur_entiere=intval($montant);
296
-		$valeur_decimal=intval(round($montant-intval($montant), 2)*100);
297
-		$dix_c=intval($valeur_decimal%100/10);
298
-		$cent_c=intval($valeur_decimal%1000/100);
299
-		$unite[1]=$valeur_entiere%10;
300
-		$dix[1]=intval($valeur_entiere%100/10);
301
-		$cent[1]=intval($valeur_entiere%1000/100);
302
-		$unite[2]=intval($valeur_entiere%10000/1000);
303
-		$dix[2]=intval($valeur_entiere%100000/10000);
304
-		$cent[2]=intval($valeur_entiere%1000000/100000);
305
-		$unite[3]=intval($valeur_entiere%10000000/1000000);
306
-		$dix[3]=intval($valeur_entiere%100000000/10000000);
307
-		$cent[3]=intval($valeur_entiere%1000000000/100000000);
308
-		$chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
309
-			$secon_c='';
310
-			$trio_c='';
311
-		for($i=1; $i<=3; $i++){
312
-			$prim[$i]='';
313
-			$secon[$i]='';
314
-			$trio[$i]='';
315
-			if($dix[$i]==0){
316
-				$secon[$i]='';
317
-				$prim[$i]=$chif[$unite[$i]];
318
-			}
319
-			else if($dix[$i]==1){
320
-				$secon[$i]='';
321
-				$prim[$i]=$chif[($unite[$i]+10)];
322
-			}
323
-			else if($dix[$i]==2){
324
-				if($unite[$i]==1){
325
-				$secon[$i]='vingt et';
326
-				$prim[$i]=$chif[$unite[$i]];
327
-				}
328
-				else {
329
-				$secon[$i]='vingt';
330
-				$prim[$i]=$chif[$unite[$i]];
331
-				}
332
-			}
333
-			else if($dix[$i]==3){
334
-				if($unite[$i]==1){
335
-				$secon[$i]='trente et';
336
-				$prim[$i]=$chif[$unite[$i]];
337
-				}
338
-				else {
339
-				$secon[$i]='trente';
340
-				$prim[$i]=$chif[$unite[$i]];
341
-				}
342
-			}
343
-			else if($dix[$i]==4){
344
-				if($unite[$i]==1){
345
-				$secon[$i]='quarante et';
346
-				$prim[$i]=$chif[$unite[$i]];
347
-				}
348
-				else {
349
-				$secon[$i]='quarante';
350
-				$prim[$i]=$chif[$unite[$i]];
351
-				}
352
-			}
353
-			else if($dix[$i]==5){
354
-				if($unite[$i]==1){
355
-				$secon[$i]='cinquante et';
356
-				$prim[$i]=$chif[$unite[$i]];
357
-				}
358
-				else {
359
-				$secon[$i]='cinquante';
360
-				$prim[$i]=$chif[$unite[$i]];
361
-				}
362
-			}
363
-			else if($dix[$i]==6){
364
-				if($unite[$i]==1){
365
-				$secon[$i]='soixante et';
366
-				$prim[$i]=$chif[$unite[$i]];
367
-				}
368
-				else {
369
-				$secon[$i]='soixante';
370
-				$prim[$i]=$chif[$unite[$i]];
371
-				}
372
-			}
373
-			else if($dix[$i]==7){
374
-				if($unite[$i]==1){
375
-				$secon[$i]='soixante et';
376
-				$prim[$i]=$chif[$unite[$i]+10];
377
-				}
378
-				else {
379
-				$secon[$i]='soixante';
380
-				$prim[$i]=$chif[$unite[$i]+10];
381
-				}
382
-			}
383
-			else if($dix[$i]==8){
384
-				if($unite[$i]==1){
385
-				$secon[$i]='quatre-vingts et';
386
-				$prim[$i]=$chif[$unite[$i]];
387
-				}
388
-				else {
389
-				$secon[$i]='quatre-vingt';
390
-				$prim[$i]=$chif[$unite[$i]];
391
-				}
392
-			}
393
-			else if($dix[$i]==9){
394
-				if($unite[$i]==1){
395
-				$secon[$i]='quatre-vingts et';
396
-				$prim[$i]=$chif[$unite[$i]+10];
397
-				}
398
-				else {
399
-				$secon[$i]='quatre-vingts';
400
-				$prim[$i]=$chif[$unite[$i]+10];
401
-				}
402
-			}
403
-			if($cent[$i]==1) $trio[$i]='cent';
404
-			else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
405
-		}
406
-
407
-
408
-		$chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
409
-		$secon_c=$chif2[$dix_c];
410
-		if($cent_c==1) $trio_c='cent';
411
-		else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
412
-
413
-		if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
414
-			$somme = $trio[3]. '  ' .$secon[3]. ' ' . $prim[3]. ' million ';
415
-		else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
416
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
417
-		else
418
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
419
-
420
-		if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
421
-			$somme = $somme.' mille ';
422
-		else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
423
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
424
-		else
425
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
426
-
427
-		$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
428
-
429
-		$somme = $somme. ' '. $dev1 .' ' ;
430
-
431
-		if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
432
-			return $somme. ' et z&eacute;ro '. $dev2;
433
-		else
434
-			return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
435
-	}
161
+                // Define contents
162
+                $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
163
+                $form = implode('', file($donmodel));
164
+                $form = str_replace('__REF__',$don->id,$form);
165
+                $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
166
+                //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
167
+                $form = str_replace('__AMOUNT__', price($don->amount), $form);
168
+                $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form);
169
+                $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
170
+                $form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
171
+                $form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form);
172
+                $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form);
173
+                $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form);
174
+                $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form);
175
+                $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form);
176
+                $form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form);
177
+                $form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form);
178
+                $form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form);
179
+                $form = str_replace('__DONATOR_STATUT__',$don->statut,$form);
180
+                $form = str_replace('__DONATOR_ADDRESS__',$don->address,$form);
181
+                $form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
182
+                $form = str_replace('__DONATOR_TOWN__',$don->town,$form);
183
+                $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
184
+                $form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
185
+                $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
186
+                $form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form);
187
+                $form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
188
+                $form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
189
+                $form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form);
190
+                $form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form);
191
+                // $form = str_replace('__CodeDon__',$CodeDon,$form);
192
+                $form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
193
+                $form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
194
+                $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
195
+                $form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
196
+                $form = str_replace('__Object__',$outputlangs->trans("Object"),$form);
197
+                $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
198
+                $form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
199
+                $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
200
+                $form = str_replace('__Message__',$outputlangs->trans("Message"),$form);
201
+                $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
202
+                $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
203
+
204
+                $form = str_replace('__ModePaiement__', $ModePaiement,$form);
205
+
206
+                $frencharticle='';
207
+                if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
208
+                $form = str_replace('__FrenchArticle__',$frencharticle,$form);
209
+
210
+                $frencheligibility='';
211
+                if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
212
+                $form = str_replace('__FrenchEligibility__',$frencheligibility,$form);
213
+
214
+                $art200='';
215
+                if (preg_match('/fr/i',$outputlangs->defaultlang)) {
216
+                    if ($conf->global->DONATION_ART200 >= 1)
217
+                    {
218
+                        $art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
219
+                    }
220
+                    else
221
+                    {
222
+                        $art200='<input type="checkbox" disabled="true">200 du CGI';
223
+                    }
224
+                }
225
+                $form = str_replace('__ARTICLE200__',$art200,$form);
226
+
227
+                $art238='';
228
+                if (preg_match('/fr/i',$outputlangs->defaultlang)) {
229
+                    if ($conf->global->DONATION_ART238 >= 1)
230
+                    {
231
+                        $art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
232
+                    }
233
+                    else
234
+                    {
235
+                        $art238='<input type="checkbox" disabled="true">238 bis du CGI';
236
+                    }
237
+                }
238
+                $form = str_replace('__ARTICLE238__',$art238,$form);
239
+
240
+                $art885='';
241
+                if (preg_match('/fr/i',$outputlangs->defaultlang)) {
242
+                    if ($conf->global->DONATION_ART885 >= 1)
243
+                    {
244
+                        $art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI';
245
+                    }
246
+                    else
247
+                    {
248
+                        $art885='<input type="checkbox" disabled="true">885-0 V bis du CGI';
249
+                    }
250
+                }
251
+                $form = str_replace('__ARTICLE885__',$art885,$form);
252
+
253
+                // Save file on disk
254
+                dol_syslog("html_cerfafr::write_file $file");
255
+                $handle=fopen($file,"w");
256
+                fwrite($handle,$form);
257
+                fclose($handle);
258
+                if (! empty($conf->global->MAIN_UMASK))
259
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
260
+
261
+                $this->result = array('fullpath'=>$file);
262
+
263
+                return 1;
264
+            }
265
+            else
266
+            {
267
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
268
+                return 0;
269
+            }
270
+        }
271
+        else
272
+        {
273
+            $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
274
+            return 0;
275
+        }
276
+    }
277
+
278
+    /**
279
+     * numbers to letters
280
+     *
281
+     * @param   mixed   $montant    amount
282
+     * @param   mixed   $devise1    devise 1 ex: euro
283
+     * @param   mixed   $devise2    devise 2 ex: centimes
284
+     * @return string               amount in letters
285
+     */
286
+    private function amountToLetters($montant, $devise1='', $devise2='')
287
+    {
288
+        $unite = array();
289
+        $dix = array();
290
+        $cent = array();
291
+        if(empty($devise1)) $dev1='euros';
292
+        else $dev1=$devise1;
293
+        if(empty($devise2)) $dev2='centimes';
294
+        else $dev2=$devise2;
295
+        $valeur_entiere=intval($montant);
296
+        $valeur_decimal=intval(round($montant-intval($montant), 2)*100);
297
+        $dix_c=intval($valeur_decimal%100/10);
298
+        $cent_c=intval($valeur_decimal%1000/100);
299
+        $unite[1]=$valeur_entiere%10;
300
+        $dix[1]=intval($valeur_entiere%100/10);
301
+        $cent[1]=intval($valeur_entiere%1000/100);
302
+        $unite[2]=intval($valeur_entiere%10000/1000);
303
+        $dix[2]=intval($valeur_entiere%100000/10000);
304
+        $cent[2]=intval($valeur_entiere%1000000/100000);
305
+        $unite[3]=intval($valeur_entiere%10000000/1000000);
306
+        $dix[3]=intval($valeur_entiere%100000000/10000000);
307
+        $cent[3]=intval($valeur_entiere%1000000000/100000000);
308
+        $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
309
+            $secon_c='';
310
+            $trio_c='';
311
+        for($i=1; $i<=3; $i++){
312
+            $prim[$i]='';
313
+            $secon[$i]='';
314
+            $trio[$i]='';
315
+            if($dix[$i]==0){
316
+                $secon[$i]='';
317
+                $prim[$i]=$chif[$unite[$i]];
318
+            }
319
+            else if($dix[$i]==1){
320
+                $secon[$i]='';
321
+                $prim[$i]=$chif[($unite[$i]+10)];
322
+            }
323
+            else if($dix[$i]==2){
324
+                if($unite[$i]==1){
325
+                $secon[$i]='vingt et';
326
+                $prim[$i]=$chif[$unite[$i]];
327
+                }
328
+                else {
329
+                $secon[$i]='vingt';
330
+                $prim[$i]=$chif[$unite[$i]];
331
+                }
332
+            }
333
+            else if($dix[$i]==3){
334
+                if($unite[$i]==1){
335
+                $secon[$i]='trente et';
336
+                $prim[$i]=$chif[$unite[$i]];
337
+                }
338
+                else {
339
+                $secon[$i]='trente';
340
+                $prim[$i]=$chif[$unite[$i]];
341
+                }
342
+            }
343
+            else if($dix[$i]==4){
344
+                if($unite[$i]==1){
345
+                $secon[$i]='quarante et';
346
+                $prim[$i]=$chif[$unite[$i]];
347
+                }
348
+                else {
349
+                $secon[$i]='quarante';
350
+                $prim[$i]=$chif[$unite[$i]];
351
+                }
352
+            }
353
+            else if($dix[$i]==5){
354
+                if($unite[$i]==1){
355
+                $secon[$i]='cinquante et';
356
+                $prim[$i]=$chif[$unite[$i]];
357
+                }
358
+                else {
359
+                $secon[$i]='cinquante';
360
+                $prim[$i]=$chif[$unite[$i]];
361
+                }
362
+            }
363
+            else if($dix[$i]==6){
364
+                if($unite[$i]==1){
365
+                $secon[$i]='soixante et';
366
+                $prim[$i]=$chif[$unite[$i]];
367
+                }
368
+                else {
369
+                $secon[$i]='soixante';
370
+                $prim[$i]=$chif[$unite[$i]];
371
+                }
372
+            }
373
+            else if($dix[$i]==7){
374
+                if($unite[$i]==1){
375
+                $secon[$i]='soixante et';
376
+                $prim[$i]=$chif[$unite[$i]+10];
377
+                }
378
+                else {
379
+                $secon[$i]='soixante';
380
+                $prim[$i]=$chif[$unite[$i]+10];
381
+                }
382
+            }
383
+            else if($dix[$i]==8){
384
+                if($unite[$i]==1){
385
+                $secon[$i]='quatre-vingts et';
386
+                $prim[$i]=$chif[$unite[$i]];
387
+                }
388
+                else {
389
+                $secon[$i]='quatre-vingt';
390
+                $prim[$i]=$chif[$unite[$i]];
391
+                }
392
+            }
393
+            else if($dix[$i]==9){
394
+                if($unite[$i]==1){
395
+                $secon[$i]='quatre-vingts et';
396
+                $prim[$i]=$chif[$unite[$i]+10];
397
+                }
398
+                else {
399
+                $secon[$i]='quatre-vingts';
400
+                $prim[$i]=$chif[$unite[$i]+10];
401
+                }
402
+            }
403
+            if($cent[$i]==1) $trio[$i]='cent';
404
+            else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
405
+        }
406
+
407
+
408
+        $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
409
+        $secon_c=$chif2[$dix_c];
410
+        if($cent_c==1) $trio_c='cent';
411
+        else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
412
+
413
+        if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
414
+            $somme = $trio[3]. '  ' .$secon[3]. ' ' . $prim[3]. ' million ';
415
+        else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
416
+            $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
417
+        else
418
+            $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
419
+
420
+        if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
421
+            $somme = $somme.' mille ';
422
+        else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
423
+            $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
424
+        else
425
+            $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
426
+
427
+        $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
428
+
429
+        $somme = $somme. ' '. $dev1 .' ' ;
430
+
431
+        if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
432
+            return $somme. ' et z&eacute;ro '. $dev2;
433
+        else
434
+            return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
435
+    }
436 436
 }
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	function __construct($db)
44 44
 	{
45
-		global $conf,$langs;
45
+		global $conf, $langs;
46 46
 
47 47
 		$this->db = $db;
48 48
 		$this->name = "cerfafr";
@@ -73,49 +73,49 @@  discard block
 block discarded – undo
73 73
 	 *  @param	string		$currency		Currency code
74 74
 	 *	@return	int             			>0 if OK, <0 if KO
75 75
 	 */
76
-	function write_file($don,$outputlangs,$currency='')
76
+	function write_file($don, $outputlangs, $currency = '')
77 77
 	{
78 78
         // phpcs:enable
79
-		global $user,$conf,$langs,$mysoc;
79
+		global $user, $conf, $langs, $mysoc;
80 80
 
81
-		$now=dol_now();
82
-		$id = (! is_object($don)?$don:'');
81
+		$now = dol_now();
82
+		$id = (!is_object($don) ? $don : '');
83 83
 
84
-		if (! is_object($outputlangs)) $outputlangs=$langs;
84
+		if (!is_object($outputlangs)) $outputlangs = $langs;
85 85
 
86 86
 		// Load traductions files requiredby by page
87 87
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations"));
88 88
 
89 89
 		$currency = !empty($currency) ? $currency : $conf->currency;
90 90
 
91
-		if (! empty($conf->don->dir_output))
91
+		if (!empty($conf->don->dir_output))
92 92
 		{
93 93
 			// Definition of the object don (for upward compatibility)
94
-			if (! is_object($don))
94
+			if (!is_object($don))
95 95
 			{
96 96
 				$don = new Don($this->db);
97
-				$ret=$don->fetch($id);
98
-				$id=$don->id;
97
+				$ret = $don->fetch($id);
98
+				$id = $don->id;
99 99
 			}
100 100
 
101 101
 			// Definition of $dir and $file
102
-			if (! empty($don->specimen))
102
+			if (!empty($don->specimen))
103 103
 			{
104 104
 				$dir = $conf->don->dir_output;
105
-				$file = $dir . "/SPECIMEN.html";
105
+				$file = $dir."/SPECIMEN.html";
106 106
 			}
107 107
 			else
108 108
 			{
109 109
 				$donref = dol_sanitizeFileName($don->ref);
110
-				$dir = $conf->don->dir_output . "/" . $donref;
111
-				$file = $dir . "/" . $donref . ".html";
110
+				$dir = $conf->don->dir_output."/".$donref;
111
+				$file = $dir."/".$donref.".html";
112 112
 			}
113 113
 
114
-			if (! file_exists($dir))
114
+			if (!file_exists($dir))
115 115
 			{
116 116
 				if (dol_mkdir($dir) < 0)
117 117
 				{
118
-					$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
118
+					$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
119 119
 					return -1;
120 120
 				}
121 121
 			}
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 				}
134 134
 				else $paymentmode = '';
135 135
 
136
-				if ($don->modepaymentcode=='CHQ'){
136
+				if ($don->modepaymentcode == 'CHQ') {
137 137
 					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
138 138
 				}
139
-				else if ($don->modepaymentcode=='LIQ'){
139
+				else if ($don->modepaymentcode == 'LIQ') {
140 140
 					$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
141 141
 				}
142
-				else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
142
+				else if ($don->modepaymentcode == 'VIR' || $don->modepaymentcode == 'PRE' || $don->modepaymentcode == 'CB') {
143 143
 					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
144 144
 				}
145 145
 				else
@@ -159,103 +159,103 @@  discard block
 block discarded – undo
159 159
 				*/
160 160
 
161 161
 				// Define contents
162
-				$donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
162
+				$donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_cerfafr.html";
163 163
 				$form = implode('', file($donmodel));
164
-				$form = str_replace('__REF__',$don->id,$form);
165
-				$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
164
+				$form = str_replace('__REF__', $don->id, $form);
165
+				$form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form);
166 166
 				//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
167 167
 				$form = str_replace('__AMOUNT__', price($don->amount), $form);
168
-				$form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form);
169
-				$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
170
-				$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
171
-				$form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form);
172
-				$form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form);
173
-				$form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form);
174
-				$form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form);
175
-				$form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form);
176
-				$form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form);
177
-				$form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form);
178
-				$form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form);
179
-				$form = str_replace('__DONATOR_STATUT__',$don->statut,$form);
180
-				$form = str_replace('__DONATOR_ADDRESS__',$don->address,$form);
181
-				$form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
182
-				$form = str_replace('__DONATOR_TOWN__',$don->town,$form);
183
-				$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
184
-				$form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
185
-				$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
186
-				$form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form);
187
-				$form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
188
-				$form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
189
-				$form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form);
190
-				$form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form);
168
+				$form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount), $form);
169
+				$form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency".$currency), $form);
170
+				$form = str_replace('__CURRENCYCODE__', $conf->currency, $form);
171
+				$form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form);
172
+				$form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form);
173
+				$form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form);
174
+				$form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form);
175
+				$form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__', $mysoc->object, $form);
176
+				$form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form);
177
+				$form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form);
178
+				$form = str_replace('__DONATOR_SOCIETE__', $don->societe, $form);
179
+				$form = str_replace('__DONATOR_STATUT__', $don->statut, $form);
180
+				$form = str_replace('__DONATOR_ADDRESS__', $don->address, $form);
181
+				$form = str_replace('__DONATOR_ZIP__', $don->zip, $form);
182
+				$form = str_replace('__DONATOR_TOWN__', $don->town, $form);
183
+				$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form);
184
+				$form = str_replace('__NOW__', dol_print_date($now, 'day', false, $outputlangs), $form);
185
+				$form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form);
186
+				$form = str_replace('__DonationTitle__', $outputlangs->trans("DonationTitle"), $form);
187
+				$form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form);
188
+				$form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form);
189
+				$form = str_replace('__DonationDatePayment__', $outputlangs->trans("DonationDatePayment"), $form);
190
+				$form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form);
191 191
 				// $form = str_replace('__CodeDon__',$CodeDon,$form);
192
-				$form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
193
-				$form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
194
-				$form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
195
-				$form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
196
-				$form = str_replace('__Object__',$outputlangs->trans("Object"),$form);
197
-				$form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
198
-				$form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
199
-				$form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
200
-				$form = str_replace('__Message__',$outputlangs->trans("Message"),$form);
201
-				$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
202
-				$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
203
-
204
-				$form = str_replace('__ModePaiement__', $ModePaiement,$form);
205
-
206
-				$frencharticle='';
207
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
208
-				$form = str_replace('__FrenchArticle__',$frencharticle,$form);
209
-
210
-				$frencheligibility='';
211
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
212
-				$form = str_replace('__FrenchEligibility__',$frencheligibility,$form);
213
-
214
-				$art200='';
215
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
192
+				$form = str_replace('__Name__', $outputlangs->trans("Name"), $form);
193
+				$form = str_replace('__Address__', $outputlangs->trans("Address"), $form);
194
+				$form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form);
195
+				$form = str_replace('__Town__', $outputlangs->trans("Town"), $form);
196
+				$form = str_replace('__Object__', $outputlangs->trans("Object"), $form);
197
+				$form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form);
198
+				$form = str_replace('__Date__', $outputlangs->trans("Date"), $form);
199
+				$form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form);
200
+				$form = str_replace('__Message__', $outputlangs->trans("Message"), $form);
201
+				$form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form);
202
+				$form = str_replace('__DonationMessage__', $conf->global->DONATION_MESSAGE, $form);
203
+
204
+				$form = str_replace('__ModePaiement__', $ModePaiement, $form);
205
+
206
+				$frencharticle = '';
207
+				if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle = '<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
208
+				$form = str_replace('__FrenchArticle__', $frencharticle, $form);
209
+
210
+				$frencheligibility = '';
211
+				if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
212
+				$form = str_replace('__FrenchEligibility__', $frencheligibility, $form);
213
+
214
+				$art200 = '';
215
+				if (preg_match('/fr/i', $outputlangs->defaultlang)) {
216 216
 					if ($conf->global->DONATION_ART200 >= 1)
217 217
 					{
218
-						$art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
218
+						$art200 = '<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
219 219
 					}
220 220
 					else
221 221
 					{
222
-						$art200='<input type="checkbox" disabled="true">200 du CGI';
222
+						$art200 = '<input type="checkbox" disabled="true">200 du CGI';
223 223
 					}
224 224
 				}
225
-				$form = str_replace('__ARTICLE200__',$art200,$form);
225
+				$form = str_replace('__ARTICLE200__', $art200, $form);
226 226
 
227
-				$art238='';
228
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
227
+				$art238 = '';
228
+				if (preg_match('/fr/i', $outputlangs->defaultlang)) {
229 229
 					if ($conf->global->DONATION_ART238 >= 1)
230 230
 					{
231
-						$art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
231
+						$art238 = '<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
232 232
 					}
233 233
 					else
234 234
 					{
235
-						$art238='<input type="checkbox" disabled="true">238 bis du CGI';
235
+						$art238 = '<input type="checkbox" disabled="true">238 bis du CGI';
236 236
 					}
237 237
 				}
238
-				$form = str_replace('__ARTICLE238__',$art238,$form);
238
+				$form = str_replace('__ARTICLE238__', $art238, $form);
239 239
 
240
-				$art885='';
241
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
240
+				$art885 = '';
241
+				if (preg_match('/fr/i', $outputlangs->defaultlang)) {
242 242
 					if ($conf->global->DONATION_ART885 >= 1)
243 243
 					{
244
-						$art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI';
244
+						$art885 = '<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI';
245 245
 					}
246 246
 					else
247 247
 					{
248
-						$art885='<input type="checkbox" disabled="true">885-0 V bis du CGI';
248
+						$art885 = '<input type="checkbox" disabled="true">885-0 V bis du CGI';
249 249
 					}
250 250
 				}
251
-				$form = str_replace('__ARTICLE885__',$art885,$form);
251
+				$form = str_replace('__ARTICLE885__', $art885, $form);
252 252
 
253 253
 				// Save file on disk
254 254
 				dol_syslog("html_cerfafr::write_file $file");
255
-				$handle=fopen($file,"w");
256
-				fwrite($handle,$form);
255
+				$handle = fopen($file, "w");
256
+				fwrite($handle, $form);
257 257
 				fclose($handle);
258
-				if (! empty($conf->global->MAIN_UMASK))
258
+				if (!empty($conf->global->MAIN_UMASK))
259 259
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
260 260
 
261 261
 				$this->result = array('fullpath'=>$file);
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
 			}
265 265
 			else
266 266
 			{
267
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
267
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
268 268
 				return 0;
269 269
 			}
270 270
 		}
271 271
 		else
272 272
 		{
273
-			$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
273
+			$this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR");
274 274
 			return 0;
275 275
 		}
276 276
 	}
@@ -283,154 +283,154 @@  discard block
 block discarded – undo
283 283
 	 * @param   mixed   $devise2    devise 2 ex: centimes
284 284
 	 * @return string               amount in letters
285 285
 	 */
286
-	private function amountToLetters($montant, $devise1='', $devise2='')
286
+	private function amountToLetters($montant, $devise1 = '', $devise2 = '')
287 287
 	{
288 288
 		$unite = array();
289 289
 		$dix = array();
290 290
 		$cent = array();
291
-		if(empty($devise1)) $dev1='euros';
292
-		else $dev1=$devise1;
293
-		if(empty($devise2)) $dev2='centimes';
294
-		else $dev2=$devise2;
295
-		$valeur_entiere=intval($montant);
296
-		$valeur_decimal=intval(round($montant-intval($montant), 2)*100);
297
-		$dix_c=intval($valeur_decimal%100/10);
298
-		$cent_c=intval($valeur_decimal%1000/100);
299
-		$unite[1]=$valeur_entiere%10;
300
-		$dix[1]=intval($valeur_entiere%100/10);
301
-		$cent[1]=intval($valeur_entiere%1000/100);
302
-		$unite[2]=intval($valeur_entiere%10000/1000);
303
-		$dix[2]=intval($valeur_entiere%100000/10000);
304
-		$cent[2]=intval($valeur_entiere%1000000/100000);
305
-		$unite[3]=intval($valeur_entiere%10000000/1000000);
306
-		$dix[3]=intval($valeur_entiere%100000000/10000000);
307
-		$cent[3]=intval($valeur_entiere%1000000000/100000000);
308
-		$chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
309
-			$secon_c='';
310
-			$trio_c='';
311
-		for($i=1; $i<=3; $i++){
312
-			$prim[$i]='';
313
-			$secon[$i]='';
314
-			$trio[$i]='';
315
-			if($dix[$i]==0){
316
-				$secon[$i]='';
317
-				$prim[$i]=$chif[$unite[$i]];
291
+		if (empty($devise1)) $dev1 = 'euros';
292
+		else $dev1 = $devise1;
293
+		if (empty($devise2)) $dev2 = 'centimes';
294
+		else $dev2 = $devise2;
295
+		$valeur_entiere = intval($montant);
296
+		$valeur_decimal = intval(round($montant - intval($montant), 2) * 100);
297
+		$dix_c = intval($valeur_decimal % 100 / 10);
298
+		$cent_c = intval($valeur_decimal % 1000 / 100);
299
+		$unite[1] = $valeur_entiere % 10;
300
+		$dix[1] = intval($valeur_entiere % 100 / 10);
301
+		$cent[1] = intval($valeur_entiere % 1000 / 100);
302
+		$unite[2] = intval($valeur_entiere % 10000 / 1000);
303
+		$dix[2] = intval($valeur_entiere % 100000 / 10000);
304
+		$cent[2] = intval($valeur_entiere % 1000000 / 100000);
305
+		$unite[3] = intval($valeur_entiere % 10000000 / 1000000);
306
+		$dix[3] = intval($valeur_entiere % 100000000 / 10000000);
307
+		$cent[3] = intval($valeur_entiere % 1000000000 / 100000000);
308
+		$chif = array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
309
+			$secon_c = '';
310
+			$trio_c = '';
311
+		for ($i = 1; $i <= 3; $i++) {
312
+			$prim[$i] = '';
313
+			$secon[$i] = '';
314
+			$trio[$i] = '';
315
+			if ($dix[$i] == 0) {
316
+				$secon[$i] = '';
317
+				$prim[$i] = $chif[$unite[$i]];
318 318
 			}
319
-			else if($dix[$i]==1){
320
-				$secon[$i]='';
321
-				$prim[$i]=$chif[($unite[$i]+10)];
319
+			else if ($dix[$i] == 1) {
320
+				$secon[$i] = '';
321
+				$prim[$i] = $chif[($unite[$i] + 10)];
322 322
 			}
323
-			else if($dix[$i]==2){
324
-				if($unite[$i]==1){
325
-				$secon[$i]='vingt et';
326
-				$prim[$i]=$chif[$unite[$i]];
323
+			else if ($dix[$i] == 2) {
324
+				if ($unite[$i] == 1) {
325
+				$secon[$i] = 'vingt et';
326
+				$prim[$i] = $chif[$unite[$i]];
327 327
 				}
328 328
 				else {
329
-				$secon[$i]='vingt';
330
-				$prim[$i]=$chif[$unite[$i]];
329
+				$secon[$i] = 'vingt';
330
+				$prim[$i] = $chif[$unite[$i]];
331 331
 				}
332 332
 			}
333
-			else if($dix[$i]==3){
334
-				if($unite[$i]==1){
335
-				$secon[$i]='trente et';
336
-				$prim[$i]=$chif[$unite[$i]];
333
+			else if ($dix[$i] == 3) {
334
+				if ($unite[$i] == 1) {
335
+				$secon[$i] = 'trente et';
336
+				$prim[$i] = $chif[$unite[$i]];
337 337
 				}
338 338
 				else {
339
-				$secon[$i]='trente';
340
-				$prim[$i]=$chif[$unite[$i]];
339
+				$secon[$i] = 'trente';
340
+				$prim[$i] = $chif[$unite[$i]];
341 341
 				}
342 342
 			}
343
-			else if($dix[$i]==4){
344
-				if($unite[$i]==1){
345
-				$secon[$i]='quarante et';
346
-				$prim[$i]=$chif[$unite[$i]];
343
+			else if ($dix[$i] == 4) {
344
+				if ($unite[$i] == 1) {
345
+				$secon[$i] = 'quarante et';
346
+				$prim[$i] = $chif[$unite[$i]];
347 347
 				}
348 348
 				else {
349
-				$secon[$i]='quarante';
350
-				$prim[$i]=$chif[$unite[$i]];
349
+				$secon[$i] = 'quarante';
350
+				$prim[$i] = $chif[$unite[$i]];
351 351
 				}
352 352
 			}
353
-			else if($dix[$i]==5){
354
-				if($unite[$i]==1){
355
-				$secon[$i]='cinquante et';
356
-				$prim[$i]=$chif[$unite[$i]];
353
+			else if ($dix[$i] == 5) {
354
+				if ($unite[$i] == 1) {
355
+				$secon[$i] = 'cinquante et';
356
+				$prim[$i] = $chif[$unite[$i]];
357 357
 				}
358 358
 				else {
359
-				$secon[$i]='cinquante';
360
-				$prim[$i]=$chif[$unite[$i]];
359
+				$secon[$i] = 'cinquante';
360
+				$prim[$i] = $chif[$unite[$i]];
361 361
 				}
362 362
 			}
363
-			else if($dix[$i]==6){
364
-				if($unite[$i]==1){
365
-				$secon[$i]='soixante et';
366
-				$prim[$i]=$chif[$unite[$i]];
363
+			else if ($dix[$i] == 6) {
364
+				if ($unite[$i] == 1) {
365
+				$secon[$i] = 'soixante et';
366
+				$prim[$i] = $chif[$unite[$i]];
367 367
 				}
368 368
 				else {
369
-				$secon[$i]='soixante';
370
-				$prim[$i]=$chif[$unite[$i]];
369
+				$secon[$i] = 'soixante';
370
+				$prim[$i] = $chif[$unite[$i]];
371 371
 				}
372 372
 			}
373
-			else if($dix[$i]==7){
374
-				if($unite[$i]==1){
375
-				$secon[$i]='soixante et';
376
-				$prim[$i]=$chif[$unite[$i]+10];
373
+			else if ($dix[$i] == 7) {
374
+				if ($unite[$i] == 1) {
375
+				$secon[$i] = 'soixante et';
376
+				$prim[$i] = $chif[$unite[$i] + 10];
377 377
 				}
378 378
 				else {
379
-				$secon[$i]='soixante';
380
-				$prim[$i]=$chif[$unite[$i]+10];
379
+				$secon[$i] = 'soixante';
380
+				$prim[$i] = $chif[$unite[$i] + 10];
381 381
 				}
382 382
 			}
383
-			else if($dix[$i]==8){
384
-				if($unite[$i]==1){
385
-				$secon[$i]='quatre-vingts et';
386
-				$prim[$i]=$chif[$unite[$i]];
383
+			else if ($dix[$i] == 8) {
384
+				if ($unite[$i] == 1) {
385
+				$secon[$i] = 'quatre-vingts et';
386
+				$prim[$i] = $chif[$unite[$i]];
387 387
 				}
388 388
 				else {
389
-				$secon[$i]='quatre-vingt';
390
-				$prim[$i]=$chif[$unite[$i]];
389
+				$secon[$i] = 'quatre-vingt';
390
+				$prim[$i] = $chif[$unite[$i]];
391 391
 				}
392 392
 			}
393
-			else if($dix[$i]==9){
394
-				if($unite[$i]==1){
395
-				$secon[$i]='quatre-vingts et';
396
-				$prim[$i]=$chif[$unite[$i]+10];
393
+			else if ($dix[$i] == 9) {
394
+				if ($unite[$i] == 1) {
395
+				$secon[$i] = 'quatre-vingts et';
396
+				$prim[$i] = $chif[$unite[$i] + 10];
397 397
 				}
398 398
 				else {
399
-				$secon[$i]='quatre-vingts';
400
-				$prim[$i]=$chif[$unite[$i]+10];
399
+				$secon[$i] = 'quatre-vingts';
400
+				$prim[$i] = $chif[$unite[$i] + 10];
401 401
 				}
402 402
 			}
403
-			if($cent[$i]==1) $trio[$i]='cent';
404
-			else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
403
+			if ($cent[$i] == 1) $trio[$i] = 'cent';
404
+			else if ($cent[$i] != 0 || $cent[$i] != '') $trio[$i] = $chif[$cent[$i]].' cents';
405 405
 		}
406 406
 
407 407
 
408
-		$chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
409
-		$secon_c=$chif2[$dix_c];
410
-		if($cent_c==1) $trio_c='cent';
411
-		else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
408
+		$chif2 = array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
409
+		$secon_c = $chif2[$dix_c];
410
+		if ($cent_c == 1) $trio_c = 'cent';
411
+		else if ($cent_c != 0 || $cent_c != '') $trio_c = $chif[$cent_c].' cents';
412 412
 
413
-		if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
414
-			$somme = $trio[3]. '  ' .$secon[3]. ' ' . $prim[3]. ' million ';
415
-		else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
416
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
413
+		if (($cent[3] == 0 || $cent[3] == '') && ($dix[3] == 0 || $dix[3] == '') && ($unite[3] == 1))
414
+			$somme = $trio[3].'  '.$secon[3].' '.$prim[3].' million ';
415
+		else if (($cent[3] != 0 && $cent[3] != '') || ($dix[3] != 0 && $dix[3] != '') || ($unite[3] != 0 && $unite[3] != ''))
416
+			$somme = $trio[3].' '.$secon[3].' '.$prim[3].' millions ';
417 417
 		else
418
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
418
+			$somme = $trio[3].' '.$secon[3].' '.$prim[3];
419 419
 
420
-		if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
420
+		if (($cent[2] == 0 || $cent[2] == '') && ($dix[2] == 0 || $dix[2] == '') && ($unite[2] == 1))
421 421
 			$somme = $somme.' mille ';
422
-		else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
423
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
422
+		else if (($cent[2] != 0 && $cent[2] != '') || ($dix[2] != 0 && $dix[2] != '') || ($unite[2] != 0 && $unite[2] != ''))
423
+			$somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2].' milles ';
424 424
 		else
425
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
425
+			$somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2];
426 426
 
427
-		$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
427
+		$somme = $somme.$trio[1].' '.$secon[1].' '.$prim[1];
428 428
 
429
-		$somme = $somme. ' '. $dev1 .' ' ;
429
+		$somme = $somme.' '.$dev1.' ';
430 430
 
431
-		if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
432
-			return $somme. ' et z&eacute;ro '. $dev2;
431
+		if (($cent_c == '0' || $cent_c == '') && ($dix_c == '0' || $dix_c == ''))
432
+			return $somme.' et z&eacute;ro '.$dev2;
433 433
 		else
434
-			return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
434
+			return $somme.$trio_c.' '.$secon_c.' '.$dev2;
435 435
 	}
436 436
 }
Please login to merge, or discard this patch.
Braces   +81 added lines, -84 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@  discard block
 block discarded – undo
81 81
 		$now=dol_now();
82 82
 		$id = (! is_object($don)?$don:'');
83 83
 
84
-		if (! is_object($outputlangs)) $outputlangs=$langs;
84
+		if (! is_object($outputlangs)) {
85
+		    $outputlangs=$langs;
86
+		}
85 87
 
86 88
 		// Load traductions files requiredby by page
87 89
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations"));
@@ -103,8 +105,7 @@  discard block
 block discarded – undo
103 105
 			{
104 106
 				$dir = $conf->don->dir_output;
105 107
 				$file = $dir . "/SPECIMEN.html";
106
-			}
107
-			else
108
+			} else
108 109
 			{
109 110
 				$donref = dol_sanitizeFileName($don->ref);
110 111
 				$dir = $conf->don->dir_output . "/" . $donref;
@@ -130,19 +131,17 @@  discard block
 block discarded – undo
130 131
 				{
131 132
 					$formclass->load_cache_types_paiements();
132 133
 					$paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
134
+				} else {
135
+				    $paymentmode = '';
133 136
 				}
134
-				else $paymentmode = '';
135 137
 
136 138
 				if ($don->modepaymentcode=='CHQ'){
137 139
 					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
138
-				}
139
-				else if ($don->modepaymentcode=='LIQ'){
140
+				} else if ($don->modepaymentcode=='LIQ'){
140 141
 					$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
141
-				}
142
-				else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
142
+				} else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
143 143
 					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
144
-				}
145
-				else
144
+				} else
146 145
 				{
147 146
 					$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
148 147
 				}
@@ -204,11 +203,15 @@  discard block
 block discarded – undo
204 203
 				$form = str_replace('__ModePaiement__', $ModePaiement,$form);
205 204
 
206 205
 				$frencharticle='';
207
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
206
+				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
207
+				    $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
208
+				}
208 209
 				$form = str_replace('__FrenchArticle__',$frencharticle,$form);
209 210
 
210 211
 				$frencheligibility='';
211
-				if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
212
+				if (preg_match('/fr/i',$outputlangs->defaultlang)) {
213
+				    $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
214
+				}
212 215
 				$form = str_replace('__FrenchEligibility__',$frencheligibility,$form);
213 216
 
214 217
 				$art200='';
@@ -216,8 +219,7 @@  discard block
 block discarded – undo
216 219
 					if ($conf->global->DONATION_ART200 >= 1)
217 220
 					{
218 221
 						$art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
219
-					}
220
-					else
222
+					} else
221 223
 					{
222 224
 						$art200='<input type="checkbox" disabled="true">200 du CGI';
223 225
 					}
@@ -229,8 +231,7 @@  discard block
 block discarded – undo
229 231
 					if ($conf->global->DONATION_ART238 >= 1)
230 232
 					{
231 233
 						$art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
232
-					}
233
-					else
234
+					} else
234 235
 					{
235 236
 						$art238='<input type="checkbox" disabled="true">238 bis du CGI';
236 237
 					}
@@ -242,8 +243,7 @@  discard block
 block discarded – undo
242 243
 					if ($conf->global->DONATION_ART885 >= 1)
243 244
 					{
244 245
 						$art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI';
245
-					}
246
-					else
246
+					} else
247 247
 					{
248 248
 						$art885='<input type="checkbox" disabled="true">885-0 V bis du CGI';
249 249
 					}
@@ -255,20 +255,19 @@  discard block
 block discarded – undo
255 255
 				$handle=fopen($file,"w");
256 256
 				fwrite($handle,$form);
257 257
 				fclose($handle);
258
-				if (! empty($conf->global->MAIN_UMASK))
259
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
258
+				if (! empty($conf->global->MAIN_UMASK)) {
259
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
260
+				}
260 261
 
261 262
 				$this->result = array('fullpath'=>$file);
262 263
 
263 264
 				return 1;
264
-			}
265
-			else
265
+			} else
266 266
 			{
267 267
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
268 268
 				return 0;
269 269
 			}
270
-		}
271
-		else
270
+		} else
272 271
 		{
273 272
 			$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
274 273
 			return 0;
@@ -288,10 +287,16 @@  discard block
 block discarded – undo
288 287
 		$unite = array();
289 288
 		$dix = array();
290 289
 		$cent = array();
291
-		if(empty($devise1)) $dev1='euros';
292
-		else $dev1=$devise1;
293
-		if(empty($devise2)) $dev2='centimes';
294
-		else $dev2=$devise2;
290
+		if(empty($devise1)) {
291
+		    $dev1='euros';
292
+		} else {
293
+		    $dev1=$devise1;
294
+		}
295
+		if(empty($devise2)) {
296
+		    $dev2='centimes';
297
+		} else {
298
+		    $dev2=$devise2;
299
+		}
295 300
 		$valeur_entiere=intval($montant);
296 301
 		$valeur_decimal=intval(round($montant-intval($montant), 2)*100);
297 302
 		$dix_c=intval($valeur_decimal%100/10);
@@ -315,122 +320,114 @@  discard block
 block discarded – undo
315 320
 			if($dix[$i]==0){
316 321
 				$secon[$i]='';
317 322
 				$prim[$i]=$chif[$unite[$i]];
318
-			}
319
-			else if($dix[$i]==1){
323
+			} else if($dix[$i]==1){
320 324
 				$secon[$i]='';
321 325
 				$prim[$i]=$chif[($unite[$i]+10)];
322
-			}
323
-			else if($dix[$i]==2){
326
+			} else if($dix[$i]==2){
324 327
 				if($unite[$i]==1){
325 328
 				$secon[$i]='vingt et';
326 329
 				$prim[$i]=$chif[$unite[$i]];
327
-				}
328
-				else {
330
+				} else {
329 331
 				$secon[$i]='vingt';
330 332
 				$prim[$i]=$chif[$unite[$i]];
331 333
 				}
332
-			}
333
-			else if($dix[$i]==3){
334
+			} else if($dix[$i]==3){
334 335
 				if($unite[$i]==1){
335 336
 				$secon[$i]='trente et';
336 337
 				$prim[$i]=$chif[$unite[$i]];
337
-				}
338
-				else {
338
+				} else {
339 339
 				$secon[$i]='trente';
340 340
 				$prim[$i]=$chif[$unite[$i]];
341 341
 				}
342
-			}
343
-			else if($dix[$i]==4){
342
+			} else if($dix[$i]==4){
344 343
 				if($unite[$i]==1){
345 344
 				$secon[$i]='quarante et';
346 345
 				$prim[$i]=$chif[$unite[$i]];
347
-				}
348
-				else {
346
+				} else {
349 347
 				$secon[$i]='quarante';
350 348
 				$prim[$i]=$chif[$unite[$i]];
351 349
 				}
352
-			}
353
-			else if($dix[$i]==5){
350
+			} else if($dix[$i]==5){
354 351
 				if($unite[$i]==1){
355 352
 				$secon[$i]='cinquante et';
356 353
 				$prim[$i]=$chif[$unite[$i]];
357
-				}
358
-				else {
354
+				} else {
359 355
 				$secon[$i]='cinquante';
360 356
 				$prim[$i]=$chif[$unite[$i]];
361 357
 				}
362
-			}
363
-			else if($dix[$i]==6){
358
+			} else if($dix[$i]==6){
364 359
 				if($unite[$i]==1){
365 360
 				$secon[$i]='soixante et';
366 361
 				$prim[$i]=$chif[$unite[$i]];
367
-				}
368
-				else {
362
+				} else {
369 363
 				$secon[$i]='soixante';
370 364
 				$prim[$i]=$chif[$unite[$i]];
371 365
 				}
372
-			}
373
-			else if($dix[$i]==7){
366
+			} else if($dix[$i]==7){
374 367
 				if($unite[$i]==1){
375 368
 				$secon[$i]='soixante et';
376 369
 				$prim[$i]=$chif[$unite[$i]+10];
377
-				}
378
-				else {
370
+				} else {
379 371
 				$secon[$i]='soixante';
380 372
 				$prim[$i]=$chif[$unite[$i]+10];
381 373
 				}
382
-			}
383
-			else if($dix[$i]==8){
374
+			} else if($dix[$i]==8){
384 375
 				if($unite[$i]==1){
385 376
 				$secon[$i]='quatre-vingts et';
386 377
 				$prim[$i]=$chif[$unite[$i]];
387
-				}
388
-				else {
378
+				} else {
389 379
 				$secon[$i]='quatre-vingt';
390 380
 				$prim[$i]=$chif[$unite[$i]];
391 381
 				}
392
-			}
393
-			else if($dix[$i]==9){
382
+			} else if($dix[$i]==9){
394 383
 				if($unite[$i]==1){
395 384
 				$secon[$i]='quatre-vingts et';
396 385
 				$prim[$i]=$chif[$unite[$i]+10];
397
-				}
398
-				else {
386
+				} else {
399 387
 				$secon[$i]='quatre-vingts';
400 388
 				$prim[$i]=$chif[$unite[$i]+10];
401 389
 				}
402 390
 			}
403
-			if($cent[$i]==1) $trio[$i]='cent';
404
-			else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
391
+			if($cent[$i]==1) {
392
+			    $trio[$i]='cent';
393
+			} else if($cent[$i]!=0 || $cent[$i]!='') {
394
+			    $trio[$i]=$chif[$cent[$i]] .' cents';
395
+			}
405 396
 		}
406 397
 
407 398
 
408 399
 		$chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
409 400
 		$secon_c=$chif2[$dix_c];
410
-		if($cent_c==1) $trio_c='cent';
411
-		else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
412
-
413
-		if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
414
-			$somme = $trio[3]. '  ' .$secon[3]. ' ' . $prim[3]. ' million ';
415
-		else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
416
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
417
-		else
418
-			$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
419
-
420
-		if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
421
-			$somme = $somme.' mille ';
422
-		else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
423
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
424
-		else
425
-			$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
401
+		if($cent_c==1) {
402
+		    $trio_c='cent';
403
+		} else if($cent_c!=0 || $cent_c!='') {
404
+		    $trio_c=$chif[$cent_c] .' cents';
405
+		}
406
+
407
+		if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) {
408
+					$somme = $trio[3]. '  ' .$secon[3]. ' ' . $prim[3]. ' million ';
409
+		} else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) {
410
+					$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
411
+		} else {
412
+					$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
413
+		}
414
+
415
+		if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) {
416
+					$somme = $somme.' mille ';
417
+		} else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) {
418
+					$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
419
+		} else {
420
+					$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
421
+		}
426 422
 
427 423
 		$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
428 424
 
429 425
 		$somme = $somme. ' '. $dev1 .' ' ;
430 426
 
431
-		if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
432
-			return $somme. ' et z&eacute;ro '. $dev2;
433
-		else
434
-			return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
427
+		if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) {
428
+					return $somme. ' et z&eacute;ro '. $dev2;
429
+		} else {
430
+					return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
431
+		}
435 432
 	}
436 433
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php 3 patches
Indentation   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -35,135 +35,135 @@  discard block
 block discarded – undo
35 35
 
36 36
 class pdf_sepamandate extends ModeleBankAccountDoc
37 37
 {
38
-	/**
39
-	 * Issuer
40
-	 * @var Societe
41
-	 */
42
-	public $emetteur;
38
+    /**
39
+     * Issuer
40
+     * @var Societe
41
+     */
42
+    public $emetteur;
43 43
 
44
-	/**
44
+    /**
45 45
      * Dolibarr version of the loaded document
46 46
      * @public string
47 47
      */
48
-	public $version = 'dolibarr';
49
-
50
-	/**
51
-	 *	Constructor
52
-	 *
53
-	 *  @param		DoliDB		$db      Database handler
54
-	 */
55
-	function __construct($db)
56
-	{
57
-		global $conf, $langs, $mysoc;
58
-
59
-		// Translations
60
-		$langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
61
-
62
-		$this->db = $db;
63
-		$this->name = "sepamandate";
64
-		$this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate");
65
-
66
-		// Dimension page pour format A4
67
-		$this->type = 'pdf';
68
-		$formatarray=pdf_getFormat();
69
-		$this->page_largeur = $formatarray['width'];
70
-		$this->page_hauteur = $formatarray['height'];
71
-		$this->format = array($this->page_largeur,$this->page_hauteur);
72
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
73
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
74
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
75
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
76
-
77
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
78
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
79
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
80
-
81
-		// Recupere emmetteur
82
-		$this->emetteur=$mysoc;
83
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
84
-
85
-		// Defini position des colonnes
86
-		$this->posxref=$this->marge_gauche+1;
87
-		$this->posxlabel=$this->marge_gauche+25;
88
-		$this->posxworkload=$this->marge_gauche+100;
89
-		$this->posxprogress=$this->marge_gauche+130;
90
-		$this->posxdatestart=$this->marge_gauche+150;
91
-		$this->posxdateend=$this->marge_gauche+170;
92
-	}
48
+    public $version = 'dolibarr';
49
+
50
+    /**
51
+     *	Constructor
52
+     *
53
+     *  @param		DoliDB		$db      Database handler
54
+     */
55
+    function __construct($db)
56
+    {
57
+        global $conf, $langs, $mysoc;
58
+
59
+        // Translations
60
+        $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
61
+
62
+        $this->db = $db;
63
+        $this->name = "sepamandate";
64
+        $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate");
65
+
66
+        // Dimension page pour format A4
67
+        $this->type = 'pdf';
68
+        $formatarray=pdf_getFormat();
69
+        $this->page_largeur = $formatarray['width'];
70
+        $this->page_hauteur = $formatarray['height'];
71
+        $this->format = array($this->page_largeur,$this->page_hauteur);
72
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
73
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
74
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
75
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
76
+
77
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
78
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
79
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
80
+
81
+        // Recupere emmetteur
82
+        $this->emetteur=$mysoc;
83
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
84
+
85
+        // Defini position des colonnes
86
+        $this->posxref=$this->marge_gauche+1;
87
+        $this->posxlabel=$this->marge_gauche+25;
88
+        $this->posxworkload=$this->marge_gauche+100;
89
+        $this->posxprogress=$this->marge_gauche+130;
90
+        $this->posxdatestart=$this->marge_gauche+150;
91
+        $this->posxdateend=$this->marge_gauche+170;
92
+    }
93 93
 
94 94
 
95 95
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
96 96
     /**
97
-	 *  Fonction generant le projet sur le disque
98
-	 *
99
-	 *	@param	    Project		$object   		    Object project a generer
100
-	 *	@param	    Translate	$outputlangs	    Lang output object
97
+     *  Fonction generant le projet sur le disque
98
+     *
99
+     *	@param	    Project		$object   		    Object project a generer
100
+     *	@param	    Translate	$outputlangs	    Lang output object
101 101
      *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
102 102
      *  @param		int			$hidedetails		Do not show line details (not used for this template)
103 103
      *  @param		int			$hidedesc			Do not show desc (not used for this template)
104 104
      *  @param		int			$hideref			Do not show ref (not used for this template)
105 105
      *  @param      null|array  $moreparams         More parameters
106
-	 *	@return	    int         				    1 if OK, <=0 if KO
107
-	 */
108
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
109
-	{
106
+     *	@return	    int         				    1 if OK, <=0 if KO
107
+     */
108
+    function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
109
+    {
110 110
         // phpcs:enable
111
-		global $conf, $hookmanager, $langs, $user, $mysoc;
112
-
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
114
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
-
117
-		// Load traductions files requiredby by page
118
-		$outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
119
-
120
-		if (! empty($conf->bank->dir_output))
121
-		{
122
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
123
-
124
-		    // Definition of $dir and $file
125
-		    if ($object->specimen)
126
-		    {
127
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
128
-		        else $dir = $conf->bank->dir_output;
129
-		        $file = $dir . "/SPECIMEN.pdf";
130
-		    }
131
-		    else
132
-		    {
133
-		        $objectref = dol_sanitizeFileName($object->ref);
134
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
135
-		        else $dir = $conf->bank->dir_output . "/" . $objectref;
136
-		        $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf";
137
-		    }
138
-
139
-			if (! file_exists($dir))
140
-			{
141
-				if (dol_mkdir($dir) < 0)
142
-				{
143
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
144
-					return 0;
145
-				}
146
-			}
147
-
148
-			if (file_exists($dir))
149
-			{
150
-				// Add pdfgeneration hook
151
-				if (! is_object($hookmanager))
152
-				{
153
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
154
-					$hookmanager=new HookManager($this->db);
155
-				}
156
-				$hookmanager->initHooks(array('pdfgeneration'));
157
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
158
-				global $action;
159
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
111
+        global $conf, $hookmanager, $langs, $user, $mysoc;
112
+
113
+        if (! is_object($outputlangs)) $outputlangs=$langs;
114
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
+
117
+        // Load traductions files requiredby by page
118
+        $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
119
+
120
+        if (! empty($conf->bank->dir_output))
121
+        {
122
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
123
+
124
+            // Definition of $dir and $file
125
+            if ($object->specimen)
126
+            {
127
+                if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
128
+                else $dir = $conf->bank->dir_output;
129
+                $file = $dir . "/SPECIMEN.pdf";
130
+            }
131
+            else
132
+            {
133
+                $objectref = dol_sanitizeFileName($object->ref);
134
+                if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
135
+                else $dir = $conf->bank->dir_output . "/" . $objectref;
136
+                $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf";
137
+            }
138
+
139
+            if (! file_exists($dir))
140
+            {
141
+                if (dol_mkdir($dir) < 0)
142
+                {
143
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
144
+                    return 0;
145
+                }
146
+            }
147
+
148
+            if (file_exists($dir))
149
+            {
150
+                // Add pdfgeneration hook
151
+                if (! is_object($hookmanager))
152
+                {
153
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
154
+                    $hookmanager=new HookManager($this->db);
155
+                }
156
+                $hookmanager->initHooks(array('pdfgeneration'));
157
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
158
+                global $action;
159
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
160 160
 
161 161
                 $pdf=pdf_getInstance($this->format);
162 162
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
163 163
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
164
-		        $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
165
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
164
+                $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
165
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
167 167
                 $pdf->SetAutoPageBreak(1,0);
168 168
 
169 169
                 if (class_exists('TCPDF'))
@@ -173,419 +173,419 @@  discard block
 block discarded – undo
173 173
                 }
174 174
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
175 175
 
176
-				$pdf->Open();
177
-				$pagenb=0;
178
-				$pdf->SetDrawColor(128,128,128);
179
-
180
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
181
-				$pdf->SetSubject($outputlangs->transnoentities("SepaMandate"));
182
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
183
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
185
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
186
-
187
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
188
-
189
-				// New page
190
-				$pdf->AddPage();
191
-				$pagenb++;
192
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
193
-				$pdf->SetFont('','', $default_font_size - 1);
194
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
195
-				$pdf->SetTextColor(0,0,0);
196
-
197
-				$tab_top = 50;
198
-				$tab_height = 200;
199
-				$tab_top_newpage = 40;
176
+                $pdf->Open();
177
+                $pagenb=0;
178
+                $pdf->SetDrawColor(128,128,128);
179
+
180
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
181
+                $pdf->SetSubject($outputlangs->transnoentities("SepaMandate"));
182
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
183
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
185
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
186
+
187
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
188
+
189
+                // New page
190
+                $pdf->AddPage();
191
+                $pagenb++;
192
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
193
+                $pdf->SetFont('','', $default_font_size - 1);
194
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
195
+                $pdf->SetTextColor(0,0,0);
196
+
197
+                $tab_top = 50;
198
+                $tab_height = 200;
199
+                $tab_top_newpage = 40;
200 200
                 $tab_height_newpage = 210;
201 201
 
202
-				// Affiche notes
203
-				if (! empty($object->note_public))
204
-				{
205
-					$pdf->SetFont('','', $default_font_size - 1);
206
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1);
207
-					$nexY = $pdf->GetY();
208
-					$height_note=$nexY-($tab_top-2);
209
-
210
-					// Rect prend une longueur en 3eme param
211
-					$pdf->SetDrawColor(192,192,192);
212
-					$pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
213
-
214
-					$tab_height = $tab_height - $height_note;
215
-					$tab_top = $nexY+6;
216
-				}
217
-				else
218
-				{
219
-					$height_note=0;
220
-				}
221
-
222
-				$iniY = $tab_top + 7;
223
-				$curY = $tab_top + 7;
224
-				$nexY = $tab_top + 7;
225
-
226
-				$posY = $curY;
227
-
228
-				$pdf->SetFont('','', $default_font_size);
229
-
230
-				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
231
-				$posY+=2;
232
-
233
-				$pdf->SetXY($this->marge_gauche, $posY);
234
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L');
235
-
236
-				$posY=$pdf->GetY();
237
-				$posY+=2;
238
-				$pdf->SetXY($this->marge_gauche, $posY);
239
-				$ics='';
240
-				if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS;
241
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L');
242
-
243
-				$posY=$pdf->GetY();
244
-				$posY+=1;
245
-				$pdf->SetXY($this->marge_gauche, $posY);
246
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L');
247
-
248
-				$posY=$pdf->GetY();
249
-				$posY+=1;
250
-				$pdf->SetXY($this->marge_gauche, $posY);
251
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
252
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L');
253
-
254
-				$posY=$pdf->GetY();
255
-				$posY+=3;
256
-
257
-				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
258
-
259
-				$pdf->SetFont('','', $default_font_size - 1);
260
-
261
-				$posY+=8;
262
-				$pdf->SetXY($this->marge_gauche, $posY);
263
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L');
264
-
265
-				// Your data form
266
-				$posY=$pdf->GetY();
267
-				$posY+=8;
268
-				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
269
-				$posY+=2;
270
-
271
-				$pdf->SetFont('','', $default_font_size);
272
-
273
-				$pdf->SetXY($this->marge_gauche, $posY);
274
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
275
-
276
-				$thirdparty=new Societe($this->db);
277
-				if ($object->socid > 0) $thirdparty->fetch($object->socid);
278
-
279
-				$sepaname = '______________________________________________';
280
-				if ($thirdparty->id > 0)
281
-				{
282
-				    $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':'');
283
-				}
284
-				$posY=$pdf->GetY();
285
-				$posY+=3;
286
-				$pdf->SetXY($this->marge_gauche, $posY);
287
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L');
288
-				$pdf->SetXY(80, $posY);
289
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L');
290
-
291
-			    $address = '______________________________________________';
292
-				if ($thirdparty->id > 0)
293
-				{
294
-				    $address = $thirdparty->getFullAddress();
295
-				}
296
-				$posY=$pdf->GetY();
297
-				$posY+=1;
298
-				$pdf->SetXY($this->marge_gauche, $posY);
299
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
300
-				$pdf->SetXY(80, $posY);
301
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
302
-				if (preg_match('/_____/', $address))
303
-				{
304
-    				$posY+=6;
305
-    				$pdf->SetXY(80, $posY);
306
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
307
-				}
308
-
309
-				$ban = '__________________________________________________';
310
-				if (! empty($object->iban)) $ban = $object->iban;
311
-				$posY=$pdf->GetY();
312
-				$posY+=1;
313
-				$pdf->SetXY($this->marge_gauche, $posY);
314
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L');
315
-				$pdf->SetXY(80, $posY);
316
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
317
-
318
-				$bic = '__________________________________________________';
319
-				if (! empty($object->bic)) $bic = $object->bic;
320
-				$posY=$pdf->GetY();
321
-				$posY+=1;
322
-				$pdf->SetXY($this->marge_gauche, $posY);
323
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L');
324
-				$pdf->SetXY(80, $posY);
325
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L');
326
-
327
-
328
-				$posY=$pdf->GetY();
329
-				$posY+=1;
330
-				$pdf->SetXY($this->marge_gauche, $posY);
331
-				$txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : ';
332
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
333
-				$pdf->Rect(80, $posY, 5, 5);
334
-				$pdf->SetXY(80, $posY);
335
-				if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L');
336
-				$pdf->SetXY(86, $posY);
337
-				$txt = $langs->transnoentitiesnoconv("ModeRECUR").'  '.$langs->transnoentitiesnoconv("or");
338
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
339
-				$posY+=6;
340
-				$pdf->Rect(80, $posY, 5, 5);
341
-				$pdf->SetXY(80, $posY);
342
-				if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L');
343
-				$pdf->SetXY(86, $posY);
344
-				$txt = $langs->transnoentitiesnoconv("ModeFRST");
345
-				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
346
-				if (empty($object->frstrecur))
347
-				{
348
-    				$posY+=6;
349
-    				$pdf->SetXY(80, $posY);
350
-				    $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
351
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
352
-				}
353
-
354
-				$posY=$pdf->GetY();
355
-				$posY+=3;
356
-				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
357
-				$posY+=3;
358
-
359
-
360
-				// Show square
361
-				if ($pagenb == 1)
362
-				{
363
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
364
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
365
-				}
366
-				else
367
-				{
368
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
369
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
370
-				}
371
-
372
-				/*var_dump($tab_top);
202
+                // Affiche notes
203
+                if (! empty($object->note_public))
204
+                {
205
+                    $pdf->SetFont('','', $default_font_size - 1);
206
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1);
207
+                    $nexY = $pdf->GetY();
208
+                    $height_note=$nexY-($tab_top-2);
209
+
210
+                    // Rect prend une longueur en 3eme param
211
+                    $pdf->SetDrawColor(192,192,192);
212
+                    $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
213
+
214
+                    $tab_height = $tab_height - $height_note;
215
+                    $tab_top = $nexY+6;
216
+                }
217
+                else
218
+                {
219
+                    $height_note=0;
220
+                }
221
+
222
+                $iniY = $tab_top + 7;
223
+                $curY = $tab_top + 7;
224
+                $nexY = $tab_top + 7;
225
+
226
+                $posY = $curY;
227
+
228
+                $pdf->SetFont('','', $default_font_size);
229
+
230
+                $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
231
+                $posY+=2;
232
+
233
+                $pdf->SetXY($this->marge_gauche, $posY);
234
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L');
235
+
236
+                $posY=$pdf->GetY();
237
+                $posY+=2;
238
+                $pdf->SetXY($this->marge_gauche, $posY);
239
+                $ics='';
240
+                if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS;
241
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L');
242
+
243
+                $posY=$pdf->GetY();
244
+                $posY+=1;
245
+                $pdf->SetXY($this->marge_gauche, $posY);
246
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L');
247
+
248
+                $posY=$pdf->GetY();
249
+                $posY+=1;
250
+                $pdf->SetXY($this->marge_gauche, $posY);
251
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
252
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L');
253
+
254
+                $posY=$pdf->GetY();
255
+                $posY+=3;
256
+
257
+                $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
258
+
259
+                $pdf->SetFont('','', $default_font_size - 1);
260
+
261
+                $posY+=8;
262
+                $pdf->SetXY($this->marge_gauche, $posY);
263
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L');
264
+
265
+                // Your data form
266
+                $posY=$pdf->GetY();
267
+                $posY+=8;
268
+                $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
269
+                $posY+=2;
270
+
271
+                $pdf->SetFont('','', $default_font_size);
272
+
273
+                $pdf->SetXY($this->marge_gauche, $posY);
274
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
275
+
276
+                $thirdparty=new Societe($this->db);
277
+                if ($object->socid > 0) $thirdparty->fetch($object->socid);
278
+
279
+                $sepaname = '______________________________________________';
280
+                if ($thirdparty->id > 0)
281
+                {
282
+                    $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':'');
283
+                }
284
+                $posY=$pdf->GetY();
285
+                $posY+=3;
286
+                $pdf->SetXY($this->marge_gauche, $posY);
287
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L');
288
+                $pdf->SetXY(80, $posY);
289
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L');
290
+
291
+                $address = '______________________________________________';
292
+                if ($thirdparty->id > 0)
293
+                {
294
+                    $address = $thirdparty->getFullAddress();
295
+                }
296
+                $posY=$pdf->GetY();
297
+                $posY+=1;
298
+                $pdf->SetXY($this->marge_gauche, $posY);
299
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
300
+                $pdf->SetXY(80, $posY);
301
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
302
+                if (preg_match('/_____/', $address))
303
+                {
304
+                    $posY+=6;
305
+                    $pdf->SetXY(80, $posY);
306
+                    $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
307
+                }
308
+
309
+                $ban = '__________________________________________________';
310
+                if (! empty($object->iban)) $ban = $object->iban;
311
+                $posY=$pdf->GetY();
312
+                $posY+=1;
313
+                $pdf->SetXY($this->marge_gauche, $posY);
314
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L');
315
+                $pdf->SetXY(80, $posY);
316
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
317
+
318
+                $bic = '__________________________________________________';
319
+                if (! empty($object->bic)) $bic = $object->bic;
320
+                $posY=$pdf->GetY();
321
+                $posY+=1;
322
+                $pdf->SetXY($this->marge_gauche, $posY);
323
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L');
324
+                $pdf->SetXY(80, $posY);
325
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L');
326
+
327
+
328
+                $posY=$pdf->GetY();
329
+                $posY+=1;
330
+                $pdf->SetXY($this->marge_gauche, $posY);
331
+                $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : ';
332
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
333
+                $pdf->Rect(80, $posY, 5, 5);
334
+                $pdf->SetXY(80, $posY);
335
+                if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L');
336
+                $pdf->SetXY(86, $posY);
337
+                $txt = $langs->transnoentitiesnoconv("ModeRECUR").'  '.$langs->transnoentitiesnoconv("or");
338
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
339
+                $posY+=6;
340
+                $pdf->Rect(80, $posY, 5, 5);
341
+                $pdf->SetXY(80, $posY);
342
+                if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L');
343
+                $pdf->SetXY(86, $posY);
344
+                $txt = $langs->transnoentitiesnoconv("ModeFRST");
345
+                $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
346
+                if (empty($object->frstrecur))
347
+                {
348
+                    $posY+=6;
349
+                    $pdf->SetXY(80, $posY);
350
+                    $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
351
+                    $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
352
+                }
353
+
354
+                $posY=$pdf->GetY();
355
+                $posY+=3;
356
+                $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
357
+                $posY+=3;
358
+
359
+
360
+                // Show square
361
+                if ($pagenb == 1)
362
+                {
363
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
364
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
365
+                }
366
+                else
367
+                {
368
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
369
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
370
+                }
371
+
372
+                /*var_dump($tab_top);
373 373
 				var_dump($heightforinfotot);
374 374
 				var_dump($heightforfreetext);
375 375
 				var_dump($heightforfooter);
376 376
 				var_dump($bottomlasttab);*/
377 377
 
378
-				// Affiche zone infos
379
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
378
+                // Affiche zone infos
379
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
380 380
 
381
-				/*
381
+                /*
382 382
 				 * Pied de page
383 383
 				 */
384
-				$this->_pagefoot($pdf,$object,$outputlangs);
385
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
386
-
387
-				$pdf->Close();
388
-
389
-				$pdf->Output($file,'F');
390
-
391
-				// Add pdfgeneration hook
392
-				if (! is_object($hookmanager))
393
-				{
394
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
395
-					$hookmanager=new HookManager($this->db);
396
-				}
397
-				$hookmanager->initHooks(array('pdfgeneration'));
398
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
399
-				global $action;
400
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
401
-
402
-				if (! empty($conf->global->MAIN_UMASK))
403
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
404
-
405
-				$this->result = array('fullpath'=>$file);
406
-
407
-				return 1;   // Pas d'erreur
408
-			}
409
-			else
410
-			{
411
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
412
-				return 0;
413
-			}
414
-		}
415
-
416
-		$this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
417
-		return 0;
418
-	}
419
-
420
-
421
-	/**
422
-	 *   Show table for lines
423
-	 *
424
-	 *   @param		PDF			$pdf     		Object PDF
425
-	 *   @param		string		$tab_top		Top position of table
426
-	 *   @param		string		$tab_height		Height of table (rectangle)
427
-	 *   @param		int			$nexY			Y
428
-	 *   @param		Translate	$outputlangs	Langs object
429
-	 *   @param		int			$hidetop		Hide top bar of array
430
-	 *   @param		int			$hidebottom		Hide bottom bar of array
431
-	 *   @return	void
432
-	 */
433
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
434
-	{
435
-		global $conf,$mysoc;
384
+                $this->_pagefoot($pdf,$object,$outputlangs);
385
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
386
+
387
+                $pdf->Close();
388
+
389
+                $pdf->Output($file,'F');
390
+
391
+                // Add pdfgeneration hook
392
+                if (! is_object($hookmanager))
393
+                {
394
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
395
+                    $hookmanager=new HookManager($this->db);
396
+                }
397
+                $hookmanager->initHooks(array('pdfgeneration'));
398
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
399
+                global $action;
400
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
401
+
402
+                if (! empty($conf->global->MAIN_UMASK))
403
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
404
+
405
+                $this->result = array('fullpath'=>$file);
406
+
407
+                return 1;   // Pas d'erreur
408
+            }
409
+            else
410
+            {
411
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
412
+                return 0;
413
+            }
414
+        }
415
+
416
+        $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
417
+        return 0;
418
+    }
419
+
420
+
421
+    /**
422
+     *   Show table for lines
423
+     *
424
+     *   @param		PDF			$pdf     		Object PDF
425
+     *   @param		string		$tab_top		Top position of table
426
+     *   @param		string		$tab_height		Height of table (rectangle)
427
+     *   @param		int			$nexY			Y
428
+     *   @param		Translate	$outputlangs	Langs object
429
+     *   @param		int			$hidetop		Hide top bar of array
430
+     *   @param		int			$hidebottom		Hide bottom bar of array
431
+     *   @return	void
432
+     */
433
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
434
+    {
435
+        global $conf,$mysoc;
436 436
 
437 437
         $default_font_size = pdf_getPDFFontSize($outputlangs);
438
-	}
438
+    }
439 439
 
440 440
 
441 441
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
442
-	/**
443
-	 *   Show miscellaneous information (payment mode, payment term, ...)
444
-	 *
445
-	 *   @param		PDF			$pdf     		Object PDF
446
-	 *   @param		Object		$object			Object to show
447
-	 *   @param		int			$posy			Y
448
-	 *   @param		Translate	$outputlangs	Langs object
449
-	 *   @return	void
450
-	 */
451
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
452
-	{
442
+    /**
443
+     *   Show miscellaneous information (payment mode, payment term, ...)
444
+     *
445
+     *   @param		PDF			$pdf     		Object PDF
446
+     *   @param		Object		$object			Object to show
447
+     *   @param		int			$posy			Y
448
+     *   @param		Translate	$outputlangs	Langs object
449
+     *   @return	void
450
+     */
451
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
452
+    {
453 453
         // phpcs:enable
454 454
         global $conf, $mysoc;
455 455
 
456
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
456
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
457 457
 
458
-	    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE);
458
+        $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE);
459 459
 
460
-	    $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs);
460
+        $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs);
461 461
 
462
-	    $pdf->SetXY($this->marge_gauche, $posy);
463
-	    $pdf->SetFont('','', $default_font_size);
464
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
465
-	    $posy=$pdf->GetY()+2;
462
+        $pdf->SetXY($this->marge_gauche, $posy);
463
+        $pdf->SetFont('','', $default_font_size);
464
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
465
+        $posy=$pdf->GetY()+2;
466 466
 
467
-	    $pdf->SetXY($this->marge_gauche, $posy);
468
-	    $pdf->SetFont('','', $default_font_size - $diffsizetitle);
469
-	    $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
470
-		$pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
471
-		$posy=$pdf->GetY()+2;
467
+        $pdf->SetXY($this->marge_gauche, $posy);
468
+        $pdf->SetFont('','', $default_font_size - $diffsizetitle);
469
+        $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
470
+        $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
471
+        $posy=$pdf->GetY()+2;
472 472
 
473
-	    return $posy;
474
-	}
473
+        return $posy;
474
+    }
475 475
 
476 476
 
477 477
 
478 478
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
479
-	/**
480
-	 *	Show area for the customer to sign
481
-	 *
482
-	 *	@param	PDF			$pdf            Object PDF
483
-	 *	@param  Facture		$object         Object invoice
484
-	 *	@param	int			$posy			Position depart
485
-	 *	@param	Translate	$outputlangs	Objet langs
486
-	 *	@return int							Position pour suite
487
-	 */
488
-	function _signature_area(&$pdf, $object, $posy, $outputlangs)
489
-	{
479
+    /**
480
+     *	Show area for the customer to sign
481
+     *
482
+     *	@param	PDF			$pdf            Object PDF
483
+     *	@param  Facture		$object         Object invoice
484
+     *	@param	int			$posy			Position depart
485
+     *	@param	Translate	$outputlangs	Objet langs
486
+     *	@return int							Position pour suite
487
+     */
488
+    function _signature_area(&$pdf, $object, $posy, $outputlangs)
489
+    {
490 490
         // phpcs:enable
491
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
492
-	    $tab_top = $posy + 4;
493
-	    $tab_hl = 4;
491
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
492
+        $tab_top = $posy + 4;
493
+        $tab_hl = 4;
494 494
 
495
-	    $posx = $this->marge_gauche;
496
-	    $pdf->SetXY($posx, $tab_top + 0);
495
+        $posx = $this->marge_gauche;
496
+        $pdf->SetXY($posx, $tab_top + 0);
497 497
 
498
-	    $pdf->SetFont('','', $default_font_size - 2);
498
+        $pdf->SetFont('','', $default_font_size - 2);
499 499
 
500
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
501
-	    $pdf->MultiCell(100, 3, ' ');
502
-	    $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
500
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
501
+        $pdf->MultiCell(100, 3, ' ');
502
+        $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
503 503
 
504
-	    $posx = 120;
505
-	    $largcol = ($this->page_largeur - $this->marge_droite - $posx);
506
-	    $useborder=0;
507
-	    $index = 0;
508
-	    // Total HT
509
-	    $pdf->SetFillColor(255,255,255);
510
-	    $pdf->SetXY($posx, $tab_top + 0);
511
-	    $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
504
+        $posx = 120;
505
+        $largcol = ($this->page_largeur - $this->marge_droite - $posx);
506
+        $useborder=0;
507
+        $index = 0;
508
+        // Total HT
509
+        $pdf->SetFillColor(255,255,255);
510
+        $pdf->SetXY($posx, $tab_top + 0);
511
+        $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
512 512
 
513
-	    $pdf->SetXY($posx, $tab_top + $tab_hl);
514
-	    $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
513
+        $pdf->SetXY($posx, $tab_top + $tab_hl);
514
+        $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
515 515
 
516
-	    return ($tab_hl*7);
517
-	}
516
+        return ($tab_hl*7);
517
+    }
518 518
 
519 519
 
520
-	/**
521
-	 *  Show top header of page.
522
-	 *
523
-	 *  @param	PDF			$pdf     		Object PDF
524
-	 *  @param  Project		$object     	Object to show
525
-	 *  @param  int	    	$showaddress    0=no, 1=yes
526
-	 *  @param  Translate	$outputlangs	Object lang for output
527
-	 *  @return	void
528
-	 */
529
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
530
-	{
531
-		global $langs,$conf,$mysoc;
520
+    /**
521
+     *  Show top header of page.
522
+     *
523
+     *  @param	PDF			$pdf     		Object PDF
524
+     *  @param  Project		$object     	Object to show
525
+     *  @param  int	    	$showaddress    0=no, 1=yes
526
+     *  @param  Translate	$outputlangs	Object lang for output
527
+     *  @return	void
528
+     */
529
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
530
+    {
531
+        global $langs,$conf,$mysoc;
532 532
 
533
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
533
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
534 534
 
535
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
535
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
536 536
 
537
-		$pdf->SetTextColor(0,0,60);
538
-		$pdf->SetFont('','B', $default_font_size + 3);
537
+        $pdf->SetTextColor(0,0,60);
538
+        $pdf->SetFont('','B', $default_font_size + 3);
539 539
 
540 540
         $posx=$this->page_largeur-$this->marge_droite-100;
541
-		$posy=$this->marge_haute;
542
-
543
-		$pdf->SetXY($this->marge_gauche,$posy);
544
-
545
-		// Logo
546
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
547
-		if ($mysoc->logo)
548
-		{
549
-			if (is_readable($logo))
550
-			{
551
-			    $height=pdf_getHeightForLogo($logo);
552
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
553
-			}
554
-			else
555
-			{
556
-				$pdf->SetTextColor(200,0,0);
557
-				$pdf->SetFont('','B', $default_font_size - 2);
558
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
559
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
560
-			}
561
-		}
562
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
563
-
564
-		$pdf->SetFont('','B', $default_font_size + 3);
565
-		$pdf->SetXY($posx,$posy);
566
-		$pdf->SetTextColor(0,0,60);
567
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R');
568
-		$pdf->SetFont('','', $default_font_size + 2);
569
-
570
-		$posy+=6;
571
-		$pdf->SetXY($posx,$posy);
572
-		$pdf->SetTextColor(0,0,60);
573
-		$daterum = '__________________';
574
-		if (! empty($object->date_rum))
575
-		{
541
+        $posy=$this->marge_haute;
542
+
543
+        $pdf->SetXY($this->marge_gauche,$posy);
544
+
545
+        // Logo
546
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
547
+        if ($mysoc->logo)
548
+        {
549
+            if (is_readable($logo))
550
+            {
551
+                $height=pdf_getHeightForLogo($logo);
552
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
553
+            }
554
+            else
555
+            {
556
+                $pdf->SetTextColor(200,0,0);
557
+                $pdf->SetFont('','B', $default_font_size - 2);
558
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
559
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
560
+            }
561
+        }
562
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
563
+
564
+        $pdf->SetFont('','B', $default_font_size + 3);
565
+        $pdf->SetXY($posx,$posy);
566
+        $pdf->SetTextColor(0,0,60);
567
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R');
568
+        $pdf->SetFont('','', $default_font_size + 2);
569
+
570
+        $posy+=6;
571
+        $pdf->SetXY($posx,$posy);
572
+        $pdf->SetTextColor(0,0,60);
573
+        $daterum = '__________________';
574
+        if (! empty($object->date_rum))
575
+        {
576 576
             $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true);
577
-		}
578
-		else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true);   // For old record, the date_rum was not saved.
579
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R');
580
-		/*$posy+=6;
577
+        }
578
+        else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true);   // For old record, the date_rum was not saved.
579
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R');
580
+        /*$posy+=6;
581 581
 		$pdf->SetXY($posx,$posy);
582 582
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
583 583
 		*/
584 584
 
585
-		$pdf->SetTextColor(0,0,60);
585
+        $pdf->SetTextColor(0,0,60);
586 586
 
587
-		// Add list of linked objects
588
-		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
587
+        // Add list of linked objects
588
+        /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
589 589
 		$object->fetchObjectLinked();
590 590
 
591 591
 	    foreach($object->linkedObjects as $objecttype => $objects)
@@ -607,21 +607,21 @@  discard block
 block discarded – undo
607 607
 	    	}
608 608
 	    }
609 609
         */
610
-	}
610
+    }
611 611
 
612
-	/**
613
-	 *   	Show footer of page. Need this->emetteur object
612
+    /**
613
+     *   	Show footer of page. Need this->emetteur object
614 614
      *
615
-	 *   	@param	PDF			$pdf     			PDF
616
-	 * 		@param	Project		$object				Object to show
617
-	 *      @param	Translate	$outputlangs		Object lang for output
618
-	 *      @param	int			$hidefreetext		1=Hide free text
619
-	 *      @return	integer
620
-	 */
621
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
622
-	{
623
-		global $conf;
624
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
625
-		return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
626
-	}
615
+     *   	@param	PDF			$pdf     			PDF
616
+     * 		@param	Project		$object				Object to show
617
+     *      @param	Translate	$outputlangs		Object lang for output
618
+     *      @param	int			$hidefreetext		1=Hide free text
619
+     *      @return	integer
620
+     */
621
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
622
+    {
623
+        global $conf;
624
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
625
+        return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
626
+    }
627 627
 }
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
 
66 66
 		// Dimension page pour format A4
67 67
 		$this->type = 'pdf';
68
-		$formatarray=pdf_getFormat();
68
+		$formatarray = pdf_getFormat();
69 69
 		$this->page_largeur = $formatarray['width'];
70 70
 		$this->page_hauteur = $formatarray['height'];
71
-		$this->format = array($this->page_largeur,$this->page_hauteur);
72
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
73
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
74
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
75
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
71
+		$this->format = array($this->page_largeur, $this->page_hauteur);
72
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
73
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
74
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
75
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
76 76
 
77
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
78
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
79
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
77
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
78
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
79
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
80 80
 
81 81
 		// Recupere emmetteur
82
-		$this->emetteur=$mysoc;
83
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
82
+		$this->emetteur = $mysoc;
83
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
84 84
 
85 85
 		// Defini position des colonnes
86
-		$this->posxref=$this->marge_gauche+1;
87
-		$this->posxlabel=$this->marge_gauche+25;
88
-		$this->posxworkload=$this->marge_gauche+100;
89
-		$this->posxprogress=$this->marge_gauche+130;
90
-		$this->posxdatestart=$this->marge_gauche+150;
91
-		$this->posxdateend=$this->marge_gauche+170;
86
+		$this->posxref = $this->marge_gauche + 1;
87
+		$this->posxlabel = $this->marge_gauche + 25;
88
+		$this->posxworkload = $this->marge_gauche + 100;
89
+		$this->posxprogress = $this->marge_gauche + 130;
90
+		$this->posxdatestart = $this->marge_gauche + 150;
91
+		$this->posxdateend = $this->marge_gauche + 170;
92 92
 	}
93 93
 
94 94
 
@@ -105,42 +105,42 @@  discard block
 block discarded – undo
105 105
      *  @param      null|array  $moreparams         More parameters
106 106
 	 *	@return	    int         				    1 if OK, <=0 if KO
107 107
 	 */
108
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
108
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
109 109
 	{
110 110
         // phpcs:enable
111 111
 		global $conf, $hookmanager, $langs, $user, $mysoc;
112 112
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
113
+		if (!is_object($outputlangs)) $outputlangs = $langs;
114 114
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
115
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
116 116
 
117 117
 		// Load traductions files requiredby by page
118 118
 		$outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
119 119
 
120
-		if (! empty($conf->bank->dir_output))
120
+		if (!empty($conf->bank->dir_output))
121 121
 		{
122 122
 			//$nblignes = count($object->lines);  // This is set later with array of tasks
123 123
 
124 124
 		    // Definition of $dir and $file
125 125
 		    if ($object->specimen)
126 126
 		    {
127
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
127
+		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
128 128
 		        else $dir = $conf->bank->dir_output;
129
-		        $file = $dir . "/SPECIMEN.pdf";
129
+		        $file = $dir."/SPECIMEN.pdf";
130 130
 		    }
131 131
 		    else
132 132
 		    {
133 133
 		        $objectref = dol_sanitizeFileName($object->ref);
134
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
135
-		        else $dir = $conf->bank->dir_output . "/" . $objectref;
136
-		        $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf";
134
+		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
135
+		        else $dir = $conf->bank->dir_output."/".$objectref;
136
+		        $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
137 137
 		    }
138 138
 
139
-			if (! file_exists($dir))
139
+			if (!file_exists($dir))
140 140
 			{
141 141
 				if (dol_mkdir($dir) < 0)
142 142
 				{
143
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
143
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
144 144
 					return 0;
145 145
 				}
146 146
 			}
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
 			if (file_exists($dir))
149 149
 			{
150 150
 				// Add pdfgeneration hook
151
-				if (! is_object($hookmanager))
151
+				if (!is_object($hookmanager))
152 152
 				{
153 153
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
154
-					$hookmanager=new HookManager($this->db);
154
+					$hookmanager = new HookManager($this->db);
155 155
 				}
156 156
 				$hookmanager->initHooks(array('pdfgeneration'));
157
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
157
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
158 158
 				global $action;
159
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
159
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
160 160
 
161
-                $pdf=pdf_getInstance($this->format);
162
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
163
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
164
-		        $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
165
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
167
-                $pdf->SetAutoPageBreak(1,0);
161
+                $pdf = pdf_getInstance($this->format);
162
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
163
+                $heightforinfotot = 50; // Height reserved to output the info and total part
164
+		        $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
165
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
166
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
167
+                $pdf->SetAutoPageBreak(1, 0);
168 168
 
169 169
                 if (class_exists('TCPDF'))
170 170
                 {
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
175 175
 
176 176
 				$pdf->Open();
177
-				$pagenb=0;
178
-				$pdf->SetDrawColor(128,128,128);
177
+				$pagenb = 0;
178
+				$pdf->SetDrawColor(128, 128, 128);
179 179
 
180 180
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
181 181
 				$pdf->SetSubject($outputlangs->transnoentities("SepaMandate"));
182 182
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
183 183
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184 184
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
185
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
185
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
186 186
 
187
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
187
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
188 188
 
189 189
 				// New page
190 190
 				$pdf->AddPage();
191 191
 				$pagenb++;
192 192
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
193
-				$pdf->SetFont('','', $default_font_size - 1);
194
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
195
-				$pdf->SetTextColor(0,0,0);
193
+				$pdf->SetFont('', '', $default_font_size - 1);
194
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
195
+				$pdf->SetTextColor(0, 0, 0);
196 196
 
197 197
 				$tab_top = 50;
198 198
 				$tab_height = 200;
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
                 $tab_height_newpage = 210;
201 201
 
202 202
 				// Affiche notes
203
-				if (! empty($object->note_public))
203
+				if (!empty($object->note_public))
204 204
 				{
205
-					$pdf->SetFont('','', $default_font_size - 1);
206
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1);
205
+					$pdf->SetFont('', '', $default_font_size - 1);
206
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
207 207
 					$nexY = $pdf->GetY();
208
-					$height_note=$nexY-($tab_top-2);
208
+					$height_note = $nexY - ($tab_top - 2);
209 209
 
210 210
 					// Rect prend une longueur en 3eme param
211
-					$pdf->SetDrawColor(192,192,192);
212
-					$pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
211
+					$pdf->SetDrawColor(192, 192, 192);
212
+					$pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
213 213
 
214 214
 					$tab_height = $tab_height - $height_note;
215
-					$tab_top = $nexY+6;
215
+					$tab_top = $nexY + 6;
216 216
 				}
217 217
 				else
218 218
 				{
219
-					$height_note=0;
219
+					$height_note = 0;
220 220
 				}
221 221
 
222 222
 				$iniY = $tab_top + 7;
@@ -225,64 +225,64 @@  discard block
 block discarded – undo
225 225
 
226 226
 				$posY = $curY;
227 227
 
228
-				$pdf->SetFont('','', $default_font_size);
228
+				$pdf->SetFont('', '', $default_font_size);
229 229
 
230 230
 				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
231
-				$posY+=2;
231
+				$posY += 2;
232 232
 
233 233
 				$pdf->SetXY($this->marge_gauche, $posY);
234 234
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L');
235 235
 
236
-				$posY=$pdf->GetY();
237
-				$posY+=2;
236
+				$posY = $pdf->GetY();
237
+				$posY += 2;
238 238
 				$pdf->SetXY($this->marge_gauche, $posY);
239
-				$ics='';
240
-				if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS;
239
+				$ics = '';
240
+				if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS;
241 241
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L');
242 242
 
243
-				$posY=$pdf->GetY();
244
-				$posY+=1;
243
+				$posY = $pdf->GetY();
244
+				$posY += 1;
245 245
 				$pdf->SetXY($this->marge_gauche, $posY);
246 246
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L');
247 247
 
248
-				$posY=$pdf->GetY();
249
-				$posY+=1;
248
+				$posY = $pdf->GetY();
249
+				$posY += 1;
250 250
 				$pdf->SetXY($this->marge_gauche, $posY);
251 251
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
252 252
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L');
253 253
 
254
-				$posY=$pdf->GetY();
255
-				$posY+=3;
254
+				$posY = $pdf->GetY();
255
+				$posY += 3;
256 256
 
257 257
 				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
258 258
 
259
-				$pdf->SetFont('','', $default_font_size - 1);
259
+				$pdf->SetFont('', '', $default_font_size - 1);
260 260
 
261
-				$posY+=8;
261
+				$posY += 8;
262 262
 				$pdf->SetXY($this->marge_gauche, $posY);
263 263
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L');
264 264
 
265 265
 				// Your data form
266
-				$posY=$pdf->GetY();
267
-				$posY+=8;
266
+				$posY = $pdf->GetY();
267
+				$posY += 8;
268 268
 				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
269
-				$posY+=2;
269
+				$posY += 2;
270 270
 
271
-				$pdf->SetFont('','', $default_font_size);
271
+				$pdf->SetFont('', '', $default_font_size);
272 272
 
273 273
 				$pdf->SetXY($this->marge_gauche, $posY);
274 274
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
275 275
 
276
-				$thirdparty=new Societe($this->db);
276
+				$thirdparty = new Societe($this->db);
277 277
 				if ($object->socid > 0) $thirdparty->fetch($object->socid);
278 278
 
279 279
 				$sepaname = '______________________________________________';
280 280
 				if ($thirdparty->id > 0)
281 281
 				{
282
-				    $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':'');
282
+				    $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
283 283
 				}
284
-				$posY=$pdf->GetY();
285
-				$posY+=3;
284
+				$posY = $pdf->GetY();
285
+				$posY += 3;
286 286
 				$pdf->SetXY($this->marge_gauche, $posY);
287 287
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L');
288 288
 				$pdf->SetXY(80, $posY);
@@ -293,40 +293,40 @@  discard block
 block discarded – undo
293 293
 				{
294 294
 				    $address = $thirdparty->getFullAddress();
295 295
 				}
296
-				$posY=$pdf->GetY();
297
-				$posY+=1;
296
+				$posY = $pdf->GetY();
297
+				$posY += 1;
298 298
 				$pdf->SetXY($this->marge_gauche, $posY);
299 299
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
300 300
 				$pdf->SetXY(80, $posY);
301 301
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
302 302
 				if (preg_match('/_____/', $address))
303 303
 				{
304
-    				$posY+=6;
304
+    				$posY += 6;
305 305
     				$pdf->SetXY(80, $posY);
306 306
     				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
307 307
 				}
308 308
 
309 309
 				$ban = '__________________________________________________';
310
-				if (! empty($object->iban)) $ban = $object->iban;
311
-				$posY=$pdf->GetY();
312
-				$posY+=1;
310
+				if (!empty($object->iban)) $ban = $object->iban;
311
+				$posY = $pdf->GetY();
312
+				$posY += 1;
313 313
 				$pdf->SetXY($this->marge_gauche, $posY);
314 314
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L');
315 315
 				$pdf->SetXY(80, $posY);
316 316
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
317 317
 
318 318
 				$bic = '__________________________________________________';
319
-				if (! empty($object->bic)) $bic = $object->bic;
320
-				$posY=$pdf->GetY();
321
-				$posY+=1;
319
+				if (!empty($object->bic)) $bic = $object->bic;
320
+				$posY = $pdf->GetY();
321
+				$posY += 1;
322 322
 				$pdf->SetXY($this->marge_gauche, $posY);
323 323
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L');
324 324
 				$pdf->SetXY(80, $posY);
325 325
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L');
326 326
 
327 327
 
328
-				$posY=$pdf->GetY();
329
-				$posY+=1;
328
+				$posY = $pdf->GetY();
329
+				$posY += 1;
330 330
 				$pdf->SetXY($this->marge_gauche, $posY);
331 331
 				$txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : ';
332 332
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				$pdf->SetXY(86, $posY);
337 337
 				$txt = $langs->transnoentitiesnoconv("ModeRECUR").'  '.$langs->transnoentitiesnoconv("or");
338 338
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
339
-				$posY+=6;
339
+				$posY += 6;
340 340
 				$pdf->Rect(80, $posY, 5, 5);
341 341
 				$pdf->SetXY(80, $posY);
342 342
 				if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L');
@@ -345,28 +345,28 @@  discard block
 block discarded – undo
345 345
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
346 346
 				if (empty($object->frstrecur))
347 347
 				{
348
-    				$posY+=6;
348
+    				$posY += 6;
349 349
     				$pdf->SetXY(80, $posY);
350 350
 				    $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
351 351
     				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
352 352
 				}
353 353
 
354
-				$posY=$pdf->GetY();
355
-				$posY+=3;
354
+				$posY = $pdf->GetY();
355
+				$posY += 3;
356 356
 				$pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
357
-				$posY+=3;
357
+				$posY += 3;
358 358
 
359 359
 
360 360
 				// Show square
361 361
 				if ($pagenb == 1)
362 362
 				{
363 363
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
364
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
364
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
365 365
 				}
366 366
 				else
367 367
 				{
368 368
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
369
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
369
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
370 370
 				}
371 371
 
372 372
 				/*var_dump($tab_top);
@@ -376,44 +376,44 @@  discard block
 block discarded – undo
376 376
 				var_dump($bottomlasttab);*/
377 377
 
378 378
 				// Affiche zone infos
379
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
379
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
380 380
 
381 381
 				/*
382 382
 				 * Pied de page
383 383
 				 */
384
-				$this->_pagefoot($pdf,$object,$outputlangs);
385
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
384
+				$this->_pagefoot($pdf, $object, $outputlangs);
385
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
386 386
 
387 387
 				$pdf->Close();
388 388
 
389
-				$pdf->Output($file,'F');
389
+				$pdf->Output($file, 'F');
390 390
 
391 391
 				// Add pdfgeneration hook
392
-				if (! is_object($hookmanager))
392
+				if (!is_object($hookmanager))
393 393
 				{
394 394
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
395
-					$hookmanager=new HookManager($this->db);
395
+					$hookmanager = new HookManager($this->db);
396 396
 				}
397 397
 				$hookmanager->initHooks(array('pdfgeneration'));
398
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
398
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
399 399
 				global $action;
400
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
400
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
401 401
 
402
-				if (! empty($conf->global->MAIN_UMASK))
402
+				if (!empty($conf->global->MAIN_UMASK))
403 403
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
404 404
 
405 405
 				$this->result = array('fullpath'=>$file);
406 406
 
407
-				return 1;   // Pas d'erreur
407
+				return 1; // Pas d'erreur
408 408
 			}
409 409
 			else
410 410
 			{
411
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
411
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
412 412
 				return 0;
413 413
 			}
414 414
 		}
415 415
 
416
-		$this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
416
+		$this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
417 417
 		return 0;
418 418
 	}
419 419
 
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 	 *   @param		int			$hidebottom		Hide bottom bar of array
431 431
 	 *   @return	void
432 432
 	 */
433
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
433
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
434 434
 	{
435
-		global $conf,$mysoc;
435
+		global $conf, $mysoc;
436 436
 
437 437
         $default_font_size = pdf_getPDFFontSize($outputlangs);
438 438
 	}
@@ -455,20 +455,20 @@  discard block
 block discarded – undo
455 455
 
456 456
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
457 457
 
458
-	    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE);
458
+	    $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
459 459
 
460
-	    $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs);
460
+	    $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
461 461
 
462 462
 	    $pdf->SetXY($this->marge_gauche, $posy);
463
-	    $pdf->SetFont('','', $default_font_size);
463
+	    $pdf->SetFont('', '', $default_font_size);
464 464
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
465
-	    $posy=$pdf->GetY()+2;
465
+	    $posy = $pdf->GetY() + 2;
466 466
 
467 467
 	    $pdf->SetXY($this->marge_gauche, $posy);
468
-	    $pdf->SetFont('','', $default_font_size - $diffsizetitle);
468
+	    $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
469 469
 	    $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
470 470
 		$pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
471
-		$posy=$pdf->GetY()+2;
471
+		$posy = $pdf->GetY() + 2;
472 472
 
473 473
 	    return $posy;
474 474
 	}
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	    $posx = $this->marge_gauche;
496 496
 	    $pdf->SetXY($posx, $tab_top + 0);
497 497
 
498
-	    $pdf->SetFont('','', $default_font_size - 2);
498
+	    $pdf->SetFont('', '', $default_font_size - 2);
499 499
 
500 500
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
501 501
 	    $pdf->MultiCell(100, 3, ' ');
@@ -503,17 +503,17 @@  discard block
 block discarded – undo
503 503
 
504 504
 	    $posx = 120;
505 505
 	    $largcol = ($this->page_largeur - $this->marge_droite - $posx);
506
-	    $useborder=0;
506
+	    $useborder = 0;
507 507
 	    $index = 0;
508 508
 	    // Total HT
509
-	    $pdf->SetFillColor(255,255,255);
509
+	    $pdf->SetFillColor(255, 255, 255);
510 510
 	    $pdf->SetXY($posx, $tab_top + 0);
511 511
 	    $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
512 512
 
513 513
 	    $pdf->SetXY($posx, $tab_top + $tab_hl);
514
-	    $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
514
+	    $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
515 515
 
516
-	    return ($tab_hl*7);
516
+	    return ($tab_hl * 7);
517 517
 	}
518 518
 
519 519
 
@@ -528,61 +528,61 @@  discard block
 block discarded – undo
528 528
 	 */
529 529
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
530 530
 	{
531
-		global $langs,$conf,$mysoc;
531
+		global $langs, $conf, $mysoc;
532 532
 
533 533
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
534 534
 
535
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
535
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
536 536
 
537
-		$pdf->SetTextColor(0,0,60);
538
-		$pdf->SetFont('','B', $default_font_size + 3);
537
+		$pdf->SetTextColor(0, 0, 60);
538
+		$pdf->SetFont('', 'B', $default_font_size + 3);
539 539
 
540
-        $posx=$this->page_largeur-$this->marge_droite-100;
541
-		$posy=$this->marge_haute;
540
+        $posx = $this->page_largeur - $this->marge_droite - 100;
541
+		$posy = $this->marge_haute;
542 542
 
543
-		$pdf->SetXY($this->marge_gauche,$posy);
543
+		$pdf->SetXY($this->marge_gauche, $posy);
544 544
 
545 545
 		// Logo
546
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
546
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
547 547
 		if ($mysoc->logo)
548 548
 		{
549 549
 			if (is_readable($logo))
550 550
 			{
551
-			    $height=pdf_getHeightForLogo($logo);
552
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
551
+			    $height = pdf_getHeightForLogo($logo);
552
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
553 553
 			}
554 554
 			else
555 555
 			{
556
-				$pdf->SetTextColor(200,0,0);
557
-				$pdf->SetFont('','B', $default_font_size - 2);
558
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
556
+				$pdf->SetTextColor(200, 0, 0);
557
+				$pdf->SetFont('', 'B', $default_font_size - 2);
558
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
559 559
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
560 560
 			}
561 561
 		}
562 562
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
563 563
 
564
-		$pdf->SetFont('','B', $default_font_size + 3);
565
-		$pdf->SetXY($posx,$posy);
566
-		$pdf->SetTextColor(0,0,60);
564
+		$pdf->SetFont('', 'B', $default_font_size + 3);
565
+		$pdf->SetXY($posx, $posy);
566
+		$pdf->SetTextColor(0, 0, 60);
567 567
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R');
568
-		$pdf->SetFont('','', $default_font_size + 2);
568
+		$pdf->SetFont('', '', $default_font_size + 2);
569 569
 
570
-		$posy+=6;
571
-		$pdf->SetXY($posx,$posy);
572
-		$pdf->SetTextColor(0,0,60);
570
+		$posy += 6;
571
+		$pdf->SetXY($posx, $posy);
572
+		$pdf->SetTextColor(0, 0, 60);
573 573
 		$daterum = '__________________';
574
-		if (! empty($object->date_rum))
574
+		if (!empty($object->date_rum))
575 575
 		{
576
-            $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true);
576
+            $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
577 577
 		}
578
-		else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true);   // For old record, the date_rum was not saved.
579
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R');
578
+		else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
579
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
580 580
 		/*$posy+=6;
581 581
 		$pdf->SetXY($posx,$posy);
582 582
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
583 583
 		*/
584 584
 
585
-		$pdf->SetTextColor(0,0,60);
585
+		$pdf->SetTextColor(0, 0, 60);
586 586
 
587 587
 		// Add list of linked objects
588 588
 		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
 	 *      @param	int			$hidefreetext		1=Hide free text
619 619
 	 *      @return	integer
620 620
 	 */
621
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
621
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
622 622
 	{
623 623
 		global $conf;
624
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
625
-		return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
624
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
625
+		return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
626 626
 	}
627 627
 }
Please login to merge, or discard this patch.
Braces   +60 added lines, -30 removed lines patch added patch discarded remove patch
@@ -80,7 +80,10 @@  discard block
 block discarded – undo
80 80
 
81 81
 		// Recupere emmetteur
82 82
 		$this->emetteur=$mysoc;
83
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
83
+		if (! $this->emetteur->country_code) {
84
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
85
+		}
86
+		// By default if not defined
84 87
 
85 88
 		// Defini position des colonnes
86 89
 		$this->posxref=$this->marge_gauche+1;
@@ -110,9 +113,13 @@  discard block
 block discarded – undo
110 113
         // phpcs:enable
111 114
 		global $conf, $hookmanager, $langs, $user, $mysoc;
112 115
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
116
+		if (! is_object($outputlangs)) {
117
+		    $outputlangs=$langs;
118
+		}
114 119
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
120
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
121
+		    $outputlangs->charset_output='ISO-8859-1';
122
+		}
116 123
 
117 124
 		// Load traductions files requiredby by page
118 125
 		$outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
@@ -124,15 +131,20 @@  discard block
 block discarded – undo
124 131
 		    // Definition of $dir and $file
125 132
 		    if ($object->specimen)
126 133
 		    {
127
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
128
-		        else $dir = $conf->bank->dir_output;
134
+		        if (! empty($moreparams['force_dir_output'])) {
135
+		            $dir = $moreparams['force_dir_output'];
136
+		        } else {
137
+		            $dir = $conf->bank->dir_output;
138
+		        }
129 139
 		        $file = $dir . "/SPECIMEN.pdf";
130
-		    }
131
-		    else
140
+		    } else
132 141
 		    {
133 142
 		        $objectref = dol_sanitizeFileName($object->ref);
134
-		        if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
135
-		        else $dir = $conf->bank->dir_output . "/" . $objectref;
143
+		        if (! empty($moreparams['force_dir_output'])) {
144
+		            $dir = $moreparams['force_dir_output'];
145
+		        } else {
146
+		            $dir = $conf->bank->dir_output . "/" . $objectref;
147
+		        }
136 148
 		        $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf";
137 149
 		    }
138 150
 
@@ -163,7 +175,9 @@  discard block
 block discarded – undo
163 175
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
164 176
 		        $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
165 177
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
178
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
179
+	                $heightforfooter+= 6;
180
+	            }
167 181
                 $pdf->SetAutoPageBreak(1,0);
168 182
 
169 183
                 if (class_exists('TCPDF'))
@@ -182,7 +196,9 @@  discard block
 block discarded – undo
182 196
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
183 197
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184 198
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
185
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
199
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
200
+				    $pdf->SetCompression(false);
201
+				}
186 202
 
187 203
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
188 204
 
@@ -213,8 +229,7 @@  discard block
 block discarded – undo
213 229
 
214 230
 					$tab_height = $tab_height - $height_note;
215 231
 					$tab_top = $nexY+6;
216
-				}
217
-				else
232
+				} else
218 233
 				{
219 234
 					$height_note=0;
220 235
 				}
@@ -237,7 +252,9 @@  discard block
 block discarded – undo
237 252
 				$posY+=2;
238 253
 				$pdf->SetXY($this->marge_gauche, $posY);
239 254
 				$ics='';
240
-				if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS;
255
+				if (! empty($conf->global->PRELEVEMENT_ICS)) {
256
+				    $ics=$conf->global->PRELEVEMENT_ICS;
257
+				}
241 258
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L');
242 259
 
243 260
 				$posY=$pdf->GetY();
@@ -274,7 +291,9 @@  discard block
 block discarded – undo
274 291
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
275 292
 
276 293
 				$thirdparty=new Societe($this->db);
277
-				if ($object->socid > 0) $thirdparty->fetch($object->socid);
294
+				if ($object->socid > 0) {
295
+				    $thirdparty->fetch($object->socid);
296
+				}
278 297
 
279 298
 				$sepaname = '______________________________________________';
280 299
 				if ($thirdparty->id > 0)
@@ -307,7 +326,9 @@  discard block
 block discarded – undo
307 326
 				}
308 327
 
309 328
 				$ban = '__________________________________________________';
310
-				if (! empty($object->iban)) $ban = $object->iban;
329
+				if (! empty($object->iban)) {
330
+				    $ban = $object->iban;
331
+				}
311 332
 				$posY=$pdf->GetY();
312 333
 				$posY+=1;
313 334
 				$pdf->SetXY($this->marge_gauche, $posY);
@@ -316,7 +337,9 @@  discard block
 block discarded – undo
316 337
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
317 338
 
318 339
 				$bic = '__________________________________________________';
319
-				if (! empty($object->bic)) $bic = $object->bic;
340
+				if (! empty($object->bic)) {
341
+				    $bic = $object->bic;
342
+				}
320 343
 				$posY=$pdf->GetY();
321 344
 				$posY+=1;
322 345
 				$pdf->SetXY($this->marge_gauche, $posY);
@@ -332,14 +355,18 @@  discard block
 block discarded – undo
332 355
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
333 356
 				$pdf->Rect(80, $posY, 5, 5);
334 357
 				$pdf->SetXY(80, $posY);
335
-				if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L');
358
+				if ($object->frstrecur == 'RECUR') {
359
+				    $pdf->MultiCell(5, 3, 'X', 0, 'L');
360
+				}
336 361
 				$pdf->SetXY(86, $posY);
337 362
 				$txt = $langs->transnoentitiesnoconv("ModeRECUR").'  '.$langs->transnoentitiesnoconv("or");
338 363
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
339 364
 				$posY+=6;
340 365
 				$pdf->Rect(80, $posY, 5, 5);
341 366
 				$pdf->SetXY(80, $posY);
342
-				if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L');
367
+				if ($object->frstrecur == 'FRST') {
368
+				    $pdf->MultiCell(5, 3, 'X', 0, 'L');
369
+				}
343 370
 				$pdf->SetXY(86, $posY);
344 371
 				$txt = $langs->transnoentitiesnoconv("ModeFRST");
345 372
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
@@ -362,8 +389,7 @@  discard block
 block discarded – undo
362 389
 				{
363 390
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
364 391
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
365
-				}
366
-				else
392
+				} else
367 393
 				{
368 394
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
369 395
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -382,7 +408,9 @@  discard block
 block discarded – undo
382 408
 				 * Pied de page
383 409
 				 */
384 410
 				$this->_pagefoot($pdf,$object,$outputlangs);
385
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
411
+				if (method_exists($pdf,'AliasNbPages')) {
412
+				    $pdf->AliasNbPages();
413
+				}
386 414
 
387 415
 				$pdf->Close();
388 416
 
@@ -399,14 +427,14 @@  discard block
 block discarded – undo
399 427
 				global $action;
400 428
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
401 429
 
402
-				if (! empty($conf->global->MAIN_UMASK))
403
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
430
+				if (! empty($conf->global->MAIN_UMASK)) {
431
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
432
+				}
404 433
 
405 434
 				$this->result = array('fullpath'=>$file);
406 435
 
407 436
 				return 1;   // Pas d'erreur
408
-			}
409
-			else
437
+			} else
410 438
 			{
411 439
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
412 440
 				return 0;
@@ -550,16 +578,16 @@  discard block
 block discarded – undo
550 578
 			{
551 579
 			    $height=pdf_getHeightForLogo($logo);
552 580
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
553
-			}
554
-			else
581
+			} else
555 582
 			{
556 583
 				$pdf->SetTextColor(200,0,0);
557 584
 				$pdf->SetFont('','B', $default_font_size - 2);
558 585
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
559 586
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
560 587
 			}
588
+		} else {
589
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
561 590
 		}
562
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
563 591
 
564 592
 		$pdf->SetFont('','B', $default_font_size + 3);
565 593
 		$pdf->SetXY($posx,$posy);
@@ -574,8 +602,10 @@  discard block
 block discarded – undo
574 602
 		if (! empty($object->date_rum))
575 603
 		{
576 604
             $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true);
605
+		} else {
606
+		    $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true);
577 607
 		}
578
-		else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true);   // For old record, the date_rum was not saved.
608
+		// For old record, the date_rum was not saved.
579 609
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R');
580 610
 		/*$posy+=6;
581 611
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.