Passed
Push — master ( 222e44...208bd5 )
by Alxarafe
31:22
created
dolibarr/htdocs/core/modules/rapport/pdf_paiement.class.php 3 patches
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -32,100 +32,100 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class pdf_paiement
34 34
 {
35
-	/**
35
+    /**
36 36
      *  Constructor
37 37
      *
38 38
      *  @param      DoliDb		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-		global $langs,$conf;
39
+     */
40
+    function __construct($db)
41
+    {
42
+        global $langs,$conf;
43 43
 
44
-		// Load translation files required by the page
44
+        // Load translation files required by the page
45 45
         $langs->loadLangs(array("bills","compta","main"));
46 46
 
47
-		$this->db = $db;
48
-		$this->description = $langs->transnoentities("ListOfCustomerPayments");
49
-
50
-		// Dimension page pour format A4
51
-		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
53
-		$this->page_largeur = $formatarray['width'];
54
-		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
60
-
61
-		$this->tab_top = 30;
62
-
63
-		$this->line_height = 5;
64
-		$this->line_per_page = 40;
65
-		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
-
67
-		$this->posxdate=$this->marge_gauche+2;
68
-		$this->posxpaymenttype=42;
69
-		$this->posxinvoice=82;
70
-		$this->posxbankaccount=110;
71
-		$this->posxinvoiceamount=132;
72
-		$this->posxpaymentamount=162;
73
-		if ($this->page_largeur < 210) // To work with US executive format
74
-		{
75
-			$this->line_per_page = 35;
76
-			$this->posxpaymenttype-=10;
77
-			$this->posxinvoice-=0;
78
-			$this->posxinvoiceamount-=10;
79
-			$this->posxpaymentamount-=20;
80
-		}
81
-		// which type of document will be generated: clients (client) or providers (fourn) invoices
82
-		$this->doc_type = "client";
83
-	}
47
+        $this->db = $db;
48
+        $this->description = $langs->transnoentities("ListOfCustomerPayments");
49
+
50
+        // Dimension page pour format A4
51
+        $this->type = 'pdf';
52
+        $formatarray=pdf_getFormat();
53
+        $this->page_largeur = $formatarray['width'];
54
+        $this->page_hauteur = $formatarray['height'];
55
+        $this->format = array($this->page_largeur,$this->page_hauteur);
56
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
60
+
61
+        $this->tab_top = 30;
62
+
63
+        $this->line_height = 5;
64
+        $this->line_per_page = 40;
65
+        $this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
+
67
+        $this->posxdate=$this->marge_gauche+2;
68
+        $this->posxpaymenttype=42;
69
+        $this->posxinvoice=82;
70
+        $this->posxbankaccount=110;
71
+        $this->posxinvoiceamount=132;
72
+        $this->posxpaymentamount=162;
73
+        if ($this->page_largeur < 210) // To work with US executive format
74
+        {
75
+            $this->line_per_page = 35;
76
+            $this->posxpaymenttype-=10;
77
+            $this->posxinvoice-=0;
78
+            $this->posxinvoiceamount-=10;
79
+            $this->posxpaymentamount-=20;
80
+        }
81
+        // which type of document will be generated: clients (client) or providers (fourn) invoices
82
+        $this->doc_type = "client";
83
+    }
84 84
 
85 85
 
86 86
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
87
-	/**
88
-	 *	Fonction generant la rapport sur le disque
89
-	 *
90
-	 *	@param	string	$_dir			repertoire
91
-	 *	@param	int		$month			mois du rapport
92
-	 *	@param	int		$year			annee du rapport
93
-	 *	@param	string	$outputlangs	Lang output object
94
-	 *	@return	int						<0 if KO, >0 if OK
95
-	 */
96
-	function write_file($_dir, $month, $year, $outputlangs)
97
-	{
87
+    /**
88
+     *	Fonction generant la rapport sur le disque
89
+     *
90
+     *	@param	string	$_dir			repertoire
91
+     *	@param	int		$month			mois du rapport
92
+     *	@param	int		$year			annee du rapport
93
+     *	@param	string	$outputlangs	Lang output object
94
+     *	@return	int						<0 if KO, >0 if OK
95
+     */
96
+    function write_file($_dir, $month, $year, $outputlangs)
97
+    {
98 98
         // phpcs:enable
99
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
99
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
100 100
 
101
-		global $conf, $hookmanager, $langs, $user;
101
+        global $conf, $hookmanager, $langs, $user;
102 102
 
103
-		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
103
+        $socid=0;
104
+        if ($user->societe_id) $socid=$user->societe_id;
105 105
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
107
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
106
+        if (! is_object($outputlangs)) $outputlangs=$langs;
107
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
109 109
 
110
-		$this->month=$month;
111
-		$this->year=$year;
112
-		$dir=$_dir.'/'.$year;
110
+        $this->month=$month;
111
+        $this->year=$year;
112
+        $dir=$_dir.'/'.$year;
113 113
 
114
-		if (! is_dir($dir))
115
-		{
116
-			$result=dol_mkdir($dir);
117
-			if ($result < 0)
118
-			{
119
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
120
-				return -1;
121
-			}
122
-		}
114
+        if (! is_dir($dir))
115
+        {
116
+            $result=dol_mkdir($dir);
117
+            if ($result < 0)
118
+            {
119
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
120
+                return -1;
121
+            }
122
+        }
123 123
 
124
-		$month = sprintf("%02d",$month);
125
-		$year = sprintf("%04d",$year);
124
+        $month = sprintf("%02d",$month);
125
+        $year = sprintf("%04d",$year);
126 126
 
127
-		$file = $dir . "/payments-".$year."-".$month.".pdf";
128
-		switch ($this->doc_type) {
127
+        $file = $dir . "/payments-".$year."-".$month.".pdf";
128
+        switch ($this->doc_type) {
129 129
             case "client":
130 130
                 $file = $dir . "/payments-".$year."-".$month.".pdf";
131 131
                 break;
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
         }
136 136
 
137 137
 
138
-		// Add pdfgeneration hook
139
-		if (! is_object($hookmanager))
140
-		{
141
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
-			$hookmanager=new HookManager($this->db);
143
-		}
144
-		$hookmanager->initHooks(array('pdfgeneration'));
145
-		$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
146
-		global $action;
147
-		$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
138
+        // Add pdfgeneration hook
139
+        if (! is_object($hookmanager))
140
+        {
141
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
+            $hookmanager=new HookManager($this->db);
143
+        }
144
+        $hookmanager->initHooks(array('pdfgeneration'));
145
+        $parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
146
+        global $action;
147
+        $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
148 148
 
149 149
         $pdf=pdf_getInstance($this->format);
150 150
         $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
         $num=0;
160 160
         $lines=array();
161 161
 
162
-		// count number of lines of payment
163
-		$sql = "SELECT p.rowid as prowid";
164
-		switch ($this->doc_type) {
162
+        // count number of lines of payment
163
+        $sql = "SELECT p.rowid as prowid";
164
+        switch ($this->doc_type) {
165 165
             case "client":
166 166
                 $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
167 167
                 break;
@@ -169,192 +169,192 @@  discard block
 block discarded – undo
169 169
                 $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
170 170
                 break;
171 171
         }
172
-		$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
-		$sql.= " AND p.entity = " . $conf->entity;
174
-		$result = $this->db->query($sql);
175
-		if ($result)
176
-		{
177
-			$numpaiement = $this->db->num_rows($result);
178
-		}
179
-
180
-		// number of bill
181
-		switch ($this->doc_type) {
182
-			case "client":
183
-				$sql = "SELECT p.datep as dp, f.ref";
184
-				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
-				$sql.= ", c.code as paiement_code, p.num_paiement";
186
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
-				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
190
-				$sql.= ", p.rowid as prowid";
191
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
-				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
-				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197
-				if (! $user->rights->societe->client->voir && ! $socid)
198
-				{
199
-					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200
-				}
201
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
-				$sql.= " AND f.entity = ".$conf->entity;
205
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
-				if (! $user->rights->societe->client->voir && ! $socid)
207
-				{
208
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209
-				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212
-				break;
213
-			case "fourn":
214
-				$sql = "SELECT p.datep as dp, f.ref as ref";
215
-				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
-				$sql.= ", c.code as paiement_code, p.num_paiement";
217
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
-				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
221
-				$sql.= ", p.rowid as prowid";
222
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
-				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
-				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228
-				if (! $user->rights->societe->client->voir && ! $socid)
229
-				{
230
-					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231
-				}
232
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
-				$sql.= " AND f.entity = ".$conf->entity;
236
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
-				if (! $user->rights->societe->client->voir && ! $socid)
238
-				{
239
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240
-				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243
-				break;
244
-		}
245
-
246
-		dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
247
-		$result = $this->db->query($sql);
248
-		if ($result)
249
-		{
250
-			$num = $this->db->num_rows($result);
251
-			$i = 0;
252
-
253
-			while ($i < $num)
254
-			{
255
-				$objp = $this->db->fetch_object($result);
256
-
257
-				$lines[$i][0] = $objp->ref;
258
-				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
259
-				$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260
-				$lines[$i][3] = $objp->num_paiement;
261
-				$lines[$i][4] = price($objp->paiement_amount);
262
-				$lines[$i][5] = price($objp->facture_amount);
263
-				$lines[$i][6] = price($objp->pf_amount);
264
-				$lines[$i][7] = $objp->prowid;
265
-				$lines[$i][8] = $objp->bankaccount;
266
-				$lines[$i][9] = $objp->paiement_amount;
267
-				$i++;
268
-			}
269
-		}
270
-		else
271
-		{
272
-			dol_print_error($this->db);
273
-		}
274
-
275
-		$pages = intval(($num + $numpaiement) / $this->line_per_page);
276
-
277
-		if ((($num + $numpaiement) % $this->line_per_page)>0)
278
-		{
279
-			$pages++;
280
-		}
281
-
282
-		if ($pages == 0)
283
-		{
284
-			// force to build at least one page if report has no line
285
-			$pages = 1;
286
-		}
287
-
288
-		$pdf->Open();
289
-		$pagenb=0;
290
-		$pdf->SetDrawColor(128,128,128);
291
-
292
-		$pdf->SetTitle($outputlangs->transnoentities("Payments"));
293
-		$pdf->SetSubject($outputlangs->transnoentities("Payments"));
294
-		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295
-		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296
-		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298
-
299
-		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
-		$pdf->SetAutoPageBreak(1,0);
301
-
302
-		// New page
303
-		$pdf->AddPage();
304
-		$pagenb++;
305
-		$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
-		$pdf->SetFont('','', 9);
307
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
308
-		$pdf->SetTextColor(0,0,0);
309
-
310
-
311
-		$this->Body($pdf, 1, $lines, $outputlangs);
312
-
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
314
-
315
-		$pdf->Close();
316
-
317
-		$pdf->Output($file,'F');
318
-
319
-		// Add pdfgeneration hook
320
-		if (! is_object($hookmanager))
321
-		{
322
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
-			$hookmanager=new HookManager($this->db);
324
-		}
325
-		$hookmanager->initHooks(array('pdfgeneration'));
326
-		$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
327
-		global $action;
328
-		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329
-
330
-		if (! empty($conf->global->MAIN_UMASK))
331
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
332
-
333
-		$this->result = array('fullpath'=>$file);
334
-
335
-		return 1;
336
-	}
337
-
338
-	/**
339
-	 *  Show top header of page.
340
-	 *
341
-	 *  @param	PDF			$pdf     		Object PDF
342
-	 *  @param  int			$page	     	Object to show
343
-	 *  @param  int	    	$showaddress    0=no, 1=yes
344
-	 *  @param  Translate	$outputlangs	Object lang for output
345
-	 *  @return	void
346
-	 */
347
-	function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
348
-	{
349
-		global $langs, $conf;
350
-
351
-		// Do not add the BACKGROUND as this is a report
352
-		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
353
-
354
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
355
-
356
-		$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
-		switch($this->doc_type) {
172
+        $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
+        $sql.= " AND p.entity = " . $conf->entity;
174
+        $result = $this->db->query($sql);
175
+        if ($result)
176
+        {
177
+            $numpaiement = $this->db->num_rows($result);
178
+        }
179
+
180
+        // number of bill
181
+        switch ($this->doc_type) {
182
+            case "client":
183
+                $sql = "SELECT p.datep as dp, f.ref";
184
+                //$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
+                $sql.= ", c.code as paiement_code, p.num_paiement";
186
+                $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
+                $sql.= ", pf.amount as pf_amount";
188
+                if (! empty($conf->banque->enabled))
189
+                    $sql.= ", ba.ref as bankaccount";
190
+                $sql.= ", p.rowid as prowid";
191
+                $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
+                $sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
+                $sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
+                if (! empty($conf->banque->enabled))
195
+                    $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
+                $sql.= " ".MAIN_DB_PREFIX."societe as s";
197
+                if (! $user->rights->societe->client->voir && ! $socid)
198
+                {
199
+                    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200
+                }
201
+                $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
+                if (! empty($conf->banque->enabled))
203
+                    $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
+                $sql.= " AND f.entity = ".$conf->entity;
205
+                $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
+                if (! $user->rights->societe->client->voir && ! $socid)
207
+                {
208
+                    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209
+                }
210
+                if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
+                $sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212
+                break;
213
+            case "fourn":
214
+                $sql = "SELECT p.datep as dp, f.ref as ref";
215
+                //$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
+                $sql.= ", c.code as paiement_code, p.num_paiement";
217
+                $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
+                $sql.= ", pf.amount as pf_amount";
219
+                if (! empty($conf->banque->enabled))
220
+                    $sql.= ", ba.ref as bankaccount";
221
+                $sql.= ", p.rowid as prowid";
222
+                $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
+                $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
+                $sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
+                if (! empty($conf->banque->enabled))
226
+                    $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
+                $sql.= " ".MAIN_DB_PREFIX."societe as s";
228
+                if (! $user->rights->societe->client->voir && ! $socid)
229
+                {
230
+                    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231
+                }
232
+                $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
+                if (! empty($conf->banque->enabled))
234
+                    $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
+                $sql.= " AND f.entity = ".$conf->entity;
236
+                $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
+                if (! $user->rights->societe->client->voir && ! $socid)
238
+                {
239
+                    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240
+                }
241
+                if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
+                $sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243
+                break;
244
+        }
245
+
246
+        dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
247
+        $result = $this->db->query($sql);
248
+        if ($result)
249
+        {
250
+            $num = $this->db->num_rows($result);
251
+            $i = 0;
252
+
253
+            while ($i < $num)
254
+            {
255
+                $objp = $this->db->fetch_object($result);
256
+
257
+                $lines[$i][0] = $objp->ref;
258
+                $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
259
+                $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260
+                $lines[$i][3] = $objp->num_paiement;
261
+                $lines[$i][4] = price($objp->paiement_amount);
262
+                $lines[$i][5] = price($objp->facture_amount);
263
+                $lines[$i][6] = price($objp->pf_amount);
264
+                $lines[$i][7] = $objp->prowid;
265
+                $lines[$i][8] = $objp->bankaccount;
266
+                $lines[$i][9] = $objp->paiement_amount;
267
+                $i++;
268
+            }
269
+        }
270
+        else
271
+        {
272
+            dol_print_error($this->db);
273
+        }
274
+
275
+        $pages = intval(($num + $numpaiement) / $this->line_per_page);
276
+
277
+        if ((($num + $numpaiement) % $this->line_per_page)>0)
278
+        {
279
+            $pages++;
280
+        }
281
+
282
+        if ($pages == 0)
283
+        {
284
+            // force to build at least one page if report has no line
285
+            $pages = 1;
286
+        }
287
+
288
+        $pdf->Open();
289
+        $pagenb=0;
290
+        $pdf->SetDrawColor(128,128,128);
291
+
292
+        $pdf->SetTitle($outputlangs->transnoentities("Payments"));
293
+        $pdf->SetSubject($outputlangs->transnoentities("Payments"));
294
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
295
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296
+        //$pdf->SetKeyWords();
297
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298
+
299
+        $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
+        $pdf->SetAutoPageBreak(1,0);
301
+
302
+        // New page
303
+        $pdf->AddPage();
304
+        $pagenb++;
305
+        $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
+        $pdf->SetFont('','', 9);
307
+        $pdf->MultiCell(0, 3, '');		// Set interline to 3
308
+        $pdf->SetTextColor(0,0,0);
309
+
310
+
311
+        $this->Body($pdf, 1, $lines, $outputlangs);
312
+
313
+        if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
314
+
315
+        $pdf->Close();
316
+
317
+        $pdf->Output($file,'F');
318
+
319
+        // Add pdfgeneration hook
320
+        if (! is_object($hookmanager))
321
+        {
322
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
+            $hookmanager=new HookManager($this->db);
324
+        }
325
+        $hookmanager->initHooks(array('pdfgeneration'));
326
+        $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
327
+        global $action;
328
+        $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329
+
330
+        if (! empty($conf->global->MAIN_UMASK))
331
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
332
+
333
+        $this->result = array('fullpath'=>$file);
334
+
335
+        return 1;
336
+    }
337
+
338
+    /**
339
+     *  Show top header of page.
340
+     *
341
+     *  @param	PDF			$pdf     		Object PDF
342
+     *  @param  int			$page	     	Object to show
343
+     *  @param  int	    	$showaddress    0=no, 1=yes
344
+     *  @param  Translate	$outputlangs	Object lang for output
345
+     *  @return	void
346
+     */
347
+    function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
348
+    {
349
+        global $langs, $conf;
350
+
351
+        // Do not add the BACKGROUND as this is a report
352
+        //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
353
+
354
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
355
+
356
+        $title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
+        switch($this->doc_type) {
358 358
             case "client":
359 359
                 $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
360 360
                 break;
@@ -362,139 +362,139 @@  discard block
 block discarded – undo
362 362
                 $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
363 363
                 break;
364 364
         }
365
-		$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
-		$pdf->SetFont('','B',$default_font_size + 1);
367
-		$pdf->SetXY($this->marge_gauche,10);
368
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
365
+        $title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
+        $pdf->SetFont('','B',$default_font_size + 1);
367
+        $pdf->SetXY($this->marge_gauche,10);
368
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
369 369
 
370
-		$pdf->SetFont('','',$default_font_size);
370
+        $pdf->SetFont('','',$default_font_size);
371 371
 
372 372
         $pdf->SetXY($this->posxdate, 16);
373
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
373
+        $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
374 374
 
375 375
         $pdf->SetXY($this->posxdate+100, 16);
376
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
376
+        $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
377 377
 
378 378
 
379
-		// Title line
379
+        // Title line
380 380
         $pdf->SetXY($this->posxdate, $this->tab_top+2);
381
-		$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
381
+        $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
382 382
 
383
-		$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
383
+        $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
384 384
         $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2);
385
-		$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
385
+        $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
386 386
 
387
-		$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
387
+        $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
388 388
         $pdf->SetXY($this->posxinvoice, $this->tab_top+2);
389
-		$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
389
+        $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
390 390
 
391
-		$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
391
+        $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
392 392
         $pdf->SetXY($this->posxbankaccount, $this->tab_top+2);
393
-		$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
393
+        $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
394 394
 
395 395
 
396
-		$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
396
+        $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
397 397
         $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2);
398
-		$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
398
+        $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
399 399
 
400
-		$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
400
+        $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
401 401
         $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2);
402
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
402
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
403 403
 
404
-		$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
404
+        $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
405 405
 
406
-		$pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
407
-	}
406
+        $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
407
+    }
408 408
 
409 409
 
410 410
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
411
-	/**
412
-	 *	Output body
413
-	 *
414
-	 *	@param	PDF			$pdf			PDF object
415
-	 *	@param	string		$page			Page
416
-	 *	@param	array		$lines			Array of lines
417
-	 *	@param	Translate	$outputlangs	Object langs
418
-	 *	@return	void
419
-	 */
420
-	function Body(&$pdf, $page, $lines, $outputlangs)
421
-	{
411
+    /**
412
+     *	Output body
413
+     *
414
+     *	@param	PDF			$pdf			PDF object
415
+     *	@param	string		$page			Page
416
+     *	@param	array		$lines			Array of lines
417
+     *	@param	Translate	$outputlangs	Object langs
418
+     *	@return	void
419
+     */
420
+    function Body(&$pdf, $page, $lines, $outputlangs)
421
+    {
422 422
         // phpcs:enable
423
-		global $langs;
424
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
425
-
426
-		$pdf->SetFont('','', $default_font_size - 1);
427
-		$oldprowid = 0;
428
-		$total_page = 0;
429
-		$total = 0;
430
-		$pdf->SetFillColor(220,220,220);
431
-		$yp = 0;
432
-		$numlines=count($lines);
433
-		for ($j = 0 ; $j < $numlines ; $j++)
434
-		{
435
-			$i = $j;
436
-			if ($yp > $this->tab_height -5)
437
-			{
438
-				$page++;
439
-				$pdf->AddPage();
440
-				$this->_pagehead($pdf, $page, 0, $outputlangs);
441
-				$pdf->SetFont('','', $default_font_size - 1);
442
-				$yp = 0;
443
-			}
444
-			if ($oldprowid <> $lines[$j][7])
445
-			{
446
-				if ($yp > $this->tab_height -15)
447
-				{
448
-					$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
-					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450
-					$page++;
451
-					$pdf->AddPage();
452
-					$this->_pagehead($pdf, $page, 0, $outputlangs);
453
-					$pdf->SetFont('','', $default_font_size - 1);
454
-					$yp = 0;
455
-					$total += $total_page;
456
-					$total_page = 0;
457
-				}
458
-
459
-				$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
460
-				$pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
461
-
462
-				$pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
463
-				$pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464
-
465
-				$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
-				$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467
-
468
-				$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469
-				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
470
-				$yp = $yp + 5;
471
-				$total_page += $lines[$j][9];
472
-			}
473
-
474
-			// Invoice number
475
-			$pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
476
-			$pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
477
-
478
-			// BankAccount
479
-			$pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
480
-			$pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
481
-
482
-			// Invoice amount
483
-			$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
-			$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485
-
486
-			// Payment amount
487
-			$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
488
-			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
489
-			$yp = $yp + 5;
490
-
491
-			if ($oldprowid <> $lines[$j][7])
492
-			{
493
-				$oldprowid = $lines[$j][7];
494
-			}
495
-		}
496
-		$total += $total_page;
497
-		$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
498
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);
499
-	}
423
+        global $langs;
424
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
425
+
426
+        $pdf->SetFont('','', $default_font_size - 1);
427
+        $oldprowid = 0;
428
+        $total_page = 0;
429
+        $total = 0;
430
+        $pdf->SetFillColor(220,220,220);
431
+        $yp = 0;
432
+        $numlines=count($lines);
433
+        for ($j = 0 ; $j < $numlines ; $j++)
434
+        {
435
+            $i = $j;
436
+            if ($yp > $this->tab_height -5)
437
+            {
438
+                $page++;
439
+                $pdf->AddPage();
440
+                $this->_pagehead($pdf, $page, 0, $outputlangs);
441
+                $pdf->SetFont('','', $default_font_size - 1);
442
+                $yp = 0;
443
+            }
444
+            if ($oldprowid <> $lines[$j][7])
445
+            {
446
+                if ($yp > $this->tab_height -15)
447
+                {
448
+                    $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
+                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450
+                    $page++;
451
+                    $pdf->AddPage();
452
+                    $this->_pagehead($pdf, $page, 0, $outputlangs);
453
+                    $pdf->SetFont('','', $default_font_size - 1);
454
+                    $yp = 0;
455
+                    $total += $total_page;
456
+                    $total_page = 0;
457
+                }
458
+
459
+                $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
460
+                $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
461
+
462
+                $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
463
+                $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464
+
465
+                $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
+                $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467
+
468
+                $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469
+                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
470
+                $yp = $yp + 5;
471
+                $total_page += $lines[$j][9];
472
+            }
473
+
474
+            // Invoice number
475
+            $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
476
+            $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
477
+
478
+            // BankAccount
479
+            $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
480
+            $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
481
+
482
+            // Invoice amount
483
+            $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
+            $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485
+
486
+            // Payment amount
487
+            $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
488
+            $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
489
+            $yp = $yp + 5;
490
+
491
+            if ($oldprowid <> $lines[$j][7])
492
+            {
493
+                $oldprowid = $lines[$j][7];
494
+            }
495
+        }
496
+        $total += $total_page;
497
+        $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
498
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);
499
+    }
500 500
 }
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -39,44 +39,44 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	function __construct($db)
41 41
 	{
42
-		global $langs,$conf;
42
+		global $langs, $conf;
43 43
 
44 44
 		// Load translation files required by the page
45
-        $langs->loadLangs(array("bills","compta","main"));
45
+        $langs->loadLangs(array("bills", "compta", "main"));
46 46
 
47 47
 		$this->db = $db;
48 48
 		$this->description = $langs->transnoentities("ListOfCustomerPayments");
49 49
 
50 50
 		// Dimension page pour format A4
51 51
 		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
52
+		$formatarray = pdf_getFormat();
53 53
 		$this->page_largeur = $formatarray['width'];
54 54
 		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
55
+		$this->format = array($this->page_largeur, $this->page_hauteur);
56
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
57
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
58
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
59
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
60 60
 
61 61
 		$this->tab_top = 30;
62 62
 
63 63
 		$this->line_height = 5;
64 64
 		$this->line_per_page = 40;
65
-		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
-
67
-		$this->posxdate=$this->marge_gauche+2;
68
-		$this->posxpaymenttype=42;
69
-		$this->posxinvoice=82;
70
-		$this->posxbankaccount=110;
71
-		$this->posxinvoiceamount=132;
72
-		$this->posxpaymentamount=162;
65
+		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; // must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
+
67
+		$this->posxdate = $this->marge_gauche + 2;
68
+		$this->posxpaymenttype = 42;
69
+		$this->posxinvoice = 82;
70
+		$this->posxbankaccount = 110;
71
+		$this->posxinvoiceamount = 132;
72
+		$this->posxpaymentamount = 162;
73 73
 		if ($this->page_largeur < 210) // To work with US executive format
74 74
 		{
75 75
 			$this->line_per_page = 35;
76
-			$this->posxpaymenttype-=10;
77
-			$this->posxinvoice-=0;
78
-			$this->posxinvoiceamount-=10;
79
-			$this->posxpaymentamount-=20;
76
+			$this->posxpaymenttype -= 10;
77
+			$this->posxinvoice -= 0;
78
+			$this->posxinvoiceamount -= 10;
79
+			$this->posxpaymentamount -= 20;
80 80
 		}
81 81
 		// which type of document will be generated: clients (client) or providers (fourn) invoices
82 82
 		$this->doc_type = "client";
@@ -100,54 +100,54 @@  discard block
 block discarded – undo
100 100
 
101 101
 		global $conf, $hookmanager, $langs, $user;
102 102
 
103
-		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
103
+		$socid = 0;
104
+		if ($user->societe_id) $socid = $user->societe_id;
105 105
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
106
+		if (!is_object($outputlangs)) $outputlangs = $langs;
107 107
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
108
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
109 109
 
110
-		$this->month=$month;
111
-		$this->year=$year;
112
-		$dir=$_dir.'/'.$year;
110
+		$this->month = $month;
111
+		$this->year = $year;
112
+		$dir = $_dir.'/'.$year;
113 113
 
114
-		if (! is_dir($dir))
114
+		if (!is_dir($dir))
115 115
 		{
116
-			$result=dol_mkdir($dir);
116
+			$result = dol_mkdir($dir);
117 117
 			if ($result < 0)
118 118
 			{
119
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
119
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
120 120
 				return -1;
121 121
 			}
122 122
 		}
123 123
 
124
-		$month = sprintf("%02d",$month);
125
-		$year = sprintf("%04d",$year);
124
+		$month = sprintf("%02d", $month);
125
+		$year = sprintf("%04d", $year);
126 126
 
127
-		$file = $dir . "/payments-".$year."-".$month.".pdf";
127
+		$file = $dir."/payments-".$year."-".$month.".pdf";
128 128
 		switch ($this->doc_type) {
129 129
             case "client":
130
-                $file = $dir . "/payments-".$year."-".$month.".pdf";
130
+                $file = $dir."/payments-".$year."-".$month.".pdf";
131 131
                 break;
132 132
             case "fourn":
133
-                $file = $dir . "/supplier_payments-".$year."-".$month.".pdf";
133
+                $file = $dir."/supplier_payments-".$year."-".$month.".pdf";
134 134
                 break;
135 135
         }
136 136
 
137 137
 
138 138
 		// Add pdfgeneration hook
139
-		if (! is_object($hookmanager))
139
+		if (!is_object($hookmanager))
140 140
 		{
141 141
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
-			$hookmanager=new HookManager($this->db);
142
+			$hookmanager = new HookManager($this->db);
143 143
 		}
144 144
 		$hookmanager->initHooks(array('pdfgeneration'));
145
-		$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
145
+		$parameters = array('file'=>$file, 'outputlangs'=>$outputlangs);
146 146
 		global $action;
147
-		$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
147
+		$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
148 148
 
149
-        $pdf=pdf_getInstance($this->format);
150
-        $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
149
+        $pdf = pdf_getInstance($this->format);
150
+        $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
151 151
 
152 152
         if (class_exists('TCPDF'))
153 153
         {
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
         }
157 157
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
158 158
 
159
-        $num=0;
160
-        $lines=array();
159
+        $num = 0;
160
+        $lines = array();
161 161
 
162 162
 		// count number of lines of payment
163 163
 		$sql = "SELECT p.rowid as prowid";
164 164
 		switch ($this->doc_type) {
165 165
             case "client":
166
-                $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
166
+                $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
167 167
                 break;
168 168
             case "fourn":
169
-                $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
169
+                $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
170 170
                 break;
171 171
         }
172
-		$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
-		$sql.= " AND p.entity = " . $conf->entity;
172
+		$sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
173
+		$sql .= " AND p.entity = ".$conf->entity;
174 174
 		$result = $this->db->query($sql);
175 175
 		if ($result)
176 176
 		{
@@ -182,64 +182,64 @@  discard block
 block discarded – undo
182 182
 			case "client":
183 183
 				$sql = "SELECT p.datep as dp, f.ref";
184 184
 				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
-				$sql.= ", c.code as paiement_code, p.num_paiement";
186
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
-				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
190
-				$sql.= ", p.rowid as prowid";
191
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
-				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
-				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197
-				if (! $user->rights->societe->client->voir && ! $socid)
185
+				$sql .= ", c.code as paiement_code, p.num_paiement";
186
+				$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
+				$sql .= ", pf.amount as pf_amount";
188
+				if (!empty($conf->banque->enabled))
189
+					$sql .= ", ba.ref as bankaccount";
190
+				$sql .= ", p.rowid as prowid";
191
+				$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
+				$sql .= ", ".MAIN_DB_PREFIX."facture as f,";
193
+				$sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
+				if (!empty($conf->banque->enabled))
195
+					$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
+				$sql .= " ".MAIN_DB_PREFIX."societe as s";
197
+				if (!$user->rights->societe->client->voir && !$socid)
198 198
 				{
199 199
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200 200
 				}
201
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
-				$sql.= " AND f.entity = ".$conf->entity;
205
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
-				if (! $user->rights->societe->client->voir && ! $socid)
201
+				$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
+				if (!empty($conf->banque->enabled))
203
+					$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
+				$sql .= " AND f.entity = ".$conf->entity;
205
+				$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
206
+				if (!$user->rights->societe->client->voir && !$socid)
207 207
 				{
208
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
208
+					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
209 209
 				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
210
+				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212 212
 				break;
213 213
 			case "fourn":
214 214
 				$sql = "SELECT p.datep as dp, f.ref as ref";
215 215
 				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
-				$sql.= ", c.code as paiement_code, p.num_paiement";
217
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
-				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
221
-				$sql.= ", p.rowid as prowid";
222
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
-				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
-				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228
-				if (! $user->rights->societe->client->voir && ! $socid)
216
+				$sql .= ", c.code as paiement_code, p.num_paiement";
217
+				$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
+				$sql .= ", pf.amount as pf_amount";
219
+				if (!empty($conf->banque->enabled))
220
+					$sql .= ", ba.ref as bankaccount";
221
+				$sql .= ", p.rowid as prowid";
222
+				$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
+				$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
+				$sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
+				if (!empty($conf->banque->enabled))
226
+					$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
+				$sql .= " ".MAIN_DB_PREFIX."societe as s";
228
+				if (!$user->rights->societe->client->voir && !$socid)
229 229
 				{
230 230
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231 231
 				}
232
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
-				$sql.= " AND f.entity = ".$conf->entity;
236
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
-				if (! $user->rights->societe->client->voir && ! $socid)
232
+				$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
+				if (!empty($conf->banque->enabled))
234
+					$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
+				$sql .= " AND f.entity = ".$conf->entity;
236
+				$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
237
+				if (!$user->rights->societe->client->voir && !$socid)
238 238
 				{
239
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
239
+					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
240 240
 				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
241
+				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243 243
 				break;
244 244
 		}
245 245
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				$objp = $this->db->fetch_object($result);
256 256
 
257 257
 				$lines[$i][0] = $objp->ref;
258
-				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
258
+				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
259 259
 				$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260 260
 				$lines[$i][3] = $objp->num_paiement;
261 261
 				$lines[$i][4] = price($objp->paiement_amount);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$pages = intval(($num + $numpaiement) / $this->line_per_page);
276 276
 
277
-		if ((($num + $numpaiement) % $this->line_per_page)>0)
277
+		if ((($num + $numpaiement) % $this->line_per_page) > 0)
278 278
 		{
279 279
 			$pages++;
280 280
 		}
@@ -286,48 +286,48 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 
288 288
 		$pdf->Open();
289
-		$pagenb=0;
290
-		$pdf->SetDrawColor(128,128,128);
289
+		$pagenb = 0;
290
+		$pdf->SetDrawColor(128, 128, 128);
291 291
 
292 292
 		$pdf->SetTitle($outputlangs->transnoentities("Payments"));
293 293
 		$pdf->SetSubject($outputlangs->transnoentities("Payments"));
294 294
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295 295
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 296
 		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
297
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298 298
 
299
-		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
-		$pdf->SetAutoPageBreak(1,0);
299
+		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
300
+		$pdf->SetAutoPageBreak(1, 0);
301 301
 
302 302
 		// New page
303 303
 		$pdf->AddPage();
304 304
 		$pagenb++;
305 305
 		$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
-		$pdf->SetFont('','', 9);
307
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
308
-		$pdf->SetTextColor(0,0,0);
306
+		$pdf->SetFont('', '', 9);
307
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
308
+		$pdf->SetTextColor(0, 0, 0);
309 309
 
310 310
 
311 311
 		$this->Body($pdf, 1, $lines, $outputlangs);
312 312
 
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
313
+		if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
314 314
 
315 315
 		$pdf->Close();
316 316
 
317
-		$pdf->Output($file,'F');
317
+		$pdf->Output($file, 'F');
318 318
 
319 319
 		// Add pdfgeneration hook
320
-		if (! is_object($hookmanager))
320
+		if (!is_object($hookmanager))
321 321
 		{
322 322
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
-			$hookmanager=new HookManager($this->db);
323
+			$hookmanager = new HookManager($this->db);
324 324
 		}
325 325
 		$hookmanager->initHooks(array('pdfgeneration'));
326
-		$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
326
+		$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
327 327
 		global $action;
328
-		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
+		$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
329 329
 
330
-		if (! empty($conf->global->MAIN_UMASK))
330
+		if (!empty($conf->global->MAIN_UMASK))
331 331
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
332 332
 
333 333
 		$this->result = array('fullpath'=>$file);
@@ -353,52 +353,52 @@  discard block
 block discarded – undo
353 353
 
354 354
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
355 355
 
356
-		$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
-		switch($this->doc_type) {
356
+		$title = $conf->global->MAIN_INFO_SOCIETE_NOM;
357
+		switch ($this->doc_type) {
358 358
             case "client":
359
-                $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
359
+                $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
360 360
                 break;
361 361
             case "fourn":
362
-                $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
362
+                $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
363 363
                 break;
364 364
         }
365
-		$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
-		$pdf->SetFont('','B',$default_font_size + 1);
367
-		$pdf->SetXY($this->marge_gauche,10);
365
+		$title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
366
+		$pdf->SetFont('', 'B', $default_font_size + 1);
367
+		$pdf->SetXY($this->marge_gauche, 10);
368 368
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
369 369
 
370
-		$pdf->SetFont('','',$default_font_size);
370
+		$pdf->SetFont('', '', $default_font_size);
371 371
 
372 372
         $pdf->SetXY($this->posxdate, 16);
373
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
373
+		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
374 374
 
375
-        $pdf->SetXY($this->posxdate+100, 16);
375
+        $pdf->SetXY($this->posxdate + 100, 16);
376 376
 		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
377 377
 
378 378
 
379 379
 		// Title line
380
-        $pdf->SetXY($this->posxdate, $this->tab_top+2);
380
+        $pdf->SetXY($this->posxdate, $this->tab_top + 2);
381 381
 		$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
382 382
 
383 383
 		$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
384
-        $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2);
384
+        $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
385 385
 		$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
386 386
 
387 387
 		$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
388
-        $pdf->SetXY($this->posxinvoice, $this->tab_top+2);
388
+        $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
389 389
 		$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
390 390
 
391 391
 		$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
392
-        $pdf->SetXY($this->posxbankaccount, $this->tab_top+2);
392
+        $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
393 393
 		$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
394 394
 
395 395
 
396 396
 		$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
397
-        $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2);
397
+        $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
398 398
 		$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
399 399
 
400 400
 		$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
401
-        $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2);
401
+        $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
402 402
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
403 403
 
404 404
 		$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
@@ -423,34 +423,34 @@  discard block
 block discarded – undo
423 423
 		global $langs;
424 424
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
425 425
 
426
-		$pdf->SetFont('','', $default_font_size - 1);
426
+		$pdf->SetFont('', '', $default_font_size - 1);
427 427
 		$oldprowid = 0;
428 428
 		$total_page = 0;
429 429
 		$total = 0;
430
-		$pdf->SetFillColor(220,220,220);
430
+		$pdf->SetFillColor(220, 220, 220);
431 431
 		$yp = 0;
432
-		$numlines=count($lines);
433
-		for ($j = 0 ; $j < $numlines ; $j++)
432
+		$numlines = count($lines);
433
+		for ($j = 0; $j < $numlines; $j++)
434 434
 		{
435 435
 			$i = $j;
436
-			if ($yp > $this->tab_height -5)
436
+			if ($yp > $this->tab_height - 5)
437 437
 			{
438 438
 				$page++;
439 439
 				$pdf->AddPage();
440 440
 				$this->_pagehead($pdf, $page, 0, $outputlangs);
441
-				$pdf->SetFont('','', $default_font_size - 1);
441
+				$pdf->SetFont('', '', $default_font_size - 1);
442 442
 				$yp = 0;
443 443
 			}
444 444
 			if ($oldprowid <> $lines[$j][7])
445 445
 			{
446
-				if ($yp > $this->tab_height -15)
446
+				if ($yp > $this->tab_height - 15)
447 447
 				{
448 448
 					$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
-					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
449
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450 450
 					$page++;
451 451
 					$pdf->AddPage();
452 452
 					$this->_pagehead($pdf, $page, 0, $outputlangs);
453
-					$pdf->SetFont('','', $default_font_size - 1);
453
+					$pdf->SetFont('', '', $default_font_size - 1);
454 454
 					$yp = 0;
455 455
 					$total += $total_page;
456 456
 					$total_page = 0;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 				$pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464 464
 
465 465
 				$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
-				$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
466
+				$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467 467
 
468 468
 				$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469 469
 				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
 			// Invoice amount
483 483
 			$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
-			$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
484
+			$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485 485
 
486 486
 			// Payment amount
487 487
 			$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
Please login to merge, or discard this patch.
Braces   +46 added lines, -24 removed lines patch added patch discarded remove patch
@@ -70,9 +70,11 @@  discard block
 block discarded – undo
70 70
 		$this->posxbankaccount=110;
71 71
 		$this->posxinvoiceamount=132;
72 72
 		$this->posxpaymentamount=162;
73
-		if ($this->page_largeur < 210) // To work with US executive format
73
+		if ($this->page_largeur < 210) {
74
+		    // To work with US executive format
74 75
 		{
75 76
 			$this->line_per_page = 35;
77
+		}
76 78
 			$this->posxpaymenttype-=10;
77 79
 			$this->posxinvoice-=0;
78 80
 			$this->posxinvoiceamount-=10;
@@ -101,11 +103,17 @@  discard block
 block discarded – undo
101 103
 		global $conf, $hookmanager, $langs, $user;
102 104
 
103 105
 		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
106
+		if ($user->societe_id) {
107
+		    $socid=$user->societe_id;
108
+		}
105 109
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
110
+		if (! is_object($outputlangs)) {
111
+		    $outputlangs=$langs;
112
+		}
107 113
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
114
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
115
+		    $outputlangs->charset_output='ISO-8859-1';
116
+		}
109 117
 
110 118
 		$this->month=$month;
111 119
 		$this->year=$year;
@@ -185,29 +193,34 @@  discard block
 block discarded – undo
185 193
 				$sql.= ", c.code as paiement_code, p.num_paiement";
186 194
 				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187 195
 				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
196
+				if (! empty($conf->banque->enabled)) {
197
+									$sql.= ", ba.ref as bankaccount";
198
+				}
190 199
 				$sql.= ", p.rowid as prowid";
191 200
 				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192 201
 				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193 202
 				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
203
+				if (! empty($conf->banque->enabled)) {
204
+									$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
205
+				}
196 206
 				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197 207
 				if (! $user->rights->societe->client->voir && ! $socid)
198 208
 				{
199 209
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200 210
 				}
201 211
 				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
212
+				if (! empty($conf->banque->enabled)) {
213
+									$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
214
+				}
204 215
 				$sql.= " AND f.entity = ".$conf->entity;
205 216
 				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206 217
 				if (! $user->rights->societe->client->voir && ! $socid)
207 218
 				{
208 219
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209 220
 				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
221
+				if (! empty($socid)) {
222
+				    $sql .= " AND s.rowid = ".$socid;
223
+				}
211 224
 				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212 225
 				break;
213 226
 			case "fourn":
@@ -216,29 +229,34 @@  discard block
 block discarded – undo
216 229
 				$sql.= ", c.code as paiement_code, p.num_paiement";
217 230
 				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218 231
 				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
232
+				if (! empty($conf->banque->enabled)) {
233
+									$sql.= ", ba.ref as bankaccount";
234
+				}
221 235
 				$sql.= ", p.rowid as prowid";
222 236
 				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223 237
 				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224 238
 				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
239
+				if (! empty($conf->banque->enabled)) {
240
+									$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
241
+				}
227 242
 				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228 243
 				if (! $user->rights->societe->client->voir && ! $socid)
229 244
 				{
230 245
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231 246
 				}
232 247
 				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
248
+				if (! empty($conf->banque->enabled)) {
249
+									$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
250
+				}
235 251
 				$sql.= " AND f.entity = ".$conf->entity;
236 252
 				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237 253
 				if (! $user->rights->societe->client->voir && ! $socid)
238 254
 				{
239 255
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240 256
 				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
257
+				if (! empty($socid)) {
258
+				    $sql .= " AND s.rowid = ".$socid;
259
+				}
242 260
 				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243 261
 				break;
244 262
 		}
@@ -266,8 +284,7 @@  discard block
 block discarded – undo
266 284
 				$lines[$i][9] = $objp->paiement_amount;
267 285
 				$i++;
268 286
 			}
269
-		}
270
-		else
287
+		} else
271 288
 		{
272 289
 			dol_print_error($this->db);
273 290
 		}
@@ -294,7 +311,9 @@  discard block
 block discarded – undo
294 311
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295 312
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 313
 		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
314
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
315
+		    $pdf->SetCompression(false);
316
+		}
298 317
 
299 318
 		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300 319
 		$pdf->SetAutoPageBreak(1,0);
@@ -310,7 +329,9 @@  discard block
 block discarded – undo
310 329
 
311 330
 		$this->Body($pdf, 1, $lines, $outputlangs);
312 331
 
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
332
+		if (method_exists($pdf,'AliasNbPages')) {
333
+		    $pdf->AliasNbPages();
334
+		}
314 335
 
315 336
 		$pdf->Close();
316 337
 
@@ -327,8 +348,9 @@  discard block
 block discarded – undo
327 348
 		global $action;
328 349
 		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329 350
 
330
-		if (! empty($conf->global->MAIN_UMASK))
331
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
351
+		if (! empty($conf->global->MAIN_UMASK)) {
352
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
353
+		}
332 354
 
333 355
 		$this->result = array('fullpath'=>$file);
334 356
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
  */
31 31
 class pdf_paiement_fourn extends pdf_paiement
32 32
 {
33
-	/**
33
+    /**
34 34
      *  Constructor
35 35
      *
36 36
      *  @param      DoliDb		$db      Database handler
37
-	 */
38
-	function __construct($db)
39
-	{
40
-		parent::__construct($db);
41
-		$this->doc_type = "fourn";
42
-	}
37
+     */
38
+    function __construct($db)
39
+    {
40
+        parent::__construct($db);
41
+        $this->doc_type = "fourn";
42
+    }
43 43
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modGravatar.class.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -31,167 +31,167 @@
 block discarded – undo
31 31
  */
32 32
 class modGravatar extends DolibarrModules
33 33
 {
34
-	/**
35
-	 *   Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 *   @param      DoliDB		$db      Database handler
38
-	 */
39
-	function __construct($db)
40
-	{
41
-		$this->db = $db;
42
-
43
-		// Id for module (must be unique).
44
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
45
-		$this->numero = 2700;
46
-		// Key text used to identify module (for permissions, menus, etc...)
47
-		$this->rights_class = 'gravatar';
48
-
49
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
50
-		// It is used to group modules in module setup page
51
-		$this->family = "interface";
52
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
53
-		$this->module_position = '75';
54
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
-		$this->name = preg_replace('/^mod/i', '', get_class($this));
56
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->description = "Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails).<br>Need an internet access.";
58
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
-		$this->version = 'dolibarr';
60
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
61
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		// Name of image file used for this module.
63
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
64
-		// If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
65
-		$this->picto = 'gravatar';
66
-
67
-		// Data directories to create when module is enabled.
68
-		// Example: this->dirs = array("/mymodule/temp");
69
-		$this->dirs = array();
70
-		$r = 0;
71
-
72
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.
73
-		$this->config_page_url = array();
74
-
75
-		// Dependencies
76
-		$this->hidden = false;			// A condition to hide module
77
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
78
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
79
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
80
-		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
81
-		$this->need_dolibarr_version = array(2, 7); // Minimum version of Dolibarr required by module
82
-		$this->langfiles = array();
83
-
84
-		// Constants
85
-		$this->const = array(); // List of particular constants to add when module is enabled
86
-		//Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),
87
-		//                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );
88
-
89
-		// Array to add new pages in new tabs
90
-		$this->tabs = array();
91
-
92
-		// Boxes
93
-		$this->boxes = array(); // List of boxes
94
-		$r = 0;
95
-
96
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
97
-		// Example:
98
-		//$this->boxes[$r][1] = "myboxa.php";
99
-		//$r++;
100
-		//$this->boxes[$r][1] = "myboxb.php";
101
-		//$r++;
102
-
103
-
104
-		// Permissions
105
-		$this->rights = array(); // Permission array used by this module
106
-		$r = 0;
107
-
108
-		// Add here list of permission defined by an id, a label, a boolean and two constant strings.
109
-		// Example:
110
-		// $this->rights[$r][0] = 2000; 				// Permission id (must not be already used)
111
-		// $this->rights[$r][1] = 'Permision label';	// Permission label
112
-		// $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)
113
-		// $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
114
-		// $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
115
-		// $r++;
116
-
117
-
118
-		// Main menu entries
119
-		$this->menus = array(); // List of menus to add
120
-		$r = 0;
121
-
122
-		// Add here entries to declare new menus
123
-		// Example to declare the Top Menu entry:
124
-		// $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu
125
-		//							'type'=>'top',			// This is a Top menu entry
126
-		//							'titre'=>'MyModule top menu',
127
-		//							'mainmenu'=>'mymodule',
128
-		//							'url'=>'/mymodule/pagetop.php',
129
-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
130
-		//							'position'=>100,
131
-		//							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
132
-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
133
-		//							'target'=>'',
134
-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
135
-		// $r++;
136
-		//
137
-		// Example to declare a Left Menu entry:
138
-		// $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
139
-		//							'type'=>'left',			// This is a Left menu entry
140
-		//							'titre'=>'MyModule left menu 1',
141
-		//							'mainmenu'=>'mymodule',
142
-		//							'url'=>'/mymodule/pagelevel1.php',
143
-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
144
-		//							'position'=>100,
145
-		//							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
146
-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
147
-		//							'target'=>'',
148
-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
149
-		// $r++;
150
-		//
151
-		// Example to declare another Left Menu entry:
152
-		// $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
153
-		//							'type'=>'left',			// This is a Left menu entry
154
-		//							'titre'=>'MyModule left menu 2',
155
-		//							'mainmenu'=>'mymodule',
156
-		//							'url'=>'/mymodule/pagelevel2.php',
157
-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
158
-		//							'position'=>100,
159
-		//							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
160
-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
161
-		//							'target'=>'',
162
-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
163
-		// $r++;
164
-
165
-
166
-		// Exports
167
-		$r = 1;
168
-
169
-		// Example:
170
-		// $this->export_code[$r]=$this->rights_class.'_'.$r;
171
-		// $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
172
-		// $this->export_permission[$r]=array(array("facture","facture","export"));
173
-		// $this->export_fields_array[$r]=array(
174
-		//	's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',
175
-		//	's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
176
-		//	's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",
177
-		//	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',
178
-		//	'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",
179
-		//	'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",
180
-		//	'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'
181
-		//);
182
-		// $this->export_entities_array[$r]=array(
183
-		//	's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',
184
-		//	's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
185
-		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",
186
-		//	'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",
187
-		//	'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",
188
-		//	'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'
189
-		//);
190
-		// $this->export_sql_start[$r]='SELECT DISTINCT ';
191
-		// $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
192
-		// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
193
-		// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
194
-		// $r++;
195
-	}
34
+    /**
35
+     *   Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     *   @param      DoliDB		$db      Database handler
38
+     */
39
+    function __construct($db)
40
+    {
41
+        $this->db = $db;
42
+
43
+        // Id for module (must be unique).
44
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
45
+        $this->numero = 2700;
46
+        // Key text used to identify module (for permissions, menus, etc...)
47
+        $this->rights_class = 'gravatar';
48
+
49
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
50
+        // It is used to group modules in module setup page
51
+        $this->family = "interface";
52
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
53
+        $this->module_position = '75';
54
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
56
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
57
+        $this->description = "Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails).<br>Need an internet access.";
58
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
+        $this->version = 'dolibarr';
60
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
61
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
+        // Name of image file used for this module.
63
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
64
+        // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
65
+        $this->picto = 'gravatar';
66
+
67
+        // Data directories to create when module is enabled.
68
+        // Example: this->dirs = array("/mymodule/temp");
69
+        $this->dirs = array();
70
+        $r = 0;
71
+
72
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.
73
+        $this->config_page_url = array();
74
+
75
+        // Dependencies
76
+        $this->hidden = false;			// A condition to hide module
77
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
78
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
79
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
80
+        $this->phpmin = array(5, 4); // Minimum version of PHP required by module
81
+        $this->need_dolibarr_version = array(2, 7); // Minimum version of Dolibarr required by module
82
+        $this->langfiles = array();
83
+
84
+        // Constants
85
+        $this->const = array(); // List of particular constants to add when module is enabled
86
+        //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),
87
+        //                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );
88
+
89
+        // Array to add new pages in new tabs
90
+        $this->tabs = array();
91
+
92
+        // Boxes
93
+        $this->boxes = array(); // List of boxes
94
+        $r = 0;
95
+
96
+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
97
+        // Example:
98
+        //$this->boxes[$r][1] = "myboxa.php";
99
+        //$r++;
100
+        //$this->boxes[$r][1] = "myboxb.php";
101
+        //$r++;
102
+
103
+
104
+        // Permissions
105
+        $this->rights = array(); // Permission array used by this module
106
+        $r = 0;
107
+
108
+        // Add here list of permission defined by an id, a label, a boolean and two constant strings.
109
+        // Example:
110
+        // $this->rights[$r][0] = 2000; 				// Permission id (must not be already used)
111
+        // $this->rights[$r][1] = 'Permision label';	// Permission label
112
+        // $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)
113
+        // $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
114
+        // $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
115
+        // $r++;
116
+
117
+
118
+        // Main menu entries
119
+        $this->menus = array(); // List of menus to add
120
+        $r = 0;
121
+
122
+        // Add here entries to declare new menus
123
+        // Example to declare the Top Menu entry:
124
+        // $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu
125
+        //							'type'=>'top',			// This is a Top menu entry
126
+        //							'titre'=>'MyModule top menu',
127
+        //							'mainmenu'=>'mymodule',
128
+        //							'url'=>'/mymodule/pagetop.php',
129
+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
130
+        //							'position'=>100,
131
+        //							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
132
+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
133
+        //							'target'=>'',
134
+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
135
+        // $r++;
136
+        //
137
+        // Example to declare a Left Menu entry:
138
+        // $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
139
+        //							'type'=>'left',			// This is a Left menu entry
140
+        //							'titre'=>'MyModule left menu 1',
141
+        //							'mainmenu'=>'mymodule',
142
+        //							'url'=>'/mymodule/pagelevel1.php',
143
+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
144
+        //							'position'=>100,
145
+        //							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
146
+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
147
+        //							'target'=>'',
148
+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
149
+        // $r++;
150
+        //
151
+        // Example to declare another Left Menu entry:
152
+        // $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
153
+        //							'type'=>'left',			// This is a Left menu entry
154
+        //							'titre'=>'MyModule left menu 2',
155
+        //							'mainmenu'=>'mymodule',
156
+        //							'url'=>'/mymodule/pagelevel2.php',
157
+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
158
+        //							'position'=>100,
159
+        //							'enabled'=>'1',			// Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
160
+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
161
+        //							'target'=>'',
162
+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
163
+        // $r++;
164
+
165
+
166
+        // Exports
167
+        $r = 1;
168
+
169
+        // Example:
170
+        // $this->export_code[$r]=$this->rights_class.'_'.$r;
171
+        // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
172
+        // $this->export_permission[$r]=array(array("facture","facture","export"));
173
+        // $this->export_fields_array[$r]=array(
174
+        //	's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',
175
+        //	's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
176
+        //	's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",
177
+        //	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',
178
+        //	'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",
179
+        //	'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",
180
+        //	'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'
181
+        //);
182
+        // $this->export_entities_array[$r]=array(
183
+        //	's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',
184
+        //	's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
185
+        //	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",
186
+        //	'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",
187
+        //	'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",
188
+        //	'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'
189
+        //);
190
+        // $this->export_sql_start[$r]='SELECT DISTINCT ';
191
+        // $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
192
+        // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
193
+        // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
194
+        // $r++;
195
+    }
196 196
 }
197 197
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@
 block discarded – undo
73 73
 		$this->config_page_url = array();
74 74
 
75 75
 		// Dependencies
76
-		$this->hidden = false;			// A condition to hide module
77
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
78
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
79
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
76
+		$this->hidden = false; // A condition to hide module
77
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
78
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
79
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
80 80
 		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
81 81
 		$this->need_dolibarr_version = array(2, 7); // Minimum version of Dolibarr required by module
82 82
 		$this->langfiles = array();
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modContrat.class.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -34,214 +34,214 @@
 block discarded – undo
34 34
 class modContrat extends DolibarrModules
35 35
 {
36 36
 
37
-	/**
38
-	 *   Constructor. Define names, constants, directories, boxes, permissions
39
-	 *
40
-	 *   @param      DoliDB		$db      Database handler
41
-	 */
42
-	function __construct($db)
43
-	{
44
-		global $conf, $langs;
45
-
46
-		$this->db = $db;
47
-		$this->numero = 54;
48
-
49
-		$this->family = "crm";
50
-		$this->module_position = '35';
51
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
-		$this->description = "Gestion des contrats de services";
54
-
55
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
56
-		$this->version = 'dolibarr';
57
-
58
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
-		$this->picto='contract';
60
-
61
-		// Data directories to create when module is enabled
62
-		$this->dirs = array("/contract/temp");
63
-
64
-		// Dependencies
65
-		$this->depends = array("modSociete");
66
-		$this->requiredby = array();
67
-
68
-		// Config pages
69
-		$this->config_page_url = array("contract.php");
70
-
71
-		// Constants
72
-		$this->const = array();
73
-		$r=0;
74
-
75
-		$this->const[$r][0] = "CONTRACT_ADDON";
76
-		$this->const[$r][1] = "chaine";
77
-		$this->const[$r][2] = "mod_contract_serpis";
78
-		$this->const[$r][3] = 'Nom du gestionnaire de numerotation des contrats';
79
-		$this->const[$r][4] = 0;
80
-		$r++;
81
-
82
-		$this->const[$r][0] = "CONTRACT_ADDON_PDF";
83
-		$this->const[$r][1] = "chaine";
84
-		$this->const[$r][2] = "strato";
85
-		$this->const[$r][3] = 'Name of PDF model of contract';
86
-		$this->const[$r][4] = 0;
87
-		$r++;
88
-
89
-		$this->const[$r][0] = "CONTRACT_ADDON_PDF_ODT_PATH";
90
-		$this->const[$r][1] = "chaine";
91
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/contracts";
92
-		$this->const[$r][3] = "";
93
-		$this->const[$r][4] = 0;
94
-		$r++;
95
-
96
-		// Boxes
97
-		$this->boxes = array(
98
-			0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'),
99
-			1=>array('file'=>'box_services_expired.php','enabledbydefaulton'=>'Home')
100
-		);
101
-
102
-		// Permissions
103
-		$this->rights = array();
104
-		$this->rights_class = 'contrat';
105
-		$r=0;
106
-
107
-		$r++;
108
-		$this->rights[$r][0] = 161;
109
-		$this->rights[$r][1] = 'Lire les contrats';
110
-		$this->rights[$r][2] = 'r';
111
-		$this->rights[$r][3] = 0;
112
-		$this->rights[$r][4] = 'lire';
113
-
114
-		$r++;
115
-		$this->rights[$r][0] = 162;
116
-		$this->rights[$r][1] = 'Creer / modifier les contrats';
117
-		$this->rights[$r][2] = 'w';
118
-		$this->rights[$r][3] = 0;
119
-		$this->rights[$r][4] = 'creer';
120
-
121
-		$r++;
122
-		$this->rights[$r][0] = 163;
123
-		$this->rights[$r][1] = 'Activer un service d\'un contrat';
124
-		$this->rights[$r][2] = 'w';
125
-		$this->rights[$r][3] = 0;
126
-		$this->rights[$r][4] = 'activer';
127
-
128
-		$r++;
129
-		$this->rights[$r][0] = 164;
130
-		$this->rights[$r][1] = 'Desactiver un service d\'un contrat';
131
-		$this->rights[$r][2] = 'w';
132
-		$this->rights[$r][3] = 0;
133
-		$this->rights[$r][4] = 'desactiver';
134
-
135
-		$r++;
136
-		$this->rights[$r][0] = 165;
137
-		$this->rights[$r][1] = 'Supprimer un contrat';
138
-		$this->rights[$r][2] = 'd';
139
-		$this->rights[$r][3] = 0;
140
-		$this->rights[$r][4] = 'supprimer';
141
-
142
-		$r++;
143
-		$this->rights[$r][0] = 167;
144
-		$this->rights[$r][1] = 'Export contracts';
145
-		$this->rights[$r][2] = 'r';
146
-		$this->rights[$r][3] = 0;
147
-		$this->rights[$r][4] = 'export';
148
-
149
-
150
-		// Menus
151
-		//-------
152
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
153
-
154
-
155
-		// Exports
156
-		//--------
157
-		$langs->load("contracts");
158
-
159
-		$r=1;
160
-
161
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
162
-		$this->export_label[$r]='ContractsAndLine';	// Translation key (used only if key ExportDataset_xxx_z not found)
163
-		$this->export_icon[$r]='contract';
164
-		$this->export_permission[$r]=array(array("contrat","export"));
165
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',
166
-		's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
167
-		's.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
168
-		'co.rowid'=>"Id",'co.ref'=>"Ref",'co.datec'=>"DateCreation",'co.date_contrat'=>"DateContract",'co.mise_en_service'=>"ContractStartDate",
169
-		'co.fin_validite'=>"ContractEndDate",'co.date_cloture'=>"Closing",'co.note_private'=>"NotePrivate",'co.note_public'=>"NotePublic",
170
-		'cod.rowid'=>'LineId','cod.label'=>"LineLabel",'cod.description'=>"LineDescription",'cod.price_ht'=>"LineUnitPrice",'cod.tva_tx'=>"LineVATRate",
171
-		'cod.qty'=>"LineQty",'cod.total_ht'=>"LineTotalHT",'cod.total_tva'=>"LineTotalVAT",'cod.total_ttc'=>"LineTotalTTC",
172
-		'cod.date_ouverture'=>"DateStart",'cod.date_ouverture_prevue'=>"DateStartPlanned",'cod.date_fin_validite'=>"DateEndPlanned",'cod.date_cloture'=>"DateEnd",
173
-		'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
174
-
175
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company',
176
-		's.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company',
177
-		's.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
178
-		'co.rowid'=>"contract",'co.ref'=>"contract",'co.datec'=>"contract",'co.date_contrat'=>"contract",'co.mise_en_service'=>"contract",
179
-		'co.fin_validite'=>"contract",'co.date_cloture'=>"contract",'co.note_private'=>"contract",'co.note_public'=>"contract",
180
-		'cod.rowid'=>'contract_line','cod.label'=>"contract_line",'cod.description'=>"contract_line",'cod.price_ht'=>"contract_line",'cod.tva_tx'=>"contract_line",
181
-		'cod.qty'=>"contract_line",'cod.total_ht'=>"contract_line",'cod.total_tva'=>"contract_line",'cod.total_ttc'=>"contract_line",
182
-		'cod.date_ouverture'=>"contract_line",'cod.date_ouverture_prevue'=>"contract_line",'cod.date_fin_validite'=>"contract_line",'cod.date_cloture'=>"contract_line",
183
-		'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product');
184
-
185
-		$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text',
186
-		's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
187
-		's.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
188
-		'co.ref'=>"Text",'co.datec'=>"Date",'co.date_contrat'=>"Date",'co.mise_en_service'=>"Date",
189
-		'co.fin_validite'=>"Date",'co.date_cloture'=>"Date",'co.note_private'=>"Text",'co.note_public'=>"Text",
190
-		'cod.label'=>"Text",'cod.description'=>"Text",'cod.price_ht'=>"Numeric",'cod.tva_tx'=>"Numeric",
191
-		'cod.qty'=>"Numeric",'cod.total_ht'=>"Numeric",'cod.total_tva'=>"Numeric",'cod.total_ttc'=>"Numeric",
192
-		'cod.date_ouverture'=>"Date",'cod.date_ouverture_prevue'=>"Date",'cod.date_fin_validite'=>"Date",'cod.date_cloture'=>"Date",
193
-		'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text');
194
-
195
-
196
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
198
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
199
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contrat as co,';
200
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod';
201
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)';
202
-		$this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat';
203
-		$this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract').')';
204
-	}
205
-
206
-
207
-	/**
208
-	 *		Function called when module is enabled.
209
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
210
-	 *		It also creates data directories
211
-	 *
37
+    /**
38
+     *   Constructor. Define names, constants, directories, boxes, permissions
39
+     *
40
+     *   @param      DoliDB		$db      Database handler
41
+     */
42
+    function __construct($db)
43
+    {
44
+        global $conf, $langs;
45
+
46
+        $this->db = $db;
47
+        $this->numero = 54;
48
+
49
+        $this->family = "crm";
50
+        $this->module_position = '35';
51
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
+        $this->name = preg_replace('/^mod/i','',get_class($this));
53
+        $this->description = "Gestion des contrats de services";
54
+
55
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
56
+        $this->version = 'dolibarr';
57
+
58
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
+        $this->picto='contract';
60
+
61
+        // Data directories to create when module is enabled
62
+        $this->dirs = array("/contract/temp");
63
+
64
+        // Dependencies
65
+        $this->depends = array("modSociete");
66
+        $this->requiredby = array();
67
+
68
+        // Config pages
69
+        $this->config_page_url = array("contract.php");
70
+
71
+        // Constants
72
+        $this->const = array();
73
+        $r=0;
74
+
75
+        $this->const[$r][0] = "CONTRACT_ADDON";
76
+        $this->const[$r][1] = "chaine";
77
+        $this->const[$r][2] = "mod_contract_serpis";
78
+        $this->const[$r][3] = 'Nom du gestionnaire de numerotation des contrats';
79
+        $this->const[$r][4] = 0;
80
+        $r++;
81
+
82
+        $this->const[$r][0] = "CONTRACT_ADDON_PDF";
83
+        $this->const[$r][1] = "chaine";
84
+        $this->const[$r][2] = "strato";
85
+        $this->const[$r][3] = 'Name of PDF model of contract';
86
+        $this->const[$r][4] = 0;
87
+        $r++;
88
+
89
+        $this->const[$r][0] = "CONTRACT_ADDON_PDF_ODT_PATH";
90
+        $this->const[$r][1] = "chaine";
91
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/contracts";
92
+        $this->const[$r][3] = "";
93
+        $this->const[$r][4] = 0;
94
+        $r++;
95
+
96
+        // Boxes
97
+        $this->boxes = array(
98
+            0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'),
99
+            1=>array('file'=>'box_services_expired.php','enabledbydefaulton'=>'Home')
100
+        );
101
+
102
+        // Permissions
103
+        $this->rights = array();
104
+        $this->rights_class = 'contrat';
105
+        $r=0;
106
+
107
+        $r++;
108
+        $this->rights[$r][0] = 161;
109
+        $this->rights[$r][1] = 'Lire les contrats';
110
+        $this->rights[$r][2] = 'r';
111
+        $this->rights[$r][3] = 0;
112
+        $this->rights[$r][4] = 'lire';
113
+
114
+        $r++;
115
+        $this->rights[$r][0] = 162;
116
+        $this->rights[$r][1] = 'Creer / modifier les contrats';
117
+        $this->rights[$r][2] = 'w';
118
+        $this->rights[$r][3] = 0;
119
+        $this->rights[$r][4] = 'creer';
120
+
121
+        $r++;
122
+        $this->rights[$r][0] = 163;
123
+        $this->rights[$r][1] = 'Activer un service d\'un contrat';
124
+        $this->rights[$r][2] = 'w';
125
+        $this->rights[$r][3] = 0;
126
+        $this->rights[$r][4] = 'activer';
127
+
128
+        $r++;
129
+        $this->rights[$r][0] = 164;
130
+        $this->rights[$r][1] = 'Desactiver un service d\'un contrat';
131
+        $this->rights[$r][2] = 'w';
132
+        $this->rights[$r][3] = 0;
133
+        $this->rights[$r][4] = 'desactiver';
134
+
135
+        $r++;
136
+        $this->rights[$r][0] = 165;
137
+        $this->rights[$r][1] = 'Supprimer un contrat';
138
+        $this->rights[$r][2] = 'd';
139
+        $this->rights[$r][3] = 0;
140
+        $this->rights[$r][4] = 'supprimer';
141
+
142
+        $r++;
143
+        $this->rights[$r][0] = 167;
144
+        $this->rights[$r][1] = 'Export contracts';
145
+        $this->rights[$r][2] = 'r';
146
+        $this->rights[$r][3] = 0;
147
+        $this->rights[$r][4] = 'export';
148
+
149
+
150
+        // Menus
151
+        //-------
152
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
153
+
154
+
155
+        // Exports
156
+        //--------
157
+        $langs->load("contracts");
158
+
159
+        $r=1;
160
+
161
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
162
+        $this->export_label[$r]='ContractsAndLine';	// Translation key (used only if key ExportDataset_xxx_z not found)
163
+        $this->export_icon[$r]='contract';
164
+        $this->export_permission[$r]=array(array("contrat","export"));
165
+        $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',
166
+        's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
167
+        's.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
168
+        'co.rowid'=>"Id",'co.ref'=>"Ref",'co.datec'=>"DateCreation",'co.date_contrat'=>"DateContract",'co.mise_en_service'=>"ContractStartDate",
169
+        'co.fin_validite'=>"ContractEndDate",'co.date_cloture'=>"Closing",'co.note_private'=>"NotePrivate",'co.note_public'=>"NotePublic",
170
+        'cod.rowid'=>'LineId','cod.label'=>"LineLabel",'cod.description'=>"LineDescription",'cod.price_ht'=>"LineUnitPrice",'cod.tva_tx'=>"LineVATRate",
171
+        'cod.qty'=>"LineQty",'cod.total_ht'=>"LineTotalHT",'cod.total_tva'=>"LineTotalVAT",'cod.total_ttc'=>"LineTotalTTC",
172
+        'cod.date_ouverture'=>"DateStart",'cod.date_ouverture_prevue'=>"DateStartPlanned",'cod.date_fin_validite'=>"DateEndPlanned",'cod.date_cloture'=>"DateEnd",
173
+        'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
174
+
175
+        $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company',
176
+        's.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company',
177
+        's.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
178
+        'co.rowid'=>"contract",'co.ref'=>"contract",'co.datec'=>"contract",'co.date_contrat'=>"contract",'co.mise_en_service'=>"contract",
179
+        'co.fin_validite'=>"contract",'co.date_cloture'=>"contract",'co.note_private'=>"contract",'co.note_public'=>"contract",
180
+        'cod.rowid'=>'contract_line','cod.label'=>"contract_line",'cod.description'=>"contract_line",'cod.price_ht'=>"contract_line",'cod.tva_tx'=>"contract_line",
181
+        'cod.qty'=>"contract_line",'cod.total_ht'=>"contract_line",'cod.total_tva'=>"contract_line",'cod.total_ttc'=>"contract_line",
182
+        'cod.date_ouverture'=>"contract_line",'cod.date_ouverture_prevue'=>"contract_line",'cod.date_fin_validite'=>"contract_line",'cod.date_cloture'=>"contract_line",
183
+        'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product');
184
+
185
+        $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text',
186
+        's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
187
+        's.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
188
+        'co.ref'=>"Text",'co.datec'=>"Date",'co.date_contrat'=>"Date",'co.mise_en_service'=>"Date",
189
+        'co.fin_validite'=>"Date",'co.date_cloture'=>"Date",'co.note_private'=>"Text",'co.note_public'=>"Text",
190
+        'cod.label'=>"Text",'cod.description'=>"Text",'cod.price_ht'=>"Numeric",'cod.tva_tx'=>"Numeric",
191
+        'cod.qty'=>"Numeric",'cod.total_ht'=>"Numeric",'cod.total_tva'=>"Numeric",'cod.total_ttc'=>"Numeric",
192
+        'cod.date_ouverture'=>"Date",'cod.date_ouverture_prevue'=>"Date",'cod.date_fin_validite'=>"Date",'cod.date_cloture'=>"Date",
193
+        'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text');
194
+
195
+
196
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
197
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
198
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
199
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contrat as co,';
200
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod';
201
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)';
202
+        $this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat';
203
+        $this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract').')';
204
+    }
205
+
206
+
207
+    /**
208
+     *		Function called when module is enabled.
209
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
210
+     *		It also creates data directories
211
+     *
212 212
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
213
-	 *      @return     int             	1 if OK, 0 if KO
214
-	 */
215
-	function init($options='')
216
-	{
217
-		global $conf;
218
-
219
-		// Nettoyage avant activation
220
-		$this->remove($options);
221
-
222
-		//ODT template
223
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt';
224
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/contracts';
225
-		$dest=$dirodt.'/template_contract.odt';
226
-
227
-		if (file_exists($src) && ! file_exists($dest))
228
-		{
229
-		    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
230
-		    dol_mkdir($dirodt);
231
-		    $result=dol_copy($src,$dest,0,0);
232
-		    if ($result < 0)
233
-		    {
234
-		        $langs->load("errors");
235
-		        $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
236
-		        return 0;
237
-		    }
238
-		}
239
-
240
-		$sql = array(
241
-		    "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity,
242
-		    "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")"
243
-		);
244
-
245
-		return $this->_init($sql,$options);
246
-	}
213
+     *      @return     int             	1 if OK, 0 if KO
214
+     */
215
+    function init($options='')
216
+    {
217
+        global $conf;
218
+
219
+        // Nettoyage avant activation
220
+        $this->remove($options);
221
+
222
+        //ODT template
223
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt';
224
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/contracts';
225
+        $dest=$dirodt.'/template_contract.odt';
226
+
227
+        if (file_exists($src) && ! file_exists($dest))
228
+        {
229
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
230
+            dol_mkdir($dirodt);
231
+            $result=dol_copy($src,$dest,0,0);
232
+            if ($result < 0)
233
+            {
234
+                $langs->load("errors");
235
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
236
+                return 0;
237
+            }
238
+        }
239
+
240
+        $sql = array(
241
+            "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity,
242
+            "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")"
243
+        );
244
+
245
+        return $this->_init($sql,$options);
246
+    }
247 247
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *	\brief      Fichier de description et activation du module Contrat
26 26
  */
27 27
 
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 		$this->family = "crm";
50 50
 		$this->module_position = '35';
51 51
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
-		$this->name = preg_replace('/^mod/i','',get_class($this));
52
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
53 53
 		$this->description = "Gestion des contrats de services";
54 54
 
55 55
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
56 56
 		$this->version = 'dolibarr';
57 57
 
58 58
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
-		$this->picto='contract';
59
+		$this->picto = 'contract';
60 60
 
61 61
 		// Data directories to create when module is enabled
62 62
 		$this->dirs = array("/contract/temp");
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		// Constants
72 72
 		$this->const = array();
73
-		$r=0;
73
+		$r = 0;
74 74
 
75 75
 		$this->const[$r][0] = "CONTRACT_ADDON";
76 76
 		$this->const[$r][1] = "chaine";
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 
96 96
 		// Boxes
97 97
 		$this->boxes = array(
98
-			0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'),
99
-			1=>array('file'=>'box_services_expired.php','enabledbydefaulton'=>'Home')
98
+			0=>array('file'=>'box_contracts.php', 'enabledbydefaulton'=>'Home'),
99
+			1=>array('file'=>'box_services_expired.php', 'enabledbydefaulton'=>'Home')
100 100
 		);
101 101
 
102 102
 		// Permissions
103 103
 		$this->rights = array();
104 104
 		$this->rights_class = 'contrat';
105
-		$r=0;
105
+		$r = 0;
106 106
 
107 107
 		$r++;
108 108
 		$this->rights[$r][0] = 161;
@@ -149,58 +149,58 @@  discard block
 block discarded – undo
149 149
 
150 150
 		// Menus
151 151
 		//-------
152
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
152
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
153 153
 
154 154
 
155 155
 		// Exports
156 156
 		//--------
157 157
 		$langs->load("contracts");
158 158
 
159
-		$r=1;
160
-
161
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
162
-		$this->export_label[$r]='ContractsAndLine';	// Translation key (used only if key ExportDataset_xxx_z not found)
163
-		$this->export_icon[$r]='contract';
164
-		$this->export_permission[$r]=array(array("contrat","export"));
165
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',
166
-		's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
167
-		's.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
168
-		'co.rowid'=>"Id",'co.ref'=>"Ref",'co.datec'=>"DateCreation",'co.date_contrat'=>"DateContract",'co.mise_en_service'=>"ContractStartDate",
169
-		'co.fin_validite'=>"ContractEndDate",'co.date_cloture'=>"Closing",'co.note_private'=>"NotePrivate",'co.note_public'=>"NotePublic",
170
-		'cod.rowid'=>'LineId','cod.label'=>"LineLabel",'cod.description'=>"LineDescription",'cod.price_ht'=>"LineUnitPrice",'cod.tva_tx'=>"LineVATRate",
171
-		'cod.qty'=>"LineQty",'cod.total_ht'=>"LineTotalHT",'cod.total_tva'=>"LineTotalVAT",'cod.total_ttc'=>"LineTotalTTC",
172
-		'cod.date_ouverture'=>"DateStart",'cod.date_ouverture_prevue'=>"DateStartPlanned",'cod.date_fin_validite'=>"DateEndPlanned",'cod.date_cloture'=>"DateEnd",
173
-		'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
174
-
175
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company',
176
-		's.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company',
177
-		's.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
178
-		'co.rowid'=>"contract",'co.ref'=>"contract",'co.datec'=>"contract",'co.date_contrat'=>"contract",'co.mise_en_service'=>"contract",
179
-		'co.fin_validite'=>"contract",'co.date_cloture'=>"contract",'co.note_private'=>"contract",'co.note_public'=>"contract",
180
-		'cod.rowid'=>'contract_line','cod.label'=>"contract_line",'cod.description'=>"contract_line",'cod.price_ht'=>"contract_line",'cod.tva_tx'=>"contract_line",
181
-		'cod.qty'=>"contract_line",'cod.total_ht'=>"contract_line",'cod.total_tva'=>"contract_line",'cod.total_ttc'=>"contract_line",
182
-		'cod.date_ouverture'=>"contract_line",'cod.date_ouverture_prevue'=>"contract_line",'cod.date_fin_validite'=>"contract_line",'cod.date_cloture'=>"contract_line",
183
-		'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product');
184
-
185
-		$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text',
186
-		's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
187
-		's.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
188
-		'co.ref'=>"Text",'co.datec'=>"Date",'co.date_contrat'=>"Date",'co.mise_en_service'=>"Date",
189
-		'co.fin_validite'=>"Date",'co.date_cloture'=>"Date",'co.note_private'=>"Text",'co.note_public'=>"Text",
190
-		'cod.label'=>"Text",'cod.description'=>"Text",'cod.price_ht'=>"Numeric",'cod.tva_tx'=>"Numeric",
191
-		'cod.qty'=>"Numeric",'cod.total_ht'=>"Numeric",'cod.total_tva'=>"Numeric",'cod.total_ttc'=>"Numeric",
192
-		'cod.date_ouverture'=>"Date",'cod.date_ouverture_prevue'=>"Date",'cod.date_fin_validite'=>"Date",'cod.date_cloture'=>"Date",
193
-		'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text');
194
-
195
-
196
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
198
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
199
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contrat as co,';
200
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod';
201
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)';
202
-		$this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat';
203
-		$this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract').')';
159
+		$r = 1;
160
+
161
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
162
+		$this->export_label[$r] = 'ContractsAndLine'; // Translation key (used only if key ExportDataset_xxx_z not found)
163
+		$this->export_icon[$r] = 'contract';
164
+		$this->export_permission[$r] = array(array("contrat", "export"));
165
+		$this->export_fields_array[$r] = array('s.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode',
166
+		's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
167
+		's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
168
+		'co.rowid'=>"Id", 'co.ref'=>"Ref", 'co.datec'=>"DateCreation", 'co.date_contrat'=>"DateContract", 'co.mise_en_service'=>"ContractStartDate",
169
+		'co.fin_validite'=>"ContractEndDate", 'co.date_cloture'=>"Closing", 'co.note_private'=>"NotePrivate", 'co.note_public'=>"NotePublic",
170
+		'cod.rowid'=>'LineId', 'cod.label'=>"LineLabel", 'cod.description'=>"LineDescription", 'cod.price_ht'=>"LineUnitPrice", 'cod.tva_tx'=>"LineVATRate",
171
+		'cod.qty'=>"LineQty", 'cod.total_ht'=>"LineTotalHT", 'cod.total_tva'=>"LineTotalVAT", 'cod.total_ttc'=>"LineTotalTTC",
172
+		'cod.date_ouverture'=>"DateStart", 'cod.date_ouverture_prevue'=>"DateStartPlanned", 'cod.date_fin_validite'=>"DateEndPlanned", 'cod.date_cloture'=>"DateEnd",
173
+		'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel');
174
+
175
+		$this->export_entities_array[$r] = array('s.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company',
176
+		's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company',
177
+		's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
178
+		'co.rowid'=>"contract", 'co.ref'=>"contract", 'co.datec'=>"contract", 'co.date_contrat'=>"contract", 'co.mise_en_service'=>"contract",
179
+		'co.fin_validite'=>"contract", 'co.date_cloture'=>"contract", 'co.note_private'=>"contract", 'co.note_public'=>"contract",
180
+		'cod.rowid'=>'contract_line', 'cod.label'=>"contract_line", 'cod.description'=>"contract_line", 'cod.price_ht'=>"contract_line", 'cod.tva_tx'=>"contract_line",
181
+		'cod.qty'=>"contract_line", 'cod.total_ht'=>"contract_line", 'cod.total_tva'=>"contract_line", 'cod.total_ttc'=>"contract_line",
182
+		'cod.date_ouverture'=>"contract_line", 'cod.date_ouverture_prevue'=>"contract_line", 'cod.date_fin_validite'=>"contract_line", 'cod.date_cloture'=>"contract_line",
183
+		'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product');
184
+
185
+		$this->export_TypeFields_array[$r] = array('s.rowid'=>"List:societe:nom", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text',
186
+		's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text',
187
+		's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
188
+		'co.ref'=>"Text", 'co.datec'=>"Date", 'co.date_contrat'=>"Date", 'co.mise_en_service'=>"Date",
189
+		'co.fin_validite'=>"Date", 'co.date_cloture'=>"Date", 'co.note_private'=>"Text", 'co.note_public'=>"Text",
190
+		'cod.label'=>"Text", 'cod.description'=>"Text", 'cod.price_ht'=>"Numeric", 'cod.tva_tx'=>"Numeric",
191
+		'cod.qty'=>"Numeric", 'cod.total_ht'=>"Numeric", 'cod.total_tva'=>"Numeric", 'cod.total_ttc'=>"Numeric",
192
+		'cod.date_ouverture'=>"Date", 'cod.date_ouverture_prevue'=>"Date", 'cod.date_fin_validite'=>"Date", 'cod.date_cloture'=>"Date",
193
+		'p.rowid'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text');
194
+
195
+
196
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
197
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
198
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
199
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'contrat as co,';
200
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'contratdet as cod';
201
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)';
202
+		$this->export_sql_end[$r] .= ' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat';
203
+		$this->export_sql_end[$r] .= ' AND co.entity IN ('.getEntity('contract').')';
204 204
 	}
205 205
 
206 206
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
213 213
 	 *      @return     int             	1 if OK, 0 if KO
214 214
 	 */
215
-	function init($options='')
215
+	function init($options = '')
216 216
 	{
217 217
 		global $conf;
218 218
 
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 		$this->remove($options);
221 221
 
222 222
 		//ODT template
223
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt';
224
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/contracts';
225
-		$dest=$dirodt.'/template_contract.odt';
223
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt';
224
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/contracts';
225
+		$dest = $dirodt.'/template_contract.odt';
226 226
 
227
-		if (file_exists($src) && ! file_exists($dest))
227
+		if (file_exists($src) && !file_exists($dest))
228 228
 		{
229 229
 		    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
230 230
 		    dol_mkdir($dirodt);
231
-		    $result=dol_copy($src,$dest,0,0);
231
+		    $result = dol_copy($src, $dest, 0, 0);
232 232
 		    if ($result < 0)
233 233
 		    {
234 234
 		        $langs->load("errors");
235
-		        $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
235
+		        $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
236 236
 		        return 0;
237 237
 		    }
238 238
 		}
@@ -242,6 +242,6 @@  discard block
 block discarded – undo
242 242
 		    "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")"
243 243
 		);
244 244
 
245
-		return $this->_init($sql,$options);
245
+		return $this->_init($sql, $options);
246 246
 	}
247 247
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modPaybox.class.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -70,10 +70,10 @@
 block discarded – undo
70 70
 
71 71
         // Dependencies
72 72
         $this->hidden = false;			// A condition to hide module
73
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
74
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
75
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
76
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
73
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
74
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
75
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
76
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
77 77
         $this->need_dolibarr_version = array(2,6);	// Minimum version of Dolibarr required by module
78 78
         $this->langfiles = array("paybox");
79 79
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    paybox
24 24
  *  \brief      Description and activation file for module Paybox
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 
29 29
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         // It is used to group modules in module setup page
51 51
         $this->family = "interface";
52 52
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-        $this->name = preg_replace('/^mod/i','',get_class($this));
53
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
55 55
         $this->description = "Module to offer an online payment page by credit card with PayBox";
56 56
         // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         // Name of image file used for this module.
61 61
         // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
62 62
         // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'
63
-        $this->picto='paybox@paybox';
63
+        $this->picto = 'paybox@paybox';
64 64
 
65 65
         // Data directories to create when module is enabled.
66 66
         $this->dirs = array('/paybox/temp');
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
         $this->config_page_url = array("paybox.php@paybox");
70 70
 
71 71
         // Dependencies
72
-        $this->hidden = false;			// A condition to hide module
73
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
74
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
75
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
76
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
77
-        $this->need_dolibarr_version = array(2,6);	// Minimum version of Dolibarr required by module
72
+        $this->hidden = false; // A condition to hide module
73
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
74
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
75
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
76
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
77
+        $this->need_dolibarr_version = array(2, 6); // Minimum version of Dolibarr required by module
78 78
         $this->langfiles = array("paybox");
79 79
 
80 80
         // Constants
81
-        $this->const = array();			// List of particular constants to add when module is enabled
81
+        $this->const = array(); // List of particular constants to add when module is enabled
82 82
         //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),
83 83
         //                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );
84 84
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
 
89 89
         // Boxes
90
-        $this->boxes = array();			// List of boxes
91
-        $r=0;
90
+        $this->boxes = array(); // List of boxes
91
+        $r = 0;
92 92
 
93 93
         // Add here list of php file(s) stored in core/boxes that contains class to show a box.
94 94
         // Example:
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 
100 100
 
101 101
         // Permissions
102
-        $this->rights = array();		// Permission array used by this module
103
-        $r=0;
102
+        $this->rights = array(); // Permission array used by this module
103
+        $r = 0;
104 104
 
105 105
         // Add here list of permission defined by an id, a label, a boolean and two constant strings.
106 106
         // Example:
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
 
115 115
         // Main menu entries
116
-        $this->menus = array();			// List of menus to add
117
-        $r=0;
116
+        $this->menus = array(); // List of menus to add
117
+        $r = 0;
118 118
 
119 119
         // Add here entries to declare new menus
120 120
         // Example to declare the Top Menu entry:
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 
160 160
         // Exports
161
-        $r=1;
161
+        $r = 1;
162 162
 
163 163
         // Example:
164 164
         // $this->export_code[$r]=$this->rights_class.'_'.$r;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modStock.class.php 2 patches
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -35,363 +35,363 @@
 block discarded – undo
35 35
 class modStock extends DolibarrModules
36 36
 {
37 37
 
38
-	/**
39
-	 *   Constructor. Define names, constants, directories, boxes, permissions
40
-	 *
41
-	 *   @param      DoliDB		$db      Database handler
42
-	 */
43
-	function __construct($db)
44
-	{
45
-		global $conf, $langs;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 52;
49
-
50
-		$this->family = "products";
51
-		$this->module_position = '40';
52
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
-		$this->description = "Gestion des stocks";
55
-
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='stock';
61
-
62
-		// Data directories to create when module is enabled
63
-		$this->dirs = array("/stock/temp");
64
-
65
-		$this->config_page_url = array("stock.php");
66
-
67
-		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array("modProduct");		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array("modProductBatch");	// 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);		// Minimum version of PHP required by module
73
-		$this->langfiles = array("stocks");
74
-
75
-		// Constants
76
-		$this->const = array();
77
-		$r=0;
78
-
79
-		$this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1);
80
-
81
-		$r++;
82
-		$this->const[$r][0] = "STOCK_ADDON_PDF";
83
-		$this->const[$r][1] = "chaine";
84
-		$this->const[$r][2] = "Standard";
85
-		$this->const[$r][3] = 'Name of PDF model of stock';
86
-		$this->const[$r][4] = 0;
87
-
88
-		$r++;
89
-		$this->const[$r][0] = "MOUVEMENT_ADDON_PDF";
90
-		$this->const[$r][1] = "chaine";
91
-		$this->const[$r][2] = "StdMouvement";
92
-		$this->const[$r][3] = 'Name of PDF model of stock mouvement';
93
-		$this->const[$r][4] = 0;
94
-
95
-		$r++;
96
-		$this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH";
97
-		$this->const[$r][1] = "chaine";
98
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks";
99
-		$this->const[$r][3] = "";
100
-		$this->const[$r][4] = 0;
101
-
102
-		$r++;
103
-		$this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH";
104
-		$this->const[$r][1] = "chaine";
105
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements";
106
-		$this->const[$r][3] = "";
107
-		$this->const[$r][4] = 0;
108
-
109
-		// Boxes
110
-		$this->boxes = array();
111
-
112
-		// Permissions
113
-		$this->rights = array();
114
-		$this->rights_class = 'stock';
115
-
116
-		$this->rights[0][0] = 1001;
117
-		$this->rights[0][1] = 'Lire les stocks';
118
-		$this->rights[0][2] = 'r';
119
-		$this->rights[0][3] = 0;
120
-		$this->rights[0][4] = 'lire';
121
-		$this->rights[0][5] = '';
122
-
123
-		$this->rights[1][0] = 1002;
124
-		$this->rights[1][1] = 'Creer/Modifier les stocks';
125
-		$this->rights[1][2] = 'w';
126
-		$this->rights[1][3] = 0;
127
-		$this->rights[1][4] = 'creer';
128
-		$this->rights[1][5] = '';
129
-
130
-		$this->rights[2][0] = 1003;
131
-		$this->rights[2][1] = 'Supprimer les stocks';
132
-		$this->rights[2][2] = 'd';
133
-		$this->rights[2][3] = 0;
134
-		$this->rights[2][4] = 'supprimer';
135
-		$this->rights[2][5] = '';
136
-
137
-		$this->rights[3][0] = 1004;
138
-		$this->rights[3][1] = 'Lire mouvements de stocks';
139
-		$this->rights[3][2] = 'r';
140
-		$this->rights[3][3] = 0;
141
-		$this->rights[3][4] = 'mouvement';
142
-		$this->rights[3][5] = 'lire';
143
-
144
-		$this->rights[4][0] = 1005;
145
-		$this->rights[4][1] = 'Creer/modifier mouvements de stocks';
146
-		$this->rights[4][2] = 'w';
147
-		$this->rights[4][3] = 0;
148
-		$this->rights[4][4] = 'mouvement';
149
-		$this->rights[4][5] = 'creer';
150
-
151
-		if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
152
-
153
-		$this->rights[5][0] = 1011;
154
-		$this->rights[5][1] = 'inventoryReadPermission';	// Permission label
155
-		$this->rights[5][3] = 0; 					// Permission by default for new user (0/1)
156
-		$this->rights[5][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
157
-		$this->rights[5][5] = 'read';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
158
-
159
-		$this->rights[6][0] = 1012;
160
-		$this->rights[6][1] = 'inventoryCreatePermission';	// Permission label
161
-		$this->rights[6][3] = 0; 					// Permission by default for new user (0/1)
162
-		$this->rights[6][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
163
-		$this->rights[6][5] = 'write';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
164
-
165
-		$this->rights[8][0] = 1014;
166
-		$this->rights[8][1] = 'inventoryValidatePermission';	// Permission label
167
-		$this->rights[8][3] = 0; 					// Permission by default for new user (0/1)
168
-		$this->rights[8][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
169
-		$this->rights[8][5] = 'validate';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
170
-
171
-		$this->rights[9][0] = 1015;
172
-		$this->rights[9][1] = 'inventoryChangePMPPermission';	// Permission label
173
-		$this->rights[9][3] = 0; 					// Permission by default for new user (0/1)
174
-		$this->rights[9][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
175
-		$this->rights[9][5] = 'changePMP';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
176
-		}
177
-
178
-		// Main menu entries
179
-		$this->menu = array();			// List of menus to add
180
-		$r=0;
181
-
182
-		// Menus
183
-		//-------
184
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
185
-
186
-
187
-		// Exports
188
-		//--------
189
-		$r=0;
190
-
191
-		$r++;
192
-		$this->export_code[$r]=$this->rights_class;
193
-		$this->export_label[$r]="WarehousesAndProducts";	// Translation key (used only if key ExportDataset_xxx_z not found)
194
-		$this->export_permission[$r]=array(array("stock","lire"));
195
-		$this->export_fields_array[$r]=array(
196
-			'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
197
-			'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
198
-			'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
199
-			'p.tms'=>'DateModification','p.pmp'=>'PMPValue','p.cost_price'=>'CostPrice'
200
-		);
201
-		$this->export_TypeFields_array[$r]=array(
202
-			'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",
203
-			'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric',
204
-			'p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','p.pmp'=>'Numeric','p.cost_price'=>'Numeric',
205
-			'ps.reel'=>'Numeric'
206
-		);
207
-		$this->export_entities_array[$r]=array(
208
-			'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
209
-			'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
210
-			'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
211
-			'p.datec'=>'product','p.tms'=>'product','p.pmp'=>'product','p.cost_price'=>'product','ps.reel'=>'stock'
212
-		);
213
-		$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
214
-		$this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
215
-		$keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra';
216
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
217
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('ps.reel'=>'Stock'));
218
-
219
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
220
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
221
-		$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
222
-		$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
223
-		if ($conf->productbatch->enabled)
224
-		{
225
-			// Export of stock including lot number
226
-			$langs->load("productbatch");
227
-
228
-			// This request is same than previous but without field ps.stock (real stock in warehouse) and with link to subtable productbatch
229
-			$r++;
230
-
231
-			$this->export_code[$r]=$this->rights_class.'_lot';
232
-			$this->export_label[$r]="WarehousesAndProductsBatchDetail";	// Translation key (used only if key ExportDataset_xxx_z not found)
233
-			$this->export_permission[$r]=array(array("stock","lire"));
234
-			$this->export_fields_array[$r]=array(
235
-				'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
236
-				'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
237
-				'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
238
-				'p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.qty'=>'Qty','pl.eatby'=>'EatByDate','pl.sellby'=>'SellByDate'
239
-			);
240
-			$this->export_TypeFields_array[$r]=array(
241
-				'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.description'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
242
-				'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
243
-				'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
244
-				'pb.batch'=>'Text','pb.qty'=>'Numeric','pl.eatby'=>'Date','pl.sellby'=>'Date'
245
-			);
246
-			$this->export_entities_array[$r]=array(
247
-				'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
248
-				'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
249
-				'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
250
-				'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'stockbatch','pb.batch'=>'stockbatch','pb.qty'=>'stockbatch','pl.eatby'=>'batch',
251
-				'pl.sellby'=>'batch'
252
-			);
253
-			$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
254
-			$this->export_dependencies_array[$r]=array('stockbatch'=>array('pb.rowid'),'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
255
-			$keyforselect='product_lot'; $keyforelement='batch'; $keyforaliasextra='extra';
256
-			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
257
-			$this->export_sql_start[$r]='SELECT DISTINCT ';
258
-			$this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';
259
-			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
260
-			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
261
-			$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'entrepot as e';
262
-			$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
263
-			$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
264
-		}
265
-
266
-		// Export of stock movement
267
-		$r++;
268
-		$this->export_code[$r]=$this->rights_class.'_movement';
269
-		$this->export_label[$r]="StockMovements";	// Translation key (used only if key ExportDataset_xxx_z not found)
270
-		$this->export_permission[$r]=array(array("stock","lire"));
271
-		$this->export_fields_array[$r]=array(
272
-			'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip',
273
-			'e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",
274
-			'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
275
-			'p.tms'=>'DateModification','sm.rowid'=>'MovementId','sm.value'=>'Qty','sm.datem'=>'DateMovement','sm.label'=>'MovementLabel',
276
-			'sm.inventorycode'=>'InventoryCode'
277
-		);
278
-		$this->export_TypeFields_array[$r]=array(
279
-			'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.description'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
280
-			'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
281
-			'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
282
-			'sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text'
283
-		);
284
-		$this->export_entities_array[$r]=array(
285
-			'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
286
-			'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
287
-			'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product',
288
-			'p.tms'=>'product','sm.rowid'=>'movement','sm.value'=>'movement','sm.datem'=>'movement','sm.label'=>'movement','sm.inventorycode'=>'movement'
289
-		);
290
-		if ($conf->productbatch->enabled)
291
-		{
292
-			$this->export_fields_array[$r]['sm.batch']='Batch';
293
-			$this->export_TypeFields_array[$r]['sm.batch']='Text';
294
-			$this->export_entities_array[$r]['sm.batch']='movement';
295
-		}
296
-		$this->export_aggregate_array[$r]=array('sm.value'=>'SUM');    // TODO Not used yet
297
-		$this->export_dependencies_array[$r]=array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
298
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
299
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'stock_mouvement as sm, '.MAIN_DB_PREFIX.'entrepot as e';
300
-		$this->export_sql_end[$r] .=' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
301
-		$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
302
-
303
-		// Imports
304
-		//--------
305
-
306
-		$r=0;
307
-
308
-		// Import warehouses
309
-		$r++;
310
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
311
-		$this->import_label[$r]="Warehouses";	// Translation key
312
-		$this->import_icon[$r]=$this->picto;
313
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
314
-		$this->import_tables_array[$r]=array('e'=>MAIN_DB_PREFIX.'entrepot');
315
-		$this->import_tables_creator_array[$r]=array('e'=>'fk_user_author');
316
-		$this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*",
317
-				'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse",
318
-				'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode',
319
-				'e.statut'=>'Status'
320
-		);
321
-
322
-		$this->import_convertvalue_array[$r]=array(
323
-				'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry')
324
-		);
325
-		$this->import_regex_array[$r]=array('e.statut'=>'^[0|1]');
326
-		$this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001",
327
-				'e.description'=>"Central Warehouse",'e.lieu'=>"Central",
328
-				'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US',
329
-				'e.statut'=>'1');
330
-
331
-		// Import stocks
332
-		$r++;
333
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
334
-		$this->import_label[$r]="Stocks";	// Translation key
335
-		$this->import_icon[$r]=$this->picto;
336
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
337
-		$this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
338
-		$this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*");
339
-
340
-		$this->import_convertvalue_array[$r]=array(
341
-			'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
342
-			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref')
343
-		  );
344
-		$this->import_examplevalues_array[$r]=array(
345
-		    'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
346
-		);
347
-		$this->import_run_sql_after_array[$r]=array(    // Because we may change data that are denormalized, we must update dernormalized data after.
348
-		    'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
349
-		);
350
-	}
351
-
352
-
353
-	/**
354
-	 *		Function called when module is enabled.
355
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
356
-	 *		It also creates data directories
357
-	 *
358
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
359
-	 *      @return     int             	1 if OK, 0 if KO
360
-	 */
361
-	function init($options='')
362
-	{
363
-		global $conf,$langs;
364
-
365
-		// Permissions
366
-		$this->remove($options);
367
-
368
-		//ODT template
369
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';
370
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/stock';
371
-		$dest=$dirodt.'/template_stock.odt';
372
-
373
-		if (file_exists($src) && ! file_exists($dest))
374
-		{
375
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
376
-			dol_mkdir($dirodt);
377
-			$result=dol_copy($src,$dest,0,0);
378
-			if ($result < 0)
379
-			{
380
-				$langs->load("errors");
381
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
382
-				return 0;
383
-			}
384
-		}
385
-
386
-		$sql = array();
387
-
388
-		$sql = array(
389
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity,
390
-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")",
391
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity,
392
-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")",
393
-		);
394
-
395
-		return $this->_init($sql,$options);
396
-	}
38
+    /**
39
+     *   Constructor. Define names, constants, directories, boxes, permissions
40
+     *
41
+     *   @param      DoliDB		$db      Database handler
42
+     */
43
+    function __construct($db)
44
+    {
45
+        global $conf, $langs;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 52;
49
+
50
+        $this->family = "products";
51
+        $this->module_position = '40';
52
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->name = preg_replace('/^mod/i','',get_class($this));
54
+        $this->description = "Gestion des stocks";
55
+
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        $this->picto='stock';
61
+
62
+        // Data directories to create when module is enabled
63
+        $this->dirs = array("/stock/temp");
64
+
65
+        $this->config_page_url = array("stock.php");
66
+
67
+        // Dependencies
68
+        $this->hidden = false;			// A condition to hide module
69
+        $this->depends = array("modProduct");		// List of module class names as string that must be enabled if this module is enabled
70
+        $this->requiredby = array("modProductBatch");	// 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);		// Minimum version of PHP required by module
73
+        $this->langfiles = array("stocks");
74
+
75
+        // Constants
76
+        $this->const = array();
77
+        $r=0;
78
+
79
+        $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1);
80
+
81
+        $r++;
82
+        $this->const[$r][0] = "STOCK_ADDON_PDF";
83
+        $this->const[$r][1] = "chaine";
84
+        $this->const[$r][2] = "Standard";
85
+        $this->const[$r][3] = 'Name of PDF model of stock';
86
+        $this->const[$r][4] = 0;
87
+
88
+        $r++;
89
+        $this->const[$r][0] = "MOUVEMENT_ADDON_PDF";
90
+        $this->const[$r][1] = "chaine";
91
+        $this->const[$r][2] = "StdMouvement";
92
+        $this->const[$r][3] = 'Name of PDF model of stock mouvement';
93
+        $this->const[$r][4] = 0;
94
+
95
+        $r++;
96
+        $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH";
97
+        $this->const[$r][1] = "chaine";
98
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks";
99
+        $this->const[$r][3] = "";
100
+        $this->const[$r][4] = 0;
101
+
102
+        $r++;
103
+        $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH";
104
+        $this->const[$r][1] = "chaine";
105
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements";
106
+        $this->const[$r][3] = "";
107
+        $this->const[$r][4] = 0;
108
+
109
+        // Boxes
110
+        $this->boxes = array();
111
+
112
+        // Permissions
113
+        $this->rights = array();
114
+        $this->rights_class = 'stock';
115
+
116
+        $this->rights[0][0] = 1001;
117
+        $this->rights[0][1] = 'Lire les stocks';
118
+        $this->rights[0][2] = 'r';
119
+        $this->rights[0][3] = 0;
120
+        $this->rights[0][4] = 'lire';
121
+        $this->rights[0][5] = '';
122
+
123
+        $this->rights[1][0] = 1002;
124
+        $this->rights[1][1] = 'Creer/Modifier les stocks';
125
+        $this->rights[1][2] = 'w';
126
+        $this->rights[1][3] = 0;
127
+        $this->rights[1][4] = 'creer';
128
+        $this->rights[1][5] = '';
129
+
130
+        $this->rights[2][0] = 1003;
131
+        $this->rights[2][1] = 'Supprimer les stocks';
132
+        $this->rights[2][2] = 'd';
133
+        $this->rights[2][3] = 0;
134
+        $this->rights[2][4] = 'supprimer';
135
+        $this->rights[2][5] = '';
136
+
137
+        $this->rights[3][0] = 1004;
138
+        $this->rights[3][1] = 'Lire mouvements de stocks';
139
+        $this->rights[3][2] = 'r';
140
+        $this->rights[3][3] = 0;
141
+        $this->rights[3][4] = 'mouvement';
142
+        $this->rights[3][5] = 'lire';
143
+
144
+        $this->rights[4][0] = 1005;
145
+        $this->rights[4][1] = 'Creer/modifier mouvements de stocks';
146
+        $this->rights[4][2] = 'w';
147
+        $this->rights[4][3] = 0;
148
+        $this->rights[4][4] = 'mouvement';
149
+        $this->rights[4][5] = 'creer';
150
+
151
+        if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
152
+
153
+        $this->rights[5][0] = 1011;
154
+        $this->rights[5][1] = 'inventoryReadPermission';	// Permission label
155
+        $this->rights[5][3] = 0; 					// Permission by default for new user (0/1)
156
+        $this->rights[5][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
157
+        $this->rights[5][5] = 'read';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
158
+
159
+        $this->rights[6][0] = 1012;
160
+        $this->rights[6][1] = 'inventoryCreatePermission';	// Permission label
161
+        $this->rights[6][3] = 0; 					// Permission by default for new user (0/1)
162
+        $this->rights[6][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
163
+        $this->rights[6][5] = 'write';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
164
+
165
+        $this->rights[8][0] = 1014;
166
+        $this->rights[8][1] = 'inventoryValidatePermission';	// Permission label
167
+        $this->rights[8][3] = 0; 					// Permission by default for new user (0/1)
168
+        $this->rights[8][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
169
+        $this->rights[8][5] = 'validate';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
170
+
171
+        $this->rights[9][0] = 1015;
172
+        $this->rights[9][1] = 'inventoryChangePMPPermission';	// Permission label
173
+        $this->rights[9][3] = 0; 					// Permission by default for new user (0/1)
174
+        $this->rights[9][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
175
+        $this->rights[9][5] = 'changePMP';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
176
+        }
177
+
178
+        // Main menu entries
179
+        $this->menu = array();			// List of menus to add
180
+        $r=0;
181
+
182
+        // Menus
183
+        //-------
184
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
185
+
186
+
187
+        // Exports
188
+        //--------
189
+        $r=0;
190
+
191
+        $r++;
192
+        $this->export_code[$r]=$this->rights_class;
193
+        $this->export_label[$r]="WarehousesAndProducts";	// Translation key (used only if key ExportDataset_xxx_z not found)
194
+        $this->export_permission[$r]=array(array("stock","lire"));
195
+        $this->export_fields_array[$r]=array(
196
+            'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
197
+            'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
198
+            'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
199
+            'p.tms'=>'DateModification','p.pmp'=>'PMPValue','p.cost_price'=>'CostPrice'
200
+        );
201
+        $this->export_TypeFields_array[$r]=array(
202
+            'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",
203
+            'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric',
204
+            'p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','p.pmp'=>'Numeric','p.cost_price'=>'Numeric',
205
+            'ps.reel'=>'Numeric'
206
+        );
207
+        $this->export_entities_array[$r]=array(
208
+            'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
209
+            'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
210
+            'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
211
+            'p.datec'=>'product','p.tms'=>'product','p.pmp'=>'product','p.cost_price'=>'product','ps.reel'=>'stock'
212
+        );
213
+        $this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
214
+        $this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
215
+        $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra';
216
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
217
+        $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('ps.reel'=>'Stock'));
218
+
219
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
220
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
221
+        $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
222
+        $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
223
+        if ($conf->productbatch->enabled)
224
+        {
225
+            // Export of stock including lot number
226
+            $langs->load("productbatch");
227
+
228
+            // This request is same than previous but without field ps.stock (real stock in warehouse) and with link to subtable productbatch
229
+            $r++;
230
+
231
+            $this->export_code[$r]=$this->rights_class.'_lot';
232
+            $this->export_label[$r]="WarehousesAndProductsBatchDetail";	// Translation key (used only if key ExportDataset_xxx_z not found)
233
+            $this->export_permission[$r]=array(array("stock","lire"));
234
+            $this->export_fields_array[$r]=array(
235
+                'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
236
+                'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
237
+                'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
238
+                'p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.qty'=>'Qty','pl.eatby'=>'EatByDate','pl.sellby'=>'SellByDate'
239
+            );
240
+            $this->export_TypeFields_array[$r]=array(
241
+                'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.description'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
242
+                'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
243
+                'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
244
+                'pb.batch'=>'Text','pb.qty'=>'Numeric','pl.eatby'=>'Date','pl.sellby'=>'Date'
245
+            );
246
+            $this->export_entities_array[$r]=array(
247
+                'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
248
+                'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
249
+                'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
250
+                'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'stockbatch','pb.batch'=>'stockbatch','pb.qty'=>'stockbatch','pl.eatby'=>'batch',
251
+                'pl.sellby'=>'batch'
252
+            );
253
+            $this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
254
+            $this->export_dependencies_array[$r]=array('stockbatch'=>array('pb.rowid'),'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
255
+            $keyforselect='product_lot'; $keyforelement='batch'; $keyforaliasextra='extra';
256
+            include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
257
+            $this->export_sql_start[$r]='SELECT DISTINCT ';
258
+            $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';
259
+            $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
260
+            $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
261
+            $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'entrepot as e';
262
+            $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
263
+            $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
264
+        }
265
+
266
+        // Export of stock movement
267
+        $r++;
268
+        $this->export_code[$r]=$this->rights_class.'_movement';
269
+        $this->export_label[$r]="StockMovements";	// Translation key (used only if key ExportDataset_xxx_z not found)
270
+        $this->export_permission[$r]=array(array("stock","lire"));
271
+        $this->export_fields_array[$r]=array(
272
+            'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip',
273
+            'e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",
274
+            'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
275
+            'p.tms'=>'DateModification','sm.rowid'=>'MovementId','sm.value'=>'Qty','sm.datem'=>'DateMovement','sm.label'=>'MovementLabel',
276
+            'sm.inventorycode'=>'InventoryCode'
277
+        );
278
+        $this->export_TypeFields_array[$r]=array(
279
+            'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.description'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
280
+            'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
281
+            'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
282
+            'sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text'
283
+        );
284
+        $this->export_entities_array[$r]=array(
285
+            'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
286
+            'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
287
+            'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product',
288
+            'p.tms'=>'product','sm.rowid'=>'movement','sm.value'=>'movement','sm.datem'=>'movement','sm.label'=>'movement','sm.inventorycode'=>'movement'
289
+        );
290
+        if ($conf->productbatch->enabled)
291
+        {
292
+            $this->export_fields_array[$r]['sm.batch']='Batch';
293
+            $this->export_TypeFields_array[$r]['sm.batch']='Text';
294
+            $this->export_entities_array[$r]['sm.batch']='movement';
295
+        }
296
+        $this->export_aggregate_array[$r]=array('sm.value'=>'SUM');    // TODO Not used yet
297
+        $this->export_dependencies_array[$r]=array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
298
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
299
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'stock_mouvement as sm, '.MAIN_DB_PREFIX.'entrepot as e';
300
+        $this->export_sql_end[$r] .=' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
301
+        $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
302
+
303
+        // Imports
304
+        //--------
305
+
306
+        $r=0;
307
+
308
+        // Import warehouses
309
+        $r++;
310
+        $this->import_code[$r]=$this->rights_class.'_'.$r;
311
+        $this->import_label[$r]="Warehouses";	// Translation key
312
+        $this->import_icon[$r]=$this->picto;
313
+        $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
314
+        $this->import_tables_array[$r]=array('e'=>MAIN_DB_PREFIX.'entrepot');
315
+        $this->import_tables_creator_array[$r]=array('e'=>'fk_user_author');
316
+        $this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*",
317
+                'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse",
318
+                'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode',
319
+                'e.statut'=>'Status'
320
+        );
321
+
322
+        $this->import_convertvalue_array[$r]=array(
323
+                'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry')
324
+        );
325
+        $this->import_regex_array[$r]=array('e.statut'=>'^[0|1]');
326
+        $this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001",
327
+                'e.description'=>"Central Warehouse",'e.lieu'=>"Central",
328
+                'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US',
329
+                'e.statut'=>'1');
330
+
331
+        // Import stocks
332
+        $r++;
333
+        $this->import_code[$r]=$this->rights_class.'_'.$r;
334
+        $this->import_label[$r]="Stocks";	// Translation key
335
+        $this->import_icon[$r]=$this->picto;
336
+        $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
337
+        $this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
338
+        $this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*");
339
+
340
+        $this->import_convertvalue_array[$r]=array(
341
+            'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
342
+            'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref')
343
+            );
344
+        $this->import_examplevalues_array[$r]=array(
345
+            'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
346
+        );
347
+        $this->import_run_sql_after_array[$r]=array(    // Because we may change data that are denormalized, we must update dernormalized data after.
348
+            'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
349
+        );
350
+    }
351
+
352
+
353
+    /**
354
+     *		Function called when module is enabled.
355
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
356
+     *		It also creates data directories
357
+     *
358
+     *      @param      string	$options    Options when enabling module ('', 'noboxes')
359
+     *      @return     int             	1 if OK, 0 if KO
360
+     */
361
+    function init($options='')
362
+    {
363
+        global $conf,$langs;
364
+
365
+        // Permissions
366
+        $this->remove($options);
367
+
368
+        //ODT template
369
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';
370
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/stock';
371
+        $dest=$dirodt.'/template_stock.odt';
372
+
373
+        if (file_exists($src) && ! file_exists($dest))
374
+        {
375
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
376
+            dol_mkdir($dirodt);
377
+            $result=dol_copy($src,$dest,0,0);
378
+            if ($result < 0)
379
+            {
380
+                $langs->load("errors");
381
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
382
+                return 0;
383
+            }
384
+        }
385
+
386
+        $sql = array();
387
+
388
+        $sql = array(
389
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity,
390
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")",
391
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity,
392
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")",
393
+        );
394
+
395
+        return $this->_init($sql,$options);
396
+    }
397 397
 }
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      Fichier de description et activation du module Stock
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 		$this->family = "products";
51 51
 		$this->module_position = '40';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Gestion des stocks";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='stock';
60
+		$this->picto = 'stock';
61 61
 
62 62
 		// Data directories to create when module is enabled
63 63
 		$this->dirs = array("/stock/temp");
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 		$this->config_page_url = array("stock.php");
66 66
 
67 67
 		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array("modProduct");		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array("modProductBatch");	// 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);		// Minimum version of PHP required by module
68
+		$this->hidden = false; // A condition to hide module
69
+		$this->depends = array("modProduct"); // List of module class names as string that must be enabled if this module is enabled
70
+		$this->requiredby = array("modProductBatch"); // 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); // Minimum version of PHP required by module
73 73
 		$this->langfiles = array("stocks");
74 74
 
75 75
 		// Constants
76 76
 		$this->const = array();
77
-		$r=0;
77
+		$r = 0;
78 78
 
79
-		$this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1);
79
+		$this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER', 'chaine', '1', '', 1);
80 80
 
81 81
 		$r++;
82 82
 		$this->const[$r][0] = "STOCK_ADDON_PDF";
@@ -151,75 +151,75 @@  discard block
 block discarded – undo
151 151
 		if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
152 152
 
153 153
 		$this->rights[5][0] = 1011;
154
-		$this->rights[5][1] = 'inventoryReadPermission';	// Permission label
155
-		$this->rights[5][3] = 0; 					// Permission by default for new user (0/1)
156
-		$this->rights[5][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
157
-		$this->rights[5][5] = 'read';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
154
+		$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
155
+		$this->rights[5][3] = 0; // Permission by default for new user (0/1)
156
+		$this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
157
+		$this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
158 158
 
159 159
 		$this->rights[6][0] = 1012;
160
-		$this->rights[6][1] = 'inventoryCreatePermission';	// Permission label
161
-		$this->rights[6][3] = 0; 					// Permission by default for new user (0/1)
162
-		$this->rights[6][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
163
-		$this->rights[6][5] = 'write';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
160
+		$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
161
+		$this->rights[6][3] = 0; // Permission by default for new user (0/1)
162
+		$this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
163
+		$this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
164 164
 
165 165
 		$this->rights[8][0] = 1014;
166
-		$this->rights[8][1] = 'inventoryValidatePermission';	// Permission label
167
-		$this->rights[8][3] = 0; 					// Permission by default for new user (0/1)
168
-		$this->rights[8][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
169
-		$this->rights[8][5] = 'validate';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
166
+		$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label
167
+		$this->rights[8][3] = 0; // Permission by default for new user (0/1)
168
+		$this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
169
+		$this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
170 170
 
171 171
 		$this->rights[9][0] = 1015;
172
-		$this->rights[9][1] = 'inventoryChangePMPPermission';	// Permission label
173
-		$this->rights[9][3] = 0; 					// Permission by default for new user (0/1)
174
-		$this->rights[9][4] = 'inventory_advance';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
175
-		$this->rights[9][5] = 'changePMP';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
172
+		$this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label
173
+		$this->rights[9][3] = 0; // Permission by default for new user (0/1)
174
+		$this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
175
+		$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
176 176
 		}
177 177
 
178 178
 		// Main menu entries
179
-		$this->menu = array();			// List of menus to add
180
-		$r=0;
179
+		$this->menu = array(); // List of menus to add
180
+		$r = 0;
181 181
 
182 182
 		// Menus
183 183
 		//-------
184
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
184
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
185 185
 
186 186
 
187 187
 		// Exports
188 188
 		//--------
189
-		$r=0;
189
+		$r = 0;
190 190
 
191 191
 		$r++;
192
-		$this->export_code[$r]=$this->rights_class;
193
-		$this->export_label[$r]="WarehousesAndProducts";	// Translation key (used only if key ExportDataset_xxx_z not found)
194
-		$this->export_permission[$r]=array(array("stock","lire"));
195
-		$this->export_fields_array[$r]=array(
196
-			'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
197
-			'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
198
-			'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
199
-			'p.tms'=>'DateModification','p.pmp'=>'PMPValue','p.cost_price'=>'CostPrice'
192
+		$this->export_code[$r] = $this->rights_class;
193
+		$this->export_label[$r] = "WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
194
+		$this->export_permission[$r] = array(array("stock", "lire"));
195
+		$this->export_fields_array[$r] = array(
196
+			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address',
197
+			'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description",
198
+			'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',
199
+			'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice'
200 200
 		);
201
-		$this->export_TypeFields_array[$r]=array(
202
-			'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",
203
-			'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric',
204
-			'p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','p.pmp'=>'Numeric','p.cost_price'=>'Numeric',
201
+		$this->export_TypeFields_array[$r] = array(
202
+			'e.rowid'=>'List:entrepot:ref', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label",
203
+			'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric',
204
+			'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric',
205 205
 			'ps.reel'=>'Numeric'
206 206
 		);
207
-		$this->export_entities_array[$r]=array(
208
-			'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
209
-			'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
210
-			'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
211
-			'p.datec'=>'product','p.tms'=>'product','p.pmp'=>'product','p.cost_price'=>'product','ps.reel'=>'stock'
207
+		$this->export_entities_array[$r] = array(
208
+			'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',
209
+			'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",
210
+			'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",
211
+			'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', 'ps.reel'=>'stock'
212 212
 		);
213
-		$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
214
-		$this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
215
-		$keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra';
213
+		$this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet
214
+		$this->export_dependencies_array[$r] = array('stock'=>array('p.rowid', 'e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
215
+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
216 216
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
217
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('ps.reel'=>'Stock'));
217
+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ps.reel'=>'Stock'));
218 218
 
219
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
220
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
221
-		$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
222
-		$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
219
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
220
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
221
+		$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
222
+		$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
223 223
 		if ($conf->productbatch->enabled)
224 224
 		{
225 225
 			// Export of stock including lot number
@@ -228,123 +228,123 @@  discard block
 block discarded – undo
228 228
 			// This request is same than previous but without field ps.stock (real stock in warehouse) and with link to subtable productbatch
229 229
 			$r++;
230 230
 
231
-			$this->export_code[$r]=$this->rights_class.'_lot';
232
-			$this->export_label[$r]="WarehousesAndProductsBatchDetail";	// Translation key (used only if key ExportDataset_xxx_z not found)
233
-			$this->export_permission[$r]=array(array("stock","lire"));
234
-			$this->export_fields_array[$r]=array(
235
-				'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address',
236
-				'e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",
237
-				'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
238
-				'p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.qty'=>'Qty','pl.eatby'=>'EatByDate','pl.sellby'=>'SellByDate'
231
+			$this->export_code[$r] = $this->rights_class.'_lot';
232
+			$this->export_label[$r] = "WarehousesAndProductsBatchDetail"; // Translation key (used only if key ExportDataset_xxx_z not found)
233
+			$this->export_permission[$r] = array(array("stock", "lire"));
234
+			$this->export_fields_array[$r] = array(
235
+				'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address',
236
+				'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description",
237
+				'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',
238
+				'p.tms'=>'DateModification', 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty', 'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate'
239 239
 			);
240
-			$this->export_TypeFields_array[$r]=array(
241
-				'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.description'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
242
-				'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
243
-				'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
244
-				'pb.batch'=>'Text','pb.qty'=>'Numeric','pl.eatby'=>'Date','pl.sellby'=>'Date'
240
+			$this->export_TypeFields_array[$r] = array(
241
+				'e.rowid'=>'List:entrepot:ref', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.description'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text',
242
+				'p.rowid'=>"List:product:label", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",
243
+				'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date',
244
+				'pb.batch'=>'Text', 'pb.qty'=>'Numeric', 'pl.eatby'=>'Date', 'pl.sellby'=>'Date'
245 245
 			);
246
-			$this->export_entities_array[$r]=array(
247
-				'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
248
-				'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
249
-				'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",
250
-				'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'stockbatch','pb.batch'=>'stockbatch','pb.qty'=>'stockbatch','pl.eatby'=>'batch',
246
+			$this->export_entities_array[$r] = array(
247
+				'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',
248
+				'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",
249
+				'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",
250
+				'p.datec'=>'product', 'p.tms'=>'product', 'pb.rowid'=>'stockbatch', 'pb.batch'=>'stockbatch', 'pb.qty'=>'stockbatch', 'pl.eatby'=>'batch',
251 251
 				'pl.sellby'=>'batch'
252 252
 			);
253
-			$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
254
-			$this->export_dependencies_array[$r]=array('stockbatch'=>array('pb.rowid'),'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
255
-			$keyforselect='product_lot'; $keyforelement='batch'; $keyforaliasextra='extra';
253
+			$this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet
254
+			$this->export_dependencies_array[$r] = array('stockbatch'=>array('pb.rowid'), 'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
255
+			$keyforselect = 'product_lot'; $keyforelement = 'batch'; $keyforaliasextra = 'extra';
256 256
 			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
257
-			$this->export_sql_start[$r]='SELECT DISTINCT ';
258
-			$this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';
259
-			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
260
-			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
261
-			$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'entrepot as e';
262
-			$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
263
-			$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
257
+			$this->export_sql_start[$r] = 'SELECT DISTINCT ';
258
+			$this->export_sql_end[$r]  = ' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';
259
+			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
260
+			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
261
+			$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'entrepot as e';
262
+			$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
263
+			$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
264 264
 		}
265 265
 
266 266
 		// Export of stock movement
267 267
 		$r++;
268
-		$this->export_code[$r]=$this->rights_class.'_movement';
269
-		$this->export_label[$r]="StockMovements";	// Translation key (used only if key ExportDataset_xxx_z not found)
270
-		$this->export_permission[$r]=array(array("stock","lire"));
271
-		$this->export_fields_array[$r]=array(
272
-			'e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip',
273
-			'e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",
274
-			'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation',
275
-			'p.tms'=>'DateModification','sm.rowid'=>'MovementId','sm.value'=>'Qty','sm.datem'=>'DateMovement','sm.label'=>'MovementLabel',
268
+		$this->export_code[$r] = $this->rights_class.'_movement';
269
+		$this->export_label[$r] = "StockMovements"; // Translation key (used only if key ExportDataset_xxx_z not found)
270
+		$this->export_permission[$r] = array(array("stock", "lire"));
271
+		$this->export_fields_array[$r] = array(
272
+			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip',
273
+			'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note",
274
+			'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',
275
+			'p.tms'=>'DateModification', 'sm.rowid'=>'MovementId', 'sm.value'=>'Qty', 'sm.datem'=>'DateMovement', 'sm.label'=>'MovementLabel',
276 276
 			'sm.inventorycode'=>'InventoryCode'
277 277
 		);
278
-		$this->export_TypeFields_array[$r]=array(
279
-			'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.description'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text',
280
-			'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",
281
-			'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date',
282
-			'sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text'
278
+		$this->export_TypeFields_array[$r] = array(
279
+			'e.rowid'=>'List:entrepot:ref', 'e.ref'=>'Text', 'e.description'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text',
280
+			'p.rowid'=>"List:product:label", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",
281
+			'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date',
282
+			'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text'
283 283
 		);
284
-		$this->export_entities_array[$r]=array(
285
-			'e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse',
286
-			'e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",
287
-			'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product',
288
-			'p.tms'=>'product','sm.rowid'=>'movement','sm.value'=>'movement','sm.datem'=>'movement','sm.label'=>'movement','sm.inventorycode'=>'movement'
284
+		$this->export_entities_array[$r] = array(
285
+			'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',
286
+			'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",
287
+			'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product',
288
+			'p.tms'=>'product', 'sm.rowid'=>'movement', 'sm.value'=>'movement', 'sm.datem'=>'movement', 'sm.label'=>'movement', 'sm.inventorycode'=>'movement'
289 289
 		);
290 290
 		if ($conf->productbatch->enabled)
291 291
 		{
292
-			$this->export_fields_array[$r]['sm.batch']='Batch';
293
-			$this->export_TypeFields_array[$r]['sm.batch']='Text';
294
-			$this->export_entities_array[$r]['sm.batch']='movement';
292
+			$this->export_fields_array[$r]['sm.batch'] = 'Batch';
293
+			$this->export_TypeFields_array[$r]['sm.batch'] = 'Text';
294
+			$this->export_entities_array[$r]['sm.batch'] = 'movement';
295 295
 		}
296
-		$this->export_aggregate_array[$r]=array('sm.value'=>'SUM');    // TODO Not used yet
297
-		$this->export_dependencies_array[$r]=array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
298
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
299
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'stock_mouvement as sm, '.MAIN_DB_PREFIX.'entrepot as e';
300
-		$this->export_sql_end[$r] .=' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
301
-		$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
296
+		$this->export_aggregate_array[$r] = array('sm.value'=>'SUM'); // TODO Not used yet
297
+		$this->export_dependencies_array[$r] = array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
298
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
299
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'stock_mouvement as sm, '.MAIN_DB_PREFIX.'entrepot as e';
300
+		$this->export_sql_end[$r] .= ' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
301
+		$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
302 302
 
303 303
 		// Imports
304 304
 		//--------
305 305
 
306
-		$r=0;
306
+		$r = 0;
307 307
 
308 308
 		// Import warehouses
309 309
 		$r++;
310
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
311
-		$this->import_label[$r]="Warehouses";	// Translation key
312
-		$this->import_icon[$r]=$this->picto;
313
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
314
-		$this->import_tables_array[$r]=array('e'=>MAIN_DB_PREFIX.'entrepot');
315
-		$this->import_tables_creator_array[$r]=array('e'=>'fk_user_author');
316
-		$this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*",
317
-				'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse",
318
-				'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode',
310
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
311
+		$this->import_label[$r] = "Warehouses"; // Translation key
312
+		$this->import_icon[$r] = $this->picto;
313
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
314
+		$this->import_tables_array[$r] = array('e'=>MAIN_DB_PREFIX.'entrepot');
315
+		$this->import_tables_creator_array[$r] = array('e'=>'fk_user_author');
316
+		$this->import_fields_array[$r] = array('e.ref'=>"LocationSummary*",
317
+				'e.description'=>"DescWareHouse", 'e.lieu'=>"LieuWareHouse",
318
+				'e.address'=>"Address", 'e.zip'=>'Zip', 'e.fk_pays'=>'CountryCode',
319 319
 				'e.statut'=>'Status'
320 320
 		);
321 321
 
322
-		$this->import_convertvalue_array[$r]=array(
323
-				'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry')
322
+		$this->import_convertvalue_array[$r] = array(
323
+				'e.fk_pays'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry')
324 324
 		);
325
-		$this->import_regex_array[$r]=array('e.statut'=>'^[0|1]');
326
-		$this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001",
327
-				'e.description'=>"Central Warehouse",'e.lieu'=>"Central",
328
-				'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US',
325
+		$this->import_regex_array[$r] = array('e.statut'=>'^[0|1]');
326
+		$this->import_examplevalues_array[$r] = array('e.ref'=>"ALM001",
327
+				'e.description'=>"Central Warehouse", 'e.lieu'=>"Central",
328
+				'e.address'=>"Route 66", 'e.zip'=>'28080', 'e.fk_pays'=>'US',
329 329
 				'e.statut'=>'1');
330 330
 
331 331
 		// Import stocks
332 332
 		$r++;
333
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
334
-		$this->import_label[$r]="Stocks";	// Translation key
335
-		$this->import_icon[$r]=$this->picto;
336
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
337
-		$this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
338
-		$this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*");
339
-
340
-		$this->import_convertvalue_array[$r]=array(
341
-			'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
342
-			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref')
333
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
334
+		$this->import_label[$r] = "Stocks"; // Translation key
335
+		$this->import_icon[$r] = $this->picto;
336
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
337
+		$this->import_tables_array[$r] = array('ps'=>MAIN_DB_PREFIX.'product_stock');
338
+		$this->import_fields_array[$r] = array('ps.fk_product'=>"Product*", 'ps.fk_entrepot'=>"Warehouse*", 'ps.reel'=>"Stock*");
339
+
340
+		$this->import_convertvalue_array[$r] = array(
341
+			'ps.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product'),
342
+			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref')
343 343
 		  );
344
-		$this->import_examplevalues_array[$r]=array(
345
-		    'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
344
+		$this->import_examplevalues_array[$r] = array(
345
+		    'ps.fk_product'=>"PREF123456", 'ps.fk_entrepot'=>"ALM001", 'ps.reel'=>"10"
346 346
 		);
347
-		$this->import_run_sql_after_array[$r]=array(    // Because we may change data that are denormalized, we must update dernormalized data after.
347
+		$this->import_run_sql_after_array[$r] = array(    // Because we may change data that are denormalized, we must update dernormalized data after.
348 348
 		    'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
349 349
 		);
350 350
 	}
@@ -358,27 +358,27 @@  discard block
 block discarded – undo
358 358
 	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
359 359
 	 *      @return     int             	1 if OK, 0 if KO
360 360
 	 */
361
-	function init($options='')
361
+	function init($options = '')
362 362
 	{
363
-		global $conf,$langs;
363
+		global $conf, $langs;
364 364
 
365 365
 		// Permissions
366 366
 		$this->remove($options);
367 367
 
368 368
 		//ODT template
369
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';
370
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/stock';
371
-		$dest=$dirodt.'/template_stock.odt';
369
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';
370
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/stock';
371
+		$dest = $dirodt.'/template_stock.odt';
372 372
 
373
-		if (file_exists($src) && ! file_exists($dest))
373
+		if (file_exists($src) && !file_exists($dest))
374 374
 		{
375 375
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
376 376
 			dol_mkdir($dirodt);
377
-			$result=dol_copy($src,$dest,0,0);
377
+			$result = dol_copy($src, $dest, 0, 0);
378 378
 			if ($result < 0)
379 379
 			{
380 380
 				$langs->load("errors");
381
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
381
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
382 382
 				return 0;
383 383
 			}
384 384
 		}
@@ -392,6 +392,6 @@  discard block
 block discarded – undo
392 392
 			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")",
393 393
 		);
394 394
 
395
-		return $this->_init($sql,$options);
395
+		return $this->_init($sql, $options);
396 396
 	}
397 397
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/product_batch/modules_product_batch.class.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -31,37 +31,37 @@
 block discarded – undo
31 31
  *  \brief      File with parent class for generating contracts to PDF and File of class to manage contract numbering
32 32
  */
33 33
 
34
- require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
34
+    require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
35 35
 
36 36
 /**
37 37
  *	Parent class to manage intervention document templates
38 38
  */
39 39
 abstract class ModelePDFProductBatch extends CommonDocGenerator
40 40
 {
41
-	/**
42
-	 * @var string Error code (or message)
43
-	 */
44
-	public $error='';
41
+    /**
42
+     * @var string Error code (or message)
43
+     */
44
+    public $error='';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
48 48
     /**
49
-	 *  Return list of active generation modules
50
-	 *
49
+     *  Return list of active generation modules
50
+     *
51 51
      *  @param  DoliDB	$db     			Database handler
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54 54
      */
55 55
     static function liste_modeles($db, $maxfilenamelength=0)
56
-	{
56
+    {
57 57
         // phpcs:enable
58
-		global $conf;
58
+        global $conf;
59 59
 
60
-		$type='product_batch';
61
-		$list = array();
60
+        $type='product_batch';
61
+        $list = array();
62 62
 
63
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
-		$list = getListOfModels($db, $type, $maxfilenamelength);
65
-		return $list;
66
-	}
63
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
+        $list = getListOfModels($db, $type, $maxfilenamelength);
65
+        return $list;
66
+    }
67 67
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @var string Error code (or message)
43 43
 	 */
44
-	public $error='';
44
+	public $error = '';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54 54
      */
55
-    static function liste_modeles($db, $maxfilenamelength=0)
55
+    static function liste_modeles($db, $maxfilenamelength = 0)
56 56
 	{
57 57
         // phpcs:enable
58 58
 		global $conf;
59 59
 
60
-		$type='product_batch';
60
+		$type = 'product_batch';
61 61
 		$list = array();
62 62
 
63 63
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
Please login to merge, or discard this patch.
htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php 3 patches
Indentation   +435 added lines, -435 removed lines patch added patch discarded remove patch
@@ -37,136 +37,136 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class doc_generic_product_odt extends ModelePDFProduct
39 39
 {
40
-	/**
41
-	 * Issuer
42
-	 * @var Societe
43
-	 */
44
-	public $emetteur;
45
-
46
-	/**
47
-   * @var array() Minimum version of PHP required by module.
48
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
49
-   */
50
-	public $phpmin = array(5, 4);
51
-
52
-	/**
40
+    /**
41
+     * Issuer
42
+     * @var Societe
43
+     */
44
+    public $emetteur;
45
+
46
+    /**
47
+     * @var array() Minimum version of PHP required by module.
48
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
49
+     */
50
+    public $phpmin = array(5, 4);
51
+
52
+    /**
53 53
      * Dolibarr version of the loaded document
54 54
      * @public string
55 55
      */
56
-	public $version = 'dolibarr';
56
+    public $version = 'dolibarr';
57 57
 
58 58
 
59
-	/**
60
-	 *	Constructor
61
-	 *
62
-	 *  @param		DoliDB		$db      Database handler
63
-	 */
64
-	function __construct($db)
65
-	{
66
-		global $conf, $langs, $mysoc;
59
+    /**
60
+     *	Constructor
61
+     *
62
+     *  @param		DoliDB		$db      Database handler
63
+     */
64
+    function __construct($db)
65
+    {
66
+        global $conf, $langs, $mysoc;
67 67
 
68
-		// Load translation files required by the page
68
+        // Load translation files required by the page
69 69
         $langs->loadLangs(array("main","companies"));
70 70
 
71
-		$this->db = $db;
72
-		$this->name = "ODT templates";
73
-		$this->description = $langs->trans("DocumentModelOdt");
74
-		$this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
-
76
-		// Dimension page pour format A4
77
-		$this->type = 'odt';
78
-		$this->page_largeur = 0;
79
-		$this->page_hauteur = 0;
80
-		$this->format = array($this->page_largeur,$this->page_hauteur);
81
-		$this->marge_gauche=0;
82
-		$this->marge_droite=0;
83
-		$this->marge_haute=0;
84
-		$this->marge_basse=0;
85
-
86
-		$this->option_logo = 1;                    // Affiche logo
87
-		$this->option_tva = 0;                     // Gere option tva PRODUCT_TVAOPTION
88
-		$this->option_modereg = 0;                 // Affiche mode reglement
89
-		$this->option_condreg = 0;                 // Affiche conditions reglement
90
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
91
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
92
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
93
-		$this->option_credit_note = 0;             // Support credit notes
94
-		$this->option_freetext = 1;				   // Support add of a personalised text
95
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
96
-
97
-		// Recupere emetteur
98
-		$this->emetteur=$mysoc;
99
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
100
-	}
101
-
102
-
103
-	/**
104
-	 *	Return description of a module
105
-	 *
106
-	 *	@param	Translate	$langs      Lang object to use for output
107
-	 *	@return string       			Description
108
-	 */
109
-	function info($langs)
110
-	{
111
-		global $conf, $langs;
112
-
113
-		// Load translation files required by the page
71
+        $this->db = $db;
72
+        $this->name = "ODT templates";
73
+        $this->description = $langs->trans("DocumentModelOdt");
74
+        $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
+
76
+        // Dimension page pour format A4
77
+        $this->type = 'odt';
78
+        $this->page_largeur = 0;
79
+        $this->page_hauteur = 0;
80
+        $this->format = array($this->page_largeur,$this->page_hauteur);
81
+        $this->marge_gauche=0;
82
+        $this->marge_droite=0;
83
+        $this->marge_haute=0;
84
+        $this->marge_basse=0;
85
+
86
+        $this->option_logo = 1;                    // Affiche logo
87
+        $this->option_tva = 0;                     // Gere option tva PRODUCT_TVAOPTION
88
+        $this->option_modereg = 0;                 // Affiche mode reglement
89
+        $this->option_condreg = 0;                 // Affiche conditions reglement
90
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
91
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
92
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
93
+        $this->option_credit_note = 0;             // Support credit notes
94
+        $this->option_freetext = 1;				   // Support add of a personalised text
95
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
96
+
97
+        // Recupere emetteur
98
+        $this->emetteur=$mysoc;
99
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
100
+    }
101
+
102
+
103
+    /**
104
+     *	Return description of a module
105
+     *
106
+     *	@param	Translate	$langs      Lang object to use for output
107
+     *	@return string       			Description
108
+     */
109
+    function info($langs)
110
+    {
111
+        global $conf, $langs;
112
+
113
+        // Load translation files required by the page
114 114
         $langs->loadLangs(array("errors","companies"));
115 115
 
116
-		$form = new Form($this->db);
117
-
118
-		$texte = $this->description.".<br>\n";
119
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
120
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
121
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
122
-		$texte.= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
123
-		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
124
-		{
125
-			$texte.= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
126
-			$texte.= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
127
-			$texte.= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
128
-		}
129
-		$texte.= '<table class="nobordernopadding" width="100%">';
130
-
131
-		// List of directories area
132
-		$texte.= '<tr><td>';
133
-		$texttitle=$langs->trans("ListOfDirectories");
134
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
135
-		$listoffiles=array();
136
-		foreach($listofdir as $key=>$tmpdir)
137
-		{
138
-			$tmpdir=trim($tmpdir);
139
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
140
-			if (! $tmpdir) {
141
-				unset($listofdir[$key]); continue;
142
-			}
143
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
-			else
145
-			{
146
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
147
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
-			}
149
-		}
150
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
151
-		// Add list of substitution keys
152
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
153
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
154
-
155
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
156
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
157
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
158
-		$texte.=$conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
159
-		$texte.= '</textarea>';
160
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
161
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
162
-		$texte.= '<br></div></div>';
163
-
164
-		// Scan directories
165
-		if (count($listofdir))
166
-		{
167
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
168
-
169
-			/*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0)
116
+        $form = new Form($this->db);
117
+
118
+        $texte = $this->description.".<br>\n";
119
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
120
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
121
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
122
+        $texte.= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
123
+        if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
124
+        {
125
+            $texte.= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
126
+            $texte.= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
127
+            $texte.= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
128
+        }
129
+        $texte.= '<table class="nobordernopadding" width="100%">';
130
+
131
+        // List of directories area
132
+        $texte.= '<tr><td>';
133
+        $texttitle=$langs->trans("ListOfDirectories");
134
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
135
+        $listoffiles=array();
136
+        foreach($listofdir as $key=>$tmpdir)
137
+        {
138
+            $tmpdir=trim($tmpdir);
139
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
140
+            if (! $tmpdir) {
141
+                unset($listofdir[$key]); continue;
142
+            }
143
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
+            else
145
+            {
146
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
147
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+            }
149
+        }
150
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
151
+        // Add list of substitution keys
152
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
153
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
154
+
155
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
156
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
157
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
158
+        $texte.=$conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
159
+        $texte.= '</textarea>';
160
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
161
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
162
+        $texte.= '<br></div></div>';
163
+
164
+        // Scan directories
165
+        if (count($listofdir))
166
+        {
167
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
168
+
169
+            /*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0)
170 170
 			{
171 171
 				// Model for creation
172 172
 				$liste=ModelePDFProduct::liste_modeles($this->db);
@@ -190,336 +190,336 @@  discard block
 block discarded – undo
190 190
 				$texte.= "</td></tr>";
191 191
 				$texte.= '</table>';
192 192
 			}*/
193
-		}
193
+        }
194 194
 
195
-		$texte.= '</td>';
195
+        $texte.= '</td>';
196 196
 
197
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
198
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
199
-		$texte.= '</td>';
200
-		$texte.= '</tr>';
197
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
198
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
199
+        $texte.= '</td>';
200
+        $texte.= '</tr>';
201 201
 
202
-		$texte.= '</table>';
203
-		$texte.= '</form>';
202
+        $texte.= '</table>';
203
+        $texte.= '</form>';
204 204
 
205
-		return $texte;
206
-	}
205
+        return $texte;
206
+    }
207 207
 
208 208
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
209
-	/**
210
-	 *	Function to build a document on disk using the generic odt module.
211
-	 *
212
-	 *	@param		Product		$object				Object source to build document
213
-	 *	@param		Translate	$outputlangs		Lang output object
214
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
215
-	 *  @param		int			$hidedetails		Do not show line details
216
-	 *  @param		int			$hidedesc			Do not show desc
217
-	 *  @param		int			$hideref			Do not show ref
218
-	 *	@return		int         					1 if OK, <=0 if KO
219
-	 */
220
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
221
-	{
209
+    /**
210
+     *	Function to build a document on disk using the generic odt module.
211
+     *
212
+     *	@param		Product		$object				Object source to build document
213
+     *	@param		Translate	$outputlangs		Lang output object
214
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
215
+     *  @param		int			$hidedetails		Do not show line details
216
+     *  @param		int			$hidedesc			Do not show desc
217
+     *  @param		int			$hideref			Do not show ref
218
+     *	@return		int         					1 if OK, <=0 if KO
219
+     */
220
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
221
+    {
222 222
         // phpcs:enable
223
-		global $product,$langs,$conf,$mysoc,$hookmanager,$user;
224
-
225
-		if (empty($srctemplatepath))
226
-		{
227
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
228
-			return -1;
229
-		}
230
-
231
-		// Add odtgeneration hook
232
-		if (! is_object($hookmanager))
233
-		{
234
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
235
-			$hookmanager=new HookManager($this->db);
236
-		}
237
-		$hookmanager->initHooks(array('odtgeneration'));
238
-		global $action;
239
-
240
-		if (! is_object($outputlangs)) $outputlangs=$langs;
241
-		$sav_charset_output=$outputlangs->charset_output;
242
-		$outputlangs->charset_output='UTF-8';
243
-
244
-		// Load translation files required by the page
245
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
246
-
247
-		if ($conf->produit->dir_output)
248
-		{
249
-			// If $object is id instead of object
250
-			if (! is_object($object))
251
-			{
252
-				$id = $object;
253
-				$object = new Product($this->db);
254
-				$result=$object->fetch($id);
255
-				if ($result < 0)
256
-				{
257
-					dol_print_error($this->db,$object->error);
258
-					return -1;
259
-				}
260
-			}
261
-			$productFournisseur = new ProductFournisseur($this->db);
262
-			$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
263
-			$object->supplierprices = $supplierprices;
264
-
265
-			$dir = $conf->produit->dir_output;
266
-			$objectref = dol_sanitizeFileName($object->ref);
267
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
268
-			$file = $dir . "/" . $objectref . ".odt";
269
-
270
-			if (! file_exists($dir))
271
-			{
272
-				if (dol_mkdir($dir) < 0)
273
-				{
274
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
275
-					return -1;
276
-				}
277
-			}
278
-
279
-			if (file_exists($dir))
280
-			{
281
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
282
-				$newfile=basename($srctemplatepath);
283
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
284
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
285
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
286
-
287
-				$newfiletmp=$objectref.'_'.$newfiletmp;
288
-
289
-				// Get extension (ods or odt)
290
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
291
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
292
-				{
293
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
294
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
295
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
296
-				}
297
-				else
298
-				{
299
-					$filename=$newfiletmp.'.'.$newfileformat;
300
-				}
301
-				$file=$dir.'/'.$filename;
302
-				//print "newdir=".$dir;
303
-				//print "newfile=".$newfile;
304
-				//print "file=".$file;
305
-				//print "conf->produit->dir_temp=".$conf->produit->dir_temp;
306
-
307
-				dol_mkdir($conf->produit->dir_temp);
308
-
309
-
310
-				// If CUSTOMER contact defined on product, we use it
311
-				$usecontact=false;
312
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
313
-				if (count($arrayidcontact) > 0)
314
-				{
315
-					$usecontact=true;
316
-					$result=$object->fetch_contact($arrayidcontact[0]);
317
-				}
318
-
319
-				// Recipient name
320
-				$contactobject=null;
321
-				if (! empty($usecontact))
322
-				{
323
-					// On peut utiliser le nom de la societe du contact
324
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
325
-					else {
326
-                        			$socobject = $object->thirdparty;
327
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
328
-                        			$contactobject = $object->contact;
329
-                    			}
330
-				}
331
-				else
332
-				{
333
-					$socobject=$object->thirdparty;
334
-				}
335
-				// Make substitution
336
-				$substitutionarray=array(
337
-				'__FROM_NAME__' => $this->emetteur->name,
338
-				'__FROM_EMAIL__' => $this->emetteur->email,
339
-				'__TOTAL_TTC__' => $object->total_ttc,
340
-				'__TOTAL_HT__' => $object->total_ht,
341
-				'__TOTAL_VAT__' => $object->total_vat
342
-				);
343
-				complete_substitutions_array($substitutionarray, $langs, $object);
344
-				// Call the ODTSubstitution hook
345
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
346
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
347
-
348
-				// Line of free text
349
-				$newfreetext='';
350
-				$paramfreetext='product_FREE_TEXT';
351
-				if (! empty($conf->global->$paramfreetext))
352
-				{
353
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
354
-				}
355
-
356
-				// Open and load template
357
-				require_once ODTPHP_PATH.'odf.php';
358
-				try {
359
-					$odfHandler = new odf(
360
-						$srctemplatepath,
361
-						array(
362
-							'PATH_TO_TMP'	  => $conf->produit->dir_temp,
363
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
364
-							'DELIMITER_LEFT'  => '{',
365
-							'DELIMITER_RIGHT' => '}'
366
-						)
367
-					);
368
-				}
369
-				catch (Exception $e)
370
-				{
371
-					$this->error=$e->getMessage();
372
-					dol_syslog($e->getMessage(), LOG_INFO);
373
-					return -1;
374
-				}
375
-				// After construction $odfHandler->contentXml contains content and
376
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
377
-				// [!-- BEGIN lines --]*[!-- END lines --]
378
-				//print html_entity_decode($odfHandler->__toString());
379
-				//print exit;
380
-
381
-				$object->fetch_optionals();
382
-
383
-				// Make substitutions into odt of freetext
384
-				try {
385
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
386
-				}
387
-				catch (OdfException $e)
388
-				{
389
-					dol_syslog($e->getMessage(), LOG_INFO);
390
-				}
391
-
392
-				// Define substitution array
393
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
394
-				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
395
-				//$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
396
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
397
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
398
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
399
-				$array_other=$this->get_substitutionarray_other($outputlangs);
400
-				// retrieve contact information for use in object as contact_xxx tags
401
-				$array_thirdparty_contact = array();
402
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
403
-
404
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
405
-				complete_substitutions_array($tmparray, $outputlangs, $object);
406
-
407
-				// Call the ODTSubstitution hook
408
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
409
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
410
-
411
-				foreach($tmparray as $key=>$value)
412
-				{
413
-					try {
414
-						if (preg_match('/logo$/',$key)) // Image
415
-						{
416
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
417
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
418
-						}
419
-						else    // Text
420
-						{
421
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
422
-						}
423
-					}
424
-					catch (OdfException $e)
425
-					{
223
+        global $product,$langs,$conf,$mysoc,$hookmanager,$user;
224
+
225
+        if (empty($srctemplatepath))
226
+        {
227
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
228
+            return -1;
229
+        }
230
+
231
+        // Add odtgeneration hook
232
+        if (! is_object($hookmanager))
233
+        {
234
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
235
+            $hookmanager=new HookManager($this->db);
236
+        }
237
+        $hookmanager->initHooks(array('odtgeneration'));
238
+        global $action;
239
+
240
+        if (! is_object($outputlangs)) $outputlangs=$langs;
241
+        $sav_charset_output=$outputlangs->charset_output;
242
+        $outputlangs->charset_output='UTF-8';
243
+
244
+        // Load translation files required by the page
245
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
246
+
247
+        if ($conf->produit->dir_output)
248
+        {
249
+            // If $object is id instead of object
250
+            if (! is_object($object))
251
+            {
252
+                $id = $object;
253
+                $object = new Product($this->db);
254
+                $result=$object->fetch($id);
255
+                if ($result < 0)
256
+                {
257
+                    dol_print_error($this->db,$object->error);
258
+                    return -1;
259
+                }
260
+            }
261
+            $productFournisseur = new ProductFournisseur($this->db);
262
+            $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
263
+            $object->supplierprices = $supplierprices;
264
+
265
+            $dir = $conf->produit->dir_output;
266
+            $objectref = dol_sanitizeFileName($object->ref);
267
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
268
+            $file = $dir . "/" . $objectref . ".odt";
269
+
270
+            if (! file_exists($dir))
271
+            {
272
+                if (dol_mkdir($dir) < 0)
273
+                {
274
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
275
+                    return -1;
276
+                }
277
+            }
278
+
279
+            if (file_exists($dir))
280
+            {
281
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
282
+                $newfile=basename($srctemplatepath);
283
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
284
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
285
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
286
+
287
+                $newfiletmp=$objectref.'_'.$newfiletmp;
288
+
289
+                // Get extension (ods or odt)
290
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
291
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
292
+                {
293
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
294
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
295
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
296
+                }
297
+                else
298
+                {
299
+                    $filename=$newfiletmp.'.'.$newfileformat;
300
+                }
301
+                $file=$dir.'/'.$filename;
302
+                //print "newdir=".$dir;
303
+                //print "newfile=".$newfile;
304
+                //print "file=".$file;
305
+                //print "conf->produit->dir_temp=".$conf->produit->dir_temp;
306
+
307
+                dol_mkdir($conf->produit->dir_temp);
308
+
309
+
310
+                // If CUSTOMER contact defined on product, we use it
311
+                $usecontact=false;
312
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
313
+                if (count($arrayidcontact) > 0)
314
+                {
315
+                    $usecontact=true;
316
+                    $result=$object->fetch_contact($arrayidcontact[0]);
317
+                }
318
+
319
+                // Recipient name
320
+                $contactobject=null;
321
+                if (! empty($usecontact))
322
+                {
323
+                    // On peut utiliser le nom de la societe du contact
324
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
325
+                    else {
326
+                                    $socobject = $object->thirdparty;
327
+                                    // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
328
+                                    $contactobject = $object->contact;
329
+                                }
330
+                }
331
+                else
332
+                {
333
+                    $socobject=$object->thirdparty;
334
+                }
335
+                // Make substitution
336
+                $substitutionarray=array(
337
+                '__FROM_NAME__' => $this->emetteur->name,
338
+                '__FROM_EMAIL__' => $this->emetteur->email,
339
+                '__TOTAL_TTC__' => $object->total_ttc,
340
+                '__TOTAL_HT__' => $object->total_ht,
341
+                '__TOTAL_VAT__' => $object->total_vat
342
+                );
343
+                complete_substitutions_array($substitutionarray, $langs, $object);
344
+                // Call the ODTSubstitution hook
345
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
346
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
347
+
348
+                // Line of free text
349
+                $newfreetext='';
350
+                $paramfreetext='product_FREE_TEXT';
351
+                if (! empty($conf->global->$paramfreetext))
352
+                {
353
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
354
+                }
355
+
356
+                // Open and load template
357
+                require_once ODTPHP_PATH.'odf.php';
358
+                try {
359
+                    $odfHandler = new odf(
360
+                        $srctemplatepath,
361
+                        array(
362
+                            'PATH_TO_TMP'	  => $conf->produit->dir_temp,
363
+                            'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
364
+                            'DELIMITER_LEFT'  => '{',
365
+                            'DELIMITER_RIGHT' => '}'
366
+                        )
367
+                    );
368
+                }
369
+                catch (Exception $e)
370
+                {
371
+                    $this->error=$e->getMessage();
372
+                    dol_syslog($e->getMessage(), LOG_INFO);
373
+                    return -1;
374
+                }
375
+                // After construction $odfHandler->contentXml contains content and
376
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
377
+                // [!-- BEGIN lines --]*[!-- END lines --]
378
+                //print html_entity_decode($odfHandler->__toString());
379
+                //print exit;
380
+
381
+                $object->fetch_optionals();
382
+
383
+                // Make substitutions into odt of freetext
384
+                try {
385
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
386
+                }
387
+                catch (OdfException $e)
388
+                {
389
+                    dol_syslog($e->getMessage(), LOG_INFO);
390
+                }
391
+
392
+                // Define substitution array
393
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
394
+                $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
395
+                //$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
396
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
397
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
398
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
399
+                $array_other=$this->get_substitutionarray_other($outputlangs);
400
+                // retrieve contact information for use in object as contact_xxx tags
401
+                $array_thirdparty_contact = array();
402
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
403
+
404
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
405
+                complete_substitutions_array($tmparray, $outputlangs, $object);
406
+
407
+                // Call the ODTSubstitution hook
408
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
409
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
410
+
411
+                foreach($tmparray as $key=>$value)
412
+                {
413
+                    try {
414
+                        if (preg_match('/logo$/',$key)) // Image
415
+                        {
416
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
417
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
418
+                        }
419
+                        else    // Text
420
+                        {
421
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
422
+                        }
423
+                    }
424
+                    catch (OdfException $e)
425
+                    {
426 426
                         dol_syslog($e->getMessage(), LOG_INFO);
427
-					}
428
-				}
429
-				// Replace tags of lines
430
-				try
431
-				{
432
-					$listlines = $odfHandler->setSegment('supplierprices');
433
-					if(!empty($object->supplierprices)){
434
-						foreach ($object->supplierprices as $supplierprice)
435
-						{
436
-							$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
437
-							complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
438
-							// Call the ODTSubstitutionLine hook
439
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice);
440
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
441
-							foreach($array_lines as $key => $val)
442
-							{
443
-								try
444
-								{
445
-									$listlines->setVars($key, $val, true, 'UTF-8');
446
-								}
447
-								catch (OdfException $e)
448
-								{
449
-									dol_syslog($e->getMessage(), LOG_INFO);
450
-								}
451
-								catch (SegmentException $e)
452
-								{
453
-									dol_syslog($e->getMessage(), LOG_INFO);
454
-								}
455
-							}
456
-							$listlines->merge();
457
-						}
458
-					}
459
-					$odfHandler->mergeSegment($listlines);
460
-				}
461
-				catch (OdfException $e)
462
-				{
463
-					$this->error=$e->getMessage();
464
-					dol_syslog($this->error, LOG_WARNING);
465
-					return -1;
466
-				}
467
-
468
-				// Replace labels translated
469
-				$tmparray=$outputlangs->get_translations_for_substitutions();
470
-				foreach($tmparray as $key=>$value)
471
-				{
472
-					try {
473
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
474
-					}
475
-					catch(OdfException $e)
476
-					{
427
+                    }
428
+                }
429
+                // Replace tags of lines
430
+                try
431
+                {
432
+                    $listlines = $odfHandler->setSegment('supplierprices');
433
+                    if(!empty($object->supplierprices)){
434
+                        foreach ($object->supplierprices as $supplierprice)
435
+                        {
436
+                            $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
437
+                            complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
438
+                            // Call the ODTSubstitutionLine hook
439
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice);
440
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
441
+                            foreach($array_lines as $key => $val)
442
+                            {
443
+                                try
444
+                                {
445
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
446
+                                }
447
+                                catch (OdfException $e)
448
+                                {
449
+                                    dol_syslog($e->getMessage(), LOG_INFO);
450
+                                }
451
+                                catch (SegmentException $e)
452
+                                {
453
+                                    dol_syslog($e->getMessage(), LOG_INFO);
454
+                                }
455
+                            }
456
+                            $listlines->merge();
457
+                        }
458
+                    }
459
+                    $odfHandler->mergeSegment($listlines);
460
+                }
461
+                catch (OdfException $e)
462
+                {
463
+                    $this->error=$e->getMessage();
464
+                    dol_syslog($this->error, LOG_WARNING);
465
+                    return -1;
466
+                }
467
+
468
+                // Replace labels translated
469
+                $tmparray=$outputlangs->get_translations_for_substitutions();
470
+                foreach($tmparray as $key=>$value)
471
+                {
472
+                    try {
473
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
474
+                    }
475
+                    catch(OdfException $e)
476
+                    {
477 477
                         dol_syslog($e->getMessage(), LOG_INFO);
478
-					}
479
-				}
480
-
481
-				// Call the beforeODTSave hook
482
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
483
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
484
-
485
-				// Write new file
486
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
487
-					try {
488
-						$odfHandler->exportAsAttachedPDF($file);
489
-					} catch (Exception $e) {
490
-						$this->error=$e->getMessage();
478
+                    }
479
+                }
480
+
481
+                // Call the beforeODTSave hook
482
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
483
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
484
+
485
+                // Write new file
486
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
487
+                    try {
488
+                        $odfHandler->exportAsAttachedPDF($file);
489
+                    } catch (Exception $e) {
490
+                        $this->error=$e->getMessage();
491 491
                         dol_syslog($e->getMessage(), LOG_INFO);
492
-						return -1;
493
-					}
494
-				}
495
-				else {
496
-					try {
497
-						$odfHandler->saveToDisk($file);
498
-					} catch (Exception $e) {
499
-						$this->error=$e->getMessage();
492
+                        return -1;
493
+                    }
494
+                }
495
+                else {
496
+                    try {
497
+                        $odfHandler->saveToDisk($file);
498
+                    } catch (Exception $e) {
499
+                        $this->error=$e->getMessage();
500 500
                         dol_syslog($e->getMessage(), LOG_INFO);
501
-						return -1;
502
-					}
503
-				}
501
+                        return -1;
502
+                    }
503
+                }
504 504
 
505
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
506 506
 
507
-				if (! empty($conf->global->MAIN_UMASK))
508
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
507
+                if (! empty($conf->global->MAIN_UMASK))
508
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
509 509
 
510
-				$odfHandler=null;	// Destroy object
510
+                $odfHandler=null;	// Destroy object
511 511
 
512
-				$this->result = array('fullpath'=>$file);
512
+                $this->result = array('fullpath'=>$file);
513 513
 
514
-				return 1;   // Success
515
-			}
516
-			else
517
-			{
518
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
519
-				return -1;
520
-			}
521
-		}
514
+                return 1;   // Success
515
+            }
516
+            else
517
+            {
518
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
519
+                return -1;
520
+            }
521
+        }
522 522
 
523
-		return -1;
524
-	}
523
+        return -1;
524
+    }
525 525
 }
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -66,37 +66,37 @@  discard block
 block discarded – undo
66 66
 		global $conf, $langs, $mysoc;
67 67
 
68 68
 		// Load translation files required by the page
69
-        $langs->loadLangs(array("main","companies"));
69
+        $langs->loadLangs(array("main", "companies"));
70 70
 
71 71
 		$this->db = $db;
72 72
 		$this->name = "ODT templates";
73 73
 		$this->description = $langs->trans("DocumentModelOdt");
74
-		$this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
74
+		$this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
75 75
 
76 76
 		// Dimension page pour format A4
77 77
 		$this->type = 'odt';
78 78
 		$this->page_largeur = 0;
79 79
 		$this->page_hauteur = 0;
80
-		$this->format = array($this->page_largeur,$this->page_hauteur);
81
-		$this->marge_gauche=0;
82
-		$this->marge_droite=0;
83
-		$this->marge_haute=0;
84
-		$this->marge_basse=0;
85
-
86
-		$this->option_logo = 1;                    // Affiche logo
87
-		$this->option_tva = 0;                     // Gere option tva PRODUCT_TVAOPTION
88
-		$this->option_modereg = 0;                 // Affiche mode reglement
89
-		$this->option_condreg = 0;                 // Affiche conditions reglement
90
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
91
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
92
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
93
-		$this->option_credit_note = 0;             // Support credit notes
94
-		$this->option_freetext = 1;				   // Support add of a personalised text
95
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
80
+		$this->format = array($this->page_largeur, $this->page_hauteur);
81
+		$this->marge_gauche = 0;
82
+		$this->marge_droite = 0;
83
+		$this->marge_haute = 0;
84
+		$this->marge_basse = 0;
85
+
86
+		$this->option_logo = 1; // Affiche logo
87
+		$this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION
88
+		$this->option_modereg = 0; // Affiche mode reglement
89
+		$this->option_condreg = 0; // Affiche conditions reglement
90
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
91
+		$this->option_multilang = 1; // Dispo en plusieurs langues
92
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
93
+		$this->option_credit_note = 0; // Support credit notes
94
+		$this->option_freetext = 1; // Support add of a personalised text
95
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
96 96
 
97 97
 		// Recupere emetteur
98
-		$this->emetteur=$mysoc;
99
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
98
+		$this->emetteur = $mysoc;
99
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
100 100
 	}
101 101
 
102 102
 
@@ -111,60 +111,60 @@  discard block
 block discarded – undo
111 111
 		global $conf, $langs;
112 112
 
113 113
 		// Load translation files required by the page
114
-        $langs->loadLangs(array("errors","companies"));
114
+        $langs->loadLangs(array("errors", "companies"));
115 115
 
116 116
 		$form = new Form($this->db);
117 117
 
118 118
 		$texte = $this->description.".<br>\n";
119
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
120
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
121
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
122
-		$texte.= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
119
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
120
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
121
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
122
+		$texte .= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
123 123
 		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
124 124
 		{
125
-			$texte.= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
126
-			$texte.= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
127
-			$texte.= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
125
+			$texte .= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
126
+			$texte .= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
127
+			$texte .= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
128 128
 		}
129
-		$texte.= '<table class="nobordernopadding" width="100%">';
129
+		$texte .= '<table class="nobordernopadding" width="100%">';
130 130
 
131 131
 		// List of directories area
132
-		$texte.= '<tr><td>';
133
-		$texttitle=$langs->trans("ListOfDirectories");
134
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
135
-		$listoffiles=array();
136
-		foreach($listofdir as $key=>$tmpdir)
132
+		$texte .= '<tr><td>';
133
+		$texttitle = $langs->trans("ListOfDirectories");
134
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
135
+		$listoffiles = array();
136
+		foreach ($listofdir as $key=>$tmpdir)
137 137
 		{
138
-			$tmpdir=trim($tmpdir);
139
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
140
-			if (! $tmpdir) {
138
+			$tmpdir = trim($tmpdir);
139
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
140
+			if (!$tmpdir) {
141 141
 				unset($listofdir[$key]); continue;
142 142
 			}
143
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
143
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
144 144
 			else
145 145
 			{
146
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
147
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
146
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
147
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
148 148
 			}
149 149
 		}
150
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
150
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
151 151
 		// Add list of substitution keys
152
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
153
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
154
-
155
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
156
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
157
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
158
-		$texte.=$conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
159
-		$texte.= '</textarea>';
160
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
161
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
162
-		$texte.= '<br></div></div>';
152
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
153
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
154
+
155
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
156
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
157
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
158
+		$texte .= $conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
159
+		$texte .= '</textarea>';
160
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
161
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
162
+		$texte .= '<br></div></div>';
163 163
 
164 164
 		// Scan directories
165 165
 		if (count($listofdir))
166 166
 		{
167
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
167
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
168 168
 
169 169
 			/*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0)
170 170
 			{
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
 			}*/
193 193
 		}
194 194
 
195
-		$texte.= '</td>';
195
+		$texte .= '</td>';
196 196
 
197
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
198
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
199
-		$texte.= '</td>';
200
-		$texte.= '</tr>';
197
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
198
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
199
+		$texte .= '</td>';
200
+		$texte .= '</tr>';
201 201
 
202
-		$texte.= '</table>';
203
-		$texte.= '</form>';
202
+		$texte .= '</table>';
203
+		$texte .= '</form>';
204 204
 
205 205
 		return $texte;
206 206
 	}
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 *  @param		int			$hideref			Do not show ref
218 218
 	 *	@return		int         					1 if OK, <=0 if KO
219 219
 	 */
220
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
220
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
221 221
 	{
222 222
         // phpcs:enable
223
-		global $product,$langs,$conf,$mysoc,$hookmanager,$user;
223
+		global $product, $langs, $conf, $mysoc, $hookmanager, $user;
224 224
 
225 225
 		if (empty($srctemplatepath))
226 226
 		{
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		}
230 230
 
231 231
 		// Add odtgeneration hook
232
-		if (! is_object($hookmanager))
232
+		if (!is_object($hookmanager))
233 233
 		{
234 234
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
235
-			$hookmanager=new HookManager($this->db);
235
+			$hookmanager = new HookManager($this->db);
236 236
 		}
237 237
 		$hookmanager->initHooks(array('odtgeneration'));
238 238
 		global $action;
239 239
 
240
-		if (! is_object($outputlangs)) $outputlangs=$langs;
241
-		$sav_charset_output=$outputlangs->charset_output;
242
-		$outputlangs->charset_output='UTF-8';
240
+		if (!is_object($outputlangs)) $outputlangs = $langs;
241
+		$sav_charset_output = $outputlangs->charset_output;
242
+		$outputlangs->charset_output = 'UTF-8';
243 243
 
244 244
 		// Load translation files required by the page
245 245
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 		if ($conf->produit->dir_output)
248 248
 		{
249 249
 			// If $object is id instead of object
250
-			if (! is_object($object))
250
+			if (!is_object($object))
251 251
 			{
252 252
 				$id = $object;
253 253
 				$object = new Product($this->db);
254
-				$result=$object->fetch($id);
254
+				$result = $object->fetch($id);
255 255
 				if ($result < 0)
256 256
 				{
257
-					dol_print_error($this->db,$object->error);
257
+					dol_print_error($this->db, $object->error);
258 258
 					return -1;
259 259
 				}
260 260
 			}
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 
265 265
 			$dir = $conf->produit->dir_output;
266 266
 			$objectref = dol_sanitizeFileName($object->ref);
267
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
268
-			$file = $dir . "/" . $objectref . ".odt";
267
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
268
+			$file = $dir."/".$objectref.".odt";
269 269
 
270
-			if (! file_exists($dir))
270
+			if (!file_exists($dir))
271 271
 			{
272 272
 				if (dol_mkdir($dir) < 0)
273 273
 				{
274
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
274
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
275 275
 					return -1;
276 276
 				}
277 277
 			}
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			if (file_exists($dir))
280 280
 			{
281 281
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
282
-				$newfile=basename($srctemplatepath);
283
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
284
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
285
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
282
+				$newfile = basename($srctemplatepath);
283
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
284
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
285
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
286 286
 
287
-				$newfiletmp=$objectref.'_'.$newfiletmp;
287
+				$newfiletmp = $objectref.'_'.$newfiletmp;
288 288
 
289 289
 				// Get extension (ods or odt)
290
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
291
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
290
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
291
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
292 292
 				{
293
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
294
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
295
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
293
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
294
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
295
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
296 296
 				}
297 297
 				else
298 298
 				{
299
-					$filename=$newfiletmp.'.'.$newfileformat;
299
+					$filename = $newfiletmp.'.'.$newfileformat;
300 300
 				}
301
-				$file=$dir.'/'.$filename;
301
+				$file = $dir.'/'.$filename;
302 302
 				//print "newdir=".$dir;
303 303
 				//print "newfile=".$newfile;
304 304
 				//print "file=".$file;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 
309 309
 
310 310
 				// If CUSTOMER contact defined on product, we use it
311
-				$usecontact=false;
312
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
311
+				$usecontact = false;
312
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
313 313
 				if (count($arrayidcontact) > 0)
314 314
 				{
315
-					$usecontact=true;
316
-					$result=$object->fetch_contact($arrayidcontact[0]);
315
+					$usecontact = true;
316
+					$result = $object->fetch_contact($arrayidcontact[0]);
317 317
 				}
318 318
 
319 319
 				// Recipient name
320
-				$contactobject=null;
321
-				if (! empty($usecontact))
320
+				$contactobject = null;
321
+				if (!empty($usecontact))
322 322
 				{
323 323
 					// On peut utiliser le nom de la societe du contact
324
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
324
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
325 325
 					else {
326 326
                         			$socobject = $object->thirdparty;
327 327
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 				}
331 331
 				else
332 332
 				{
333
-					$socobject=$object->thirdparty;
333
+					$socobject = $object->thirdparty;
334 334
 				}
335 335
 				// Make substitution
336
-				$substitutionarray=array(
336
+				$substitutionarray = array(
337 337
 				'__FROM_NAME__' => $this->emetteur->name,
338 338
 				'__FROM_EMAIL__' => $this->emetteur->email,
339 339
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
 				);
343 343
 				complete_substitutions_array($substitutionarray, $langs, $object);
344 344
 				// Call the ODTSubstitution hook
345
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
346
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
345
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
346
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
347 347
 
348 348
 				// Line of free text
349
-				$newfreetext='';
350
-				$paramfreetext='product_FREE_TEXT';
351
-				if (! empty($conf->global->$paramfreetext))
349
+				$newfreetext = '';
350
+				$paramfreetext = 'product_FREE_TEXT';
351
+				if (!empty($conf->global->$paramfreetext))
352 352
 				{
353
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
353
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
354 354
 				}
355 355
 
356 356
 				// Open and load template
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 						$srctemplatepath,
361 361
 						array(
362 362
 							'PATH_TO_TMP'	  => $conf->produit->dir_temp,
363
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
363
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
364 364
 							'DELIMITER_LEFT'  => '{',
365 365
 							'DELIMITER_RIGHT' => '}'
366 366
 						)
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				}
369 369
 				catch (Exception $e)
370 370
 				{
371
-					$this->error=$e->getMessage();
371
+					$this->error = $e->getMessage();
372 372
 					dol_syslog($e->getMessage(), LOG_INFO);
373 373
 					return -1;
374 374
 				}
@@ -393,25 +393,25 @@  discard block
 block discarded – undo
393 393
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
394 394
 				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
395 395
 				//$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
396
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
397
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
398
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
399
-				$array_other=$this->get_substitutionarray_other($outputlangs);
396
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
397
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
398
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
399
+				$array_other = $this->get_substitutionarray_other($outputlangs);
400 400
 				// retrieve contact information for use in object as contact_xxx tags
401 401
 				$array_thirdparty_contact = array();
402
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
402
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
403 403
 
404
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
404
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact);
405 405
 				complete_substitutions_array($tmparray, $outputlangs, $object);
406 406
 
407 407
 				// Call the ODTSubstitution hook
408
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
409
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
408
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
409
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
410 410
 
411
-				foreach($tmparray as $key=>$value)
411
+				foreach ($tmparray as $key=>$value)
412 412
 				{
413 413
 					try {
414
-						if (preg_match('/logo$/',$key)) // Image
414
+						if (preg_match('/logo$/', $key)) // Image
415 415
 						{
416 416
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
417 417
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
 				try
431 431
 				{
432 432
 					$listlines = $odfHandler->setSegment('supplierprices');
433
-					if(!empty($object->supplierprices)){
433
+					if (!empty($object->supplierprices)) {
434 434
 						foreach ($object->supplierprices as $supplierprice)
435 435
 						{
436 436
 							$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
437 437
 							complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
438 438
 							// Call the ODTSubstitutionLine hook
439
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice);
440
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
441
-							foreach($array_lines as $key => $val)
439
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice);
440
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
441
+							foreach ($array_lines as $key => $val)
442 442
 							{
443 443
 								try
444 444
 								{
@@ -460,34 +460,34 @@  discard block
 block discarded – undo
460 460
 				}
461 461
 				catch (OdfException $e)
462 462
 				{
463
-					$this->error=$e->getMessage();
463
+					$this->error = $e->getMessage();
464 464
 					dol_syslog($this->error, LOG_WARNING);
465 465
 					return -1;
466 466
 				}
467 467
 
468 468
 				// Replace labels translated
469
-				$tmparray=$outputlangs->get_translations_for_substitutions();
470
-				foreach($tmparray as $key=>$value)
469
+				$tmparray = $outputlangs->get_translations_for_substitutions();
470
+				foreach ($tmparray as $key=>$value)
471 471
 				{
472 472
 					try {
473 473
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
474 474
 					}
475
-					catch(OdfException $e)
475
+					catch (OdfException $e)
476 476
 					{
477 477
                         dol_syslog($e->getMessage(), LOG_INFO);
478 478
 					}
479 479
 				}
480 480
 
481 481
 				// Call the beforeODTSave hook
482
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
483
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
482
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
483
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
484 484
 
485 485
 				// Write new file
486 486
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
487 487
 					try {
488 488
 						$odfHandler->exportAsAttachedPDF($file);
489 489
 					} catch (Exception $e) {
490
-						$this->error=$e->getMessage();
490
+						$this->error = $e->getMessage();
491 491
                         dol_syslog($e->getMessage(), LOG_INFO);
492 492
 						return -1;
493 493
 					}
@@ -496,26 +496,26 @@  discard block
 block discarded – undo
496 496
 					try {
497 497
 						$odfHandler->saveToDisk($file);
498 498
 					} catch (Exception $e) {
499
-						$this->error=$e->getMessage();
499
+						$this->error = $e->getMessage();
500 500
                         dol_syslog($e->getMessage(), LOG_INFO);
501 501
 						return -1;
502 502
 					}
503 503
 				}
504 504
 
505
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
506 506
 
507
-				if (! empty($conf->global->MAIN_UMASK))
507
+				if (!empty($conf->global->MAIN_UMASK))
508 508
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
509 509
 
510
-				$odfHandler=null;	// Destroy object
510
+				$odfHandler = null; // Destroy object
511 511
 
512 512
 				$this->result = array('fullpath'=>$file);
513 513
 
514
-				return 1;   // Success
514
+				return 1; // Success
515 515
 			}
516 516
 			else
517 517
 			{
518
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
518
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
519 519
 				return -1;
520 520
 			}
521 521
 		}
Please login to merge, or discard this patch.
Braces   +45 added lines, -38 removed lines patch added patch discarded remove patch
@@ -96,7 +96,10 @@  discard block
 block discarded – undo
96 96
 
97 97
 		// Recupere emetteur
98 98
 		$this->emetteur=$mysoc;
99
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
+		if (! $this->emetteur->country_code) {
100
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
101
+		}
102
+		// By default if not defined
100 103
 	}
101 104
 
102 105
 
@@ -140,11 +143,14 @@  discard block
 block discarded – undo
140 143
 			if (! $tmpdir) {
141 144
 				unset($listofdir[$key]); continue;
142 145
 			}
143
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
-			else
146
+			if (! is_dir($tmpdir)) {
147
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
148
+			} else
145 149
 			{
146 150
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
147
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
151
+				if (count($tmpfiles)) {
152
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
153
+				}
148 154
 			}
149 155
 		}
150 156
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -237,7 +243,9 @@  discard block
 block discarded – undo
237 243
 		$hookmanager->initHooks(array('odtgeneration'));
238 244
 		global $action;
239 245
 
240
-		if (! is_object($outputlangs)) $outputlangs=$langs;
246
+		if (! is_object($outputlangs)) {
247
+		    $outputlangs=$langs;
248
+		}
241 249
 		$sav_charset_output=$outputlangs->charset_output;
242 250
 		$outputlangs->charset_output='UTF-8';
243 251
 
@@ -264,7 +272,9 @@  discard block
 block discarded – undo
264 272
 
265 273
 			$dir = $conf->produit->dir_output;
266 274
 			$objectref = dol_sanitizeFileName($object->ref);
267
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
275
+			if (! preg_match('/specimen/i',$objectref)) {
276
+			    $dir.= "/" . $objectref;
277
+			}
268 278
 			$file = $dir . "/" . $objectref . ".odt";
269 279
 
270 280
 			if (! file_exists($dir))
@@ -291,10 +301,11 @@  discard block
 block discarded – undo
291 301
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
292 302
 				{
293 303
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
294
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
304
+				    if ($format == '1') {
305
+				        $format='%Y%m%d%H%M%S';
306
+				    }
295 307
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
296
-				}
297
-				else
308
+				} else
298 309
 				{
299 310
 					$filename=$newfiletmp.'.'.$newfileformat;
300 311
 				}
@@ -321,14 +332,14 @@  discard block
 block discarded – undo
321 332
 				if (! empty($usecontact))
322 333
 				{
323 334
 					// On peut utiliser le nom de la societe du contact
324
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
325
-					else {
335
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
336
+					    $socobject = $object->contact;
337
+					} else {
326 338
                         			$socobject = $object->thirdparty;
327 339
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
328 340
                         			$contactobject = $object->contact;
329 341
                     			}
330
-				}
331
-				else
342
+				} else
332 343
 				{
333 344
 					$socobject=$object->thirdparty;
334 345
 				}
@@ -365,8 +376,7 @@  discard block
 block discarded – undo
365 376
 							'DELIMITER_RIGHT' => '}'
366 377
 						)
367 378
 					);
368
-				}
369
-				catch (Exception $e)
379
+				} catch (Exception $e)
370 380
 				{
371 381
 					$this->error=$e->getMessage();
372 382
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -383,8 +393,7 @@  discard block
 block discarded – undo
383 393
 				// Make substitutions into odt of freetext
384 394
 				try {
385 395
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
386
-				}
387
-				catch (OdfException $e)
396
+				} catch (OdfException $e)
388 397
 				{
389 398
 					dol_syslog($e->getMessage(), LOG_INFO);
390 399
 				}
@@ -399,7 +408,9 @@  discard block
 block discarded – undo
399 408
 				$array_other=$this->get_substitutionarray_other($outputlangs);
400 409
 				// retrieve contact information for use in object as contact_xxx tags
401 410
 				$array_thirdparty_contact = array();
402
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
411
+				if ($usecontact && is_object($contactobject)) {
412
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
413
+				}
403 414
 
404 415
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
405 416
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -411,17 +422,18 @@  discard block
 block discarded – undo
411 422
 				foreach($tmparray as $key=>$value)
412 423
 				{
413 424
 					try {
414
-						if (preg_match('/logo$/',$key)) // Image
425
+						if (preg_match('/logo$/',$key)) {
426
+						    // Image
415 427
 						{
416 428
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
417
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
418
-						}
419
-						else    // Text
429
+						} else {
430
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
431
+							}
432
+						} else    // Text
420 433
 						{
421 434
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
422 435
 						}
423
-					}
424
-					catch (OdfException $e)
436
+					} catch (OdfException $e)
425 437
 					{
426 438
                         dol_syslog($e->getMessage(), LOG_INFO);
427 439
 					}
@@ -443,12 +455,10 @@  discard block
 block discarded – undo
443 455
 								try
444 456
 								{
445 457
 									$listlines->setVars($key, $val, true, 'UTF-8');
446
-								}
447
-								catch (OdfException $e)
458
+								} catch (OdfException $e)
448 459
 								{
449 460
 									dol_syslog($e->getMessage(), LOG_INFO);
450
-								}
451
-								catch (SegmentException $e)
461
+								} catch (SegmentException $e)
452 462
 								{
453 463
 									dol_syslog($e->getMessage(), LOG_INFO);
454 464
 								}
@@ -457,8 +467,7 @@  discard block
 block discarded – undo
457 467
 						}
458 468
 					}
459 469
 					$odfHandler->mergeSegment($listlines);
460
-				}
461
-				catch (OdfException $e)
470
+				} catch (OdfException $e)
462 471
 				{
463 472
 					$this->error=$e->getMessage();
464 473
 					dol_syslog($this->error, LOG_WARNING);
@@ -471,8 +480,7 @@  discard block
 block discarded – undo
471 480
 				{
472 481
 					try {
473 482
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
474
-					}
475
-					catch(OdfException $e)
483
+					} catch(OdfException $e)
476 484
 					{
477 485
                         dol_syslog($e->getMessage(), LOG_INFO);
478 486
 					}
@@ -491,8 +499,7 @@  discard block
 block discarded – undo
491 499
                         dol_syslog($e->getMessage(), LOG_INFO);
492 500
 						return -1;
493 501
 					}
494
-				}
495
-				else {
502
+				} else {
496 503
 					try {
497 504
 						$odfHandler->saveToDisk($file);
498 505
 					} catch (Exception $e) {
@@ -504,16 +511,16 @@  discard block
 block discarded – undo
504 511
 
505 512
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
506 513
 
507
-				if (! empty($conf->global->MAIN_UMASK))
508
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
514
+				if (! empty($conf->global->MAIN_UMASK)) {
515
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
516
+				}
509 517
 
510 518
 				$odfHandler=null;	// Destroy object
511 519
 
512 520
 				$this->result = array('fullpath'=>$file);
513 521
 
514 522
 				return 1;   // Success
515
-			}
516
-			else
523
+			} else
517 524
 			{
518 525
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
519 526
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/product/doc/pdf_standard.modules.php 3 patches
Indentation   +466 added lines, -466 removed lines patch added patch discarded remove patch
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public $db;
43 43
 
44
-	/**
44
+    /**
45 45
      * @var string model name
46 46
      */
47 47
     public $name;
48 48
 
49
-	/**
49
+    /**
50 50
      * @var string model description (short text)
51 51
      */
52 52
     public $description;
53 53
 
54
-	/**
54
+    /**
55 55
      * @var string document type
56 56
      */
57 57
     public $type;
58 58
 
59
-	/**
59
+    /**
60 60
      * @var array() Minimum version of PHP required by module.
61
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
61
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
62 62
      */
63
-	public $phpmin = array(5, 4);
63
+    public $phpmin = array(5, 4);
64 64
 
65
-	/**
65
+    /**
66 66
      * Dolibarr version of the loaded document
67 67
      * @public string
68 68
      */
69
-	public $version = 'dolibarr';
69
+    public $version = 'dolibarr';
70 70
 
71 71
     /**
72 72
      * @var int page_largeur
@@ -83,147 +83,147 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public $format;
85 85
 
86
-	/**
86
+    /**
87 87
      * @var int marge_gauche
88 88
      */
89
-	public $marge_gauche;
89
+    public $marge_gauche;
90 90
 
91
-	/**
91
+    /**
92 92
      * @var int marge_droite
93 93
      */
94
-	public $marge_droite;
94
+    public $marge_droite;
95 95
 
96
-	/**
96
+    /**
97 97
      * @var int marge_haute
98 98
      */
99
-	public $marge_haute;
99
+    public $marge_haute;
100 100
 
101
-	/**
101
+    /**
102 102
      * @var int marge_basse
103 103
      */
104
-	public $marge_basse;
104
+    public $marge_basse;
105
+
106
+    /**
107
+     * Issuer
108
+     * @var Societe
109
+     */
110
+    public $emetteur;
111
+
105 112
 
106 113
     /**
107
-	 * Issuer
108
-	 * @var Societe
109
-	 */
110
-	public $emetteur;
111
-
112
-
113
-	/**
114
-	 *	Constructor
115
-	 *
116
-	 *  @param		DoliDB		$db      Database handler
117
-	 */
118
-	public function __construct($db)
119
-	{
120
-		global $conf,$langs,$mysoc;
121
-
122
-		// Load traductions files requiredby by page
123
-		$langs->loadLangs(array("main", "companies"));
124
-
125
-		$this->db = $db;
126
-		$this->name = "standard";
127
-		$this->description = $langs->trans("DocumentModelStandardPDF");
128
-
129
-		// Dimension page pour format A4
130
-		$this->type = 'pdf';
131
-		$formatarray=pdf_getFormat();
132
-		$this->page_largeur = $formatarray['width'];
133
-		$this->page_hauteur = $formatarray['height'];
134
-		$this->format = array($this->page_largeur,$this->page_hauteur);
135
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
136
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
137
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
138
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
139
-
140
-		$this->option_logo = 1;                    // Affiche logo
141
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
142
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
143
-		$this->option_freetext = 0;				   // Support add of a personalised text
144
-
145
-		// Recupere emetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
-	}
114
+     *	Constructor
115
+     *
116
+     *  @param		DoliDB		$db      Database handler
117
+     */
118
+    public function __construct($db)
119
+    {
120
+        global $conf,$langs,$mysoc;
121
+
122
+        // Load traductions files requiredby by page
123
+        $langs->loadLangs(array("main", "companies"));
124
+
125
+        $this->db = $db;
126
+        $this->name = "standard";
127
+        $this->description = $langs->trans("DocumentModelStandardPDF");
128
+
129
+        // Dimension page pour format A4
130
+        $this->type = 'pdf';
131
+        $formatarray=pdf_getFormat();
132
+        $this->page_largeur = $formatarray['width'];
133
+        $this->page_hauteur = $formatarray['height'];
134
+        $this->format = array($this->page_largeur,$this->page_hauteur);
135
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
136
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
137
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
138
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
139
+
140
+        $this->option_logo = 1;                    // Affiche logo
141
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
142
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
143
+        $this->option_freetext = 0;				   // Support add of a personalised text
144
+
145
+        // Recupere emetteur
146
+        $this->emetteur=$mysoc;
147
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
+    }
149 149
 
150 150
 
151 151
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
152
-	/**
153
-	 *	Function to build a document on disk using the generic odt module.
154
-	 *
155
-	 *	@param		Product		$object				Object source to build document
156
-	 *	@param		Translate	$outputlangs		Lang output object
157
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
158
-	 *  @param		int			$hidedetails		Do not show line details
159
-	 *  @param		int			$hidedesc			Do not show desc
160
-	 *  @param		int			$hideref			Do not show ref
161
-	 *	@return		int         					1 if OK, <=0 if KO
162
-	 */
163
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
164
-	{
152
+    /**
153
+     *	Function to build a document on disk using the generic odt module.
154
+     *
155
+     *	@param		Product		$object				Object source to build document
156
+     *	@param		Translate	$outputlangs		Lang output object
157
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
158
+     *  @param		int			$hidedetails		Do not show line details
159
+     *  @param		int			$hidedesc			Do not show desc
160
+     *  @param		int			$hideref			Do not show ref
161
+     *	@return		int         					1 if OK, <=0 if KO
162
+     */
163
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
164
+    {
165 165
         // phpcs:enable
166
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
167
-
168
-		if (! is_object($outputlangs)) $outputlangs=$langs;
169
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
170
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
171
-
172
-		// Load traductions files requiredby by page
173
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
174
-
175
-		$nblignes = count($object->lines);
176
-
177
-		if ($conf->produit->dir_output)
178
-		{
179
-		    // Definition of $dir and $file
180
-			if ($object->specimen)
181
-			{
182
-				$dir = $conf->produit->dir_output;
183
-				$file = $dir . "/SPECIMEN.pdf";
184
-			}
185
-			else
186
-			{
187
-				$objectref = dol_sanitizeFileName($object->ref);
188
-				$dir = $conf->produit->dir_output . "/" . $objectref;
189
-				$file = $dir . "/" . $objectref . ".pdf";
190
-			}
191
-
192
-			$productFournisseur = new ProductFournisseur($this->db);
193
-			$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
194
-			$object->supplierprices = $supplierprices;
195
-
196
-			if (! file_exists($dir))
197
-			{
198
-				if (dol_mkdir($dir) < 0)
199
-				{
200
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
201
-					return -1;
202
-				}
203
-			}
166
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager;
167
+
168
+        if (! is_object($outputlangs)) $outputlangs=$langs;
169
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
170
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
171
+
172
+        // Load traductions files requiredby by page
173
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
174
+
175
+        $nblignes = count($object->lines);
176
+
177
+        if ($conf->produit->dir_output)
178
+        {
179
+            // Definition of $dir and $file
180
+            if ($object->specimen)
181
+            {
182
+                $dir = $conf->produit->dir_output;
183
+                $file = $dir . "/SPECIMEN.pdf";
184
+            }
185
+            else
186
+            {
187
+                $objectref = dol_sanitizeFileName($object->ref);
188
+                $dir = $conf->produit->dir_output . "/" . $objectref;
189
+                $file = $dir . "/" . $objectref . ".pdf";
190
+            }
191
+
192
+            $productFournisseur = new ProductFournisseur($this->db);
193
+            $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
194
+            $object->supplierprices = $supplierprices;
195
+
196
+            if (! file_exists($dir))
197
+            {
198
+                if (dol_mkdir($dir) < 0)
199
+                {
200
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
201
+                    return -1;
202
+                }
203
+            }
204 204
 
205
-			if (file_exists($dir))
206
-			{
207
-							// Add pdfgeneration hook
208
-				if (! is_object($hookmanager))
209
-				{
210
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
-					$hookmanager=new HookManager($this->db);
212
-				}
213
-				$hookmanager->initHooks(array('pdfgeneration'));
214
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
-				global $action;
216
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
205
+            if (file_exists($dir))
206
+            {
207
+                            // Add pdfgeneration hook
208
+                if (! is_object($hookmanager))
209
+                {
210
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
+                    $hookmanager=new HookManager($this->db);
212
+                }
213
+                $hookmanager->initHooks(array('pdfgeneration'));
214
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
+                global $action;
216
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217 217
 
218
-				// Create pdf instance
219
-				$pdf=pdf_getInstance($this->format);
220
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
221
-				$pdf->SetAutoPageBreak(1,0);
218
+                // Create pdf instance
219
+                $pdf=pdf_getInstance($this->format);
220
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
221
+                $pdf->SetAutoPageBreak(1,0);
222 222
 
223
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
224
-		        $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
225
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
223
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
224
+                $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
225
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
227 227
 
228 228
                 if (class_exists('TCPDF'))
229 229
                 {
@@ -238,113 +238,113 @@  discard block
 block discarded – undo
238 238
                     $tplidx = $pdf->importPage(1);
239 239
                 }
240 240
 
241
-				$pdf->Open();
242
-				$pagenb=0;
243
-				$pdf->SetDrawColor(128,128,128);
241
+                $pdf->Open();
242
+                $pagenb=0;
243
+                $pdf->SetDrawColor(128,128,128);
244 244
 
245
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
246
-				$pdf->SetSubject($outputlangs->transnoentities("Order"));
247
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
248
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
249
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
250
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
245
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
246
+                $pdf->SetSubject($outputlangs->transnoentities("Order"));
247
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
248
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
249
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
250
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
251 251
 
252
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
252
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
253 253
 
254 254
 
255
-				// New page
256
-				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258
-				$pagenb++;
259
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
260
-				$pdf->SetFont('','', $default_font_size - 1);
261
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
262
-				$pdf->SetTextColor(0,0,0);
255
+                // New page
256
+                $pdf->AddPage();
257
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258
+                $pagenb++;
259
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
260
+                $pdf->SetFont('','', $default_font_size - 1);
261
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
262
+                $pdf->SetTextColor(0,0,0);
263 263
 
264 264
 
265
-				$tab_top = 42;
266
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
267
-				$tab_height = 130;
268
-				$tab_height_newpage = 150;
265
+                $tab_top = 42;
266
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
267
+                $tab_height = 130;
268
+                $tab_height_newpage = 150;
269 269
 
270
-				//
271
-				$pdf->SetFont('','B', $default_font_size);
272
-				$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1);
273
-				$nexY = $pdf->GetY();
270
+                //
271
+                $pdf->SetFont('','B', $default_font_size);
272
+                $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1);
273
+                $nexY = $pdf->GetY();
274 274
 
275
-				$pdf->SetFont('','', $default_font_size);
276
-				$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1);
277
-				$nexY = $pdf->GetY();
275
+                $pdf->SetFont('','', $default_font_size);
276
+                $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1);
277
+                $nexY = $pdf->GetY();
278 278
 
279
-				$nexY+=5;
279
+                $nexY+=5;
280 280
 
281
-				if ($object->weight)
282
-				{
283
-				    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Weight").': '.dol_htmlentitiesbr($object->weight), 0, 1);
284
-				    $nexY = $pdf->GetY();
285
-				}
286
-				if ($object->weight)
287
-				{
288
-				    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.($object->length != ''?$object->length:'?').' x '.($object->width != ''?$object->width:'?').' x '.($object->height != ''?$object->height:'?'), 0, 1);
289
-				    $nexY = $pdf->GetY();
290
-				}
291
-				if ($object->surface)
292
-				{
293
-				    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Area").': '.dol_htmlentitiesbr($object->surface), 0, 1);
294
-				    $nexY = $pdf->GetY();
295
-				}
296
-				if ($object->volume)
297
-				{
298
-    				$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Volume").': '.dol_htmlentitiesbr($object->volume), 0, 1);
299
-	   			    $nexY = $pdf->GetY();
300
-				}
281
+                if ($object->weight)
282
+                {
283
+                    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Weight").': '.dol_htmlentitiesbr($object->weight), 0, 1);
284
+                    $nexY = $pdf->GetY();
285
+                }
286
+                if ($object->weight)
287
+                {
288
+                    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.($object->length != ''?$object->length:'?').' x '.($object->width != ''?$object->width:'?').' x '.($object->height != ''?$object->height:'?'), 0, 1);
289
+                    $nexY = $pdf->GetY();
290
+                }
291
+                if ($object->surface)
292
+                {
293
+                    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Area").': '.dol_htmlentitiesbr($object->surface), 0, 1);
294
+                    $nexY = $pdf->GetY();
295
+                }
296
+                if ($object->volume)
297
+                {
298
+                    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Volume").': '.dol_htmlentitiesbr($object->volume), 0, 1);
299
+                        $nexY = $pdf->GetY();
300
+                }
301 301
 
302 302
 
303
-				// Affiche notes
304
-				// TODO There is no public note on product yet
305
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
306
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
307
-				{
308
-					// Get first sale rep
309
-					if (is_object($object->thirdparty))
310
-					{
311
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
312
-						$salerepobj=new User($this->db);
313
-						$salerepobj->fetch($salereparray[0]['id']);
314
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
315
-					}
316
-				}
317
-				if ($notetoshow)
318
-				{
319
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
320
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
321
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
303
+                // Affiche notes
304
+                // TODO There is no public note on product yet
305
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
306
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
307
+                {
308
+                    // Get first sale rep
309
+                    if (is_object($object->thirdparty))
310
+                    {
311
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
312
+                        $salerepobj=new User($this->db);
313
+                        $salerepobj->fetch($salereparray[0]['id']);
314
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
315
+                    }
316
+                }
317
+                if ($notetoshow)
318
+                {
319
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
320
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
321
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
322 322
 
323
-					$tab_top = 88;
323
+                    $tab_top = 88;
324 324
 
325
-					$pdf->SetFont('','', $default_font_size - 1);
326
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
327
-					$nexY = $pdf->GetY();
328
-					$height_note=$nexY-$tab_top;
325
+                    $pdf->SetFont('','', $default_font_size - 1);
326
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
327
+                    $nexY = $pdf->GetY();
328
+                    $height_note=$nexY-$tab_top;
329 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_note+1);
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_note+1);
333 333
 
334
-					$tab_height = $tab_height - $height_note;
335
-					$tab_top = $nexY+6;
336
-				}
337
-				else
338
-				{
339
-					$height_note=0;
340
-				}
334
+                    $tab_height = $tab_height - $height_note;
335
+                    $tab_top = $nexY+6;
336
+                }
337
+                else
338
+                {
339
+                    $height_note=0;
340
+                }
341 341
 
342
-				$iniY = $tab_top + 7;
343
-				$curY = $tab_top + 7;
344
-				$nexY = $tab_top + 7;
342
+                $iniY = $tab_top + 7;
343
+                $curY = $tab_top + 7;
344
+                $nexY = $tab_top + 7;
345 345
 
346
-				// Loop on each lines
347
-				/*
346
+                // Loop on each lines
347
+                /*
348 348
 				for ($i = 0 ; $i < $nblignes ; $i++)
349 349
 				{
350 350
 					$curY = $nexY;
@@ -552,235 +552,235 @@  discard block
 block discarded – undo
552 552
 				}
553 553
                 */
554 554
 
555
-				// Affiche zone infos
556
-				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
557
-
558
-				// Pied de page
559
-				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
561
-
562
-				$pdf->Close();
563
-
564
-				$pdf->Output($file,'F');
565
-
566
-				// Add pdfgeneration hook
567
-				$hookmanager->initHooks(array('pdfgeneration'));
568
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
569
-				global $action;
570
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
571
-
572
-				if (! empty($conf->global->MAIN_UMASK))
573
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
574
-
575
-				$this->result = array('fullpath'=>$file);
576
-
577
-				return 1;   // Pas d'erreur
578
-			}
579
-			else
580
-			{
581
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
582
-				return 0;
583
-			}
584
-		}
585
-		else
586
-		{
587
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
588
-			return 0;
589
-		}
590
-	}
591
-
592
-
593
-	/**
594
-	 *   Show table for lines
595
-	 *
596
-	 *   @param		TCPDF		$pdf     		Object PDF
597
-	 *   @param		string		$tab_top		Top position of table
598
-	 *   @param		string		$tab_height		Height of table (rectangle)
599
-	 *   @param		int			$nexY			Y (not used)
600
-	 *   @param		Translate	$outputlangs	Langs object
601
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
602
-	 *   @param		int			$hidebottom		Hide bottom bar of array
603
-	 *   @param		string		$currency		Currency code
604
-	 *   @return	void
605
-	 */
606
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
607
-	{
608
-	    global $conf;
609
-
610
-	    // Force to disable hidetop and hidebottom
611
-	    $hidebottom=0;
612
-	    if ($hidetop) $hidetop=-1;
613
-
614
-	    $currency = !empty($currency) ? $currency : $conf->currency;
615
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
616
-
617
-	    // Amount in (at tab_top - 1)
618
-	    $pdf->SetTextColor(0,0,0);
619
-	    $pdf->SetFont('','', $default_font_size - 2);
620
-
621
-	    if (empty($hidetop))
622
-	    {
623
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
624
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
625
-	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
626
-
627
-	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
628
-	        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));
629
-	    }
555
+                // Affiche zone infos
556
+                //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
630 557
 
631
-	    $pdf->SetDrawColor(128,128,128);
632
-	    $pdf->SetFont('','', $default_font_size - 1);
558
+                // Pied de page
559
+                $this->_pagefoot($pdf,$object,$outputlangs);
560
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
633 561
 
634
-	    // Output Rect
635
-	    $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
562
+                $pdf->Close();
636 563
 
637
-	    if (empty($hidetop))
638
-	    {
639
-	        $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
564
+                $pdf->Output($file,'F');
640 565
 
641
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
642
-	        $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
643
-	    }
644
-
645
-	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
646
-	    {
647
-	        $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
648
-	        if (empty($hidetop))
649
-	        {
650
-	            $pdf->SetXY($this->posxtva-3, $tab_top+1);
651
-	            $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
652
-	        }
653
-	    }
654
-
655
-	    $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
656
-	    if (empty($hidetop))
657
-	    {
658
-	        $pdf->SetXY($this->posxup-1, $tab_top+1);
659
-	        $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
660
-	    }
566
+                // Add pdfgeneration hook
567
+                $hookmanager->initHooks(array('pdfgeneration'));
568
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
569
+                global $action;
570
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
661 571
 
662
-	    $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
663
-	    if (empty($hidetop))
664
-	    {
665
-	        $pdf->SetXY($this->posxqty-1, $tab_top+1);
666
-	        if($conf->global->PRODUCT_USE_UNITS)
667
-	        {
668
-	            $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
669
-	        }
670
-	        else
671
-	        {
672
-	            $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
673
-	        }
674
-	    }
675
-
676
-	    if($conf->global->PRODUCT_USE_UNITS) {
677
-	        $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
678
-	        if (empty($hidetop)) {
679
-	            $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
680
-	            $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
681
-	                'C');
682
-	        }
683
-	    }
572
+                if (! empty($conf->global->MAIN_UMASK))
573
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
684 574
 
685
-	    $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
686
-	    if (empty($hidetop))
687
-	    {
688
-	        if ($this->atleastonediscount)
689
-	        {
690
-	            $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
691
-	            $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
692
-	        }
693
-	    }
575
+                $this->result = array('fullpath'=>$file);
694 576
 
695
-	    if ($this->atleastonediscount)
696
-	    {
697
-	        $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
698
-	    }
699
-	    if (empty($hidetop))
700
-	    {
701
-	        $pdf->SetXY($this->postotalht-1, $tab_top+1);
702
-	        $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
703
-	    }
704
-	}
705
-
706
-	/**
707
-	 *  Show top header of page.
708
-	 *
709
-	 *  @param	TCPDF		$pdf     		Object PDF
710
-	 *  @param  Object		$object     	Object to show
711
-	 *  @param  int	    	$showaddress    0=no, 1=yes
712
-	 *  @param  Translate	$outputlangs	Object lang for output
713
-	 *  @param	string		$titlekey		Translation key to show as title of document
714
-	 *  @return	void
715
-	 */
716
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
717
-	{
718
-	    global $conf,$langs,$hookmanager;
719
-
720
-	    // Load traductions files requiredby by page
721
-		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders"));
722
-
723
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
724
-
725
-	    if ($object->type == 1) $titlekey='ServiceSheet';
726
-	    else $titlekey='ProductSheet';
727
-
728
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
729
-
730
-	    // Show Draft Watermark
731
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
732
-	    {
733
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
734
-	    }
577
+                return 1;   // Pas d'erreur
578
+            }
579
+            else
580
+            {
581
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
582
+                return 0;
583
+            }
584
+        }
585
+        else
586
+        {
587
+            $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
588
+            return 0;
589
+        }
590
+    }
735 591
 
736
-	    $pdf->SetTextColor(0,0,60);
737
-	    $pdf->SetFont('','B', $default_font_size + 3);
738 592
 
739
-	    $posy=$this->marge_haute;
740
-	    $posx=$this->page_largeur-$this->marge_droite-100;
741
-
742
-	    $pdf->SetXY($this->marge_gauche,$posy);
743
-
744
-	    // Logo
745
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
746
-	    if ($this->emetteur->logo)
747
-	    {
748
-	        if (is_readable($logo))
749
-	        {
750
-	            $height=pdf_getHeightForLogo($logo);
751
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
752
-	        }
753
-	        else
754
-	        {
755
-	            $pdf->SetTextColor(200,0,0);
756
-	            $pdf->SetFont('','B', $default_font_size -2);
757
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
758
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
759
-	        }
760
-	    }
761
-	    else
762
-	    {
763
-	        $text=$this->emetteur->name;
764
-	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
765
-	    }
766
-
767
-	    $pdf->SetFont('','B', $default_font_size + 3);
768
-	    $pdf->SetXY($posx,$posy);
769
-	    $pdf->SetTextColor(0,0,60);
770
-	    $title=$outputlangs->transnoentities($titlekey);
771
-	    $pdf->MultiCell(100, 3, $title, '', 'R');
772
-
773
-	    $pdf->SetFont('','B',$default_font_size);
774
-
775
-	    $posy+=5;
776
-	    $pdf->SetXY($posx,$posy);
777
-	    $pdf->SetTextColor(0,0,60);
778
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
779
-
780
-	    $posy+=1;
781
-	    $pdf->SetFont('','', $default_font_size - 1);
593
+    /**
594
+     *   Show table for lines
595
+     *
596
+     *   @param		TCPDF		$pdf     		Object PDF
597
+     *   @param		string		$tab_top		Top position of table
598
+     *   @param		string		$tab_height		Height of table (rectangle)
599
+     *   @param		int			$nexY			Y (not used)
600
+     *   @param		Translate	$outputlangs	Langs object
601
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
602
+     *   @param		int			$hidebottom		Hide bottom bar of array
603
+     *   @param		string		$currency		Currency code
604
+     *   @return	void
605
+     */
606
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
607
+    {
608
+        global $conf;
609
+
610
+        // Force to disable hidetop and hidebottom
611
+        $hidebottom=0;
612
+        if ($hidetop) $hidetop=-1;
613
+
614
+        $currency = !empty($currency) ? $currency : $conf->currency;
615
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
616
+
617
+        // Amount in (at tab_top - 1)
618
+        $pdf->SetTextColor(0,0,0);
619
+        $pdf->SetFont('','', $default_font_size - 2);
620
+
621
+        if (empty($hidetop))
622
+        {
623
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
624
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
625
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
626
+
627
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
628
+            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));
629
+        }
630
+
631
+        $pdf->SetDrawColor(128,128,128);
632
+        $pdf->SetFont('','', $default_font_size - 1);
633
+
634
+        // Output Rect
635
+        $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
636
+
637
+        if (empty($hidetop))
638
+        {
639
+            $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
640
+
641
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
642
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
643
+        }
644
+
645
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
646
+        {
647
+            $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
648
+            if (empty($hidetop))
649
+            {
650
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
651
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
652
+            }
653
+        }
654
+
655
+        $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
656
+        if (empty($hidetop))
657
+        {
658
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
659
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
660
+        }
661
+
662
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
663
+        if (empty($hidetop))
664
+        {
665
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
666
+            if($conf->global->PRODUCT_USE_UNITS)
667
+            {
668
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
669
+            }
670
+            else
671
+            {
672
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
673
+            }
674
+        }
675
+
676
+        if($conf->global->PRODUCT_USE_UNITS) {
677
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
678
+            if (empty($hidetop)) {
679
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
680
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
681
+                    'C');
682
+            }
683
+        }
684
+
685
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
686
+        if (empty($hidetop))
687
+        {
688
+            if ($this->atleastonediscount)
689
+            {
690
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
691
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
692
+            }
693
+        }
694
+
695
+        if ($this->atleastonediscount)
696
+        {
697
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
698
+        }
699
+        if (empty($hidetop))
700
+        {
701
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
702
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
703
+        }
704
+    }
782 705
 
783
-	    /*if ($object->ref_client)
706
+    /**
707
+     *  Show top header of page.
708
+     *
709
+     *  @param	TCPDF		$pdf     		Object PDF
710
+     *  @param  Object		$object     	Object to show
711
+     *  @param  int	    	$showaddress    0=no, 1=yes
712
+     *  @param  Translate	$outputlangs	Object lang for output
713
+     *  @param	string		$titlekey		Translation key to show as title of document
714
+     *  @return	void
715
+     */
716
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
717
+    {
718
+        global $conf,$langs,$hookmanager;
719
+
720
+        // Load traductions files requiredby by page
721
+        $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders"));
722
+
723
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
724
+
725
+        if ($object->type == 1) $titlekey='ServiceSheet';
726
+        else $titlekey='ProductSheet';
727
+
728
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
729
+
730
+        // Show Draft Watermark
731
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
732
+        {
733
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
734
+        }
735
+
736
+        $pdf->SetTextColor(0,0,60);
737
+        $pdf->SetFont('','B', $default_font_size + 3);
738
+
739
+        $posy=$this->marge_haute;
740
+        $posx=$this->page_largeur-$this->marge_droite-100;
741
+
742
+        $pdf->SetXY($this->marge_gauche,$posy);
743
+
744
+        // Logo
745
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
746
+        if ($this->emetteur->logo)
747
+        {
748
+            if (is_readable($logo))
749
+            {
750
+                $height=pdf_getHeightForLogo($logo);
751
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
752
+            }
753
+            else
754
+            {
755
+                $pdf->SetTextColor(200,0,0);
756
+                $pdf->SetFont('','B', $default_font_size -2);
757
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
758
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
759
+            }
760
+        }
761
+        else
762
+        {
763
+            $text=$this->emetteur->name;
764
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
765
+        }
766
+
767
+        $pdf->SetFont('','B', $default_font_size + 3);
768
+        $pdf->SetXY($posx,$posy);
769
+        $pdf->SetTextColor(0,0,60);
770
+        $title=$outputlangs->transnoentities($titlekey);
771
+        $pdf->MultiCell(100, 3, $title, '', 'R');
772
+
773
+        $pdf->SetFont('','B',$default_font_size);
774
+
775
+        $posy+=5;
776
+        $pdf->SetXY($posx,$posy);
777
+        $pdf->SetTextColor(0,0,60);
778
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
779
+
780
+        $posy+=1;
781
+        $pdf->SetFont('','', $default_font_size - 1);
782
+
783
+        /*if ($object->ref_client)
784 784
 	    {
785 785
 	        $posy+=5;
786 786
 	        $pdf->SetXY($posx,$posy);
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 	        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
789 789
 	    }*/
790 790
 
791
-	    /*$posy+=4;
791
+        /*$posy+=4;
792 792
 	    $pdf->SetXY($posx,$posy);
793 793
 	    $pdf->SetTextColor(0,0,60);
794 794
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
795 795
 	    */
796 796
 
797
-	    // Get contact
798
-	    /*
797
+        // Get contact
798
+        /*
799 799
 	    if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
800 800
 	    {
801 801
 	        $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 	        }
811 811
 	    }*/
812 812
 
813
-	    $posy+=2;
813
+        $posy+=2;
814 814
 
815
-	    // Show list of linked objects
816
-	    $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
815
+        // Show list of linked objects
816
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
817 817
 
818
-	    if ($showaddress)
819
-	    {
820
-	        /*
818
+        if ($showaddress)
819
+        {
820
+            /*
821 821
 	        // Sender properties
822 822
 	        $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
823 823
 
@@ -848,24 +848,24 @@  discard block
 block discarded – undo
848 848
 	        $pdf->SetFont('','', $default_font_size - 1);
849 849
 	        $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
850 850
 	        */
851
-	    }
852
-
853
-	    $pdf->SetTextColor(0,0,0);
854
-	}
855
-
856
-	/**
857
-	 *   	Show footer of page. Need this->emetteur object
858
-	 *
859
-	 *   	@param	TCPDF		$pdf     			PDF
860
-	 * 		@param	Object		$object				Object to show
861
-	 *      @param	Translate	$outputlangs		Object lang for output
862
-	 *      @param	int			$hidefreetext		1=Hide free text
863
-	 *      @return	int								Return height of bottom margin including footer text
864
-	 */
865
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
866
-	{
867
-	    global $conf;
868
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
869
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
870
-	}
851
+        }
852
+
853
+        $pdf->SetTextColor(0,0,0);
854
+    }
855
+
856
+    /**
857
+     *   	Show footer of page. Need this->emetteur object
858
+     *
859
+     *   	@param	TCPDF		$pdf     			PDF
860
+     * 		@param	Object		$object				Object to show
861
+     *      @param	Translate	$outputlangs		Object lang for output
862
+     *      @param	int			$hidefreetext		1=Hide free text
863
+     *      @return	int								Return height of bottom margin including footer text
864
+     */
865
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
866
+    {
867
+        global $conf;
868
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
869
+        return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
870
+    }
871 871
 }
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function __construct($db)
119 119
 	{
120
-		global $conf,$langs,$mysoc;
120
+		global $conf, $langs, $mysoc;
121 121
 
122 122
 		// Load traductions files requiredby by page
123 123
 		$langs->loadLangs(array("main", "companies"));
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 
129 129
 		// Dimension page pour format A4
130 130
 		$this->type = 'pdf';
131
-		$formatarray=pdf_getFormat();
131
+		$formatarray = pdf_getFormat();
132 132
 		$this->page_largeur = $formatarray['width'];
133 133
 		$this->page_hauteur = $formatarray['height'];
134
-		$this->format = array($this->page_largeur,$this->page_hauteur);
135
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
136
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
137
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
138
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
134
+		$this->format = array($this->page_largeur, $this->page_hauteur);
135
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
136
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
137
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
138
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
139 139
 
140
-		$this->option_logo = 1;                    // Affiche logo
141
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
142
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
143
-		$this->option_freetext = 0;				   // Support add of a personalised text
140
+		$this->option_logo = 1; // Affiche logo
141
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
142
+		$this->option_multilang = 1; // Dispo en plusieurs langues
143
+		$this->option_freetext = 0; // Support add of a personalised text
144 144
 
145 145
 		// Recupere emetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
146
+		$this->emetteur = $mysoc;
147
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
148 148
 	}
149 149
 
150 150
 
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	 *  @param		int			$hideref			Do not show ref
161 161
 	 *	@return		int         					1 if OK, <=0 if KO
162 162
 	 */
163
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
163
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
164 164
 	{
165 165
         // phpcs:enable
166
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
166
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
167 167
 
168
-		if (! is_object($outputlangs)) $outputlangs=$langs;
168
+		if (!is_object($outputlangs)) $outputlangs = $langs;
169 169
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
170
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
170
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
171 171
 
172 172
 		// Load traductions files requiredby by page
173 173
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
 			if ($object->specimen)
181 181
 			{
182 182
 				$dir = $conf->produit->dir_output;
183
-				$file = $dir . "/SPECIMEN.pdf";
183
+				$file = $dir."/SPECIMEN.pdf";
184 184
 			}
185 185
 			else
186 186
 			{
187 187
 				$objectref = dol_sanitizeFileName($object->ref);
188
-				$dir = $conf->produit->dir_output . "/" . $objectref;
189
-				$file = $dir . "/" . $objectref . ".pdf";
188
+				$dir = $conf->produit->dir_output."/".$objectref;
189
+				$file = $dir."/".$objectref.".pdf";
190 190
 			}
191 191
 
192 192
 			$productFournisseur = new ProductFournisseur($this->db);
193 193
 			$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
194 194
 			$object->supplierprices = $supplierprices;
195 195
 
196
-			if (! file_exists($dir))
196
+			if (!file_exists($dir))
197 197
 			{
198 198
 				if (dol_mkdir($dir) < 0)
199 199
 				{
200
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
200
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
201 201
 					return -1;
202 202
 				}
203 203
 			}
@@ -205,25 +205,25 @@  discard block
 block discarded – undo
205 205
 			if (file_exists($dir))
206 206
 			{
207 207
 							// Add pdfgeneration hook
208
-				if (! is_object($hookmanager))
208
+				if (!is_object($hookmanager))
209 209
 				{
210 210
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
-					$hookmanager=new HookManager($this->db);
211
+					$hookmanager = new HookManager($this->db);
212 212
 				}
213 213
 				$hookmanager->initHooks(array('pdfgeneration'));
214
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
214
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
215 215
 				global $action;
216
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
216
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
217 217
 
218 218
 				// Create pdf instance
219
-				$pdf=pdf_getInstance($this->format);
220
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
221
-				$pdf->SetAutoPageBreak(1,0);
219
+				$pdf = pdf_getInstance($this->format);
220
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
221
+				$pdf->SetAutoPageBreak(1, 0);
222 222
 
223
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
224
-		        $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
225
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
223
+				$heightforinfotot = 40; // Height reserved to output the info and total part
224
+		        $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
225
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
226
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
227 227
 
228 228
                 if (class_exists('TCPDF'))
229 229
                 {
@@ -232,51 +232,51 @@  discard block
 block discarded – undo
232 232
                 }
233 233
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
234 234
                 // Set path to the background PDF File
235
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
235
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236 236
                 {
237 237
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
238 238
                     $tplidx = $pdf->importPage(1);
239 239
                 }
240 240
 
241 241
 				$pdf->Open();
242
-				$pagenb=0;
243
-				$pdf->SetDrawColor(128,128,128);
242
+				$pagenb = 0;
243
+				$pdf->SetDrawColor(128, 128, 128);
244 244
 
245 245
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
246 246
 				$pdf->SetSubject($outputlangs->transnoentities("Order"));
247 247
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
248 248
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
249 249
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
250
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
250
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
251 251
 
252
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
252
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
253 253
 
254 254
 
255 255
 				// New page
256 256
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
257
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
258 258
 				$pagenb++;
259 259
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260
-				$pdf->SetFont('','', $default_font_size - 1);
261
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
262
-				$pdf->SetTextColor(0,0,0);
260
+				$pdf->SetFont('', '', $default_font_size - 1);
261
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
262
+				$pdf->SetTextColor(0, 0, 0);
263 263
 
264 264
 
265 265
 				$tab_top = 42;
266
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
266
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
267 267
 				$tab_height = 130;
268 268
 				$tab_height_newpage = 150;
269 269
 
270 270
 				//
271
-				$pdf->SetFont('','B', $default_font_size);
271
+				$pdf->SetFont('', 'B', $default_font_size);
272 272
 				$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1);
273 273
 				$nexY = $pdf->GetY();
274 274
 
275
-				$pdf->SetFont('','', $default_font_size);
275
+				$pdf->SetFont('', '', $default_font_size);
276 276
 				$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1);
277 277
 				$nexY = $pdf->GetY();
278 278
 
279
-				$nexY+=5;
279
+				$nexY += 5;
280 280
 
281 281
 				if ($object->weight)
282 282
 				{
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				}
286 286
 				if ($object->weight)
287 287
 				{
288
-				    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.($object->length != ''?$object->length:'?').' x '.($object->width != ''?$object->width:'?').' x '.($object->height != ''?$object->height:'?'), 0, 1);
288
+				    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.($object->length != '' ? $object->length : '?').' x '.($object->width != '' ? $object->width : '?').' x '.($object->height != '' ? $object->height : '?'), 0, 1);
289 289
 				    $nexY = $pdf->GetY();
290 290
 				}
291 291
 				if ($object->surface)
@@ -302,41 +302,41 @@  discard block
 block discarded – undo
302 302
 
303 303
 				// Affiche notes
304 304
 				// TODO There is no public note on product yet
305
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
306
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
305
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
306
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
307 307
 				{
308 308
 					// Get first sale rep
309 309
 					if (is_object($object->thirdparty))
310 310
 					{
311
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
312
-						$salerepobj=new User($this->db);
311
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
312
+						$salerepobj = new User($this->db);
313 313
 						$salerepobj->fetch($salereparray[0]['id']);
314
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
314
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
315 315
 					}
316 316
 				}
317 317
 				if ($notetoshow)
318 318
 				{
319
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
319
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
320 320
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
321 321
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
322 322
 
323 323
 					$tab_top = 88;
324 324
 
325
-					$pdf->SetFont('','', $default_font_size - 1);
326
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
325
+					$pdf->SetFont('', '', $default_font_size - 1);
326
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
327 327
 					$nexY = $pdf->GetY();
328
-					$height_note=$nexY-$tab_top;
328
+					$height_note = $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_note+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_note + 1);
333 333
 
334 334
 					$tab_height = $tab_height - $height_note;
335
-					$tab_top = $nexY+6;
335
+					$tab_top = $nexY + 6;
336 336
 				}
337 337
 				else
338 338
 				{
339
-					$height_note=0;
339
+					$height_note = 0;
340 340
 				}
341 341
 
342 342
 				$iniY = $tab_top + 7;
@@ -556,35 +556,35 @@  discard block
 block discarded – undo
556 556
 				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
557 557
 
558 558
 				// Pied de page
559
-				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
559
+				$this->_pagefoot($pdf, $object, $outputlangs);
560
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
561 561
 
562 562
 				$pdf->Close();
563 563
 
564
-				$pdf->Output($file,'F');
564
+				$pdf->Output($file, 'F');
565 565
 
566 566
 				// Add pdfgeneration hook
567 567
 				$hookmanager->initHooks(array('pdfgeneration'));
568
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
568
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
569 569
 				global $action;
570
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
571 571
 
572
-				if (! empty($conf->global->MAIN_UMASK))
572
+				if (!empty($conf->global->MAIN_UMASK))
573 573
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
574 574
 
575 575
 				$this->result = array('fullpath'=>$file);
576 576
 
577
-				return 1;   // Pas d'erreur
577
+				return 1; // Pas d'erreur
578 578
 			}
579 579
 			else
580 580
 			{
581
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
581
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
582 582
 				return 0;
583 583
 			}
584 584
 		}
585 585
 		else
586 586
 		{
587
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
587
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR");
588 588
 			return 0;
589 589
 		}
590 590
 	}
@@ -603,77 +603,77 @@  discard block
 block discarded – undo
603 603
 	 *   @param		string		$currency		Currency code
604 604
 	 *   @return	void
605 605
 	 */
606
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
606
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
607 607
 	{
608 608
 	    global $conf;
609 609
 
610 610
 	    // Force to disable hidetop and hidebottom
611
-	    $hidebottom=0;
612
-	    if ($hidetop) $hidetop=-1;
611
+	    $hidebottom = 0;
612
+	    if ($hidetop) $hidetop = -1;
613 613
 
614 614
 	    $currency = !empty($currency) ? $currency : $conf->currency;
615 615
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
616 616
 
617 617
 	    // Amount in (at tab_top - 1)
618
-	    $pdf->SetTextColor(0,0,0);
619
-	    $pdf->SetFont('','', $default_font_size - 2);
618
+	    $pdf->SetTextColor(0, 0, 0);
619
+	    $pdf->SetFont('', '', $default_font_size - 2);
620 620
 
621 621
 	    if (empty($hidetop))
622 622
 	    {
623
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
624
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
623
+	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
624
+	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
625 625
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
626 626
 
627 627
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
628
-	        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));
628
+	        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));
629 629
 	    }
630 630
 
631
-	    $pdf->SetDrawColor(128,128,128);
632
-	    $pdf->SetFont('','', $default_font_size - 1);
631
+	    $pdf->SetDrawColor(128, 128, 128);
632
+	    $pdf->SetFont('', '', $default_font_size - 1);
633 633
 
634 634
 	    // Output Rect
635
-	    $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
635
+	    $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
636 636
 
637 637
 	    if (empty($hidetop))
638 638
 	    {
639
-	        $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
639
+	        $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
640 640
 
641
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
642
-	        $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
641
+	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
642
+	        $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
643 643
 	    }
644 644
 
645 645
 	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
646 646
 	    {
647
-	        $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
647
+	        $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
648 648
 	        if (empty($hidetop))
649 649
 	        {
650
-	            $pdf->SetXY($this->posxtva-3, $tab_top+1);
651
-	            $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
650
+	            $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
651
+	            $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
652 652
 	        }
653 653
 	    }
654 654
 
655
-	    $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
655
+	    $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
656 656
 	    if (empty($hidetop))
657 657
 	    {
658
-	        $pdf->SetXY($this->posxup-1, $tab_top+1);
659
-	        $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
658
+	        $pdf->SetXY($this->posxup - 1, $tab_top + 1);
659
+	        $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
660 660
 	    }
661 661
 
662
-	    $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
662
+	    $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
663 663
 	    if (empty($hidetop))
664 664
 	    {
665
-	        $pdf->SetXY($this->posxqty-1, $tab_top+1);
666
-	        if($conf->global->PRODUCT_USE_UNITS)
665
+	        $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
666
+	        if ($conf->global->PRODUCT_USE_UNITS)
667 667
 	        {
668
-	            $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
668
+	            $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
669 669
 	        }
670 670
 	        else
671 671
 	        {
672
-	            $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
672
+	            $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
673 673
 	        }
674 674
 	    }
675 675
 
676
-	    if($conf->global->PRODUCT_USE_UNITS) {
676
+	    if ($conf->global->PRODUCT_USE_UNITS) {
677 677
 	        $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
678 678
 	        if (empty($hidetop)) {
679 679
 	            $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
 	        }
683 683
 	    }
684 684
 
685
-	    $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
685
+	    $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
686 686
 	    if (empty($hidetop))
687 687
 	    {
688 688
 	        if ($this->atleastonediscount)
689 689
 	        {
690
-	            $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
691
-	            $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
690
+	            $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
691
+	            $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
692 692
 	        }
693 693
 	    }
694 694
 
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
 	    }
699 699
 	    if (empty($hidetop))
700 700
 	    {
701
-	        $pdf->SetXY($this->postotalht-1, $tab_top+1);
702
-	        $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
701
+	        $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
702
+	        $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
703 703
 	    }
704 704
 	}
705 705
 
@@ -713,72 +713,72 @@  discard block
 block discarded – undo
713 713
 	 *  @param	string		$titlekey		Translation key to show as title of document
714 714
 	 *  @return	void
715 715
 	 */
716
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
716
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
717 717
 	{
718
-	    global $conf,$langs,$hookmanager;
718
+	    global $conf, $langs, $hookmanager;
719 719
 
720 720
 	    // Load traductions files requiredby by page
721 721
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders"));
722 722
 
723 723
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
724 724
 
725
-	    if ($object->type == 1) $titlekey='ServiceSheet';
726
-	    else $titlekey='ProductSheet';
725
+	    if ($object->type == 1) $titlekey = 'ServiceSheet';
726
+	    else $titlekey = 'ProductSheet';
727 727
 
728
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
728
+	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
729 729
 
730 730
 	    // Show Draft Watermark
731
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
731
+	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
732 732
 	    {
733
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
733
+	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
734 734
 	    }
735 735
 
736
-	    $pdf->SetTextColor(0,0,60);
737
-	    $pdf->SetFont('','B', $default_font_size + 3);
736
+	    $pdf->SetTextColor(0, 0, 60);
737
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
738 738
 
739
-	    $posy=$this->marge_haute;
740
-	    $posx=$this->page_largeur-$this->marge_droite-100;
739
+	    $posy = $this->marge_haute;
740
+	    $posx = $this->page_largeur - $this->marge_droite - 100;
741 741
 
742
-	    $pdf->SetXY($this->marge_gauche,$posy);
742
+	    $pdf->SetXY($this->marge_gauche, $posy);
743 743
 
744 744
 	    // Logo
745
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
745
+	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
746 746
 	    if ($this->emetteur->logo)
747 747
 	    {
748 748
 	        if (is_readable($logo))
749 749
 	        {
750
-	            $height=pdf_getHeightForLogo($logo);
751
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
750
+	            $height = pdf_getHeightForLogo($logo);
751
+	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
752 752
 	        }
753 753
 	        else
754 754
 	        {
755
-	            $pdf->SetTextColor(200,0,0);
756
-	            $pdf->SetFont('','B', $default_font_size -2);
757
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
755
+	            $pdf->SetTextColor(200, 0, 0);
756
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
757
+	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
758 758
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
759 759
 	        }
760 760
 	    }
761 761
 	    else
762 762
 	    {
763
-	        $text=$this->emetteur->name;
763
+	        $text = $this->emetteur->name;
764 764
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
765 765
 	    }
766 766
 
767
-	    $pdf->SetFont('','B', $default_font_size + 3);
768
-	    $pdf->SetXY($posx,$posy);
769
-	    $pdf->SetTextColor(0,0,60);
770
-	    $title=$outputlangs->transnoentities($titlekey);
767
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
768
+	    $pdf->SetXY($posx, $posy);
769
+	    $pdf->SetTextColor(0, 0, 60);
770
+	    $title = $outputlangs->transnoentities($titlekey);
771 771
 	    $pdf->MultiCell(100, 3, $title, '', 'R');
772 772
 
773
-	    $pdf->SetFont('','B',$default_font_size);
773
+	    $pdf->SetFont('', 'B', $default_font_size);
774 774
 
775
-	    $posy+=5;
776
-	    $pdf->SetXY($posx,$posy);
777
-	    $pdf->SetTextColor(0,0,60);
778
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
775
+	    $posy += 5;
776
+	    $pdf->SetXY($posx, $posy);
777
+	    $pdf->SetTextColor(0, 0, 60);
778
+	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
779 779
 
780
-	    $posy+=1;
781
-	    $pdf->SetFont('','', $default_font_size - 1);
780
+	    $posy += 1;
781
+	    $pdf->SetFont('', '', $default_font_size - 1);
782 782
 
783 783
 	    /*if ($object->ref_client)
784 784
 	    {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	        }
811 811
 	    }*/
812 812
 
813
-	    $posy+=2;
813
+	    $posy += 2;
814 814
 
815 815
 	    // Show list of linked objects
816 816
 	    $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	        */
851 851
 	    }
852 852
 
853
-	    $pdf->SetTextColor(0,0,0);
853
+	    $pdf->SetTextColor(0, 0, 0);
854 854
 	}
855 855
 
856 856
 	/**
@@ -862,10 +862,10 @@  discard block
 block discarded – undo
862 862
 	 *      @param	int			$hidefreetext		1=Hide free text
863 863
 	 *      @return	int								Return height of bottom margin including footer text
864 864
 	 */
865
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
865
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
866 866
 	{
867 867
 	    global $conf;
868
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
869
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
868
+	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
869
+	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
870 870
 	}
871 871
 }
Please login to merge, or discard this patch.
Braces   +46 added lines, -28 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere emetteur
146 146
 		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
147
+		if (! $this->emetteur->country_code) {
148
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
149
+		}
150
+		// By default if not defined
148 151
 	}
149 152
 
150 153
 
@@ -165,9 +168,13 @@  discard block
 block discarded – undo
165 168
         // phpcs:enable
166 169
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
167 170
 
168
-		if (! is_object($outputlangs)) $outputlangs=$langs;
171
+		if (! is_object($outputlangs)) {
172
+		    $outputlangs=$langs;
173
+		}
169 174
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
170
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
175
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
176
+		    $outputlangs->charset_output='ISO-8859-1';
177
+		}
171 178
 
172 179
 		// Load traductions files requiredby by page
173 180
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -181,8 +188,7 @@  discard block
 block discarded – undo
181 188
 			{
182 189
 				$dir = $conf->produit->dir_output;
183 190
 				$file = $dir . "/SPECIMEN.pdf";
184
-			}
185
-			else
191
+			} else
186 192
 			{
187 193
 				$objectref = dol_sanitizeFileName($object->ref);
188 194
 				$dir = $conf->produit->dir_output . "/" . $objectref;
@@ -223,7 +229,9 @@  discard block
 block discarded – undo
223 229
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
224 230
 		        $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
225 231
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
232
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
233
+	                $heightforfooter+= 6;
234
+	            }
227 235
 
228 236
                 if (class_exists('TCPDF'))
229 237
                 {
@@ -247,14 +255,18 @@  discard block
 block discarded – undo
247 255
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
248 256
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
249 257
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
250
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
258
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
259
+				    $pdf->SetCompression(false);
260
+				}
251 261
 
252 262
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
253 263
 
254 264
 
255 265
 				// New page
256 266
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
267
+				if (! empty($tplidx)) {
268
+				    $pdf->useTemplate($tplidx);
269
+				}
258 270
 				$pagenb++;
259 271
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260 272
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -311,7 +323,9 @@  discard block
 block discarded – undo
311 323
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
312 324
 						$salerepobj=new User($this->db);
313 325
 						$salerepobj->fetch($salereparray[0]['id']);
314
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
326
+						if (! empty($salerepobj->signature)) {
327
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
328
+						}
315 329
 					}
316 330
 				}
317 331
 				if ($notetoshow)
@@ -333,8 +347,7 @@  discard block
 block discarded – undo
333 347
 
334 348
 					$tab_height = $tab_height - $height_note;
335 349
 					$tab_top = $nexY+6;
336
-				}
337
-				else
350
+				} else
338 351
 				{
339 352
 					$height_note=0;
340 353
 				}
@@ -557,7 +570,9 @@  discard block
 block discarded – undo
557 570
 
558 571
 				// Pied de page
559 572
 				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
573
+				if (method_exists($pdf,'AliasNbPages')) {
574
+				    $pdf->AliasNbPages();
575
+				}
561 576
 
562 577
 				$pdf->Close();
563 578
 
@@ -569,20 +584,19 @@  discard block
 block discarded – undo
569 584
 				global $action;
570 585
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
571 586
 
572
-				if (! empty($conf->global->MAIN_UMASK))
573
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
587
+				if (! empty($conf->global->MAIN_UMASK)) {
588
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
589
+				}
574 590
 
575 591
 				$this->result = array('fullpath'=>$file);
576 592
 
577 593
 				return 1;   // Pas d'erreur
578
-			}
579
-			else
594
+			} else
580 595
 			{
581 596
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
582 597
 				return 0;
583 598
 			}
584
-		}
585
-		else
599
+		} else
586 600
 		{
587 601
 			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
588 602
 			return 0;
@@ -609,7 +623,9 @@  discard block
 block discarded – undo
609 623
 
610 624
 	    // Force to disable hidetop and hidebottom
611 625
 	    $hidebottom=0;
612
-	    if ($hidetop) $hidetop=-1;
626
+	    if ($hidetop) {
627
+	        $hidetop=-1;
628
+	    }
613 629
 
614 630
 	    $currency = !empty($currency) ? $currency : $conf->currency;
615 631
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -625,7 +641,9 @@  discard block
 block discarded – undo
625 641
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
626 642
 
627 643
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
628
-	        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));
644
+	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
645
+	            $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));
646
+	        }
629 647
 	    }
630 648
 
631 649
 	    $pdf->SetDrawColor(128,128,128);
@@ -666,8 +684,7 @@  discard block
 block discarded – undo
666 684
 	        if($conf->global->PRODUCT_USE_UNITS)
667 685
 	        {
668 686
 	            $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
669
-	        }
670
-	        else
687
+	        } else
671 688
 	        {
672 689
 	            $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
673 690
 	        }
@@ -722,8 +739,11 @@  discard block
 block discarded – undo
722 739
 
723 740
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
724 741
 
725
-	    if ($object->type == 1) $titlekey='ServiceSheet';
726
-	    else $titlekey='ProductSheet';
742
+	    if ($object->type == 1) {
743
+	        $titlekey='ServiceSheet';
744
+	    } else {
745
+	        $titlekey='ProductSheet';
746
+	    }
727 747
 
728 748
 	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
729 749
 
@@ -749,16 +769,14 @@  discard block
 block discarded – undo
749 769
 	        {
750 770
 	            $height=pdf_getHeightForLogo($logo);
751 771
 	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
752
-	        }
753
-	        else
772
+	        } else
754 773
 	        {
755 774
 	            $pdf->SetTextColor(200,0,0);
756 775
 	            $pdf->SetFont('','B', $default_font_size -2);
757 776
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
758 777
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
759 778
 	        }
760
-	    }
761
-	    else
779
+	    } else
762 780
 	    {
763 781
 	        $text=$this->emetteur->name;
764 782
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
Please login to merge, or discard this patch.