Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php 3 patches
Indentation   +992 added lines, -992 removed lines patch added patch discarded remove patch
@@ -42,32 +42,32 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public $db;
44 44
 
45
-	/**
45
+    /**
46 46
      * @var string model name
47 47
      */
48 48
     public $name;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model description (short text)
52 52
      */
53 53
     public $description;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string document type
57 57
      */
58 58
     public $type;
59 59
 
60
-	/**
60
+    /**
61 61
      * @var array() Minimum version of PHP required by module.
62
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
62
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
63 63
      */
64
-	public $phpmin = array(5, 4);
64
+    public $phpmin = array(5, 4);
65 65
 
66
-	/**
66
+    /**
67 67
      * Dolibarr version of the loaded document
68 68
      * @public string
69 69
      */
70
-	public $version = 'dolibarr';
70
+    public $version = 'dolibarr';
71 71
 
72 72
     /**
73 73
      * @var int page_largeur
@@ -84,342 +84,342 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public $format;
86 86
 
87
-	/**
87
+    /**
88 88
      * @var int marge_gauche
89 89
      */
90
-	public $marge_gauche;
90
+    public $marge_gauche;
91 91
 
92
-	/**
92
+    /**
93 93
      * @var int marge_droite
94 94
      */
95
-	public $marge_droite;
95
+    public $marge_droite;
96 96
 
97
-	/**
97
+    /**
98 98
      * @var int marge_haute
99 99
      */
100
-	public $marge_haute;
100
+    public $marge_haute;
101 101
 
102
-	/**
102
+    /**
103 103
      * @var int marge_basse
104 104
      */
105
-	public $marge_basse;
105
+    public $marge_basse;
106
+
107
+    /**
108
+     * Issuer
109
+     * @var Societe
110
+     */
111
+    public $emetteur;
112
+
106 113
 
107 114
     /**
108
-	 * Issuer
109
-	 * @var Societe
110
-	 */
111
-	public $emetteur;
112
-
113
-
114
-	/**
115
-	 *	Constructor
116
-	 *
117
-	 *  @param		DoliDB		$db      Database handler
118
-	 */
119
-	public function __construct($db)
120
-	{
121
-		global $conf,$langs,$mysoc;
122
-
123
-		// Load traductions files requiredby by page
124
-		$langs->loadLangs(array("main", "companies"));
125
-
126
-		$this->db = $db;
127
-		$this->name = "stdmouvement";
128
-		$this->description = $langs->trans("DocumentModelStandardPDF");
129
-
130
-		// Dimension page pour format A4
131
-		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
133
-		$this->page_largeur = $formatarray['width'];
134
-		$this->page_hauteur = $formatarray['height'];
135
-		$this->format = array($this->page_largeur,$this->page_hauteur);
136
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
140
-
141
-		$this->option_logo = 1;                    // Affiche logo
142
-		$this->option_codestockservice = 0;      // Affiche code stock-service
143
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
144
-		$this->option_freetext = 0;				   // Support add of a personalised text
145
-
146
-		// Recupere emetteur
147
-		$this->emetteur=$mysoc;
148
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
149
-
150
-		// Define position of columns
151
-		$this->wref = 15;
152
-		$this->posxidref = $this->marge_gauche;
153
-		$this->posxdatemouv = $this->marge_gauche+8;
154
-		$this->posxdesc=37;
155
-		$this->posxlabel=50;
156
-		$this->posxtva=80;
157
-		$this->posxqty=105;
158
-		$this->posxup=119;
159
-		$this->posxunit=136;
160
-		$this->posxdiscount=167;
161
-		$this->postotalht=180;
162
-
163
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
164
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
165
-		if ($this->page_largeur < 210) // To work with US executive format
166
-		{
167
-			$this->posxpicture-=20;
168
-			$this->posxtva-=20;
169
-			$this->posxup-=20;
170
-			$this->posxqty-=20;
171
-			$this->posxunit-=20;
172
-			$this->posxdiscount-=20;
173
-			$this->postotalht-=20;
174
-		}
175
-		$this->tva=array();
176
-		$this->localtax1=array();
177
-		$this->localtax2=array();
178
-		$this->atleastoneratenotnull=0;
179
-		$this->atleastonediscount=0;
180
-	}
115
+     *	Constructor
116
+     *
117
+     *  @param		DoliDB		$db      Database handler
118
+     */
119
+    public function __construct($db)
120
+    {
121
+        global $conf,$langs,$mysoc;
122
+
123
+        // Load traductions files requiredby by page
124
+        $langs->loadLangs(array("main", "companies"));
125
+
126
+        $this->db = $db;
127
+        $this->name = "stdmouvement";
128
+        $this->description = $langs->trans("DocumentModelStandardPDF");
129
+
130
+        // Dimension page pour format A4
131
+        $this->type = 'pdf';
132
+        $formatarray=pdf_getFormat();
133
+        $this->page_largeur = $formatarray['width'];
134
+        $this->page_hauteur = $formatarray['height'];
135
+        $this->format = array($this->page_largeur,$this->page_hauteur);
136
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
140
+
141
+        $this->option_logo = 1;                    // Affiche logo
142
+        $this->option_codestockservice = 0;      // Affiche code stock-service
143
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
144
+        $this->option_freetext = 0;				   // Support add of a personalised text
145
+
146
+        // Recupere emetteur
147
+        $this->emetteur=$mysoc;
148
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
149
+
150
+        // Define position of columns
151
+        $this->wref = 15;
152
+        $this->posxidref = $this->marge_gauche;
153
+        $this->posxdatemouv = $this->marge_gauche+8;
154
+        $this->posxdesc=37;
155
+        $this->posxlabel=50;
156
+        $this->posxtva=80;
157
+        $this->posxqty=105;
158
+        $this->posxup=119;
159
+        $this->posxunit=136;
160
+        $this->posxdiscount=167;
161
+        $this->postotalht=180;
162
+
163
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
164
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
165
+        if ($this->page_largeur < 210) // To work with US executive format
166
+        {
167
+            $this->posxpicture-=20;
168
+            $this->posxtva-=20;
169
+            $this->posxup-=20;
170
+            $this->posxqty-=20;
171
+            $this->posxunit-=20;
172
+            $this->posxdiscount-=20;
173
+            $this->postotalht-=20;
174
+        }
175
+        $this->tva=array();
176
+        $this->localtax1=array();
177
+        $this->localtax2=array();
178
+        $this->atleastoneratenotnull=0;
179
+        $this->atleastonediscount=0;
180
+    }
181 181
 
182 182
 
183 183
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
184
-	/**
185
-	 *	Function to build a document on disk using the generic odt module.
186
-	 *
187
-	 *	@param		Stock		$object				Object source to build document
188
-	 *	@param		Translate	$outputlangs		Lang output object
189
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
190
-	 *  @param		int			$hidedetails		Do not show line details
191
-	 *  @param		int			$hidedesc			Do not show desc
192
-	 *  @param		int			$hideref			Do not show ref
193
-	 *	@return		int         					1 if OK, <=0 if KO
194
-	 */
195
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
196
-	{
184
+    /**
185
+     *	Function to build a document on disk using the generic odt module.
186
+     *
187
+     *	@param		Stock		$object				Object source to build document
188
+     *	@param		Translate	$outputlangs		Lang output object
189
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
190
+     *  @param		int			$hidedetails		Do not show line details
191
+     *  @param		int			$hidedesc			Do not show desc
192
+     *  @param		int			$hideref			Do not show ref
193
+     *	@return		int         					1 if OK, <=0 if KO
194
+     */
195
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
196
+    {
197 197
         // phpcs:enable
198
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
199
-
200
-		if (! is_object($outputlangs)) $outputlangs=$langs;
201
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
202
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
203
-
204
-		// Load traductions files requiredby by page
205
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
206
-
207
-	/**
208
-	 * TODO: get from object
209
-	 */
210
-
211
-		$id=GETPOST('id','int');
212
-		$ref = GETPOST('ref','alpha');
213
-		$msid=GETPOST('msid','int');
214
-		$product_id=GETPOST("product_id");
215
-		$action=GETPOST('action','aZ09');
216
-		$cancel=GETPOST('cancel','alpha');
217
-		$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist';
218
-
219
-		$idproduct = GETPOST('idproduct','int');
220
-		$year = GETPOST("year");
221
-		$month = GETPOST("month");
222
-		$search_ref = GETPOST('search_ref', 'alpha');
223
-		$search_movement = GETPOST("search_movement");
224
-		$search_product_ref = trim(GETPOST("search_product_ref"));
225
-		$search_product = trim(GETPOST("search_product"));
226
-		$search_warehouse = trim(GETPOST("search_warehouse"));
227
-		$search_inventorycode = trim(GETPOST("search_inventorycode"));
228
-		$search_user = trim(GETPOST("search_user"));
229
-		$search_batch = trim(GETPOST("search_batch"));
230
-		$search_qty = trim(GETPOST("search_qty"));
231
-		$search_type_mouvement=GETPOST('search_type_mouvement','int');
232
-
233
-		$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
234
-		$page = GETPOST("page",'int');
235
-		$sortfield = GETPOST("sortfield",'alpha');
236
-		$sortorder = GETPOST("sortorder",'alpha');
237
-		if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
238
-		$offset = $limit * $page;
239
-		if (! $sortfield) $sortfield="m.datem";
240
-		if (! $sortorder) $sortorder="DESC";
241
-
242
-		$pdluoid=GETPOST('pdluoid','int');
243
-
244
-		// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
245
-		$hookmanager->initHooks(array('movementlist'));
246
-		$extrafields = new ExtraFields($db);
247
-
248
-		// fetch optionals attributes and labels
249
-		$extralabels = $extrafields->fetch_name_optionals_label('movement');
250
-		$search_array_options=$extrafields->getOptionalsFromPost('movement','','search_');
251
-
252
-		$productlot=new ProductLot($db);
253
-		$productstatic=new Product($db);
254
-		$warehousestatic=new Entrepot($db);
255
-		$movement=new MouvementStock($db);
256
-		$userstatic=new User($db);
257
-
258
-		$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
259
-		$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
-		$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
-		$sql.= " m.batch, m.price,";
262
-		$sql.= " m.type_mouvement,";
263
-		$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
-		$sql.= " u.login, u.photo, u.lastname, u.firstname";
265
-		// Add fields from extrafields
266
-		foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
267
-		// Add fields from hooks
268
-		$parameters=array();
269
-		$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
270
-		$sql.=$hookmanager->resPrint;
271
-		$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
-		$sql.= " ".MAIN_DB_PREFIX."product as p,";
273
-		$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
-		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
-		$sql.= " WHERE m.fk_product = p.rowid";
278
-		if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
279
-		$sql.= " AND m.fk_entrepot = e.rowid";
280
-		$sql.= " AND e.entity IN (".getEntity('stock').")";
281
-		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
282
-		if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
283
-		if ($month > 0)
284
-		{
285
-			if ($year > 0)
286
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
287
-			else
288
-			$sql.= " AND date_format(m.datem, '%m') = '$month'";
289
-		}
290
-		else if ($year > 0)
291
-		{
292
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
293
-		}
294
-		if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
295
-		if (! empty($search_ref))			$sql.= natural_search('m.rowid', $search_ref, 1);
296
-		if (! empty($search_movement))      $sql.= natural_search('m.label', $search_movement);
297
-		if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
298
-		if (! empty($search_product_ref))   $sql.= natural_search('p.ref', $search_product_ref);
299
-		if (! empty($search_product))       $sql.= natural_search('p.label', $search_product);
300
-		if ($search_warehouse > 0)          $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
-		if (! empty($search_user))          $sql.= natural_search('u.login', $search_user);
302
-		if (! empty($search_batch))         $sql.= natural_search('m.batch', $search_batch);
303
-		if ($search_qty != '')				$sql.= natural_search('m.value', $search_qty, 1);
304
-		if ($search_type_mouvement > 0)		$sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
305
-		// Add where from extra fields
306
-		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307
-		// Add where from hooks
308
-		$parameters=array();
309
-		$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
310
-		$sql.=$hookmanager->resPrint;
311
-		$sql.= $db->order($sortfield,$sortorder);
312
-
313
-		$nbtotalofrecords = '';
314
-		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
315
-		{
316
-			$result = $db->query($sql);
317
-			$nbtotalofrecords = $db->num_rows($result);
318
-			if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
319
-			{
320
-				$page = 0;
321
-				$offset = 0;
322
-			}
323
-		}
324
-
325
-		if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset);
326
-
327
-
328
-		$resql = $db->query($sql);
329
-		$nbtotalofrecords = $db->num_rows($result);
330
-
331
-	/*
198
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager;
199
+
200
+        if (! is_object($outputlangs)) $outputlangs=$langs;
201
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
202
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
203
+
204
+        // Load traductions files requiredby by page
205
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
206
+
207
+    /**
208
+     * TODO: get from object
209
+     */
210
+
211
+        $id=GETPOST('id','int');
212
+        $ref = GETPOST('ref','alpha');
213
+        $msid=GETPOST('msid','int');
214
+        $product_id=GETPOST("product_id");
215
+        $action=GETPOST('action','aZ09');
216
+        $cancel=GETPOST('cancel','alpha');
217
+        $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist';
218
+
219
+        $idproduct = GETPOST('idproduct','int');
220
+        $year = GETPOST("year");
221
+        $month = GETPOST("month");
222
+        $search_ref = GETPOST('search_ref', 'alpha');
223
+        $search_movement = GETPOST("search_movement");
224
+        $search_product_ref = trim(GETPOST("search_product_ref"));
225
+        $search_product = trim(GETPOST("search_product"));
226
+        $search_warehouse = trim(GETPOST("search_warehouse"));
227
+        $search_inventorycode = trim(GETPOST("search_inventorycode"));
228
+        $search_user = trim(GETPOST("search_user"));
229
+        $search_batch = trim(GETPOST("search_batch"));
230
+        $search_qty = trim(GETPOST("search_qty"));
231
+        $search_type_mouvement=GETPOST('search_type_mouvement','int');
232
+
233
+        $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
234
+        $page = GETPOST("page",'int');
235
+        $sortfield = GETPOST("sortfield",'alpha');
236
+        $sortorder = GETPOST("sortorder",'alpha');
237
+        if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
238
+        $offset = $limit * $page;
239
+        if (! $sortfield) $sortfield="m.datem";
240
+        if (! $sortorder) $sortorder="DESC";
241
+
242
+        $pdluoid=GETPOST('pdluoid','int');
243
+
244
+        // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
245
+        $hookmanager->initHooks(array('movementlist'));
246
+        $extrafields = new ExtraFields($db);
247
+
248
+        // fetch optionals attributes and labels
249
+        $extralabels = $extrafields->fetch_name_optionals_label('movement');
250
+        $search_array_options=$extrafields->getOptionalsFromPost('movement','','search_');
251
+
252
+        $productlot=new ProductLot($db);
253
+        $productstatic=new Product($db);
254
+        $warehousestatic=new Entrepot($db);
255
+        $movement=new MouvementStock($db);
256
+        $userstatic=new User($db);
257
+
258
+        $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
259
+        $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
+        $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
+        $sql.= " m.batch, m.price,";
262
+        $sql.= " m.type_mouvement,";
263
+        $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
+        $sql.= " u.login, u.photo, u.lastname, u.firstname";
265
+        // Add fields from extrafields
266
+        foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
267
+        // Add fields from hooks
268
+        $parameters=array();
269
+        $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
270
+        $sql.=$hookmanager->resPrint;
271
+        $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
+        $sql.= " ".MAIN_DB_PREFIX."product as p,";
273
+        $sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
+        if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
+        $sql.= " WHERE m.fk_product = p.rowid";
278
+        if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
279
+        $sql.= " AND m.fk_entrepot = e.rowid";
280
+        $sql.= " AND e.entity IN (".getEntity('stock').")";
281
+        if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
282
+        if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
283
+        if ($month > 0)
284
+        {
285
+            if ($year > 0)
286
+            $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
287
+            else
288
+            $sql.= " AND date_format(m.datem, '%m') = '$month'";
289
+        }
290
+        else if ($year > 0)
291
+        {
292
+            $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
293
+        }
294
+        if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
295
+        if (! empty($search_ref))			$sql.= natural_search('m.rowid', $search_ref, 1);
296
+        if (! empty($search_movement))      $sql.= natural_search('m.label', $search_movement);
297
+        if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
298
+        if (! empty($search_product_ref))   $sql.= natural_search('p.ref', $search_product_ref);
299
+        if (! empty($search_product))       $sql.= natural_search('p.label', $search_product);
300
+        if ($search_warehouse > 0)          $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
+        if (! empty($search_user))          $sql.= natural_search('u.login', $search_user);
302
+        if (! empty($search_batch))         $sql.= natural_search('m.batch', $search_batch);
303
+        if ($search_qty != '')				$sql.= natural_search('m.value', $search_qty, 1);
304
+        if ($search_type_mouvement > 0)		$sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
305
+        // Add where from extra fields
306
+        include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307
+        // Add where from hooks
308
+        $parameters=array();
309
+        $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
310
+        $sql.=$hookmanager->resPrint;
311
+        $sql.= $db->order($sortfield,$sortorder);
312
+
313
+        $nbtotalofrecords = '';
314
+        if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
315
+        {
316
+            $result = $db->query($sql);
317
+            $nbtotalofrecords = $db->num_rows($result);
318
+            if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
319
+            {
320
+                $page = 0;
321
+                $offset = 0;
322
+            }
323
+        }
324
+
325
+        if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset);
326
+
327
+
328
+        $resql = $db->query($sql);
329
+        $nbtotalofrecords = $db->num_rows($result);
330
+
331
+    /*
332 332
 	 * END TODO
333 333
 	 **/
334 334
 
335
-		//$nblignes = count($object->lines);
336
-
337
-		if ($conf->stock->dir_output)
338
-		{
339
-
340
-			if ($resql)
341
-			{
342
-				$product = new Product($db);
343
-				$object = new Entrepot($db);
344
-
345
-				if ($idproduct > 0)
346
-				{
347
-					$product->fetch($idproduct);
348
-				}
349
-				if ($id > 0 || $ref)
350
-				{
351
-					$result = $object->fetch($id, $ref);
352
-					if ($result < 0)
353
-					{
354
-						dol_print_error($db);
355
-					}
356
-				}
357
-
358
-				$num = $db->num_rows($resql);
359
-
360
-				$arrayofselected=is_array($toselect)?$toselect:array();
361
-
362
-				$i = 0;
363
-				$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
364
-				if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
365
-				else
366
-				{
367
-					$texte = $langs->trans("ListOfStockMovements");
368
-					if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
369
-				}
370
-			}
371
-
372
-			// Definition of $dir and $file
373
-			if ($object->specimen)
374
-			{
375
-				$dir = $conf->stock->dir_output . "/movement";
376
-				$file = $dir . "/SPECIMEN.pdf";
377
-			}
378
-			else
379
-			{
380
-				$objectref = dol_sanitizeFileName($object->ref);
381
-				if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
382
-				if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
383
-				$dir = $conf->stock->dir_output . "/movement/" . $objectref;
384
-				$file = $dir . "/" . $objectref . ".pdf";
385
-			}
386
-
387
-			$stockFournisseur = new ProductFournisseur($this->db);
388
-			$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
389
-			$object->supplierprices = $supplierprices;
390
-
391
-			$productstatic=new Product($db);
392
-
393
-			if (! file_exists($dir))
394
-			{
395
-				if (dol_mkdir($dir) < 0)
396
-				{
397
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
398
-					return -1;
399
-				}
400
-			}
401
-
402
-			if (file_exists($dir))
403
-			{
404
-				// Add pdfgeneration hook
405
-				if (! is_object($hookmanager))
406
-				{
407
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
408
-					$hookmanager=new HookManager($this->db);
409
-				}
410
-				$hookmanager->initHooks(array('pdfgeneration'));
411
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
412
-				global $action;
413
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
414
-
415
-				// Create pdf instance
416
-				$pdf=pdf_getInstance($this->format);
417
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
418
-				$pdf->SetAutoPageBreak(1,0);
419
-
420
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
421
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
422
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
335
+        //$nblignes = count($object->lines);
336
+
337
+        if ($conf->stock->dir_output)
338
+        {
339
+
340
+            if ($resql)
341
+            {
342
+                $product = new Product($db);
343
+                $object = new Entrepot($db);
344
+
345
+                if ($idproduct > 0)
346
+                {
347
+                    $product->fetch($idproduct);
348
+                }
349
+                if ($id > 0 || $ref)
350
+                {
351
+                    $result = $object->fetch($id, $ref);
352
+                    if ($result < 0)
353
+                    {
354
+                        dol_print_error($db);
355
+                    }
356
+                }
357
+
358
+                $num = $db->num_rows($resql);
359
+
360
+                $arrayofselected=is_array($toselect)?$toselect:array();
361
+
362
+                $i = 0;
363
+                $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
364
+                if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
365
+                else
366
+                {
367
+                    $texte = $langs->trans("ListOfStockMovements");
368
+                    if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
369
+                }
370
+            }
371
+
372
+            // Definition of $dir and $file
373
+            if ($object->specimen)
374
+            {
375
+                $dir = $conf->stock->dir_output . "/movement";
376
+                $file = $dir . "/SPECIMEN.pdf";
377
+            }
378
+            else
379
+            {
380
+                $objectref = dol_sanitizeFileName($object->ref);
381
+                if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
382
+                if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
383
+                $dir = $conf->stock->dir_output . "/movement/" . $objectref;
384
+                $file = $dir . "/" . $objectref . ".pdf";
385
+            }
386
+
387
+            $stockFournisseur = new ProductFournisseur($this->db);
388
+            $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
389
+            $object->supplierprices = $supplierprices;
390
+
391
+            $productstatic=new Product($db);
392
+
393
+            if (! file_exists($dir))
394
+            {
395
+                if (dol_mkdir($dir) < 0)
396
+                {
397
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
398
+                    return -1;
399
+                }
400
+            }
401
+
402
+            if (file_exists($dir))
403
+            {
404
+                // Add pdfgeneration hook
405
+                if (! is_object($hookmanager))
406
+                {
407
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
408
+                    $hookmanager=new HookManager($this->db);
409
+                }
410
+                $hookmanager->initHooks(array('pdfgeneration'));
411
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
412
+                global $action;
413
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
414
+
415
+                // Create pdf instance
416
+                $pdf=pdf_getInstance($this->format);
417
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
418
+                $pdf->SetAutoPageBreak(1,0);
419
+
420
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
421
+                $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
422
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
423 423
 
424 424
                 if (class_exists('TCPDF'))
425 425
                 {
@@ -434,663 +434,663 @@  discard block
 block discarded – undo
434 434
                     $tplidx = $pdf->importPage(1);
435 435
                 }
436 436
 
437
-				$pdf->Open();
438
-				$pagenb=0;
439
-				$pdf->SetDrawColor(128,128,128);
440
-
441
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
442
-				$pdf->SetSubject($outputlangs->transnoentities("Stock"));
443
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
444
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
445
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
446
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
447
-
448
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
449
-
450
-
451
-				// New page
452
-				$pdf->AddPage();
453
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
454
-				$pagenb++;
455
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
456
-				$pdf->SetFont('','', $default_font_size - 1);
457
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
458
-				$pdf->SetTextColor(0,0,0);
459
-
460
-				$tab_top = 42;
461
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
462
-				$tab_height = 130;
463
-				$tab_height_newpage = 150;
464
-
465
-				/* ************************************************************************** */
466
-				/*                                                                            */
467
-				/* Affichage de la liste des produits du MouvementStock                           */
468
-				/*                                                                            */
469
-				/* ************************************************************************** */
470
-
471
-				$nexY+=5;
472
-				$nexY = $pdf->GetY();
473
-				$nexY+=10;
474
-
475
-				$totalunit=0;
476
-				$totalvalue=$totalvaluesell=0;
477
-				$arrayofuniqueproduct = array();
478
-
479
-				//dol_syslog('List products', LOG_DEBUG);
480
-				$resql = $db->query($sql);
481
-				if ($resql)
482
-				{
483
-					$num = $db->num_rows($resql);
484
-					$i = 0;
485
-					$nblignes = $num;
486
-					for ($i = 0 ; $i < $nblignes ; $i++)
487
-					{
488
-						$objp = $db->fetch_object($resql);
489
-
490
-						// Multilangs
491
-						if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
492
-						{
493
-							$sql = "SELECT label";
494
-							$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
495
-							$sql.= " WHERE fk_product=".$objp->rowid;
496
-							$sql.= " AND lang='". $langs->getDefaultLang() ."'";
497
-							$sql.= " LIMIT 1";
498
-
499
-							$result = $db->query($sql);
500
-							if ($result)
501
-							{
502
-								$objtp = $db->fetch_object($result);
503
-								if ($objtp->label != '') $objp->produit = $objtp->label;
504
-							}
505
-						}
506
-
507
-						$curY = $nexY;
508
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
509
-						$pdf->SetTextColor(0,0,0);
510
-
511
-						$pdf->setTopMargin($tab_top_newpage);
512
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
513
-						$pageposbefore=$pdf->getPage();
514
-
515
-						// Description of product line
516
-						$curX = $this->posxdesc-1;
517
-
518
-						$showpricebeforepagebreak=1;
519
-
520
-						$pdf->startTransaction();
521
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
522
-						$pageposafter=$pdf->getPage();
523
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
524
-						{
525
-							$pdf->rollbackTransaction(true);
526
-							$pageposafter=$pageposbefore;
527
-							//print $pageposafter.'-'.$pageposbefore;exit;
528
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
529
-							pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
530
-							$pageposafter=$pdf->getPage();
531
-							$posyafter=$pdf->GetY();
532
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
533
-							{
534
-								if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
535
-								{
536
-									$pdf->AddPage('','',true);
537
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
538
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
539
-									$pdf->setPage($pageposafter+1);
540
-								}
541
-							}
542
-							else
543
-							{
544
-								// We found a page break
545
-								$showpricebeforepagebreak=0;
546
-							}
547
-						}
548
-						else	// No pagebreak
549
-						{
550
-							$pdf->commitTransaction();
551
-						}
552
-						$posYAfterDescription=$pdf->GetY();
553
-
554
-						$nexY = $pdf->GetY();
555
-						$pageposafter=$pdf->getPage();
556
-
557
-						$pdf->setPage($pageposbefore);
558
-						$pdf->setTopMargin($this->marge_haute);
559
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
560
-
561
-						// We suppose that a too long description is moved completely on next page
562
-						if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563
-							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
564
-						}
565
-
566
-						$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
567
-
568
-						// $objp = $db->fetch_object($resql);
569
-
570
-						$userstatic->id=$objp->fk_user_author;
571
-						$userstatic->login=$objp->login;
572
-						$userstatic->lastname=$objp->lastname;
573
-						$userstatic->firstname=$objp->firstname;
574
-						$userstatic->photo=$objp->photo;
575
-
576
-						$productstatic->id=$objp->rowid;
577
-						$productstatic->ref=$objp->product_ref;
578
-						$productstatic->label=$objp->produit;
579
-						$productstatic->type=$objp->type;
580
-						$productstatic->entity=$objp->entity;
581
-						$productstatic->status_batch=$objp->tobatch;
582
-
583
-						$productlot->id = $objp->lotid;
584
-						$productlot->batch= $objp->batch;
585
-						$productlot->eatby= $objp->eatby;
586
-						$productlot->sellby= $objp->sellby;
587
-
588
-						$warehousestatic->id=$objp->entrepot_id;
589
-						$warehousestatic->libelle=$objp->stock;
590
-						$warehousestatic->lieu=$objp->lieu;
591
-
592
-						$arrayofuniqueproduct[$objp->rowid]=$objp->produit;
593
-						if(!empty($objp->fk_origin)) {
594
-							$origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
595
-						} else {
596
-							$origin = '';
597
-						}
598
-
599
-						// Id movement.
600
-						$pdf->SetXY($this->posxidref, $curY);
601
-						$pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L');
602
-
603
-						// Date.
604
-						$pdf->SetXY($this->posxdatemouv, $curY);
605
-						$pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L');
606
-
607
-						// Ref.
608
-						$pdf->SetXY($this->posxdesc, $curY);
609
-						$pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L');
610
-
611
-						// Label
612
-						$pdf->SetXY($this->posxlabel+0.8, $curY);
613
-						$pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L');
614
-
615
-						// Lot/serie
616
-						$pdf->SetXY($this->posxqty, $curY);
617
-						$pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R');
618
-
619
-						// Inv. code
620
-						$pdf->SetXY($this->posxup, $curY);
621
-						$pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R');
622
-
623
-						// Label mouvement
624
-						$pdf->SetXY($this->posxunit, $curY);
625
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R');
626
-						$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
627
-
628
-						// Origin
629
-						$pricemin=$objp->price;
630
-						$pdf->SetXY($this->posxdiscount, $curY);
631
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0);
632
-
633
-						// Qty
634
-						$valtoshow=price2num($objp->qty, 'MS');
635
-						$towrite = (empty($valtoshow)?'0':$valtoshow);
636
-						$totalunit+=$objp->qty;
637
-
638
-						$pdf->SetXY($this->postotalht, $curY);
639
-						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0);
640
-
641
-						$totalvaluesell+=price2num($pricemin*$objp->value,'MT');
642
-
643
-						$nexY+=3.5;    // Passe espace entre les lignes
644
-						// Add line
645
-						if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
646
-						{
647
-							$pdf->setPage($pageposafter);
648
-							$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
649
-							//$pdf->SetDrawColor(190,190,200);
650
-							$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
651
-							$pdf->SetLineStyle(array('dash'=>0));
652
-						}
653
-
654
-						$nexY+=2;    // Passe espace entre les lignes
655
-
656
-						// Detect if some page were added automatically and output _tableau for past pages
657
-						while ($pagenb < $pageposafter)
658
-						{
659
-							$pdf->setPage($pagenb);
660
-							if ($pagenb == 1)
661
-							{
662
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
663
-							}
664
-							else
665
-							{
666
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667
-							}
668
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
669
-							$pagenb++;
670
-							$pdf->setPage($pagenb);
671
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
672
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
673
-						}
674
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
675
-						{
676
-							if ($pagenb == 1)
677
-							{
678
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
679
-							}
680
-							else
681
-							{
682
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
683
-							}
684
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
685
-							// New page
686
-							$pdf->AddPage();
687
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
688
-							$pagenb++;
689
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
690
-						}
691
-					}
692
-
693
-					$db->free($resql);
694
-
695
-					/**
696
-					 * footer table
697
-					 */
698
-					$nexY = $pdf->GetY();
699
-					$nexY+=5;
700
-					$curY = $nexY;
701
-
702
-					$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
703
-					$pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
704
-					$pdf->SetLineStyle(array('dash'=>0));
705
-
706
-					$pdf->SetFont('','B',$default_font_size-1);
707
-					$pdf->SetTextColor(0,0,120);
708
-
709
-					// Total
710
-					$pdf->SetXY($this->posxidref, $curY);
711
-					$pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L');
712
-
713
-					// Total Qty
714
-					$pdf->SetXY($this->postotalht, $curY);
715
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
716
-				}
717
-				else
718
-				{
719
-					dol_print_error($db);
720
-				}
721
-
722
-				if ($notetoshow)
723
-				{
724
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
725
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
726
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
727
-
728
-					$tab_top = 88;
729
-
730
-					$pdf->SetFont('','', $default_font_size - 1);
731
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
732
-					$nexY = $pdf->GetY();
733
-					$height_note=$nexY-$tab_top;
734
-
735
-					// Rect prend une longueur en 3eme param
736
-					$pdf->SetDrawColor(192,192,192);
737
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
738
-
739
-					$tab_height = $tab_height - $height_note;
740
-					$tab_top = $nexY+6;
741
-				}
742
-				else
743
-				{
744
-					$height_note=0;
745
-				}
746
-
747
-				$iniY = $tab_top + 7;
748
-				$curY = $tab_top + 7;
749
-				$nexY = $tab_top + 7;
750
-
751
-				$tab_top = $tab_top_newpage+21;
752
-
753
-				// Show square
754
-				if ($pagenb == 1)
755
-				{
756
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
757
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758
-				}
759
-				else
760
-				{
761
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763
-				}
764
-
765
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
766
-
767
-				// Affiche zone infos
768
-				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
769
-
770
-				// Affiche zone totaux
771
-				//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
772
-
773
-				// Pied de page
774
-				$this->_pagefoot($pdf,$object,$outputlangs);
775
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
776
-
777
-				$pdf->Close();
778
-
779
-				$pdf->Output($file,'F');
780
-
781
-				// Add pdfgeneration hook
782
-				$hookmanager->initHooks(array('pdfgeneration'));
783
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
784
-				global $action;
785
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
786
-
787
-				if (! empty($conf->global->MAIN_UMASK))
788
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
789
-
790
-				$this->result = array('fullpath'=>$file);
791
-
792
-				return 1;   // Pas d'erreur
793
-			}
794
-			else
795
-			{
796
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
797
-				return 0;
798
-			}
799
-		}
800
-		else
801
-		{
802
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
803
-			return 0;
804
-		}
805
-	}
806
-
807
-
808
-	/**
809
-	 *   Show table for lines
810
-	 *
811
-	 *   @param		TCPDF		$pdf     		Object PDF
812
-	 *   @param		string		$tab_top		Top position of table
813
-	 *   @param		string		$tab_height		Height of table (rectangle)
814
-	 *   @param		int			$nexY			Y (not used)
815
-	 *   @param		Translate	$outputlangs	Langs object
816
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
817
-	 *   @param		int			$hidebottom		Hide bottom bar of array
818
-	 *   @param		string		$currency		Currency code
819
-	 *   @return	void
820
-	 */
821
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
822
-	{
823
-	    global $conf;
824
-
825
-	    // Force to disable hidetop and hidebottom
826
-	    $hidebottom=0;
827
-	    if ($hidetop) $hidetop=-1;
828
-
829
-	    $currency = !empty($currency) ? $currency : $conf->currency;
830
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
831
-
832
-	    // Amount in (at tab_top - 1)
833
-	    $pdf->SetTextColor(0,0,0);
834
-	    $pdf->SetFont('','', $default_font_size - 2);
835
-
836
-	    if (empty($hidetop))
837
-	    {
838
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
839
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
840
-	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
437
+                $pdf->Open();
438
+                $pagenb=0;
439
+                $pdf->SetDrawColor(128,128,128);
440
+
441
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
442
+                $pdf->SetSubject($outputlangs->transnoentities("Stock"));
443
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
444
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
445
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
446
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
447
+
448
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
449
+
450
+
451
+                // New page
452
+                $pdf->AddPage();
453
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
454
+                $pagenb++;
455
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
456
+                $pdf->SetFont('','', $default_font_size - 1);
457
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
458
+                $pdf->SetTextColor(0,0,0);
459
+
460
+                $tab_top = 42;
461
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
462
+                $tab_height = 130;
463
+                $tab_height_newpage = 150;
464
+
465
+                /* ************************************************************************** */
466
+                /*                                                                            */
467
+                /* Affichage de la liste des produits du MouvementStock                           */
468
+                /*                                                                            */
469
+                /* ************************************************************************** */
470
+
471
+                $nexY+=5;
472
+                $nexY = $pdf->GetY();
473
+                $nexY+=10;
474
+
475
+                $totalunit=0;
476
+                $totalvalue=$totalvaluesell=0;
477
+                $arrayofuniqueproduct = array();
478
+
479
+                //dol_syslog('List products', LOG_DEBUG);
480
+                $resql = $db->query($sql);
481
+                if ($resql)
482
+                {
483
+                    $num = $db->num_rows($resql);
484
+                    $i = 0;
485
+                    $nblignes = $num;
486
+                    for ($i = 0 ; $i < $nblignes ; $i++)
487
+                    {
488
+                        $objp = $db->fetch_object($resql);
489
+
490
+                        // Multilangs
491
+                        if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
492
+                        {
493
+                            $sql = "SELECT label";
494
+                            $sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
495
+                            $sql.= " WHERE fk_product=".$objp->rowid;
496
+                            $sql.= " AND lang='". $langs->getDefaultLang() ."'";
497
+                            $sql.= " LIMIT 1";
498
+
499
+                            $result = $db->query($sql);
500
+                            if ($result)
501
+                            {
502
+                                $objtp = $db->fetch_object($result);
503
+                                if ($objtp->label != '') $objp->produit = $objtp->label;
504
+                            }
505
+                        }
506
+
507
+                        $curY = $nexY;
508
+                        $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
509
+                        $pdf->SetTextColor(0,0,0);
510
+
511
+                        $pdf->setTopMargin($tab_top_newpage);
512
+                        $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
513
+                        $pageposbefore=$pdf->getPage();
514
+
515
+                        // Description of product line
516
+                        $curX = $this->posxdesc-1;
517
+
518
+                        $showpricebeforepagebreak=1;
519
+
520
+                        $pdf->startTransaction();
521
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
522
+                        $pageposafter=$pdf->getPage();
523
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
524
+                        {
525
+                            $pdf->rollbackTransaction(true);
526
+                            $pageposafter=$pageposbefore;
527
+                            //print $pageposafter.'-'.$pageposbefore;exit;
528
+                            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
529
+                            pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
530
+                            $pageposafter=$pdf->getPage();
531
+                            $posyafter=$pdf->GetY();
532
+                            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
533
+                            {
534
+                                if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
535
+                                {
536
+                                    $pdf->AddPage('','',true);
537
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
538
+                                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
539
+                                    $pdf->setPage($pageposafter+1);
540
+                                }
541
+                            }
542
+                            else
543
+                            {
544
+                                // We found a page break
545
+                                $showpricebeforepagebreak=0;
546
+                            }
547
+                        }
548
+                        else	// No pagebreak
549
+                        {
550
+                            $pdf->commitTransaction();
551
+                        }
552
+                        $posYAfterDescription=$pdf->GetY();
553
+
554
+                        $nexY = $pdf->GetY();
555
+                        $pageposafter=$pdf->getPage();
556
+
557
+                        $pdf->setPage($pageposbefore);
558
+                        $pdf->setTopMargin($this->marge_haute);
559
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
560
+
561
+                        // We suppose that a too long description is moved completely on next page
562
+                        if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563
+                            $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
564
+                        }
565
+
566
+                        $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
567
+
568
+                        // $objp = $db->fetch_object($resql);
569
+
570
+                        $userstatic->id=$objp->fk_user_author;
571
+                        $userstatic->login=$objp->login;
572
+                        $userstatic->lastname=$objp->lastname;
573
+                        $userstatic->firstname=$objp->firstname;
574
+                        $userstatic->photo=$objp->photo;
575
+
576
+                        $productstatic->id=$objp->rowid;
577
+                        $productstatic->ref=$objp->product_ref;
578
+                        $productstatic->label=$objp->produit;
579
+                        $productstatic->type=$objp->type;
580
+                        $productstatic->entity=$objp->entity;
581
+                        $productstatic->status_batch=$objp->tobatch;
582
+
583
+                        $productlot->id = $objp->lotid;
584
+                        $productlot->batch= $objp->batch;
585
+                        $productlot->eatby= $objp->eatby;
586
+                        $productlot->sellby= $objp->sellby;
587
+
588
+                        $warehousestatic->id=$objp->entrepot_id;
589
+                        $warehousestatic->libelle=$objp->stock;
590
+                        $warehousestatic->lieu=$objp->lieu;
591
+
592
+                        $arrayofuniqueproduct[$objp->rowid]=$objp->produit;
593
+                        if(!empty($objp->fk_origin)) {
594
+                            $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
595
+                        } else {
596
+                            $origin = '';
597
+                        }
598
+
599
+                        // Id movement.
600
+                        $pdf->SetXY($this->posxidref, $curY);
601
+                        $pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L');
602
+
603
+                        // Date.
604
+                        $pdf->SetXY($this->posxdatemouv, $curY);
605
+                        $pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L');
606
+
607
+                        // Ref.
608
+                        $pdf->SetXY($this->posxdesc, $curY);
609
+                        $pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L');
610
+
611
+                        // Label
612
+                        $pdf->SetXY($this->posxlabel+0.8, $curY);
613
+                        $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L');
614
+
615
+                        // Lot/serie
616
+                        $pdf->SetXY($this->posxqty, $curY);
617
+                        $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R');
618
+
619
+                        // Inv. code
620
+                        $pdf->SetXY($this->posxup, $curY);
621
+                        $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R');
622
+
623
+                        // Label mouvement
624
+                        $pdf->SetXY($this->posxunit, $curY);
625
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R');
626
+                        $totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
627
+
628
+                        // Origin
629
+                        $pricemin=$objp->price;
630
+                        $pdf->SetXY($this->posxdiscount, $curY);
631
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0);
632
+
633
+                        // Qty
634
+                        $valtoshow=price2num($objp->qty, 'MS');
635
+                        $towrite = (empty($valtoshow)?'0':$valtoshow);
636
+                        $totalunit+=$objp->qty;
637
+
638
+                        $pdf->SetXY($this->postotalht, $curY);
639
+                        $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0);
640
+
641
+                        $totalvaluesell+=price2num($pricemin*$objp->value,'MT');
642
+
643
+                        $nexY+=3.5;    // Passe espace entre les lignes
644
+                        // Add line
645
+                        if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
646
+                        {
647
+                            $pdf->setPage($pageposafter);
648
+                            $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
649
+                            //$pdf->SetDrawColor(190,190,200);
650
+                            $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
651
+                            $pdf->SetLineStyle(array('dash'=>0));
652
+                        }
653
+
654
+                        $nexY+=2;    // Passe espace entre les lignes
655
+
656
+                        // Detect if some page were added automatically and output _tableau for past pages
657
+                        while ($pagenb < $pageposafter)
658
+                        {
659
+                            $pdf->setPage($pagenb);
660
+                            if ($pagenb == 1)
661
+                            {
662
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
663
+                            }
664
+                            else
665
+                            {
666
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667
+                            }
668
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
669
+                            $pagenb++;
670
+                            $pdf->setPage($pagenb);
671
+                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
672
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
673
+                        }
674
+                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
675
+                        {
676
+                            if ($pagenb == 1)
677
+                            {
678
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
679
+                            }
680
+                            else
681
+                            {
682
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
683
+                            }
684
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
685
+                            // New page
686
+                            $pdf->AddPage();
687
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
688
+                            $pagenb++;
689
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
690
+                        }
691
+                    }
692
+
693
+                    $db->free($resql);
694
+
695
+                    /**
696
+                     * footer table
697
+                     */
698
+                    $nexY = $pdf->GetY();
699
+                    $nexY+=5;
700
+                    $curY = $nexY;
701
+
702
+                    $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
703
+                    $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
704
+                    $pdf->SetLineStyle(array('dash'=>0));
705
+
706
+                    $pdf->SetFont('','B',$default_font_size-1);
707
+                    $pdf->SetTextColor(0,0,120);
708
+
709
+                    // Total
710
+                    $pdf->SetXY($this->posxidref, $curY);
711
+                    $pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L');
712
+
713
+                    // Total Qty
714
+                    $pdf->SetXY($this->postotalht, $curY);
715
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
716
+                }
717
+                else
718
+                {
719
+                    dol_print_error($db);
720
+                }
841 721
 
842
-	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
843
-	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
844
-	    }
722
+                if ($notetoshow)
723
+                {
724
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
725
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
726
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
845 727
 
846
-	    $pdf->SetDrawColor(128,128,128);
847
-	    $pdf->SetFont('','B', $default_font_size - 3);
728
+                    $tab_top = 88;
848 729
 
849
-	    // Output Rect
850
-	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
730
+                    $pdf->SetFont('','', $default_font_size - 1);
731
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
732
+                    $nexY = $pdf->GetY();
733
+                    $height_note=$nexY-$tab_top;
851 734
 
852
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
853
-		$pdf->SetDrawColor(220,26,26);
854
-		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
855
-		$pdf->SetLineStyle(array('dash'=>0));
856
-		$pdf->SetDrawColor(128,128,128);
857
-		$pdf->SetTextColor(0,0,120);
735
+                    // Rect prend une longueur en 3eme param
736
+                    $pdf->SetDrawColor(192,192,192);
737
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
858 738
 
859
-		//Ref mouv
860
-	    if (empty($hidetop))
861
-	    {
862
-	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
863
-	        $pdf->SetXY($this->posxidref, $tab_top+1);
864
-	        $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L');
865
-	    }
866
-
867
-		//Date mouv
868
-		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
869
-		if (empty($hidetop))
870
-		{
871
-			$pdf->SetXY($this->posxdatemouv, $tab_top+1);
872
-			$pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C');
873
-		}
874
-
875
-		//Ref Product
876
-	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
877
-	    if (empty($hidetop))
878
-	    {
879
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
880
-	        $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C');
881
-	    }
739
+                    $tab_height = $tab_height - $height_note;
740
+                    $tab_top = $nexY+6;
741
+                }
742
+                else
743
+                {
744
+                    $height_note=0;
745
+                }
882 746
 
883
-		//Label Product
884
-	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
885
-	    if (empty($hidetop))
886
-	    {
887
-	        $pdf->SetXY($this->posxlabel-1, $tab_top+1);
888
-			$pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C');
889
-	    }
890
-
891
-		//Lot/serie Product
892
-		//$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
893
-		if (empty($hidetop))
894
-		{
895
-			$pdf->SetXY($this->posxqty, $tab_top + 1);
896
-			$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C');
897
-		}
898
-
899
-		//Code Inv
900
-	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
901
-	    if (empty($hidetop))
902
-	    {
903
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
904
-			$pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C');
905
-	    }
747
+                $iniY = $tab_top + 7;
748
+                $curY = $tab_top + 7;
749
+                $nexY = $tab_top + 7;
906 750
 
907
-		//Label mouvement
908
-	    //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
909
-	    if (empty($hidetop))
910
-	    {
911
-	        $pdf->SetXY($this->posxunit, $tab_top+1);
912
-	        $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C');
913
-	    }
751
+                $tab_top = $tab_top_newpage+21;
914 752
 
915
-		//Origin
916
-	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
917
-	    if (empty($hidetop))
918
-	    {
919
-	        $pdf->SetXY($this->posxdiscount+2, $tab_top+1);
920
-	        $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C');
921
-	    }
753
+                // Show square
754
+                if ($pagenb == 1)
755
+                {
756
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
757
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758
+                }
759
+                else
760
+                {
761
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763
+                }
922 764
 
923
-		//Qty
924
-	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
925
-	    if (empty($hidetop))
926
-	    {
927
-	        $pdf->SetXY($this->postotalht+2, $tab_top+1);
928
-	        $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C');
929
-	    }
930
-
931
-		$pdf->SetDrawColor(220,26,26);
932
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
933
-		$pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
934
-		$pdf->SetLineStyle(array('dash'=>0));
935
-	}
936
-
937
-	/**
938
-	 *  Show top header of page.
939
-	 *
940
-	 *  @param	TCPDF		$pdf     		Object PDF
941
-	 *  @param  Object		$object     	Object to show
942
-	 *  @param  int	    	$showaddress    0=no, 1=yes
943
-	 *  @param  Translate	$outputlangs	Object lang for output
944
-	 *  @param	string		$titlekey		Translation key to show as title of document
945
-	 *  @return	void
946
-	 */
947
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
948
-	{
949
-	    global $conf,$langs,$db,$hookmanager;
950
-
951
-	    // Load traductions files requiredby by page
952
-		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
953
-
954
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
955
-
956
-	    if ($object->type == 1) $titlekey='ServiceSheet';
957
-	    else $titlekey='StockSheet';
958
-
959
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
960
-
961
-	    // Show Draft Watermark
962
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
963
-	    {
964
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
965
-	    }
765
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
966 766
 
967
-	    $pdf->SetTextColor(0,0,60);
968
-	    $pdf->SetFont('','B', $default_font_size + 3);
767
+                // Affiche zone infos
768
+                //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
969 769
 
970
-	    $posy=$this->marge_haute;
971
-	    $posx=$this->page_largeur-$this->marge_droite-100;
770
+                // Affiche zone totaux
771
+                //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
972 772
 
973
-	    $pdf->SetXY($this->marge_gauche,$posy);
773
+                // Pied de page
774
+                $this->_pagefoot($pdf,$object,$outputlangs);
775
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
974 776
 
975
-	    // Logo
976
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
977
-	    if ($this->emetteur->logo)
978
-	    {
979
-	        if (is_readable($logo))
980
-	        {
981
-	            $height=pdf_getHeightForLogo($logo);
982
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
983
-	        }
984
-	        else
985
-	        {
986
-	            $pdf->SetTextColor(200,0,0);
987
-	            $pdf->SetFont('','B', $default_font_size -2);
988
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
989
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
990
-	        }
991
-	    }
992
-	    else
993
-	    {
994
-	        $text=$this->emetteur->name;
995
-	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
996
-	    }
777
+                $pdf->Close();
997 778
 
998
-	    $pdf->SetFont('','B', $default_font_size + 3);
999
-	    $pdf->SetXY($posx,$posy);
1000
-	    $pdf->SetTextColor(0,0,60);
1001
-	    $title=$outputlangs->transnoentities("Warehouse");
1002
-	    $pdf->MultiCell(100, 3, $title, '', 'R');
779
+                $pdf->Output($file,'F');
1003 780
 
1004
-	    $pdf->SetFont('','B',$default_font_size);
781
+                // Add pdfgeneration hook
782
+                $hookmanager->initHooks(array('pdfgeneration'));
783
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
784
+                global $action;
785
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1005 786
 
1006
-	    $posy+=5;
1007
-	    $pdf->SetXY($posx,$posy);
1008
-	    $pdf->SetTextColor(0,0,60);
787
+                if (! empty($conf->global->MAIN_UMASK))
788
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
1009 789
 
1010
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
790
+                $this->result = array('fullpath'=>$file);
1011 791
 
1012
-	    $posy+=5;
1013
-	    $pdf->SetFont('','', $default_font_size - 1);
1014
-		$pdf->SetXY($posx,$posy);
1015
-	    $pdf->SetTextColor(0,0,60);
1016
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1017
-
1018
-		$posy+=4;
1019
-		$pdf->SetXY($posx-50,$posy);
1020
-		$pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1021
-
1022
-
1023
-		// Parent MouvementStock
1024
-		$posy+=4;
1025
-		$pdf->SetXY($posx,$posy);
1026
-		$pdf->SetTextColor(0,0,60);
1027
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1028
-
1029
-		$posy+=4;
1030
-		$pdf->SetXY($posx-50,$posy);
1031
-		$e = new MouvementStock($db);
1032
-		if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1033
-		{
1034
-			$pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1035
-		}
1036
-		else
1037
-		{
1038
-			$pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R');
1039
-		}
1040
-
1041
-		// Description
1042
-		$nexY = $pdf->GetY();
1043
-		$nexY+=5;
1044
-		$pdf->SetXY($posx,$posy);
1045
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1046
-		$nexY = $pdf->GetY();
1047
-
1048
-		$calcproductsunique=$object->nb_different_products();
1049
-		$calcproducts=$object->nb_products();
1050
-
1051
-		// Total nb of different products
1052
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1053
-		$nexY = $pdf->GetY();
1054
-
1055
-		// Nb of products
1056
-		$valtoshow=price2num($calcproducts['nb'], 'MS');
1057
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1058
-		$nexY = $pdf->GetY();
1059
-
1060
-		// Value
1061
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1062
-		$nexY = $pdf->GetY();
1063
-
1064
-
1065
-		// Last movement
1066
-		$sql = "SELECT max(m.datem) as datem";
1067
-		$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
1068
-		$sql .= " WHERE m.fk_entrepot = '".$object->id."'";
1069
-		$resqlbis = $db->query($sql);
1070
-		if ($resqlbis)
1071
-		{
1072
-			$obj = $db->fetch_object($resqlbis);
1073
-			$lastmovementdate=$db->jdate($obj->datem);
1074
-		}
1075
-		else
1076
-		{
1077
-			dol_print_error($db);
1078
-		}
1079
-
1080
-		if ($lastmovementdate)
1081
-		{
1082
-			$toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1083
-		}
1084
-		else
1085
-		{
1086
-			$toWrite = $outputlangs->transnoentities("None");
1087
-		}
1088
-
1089
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
1090
-		$nexY = $pdf->GetY();
1091
-
1092
-
1093
-	    /*if ($object->ref_client)
792
+                return 1;   // Pas d'erreur
793
+            }
794
+            else
795
+            {
796
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
797
+                return 0;
798
+            }
799
+        }
800
+        else
801
+        {
802
+            $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
803
+            return 0;
804
+        }
805
+    }
806
+
807
+
808
+    /**
809
+     *   Show table for lines
810
+     *
811
+     *   @param		TCPDF		$pdf     		Object PDF
812
+     *   @param		string		$tab_top		Top position of table
813
+     *   @param		string		$tab_height		Height of table (rectangle)
814
+     *   @param		int			$nexY			Y (not used)
815
+     *   @param		Translate	$outputlangs	Langs object
816
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
817
+     *   @param		int			$hidebottom		Hide bottom bar of array
818
+     *   @param		string		$currency		Currency code
819
+     *   @return	void
820
+     */
821
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
822
+    {
823
+        global $conf;
824
+
825
+        // Force to disable hidetop and hidebottom
826
+        $hidebottom=0;
827
+        if ($hidetop) $hidetop=-1;
828
+
829
+        $currency = !empty($currency) ? $currency : $conf->currency;
830
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
831
+
832
+        // Amount in (at tab_top - 1)
833
+        $pdf->SetTextColor(0,0,0);
834
+        $pdf->SetFont('','', $default_font_size - 2);
835
+
836
+        if (empty($hidetop))
837
+        {
838
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
839
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
840
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
841
+
842
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
843
+            if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
844
+        }
845
+
846
+        $pdf->SetDrawColor(128,128,128);
847
+        $pdf->SetFont('','B', $default_font_size - 3);
848
+
849
+        // Output Rect
850
+        //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
851
+
852
+        $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
853
+        $pdf->SetDrawColor(220,26,26);
854
+        $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
855
+        $pdf->SetLineStyle(array('dash'=>0));
856
+        $pdf->SetDrawColor(128,128,128);
857
+        $pdf->SetTextColor(0,0,120);
858
+
859
+        //Ref mouv
860
+        if (empty($hidetop))
861
+        {
862
+            //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
863
+            $pdf->SetXY($this->posxidref, $tab_top+1);
864
+            $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L');
865
+        }
866
+
867
+        //Date mouv
868
+        //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
869
+        if (empty($hidetop))
870
+        {
871
+            $pdf->SetXY($this->posxdatemouv, $tab_top+1);
872
+            $pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C');
873
+        }
874
+
875
+        //Ref Product
876
+        //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
877
+        if (empty($hidetop))
878
+        {
879
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
880
+            $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C');
881
+        }
882
+
883
+        //Label Product
884
+        //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
885
+        if (empty($hidetop))
886
+        {
887
+            $pdf->SetXY($this->posxlabel-1, $tab_top+1);
888
+            $pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C');
889
+        }
890
+
891
+        //Lot/serie Product
892
+        //$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
893
+        if (empty($hidetop))
894
+        {
895
+            $pdf->SetXY($this->posxqty, $tab_top + 1);
896
+            $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C');
897
+        }
898
+
899
+        //Code Inv
900
+        //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
901
+        if (empty($hidetop))
902
+        {
903
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
904
+            $pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C');
905
+        }
906
+
907
+        //Label mouvement
908
+        //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
909
+        if (empty($hidetop))
910
+        {
911
+            $pdf->SetXY($this->posxunit, $tab_top+1);
912
+            $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C');
913
+        }
914
+
915
+        //Origin
916
+        //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
917
+        if (empty($hidetop))
918
+        {
919
+            $pdf->SetXY($this->posxdiscount+2, $tab_top+1);
920
+            $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C');
921
+        }
922
+
923
+        //Qty
924
+        //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
925
+        if (empty($hidetop))
926
+        {
927
+            $pdf->SetXY($this->postotalht+2, $tab_top+1);
928
+            $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C');
929
+        }
930
+
931
+        $pdf->SetDrawColor(220,26,26);
932
+        $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
933
+        $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
934
+        $pdf->SetLineStyle(array('dash'=>0));
935
+    }
936
+
937
+    /**
938
+     *  Show top header of page.
939
+     *
940
+     *  @param	TCPDF		$pdf     		Object PDF
941
+     *  @param  Object		$object     	Object to show
942
+     *  @param  int	    	$showaddress    0=no, 1=yes
943
+     *  @param  Translate	$outputlangs	Object lang for output
944
+     *  @param	string		$titlekey		Translation key to show as title of document
945
+     *  @return	void
946
+     */
947
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
948
+    {
949
+        global $conf,$langs,$db,$hookmanager;
950
+
951
+        // Load traductions files requiredby by page
952
+        $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
953
+
954
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
955
+
956
+        if ($object->type == 1) $titlekey='ServiceSheet';
957
+        else $titlekey='StockSheet';
958
+
959
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
960
+
961
+        // Show Draft Watermark
962
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
963
+        {
964
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
965
+        }
966
+
967
+        $pdf->SetTextColor(0,0,60);
968
+        $pdf->SetFont('','B', $default_font_size + 3);
969
+
970
+        $posy=$this->marge_haute;
971
+        $posx=$this->page_largeur-$this->marge_droite-100;
972
+
973
+        $pdf->SetXY($this->marge_gauche,$posy);
974
+
975
+        // Logo
976
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
977
+        if ($this->emetteur->logo)
978
+        {
979
+            if (is_readable($logo))
980
+            {
981
+                $height=pdf_getHeightForLogo($logo);
982
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
983
+            }
984
+            else
985
+            {
986
+                $pdf->SetTextColor(200,0,0);
987
+                $pdf->SetFont('','B', $default_font_size -2);
988
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
989
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
990
+            }
991
+        }
992
+        else
993
+        {
994
+            $text=$this->emetteur->name;
995
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
996
+        }
997
+
998
+        $pdf->SetFont('','B', $default_font_size + 3);
999
+        $pdf->SetXY($posx,$posy);
1000
+        $pdf->SetTextColor(0,0,60);
1001
+        $title=$outputlangs->transnoentities("Warehouse");
1002
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1003
+
1004
+        $pdf->SetFont('','B',$default_font_size);
1005
+
1006
+        $posy+=5;
1007
+        $pdf->SetXY($posx,$posy);
1008
+        $pdf->SetTextColor(0,0,60);
1009
+
1010
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
1011
+
1012
+        $posy+=5;
1013
+        $pdf->SetFont('','', $default_font_size - 1);
1014
+        $pdf->SetXY($posx,$posy);
1015
+        $pdf->SetTextColor(0,0,60);
1016
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1017
+
1018
+        $posy+=4;
1019
+        $pdf->SetXY($posx-50,$posy);
1020
+        $pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1021
+
1022
+
1023
+        // Parent MouvementStock
1024
+        $posy+=4;
1025
+        $pdf->SetXY($posx,$posy);
1026
+        $pdf->SetTextColor(0,0,60);
1027
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1028
+
1029
+        $posy+=4;
1030
+        $pdf->SetXY($posx-50,$posy);
1031
+        $e = new MouvementStock($db);
1032
+        if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1033
+        {
1034
+            $pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1035
+        }
1036
+        else
1037
+        {
1038
+            $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R');
1039
+        }
1040
+
1041
+        // Description
1042
+        $nexY = $pdf->GetY();
1043
+        $nexY+=5;
1044
+        $pdf->SetXY($posx,$posy);
1045
+        $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1046
+        $nexY = $pdf->GetY();
1047
+
1048
+        $calcproductsunique=$object->nb_different_products();
1049
+        $calcproducts=$object->nb_products();
1050
+
1051
+        // Total nb of different products
1052
+        $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1053
+        $nexY = $pdf->GetY();
1054
+
1055
+        // Nb of products
1056
+        $valtoshow=price2num($calcproducts['nb'], 'MS');
1057
+        $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1058
+        $nexY = $pdf->GetY();
1059
+
1060
+        // Value
1061
+        $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1062
+        $nexY = $pdf->GetY();
1063
+
1064
+
1065
+        // Last movement
1066
+        $sql = "SELECT max(m.datem) as datem";
1067
+        $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
1068
+        $sql .= " WHERE m.fk_entrepot = '".$object->id."'";
1069
+        $resqlbis = $db->query($sql);
1070
+        if ($resqlbis)
1071
+        {
1072
+            $obj = $db->fetch_object($resqlbis);
1073
+            $lastmovementdate=$db->jdate($obj->datem);
1074
+        }
1075
+        else
1076
+        {
1077
+            dol_print_error($db);
1078
+        }
1079
+
1080
+        if ($lastmovementdate)
1081
+        {
1082
+            $toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1083
+        }
1084
+        else
1085
+        {
1086
+            $toWrite = $outputlangs->transnoentities("None");
1087
+        }
1088
+
1089
+        $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
1090
+        $nexY = $pdf->GetY();
1091
+
1092
+
1093
+        /*if ($object->ref_client)
1094 1094
 	    {
1095 1095
 	        $posy+=5;
1096 1096
 	        $pdf->SetXY($posx,$posy);
@@ -1098,14 +1098,14 @@  discard block
 block discarded – undo
1098 1098
 	        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1099 1099
 	    }*/
1100 1100
 
1101
-	    /*$posy+=4;
1101
+        /*$posy+=4;
1102 1102
 	    $pdf->SetXY($posx,$posy);
1103 1103
 	    $pdf->SetTextColor(0,0,60);
1104 1104
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1105 1105
 	    */
1106 1106
 
1107
-	    // Get contact
1108
-	    /*
1107
+        // Get contact
1108
+        /*
1109 1109
 	    if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1110 1110
 	    {
1111 1111
 	        $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
@@ -1120,14 +1120,14 @@  discard block
 block discarded – undo
1120 1120
 	        }
1121 1121
 	    }*/
1122 1122
 
1123
-	    $posy+=2;
1123
+        $posy+=2;
1124 1124
 
1125
-	    // Show list of linked objects
1126
-	    //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1125
+        // Show list of linked objects
1126
+        //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1127 1127
 
1128
-	    if ($showaddress)
1129
-	    {
1130
-	        /*
1128
+        if ($showaddress)
1129
+        {
1130
+            /*
1131 1131
 	        // Sender properties
1132 1132
 	        $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1133 1133
 
@@ -1158,24 +1158,24 @@  discard block
 block discarded – undo
1158 1158
 	        $pdf->SetFont('','', $default_font_size - 1);
1159 1159
 	        $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1160 1160
 	        */
1161
-	    }
1162
-
1163
-	    $pdf->SetTextColor(0,0,0);
1164
-	}
1165
-
1166
-	/**
1167
-	 *   	Show footer of page. Need this->emetteur object
1168
-	 *
1169
-	 *   	@param	TCPDF		$pdf     			PDF
1170
-	 * 		@param	Object		$object				Object to show
1171
-	 *      @param	Translate	$outputlangs		Object lang for output
1172
-	 *      @param	int			$hidefreetext		1=Hide free text
1173
-	 *      @return	int								Return height of bottom margin including footer text
1174
-	 */
1175
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1176
-	{
1177
-	    global $conf;
1178
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1180
-	}
1161
+        }
1162
+
1163
+        $pdf->SetTextColor(0,0,0);
1164
+    }
1165
+
1166
+    /**
1167
+     *   	Show footer of page. Need this->emetteur object
1168
+     *
1169
+     *   	@param	TCPDF		$pdf     			PDF
1170
+     * 		@param	Object		$object				Object to show
1171
+     *      @param	Translate	$outputlangs		Object lang for output
1172
+     *      @param	int			$hidefreetext		1=Hide free text
1173
+     *      @return	int								Return height of bottom margin including footer text
1174
+     */
1175
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1176
+    {
1177
+        global $conf;
1178
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
+        return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1180
+    }
1181 1181
 }
Please login to merge, or discard this patch.
Spacing   +331 added lines, -331 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function __construct($db)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		// Load traductions files requiredby by page
124 124
 		$langs->loadLangs(array("main", "companies"));
@@ -129,54 +129,54 @@  discard block
 block discarded – undo
129 129
 
130 130
 		// Dimension page pour format A4
131 131
 		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
132
+		$formatarray = pdf_getFormat();
133 133
 		$this->page_largeur = $formatarray['width'];
134 134
 		$this->page_hauteur = $formatarray['height'];
135
-		$this->format = array($this->page_largeur,$this->page_hauteur);
136
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
135
+		$this->format = array($this->page_largeur, $this->page_hauteur);
136
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
137
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
138
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
139
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
140 140
 
141
-		$this->option_logo = 1;                    // Affiche logo
142
-		$this->option_codestockservice = 0;      // Affiche code stock-service
143
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
144
-		$this->option_freetext = 0;				   // Support add of a personalised text
141
+		$this->option_logo = 1; // Affiche logo
142
+		$this->option_codestockservice = 0; // Affiche code stock-service
143
+		$this->option_multilang = 1; // Dispo en plusieurs langues
144
+		$this->option_freetext = 0; // Support add of a personalised text
145 145
 
146 146
 		// Recupere emetteur
147
-		$this->emetteur=$mysoc;
148
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
147
+		$this->emetteur = $mysoc;
148
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
149 149
 
150 150
 		// Define position of columns
151 151
 		$this->wref = 15;
152 152
 		$this->posxidref = $this->marge_gauche;
153
-		$this->posxdatemouv = $this->marge_gauche+8;
154
-		$this->posxdesc=37;
155
-		$this->posxlabel=50;
156
-		$this->posxtva=80;
157
-		$this->posxqty=105;
158
-		$this->posxup=119;
159
-		$this->posxunit=136;
160
-		$this->posxdiscount=167;
161
-		$this->postotalht=180;
162
-
163
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
164
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
153
+		$this->posxdatemouv = $this->marge_gauche + 8;
154
+		$this->posxdesc = 37;
155
+		$this->posxlabel = 50;
156
+		$this->posxtva = 80;
157
+		$this->posxqty = 105;
158
+		$this->posxup = 119;
159
+		$this->posxunit = 136;
160
+		$this->posxdiscount = 167;
161
+		$this->postotalht = 180;
162
+
163
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
164
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
165 165
 		if ($this->page_largeur < 210) // To work with US executive format
166 166
 		{
167
-			$this->posxpicture-=20;
168
-			$this->posxtva-=20;
169
-			$this->posxup-=20;
170
-			$this->posxqty-=20;
171
-			$this->posxunit-=20;
172
-			$this->posxdiscount-=20;
173
-			$this->postotalht-=20;
167
+			$this->posxpicture -= 20;
168
+			$this->posxtva -= 20;
169
+			$this->posxup -= 20;
170
+			$this->posxqty -= 20;
171
+			$this->posxunit -= 20;
172
+			$this->posxdiscount -= 20;
173
+			$this->postotalht -= 20;
174 174
 		}
175
-		$this->tva=array();
176
-		$this->localtax1=array();
177
-		$this->localtax2=array();
178
-		$this->atleastoneratenotnull=0;
179
-		$this->atleastonediscount=0;
175
+		$this->tva = array();
176
+		$this->localtax1 = array();
177
+		$this->localtax2 = array();
178
+		$this->atleastoneratenotnull = 0;
179
+		$this->atleastonediscount = 0;
180 180
 	}
181 181
 
182 182
 
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 	 *  @param		int			$hideref			Do not show ref
193 193
 	 *	@return		int         					1 if OK, <=0 if KO
194 194
 	 */
195
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
195
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
196 196
 	{
197 197
         // phpcs:enable
198
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
198
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
199 199
 
200
-		if (! is_object($outputlangs)) $outputlangs=$langs;
200
+		if (!is_object($outputlangs)) $outputlangs = $langs;
201 201
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
202
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
202
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
203 203
 
204 204
 		// Load traductions files requiredby by page
205 205
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 	 * TODO: get from object
209 209
 	 */
210 210
 
211
-		$id=GETPOST('id','int');
212
-		$ref = GETPOST('ref','alpha');
213
-		$msid=GETPOST('msid','int');
214
-		$product_id=GETPOST("product_id");
215
-		$action=GETPOST('action','aZ09');
216
-		$cancel=GETPOST('cancel','alpha');
217
-		$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist';
211
+		$id = GETPOST('id', 'int');
212
+		$ref = GETPOST('ref', 'alpha');
213
+		$msid = GETPOST('msid', 'int');
214
+		$product_id = GETPOST("product_id");
215
+		$action = GETPOST('action', 'aZ09');
216
+		$cancel = GETPOST('cancel', 'alpha');
217
+		$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist';
218 218
 
219
-		$idproduct = GETPOST('idproduct','int');
219
+		$idproduct = GETPOST('idproduct', 'int');
220 220
 		$year = GETPOST("year");
221 221
 		$month = GETPOST("month");
222 222
 		$search_ref = GETPOST('search_ref', 'alpha');
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 		$search_user = trim(GETPOST("search_user"));
229 229
 		$search_batch = trim(GETPOST("search_batch"));
230 230
 		$search_qty = trim(GETPOST("search_qty"));
231
-		$search_type_mouvement=GETPOST('search_type_mouvement','int');
231
+		$search_type_mouvement = GETPOST('search_type_mouvement', 'int');
232 232
 
233
-		$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
234
-		$page = GETPOST("page",'int');
235
-		$sortfield = GETPOST("sortfield",'alpha');
236
-		$sortorder = GETPOST("sortorder",'alpha');
233
+		$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
234
+		$page = GETPOST("page", 'int');
235
+		$sortfield = GETPOST("sortfield", 'alpha');
236
+		$sortorder = GETPOST("sortorder", 'alpha');
237 237
 		if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
238 238
 		$offset = $limit * $page;
239
-		if (! $sortfield) $sortfield="m.datem";
240
-		if (! $sortorder) $sortorder="DESC";
239
+		if (!$sortfield) $sortfield = "m.datem";
240
+		if (!$sortorder) $sortorder = "DESC";
241 241
 
242
-		$pdluoid=GETPOST('pdluoid','int');
242
+		$pdluoid = GETPOST('pdluoid', 'int');
243 243
 
244 244
 		// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
245 245
 		$hookmanager->initHooks(array('movementlist'));
@@ -247,68 +247,68 @@  discard block
 block discarded – undo
247 247
 
248 248
 		// fetch optionals attributes and labels
249 249
 		$extralabels = $extrafields->fetch_name_optionals_label('movement');
250
-		$search_array_options=$extrafields->getOptionalsFromPost('movement','','search_');
250
+		$search_array_options = $extrafields->getOptionalsFromPost('movement', '', 'search_');
251 251
 
252
-		$productlot=new ProductLot($db);
253
-		$productstatic=new Product($db);
254
-		$warehousestatic=new Entrepot($db);
255
-		$movement=new MouvementStock($db);
256
-		$userstatic=new User($db);
252
+		$productlot = new ProductLot($db);
253
+		$productstatic = new Product($db);
254
+		$warehousestatic = new Entrepot($db);
255
+		$movement = new MouvementStock($db);
256
+		$userstatic = new User($db);
257 257
 
258 258
 		$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
259
-		$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
-		$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
-		$sql.= " m.batch, m.price,";
262
-		$sql.= " m.type_mouvement,";
263
-		$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
-		$sql.= " u.login, u.photo, u.lastname, u.firstname";
259
+		$sql .= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
260
+		$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261
+		$sql .= " m.batch, m.price,";
262
+		$sql .= " m.type_mouvement,";
263
+		$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264
+		$sql .= " u.login, u.photo, u.lastname, u.firstname";
265 265
 		// Add fields from extrafields
266
-		foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
266
+		foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
267 267
 		// Add fields from hooks
268
-		$parameters=array();
269
-		$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
270
-		$sql.=$hookmanager->resPrint;
271
-		$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
-		$sql.= " ".MAIN_DB_PREFIX."product as p,";
273
-		$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
-		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
-		$sql.= " WHERE m.fk_product = p.rowid";
268
+		$parameters = array();
269
+		$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
270
+		$sql .= $hookmanager->resPrint;
271
+		$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272
+		$sql .= " ".MAIN_DB_PREFIX."product as p,";
273
+		$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
+		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
275
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277
+		$sql .= " WHERE m.fk_product = p.rowid";
278 278
 		if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
279
-		$sql.= " AND m.fk_entrepot = e.rowid";
280
-		$sql.= " AND e.entity IN (".getEntity('stock').")";
281
-		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
282
-		if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
279
+		$sql .= " AND m.fk_entrepot = e.rowid";
280
+		$sql .= " AND e.entity IN (".getEntity('stock').")";
281
+		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
282
+		if ($id > 0) $sql .= " AND e.rowid ='".$id."'";
283 283
 		if ($month > 0)
284 284
 		{
285 285
 			if ($year > 0)
286
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
286
+			$sql .= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'";
287 287
 			else
288
-			$sql.= " AND date_format(m.datem, '%m') = '$month'";
288
+			$sql .= " AND date_format(m.datem, '%m') = '$month'";
289 289
 		}
290 290
 		else if ($year > 0)
291 291
 		{
292
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
292
+			$sql .= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
293 293
 		}
294
-		if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
295
-		if (! empty($search_ref))			$sql.= natural_search('m.rowid', $search_ref, 1);
296
-		if (! empty($search_movement))      $sql.= natural_search('m.label', $search_movement);
297
-		if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
298
-		if (! empty($search_product_ref))   $sql.= natural_search('p.ref', $search_product_ref);
299
-		if (! empty($search_product))       $sql.= natural_search('p.label', $search_product);
300
-		if ($search_warehouse > 0)          $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
-		if (! empty($search_user))          $sql.= natural_search('u.login', $search_user);
302
-		if (! empty($search_batch))         $sql.= natural_search('m.batch', $search_batch);
303
-		if ($search_qty != '')				$sql.= natural_search('m.value', $search_qty, 1);
304
-		if ($search_type_mouvement > 0)		$sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
294
+		if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'";
295
+		if (!empty($search_ref))			$sql .= natural_search('m.rowid', $search_ref, 1);
296
+		if (!empty($search_movement))      $sql .= natural_search('m.label', $search_movement);
297
+		if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
298
+		if (!empty($search_product_ref))   $sql .= natural_search('p.ref', $search_product_ref);
299
+		if (!empty($search_product))       $sql .= natural_search('p.label', $search_product);
300
+		if ($search_warehouse > 0)          $sql .= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
+		if (!empty($search_user))          $sql .= natural_search('u.login', $search_user);
302
+		if (!empty($search_batch))         $sql .= natural_search('m.batch', $search_batch);
303
+		if ($search_qty != '')				$sql .= natural_search('m.value', $search_qty, 1);
304
+		if ($search_type_mouvement > 0)		$sql .= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
305 305
 		// Add where from extra fields
306 306
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307 307
 		// Add where from hooks
308
-		$parameters=array();
309
-		$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
310
-		$sql.=$hookmanager->resPrint;
311
-		$sql.= $db->order($sortfield,$sortorder);
308
+		$parameters = array();
309
+		$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
310
+		$sql .= $hookmanager->resPrint;
311
+		$sql .= $db->order($sortfield, $sortorder);
312 312
 
313 313
 		$nbtotalofrecords = '';
314 314
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			}
323 323
 		}
324 324
 
325
-		if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset);
325
+		if (empty($search_inventorycode)) $sql .= $db->plimit($limit + 1, $offset);
326 326
 
327 327
 
328 328
 		$resql = $db->query($sql);
@@ -357,44 +357,44 @@  discard block
 block discarded – undo
357 357
 
358 358
 				$num = $db->num_rows($resql);
359 359
 
360
-				$arrayofselected=is_array($toselect)?$toselect:array();
360
+				$arrayofselected = is_array($toselect) ? $toselect : array();
361 361
 
362 362
 				$i = 0;
363
-				$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
363
+				$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
364 364
 				if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
365 365
 				else
366 366
 				{
367 367
 					$texte = $langs->trans("ListOfStockMovements");
368
-					if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
368
+					if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')';
369 369
 				}
370 370
 			}
371 371
 
372 372
 			// Definition of $dir and $file
373 373
 			if ($object->specimen)
374 374
 			{
375
-				$dir = $conf->stock->dir_output . "/movement";
376
-				$file = $dir . "/SPECIMEN.pdf";
375
+				$dir = $conf->stock->dir_output."/movement";
376
+				$file = $dir."/SPECIMEN.pdf";
377 377
 			}
378 378
 			else
379 379
 			{
380 380
 				$objectref = dol_sanitizeFileName($object->ref);
381
-				if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
382
-				if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
383
-				$dir = $conf->stock->dir_output . "/movement/" . $objectref;
384
-				$file = $dir . "/" . $objectref . ".pdf";
381
+				if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode;
382
+				if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement;
383
+				$dir = $conf->stock->dir_output."/movement/".$objectref;
384
+				$file = $dir."/".$objectref.".pdf";
385 385
 			}
386 386
 
387 387
 			$stockFournisseur = new ProductFournisseur($this->db);
388 388
 			$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
389 389
 			$object->supplierprices = $supplierprices;
390 390
 
391
-			$productstatic=new Product($db);
391
+			$productstatic = new Product($db);
392 392
 
393
-			if (! file_exists($dir))
393
+			if (!file_exists($dir))
394 394
 			{
395 395
 				if (dol_mkdir($dir) < 0)
396 396
 				{
397
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
397
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
398 398
 					return -1;
399 399
 				}
400 400
 			}
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
 			if (file_exists($dir))
403 403
 			{
404 404
 				// Add pdfgeneration hook
405
-				if (! is_object($hookmanager))
405
+				if (!is_object($hookmanager))
406 406
 				{
407 407
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
408
-					$hookmanager=new HookManager($this->db);
408
+					$hookmanager = new HookManager($this->db);
409 409
 				}
410 410
 				$hookmanager->initHooks(array('pdfgeneration'));
411
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
411
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
412 412
 				global $action;
413
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
413
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
414 414
 
415 415
 				// Create pdf instance
416
-				$pdf=pdf_getInstance($this->format);
417
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
418
-				$pdf->SetAutoPageBreak(1,0);
416
+				$pdf = pdf_getInstance($this->format);
417
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
418
+				$pdf->SetAutoPageBreak(1, 0);
419 419
 
420
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
421
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
422
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
420
+				$heightforinfotot = 40; // Height reserved to output the info and total part
421
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
422
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
423 423
 
424 424
                 if (class_exists('TCPDF'))
425 425
                 {
@@ -428,37 +428,37 @@  discard block
 block discarded – undo
428 428
                 }
429 429
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
430 430
                 // Set path to the background PDF File
431
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
431
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
432 432
                 {
433 433
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
434 434
                     $tplidx = $pdf->importPage(1);
435 435
                 }
436 436
 
437 437
 				$pdf->Open();
438
-				$pagenb=0;
439
-				$pdf->SetDrawColor(128,128,128);
438
+				$pagenb = 0;
439
+				$pdf->SetDrawColor(128, 128, 128);
440 440
 
441 441
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
442 442
 				$pdf->SetSubject($outputlangs->transnoentities("Stock"));
443 443
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
444 444
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
445 445
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
446
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
446
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
447 447
 
448
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
448
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
449 449
 
450 450
 
451 451
 				// New page
452 452
 				$pdf->AddPage();
453
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
453
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
454 454
 				$pagenb++;
455 455
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
456
-				$pdf->SetFont('','', $default_font_size - 1);
457
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
458
-				$pdf->SetTextColor(0,0,0);
456
+				$pdf->SetFont('', '', $default_font_size - 1);
457
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
458
+				$pdf->SetTextColor(0, 0, 0);
459 459
 
460 460
 				$tab_top = 42;
461
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
461
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
462 462
 				$tab_height = 130;
463 463
 				$tab_height_newpage = 150;
464 464
 
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 				/*                                                                            */
469 469
 				/* ************************************************************************** */
470 470
 
471
-				$nexY+=5;
471
+				$nexY += 5;
472 472
 				$nexY = $pdf->GetY();
473
-				$nexY+=10;
473
+				$nexY += 10;
474 474
 
475
-				$totalunit=0;
476
-				$totalvalue=$totalvaluesell=0;
475
+				$totalunit = 0;
476
+				$totalvalue = $totalvaluesell = 0;
477 477
 				$arrayofuniqueproduct = array();
478 478
 
479 479
 				//dol_syslog('List products', LOG_DEBUG);
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 					$num = $db->num_rows($resql);
484 484
 					$i = 0;
485 485
 					$nblignes = $num;
486
-					for ($i = 0 ; $i < $nblignes ; $i++)
486
+					for ($i = 0; $i < $nblignes; $i++)
487 487
 					{
488 488
 						$objp = $db->fetch_object($resql);
489 489
 
490 490
 						// Multilangs
491
-						if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
491
+						if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
492 492
 						{
493 493
 							$sql = "SELECT label";
494
-							$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
495
-							$sql.= " WHERE fk_product=".$objp->rowid;
496
-							$sql.= " AND lang='". $langs->getDefaultLang() ."'";
497
-							$sql.= " LIMIT 1";
494
+							$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
495
+							$sql .= " WHERE fk_product=".$objp->rowid;
496
+							$sql .= " AND lang='".$langs->getDefaultLang()."'";
497
+							$sql .= " LIMIT 1";
498 498
 
499 499
 							$result = $db->query($sql);
500 500
 							if ($result)
@@ -505,92 +505,92 @@  discard block
 block discarded – undo
505 505
 						}
506 506
 
507 507
 						$curY = $nexY;
508
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
509
-						$pdf->SetTextColor(0,0,0);
508
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
509
+						$pdf->SetTextColor(0, 0, 0);
510 510
 
511 511
 						$pdf->setTopMargin($tab_top_newpage);
512
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
513
-						$pageposbefore=$pdf->getPage();
512
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
513
+						$pageposbefore = $pdf->getPage();
514 514
 
515 515
 						// Description of product line
516
-						$curX = $this->posxdesc-1;
516
+						$curX = $this->posxdesc - 1;
517 517
 
518
-						$showpricebeforepagebreak=1;
518
+						$showpricebeforepagebreak = 1;
519 519
 
520 520
 						$pdf->startTransaction();
521
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
522
-						$pageposafter=$pdf->getPage();
521
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
522
+						$pageposafter = $pdf->getPage();
523 523
 						if ($pageposafter > $pageposbefore)	// There is a pagebreak
524 524
 						{
525 525
 							$pdf->rollbackTransaction(true);
526
-							$pageposafter=$pageposbefore;
526
+							$pageposafter = $pageposbefore;
527 527
 							//print $pageposafter.'-'.$pageposbefore;exit;
528
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
529
-							pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
530
-							$pageposafter=$pdf->getPage();
531
-							$posyafter=$pdf->GetY();
532
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
528
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
529
+							pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
530
+							$pageposafter = $pdf->getPage();
531
+							$posyafter = $pdf->GetY();
532
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
533 533
 							{
534
-								if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
534
+								if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
535 535
 								{
536
-									$pdf->AddPage('','',true);
537
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
536
+									$pdf->AddPage('', '', true);
537
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
538 538
 									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
539
-									$pdf->setPage($pageposafter+1);
539
+									$pdf->setPage($pageposafter + 1);
540 540
 								}
541 541
 							}
542 542
 							else
543 543
 							{
544 544
 								// We found a page break
545
-								$showpricebeforepagebreak=0;
545
+								$showpricebeforepagebreak = 0;
546 546
 							}
547 547
 						}
548 548
 						else	// No pagebreak
549 549
 						{
550 550
 							$pdf->commitTransaction();
551 551
 						}
552
-						$posYAfterDescription=$pdf->GetY();
552
+						$posYAfterDescription = $pdf->GetY();
553 553
 
554 554
 						$nexY = $pdf->GetY();
555
-						$pageposafter=$pdf->getPage();
555
+						$pageposafter = $pdf->getPage();
556 556
 
557 557
 						$pdf->setPage($pageposbefore);
558 558
 						$pdf->setTopMargin($this->marge_haute);
559
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
559
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
560 560
 
561 561
 						// We suppose that a too long description is moved completely on next page
562 562
 						if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563 563
 							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
564 564
 						}
565 565
 
566
-						$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
566
+						$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
567 567
 
568 568
 						// $objp = $db->fetch_object($resql);
569 569
 
570
-						$userstatic->id=$objp->fk_user_author;
571
-						$userstatic->login=$objp->login;
572
-						$userstatic->lastname=$objp->lastname;
573
-						$userstatic->firstname=$objp->firstname;
574
-						$userstatic->photo=$objp->photo;
570
+						$userstatic->id = $objp->fk_user_author;
571
+						$userstatic->login = $objp->login;
572
+						$userstatic->lastname = $objp->lastname;
573
+						$userstatic->firstname = $objp->firstname;
574
+						$userstatic->photo = $objp->photo;
575 575
 
576
-						$productstatic->id=$objp->rowid;
577
-						$productstatic->ref=$objp->product_ref;
578
-						$productstatic->label=$objp->produit;
579
-						$productstatic->type=$objp->type;
580
-						$productstatic->entity=$objp->entity;
581
-						$productstatic->status_batch=$objp->tobatch;
576
+						$productstatic->id = $objp->rowid;
577
+						$productstatic->ref = $objp->product_ref;
578
+						$productstatic->label = $objp->produit;
579
+						$productstatic->type = $objp->type;
580
+						$productstatic->entity = $objp->entity;
581
+						$productstatic->status_batch = $objp->tobatch;
582 582
 
583 583
 						$productlot->id = $objp->lotid;
584
-						$productlot->batch= $objp->batch;
585
-						$productlot->eatby= $objp->eatby;
586
-						$productlot->sellby= $objp->sellby;
584
+						$productlot->batch = $objp->batch;
585
+						$productlot->eatby = $objp->eatby;
586
+						$productlot->sellby = $objp->sellby;
587 587
 
588
-						$warehousestatic->id=$objp->entrepot_id;
589
-						$warehousestatic->libelle=$objp->stock;
590
-						$warehousestatic->lieu=$objp->lieu;
588
+						$warehousestatic->id = $objp->entrepot_id;
589
+						$warehousestatic->libelle = $objp->stock;
590
+						$warehousestatic->lieu = $objp->lieu;
591 591
 
592
-						$arrayofuniqueproduct[$objp->rowid]=$objp->produit;
593
-						if(!empty($objp->fk_origin)) {
592
+						$arrayofuniqueproduct[$objp->rowid] = $objp->produit;
593
+						if (!empty($objp->fk_origin)) {
594 594
 							$origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
595 595
 						} else {
596 596
 							$origin = '';
@@ -598,60 +598,60 @@  discard block
 block discarded – undo
598 598
 
599 599
 						// Id movement.
600 600
 						$pdf->SetXY($this->posxidref, $curY);
601
-						$pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L');
601
+						$pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0, 'L');
602 602
 
603 603
 						// Date.
604 604
 						$pdf->SetXY($this->posxdatemouv, $curY);
605
-						$pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L');
605
+						$pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L');
606 606
 
607 607
 						// Ref.
608 608
 						$pdf->SetXY($this->posxdesc, $curY);
609
-						$pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L');
609
+						$pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0, 'L');
610 610
 
611 611
 						// Label
612
-						$pdf->SetXY($this->posxlabel+0.8, $curY);
613
-						$pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L');
612
+						$pdf->SetXY($this->posxlabel + 0.8, $curY);
613
+						$pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0, 'L');
614 614
 
615 615
 						// Lot/serie
616 616
 						$pdf->SetXY($this->posxqty, $curY);
617
-						$pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R');
617
+						$pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0, 'R');
618 618
 
619 619
 						// Inv. code
620 620
 						$pdf->SetXY($this->posxup, $curY);
621
-						$pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R');
621
+						$pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0, 'R');
622 622
 
623 623
 						// Label mouvement
624 624
 						$pdf->SetXY($this->posxunit, $curY);
625
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R');
626
-						$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
625
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0, 'R');
626
+						$totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
627 627
 
628 628
 						// Origin
629
-						$pricemin=$objp->price;
629
+						$pricemin = $objp->price;
630 630
 						$pdf->SetXY($this->posxdiscount, $curY);
631
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0);
631
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0, 'R', 0);
632 632
 
633 633
 						// Qty
634
-						$valtoshow=price2num($objp->qty, 'MS');
635
-						$towrite = (empty($valtoshow)?'0':$valtoshow);
636
-						$totalunit+=$objp->qty;
634
+						$valtoshow = price2num($objp->qty, 'MS');
635
+						$towrite = (empty($valtoshow) ? '0' : $valtoshow);
636
+						$totalunit += $objp->qty;
637 637
 
638 638
 						$pdf->SetXY($this->postotalht, $curY);
639
-						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0);
639
+						$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0, 'R', 0);
640 640
 
641
-						$totalvaluesell+=price2num($pricemin*$objp->value,'MT');
641
+						$totalvaluesell += price2num($pricemin * $objp->value, 'MT');
642 642
 
643
-						$nexY+=3.5;    // Passe espace entre les lignes
643
+						$nexY += 3.5; // Passe espace entre les lignes
644 644
 						// Add line
645
-						if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
645
+						if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
646 646
 						{
647 647
 							$pdf->setPage($pageposafter);
648
-							$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
648
+							$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
649 649
 							//$pdf->SetDrawColor(190,190,200);
650
-							$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
650
+							$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
651 651
 							$pdf->SetLineStyle(array('dash'=>0));
652 652
 						}
653 653
 
654
-						$nexY+=2;    // Passe espace entre les lignes
654
+						$nexY += 2; // Passe espace entre les lignes
655 655
 
656 656
 						// Detect if some page were added automatically and output _tableau for past pages
657 657
 						while ($pagenb < $pageposafter)
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
 							{
666 666
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667 667
 							}
668
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
668
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
669 669
 							$pagenb++;
670 670
 							$pdf->setPage($pagenb);
671
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
671
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
672 672
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
673 673
 						}
674
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
674
+						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
675 675
 						{
676 676
 							if ($pagenb == 1)
677 677
 							{
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 							{
682 682
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
683 683
 							}
684
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
684
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
685 685
 							// New page
686 686
 							$pdf->AddPage();
687
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
687
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
688 688
 							$pagenb++;
689 689
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
690 690
 						}
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
 					 * footer table
697 697
 					 */
698 698
 					$nexY = $pdf->GetY();
699
-					$nexY+=5;
699
+					$nexY += 5;
700 700
 					$curY = $nexY;
701 701
 
702
-					$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
703
-					$pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
702
+					$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
703
+					$pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
704 704
 					$pdf->SetLineStyle(array('dash'=>0));
705 705
 
706
-					$pdf->SetFont('','B',$default_font_size-1);
707
-					$pdf->SetTextColor(0,0,120);
706
+					$pdf->SetFont('', 'B', $default_font_size - 1);
707
+					$pdf->SetTextColor(0, 0, 120);
708 708
 
709 709
 					// Total
710 710
 					$pdf->SetXY($this->posxidref, $curY);
711
-					$pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L');
711
+					$pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans("Total"), 0, 'L');
712 712
 
713 713
 					// Total Qty
714 714
 					$pdf->SetXY($this->postotalht, $curY);
715
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
715
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0, 'R', 0);
716 716
 				}
717 717
 				else
718 718
 				{
@@ -721,48 +721,48 @@  discard block
 block discarded – undo
721 721
 
722 722
 				if ($notetoshow)
723 723
 				{
724
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
724
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
725 725
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
726 726
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
727 727
 
728 728
 					$tab_top = 88;
729 729
 
730
-					$pdf->SetFont('','', $default_font_size - 1);
731
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
730
+					$pdf->SetFont('', '', $default_font_size - 1);
731
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
732 732
 					$nexY = $pdf->GetY();
733
-					$height_note=$nexY-$tab_top;
733
+					$height_note = $nexY - $tab_top;
734 734
 
735 735
 					// Rect prend une longueur en 3eme param
736
-					$pdf->SetDrawColor(192,192,192);
737
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
736
+					$pdf->SetDrawColor(192, 192, 192);
737
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
738 738
 
739 739
 					$tab_height = $tab_height - $height_note;
740
-					$tab_top = $nexY+6;
740
+					$tab_top = $nexY + 6;
741 741
 				}
742 742
 				else
743 743
 				{
744
-					$height_note=0;
744
+					$height_note = 0;
745 745
 				}
746 746
 
747 747
 				$iniY = $tab_top + 7;
748 748
 				$curY = $tab_top + 7;
749 749
 				$nexY = $tab_top + 7;
750 750
 
751
-				$tab_top = $tab_top_newpage+21;
751
+				$tab_top = $tab_top_newpage + 21;
752 752
 
753 753
 				// Show square
754 754
 				if ($pagenb == 1)
755 755
 				{
756 756
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
757
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
757
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758 758
 				}
759 759
 				else
760 760
 				{
761 761
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
762
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763 763
 				}
764 764
 
765
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
765
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
766 766
 
767 767
 				// Affiche zone infos
768 768
 				//$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -771,35 +771,35 @@  discard block
 block discarded – undo
771 771
 				//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
772 772
 
773 773
 				// Pied de page
774
-				$this->_pagefoot($pdf,$object,$outputlangs);
775
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
774
+				$this->_pagefoot($pdf, $object, $outputlangs);
775
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
776 776
 
777 777
 				$pdf->Close();
778 778
 
779
-				$pdf->Output($file,'F');
779
+				$pdf->Output($file, 'F');
780 780
 
781 781
 				// Add pdfgeneration hook
782 782
 				$hookmanager->initHooks(array('pdfgeneration'));
783
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
783
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
784 784
 				global $action;
785
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
785
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
786 786
 
787
-				if (! empty($conf->global->MAIN_UMASK))
787
+				if (!empty($conf->global->MAIN_UMASK))
788 788
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
789 789
 
790 790
 				$this->result = array('fullpath'=>$file);
791 791
 
792
-				return 1;   // Pas d'erreur
792
+				return 1; // Pas d'erreur
793 793
 			}
794 794
 			else
795 795
 			{
796
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
796
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
797 797
 				return 0;
798 798
 			}
799 799
 		}
800 800
 		else
801 801
 		{
802
-			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
802
+			$this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR");
803 803
 			return 0;
804 804
 		}
805 805
 	}
@@ -818,74 +818,74 @@  discard block
 block discarded – undo
818 818
 	 *   @param		string		$currency		Currency code
819 819
 	 *   @return	void
820 820
 	 */
821
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
821
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
822 822
 	{
823 823
 	    global $conf;
824 824
 
825 825
 	    // Force to disable hidetop and hidebottom
826
-	    $hidebottom=0;
827
-	    if ($hidetop) $hidetop=-1;
826
+	    $hidebottom = 0;
827
+	    if ($hidetop) $hidetop = -1;
828 828
 
829 829
 	    $currency = !empty($currency) ? $currency : $conf->currency;
830 830
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
831 831
 
832 832
 	    // Amount in (at tab_top - 1)
833
-	    $pdf->SetTextColor(0,0,0);
834
-	    $pdf->SetFont('','', $default_font_size - 2);
833
+	    $pdf->SetTextColor(0, 0, 0);
834
+	    $pdf->SetFont('', '', $default_font_size - 2);
835 835
 
836 836
 	    if (empty($hidetop))
837 837
 	    {
838
-	        $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
839
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
838
+	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
839
+	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
840 840
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
841 841
 
842 842
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
843
-	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
843
+	        if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
844 844
 	    }
845 845
 
846
-	    $pdf->SetDrawColor(128,128,128);
847
-	    $pdf->SetFont('','B', $default_font_size - 3);
846
+	    $pdf->SetDrawColor(128, 128, 128);
847
+	    $pdf->SetFont('', 'B', $default_font_size - 3);
848 848
 
849 849
 	    // Output Rect
850 850
 	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
851 851
 
852
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
853
-		$pdf->SetDrawColor(220,26,26);
854
-		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
852
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
853
+		$pdf->SetDrawColor(220, 26, 26);
854
+		$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
855 855
 		$pdf->SetLineStyle(array('dash'=>0));
856
-		$pdf->SetDrawColor(128,128,128);
857
-		$pdf->SetTextColor(0,0,120);
856
+		$pdf->SetDrawColor(128, 128, 128);
857
+		$pdf->SetTextColor(0, 0, 120);
858 858
 
859 859
 		//Ref mouv
860 860
 	    if (empty($hidetop))
861 861
 	    {
862 862
 	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
863
-	        $pdf->SetXY($this->posxidref, $tab_top+1);
864
-	        $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L');
863
+	        $pdf->SetXY($this->posxidref, $tab_top + 1);
864
+	        $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
865 865
 	    }
866 866
 
867 867
 		//Date mouv
868 868
 		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
869 869
 		if (empty($hidetop))
870 870
 		{
871
-			$pdf->SetXY($this->posxdatemouv, $tab_top+1);
872
-			$pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C');
871
+			$pdf->SetXY($this->posxdatemouv, $tab_top + 1);
872
+			$pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C');
873 873
 		}
874 874
 
875 875
 		//Ref Product
876 876
 	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
877 877
 	    if (empty($hidetop))
878 878
 	    {
879
-	        $pdf->SetXY($this->posxdesc-1, $tab_top+1);
880
-	        $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C');
879
+	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
880
+	        $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
881 881
 	    }
882 882
 
883 883
 		//Label Product
884 884
 	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
885 885
 	    if (empty($hidetop))
886 886
 	    {
887
-	        $pdf->SetXY($this->posxlabel-1, $tab_top+1);
888
-			$pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C');
887
+	        $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
888
+			$pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C');
889 889
 	    }
890 890
 
891 891
 		//Lot/serie Product
@@ -893,44 +893,44 @@  discard block
 block discarded – undo
893 893
 		if (empty($hidetop))
894 894
 		{
895 895
 			$pdf->SetXY($this->posxqty, $tab_top + 1);
896
-			$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C');
896
+			$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '', 'C');
897 897
 		}
898 898
 
899 899
 		//Code Inv
900 900
 	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
901 901
 	    if (empty($hidetop))
902 902
 	    {
903
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
904
-			$pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C');
903
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
904
+			$pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C');
905 905
 	    }
906 906
 
907 907
 		//Label mouvement
908 908
 	    //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
909 909
 	    if (empty($hidetop))
910 910
 	    {
911
-	        $pdf->SetXY($this->posxunit, $tab_top+1);
912
-	        $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C');
911
+	        $pdf->SetXY($this->posxunit, $tab_top + 1);
912
+	        $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
913 913
 	    }
914 914
 
915 915
 		//Origin
916 916
 	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
917 917
 	    if (empty($hidetop))
918 918
 	    {
919
-	        $pdf->SetXY($this->posxdiscount+2, $tab_top+1);
920
-	        $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C');
919
+	        $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
920
+	        $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
921 921
 	    }
922 922
 
923 923
 		//Qty
924 924
 	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
925 925
 	    if (empty($hidetop))
926 926
 	    {
927
-	        $pdf->SetXY($this->postotalht+2, $tab_top+1);
928
-	        $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C');
927
+	        $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
928
+	        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
929 929
 	    }
930 930
 
931
-		$pdf->SetDrawColor(220,26,26);
932
-		$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
933
-		$pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
931
+		$pdf->SetDrawColor(220, 26, 26);
932
+		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
933
+		$pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
934 934
 		$pdf->SetLineStyle(array('dash'=>0));
935 935
 	}
936 936
 
@@ -944,92 +944,92 @@  discard block
 block discarded – undo
944 944
 	 *  @param	string		$titlekey		Translation key to show as title of document
945 945
 	 *  @return	void
946 946
 	 */
947
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
947
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
948 948
 	{
949
-	    global $conf,$langs,$db,$hookmanager;
949
+	    global $conf, $langs, $db, $hookmanager;
950 950
 
951 951
 	    // Load traductions files requiredby by page
952 952
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
953 953
 
954 954
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
955 955
 
956
-	    if ($object->type == 1) $titlekey='ServiceSheet';
957
-	    else $titlekey='StockSheet';
956
+	    if ($object->type == 1) $titlekey = 'ServiceSheet';
957
+	    else $titlekey = 'StockSheet';
958 958
 
959
-	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
959
+	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
960 960
 
961 961
 	    // Show Draft Watermark
962
-	    if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
962
+	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
963 963
 	    {
964
-	        pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
964
+	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
965 965
 	    }
966 966
 
967
-	    $pdf->SetTextColor(0,0,60);
968
-	    $pdf->SetFont('','B', $default_font_size + 3);
967
+	    $pdf->SetTextColor(0, 0, 60);
968
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
969 969
 
970
-	    $posy=$this->marge_haute;
971
-	    $posx=$this->page_largeur-$this->marge_droite-100;
970
+	    $posy = $this->marge_haute;
971
+	    $posx = $this->page_largeur - $this->marge_droite - 100;
972 972
 
973
-	    $pdf->SetXY($this->marge_gauche,$posy);
973
+	    $pdf->SetXY($this->marge_gauche, $posy);
974 974
 
975 975
 	    // Logo
976
-	    $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
976
+	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
977 977
 	    if ($this->emetteur->logo)
978 978
 	    {
979 979
 	        if (is_readable($logo))
980 980
 	        {
981
-	            $height=pdf_getHeightForLogo($logo);
982
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
981
+	            $height = pdf_getHeightForLogo($logo);
982
+	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
983 983
 	        }
984 984
 	        else
985 985
 	        {
986
-	            $pdf->SetTextColor(200,0,0);
987
-	            $pdf->SetFont('','B', $default_font_size -2);
988
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
986
+	            $pdf->SetTextColor(200, 0, 0);
987
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
988
+	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
989 989
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
990 990
 	        }
991 991
 	    }
992 992
 	    else
993 993
 	    {
994
-	        $text=$this->emetteur->name;
994
+	        $text = $this->emetteur->name;
995 995
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
996 996
 	    }
997 997
 
998
-	    $pdf->SetFont('','B', $default_font_size + 3);
999
-	    $pdf->SetXY($posx,$posy);
1000
-	    $pdf->SetTextColor(0,0,60);
1001
-	    $title=$outputlangs->transnoentities("Warehouse");
998
+	    $pdf->SetFont('', 'B', $default_font_size + 3);
999
+	    $pdf->SetXY($posx, $posy);
1000
+	    $pdf->SetTextColor(0, 0, 60);
1001
+	    $title = $outputlangs->transnoentities("Warehouse");
1002 1002
 	    $pdf->MultiCell(100, 3, $title, '', 'R');
1003 1003
 
1004
-	    $pdf->SetFont('','B',$default_font_size);
1004
+	    $pdf->SetFont('', 'B', $default_font_size);
1005 1005
 
1006
-	    $posy+=5;
1007
-	    $pdf->SetXY($posx,$posy);
1008
-	    $pdf->SetTextColor(0,0,60);
1006
+	    $posy += 5;
1007
+	    $pdf->SetXY($posx, $posy);
1008
+	    $pdf->SetTextColor(0, 0, 60);
1009 1009
 
1010
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
1010
+	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->libelle), '', 'R');
1011 1011
 
1012
-	    $posy+=5;
1013
-	    $pdf->SetFont('','', $default_font_size - 1);
1014
-		$pdf->SetXY($posx,$posy);
1015
-	    $pdf->SetTextColor(0,0,60);
1012
+	    $posy += 5;
1013
+	    $pdf->SetFont('', '', $default_font_size - 1);
1014
+		$pdf->SetXY($posx, $posy);
1015
+	    $pdf->SetTextColor(0, 0, 60);
1016 1016
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1017 1017
 
1018
-		$posy+=4;
1019
-		$pdf->SetXY($posx-50,$posy);
1018
+		$posy += 4;
1019
+		$pdf->SetXY($posx - 50, $posy);
1020 1020
 		$pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1021 1021
 
1022 1022
 
1023 1023
 		// Parent MouvementStock
1024
-		$posy+=4;
1025
-		$pdf->SetXY($posx,$posy);
1026
-		$pdf->SetTextColor(0,0,60);
1024
+		$posy += 4;
1025
+		$pdf->SetXY($posx, $posy);
1026
+		$pdf->SetTextColor(0, 0, 60);
1027 1027
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1028 1028
 
1029
-		$posy+=4;
1030
-		$pdf->SetXY($posx-50,$posy);
1029
+		$posy += 4;
1030
+		$pdf->SetXY($posx - 50, $posy);
1031 1031
 		$e = new MouvementStock($db);
1032
-		if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1032
+		if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1033 1033
 		{
1034 1034
 			$pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1035 1035
 		}
@@ -1040,25 +1040,25 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 		// Description
1042 1042
 		$nexY = $pdf->GetY();
1043
-		$nexY+=5;
1044
-		$pdf->SetXY($posx,$posy);
1043
+		$nexY += 5;
1044
+		$pdf->SetXY($posx, $posy);
1045 1045
 		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1046 1046
 		$nexY = $pdf->GetY();
1047 1047
 
1048
-		$calcproductsunique=$object->nb_different_products();
1049
-		$calcproducts=$object->nb_products();
1048
+		$calcproductsunique = $object->nb_different_products();
1049
+		$calcproducts = $object->nb_products();
1050 1050
 
1051 1051
 		// Total nb of different products
1052
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1052
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
1053 1053
 		$nexY = $pdf->GetY();
1054 1054
 
1055 1055
 		// Nb of products
1056
-		$valtoshow=price2num($calcproducts['nb'], 'MS');
1057
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1056
+		$valtoshow = price2num($calcproducts['nb'], 'MS');
1057
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
1058 1058
 		$nexY = $pdf->GetY();
1059 1059
 
1060 1060
 		// Value
1061
-		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1061
+		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1062 1062
 		$nexY = $pdf->GetY();
1063 1063
 
1064 1064
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 		if ($resqlbis)
1071 1071
 		{
1072 1072
 			$obj = $db->fetch_object($resqlbis);
1073
-			$lastmovementdate=$db->jdate($obj->datem);
1073
+			$lastmovementdate = $db->jdate($obj->datem);
1074 1074
 		}
1075 1075
 		else
1076 1076
 		{
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 
1080 1080
 		if ($lastmovementdate)
1081 1081
 		{
1082
-			$toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1082
+			$toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
1083 1083
 		}
1084 1084
 		else
1085 1085
 		{
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 	        }
1121 1121
 	    }*/
1122 1122
 
1123
-	    $posy+=2;
1123
+	    $posy += 2;
1124 1124
 
1125 1125
 	    // Show list of linked objects
1126 1126
 	    //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	        */
1161 1161
 	    }
1162 1162
 
1163
-	    $pdf->SetTextColor(0,0,0);
1163
+	    $pdf->SetTextColor(0, 0, 0);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
@@ -1172,10 +1172,10 @@  discard block
 block discarded – undo
1172 1172
 	 *      @param	int			$hidefreetext		1=Hide free text
1173 1173
 	 *      @return	int								Return height of bottom margin including footer text
1174 1174
 	 */
1175
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1175
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1176 1176
 	{
1177 1177
 	    global $conf;
1178
-	    $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
-	    return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1178
+	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1179
+	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1180 1180
 	}
1181 1181
 }
Please login to merge, or discard this patch.
Braces   +159 added lines, -84 removed lines patch added patch discarded remove patch
@@ -145,7 +145,10 @@  discard block
 block discarded – undo
145 145
 
146 146
 		// Recupere emetteur
147 147
 		$this->emetteur=$mysoc;
148
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
+		if (! $this->emetteur->country_code) {
149
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
150
+		}
151
+		// By default if not defined
149 152
 
150 153
 		// Define position of columns
151 154
 		$this->wref = 15;
@@ -160,11 +163,15 @@  discard block
 block discarded – undo
160 163
 		$this->posxdiscount=167;
161 164
 		$this->postotalht=180;
162 165
 
163
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
166
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
167
+		    $this->posxtva=$this->posxup;
168
+		}
164 169
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
165
-		if ($this->page_largeur < 210) // To work with US executive format
170
+		if ($this->page_largeur < 210) {
171
+		    // To work with US executive format
166 172
 		{
167 173
 			$this->posxpicture-=20;
174
+		}
168 175
 			$this->posxtva-=20;
169 176
 			$this->posxup-=20;
170 177
 			$this->posxqty-=20;
@@ -197,9 +204,13 @@  discard block
 block discarded – undo
197 204
         // phpcs:enable
198 205
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
199 206
 
200
-		if (! is_object($outputlangs)) $outputlangs=$langs;
207
+		if (! is_object($outputlangs)) {
208
+		    $outputlangs=$langs;
209
+		}
201 210
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
202
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
211
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
212
+		    $outputlangs->charset_output='ISO-8859-1';
213
+		}
203 214
 
204 215
 		// Load traductions files requiredby by page
205 216
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -236,8 +247,12 @@  discard block
 block discarded – undo
236 247
 		$sortorder = GETPOST("sortorder",'alpha');
237 248
 		if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
238 249
 		$offset = $limit * $page;
239
-		if (! $sortfield) $sortfield="m.datem";
240
-		if (! $sortorder) $sortorder="DESC";
250
+		if (! $sortfield) {
251
+		    $sortfield="m.datem";
252
+		}
253
+		if (! $sortorder) {
254
+		    $sortorder="DESC";
255
+		}
241 256
 
242 257
 		$pdluoid=GETPOST('pdluoid','int');
243 258
 
@@ -263,7 +278,9 @@  discard block
 block discarded – undo
263 278
 		$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
264 279
 		$sql.= " u.login, u.photo, u.lastname, u.firstname";
265 280
 		// Add fields from extrafields
266
-		foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
281
+		foreach ($extrafields->attribute_label as $key => $val) {
282
+		    $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
283
+		}
267 284
 		// Add fields from hooks
268 285
 		$parameters=array();
269 286
 		$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
@@ -271,37 +288,67 @@  discard block
 block discarded – undo
271 288
 		$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
272 289
 		$sql.= " ".MAIN_DB_PREFIX."product as p,";
273 290
 		$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
274
-		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
291
+		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
292
+		    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)";
293
+		}
275 294
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276 295
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277 296
 		$sql.= " WHERE m.fk_product = p.rowid";
278
-		if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
297
+		if ($msid > 0) {
298
+		    $sql .= " AND m.rowid = ".$msid;
299
+		}
279 300
 		$sql.= " AND m.fk_entrepot = e.rowid";
280 301
 		$sql.= " AND e.entity IN (".getEntity('stock').")";
281
-		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
282
-		if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
302
+		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
303
+		    $sql.= " AND p.fk_product_type = 0";
304
+		}
305
+		if ($id > 0) {
306
+		    $sql.= " AND e.rowid ='".$id."'";
307
+		}
283 308
 		if ($month > 0)
284 309
 		{
285
-			if ($year > 0)
286
-			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
287
-			else
288
-			$sql.= " AND date_format(m.datem, '%m') = '$month'";
289
-		}
290
-		else if ($year > 0)
310
+			if ($year > 0) {
311
+						$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
312
+			} else {
313
+						$sql.= " AND date_format(m.datem, '%m') = '$month'";
314
+			}
315
+		} else if ($year > 0)
291 316
 		{
292 317
 			$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
293 318
 		}
294
-		if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
295
-		if (! empty($search_ref))			$sql.= natural_search('m.rowid', $search_ref, 1);
296
-		if (! empty($search_movement))      $sql.= natural_search('m.label', $search_movement);
297
-		if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
298
-		if (! empty($search_product_ref))   $sql.= natural_search('p.ref', $search_product_ref);
299
-		if (! empty($search_product))       $sql.= natural_search('p.label', $search_product);
300
-		if ($search_warehouse > 0)          $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
301
-		if (! empty($search_user))          $sql.= natural_search('u.login', $search_user);
302
-		if (! empty($search_batch))         $sql.= natural_search('m.batch', $search_batch);
303
-		if ($search_qty != '')				$sql.= natural_search('m.value', $search_qty, 1);
304
-		if ($search_type_mouvement > 0)		$sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
319
+		if ($idproduct > 0) {
320
+		    $sql.= " AND p.rowid = '".$idproduct."'";
321
+		}
322
+		if (! empty($search_ref)) {
323
+		    $sql.= natural_search('m.rowid', $search_ref, 1);
324
+		}
325
+		if (! empty($search_movement)) {
326
+		    $sql.= natural_search('m.label', $search_movement);
327
+		}
328
+		if (! empty($search_inventorycode)) {
329
+		    $sql.= natural_search('m.inventorycode', $search_inventorycode);
330
+		}
331
+		if (! empty($search_product_ref)) {
332
+		    $sql.= natural_search('p.ref', $search_product_ref);
333
+		}
334
+		if (! empty($search_product)) {
335
+		    $sql.= natural_search('p.label', $search_product);
336
+		}
337
+		if ($search_warehouse > 0) {
338
+		    $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'";
339
+		}
340
+		if (! empty($search_user)) {
341
+		    $sql.= natural_search('u.login', $search_user);
342
+		}
343
+		if (! empty($search_batch)) {
344
+		    $sql.= natural_search('m.batch', $search_batch);
345
+		}
346
+		if ($search_qty != '') {
347
+		    $sql.= natural_search('m.value', $search_qty, 1);
348
+		}
349
+		if ($search_type_mouvement > 0) {
350
+		    $sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'";
351
+		}
305 352
 		// Add where from extra fields
306 353
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307 354
 		// Add where from hooks
@@ -315,14 +362,18 @@  discard block
 block discarded – undo
315 362
 		{
316 363
 			$result = $db->query($sql);
317 364
 			$nbtotalofrecords = $db->num_rows($result);
318
-			if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
365
+			if (($page * $limit) > $nbtotalofrecords) {
366
+			    // if total resultset is smaller then paging size (filtering), goto and load page 0
319 367
 			{
320 368
 				$page = 0;
369
+			}
321 370
 				$offset = 0;
322 371
 			}
323 372
 		}
324 373
 
325
-		if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset);
374
+		if(empty($search_inventorycode)) {
375
+		    $sql.= $db->plimit($limit+1, $offset);
376
+		}
326 377
 
327 378
 
328 379
 		$resql = $db->query($sql);
@@ -361,11 +412,14 @@  discard block
 block discarded – undo
361 412
 
362 413
 				$i = 0;
363 414
 				$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
364
-				if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
365
-				else
415
+				if ($msid) {
416
+				    $texte = $langs->trans('StockMovementForId', $msid);
417
+				} else
366 418
 				{
367 419
 					$texte = $langs->trans("ListOfStockMovements");
368
-					if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
420
+					if ($id) {
421
+					    $texte.=' ('.$langs->trans("ForThisWarehouse").')';
422
+					}
369 423
 				}
370 424
 			}
371 425
 
@@ -374,12 +428,15 @@  discard block
 block discarded – undo
374 428
 			{
375 429
 				$dir = $conf->stock->dir_output . "/movement";
376 430
 				$file = $dir . "/SPECIMEN.pdf";
377
-			}
378
-			else
431
+			} else
379 432
 			{
380 433
 				$objectref = dol_sanitizeFileName($object->ref);
381
-				if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
382
-				if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
434
+				if(!empty($search_inventorycode)) {
435
+				    $objectref.="_".$id."_".$search_inventorycode;
436
+				}
437
+				if($search_type_mouvement) {
438
+				    $objectref.="_".$search_type_mouvement;
439
+				}
383 440
 				$dir = $conf->stock->dir_output . "/movement/" . $objectref;
384 441
 				$file = $dir . "/" . $objectref . ".pdf";
385 442
 			}
@@ -443,14 +500,18 @@  discard block
 block discarded – undo
443 500
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
444 501
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
445 502
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
446
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
503
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
504
+				    $pdf->SetCompression(false);
505
+				}
447 506
 
448 507
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
449 508
 
450 509
 
451 510
 				// New page
452 511
 				$pdf->AddPage();
453
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
512
+				if (! empty($tplidx)) {
513
+				    $pdf->useTemplate($tplidx);
514
+				}
454 515
 				$pagenb++;
455 516
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
456 517
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -488,9 +549,11 @@  discard block
 block discarded – undo
488 549
 						$objp = $db->fetch_object($resql);
489 550
 
490 551
 						// Multilangs
491
-						if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
552
+						if (! empty($conf->global->MAIN_MULTILANGS)) {
553
+						    // si l'option est active
492 554
 						{
493 555
 							$sql = "SELECT label";
556
+						}
494 557
 							$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
495 558
 							$sql.= " WHERE fk_product=".$objp->rowid;
496 559
 							$sql.= " AND lang='". $langs->getDefaultLang() ."'";
@@ -500,7 +563,9 @@  discard block
 block discarded – undo
500 563
 							if ($result)
501 564
 							{
502 565
 								$objtp = $db->fetch_object($result);
503
-								if ($objtp->label != '') $objp->produit = $objtp->label;
566
+								if ($objtp->label != '') {
567
+								    $objp->produit = $objtp->label;
568
+								}
504 569
 							}
505 570
 						}
506 571
 
@@ -520,32 +585,38 @@  discard block
 block discarded – undo
520 585
 						$pdf->startTransaction();
521 586
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
522 587
 						$pageposafter=$pdf->getPage();
523
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
588
+						if ($pageposafter > $pageposbefore) {
589
+						    // There is a pagebreak
524 590
 						{
525 591
 							$pdf->rollbackTransaction(true);
592
+						}
526 593
 							$pageposafter=$pageposbefore;
527 594
 							//print $pageposafter.'-'.$pageposbefore;exit;
528 595
 							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
529 596
 							pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
530 597
 							$pageposafter=$pdf->getPage();
531 598
 							$posyafter=$pdf->GetY();
532
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
599
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
600
+							    // There is no space left for total+free text
533 601
 							{
534 602
 								if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
535 603
 								{
536 604
 									$pdf->AddPage('','',true);
537
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
538
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
605
+							}
606
+									if (! empty($tplidx)) {
607
+									    $pdf->useTemplate($tplidx);
608
+									}
609
+									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
610
+									    $this->_pagehead($pdf, $object, 0, $outputlangs);
611
+									}
539 612
 									$pdf->setPage($pageposafter+1);
540 613
 								}
541
-							}
542
-							else
614
+							} else
543 615
 							{
544 616
 								// We found a page break
545 617
 								$showpricebeforepagebreak=0;
546 618
 							}
547
-						}
548
-						else	// No pagebreak
619
+						} else	// No pagebreak
549 620
 						{
550 621
 							$pdf->commitTransaction();
551 622
 						}
@@ -660,8 +731,7 @@  discard block
 block discarded – undo
660 731
 							if ($pagenb == 1)
661 732
 							{
662 733
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
663
-							}
664
-							else
734
+							} else
665 735
 							{
666 736
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667 737
 							}
@@ -669,24 +739,29 @@  discard block
 block discarded – undo
669 739
 							$pagenb++;
670 740
 							$pdf->setPage($pagenb);
671 741
 							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
672
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
742
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
743
+							    $this->_pagehead($pdf, $object, 0, $outputlangs);
744
+							}
673 745
 						}
674 746
 						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
675 747
 						{
676 748
 							if ($pagenb == 1)
677 749
 							{
678 750
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
679
-							}
680
-							else
751
+							} else
681 752
 							{
682 753
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
683 754
 							}
684 755
 							$this->_pagefoot($pdf,$object,$outputlangs,1);
685 756
 							// New page
686 757
 							$pdf->AddPage();
687
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
758
+							if (! empty($tplidx)) {
759
+							    $pdf->useTemplate($tplidx);
760
+							}
688 761
 							$pagenb++;
689
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
762
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
763
+							    $this->_pagehead($pdf, $object, 0, $outputlangs);
764
+							}
690 765
 						}
691 766
 					}
692 767
 
@@ -713,8 +788,7 @@  discard block
 block discarded – undo
713 788
 					// Total Qty
714 789
 					$pdf->SetXY($this->postotalht, $curY);
715 790
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
716
-				}
717
-				else
791
+				} else
718 792
 				{
719 793
 					dol_print_error($db);
720 794
 				}
@@ -738,8 +812,7 @@  discard block
 block discarded – undo
738 812
 
739 813
 					$tab_height = $tab_height - $height_note;
740 814
 					$tab_top = $nexY+6;
741
-				}
742
-				else
815
+				} else
743 816
 				{
744 817
 					$height_note=0;
745 818
 				}
@@ -755,8 +828,7 @@  discard block
 block discarded – undo
755 828
 				{
756 829
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
757 830
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758
-				}
759
-				else
831
+				} else
760 832
 				{
761 833
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762 834
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -772,7 +844,9 @@  discard block
 block discarded – undo
772 844
 
773 845
 				// Pied de page
774 846
 				$this->_pagefoot($pdf,$object,$outputlangs);
775
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
847
+				if (method_exists($pdf,'AliasNbPages')) {
848
+				    $pdf->AliasNbPages();
849
+				}
776 850
 
777 851
 				$pdf->Close();
778 852
 
@@ -784,20 +858,19 @@  discard block
 block discarded – undo
784 858
 				global $action;
785 859
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
786 860
 
787
-				if (! empty($conf->global->MAIN_UMASK))
788
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
861
+				if (! empty($conf->global->MAIN_UMASK)) {
862
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
863
+				}
789 864
 
790 865
 				$this->result = array('fullpath'=>$file);
791 866
 
792 867
 				return 1;   // Pas d'erreur
793
-			}
794
-			else
868
+			} else
795 869
 			{
796 870
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
797 871
 				return 0;
798 872
 			}
799
-		}
800
-		else
873
+		} else
801 874
 		{
802 875
 			$this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
803 876
 			return 0;
@@ -824,7 +897,9 @@  discard block
 block discarded – undo
824 897
 
825 898
 	    // Force to disable hidetop and hidebottom
826 899
 	    $hidebottom=0;
827
-	    if ($hidetop) $hidetop=-1;
900
+	    if ($hidetop) {
901
+	        $hidetop=-1;
902
+	    }
828 903
 
829 904
 	    $currency = !empty($currency) ? $currency : $conf->currency;
830 905
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -840,7 +915,9 @@  discard block
 block discarded – undo
840 915
 	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
841 916
 
842 917
 	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
843
-	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
918
+	        if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
919
+	            $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));
920
+	        }
844 921
 	    }
845 922
 
846 923
 	    $pdf->SetDrawColor(128,128,128);
@@ -953,8 +1030,11 @@  discard block
 block discarded – undo
953 1030
 
954 1031
 	    $default_font_size = pdf_getPDFFontSize($outputlangs);
955 1032
 
956
-	    if ($object->type == 1) $titlekey='ServiceSheet';
957
-	    else $titlekey='StockSheet';
1033
+	    if ($object->type == 1) {
1034
+	        $titlekey='ServiceSheet';
1035
+	    } else {
1036
+	        $titlekey='StockSheet';
1037
+	    }
958 1038
 
959 1039
 	    pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
960 1040
 
@@ -980,16 +1060,14 @@  discard block
 block discarded – undo
980 1060
 	        {
981 1061
 	            $height=pdf_getHeightForLogo($logo);
982 1062
 	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
983
-	        }
984
-	        else
1063
+	        } else
985 1064
 	        {
986 1065
 	            $pdf->SetTextColor(200,0,0);
987 1066
 	            $pdf->SetFont('','B', $default_font_size -2);
988 1067
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
989 1068
 	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
990 1069
 	        }
991
-	    }
992
-	    else
1070
+	    } else
993 1071
 	    {
994 1072
 	        $text=$this->emetteur->name;
995 1073
 	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1032,8 +1110,7 @@  discard block
 block discarded – undo
1032 1110
 		if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1033 1111
 		{
1034 1112
 			$pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1035
-		}
1036
-		else
1113
+		} else
1037 1114
 		{
1038 1115
 			$pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R');
1039 1116
 		}
@@ -1071,8 +1148,7 @@  discard block
 block discarded – undo
1071 1148
 		{
1072 1149
 			$obj = $db->fetch_object($resqlbis);
1073 1150
 			$lastmovementdate=$db->jdate($obj->datem);
1074
-		}
1075
-		else
1151
+		} else
1076 1152
 		{
1077 1153
 			dol_print_error($db);
1078 1154
 		}
@@ -1080,8 +1156,7 @@  discard block
 block discarded – undo
1080 1156
 		if ($lastmovementdate)
1081 1157
 		{
1082 1158
 			$toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1083
-		}
1084
-		else
1159
+		} else
1085 1160
 		{
1086 1161
 			$toWrite = $outputlangs->transnoentities("None");
1087 1162
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/stock/modules_movement.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@
 block discarded – undo
30 30
  */
31 31
 abstract class ModelePDFMovement extends CommonDocGenerator
32 32
 {
33
-	/**
34
-	 * @var string Error code (or message)
35
-	 */
36
-	public $error='';
33
+    /**
34
+     * @var string Error code (or message)
35
+     */
36
+    public $error='';
37 37
 
38 38
 
39 39
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
40
-	/**
41
-	 *	Return list of active generation modules
42
-	 *
40
+    /**
41
+     *	Return list of active generation modules
42
+     *
43 43
      *  @param	DoliDB	$db     			Database handler
44 44
      *  @param  integer	$maxfilenamelength  Max length of value to show
45 45
      *  @return	array						List of templates
46
-	 */
47
-	static function liste_modeles($db,$maxfilenamelength=0)
48
-	{
46
+     */
47
+    static function liste_modeles($db,$maxfilenamelength=0)
48
+    {
49 49
         // phpcs:enable
50
-		global $conf;
50
+        global $conf;
51 51
 
52
-		$type='mouvement';
53
-		$liste=array();
54
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
56
-		return $liste;
57
-	}
52
+        $type='mouvement';
53
+        $liste=array();
54
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
56
+        return $liste;
57
+    }
58 58
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var string Error code (or message)
35 35
 	 */
36
-	public $error='';
36
+	public $error = '';
37 37
 
38 38
 
39 39
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
      *  @param  integer	$maxfilenamelength  Max length of value to show
45 45
      *  @return	array						List of templates
46 46
 	 */
47
-	static function liste_modeles($db,$maxfilenamelength=0)
47
+	static function liste_modeles($db, $maxfilenamelength = 0)
48 48
 	{
49 49
         // phpcs:enable
50 50
 		global $conf;
51 51
 
52
-		$type='mouvement';
53
-		$liste=array();
52
+		$type = 'mouvement';
53
+		$liste = array();
54 54
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
55
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
56 56
 		return $liste;
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modProjet.class.php 3 patches
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -36,332 +36,332 @@
 block discarded – undo
36 36
  */
37 37
 class modProjet extends DolibarrModules
38 38
 {
39
-	/**
40
-	 *   Constructor. Define names, constants, directories, boxes, permissions
41
-	 *
42
-	 *   @param      DoliDB		$db      Database handler
43
-	 */
44
-	function __construct($db)
45
-	{
46
-		global $conf;
47
-
48
-		$this->db = $db;
49
-		$this->numero = 400;
50
-
51
-		$this->family = "projects";
52
-		$this->module_position = '10';
53
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54
-		$this->name = preg_replace('/^mod/i','',get_class($this));
55
-		$this->description = "Gestion des projets";
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->config_page_url = array("project.php@projet");
61
-		$this->picto='project';
62
-
63
-		// Data directories to create when module is enabled
64
-		$this->dirs = array("/projet/temp");
65
-
66
-		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
-		$this->langfiles = array('projects');
73
-
74
-		// Constants
75
-		$this->const = array();
76
-		$r=0;
77
-
78
-		$this->const[$r][0] = "PROJECT_ADDON_PDF";
79
-		$this->const[$r][1] = "chaine";
80
-		$this->const[$r][2] = "baleine";
81
-		$this->const[$r][3] = 'Name of PDF/ODT project manager class';
82
-		$this->const[$r][4] = 0;
83
-		$r++;
84
-
85
-		$this->const[$r][0] = "PROJECT_ADDON";
86
-		$this->const[$r][1] = "chaine";
87
-		$this->const[$r][2] = "mod_project_simple";
88
-		$this->const[$r][3] = 'Name of Numbering Rule project manager class';
89
-		$this->const[$r][4] = 0;
90
-		$r++;
91
-
92
-		$this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH";
93
-		$this->const[$r][1] = "chaine";
94
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects";
95
-		$this->const[$r][3] = "";
96
-		$this->const[$r][4] = 0;
97
-		$r++;
98
-
99
-		$this->const[$r][0] = "PROJECT_TASK_ADDON_PDF";
100
-		$this->const[$r][1] = "chaine";
101
-		$this->const[$r][2] = "";
102
-		$this->const[$r][3] = 'Name of PDF/ODT tasks manager class';
103
-		$this->const[$r][4] = 0;
104
-		$r++;
105
-
106
-		$this->const[$r][0] = "PROJECT_TASK_ADDON";
107
-		$this->const[$r][1] = "chaine";
108
-		$this->const[$r][2] = "mod_task_simple";
109
-		$this->const[$r][3] = 'Name of Numbering Rule task manager class';
110
-		$this->const[$r][4] = 0;
111
-		$r++;
112
-
113
-		$this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH";
114
-		$this->const[$r][1] = "chaine";
115
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks";
116
-		$this->const[$r][3] = "";
117
-		$this->const[$r][4] = 0;
118
-		$r++;
119
-
120
-		$this->const[$r][0] = "PROJECT_USE_OPPORTUNITIES";
121
-		$this->const[$r][1] = "chaine";
122
-		$this->const[$r][2] = "1";
123
-		$this->const[$r][3] = "";
124
-		$this->const[$r][4] = 0;
125
-		$r++;
126
-
127
-		$this->const[$r][0] = "MAIN_DELAY_PROJECT_TO_CLOSE";
128
-		$this->const[$r][1] = "chaine";
129
-		$this->const[$r][2] = "7";
130
-		$this->const[$r][3] = "";
131
-		$this->const[$r][4] = 0;
132
-		$r++;
133
-		$this->const[$r][0] = "MAIN_DELAY_TASKS_TODO";
134
-		$this->const[$r][1] = "chaine";
135
-		$this->const[$r][2] = "7";
136
-		$this->const[$r][3] = "";
137
-		$this->const[$r][4] = 0;
138
-		$r++;
139
-
140
-		// Boxes
141
-		$this->boxes = array();
142
-		$r=0;
143
-		$this->boxes[$r][1] = "box_project.php";
144
-		$r++;
145
-		$this->boxes[$r][1] = "box_task.php";
146
-		$r++;
147
-
148
-		// Permissions
149
-		$this->rights = array();
150
-		$this->rights_class = 'projet';
151
-		$r=0;
152
-
153
-		$r++;
154
-		$this->rights[$r][0] = 41; // id de la permission
155
-		$this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
156
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
157
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
158
-		$this->rights[$r][4] = 'lire';
159
-
160
-		$r++;
161
-		$this->rights[$r][0] = 42; // id de la permission
162
-		$this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
163
-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
164
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
165
-		$this->rights[$r][4] = 'creer';
166
-
167
-		$r++;
168
-		$this->rights[$r][0] = 44; // id de la permission
169
-		$this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission
170
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
171
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
172
-		$this->rights[$r][4] = 'supprimer';
173
-
174
-		$r++;
175
-		$this->rights[$r][0] = 45; // id de la permission
176
-		$this->rights[$r][1] = "Export projects"; // libelle de la permission
177
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
178
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
179
-		$this->rights[$r][4] = 'export';
180
-
181
-		$r++;
182
-		$this->rights[$r][0] = 141; // id de la permission
183
-		$this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
184
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
185
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
186
-		$this->rights[$r][4] = 'all';
187
-		$this->rights[$r][5] = 'lire';
188
-
189
-		$r++;
190
-		$this->rights[$r][0] = 142; // id de la permission
191
-		$this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
192
-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
193
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
194
-		$this->rights[$r][4] = 'all';
195
-		$this->rights[$r][5] = 'creer';
196
-
197
-		$r++;
198
-		$this->rights[$r][0] = 144; // id de la permission
199
-		$this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
200
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
201
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
202
-		$this->rights[$r][4] = 'all';
203
-		$this->rights[$r][5] = 'supprimer';
204
-
205
-
206
-		// Menus
207
-		//-------
208
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
209
-
210
-
211
-		//Exports
212
-		//--------
213
-		$r=1;
214
-
215
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
216
-		$this->export_label[$r]='ProjectsAndTasksLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
217
-		$this->export_permission[$r]=array(array("projet","export"));
218
-		$this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
-
220
-		$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
221
-		's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
222
-		'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
223
-		'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
224
-		'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
225
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
226
-		's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
227
-
228
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
229
-		's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
-		'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description");
231
-	    // Add multicompany field
39
+    /**
40
+     *   Constructor. Define names, constants, directories, boxes, permissions
41
+     *
42
+     *   @param      DoliDB		$db      Database handler
43
+     */
44
+    function __construct($db)
45
+    {
46
+        global $conf;
47
+
48
+        $this->db = $db;
49
+        $this->numero = 400;
50
+
51
+        $this->family = "projects";
52
+        $this->module_position = '10';
53
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54
+        $this->name = preg_replace('/^mod/i','',get_class($this));
55
+        $this->description = "Gestion des projets";
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->config_page_url = array("project.php@projet");
61
+        $this->picto='project';
62
+
63
+        // Data directories to create when module is enabled
64
+        $this->dirs = array("/projet/temp");
65
+
66
+        // Dependencies
67
+        $this->hidden = false;			// A condition to hide module
68
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
70
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
+        $this->langfiles = array('projects');
73
+
74
+        // Constants
75
+        $this->const = array();
76
+        $r=0;
77
+
78
+        $this->const[$r][0] = "PROJECT_ADDON_PDF";
79
+        $this->const[$r][1] = "chaine";
80
+        $this->const[$r][2] = "baleine";
81
+        $this->const[$r][3] = 'Name of PDF/ODT project manager class';
82
+        $this->const[$r][4] = 0;
83
+        $r++;
84
+
85
+        $this->const[$r][0] = "PROJECT_ADDON";
86
+        $this->const[$r][1] = "chaine";
87
+        $this->const[$r][2] = "mod_project_simple";
88
+        $this->const[$r][3] = 'Name of Numbering Rule project manager class';
89
+        $this->const[$r][4] = 0;
90
+        $r++;
91
+
92
+        $this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH";
93
+        $this->const[$r][1] = "chaine";
94
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects";
95
+        $this->const[$r][3] = "";
96
+        $this->const[$r][4] = 0;
97
+        $r++;
98
+
99
+        $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF";
100
+        $this->const[$r][1] = "chaine";
101
+        $this->const[$r][2] = "";
102
+        $this->const[$r][3] = 'Name of PDF/ODT tasks manager class';
103
+        $this->const[$r][4] = 0;
104
+        $r++;
105
+
106
+        $this->const[$r][0] = "PROJECT_TASK_ADDON";
107
+        $this->const[$r][1] = "chaine";
108
+        $this->const[$r][2] = "mod_task_simple";
109
+        $this->const[$r][3] = 'Name of Numbering Rule task manager class';
110
+        $this->const[$r][4] = 0;
111
+        $r++;
112
+
113
+        $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH";
114
+        $this->const[$r][1] = "chaine";
115
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks";
116
+        $this->const[$r][3] = "";
117
+        $this->const[$r][4] = 0;
118
+        $r++;
119
+
120
+        $this->const[$r][0] = "PROJECT_USE_OPPORTUNITIES";
121
+        $this->const[$r][1] = "chaine";
122
+        $this->const[$r][2] = "1";
123
+        $this->const[$r][3] = "";
124
+        $this->const[$r][4] = 0;
125
+        $r++;
126
+
127
+        $this->const[$r][0] = "MAIN_DELAY_PROJECT_TO_CLOSE";
128
+        $this->const[$r][1] = "chaine";
129
+        $this->const[$r][2] = "7";
130
+        $this->const[$r][3] = "";
131
+        $this->const[$r][4] = 0;
132
+        $r++;
133
+        $this->const[$r][0] = "MAIN_DELAY_TASKS_TODO";
134
+        $this->const[$r][1] = "chaine";
135
+        $this->const[$r][2] = "7";
136
+        $this->const[$r][3] = "";
137
+        $this->const[$r][4] = 0;
138
+        $r++;
139
+
140
+        // Boxes
141
+        $this->boxes = array();
142
+        $r=0;
143
+        $this->boxes[$r][1] = "box_project.php";
144
+        $r++;
145
+        $this->boxes[$r][1] = "box_task.php";
146
+        $r++;
147
+
148
+        // Permissions
149
+        $this->rights = array();
150
+        $this->rights_class = 'projet';
151
+        $r=0;
152
+
153
+        $r++;
154
+        $this->rights[$r][0] = 41; // id de la permission
155
+        $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
156
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
157
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
158
+        $this->rights[$r][4] = 'lire';
159
+
160
+        $r++;
161
+        $this->rights[$r][0] = 42; // id de la permission
162
+        $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
163
+        $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
164
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
165
+        $this->rights[$r][4] = 'creer';
166
+
167
+        $r++;
168
+        $this->rights[$r][0] = 44; // id de la permission
169
+        $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission
170
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
171
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
172
+        $this->rights[$r][4] = 'supprimer';
173
+
174
+        $r++;
175
+        $this->rights[$r][0] = 45; // id de la permission
176
+        $this->rights[$r][1] = "Export projects"; // libelle de la permission
177
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
178
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
179
+        $this->rights[$r][4] = 'export';
180
+
181
+        $r++;
182
+        $this->rights[$r][0] = 141; // id de la permission
183
+        $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
184
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
185
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
186
+        $this->rights[$r][4] = 'all';
187
+        $this->rights[$r][5] = 'lire';
188
+
189
+        $r++;
190
+        $this->rights[$r][0] = 142; // id de la permission
191
+        $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
192
+        $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
193
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
194
+        $this->rights[$r][4] = 'all';
195
+        $this->rights[$r][5] = 'creer';
196
+
197
+        $r++;
198
+        $this->rights[$r][0] = 144; // id de la permission
199
+        $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
200
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
201
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
202
+        $this->rights[$r][4] = 'all';
203
+        $this->rights[$r][5] = 'supprimer';
204
+
205
+
206
+        // Menus
207
+        //-------
208
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
209
+
210
+
211
+        //Exports
212
+        //--------
213
+        $r=1;
214
+
215
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
216
+        $this->export_label[$r]='ProjectsAndTasksLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
217
+        $this->export_permission[$r]=array(array("projet","export"));
218
+        $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
+
220
+        $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
221
+        's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
222
+        'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
223
+        'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
224
+        'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
225
+        $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
226
+        's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
227
+
228
+        $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
229
+        's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
+        'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description");
231
+        // Add multicompany field
232 232
         if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
233 233
         {
234 234
             $nbofallowedentities=count(explode(',',getEntity('project')));    // If project are shared, nb will be > 1
235 235
             if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
236 236
         }
237
-		if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
238
-		{
239
-		    unset($this->export_fields_array[$r]['p.opp_percent']);
240
-		    unset($this->export_fields_array[$r]['p.opp_amount']);
241
-		    unset($this->export_fields_array[$r]['cls.code']);
242
-		}
243
-
244
-		// Add fields for project
245
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
246
-		// Add extra fields for project
247
-		$keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
248
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
249
-		// Add fields for tasks
237
+        if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
238
+        {
239
+            unset($this->export_fields_array[$r]['p.opp_percent']);
240
+            unset($this->export_fields_array[$r]['p.opp_amount']);
241
+            unset($this->export_fields_array[$r]['cls.code']);
242
+        }
243
+
244
+        // Add fields for project
245
+        $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
246
+        // Add extra fields for project
247
+        $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
248
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
249
+        // Add fields for tasks
250 250
         $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
251
-		$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
251
+        $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
252 252
         // Add extra fields for task
253
-		$keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
254
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
253
+        $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
254
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
255 255
         // End add extra fields
256
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
256
+        $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
257 257
         $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
258 258
 
259 259
         $this->export_sql_start[$r]='SELECT DISTINCT ';
260
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'projet as p';
260
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'projet as p';
261 261
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
262 262
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
263 263
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
264 264
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
265
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
-		$this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")";
268
-
269
-
270
-		// Import list of tasks
271
-		if (empty($conf->global->PROJECT_HIDE_TASKS))
272
-		{
273
-    		$r++;
274
-    		$this->import_code[$r]='tasksofprojects';
275
-    		$this->import_label[$r]='ImportDatasetTasks';
276
-    		$this->import_icon[$r]='task';
277
-    		$this->import_entities_array[$r]=array('t.fk_projet'=>'project');	// We define here only fields that use another icon that the one defined into import_icon
278
-    		$this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields');	// List of tables to insert into (insert done in same order)
279
-    		$this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation");
280
-    		// Add extra fields
281
-    		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
-    		$resql=$this->db->query($sql);
283
-    		if ($resql)    // This can fail when class is used on old database (during migration for example)
284
-    		{
285
-    		    while ($obj=$this->db->fetch_object($resql))
286
-    		    {
287
-    		        $fieldname='extra.'.$obj->name;
288
-    		        $fieldlabel=ucfirst($obj->label);
289
-    		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
290
-    		    }
291
-    		}
292
-    		// End add extra fields
293
-    		$this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
-    		$this->import_convertvalue_array[$r]=array(
295
-    		    't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'),
296
-    		    't.ref'=>array('rule'=>'getrefifauto')
297
-    		);
298
-    		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
299
-    		$this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
-    		$this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note");
301
-		}
302
-	}
303
-
304
-
305
-	/**
306
-	 *		Function called when module is enabled.
307
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
308
-	 *		It also creates data directories
309
-	 *
265
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
+        $this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")";
268
+
269
+
270
+        // Import list of tasks
271
+        if (empty($conf->global->PROJECT_HIDE_TASKS))
272
+        {
273
+            $r++;
274
+            $this->import_code[$r]='tasksofprojects';
275
+            $this->import_label[$r]='ImportDatasetTasks';
276
+            $this->import_icon[$r]='task';
277
+            $this->import_entities_array[$r]=array('t.fk_projet'=>'project');	// We define here only fields that use another icon that the one defined into import_icon
278
+            $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields');	// List of tables to insert into (insert done in same order)
279
+            $this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation");
280
+            // Add extra fields
281
+            $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
+            $resql=$this->db->query($sql);
283
+            if ($resql)    // This can fail when class is used on old database (during migration for example)
284
+            {
285
+                while ($obj=$this->db->fetch_object($resql))
286
+                {
287
+                    $fieldname='extra.'.$obj->name;
288
+                    $fieldlabel=ucfirst($obj->label);
289
+                    $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
290
+                }
291
+            }
292
+            // End add extra fields
293
+            $this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
+            $this->import_convertvalue_array[$r]=array(
295
+                't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'),
296
+                't.ref'=>array('rule'=>'getrefifauto')
297
+            );
298
+            //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
299
+            $this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
+            $this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note");
301
+        }
302
+    }
303
+
304
+
305
+    /**
306
+     *		Function called when module is enabled.
307
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
308
+     *		It also creates data directories
309
+     *
310 310
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
311
-	 *      @return     int             	1 if OK, 0 if KO
312
-	 */
313
-	function init($options='')
314
-	{
315
-		global $conf,$langs;
316
-
317
-		// Permissions
318
-		$this->remove($options);
319
-
320
-		//ODT template for project
321
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/projects';
323
-		$dest=$dirodt.'/template_project.odt';
324
-
325
-		if (file_exists($src) && ! file_exists($dest))
326
-		{
327
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
328
-			dol_mkdir($dirodt);
329
-			$result=dol_copy($src,$dest,0,0);
330
-			if ($result < 0)
331
-			{
332
-				$langs->load("errors");
333
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
334
-				return 0;
335
-			}
336
-		}
337
-
338
-		//ODT template for tasks
339
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/tasks';
341
-		$dest=$dirodt.'/template_task_summary.odt';
342
-
343
-		if (file_exists($src) && ! file_exists($dest))
344
-		{
345
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
346
-			dol_mkdir($dirodt);
347
-			$result=dol_copy($src,$dest,0,0);
348
-			if ($result < 0)
349
-			{
350
-				$langs->load("errors");
351
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
352
-				return 0;
353
-			}
354
-		}
355
-
356
-		$sql = array();
357
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
363
-
364
-
365
-		return $this->_init($sql,$options);
366
-	}
311
+     *      @return     int             	1 if OK, 0 if KO
312
+     */
313
+    function init($options='')
314
+    {
315
+        global $conf,$langs;
316
+
317
+        // Permissions
318
+        $this->remove($options);
319
+
320
+        //ODT template for project
321
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/projects';
323
+        $dest=$dirodt.'/template_project.odt';
324
+
325
+        if (file_exists($src) && ! file_exists($dest))
326
+        {
327
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
328
+            dol_mkdir($dirodt);
329
+            $result=dol_copy($src,$dest,0,0);
330
+            if ($result < 0)
331
+            {
332
+                $langs->load("errors");
333
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
334
+                return 0;
335
+            }
336
+        }
337
+
338
+        //ODT template for tasks
339
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/tasks';
341
+        $dest=$dirodt.'/template_task_summary.odt';
342
+
343
+        if (file_exists($src) && ! file_exists($dest))
344
+        {
345
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
346
+            dol_mkdir($dirodt);
347
+            $result=dol_copy($src,$dest,0,0);
348
+            if ($result < 0)
349
+            {
350
+                $langs->load("errors");
351
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
352
+                return 0;
353
+            }
354
+        }
355
+
356
+        $sql = array();
357
+        $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
+        $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
+        $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
+        $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
+        $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
+        $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
363
+
364
+
365
+        return $this->_init($sql,$options);
366
+    }
367 367
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  *	\ingroup    projet
29 29
  *	\brief      Fichier de description et activation du module Projet
30 30
  */
31
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
31
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32 32
 
33 33
 
34 34
 /**
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 		$this->family = "projects";
52 52
 		$this->module_position = '10';
53 53
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
55 55
 		$this->description = "Gestion des projets";
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		$this->config_page_url = array("project.php@projet");
61
-		$this->picto='project';
61
+		$this->picto = 'project';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array("/projet/temp");
65 65
 
66 66
 		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
67
+		$this->hidden = false; // A condition to hide module
68
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
69
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
70
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
71
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
72 72
 		$this->langfiles = array('projects');
73 73
 
74 74
 		// Constants
75 75
 		$this->const = array();
76
-		$r=0;
76
+		$r = 0;
77 77
 
78 78
 		$this->const[$r][0] = "PROJECT_ADDON_PDF";
79 79
 		$this->const[$r][1] = "chaine";
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		// Boxes
141 141
 		$this->boxes = array();
142
-		$r=0;
142
+		$r = 0;
143 143
 		$this->boxes[$r][1] = "box_project.php";
144 144
 		$r++;
145 145
 		$this->boxes[$r][1] = "box_task.php";
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		// Permissions
149 149
 		$this->rights = array();
150 150
 		$this->rights_class = 'projet';
151
-		$r=0;
151
+		$r = 0;
152 152
 
153 153
 		$r++;
154 154
 		$this->rights[$r][0] = 41; // id de la permission
@@ -205,34 +205,34 @@  discard block
 block discarded – undo
205 205
 
206 206
 		// Menus
207 207
 		//-------
208
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
208
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
209 209
 
210 210
 
211 211
 		//Exports
212 212
 		//--------
213
-		$r=1;
214
-
215
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
216
-		$this->export_label[$r]='ProjectsAndTasksLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
217
-		$this->export_permission[$r]=array(array("projet","export"));
218
-		$this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
-
220
-		$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
221
-		's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
222
-		'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
223
-		'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
224
-		'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
225
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
226
-		's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
227
-
228
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
229
-		's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
-		'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description");
213
+		$r = 1;
214
+
215
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
216
+		$this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
217
+		$this->export_permission[$r] = array(array("projet", "export"));
218
+		$this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
219
+
220
+		$this->export_TypeFields_array[$r] = array('s.rowid'=>"List:societe:nom", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
221
+		's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
222
+		'p.rowid'=>"List:projet:ref", 'p.ref'=>"Text", 'p.title'=>"Text", 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric',
223
+		'pt.rowid'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text",
224
+		'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text");
225
+		$this->export_entities_array[$r] = array('s.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
226
+		's.phone'=>'company', 's.email'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company');
227
+
228
+		$this->export_fields_array[$r] = array('s.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
229
+		's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
230
+		'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description");
231 231
 	    // Add multicompany field
232
-        if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
232
+        if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
233 233
         {
234
-            $nbofallowedentities=count(explode(',',getEntity('project')));    // If project are shared, nb will be > 1
235
-            if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
234
+            $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
235
+            if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity');
236 236
         }
237 237
 		if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
238 238
 		{
@@ -242,62 +242,62 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 
244 244
 		// Add fields for project
245
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
245
+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
246 246
 		// Add extra fields for project
247
-		$keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
247
+		$keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra';
248 248
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
249 249
 		// Add fields for tasks
250
-        $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
251
-		$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
250
+        $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
251
+		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
252 252
         // Add extra fields for task
253
-		$keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
253
+		$keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2';
254 254
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
255 255
         // End add extra fields
256
-		$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
257
-        $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
256
+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));
257
+        $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));
258 258
 
259
-        $this->export_sql_start[$r]='SELECT DISTINCT ';
260
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'projet as p';
261
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
262
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
263
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
264
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
265
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
-		$this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")";
259
+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
260
+		$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
261
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
262
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
263
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
264
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
265
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
266
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
267
+		$this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
268 268
 
269 269
 
270 270
 		// Import list of tasks
271 271
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
272 272
 		{
273 273
     		$r++;
274
-    		$this->import_code[$r]='tasksofprojects';
275
-    		$this->import_label[$r]='ImportDatasetTasks';
276
-    		$this->import_icon[$r]='task';
277
-    		$this->import_entities_array[$r]=array('t.fk_projet'=>'project');	// We define here only fields that use another icon that the one defined into import_icon
278
-    		$this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields');	// List of tables to insert into (insert done in same order)
279
-    		$this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation");
274
+    		$this->import_code[$r] = 'tasksofprojects';
275
+    		$this->import_label[$r] = 'ImportDatasetTasks';
276
+    		$this->import_icon[$r] = 'task';
277
+    		$this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon
278
+    		$this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)
279
+    		$this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");
280 280
     		// Add extra fields
281
-    		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
-    		$resql=$this->db->query($sql);
281
+    		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282
+    		$resql = $this->db->query($sql);
283 283
     		if ($resql)    // This can fail when class is used on old database (during migration for example)
284 284
     		{
285
-    		    while ($obj=$this->db->fetch_object($resql))
285
+    		    while ($obj = $this->db->fetch_object($resql))
286 286
     		    {
287
-    		        $fieldname='extra.'.$obj->name;
288
-    		        $fieldlabel=ucfirst($obj->label);
289
-    		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
287
+    		        $fieldname = 'extra.'.$obj->name;
288
+    		        $fieldlabel = ucfirst($obj->label);
289
+    		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
290 290
     		    }
291 291
     		}
292 292
     		// End add extra fields
293
-    		$this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
-    		$this->import_convertvalue_array[$r]=array(
295
-    		    't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'),
293
+    		$this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
294
+    		$this->import_convertvalue_array[$r] = array(
295
+    		    't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
296 296
     		    't.ref'=>array('rule'=>'getrefifauto')
297 297
     		);
298 298
     		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
299
-    		$this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
-    		$this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note");
299
+    		$this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
300
+    		$this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");
301 301
 		}
302 302
 	}
303 303
 
@@ -310,58 +310,58 @@  discard block
 block discarded – undo
310 310
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
311 311
 	 *      @return     int             	1 if OK, 0 if KO
312 312
 	 */
313
-	function init($options='')
313
+	function init($options = '')
314 314
 	{
315
-		global $conf,$langs;
315
+		global $conf, $langs;
316 316
 
317 317
 		// Permissions
318 318
 		$this->remove($options);
319 319
 
320 320
 		//ODT template for project
321
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/projects';
323
-		$dest=$dirodt.'/template_project.odt';
321
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
322
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
323
+		$dest = $dirodt.'/template_project.odt';
324 324
 
325
-		if (file_exists($src) && ! file_exists($dest))
325
+		if (file_exists($src) && !file_exists($dest))
326 326
 		{
327 327
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
328 328
 			dol_mkdir($dirodt);
329
-			$result=dol_copy($src,$dest,0,0);
329
+			$result = dol_copy($src, $dest, 0, 0);
330 330
 			if ($result < 0)
331 331
 			{
332 332
 				$langs->load("errors");
333
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
333
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
334 334
 				return 0;
335 335
 			}
336 336
 		}
337 337
 
338 338
 		//ODT template for tasks
339
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/tasks';
341
-		$dest=$dirodt.'/template_task_summary.odt';
339
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
340
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
341
+		$dest = $dirodt.'/template_task_summary.odt';
342 342
 
343
-		if (file_exists($src) && ! file_exists($dest))
343
+		if (file_exists($src) && !file_exists($dest))
344 344
 		{
345 345
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
346 346
 			dol_mkdir($dirodt);
347
-			$result=dol_copy($src,$dest,0,0);
347
+			$result = dol_copy($src, $dest, 0, 0);
348 348
 			if ($result < 0)
349 349
 			{
350 350
 				$langs->load("errors");
351
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
351
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
352 352
 				return 0;
353 353
 			}
354 354
 		}
355 355
 
356 356
 		$sql = array();
357
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
-		$sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
-		$sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
357
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
358
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
359
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
360
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
361
+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
362
+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
363 363
 
364 364
 
365
-		return $this->_init($sql,$options);
365
+		return $this->_init($sql, $options);
366 366
 	}
367 367
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -232,7 +232,9 @@  discard block
 block discarded – undo
232 232
         if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
233 233
         {
234 234
             $nbofallowedentities=count(explode(',',getEntity('project')));    // If project are shared, nb will be > 1
235
-            if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
235
+            if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
236
+                $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
237
+            }
236 238
         }
237 239
 		if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
238 240
 		{
@@ -280,11 +282,13 @@  discard block
 block discarded – undo
280 282
     		// Add extra fields
281 283
     		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
282 284
     		$resql=$this->db->query($sql);
283
-    		if ($resql)    // This can fail when class is used on old database (during migration for example)
285
+    		if ($resql) {
286
+    		    // This can fail when class is used on old database (during migration for example)
284 287
     		{
285 288
     		    while ($obj=$this->db->fetch_object($resql))
286 289
     		    {
287 290
     		        $fieldname='extra.'.$obj->name;
291
+    		}
288 292
     		        $fieldlabel=ucfirst($obj->label);
289 293
     		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
290 294
     		    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modFournisseur.class.php 3 patches
Indentation   +568 added lines, -568 removed lines patch added patch discarded remove patch
@@ -35,67 +35,67 @@  discard block
 block discarded – undo
35 35
 class modFournisseur 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, $user;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 40;
49
-
50
-		// Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
51
-		// It is used to group modules in module setup page
52
-		$this->family = "srm";
53
-		$this->module_position = '10';
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
-		$this->description = "Gestion des fournisseurs";
57
-
58
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
-		$this->version = 'dolibarr';
60
-
61
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		$this->picto='company';
63
-
64
-		// Data directories to create when module is enabled
65
-		$this->dirs = array("/fournisseur/temp",
66
-							"/fournisseur/commande",
67
-		                    "/fournisseur/commande/temp",
68
-		                    "/fournisseur/facture",
69
-		                    "/fournisseur/facture/temp"
70
-		                    );
71
-
72
-		// Dependencies
73
-		$this->depends = array("modSociete");
74
-		$this->requiredby = array();
75
-		$this->langfiles = array('bills', 'companies', 'suppliers', 'orders', 'sendings');
76
-
77
-		// Config pages
78
-		$this->config_page_url = array("supplier_order.php");
79
-
80
-		// Constants
81
-		$this->const = array();
82
-		$r=0;
83
-
84
-		$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
85
-		$this->const[$r][1] = "chaine";
86
-		$this->const[$r][2] = "muscadet";
87
-		$this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF';
88
-		$this->const[$r][4] = 0;
89
-		$r++;
90
-
91
-		$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_NUMBER";
92
-		$this->const[$r][1] = "chaine";
93
-		$this->const[$r][2] = "mod_commande_fournisseur_muguet";
94
-		$this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes fournisseur';
95
-		$this->const[$r][4] = 0;
96
-		$r++;
97
-
98
-		/* For supplier invoice, we must not have default pdf template on. In most cases, we need to join PDF from supplier, not have a document generated.
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, $user;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 40;
49
+
50
+        // Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
51
+        // It is used to group modules in module setup page
52
+        $this->family = "srm";
53
+        $this->module_position = '10';
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
+        $this->description = "Gestion des fournisseurs";
57
+
58
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
+        $this->version = 'dolibarr';
60
+
61
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
+        $this->picto='company';
63
+
64
+        // Data directories to create when module is enabled
65
+        $this->dirs = array("/fournisseur/temp",
66
+                            "/fournisseur/commande",
67
+                            "/fournisseur/commande/temp",
68
+                            "/fournisseur/facture",
69
+                            "/fournisseur/facture/temp"
70
+                            );
71
+
72
+        // Dependencies
73
+        $this->depends = array("modSociete");
74
+        $this->requiredby = array();
75
+        $this->langfiles = array('bills', 'companies', 'suppliers', 'orders', 'sendings');
76
+
77
+        // Config pages
78
+        $this->config_page_url = array("supplier_order.php");
79
+
80
+        // Constants
81
+        $this->const = array();
82
+        $r=0;
83
+
84
+        $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
85
+        $this->const[$r][1] = "chaine";
86
+        $this->const[$r][2] = "muscadet";
87
+        $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF';
88
+        $this->const[$r][4] = 0;
89
+        $r++;
90
+
91
+        $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_NUMBER";
92
+        $this->const[$r][1] = "chaine";
93
+        $this->const[$r][2] = "mod_commande_fournisseur_muguet";
94
+        $this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes fournisseur';
95
+        $this->const[$r][4] = 0;
96
+        $r++;
97
+
98
+        /* For supplier invoice, we must not have default pdf template on. In most cases, we need to join PDF from supplier, not have a document generated.
99 99
 		$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF";
100 100
 		$this->const[$r][1] = "chaine";
101 101
 		$this->const[$r][2] = "canelle";
@@ -104,84 +104,84 @@  discard block
 block discarded – undo
104 104
 		$r++;
105 105
 		*/
106 106
 
107
-		$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER";
108
-		$this->const[$r][1] = "chaine";
109
-		$this->const[$r][2] = "mod_facture_fournisseur_cactus";
110
-		$this->const[$r][3] = 'Nom du gestionnaire de numerotation des factures fournisseur';
111
-		$this->const[$r][4] = 0;
112
-		$r++;
113
-
114
-		// Boxes
115
-		$this->boxes = array(
116
-		0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
117
-		1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'),
118
-		2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
119
-		3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
120
-		4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
121
-		5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
122
-		);
123
-
124
-		// Permissions
125
-		$this->rights = array();
126
-		$this->rights_class = 'fournisseur';
127
-		$r=0;
128
-
129
-		$r++;
130
-		$this->rights[$r][0] = 1181;
131
-		$this->rights[$r][1] = 'Consulter les fournisseurs';
132
-		$this->rights[$r][2] = 'r';
133
-		$this->rights[$r][3] = 0;
134
-		$this->rights[$r][4] = 'lire';
107
+        $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER";
108
+        $this->const[$r][1] = "chaine";
109
+        $this->const[$r][2] = "mod_facture_fournisseur_cactus";
110
+        $this->const[$r][3] = 'Nom du gestionnaire de numerotation des factures fournisseur';
111
+        $this->const[$r][4] = 0;
112
+        $r++;
113
+
114
+        // Boxes
115
+        $this->boxes = array(
116
+        0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
117
+        1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'),
118
+        2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
119
+        3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
120
+        4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
121
+        5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
122
+        );
123
+
124
+        // Permissions
125
+        $this->rights = array();
126
+        $this->rights_class = 'fournisseur';
127
+        $r=0;
128
+
129
+        $r++;
130
+        $this->rights[$r][0] = 1181;
131
+        $this->rights[$r][1] = 'Consulter les fournisseurs';
132
+        $this->rights[$r][2] = 'r';
133
+        $this->rights[$r][3] = 0;
134
+        $this->rights[$r][4] = 'lire';
135 135
 
136
-		$r++;
137
-		$this->rights[$r][0] = 1182;
138
-		$this->rights[$r][1] = 'Consulter les commandes fournisseur';
139
-		$this->rights[$r][2] = 'r';
140
-		$this->rights[$r][3] = 0;
141
-		$this->rights[$r][4] = 'commande';
142
-		$this->rights[$r][5] = 'lire';
136
+        $r++;
137
+        $this->rights[$r][0] = 1182;
138
+        $this->rights[$r][1] = 'Consulter les commandes fournisseur';
139
+        $this->rights[$r][2] = 'r';
140
+        $this->rights[$r][3] = 0;
141
+        $this->rights[$r][4] = 'commande';
142
+        $this->rights[$r][5] = 'lire';
143 143
 
144
-		$r++;
145
-		$this->rights[$r][0] = 1183;
146
-		$this->rights[$r][1] = 'Creer une commande fournisseur';
147
-		$this->rights[$r][2] = 'w';
148
-		$this->rights[$r][3] = 0;
149
-		$this->rights[$r][4] = 'commande';
150
-		$this->rights[$r][5] = 'creer';
144
+        $r++;
145
+        $this->rights[$r][0] = 1183;
146
+        $this->rights[$r][1] = 'Creer une commande fournisseur';
147
+        $this->rights[$r][2] = 'w';
148
+        $this->rights[$r][3] = 0;
149
+        $this->rights[$r][4] = 'commande';
150
+        $this->rights[$r][5] = 'creer';
151 151
 
152
-		$r++;
153
-		$this->rights[$r][0] = 1184;
154
-		$this->rights[$r][1] = 'Valider une commande fournisseur';
155
-		$this->rights[$r][2] = 'w';
156
-		$this->rights[$r][3] = 0;
157
-		$this->rights[$r][4] = 'supplier_order_advance';
158
-		$this->rights[$r][5] = 'validate';
152
+        $r++;
153
+        $this->rights[$r][0] = 1184;
154
+        $this->rights[$r][1] = 'Valider une commande fournisseur';
155
+        $this->rights[$r][2] = 'w';
156
+        $this->rights[$r][3] = 0;
157
+        $this->rights[$r][4] = 'supplier_order_advance';
158
+        $this->rights[$r][5] = 'validate';
159 159
 
160
-		$r++;
161
-		$this->rights[$r][0] = 1185;
162
-		$this->rights[$r][1] = 'Approuver une commande fournisseur';
163
-		$this->rights[$r][2] = 'w';
164
-		$this->rights[$r][3] = 0;
165
-		$this->rights[$r][4] = 'commande';
166
-		$this->rights[$r][5] = 'approuver';
160
+        $r++;
161
+        $this->rights[$r][0] = 1185;
162
+        $this->rights[$r][1] = 'Approuver une commande fournisseur';
163
+        $this->rights[$r][2] = 'w';
164
+        $this->rights[$r][3] = 0;
165
+        $this->rights[$r][4] = 'commande';
166
+        $this->rights[$r][5] = 'approuver';
167 167
 
168
-		$r++;
169
-		$this->rights[$r][0] = 1186;
170
-		$this->rights[$r][1] = 'Commander une commande fournisseur';
171
-		$this->rights[$r][2] = 'w';
172
-		$this->rights[$r][3] = 0;
173
-		$this->rights[$r][4] = 'commande';
174
-		$this->rights[$r][5] = 'commander';
168
+        $r++;
169
+        $this->rights[$r][0] = 1186;
170
+        $this->rights[$r][1] = 'Commander une commande fournisseur';
171
+        $this->rights[$r][2] = 'w';
172
+        $this->rights[$r][3] = 0;
173
+        $this->rights[$r][4] = 'commande';
174
+        $this->rights[$r][5] = 'commander';
175 175
 
176
-		$r++;
177
-		$this->rights[$r][0] = 1187;
178
-		$this->rights[$r][1] = 'Receptionner une commande fournisseur';
179
-		$this->rights[$r][2] = 'd';
180
-		$this->rights[$r][3] = 0;
181
-		$this->rights[$r][4] = 'commande';
182
-		$this->rights[$r][5] = 'receptionner';
176
+        $r++;
177
+        $this->rights[$r][0] = 1187;
178
+        $this->rights[$r][1] = 'Receptionner une commande fournisseur';
179
+        $this->rights[$r][2] = 'd';
180
+        $this->rights[$r][3] = 0;
181
+        $this->rights[$r][4] = 'commande';
182
+        $this->rights[$r][5] = 'receptionner';
183 183
 
184
-		$r++;
184
+        $r++;
185 185
         $this->rights[$r][0] = 1189;
186 186
         $this->rights[$r][1] = 'Check/Uncheck a supplier order reception';
187 187
         $this->rights[$r][2] = 'w';
@@ -189,451 +189,451 @@  discard block
 block discarded – undo
189 189
         $this->rights[$r][4] = 'commande_advance';
190 190
         $this->rights[$r][5] = 'check';
191 191
 
192
-		$r++;
193
-		$this->rights[$r][0] = 1188;
194
-		$this->rights[$r][1] = 'Supprimer une commande fournisseur';
195
-		$this->rights[$r][2] = 'd';
196
-		$this->rights[$r][3] = 0;
197
-		$this->rights[$r][4] = 'commande';
198
-		$this->rights[$r][5] = 'supprimer';
199
-
200
-		if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
201
-		{
202
-			$r++;
203
-			$this->rights[$r][0] = 1190;
204
-			$this->rights[$r][1] = 'Approve supplier order (second level)';		// $langs->trans("Permission1190");
205
-			$this->rights[$r][2] = 'w';
206
-			$this->rights[$r][3] = 0;
207
-			$this->rights[$r][4] = 'commande';
208
-			$this->rights[$r][5] = 'approve2';
209
-		}
210
-
211
-		$r++;
212
-		$this->rights[$r][0] = 1191;
213
-		$this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs';
214
-		$this->rights[$r][2] = 'r';
215
-		$this->rights[$r][3] = 0;
216
-		$this->rights[$r][4] = 'commande';
217
-		$this->rights[$r][5] = 'export';
218
-
219
-		$r++;
220
-		$this->rights[$r][0] = 1231;
221
-		$this->rights[$r][1] = 'Consulter les factures fournisseur';
222
-		$this->rights[$r][2] = 'r';
223
-		$this->rights[$r][3] = 0;
224
-		$this->rights[$r][4] = 'facture';
225
-		$this->rights[$r][5] = 'lire';
226
-
227
-		$r++;
228
-		$this->rights[$r][0] = 1232;
229
-		$this->rights[$r][1] = 'Creer une facture fournisseur';
230
-		$this->rights[$r][2] = 'w';
231
-		$this->rights[$r][3] = 0;
232
-		$this->rights[$r][4] = 'facture';
233
-		$this->rights[$r][5] = 'creer';
234
-
235
-		$r++;
236
-		$this->rights[$r][0] = 1233;
237
-		$this->rights[$r][1] = 'Valider une facture fournisseur';
238
-		$this->rights[$r][2] = 'w';
239
-		$this->rights[$r][3] = 0;
240
-		$this->rights[$r][4] = 'supplier_invoice_advance';
241
-		$this->rights[$r][5] = 'validate';
242
-
243
-		$r++;
244
-		$this->rights[$r][0] = 1234;
245
-		$this->rights[$r][1] = 'Supprimer une facture fournisseur';
246
-		$this->rights[$r][2] = 'd';
247
-		$this->rights[$r][3] = 0;
248
-		$this->rights[$r][4] = 'facture';
249
-		$this->rights[$r][5] = 'supprimer';
250
-
251
-		$r++;
252
-		$this->rights[$r][0] = 1235;
253
-		$this->rights[$r][1] = 'Envoyer les factures par mail';
254
-		$this->rights[$r][2] = 'a';
255
-		$this->rights[$r][3] = 0;
256
-		$this->rights[$r][4] = 'supplier_invoice_advance';
257
-		$this->rights[$r][5] = 'send';
258
-
259
-		$r++;
260
-		$this->rights[$r][0] = 1236;
261
-		$this->rights[$r][1] = 'Exporter les factures fournisseurs, attributs et reglements';
262
-		$this->rights[$r][2] = 'r';
263
-		$this->rights[$r][3] = 0;
264
-		$this->rights[$r][4] = 'facture';
265
-		$this->rights[$r][5] = 'export';
192
+        $r++;
193
+        $this->rights[$r][0] = 1188;
194
+        $this->rights[$r][1] = 'Supprimer une commande fournisseur';
195
+        $this->rights[$r][2] = 'd';
196
+        $this->rights[$r][3] = 0;
197
+        $this->rights[$r][4] = 'commande';
198
+        $this->rights[$r][5] = 'supprimer';
199
+
200
+        if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
201
+        {
202
+            $r++;
203
+            $this->rights[$r][0] = 1190;
204
+            $this->rights[$r][1] = 'Approve supplier order (second level)';		// $langs->trans("Permission1190");
205
+            $this->rights[$r][2] = 'w';
206
+            $this->rights[$r][3] = 0;
207
+            $this->rights[$r][4] = 'commande';
208
+            $this->rights[$r][5] = 'approve2';
209
+        }
210
+
211
+        $r++;
212
+        $this->rights[$r][0] = 1191;
213
+        $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs';
214
+        $this->rights[$r][2] = 'r';
215
+        $this->rights[$r][3] = 0;
216
+        $this->rights[$r][4] = 'commande';
217
+        $this->rights[$r][5] = 'export';
266 218
 
219
+        $r++;
220
+        $this->rights[$r][0] = 1231;
221
+        $this->rights[$r][1] = 'Consulter les factures fournisseur';
222
+        $this->rights[$r][2] = 'r';
223
+        $this->rights[$r][3] = 0;
224
+        $this->rights[$r][4] = 'facture';
225
+        $this->rights[$r][5] = 'lire';
267 226
 
268
-	    // Menus
269
-	    //-------
270
-	    $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
227
+        $r++;
228
+        $this->rights[$r][0] = 1232;
229
+        $this->rights[$r][1] = 'Creer une facture fournisseur';
230
+        $this->rights[$r][2] = 'w';
231
+        $this->rights[$r][3] = 0;
232
+        $this->rights[$r][4] = 'facture';
233
+        $this->rights[$r][5] = 'creer';
271 234
 
235
+        $r++;
236
+        $this->rights[$r][0] = 1233;
237
+        $this->rights[$r][1] = 'Valider une facture fournisseur';
238
+        $this->rights[$r][2] = 'w';
239
+        $this->rights[$r][3] = 0;
240
+        $this->rights[$r][4] = 'supplier_invoice_advance';
241
+        $this->rights[$r][5] = 'validate';
272 242
 
273
-		// Exports
274
-		//--------
275
-		$r=0;
243
+        $r++;
244
+        $this->rights[$r][0] = 1234;
245
+        $this->rights[$r][1] = 'Supprimer une facture fournisseur';
246
+        $this->rights[$r][2] = 'd';
247
+        $this->rights[$r][3] = 0;
248
+        $this->rights[$r][4] = 'facture';
249
+        $this->rights[$r][5] = 'supprimer';
276 250
 
277
-		$r++;
278
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
279
-		$this->export_label[$r]='Factures fournisseurs et lignes de facture';
280
-		$this->export_icon[$r]='bill';
281
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
282
-		$this->export_fields_array[$r]=array(
283
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
284
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
285
-			'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment',
286
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",
287
-			'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",
288
-			'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
289
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId',
290
-			'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
291
-		);
292
-		//$this->export_TypeFields_array[$r]=array(
293
-		//    's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
294
-		//    's.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",
295
-		//    'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
296
-		//     'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
297
-		//);
298
-		$this->export_TypeFields_array[$r]=array(
299
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
300
-			's.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date','f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",
301
-			'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",
302
-			'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
303
-			'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
304
-		);
305
-		$this->export_entities_array[$r]=array(
306
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company',
307
-			's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",
308
-			'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',
309
-			'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",
310
-			'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product',
311
-			'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
312
-		);
313
-		$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
314
-		// Add extra fields object
315
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
-		$resql=$this->db->query($sql);
317
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
318
-		{
319
-			while ($obj=$this->db->fetch_object($resql))
320
-			{
321
-				$fieldname='extra.'.$obj->name;
322
-				$fieldlabel=ucfirst($obj->label);
323
-				$typeFilter="Text";
324
-				switch($obj->type)
325
-				{
326
-					case 'int':
327
-					case 'double':
328
-					case 'price':
329
-						$typeFilter="Numeric";
330
-						break;
331
-					case 'date':
332
-					case 'datetime':
333
-						$typeFilter="Date";
334
-						break;
335
-					case 'boolean':
336
-						$typeFilter="Boolean";
337
-						break;
338
-					case 'sellist':
339
-						$tmp='';
340
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
342
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
343
-						break;
344
-				}
345
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
346
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
347
-				$this->export_entities_array[$r][$fieldname]='invoice';
348
-			}
349
-		}
350
-		// End add extra fields
351
-		// Add extra fields line
352
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
-		$resql=$this->db->query($sql);
354
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
355
-		{
356
-			while ($obj=$this->db->fetch_object($resql))
357
-			{
358
-				$fieldname='extraline.'.$obj->name;
359
-				$fieldlabel=ucfirst($obj->label);
360
-				$typeFilter="Text";
361
-				switch($obj->type)
362
-				{
363
-					case 'int':
364
-					case 'double':
365
-					case 'price':
366
-						$typeFilter="Numeric";
367
-						break;
368
-					case 'date':
369
-					case 'datetime':
370
-						$typeFilter="Date";
371
-						break;
372
-					case 'boolean':
373
-						$typeFilter="Boolean";
374
-						break;
375
-					case 'sellist':
376
-						$tmp='';
377
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
379
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
380
-						break;
381
-				}
382
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
383
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
384
-				$this->export_entities_array[$r][$fieldname]='invoice_line';
385
-			}
386
-		}
387
-		// End add extra fields line
388
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
389
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
390
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
251
+        $r++;
252
+        $this->rights[$r][0] = 1235;
253
+        $this->rights[$r][1] = 'Envoyer les factures par mail';
254
+        $this->rights[$r][2] = 'a';
255
+        $this->rights[$r][3] = 0;
256
+        $this->rights[$r][4] = 'supplier_invoice_advance';
257
+        $this->rights[$r][5] = 'send';
401 258
 
402
-		$r++;
403
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
404
-		$this->export_label[$r]='Factures fournisseurs et reglements';
405
-		$this->export_icon[$r]='bill';
406
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
407
-		$this->export_fields_array[$r]=array(
408
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
409
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
410
-			's.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",
411
-			'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",
412
-			'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment',
413
-			'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
414
-		);
415
-		//$this->export_TypeFields_array[$r]=array(
416
-		//	's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
417
-		//	's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",
418
-		//	'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
419
-		//	'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
420
-		//);
421
-		$this->export_TypeFields_array[$r]=array(
422
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text',
423
-			's.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",
424
-			'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric',
425
-			'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text'
426
-		);
427
-		$this->export_entities_array[$r]=array(
428
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company',
429
-			's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company',
430
-			'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",
431
-			'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment',
432
-		    'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');
433
-		$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
434
-		// Add extra fields object
435
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
-		$resql=$this->db->query($sql);
437
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
438
-		{
439
-			while ($obj=$this->db->fetch_object($resql))
440
-			{
441
-				$fieldname='extra.'.$obj->name;
442
-				$fieldlabel=ucfirst($obj->label);
443
-				$typeFilter="Text";
444
-				switch($obj->type)
445
-				{
446
-					case 'int':
447
-					case 'double':
448
-					case 'price':
449
-						$typeFilter="Numeric";
450
-						break;
451
-					case 'date':
452
-					case 'datetime':
453
-						$typeFilter="Date";
454
-						break;
455
-					case 'boolean':
456
-						$typeFilter="Boolean";
457
-						break;
458
-					case 'sellist':
459
-						$tmp='';
460
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
462
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
463
-						break;
464
-				}
465
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
466
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
467
-				$this->export_entities_array[$r][$fieldname]='invoice';
468
-			}
469
-		}
470
-		// End add extra fields object
471
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
472
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
473
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
259
+        $r++;
260
+        $this->rights[$r][0] = 1236;
261
+        $this->rights[$r][1] = 'Exporter les factures fournisseurs, attributs et reglements';
262
+        $this->rights[$r][2] = 'r';
263
+        $this->rights[$r][3] = 0;
264
+        $this->rights[$r][4] = 'facture';
265
+        $this->rights[$r][5] = 'export';
266
+
267
+
268
+        // Menus
269
+        //-------
270
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
271
+
272
+
273
+        // Exports
274
+        //--------
275
+        $r=0;
276
+
277
+        $r++;
278
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
279
+        $this->export_label[$r]='Factures fournisseurs et lignes de facture';
280
+        $this->export_icon[$r]='bill';
281
+        $this->export_permission[$r]=array(array("fournisseur","facture","export"));
282
+        $this->export_fields_array[$r]=array(
283
+            's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
284
+            's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
285
+            'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment',
286
+            'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",
287
+            'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",
288
+            'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
289
+            'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId',
290
+            'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
291
+        );
292
+        //$this->export_TypeFields_array[$r]=array(
293
+        //    's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
294
+        //    's.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",
295
+        //    'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
296
+        //     'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
297
+        //);
298
+        $this->export_TypeFields_array[$r]=array(
299
+            's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
300
+            's.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date','f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",
301
+            'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",
302
+            'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
303
+            'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
304
+        );
305
+        $this->export_entities_array[$r]=array(
306
+            's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company',
307
+            's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",
308
+            'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',
309
+            'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",
310
+            'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product',
311
+            'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
312
+        );
313
+        $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
314
+        // Add extra fields object
315
+        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
+        $resql=$this->db->query($sql);
317
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
318
+        {
319
+            while ($obj=$this->db->fetch_object($resql))
320
+            {
321
+                $fieldname='extra.'.$obj->name;
322
+                $fieldlabel=ucfirst($obj->label);
323
+                $typeFilter="Text";
324
+                switch($obj->type)
325
+                {
326
+                    case 'int':
327
+                    case 'double':
328
+                    case 'price':
329
+                        $typeFilter="Numeric";
330
+                        break;
331
+                    case 'date':
332
+                    case 'datetime':
333
+                        $typeFilter="Date";
334
+                        break;
335
+                    case 'boolean':
336
+                        $typeFilter="Boolean";
337
+                        break;
338
+                    case 'sellist':
339
+                        $tmp='';
340
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
342
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
343
+                        break;
344
+                }
345
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
346
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
347
+                $this->export_entities_array[$r][$fieldname]='invoice';
348
+            }
349
+        }
350
+        // End add extra fields
351
+        // Add extra fields line
352
+        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
+        $resql=$this->db->query($sql);
354
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
355
+        {
356
+            while ($obj=$this->db->fetch_object($resql))
357
+            {
358
+                $fieldname='extraline.'.$obj->name;
359
+                $fieldlabel=ucfirst($obj->label);
360
+                $typeFilter="Text";
361
+                switch($obj->type)
362
+                {
363
+                    case 'int':
364
+                    case 'double':
365
+                    case 'price':
366
+                        $typeFilter="Numeric";
367
+                        break;
368
+                    case 'date':
369
+                    case 'datetime':
370
+                        $typeFilter="Date";
371
+                        break;
372
+                    case 'boolean':
373
+                        $typeFilter="Boolean";
374
+                        break;
375
+                    case 'sellist':
376
+                        $tmp='';
377
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
379
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
380
+                        break;
381
+                }
382
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
383
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
384
+                $this->export_entities_array[$r][$fieldname]='invoice_line';
385
+            }
386
+        }
387
+        // End add extra fields line
388
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
389
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
390
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
+        $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
+        $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
481 399
         $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
483
-
484
-		// Order
485
-		$r++;
486
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
487
-		$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
488
-		$this->export_icon[$r]='order';
489
-		$this->export_permission[$r]=array(array("fournisseur","commande","export"));
490
-		$this->export_fields_array[$r]=array(
491
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
492
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
493
-			'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",
494
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2',
495
-			'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",
496
-			'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",
497
-			'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId',
498
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
499
-		);
500
-		if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
501
-		{
502
-			unset($this->export_fields_array['f.date_approve2']);
503
-			unset($this->export_fields_array['ua2.login']);
504
-		}
505
-		$this->export_TypeFields_array[$r]=array(
506
-			's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text',
507
-			's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",
508
-			'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
509
-			'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",
510
-			'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",
511
-			'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
512
-		);
513
-		$this->export_entities_array[$r]=array(
514
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company',
515
-			's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user',
516
-			'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",
517
-			'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product',
518
-			'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
519
-		);
520
-		$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
521
-		// Add extra fields object
522
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
-		$resql=$this->db->query($sql);
524
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
525
-		{
526
-			while ($obj=$this->db->fetch_object($resql))
527
-			{
528
-				$fieldname='extra.'.$obj->name;
529
-				$fieldlabel=ucfirst($obj->label);
530
-				$typeFilter="Text";
531
-				switch($obj->type)
532
-				{
533
-					case 'int':
534
-					case 'double':
535
-					case 'price':
536
-						$typeFilter="Numeric";
537
-						break;
538
-					case 'date':
539
-					case 'datetime':
540
-						$typeFilter="Date";
541
-						break;
542
-					case 'boolean':
543
-						$typeFilter="Boolean";
544
-						break;
545
-					case 'sellist':
546
-						$tmp='';
547
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
-						$tmpkey=array_keys($tmpparam['options']);
549
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
550
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
551
-						break;
552
-				}
553
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
554
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
555
-				$this->export_entities_array[$r][$fieldname]='order';
556
-			}
557
-		}
558
-		// End add extra fields object
559
-		// Add extra fields line
560
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
-		$resql=$this->db->query($sql);
562
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
563
-		{
564
-			while ($obj=$this->db->fetch_object($resql))
565
-			{
566
-				$fieldname='extraline.'.$obj->name;
567
-				$fieldlabel=ucfirst($obj->label);
568
-				$typeFilter="Text";
569
-				switch($obj->type)
570
-				{
571
-					case 'int':
572
-					case 'double':
573
-					case 'price':
574
-						$typeFilter="Numeric";
575
-						break;
576
-					case 'date':
577
-					case 'datetime':
578
-						$typeFilter="Date";
579
-						break;
580
-					case 'boolean':
581
-						$typeFilter="Boolean";
582
-						break;
583
-					case 'sellist':
584
-						$tmp='';
585
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
586
-
587
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
588
-							$tmpparam_param_key=array_keys($tmpparam['options']);
589
-							$tmp=array_shift($tmpparam_param_key);
590
-						}
591
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
592
-						break;
593
-				}
594
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
595
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
596
-				$this->export_entities_array[$r][$fieldname]='order_line';
597
-			}
598
-		}
599
-		// End add extra fields line
600
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
601
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
602
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
614
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
615
-	}
616
-
617
-
618
-	/**
619
-	 *		Function called when module is enabled.
620
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
621
-	 *		It also creates data directories
622
-	 *
400
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
401
+
402
+        $r++;
403
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
404
+        $this->export_label[$r]='Factures fournisseurs et reglements';
405
+        $this->export_icon[$r]='bill';
406
+        $this->export_permission[$r]=array(array("fournisseur","facture","export"));
407
+        $this->export_fields_array[$r]=array(
408
+            's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
409
+            's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
410
+            's.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",
411
+            'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",
412
+            'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment',
413
+            'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
414
+        );
415
+        //$this->export_TypeFields_array[$r]=array(
416
+        //	's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
417
+        //	's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",
418
+        //	'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
419
+        //	'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
420
+        //);
421
+        $this->export_TypeFields_array[$r]=array(
422
+            's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text',
423
+            's.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",
424
+            'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric',
425
+            'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text'
426
+        );
427
+        $this->export_entities_array[$r]=array(
428
+            's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company',
429
+            's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company',
430
+            'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",
431
+            'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment',
432
+            'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');
433
+        $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
434
+        // Add extra fields object
435
+        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
+        $resql=$this->db->query($sql);
437
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
438
+        {
439
+            while ($obj=$this->db->fetch_object($resql))
440
+            {
441
+                $fieldname='extra.'.$obj->name;
442
+                $fieldlabel=ucfirst($obj->label);
443
+                $typeFilter="Text";
444
+                switch($obj->type)
445
+                {
446
+                    case 'int':
447
+                    case 'double':
448
+                    case 'price':
449
+                        $typeFilter="Numeric";
450
+                        break;
451
+                    case 'date':
452
+                    case 'datetime':
453
+                        $typeFilter="Date";
454
+                        break;
455
+                    case 'boolean':
456
+                        $typeFilter="Boolean";
457
+                        break;
458
+                    case 'sellist':
459
+                        $tmp='';
460
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
462
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
463
+                        break;
464
+                }
465
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
466
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
467
+                $this->export_entities_array[$r][$fieldname]='invoice';
468
+            }
469
+        }
470
+        // End add extra fields object
471
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
472
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
473
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
+        $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
481
+        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
483
+
484
+        // Order
485
+        $r++;
486
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
487
+        $this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
488
+        $this->export_icon[$r]='order';
489
+        $this->export_permission[$r]=array(array("fournisseur","commande","export"));
490
+        $this->export_fields_array[$r]=array(
491
+            's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
492
+            's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
493
+            'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",
494
+            'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2',
495
+            'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",
496
+            'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",
497
+            'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId',
498
+            'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
499
+        );
500
+        if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
501
+        {
502
+            unset($this->export_fields_array['f.date_approve2']);
503
+            unset($this->export_fields_array['ua2.login']);
504
+        }
505
+        $this->export_TypeFields_array[$r]=array(
506
+            's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text',
507
+            's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",
508
+            'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
509
+            'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",
510
+            'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",
511
+            'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
512
+        );
513
+        $this->export_entities_array[$r]=array(
514
+            's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company',
515
+            's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user',
516
+            'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",
517
+            'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product',
518
+            'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
519
+        );
520
+        $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
521
+        // Add extra fields object
522
+        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
+        $resql=$this->db->query($sql);
524
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
525
+        {
526
+            while ($obj=$this->db->fetch_object($resql))
527
+            {
528
+                $fieldname='extra.'.$obj->name;
529
+                $fieldlabel=ucfirst($obj->label);
530
+                $typeFilter="Text";
531
+                switch($obj->type)
532
+                {
533
+                    case 'int':
534
+                    case 'double':
535
+                    case 'price':
536
+                        $typeFilter="Numeric";
537
+                        break;
538
+                    case 'date':
539
+                    case 'datetime':
540
+                        $typeFilter="Date";
541
+                        break;
542
+                    case 'boolean':
543
+                        $typeFilter="Boolean";
544
+                        break;
545
+                    case 'sellist':
546
+                        $tmp='';
547
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
+                        $tmpkey=array_keys($tmpparam['options']);
549
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
550
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
551
+                        break;
552
+                }
553
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
554
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
555
+                $this->export_entities_array[$r][$fieldname]='order';
556
+            }
557
+        }
558
+        // End add extra fields object
559
+        // Add extra fields line
560
+        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
+        $resql=$this->db->query($sql);
562
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
563
+        {
564
+            while ($obj=$this->db->fetch_object($resql))
565
+            {
566
+                $fieldname='extraline.'.$obj->name;
567
+                $fieldlabel=ucfirst($obj->label);
568
+                $typeFilter="Text";
569
+                switch($obj->type)
570
+                {
571
+                    case 'int':
572
+                    case 'double':
573
+                    case 'price':
574
+                        $typeFilter="Numeric";
575
+                        break;
576
+                    case 'date':
577
+                    case 'datetime':
578
+                        $typeFilter="Date";
579
+                        break;
580
+                    case 'boolean':
581
+                        $typeFilter="Boolean";
582
+                        break;
583
+                    case 'sellist':
584
+                        $tmp='';
585
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
586
+
587
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) {
588
+                            $tmpparam_param_key=array_keys($tmpparam['options']);
589
+                            $tmp=array_shift($tmpparam_param_key);
590
+                        }
591
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
592
+                        break;
593
+                }
594
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
595
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
596
+                $this->export_entities_array[$r][$fieldname]='order_line';
597
+            }
598
+        }
599
+        // End add extra fields line
600
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
601
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
602
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
+        $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
+        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
614
+        if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
615
+    }
616
+
617
+
618
+    /**
619
+     *		Function called when module is enabled.
620
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
621
+     *		It also creates data directories
622
+     *
623 623
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
624
-	 *      @return     int             	1 if OK, 0 if KO
625
-	 */
626
-	function init($options='')
627
-	{
628
-		global $conf;
624
+     *      @return     int             	1 if OK, 0 if KO
625
+     */
626
+    function init($options='')
627
+    {
628
+        global $conf;
629 629
 
630
-		$this->remove($options);
630
+        $this->remove($options);
631 631
 
632
-		$sql = array(
633
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".$conf->entity,
634
-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",
635
-		);
632
+        $sql = array(
633
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".$conf->entity,
634
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",
635
+        );
636 636
 
637
-		return $this->_init($sql,$options);
638
-	}
637
+        return $this->_init($sql,$options);
638
+    }
639 639
 }
Please login to merge, or discard this patch.
Spacing   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *		\ingroup    fournisseur
27 27
  *		\brief      Description and activation file for module Fournisseur
28 28
  */
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		$this->family = "srm";
53 53
 		$this->module_position = '10';
54 54
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
-		$this->name = preg_replace('/^mod/i','',get_class($this));
55
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
56 56
 		$this->description = "Gestion des fournisseurs";
57 57
 
58 58
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59 59
 		$this->version = 'dolibarr';
60 60
 
61 61
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		$this->picto='company';
62
+		$this->picto = 'company';
63 63
 
64 64
 		// Data directories to create when module is enabled
65 65
 		$this->dirs = array("/fournisseur/temp",
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 		// Constants
81 81
 		$this->const = array();
82
-		$r=0;
82
+		$r = 0;
83 83
 
84 84
 		$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
85 85
 		$this->const[$r][1] = "chaine";
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 		// Boxes
115 115
 		$this->boxes = array(
116
-		0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
117
-		1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'),
118
-		2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
119
-		3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
120
-		4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
121
-		5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
116
+		0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
117
+		1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
118
+		2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),
119
+		3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),
120
+		4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),
121
+		5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),
122 122
 		);
123 123
 
124 124
 		// Permissions
125 125
 		$this->rights = array();
126 126
 		$this->rights_class = 'fournisseur';
127
-		$r=0;
127
+		$r = 0;
128 128
 
129 129
 		$r++;
130 130
 		$this->rights[$r][0] = 1181;
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 		$this->rights[$r][4] = 'commande';
198 198
 		$this->rights[$r][5] = 'supprimer';
199 199
 
200
-		if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
200
+		if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
201 201
 		{
202 202
 			$r++;
203 203
 			$this->rights[$r][0] = 1190;
204
-			$this->rights[$r][1] = 'Approve supplier order (second level)';		// $langs->trans("Permission1190");
204
+			$this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190");
205 205
 			$this->rights[$r][2] = 'w';
206 206
 			$this->rights[$r][3] = 0;
207 207
 			$this->rights[$r][4] = 'commande';
@@ -267,27 +267,27 @@  discard block
 block discarded – undo
267 267
 
268 268
 	    // Menus
269 269
 	    //-------
270
-	    $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
270
+	    $this->menu = 1; // This module add menu entries. They are coded into menu manager.
271 271
 
272 272
 
273 273
 		// Exports
274 274
 		//--------
275
-		$r=0;
275
+		$r = 0;
276 276
 
277 277
 		$r++;
278
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
279
-		$this->export_label[$r]='Factures fournisseurs et lignes de facture';
280
-		$this->export_icon[$r]='bill';
281
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
282
-		$this->export_fields_array[$r]=array(
283
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
284
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
285
-			'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment',
286
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",
287
-			'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",
288
-			'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
289
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId',
290
-			'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
278
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
279
+		$this->export_label[$r] = 'Factures fournisseurs et lignes de facture';
280
+		$this->export_icon[$r] = 'bill';
281
+		$this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
282
+		$this->export_fields_array[$r] = array(
283
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
284
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
285
+			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>'DateMaxPayment',
286
+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",
287
+			'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT",
288
+			'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',
289
+			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',
290
+			'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
291 291
 		);
292 292
 		//$this->export_TypeFields_array[$r]=array(
293 293
 		//    's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
@@ -295,122 +295,122 @@  discard block
 block discarded – undo
295 295
 		//    'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
296 296
 		//     'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
297 297
 		//);
298
-		$this->export_TypeFields_array[$r]=array(
299
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
300
-			's.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date','f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",
301
-			'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",
302
-			'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
303
-			'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
298
+		$this->export_TypeFields_array[$r] = array(
299
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text',
300
+			's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date', 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric",
301
+			'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Text", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric",
302
+			'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label',
303
+			'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
304 304
 		);
305
-		$this->export_entities_array[$r]=array(
306
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company',
307
-			's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",
308
-			'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',
309
-			'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",
310
-			'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product',
311
-			'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
305
+		$this->export_entities_array[$r] = array(
306
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',
307
+			's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice",
308
+			'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice', 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice',
309
+			'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.remise_percent'=>"invoice_line",
310
+			'fd.total_ht'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',
311
+			'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
312 312
 		);
313
-		$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
313
+		$this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
314 314
 		// Add extra fields object
315
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
-		$resql=$this->db->query($sql);
315
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316
+		$resql = $this->db->query($sql);
317 317
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
318 318
 		{
319
-			while ($obj=$this->db->fetch_object($resql))
319
+			while ($obj = $this->db->fetch_object($resql))
320 320
 			{
321
-				$fieldname='extra.'.$obj->name;
322
-				$fieldlabel=ucfirst($obj->label);
323
-				$typeFilter="Text";
324
-				switch($obj->type)
321
+				$fieldname = 'extra.'.$obj->name;
322
+				$fieldlabel = ucfirst($obj->label);
323
+				$typeFilter = "Text";
324
+				switch ($obj->type)
325 325
 				{
326 326
 					case 'int':
327 327
 					case 'double':
328 328
 					case 'price':
329
-						$typeFilter="Numeric";
329
+						$typeFilter = "Numeric";
330 330
 						break;
331 331
 					case 'date':
332 332
 					case 'datetime':
333
-						$typeFilter="Date";
333
+						$typeFilter = "Date";
334 334
 						break;
335 335
 					case 'boolean':
336
-						$typeFilter="Boolean";
336
+						$typeFilter = "Boolean";
337 337
 						break;
338 338
 					case 'sellist':
339
-						$tmp='';
340
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
342
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
339
+						$tmp = '';
340
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
342
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
343 343
 						break;
344 344
 				}
345
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
346
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
347
-				$this->export_entities_array[$r][$fieldname]='invoice';
345
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
346
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
347
+				$this->export_entities_array[$r][$fieldname] = 'invoice';
348 348
 			}
349 349
 		}
350 350
 		// End add extra fields
351 351
 		// Add extra fields line
352
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
-		$resql=$this->db->query($sql);
352
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353
+		$resql = $this->db->query($sql);
354 354
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
355 355
 		{
356
-			while ($obj=$this->db->fetch_object($resql))
356
+			while ($obj = $this->db->fetch_object($resql))
357 357
 			{
358
-				$fieldname='extraline.'.$obj->name;
359
-				$fieldlabel=ucfirst($obj->label);
360
-				$typeFilter="Text";
361
-				switch($obj->type)
358
+				$fieldname = 'extraline.'.$obj->name;
359
+				$fieldlabel = ucfirst($obj->label);
360
+				$typeFilter = "Text";
361
+				switch ($obj->type)
362 362
 				{
363 363
 					case 'int':
364 364
 					case 'double':
365 365
 					case 'price':
366
-						$typeFilter="Numeric";
366
+						$typeFilter = "Numeric";
367 367
 						break;
368 368
 					case 'date':
369 369
 					case 'datetime':
370
-						$typeFilter="Date";
370
+						$typeFilter = "Date";
371 371
 						break;
372 372
 					case 'boolean':
373
-						$typeFilter="Boolean";
373
+						$typeFilter = "Boolean";
374 374
 						break;
375 375
 					case 'sellist':
376
-						$tmp='';
377
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
379
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
376
+						$tmp = '';
377
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
379
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
380 380
 						break;
381 381
 				}
382
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
383
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
384
-				$this->export_entities_array[$r][$fieldname]='invoice_line';
382
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
383
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
384
+				$this->export_entities_array[$r][$fieldname] = 'invoice_line';
385 385
 			}
386 386
 		}
387 387
 		// End add extra fields line
388
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
389
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
390
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
388
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
389
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
390
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
391
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
393
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
394
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
395
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
396
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
397
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399
+		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
401 401
 
402 402
 		$r++;
403
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
404
-		$this->export_label[$r]='Factures fournisseurs et reglements';
405
-		$this->export_icon[$r]='bill';
406
-		$this->export_permission[$r]=array(array("fournisseur","facture","export"));
407
-		$this->export_fields_array[$r]=array(
408
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
409
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
410
-			's.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",
411
-			'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",
412
-			'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment',
413
-			'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
403
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
404
+		$this->export_label[$r] = 'Factures fournisseurs et reglements';
405
+		$this->export_icon[$r] = 'bill';
406
+		$this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
407
+		$this->export_fields_array[$r] = array(
408
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
409
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
410
+			's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation",
411
+			'f.datef'=>"DateInvoice", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid",
412
+			'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment',
413
+			'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
414 414
 		);
415 415
 		//$this->export_TypeFields_array[$r]=array(
416 416
 		//	's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
@@ -418,200 +418,200 @@  discard block
 block discarded – undo
418 418
 		//	'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
419 419
 		//	'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
420 420
 		//);
421
-		$this->export_TypeFields_array[$r]=array(
422
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text',
423
-			's.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",
424
-			'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric',
425
-			'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text'
421
+		$this->export_TypeFields_array[$r] = array(
422
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',
423
+			's.idprof4'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.total_ht'=>"Numeric",
424
+			'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',
425
+			'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text'
426 426
 		);
427
-		$this->export_entities_array[$r]=array(
428
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company',
429
-			's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company',
430
-			'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",
431
-			'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment',
432
-		    'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');
433
-		$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
427
+		$this->export_entities_array[$r] = array(
428
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
429
+			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company',
430
+			'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice",
431
+			'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',
432
+		    'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');
433
+		$this->export_dependencies_array[$r] = array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
434 434
 		// Add extra fields object
435
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
-		$resql=$this->db->query($sql);
435
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436
+		$resql = $this->db->query($sql);
437 437
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
438 438
 		{
439
-			while ($obj=$this->db->fetch_object($resql))
439
+			while ($obj = $this->db->fetch_object($resql))
440 440
 			{
441
-				$fieldname='extra.'.$obj->name;
442
-				$fieldlabel=ucfirst($obj->label);
443
-				$typeFilter="Text";
444
-				switch($obj->type)
441
+				$fieldname = 'extra.'.$obj->name;
442
+				$fieldlabel = ucfirst($obj->label);
443
+				$typeFilter = "Text";
444
+				switch ($obj->type)
445 445
 				{
446 446
 					case 'int':
447 447
 					case 'double':
448 448
 					case 'price':
449
-						$typeFilter="Numeric";
449
+						$typeFilter = "Numeric";
450 450
 						break;
451 451
 					case 'date':
452 452
 					case 'datetime':
453
-						$typeFilter="Date";
453
+						$typeFilter = "Date";
454 454
 						break;
455 455
 					case 'boolean':
456
-						$typeFilter="Boolean";
456
+						$typeFilter = "Boolean";
457 457
 						break;
458 458
 					case 'sellist':
459
-						$tmp='';
460
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
462
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
459
+						$tmp = '';
460
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
462
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
463 463
 						break;
464 464
 				}
465
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
466
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
467
-				$this->export_entities_array[$r][$fieldname]='invoice';
465
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
466
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
467
+				$this->export_entities_array[$r][$fieldname] = 'invoice';
468 468
 			}
469 469
 		}
470 470
 		// End add extra fields object
471
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
472
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
473
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
481
-        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
471
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
472
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
473
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
474
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
476
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
477
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
478
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
479
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
481
+        $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
483 483
 
484 484
 		// Order
485 485
 		$r++;
486
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
487
-		$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
488
-		$this->export_icon[$r]='order';
489
-		$this->export_permission[$r]=array(array("fournisseur","commande","export"));
490
-		$this->export_fields_array[$r]=array(
491
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
492
-			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
493
-			'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",
494
-			'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2',
495
-			'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",
496
-			'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",
497
-			'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId',
498
-			'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
486
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
487
+		$this->export_label[$r] = 'Commandes fournisseurs et lignes de commandes';
488
+		$this->export_icon[$r] = 'order';
489
+		$this->export_permission[$r] = array(array("fournisseur", "commande", "export"));
490
+		$this->export_fields_array[$r] = array(
491
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
492
+			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
493
+			'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned",
494
+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
495
+			'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
496
+			'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC",
497
+			'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
498
+			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
499 499
 		);
500 500
 		if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
501 501
 		{
502 502
 			unset($this->export_fields_array['f.date_approve2']);
503 503
 			unset($this->export_fields_array['ua2.login']);
504 504
 		}
505
-		$this->export_TypeFields_array[$r]=array(
506
-			's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text',
507
-			's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",
508
-			'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
509
-			'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",
510
-			'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",
511
-			'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
505
+		$this->export_TypeFields_array[$r] = array(
506
+			's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',
507
+			's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",
508
+			'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",
509
+			'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",
510
+			'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric",
511
+			'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
512 512
 		);
513
-		$this->export_entities_array[$r]=array(
514
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company',
515
-			's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user',
516
-			'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",
517
-			'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product',
518
-			'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
513
+		$this->export_entities_array[$r] = array(
514
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',
515
+			's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'ua1.login'=>'user',
516
+			'ua2.login'=>'user', 'fd.rowid'=>'order_line', 'fd.description'=>"order_line", 'fd.tva_tx'=>"order_line", 'fd.qty'=>"order_line", 'fd.remise_percent'=>"order_line",
517
+			'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',
518
+			'p.ref'=>'product', 'p.label'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
519 519
 		);
520
-		$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
520
+		$this->export_dependencies_array[$r] = array('order_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
521 521
 		// Add extra fields object
522
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
-		$resql=$this->db->query($sql);
522
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523
+		$resql = $this->db->query($sql);
524 524
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
525 525
 		{
526
-			while ($obj=$this->db->fetch_object($resql))
526
+			while ($obj = $this->db->fetch_object($resql))
527 527
 			{
528
-				$fieldname='extra.'.$obj->name;
529
-				$fieldlabel=ucfirst($obj->label);
530
-				$typeFilter="Text";
531
-				switch($obj->type)
528
+				$fieldname = 'extra.'.$obj->name;
529
+				$fieldlabel = ucfirst($obj->label);
530
+				$typeFilter = "Text";
531
+				switch ($obj->type)
532 532
 				{
533 533
 					case 'int':
534 534
 					case 'double':
535 535
 					case 'price':
536
-						$typeFilter="Numeric";
536
+						$typeFilter = "Numeric";
537 537
 						break;
538 538
 					case 'date':
539 539
 					case 'datetime':
540
-						$typeFilter="Date";
540
+						$typeFilter = "Date";
541 541
 						break;
542 542
 					case 'boolean':
543
-						$typeFilter="Boolean";
543
+						$typeFilter = "Boolean";
544 544
 						break;
545 545
 					case 'sellist':
546
-						$tmp='';
547
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
-						$tmpkey=array_keys($tmpparam['options']);
549
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
550
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
546
+						$tmp = '';
547
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548
+						$tmpkey = array_keys($tmpparam['options']);
549
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey);
550
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
551 551
 						break;
552 552
 				}
553
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
554
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
555
-				$this->export_entities_array[$r][$fieldname]='order';
553
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
554
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
555
+				$this->export_entities_array[$r][$fieldname] = 'order';
556 556
 			}
557 557
 		}
558 558
 		// End add extra fields object
559 559
 		// Add extra fields line
560
-		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
-		$resql=$this->db->query($sql);
560
+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561
+		$resql = $this->db->query($sql);
562 562
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
563 563
 		{
564
-			while ($obj=$this->db->fetch_object($resql))
564
+			while ($obj = $this->db->fetch_object($resql))
565 565
 			{
566
-				$fieldname='extraline.'.$obj->name;
567
-				$fieldlabel=ucfirst($obj->label);
568
-				$typeFilter="Text";
569
-				switch($obj->type)
566
+				$fieldname = 'extraline.'.$obj->name;
567
+				$fieldlabel = ucfirst($obj->label);
568
+				$typeFilter = "Text";
569
+				switch ($obj->type)
570 570
 				{
571 571
 					case 'int':
572 572
 					case 'double':
573 573
 					case 'price':
574
-						$typeFilter="Numeric";
574
+						$typeFilter = "Numeric";
575 575
 						break;
576 576
 					case 'date':
577 577
 					case 'datetime':
578
-						$typeFilter="Date";
578
+						$typeFilter = "Date";
579 579
 						break;
580 580
 					case 'boolean':
581
-						$typeFilter="Boolean";
581
+						$typeFilter = "Boolean";
582 582
 						break;
583 583
 					case 'sellist':
584
-						$tmp='';
585
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
584
+						$tmp = '';
585
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
586 586
 
587 587
 						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
588
-							$tmpparam_param_key=array_keys($tmpparam['options']);
589
-							$tmp=array_shift($tmpparam_param_key);
588
+							$tmpparam_param_key = array_keys($tmpparam['options']);
589
+							$tmp = array_shift($tmpparam_param_key);
590 590
 						}
591
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
591
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
592 592
 						break;
593 593
 				}
594
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
595
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
596
-				$this->export_entities_array[$r][$fieldname]='order_line';
594
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
595
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
596
+				$this->export_entities_array[$r][$fieldname] = 'order_line';
597 597
 			}
598 598
 		}
599 599
 		// End add extra fields line
600
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
601
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
602
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
614
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
600
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
601
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
602
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
603
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
606
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
607
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
610
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612
+		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613
+		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')';
614
+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
615 615
 	}
616 616
 
617 617
 
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
624 624
 	 *      @return     int             	1 if OK, 0 if KO
625 625
 	 */
626
-	function init($options='')
626
+	function init($options = '')
627 627
 	{
628 628
 		global $conf;
629 629
 
@@ -634,6 +634,6 @@  discard block
 block discarded – undo
634 634
 			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",
635 635
 		);
636 636
 
637
-		return $this->_init($sql,$options);
637
+		return $this->_init($sql, $options);
638 638
 	}
639 639
 }
Please login to merge, or discard this patch.
Braces   +60 added lines, -20 removed lines patch added patch discarded remove patch
@@ -314,11 +314,13 @@  discard block
 block discarded – undo
314 314
 		// Add extra fields object
315 315
 		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
316 316
 		$resql=$this->db->query($sql);
317
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
317
+		if ($resql) {
318
+		    // This can fail when class is used on old database (during migration for example)
318 319
 		{
319 320
 			while ($obj=$this->db->fetch_object($resql))
320 321
 			{
321 322
 				$fieldname='extra.'.$obj->name;
323
+		}
322 324
 				$fieldlabel=ucfirst($obj->label);
323 325
 				$typeFilter="Text";
324 326
 				switch($obj->type)
@@ -338,8 +340,12 @@  discard block
 block discarded – undo
338 340
 					case 'sellist':
339 341
 						$tmp='';
340 342
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
341
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
342
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
343
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
344
+						    $tmp=array_shift(array_keys($tmpparam['options']));
345
+						}
346
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
347
+						    $typeFilter="List:".$tmp;
348
+						}
343 349
 						break;
344 350
 				}
345 351
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -351,11 +357,13 @@  discard block
 block discarded – undo
351 357
 		// Add extra fields line
352 358
 		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
353 359
 		$resql=$this->db->query($sql);
354
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
360
+		if ($resql) {
361
+		    // This can fail when class is used on old database (during migration for example)
355 362
 		{
356 363
 			while ($obj=$this->db->fetch_object($resql))
357 364
 			{
358 365
 				$fieldname='extraline.'.$obj->name;
366
+		}
359 367
 				$fieldlabel=ucfirst($obj->label);
360 368
 				$typeFilter="Text";
361 369
 				switch($obj->type)
@@ -375,8 +383,12 @@  discard block
 block discarded – undo
375 383
 					case 'sellist':
376 384
 						$tmp='';
377 385
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
378
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
379
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
386
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
387
+						    $tmp=array_shift(array_keys($tmpparam['options']));
388
+						}
389
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
390
+						    $typeFilter="List:".$tmp;
391
+						}
380 392
 						break;
381 393
 				}
382 394
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -387,7 +399,9 @@  discard block
 block discarded – undo
387 399
 		// End add extra fields line
388 400
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
389 401
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
390
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
402
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
403
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
404
+		}
391 405
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
392 406
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
393 407
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@@ -397,7 +411,9 @@  discard block
 block discarded – undo
397 411
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
398 412
 		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
399 413
 		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
400
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
414
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
415
+		    $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
416
+		}
401 417
 
402 418
 		$r++;
403 419
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
@@ -434,11 +450,13 @@  discard block
 block discarded – undo
434 450
 		// Add extra fields object
435 451
 		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
436 452
 		$resql=$this->db->query($sql);
437
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
453
+		if ($resql) {
454
+		    // This can fail when class is used on old database (during migration for example)
438 455
 		{
439 456
 			while ($obj=$this->db->fetch_object($resql))
440 457
 			{
441 458
 				$fieldname='extra.'.$obj->name;
459
+		}
442 460
 				$fieldlabel=ucfirst($obj->label);
443 461
 				$typeFilter="Text";
444 462
 				switch($obj->type)
@@ -458,8 +476,12 @@  discard block
 block discarded – undo
458 476
 					case 'sellist':
459 477
 						$tmp='';
460 478
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
461
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
462
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
479
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
480
+						    $tmp=array_shift(array_keys($tmpparam['options']));
481
+						}
482
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
483
+						    $typeFilter="List:".$tmp;
484
+						}
463 485
 						break;
464 486
 				}
465 487
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -470,7 +492,9 @@  discard block
 block discarded – undo
470 492
 		// End add extra fields object
471 493
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
472 494
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
473
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
495
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
496
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
497
+		}
474 498
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
475 499
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
476 500
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@@ -479,7 +503,9 @@  discard block
 block discarded – undo
479 503
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
480 504
 		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
481 505
         $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
482
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
506
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
507
+		    $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
508
+		}
483 509
 
484 510
 		// Order
485 511
 		$r++;
@@ -521,11 +547,13 @@  discard block
 block discarded – undo
521 547
 		// Add extra fields object
522 548
 		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
523 549
 		$resql=$this->db->query($sql);
524
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
550
+		if ($resql) {
551
+		    // This can fail when class is used on old database (during migration for example)
525 552
 		{
526 553
 			while ($obj=$this->db->fetch_object($resql))
527 554
 			{
528 555
 				$fieldname='extra.'.$obj->name;
556
+		}
529 557
 				$fieldlabel=ucfirst($obj->label);
530 558
 				$typeFilter="Text";
531 559
 				switch($obj->type)
@@ -546,8 +574,12 @@  discard block
 block discarded – undo
546 574
 						$tmp='';
547 575
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
548 576
 						$tmpkey=array_keys($tmpparam['options']);
549
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
550
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
577
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
578
+						    $tmp=array_shift($tmpkey);
579
+						}
580
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
581
+						    $typeFilter="List:".$tmp;
582
+						}
551 583
 						break;
552 584
 				}
553 585
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -559,11 +591,13 @@  discard block
 block discarded – undo
559 591
 		// Add extra fields line
560 592
 		$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
561 593
 		$resql=$this->db->query($sql);
562
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
594
+		if ($resql) {
595
+		    // This can fail when class is used on old database (during migration for example)
563 596
 		{
564 597
 			while ($obj=$this->db->fetch_object($resql))
565 598
 			{
566 599
 				$fieldname='extraline.'.$obj->name;
600
+		}
567 601
 				$fieldlabel=ucfirst($obj->label);
568 602
 				$typeFilter="Text";
569 603
 				switch($obj->type)
@@ -588,7 +622,9 @@  discard block
 block discarded – undo
588 622
 							$tmpparam_param_key=array_keys($tmpparam['options']);
589 623
 							$tmp=array_shift($tmpparam_param_key);
590 624
 						}
591
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
625
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
626
+						    $typeFilter="List:".$tmp;
627
+						}
592 628
 						break;
593 629
 				}
594 630
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -599,7 +635,9 @@  discard block
 block discarded – undo
599 635
 		// End add extra fields line
600 636
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
601 637
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
602
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
638
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
639
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
640
+		}
603 641
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
604 642
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
605 643
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@@ -611,7 +649,9 @@  discard block
 block discarded – undo
611 649
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
612 650
 		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613 651
 		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
614
-		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
652
+		if (is_object($user) && empty($user->rights->societe->client->voir)) {
653
+		    $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
654
+		}
615 655
 	}
616 656
 
617 657
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modSalaries.class.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -38,143 +38,143 @@
 block discarded – undo
38 38
 class modSalaries extends DolibarrModules
39 39
 {
40 40
 
41
-	/**
42
-	 *   Constructor. Define names, constants, directories, boxes, permissions
43
-	 *
44
-	 *   @param      DoliDB		$db      Database handler
45
-	 */
46
-	function __construct($db)
47
-	{
48
-		global $conf;
49
-
50
-		$this->db = $db;
51
-		$this->numero = 510; // Perms from 501..519
52
-
53
-		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
54
-		// It is used to group modules by family in module setup page
55
-		$this->family = "financial";
56
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
58
-		// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59
-		$this->description = "Payment of salaries";
60
-
61
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
62
-		$this->version = 'dolibarr';
63
-
64
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65
-		$this->picto='bill';
66
-
67
-		// Data directories to create when module is enabled
68
-		$this->dirs = array("/salaries/temp");
69
-
70
-		// Config pages
71
-		//$this->config_page_url = array('salaries.php');
72
-		$this->config_page_url = array();
73
-
74
-		// Dependencies
75
-		$this->hidden = false;			// A condition to hide module
76
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
77
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
78
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
79
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
80
-		$this->langfiles = array("salaries","bills");
81
-
82
-		// Constants
83
-		$this->const = array();
84
-		$this->const[0] = array(
85
-				"SALARIES_ACCOUNTING_ACCOUNT_PAYMENT",
86
-				"chaine",
87
-				"421"
88
-		);
89
-		$this->const[1] = array(
90
-				"SALARIES_ACCOUNTING_ACCOUNT_CHARGE",
91
-				"chaine",
92
-				"641"
93
-		);
94
-
95
-		// Boxes
96
-		$this->boxes = array();
97
-
98
-		// Permissions
99
-		$this->rights = array();
100
-		$this->rights_class = 'salaries';
101
-		$r=0;
102
-
103
-		$r++;
104
-		$this->rights[$r][0] = 511;
105
-		$this->rights[$r][1] = 'Read payments of employee salaries';
106
-		$this->rights[$r][2] = 'r';
107
-		$this->rights[$r][3] = 0;
108
-		$this->rights[$r][4] = 'read';
109
-		$this->rights[$r][5] = '';
110
-
111
-		$r++;
112
-		$this->rights[$r][0] = 512;
113
-		$this->rights[$r][1] = 'Create/modify payments of empoyee salaries';
114
-		$this->rights[$r][2] = 'w';
115
-		$this->rights[$r][3] = 0;
116
-		$this->rights[$r][4] = 'write';
117
-		$this->rights[$r][5] = '';
118
-
119
-		$r++;
120
-		$this->rights[$r][0] = 514;
121
-		$this->rights[$r][1] = 'Delete payments of employee salary';
122
-		$this->rights[$r][2] = 'd';
123
-		$this->rights[$r][3] = 0;
124
-		$this->rights[$r][4] = 'delete';
125
-		$this->rights[$r][5] = '';
126
-
127
-		$r++;
128
-		$this->rights[$r][0] = 517;
129
-		$this->rights[$r][1] = 'Export payments of employee salaries';
130
-		$this->rights[$r][2] = 'r';
131
-		$this->rights[$r][3] = 0;
132
-		$this->rights[$r][4] = 'export';
133
-		$this->rights[$r][5] = '';
134
-
135
-
136
-		// Menus
137
-		//-------
138
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
139
-
140
-
141
-		// Exports
142
-		//--------
143
-		$r=0;
144
-
145
-		$r++;
146
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
147
-		$this->export_label[$r]='Salaries and payments';
148
-		$this->export_permission[$r]=array(array("salaries","export"));
149
-		$this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_payment'=>'Numero','p.label'=>'Label','p.note'=>'Note');
150
-		$this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Numeric",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Numeric','p.num_payment'=>'Numeric','p.label'=>'Text');
151
-		$this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_payment'=>'payment');
152
-
153
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
154
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
155
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
158
-	}
159
-
160
-
161
-	/**
162
-	 *		Function called when module is enabled.
163
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
164
-	 *		It also creates data directories
165
-	 *
166
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
167
-	 *      @return     int             	1 if OK, 0 if KO
168
-	 */
169
-	function init($options='')
170
-	{
171
-		global $conf;
172
-
173
-		// Clean before activation
174
-		$this->remove($options);
175
-
176
-		$sql = array();
177
-
178
-		return $this->_init($sql,$options);
179
-	}
41
+    /**
42
+     *   Constructor. Define names, constants, directories, boxes, permissions
43
+     *
44
+     *   @param      DoliDB		$db      Database handler
45
+     */
46
+    function __construct($db)
47
+    {
48
+        global $conf;
49
+
50
+        $this->db = $db;
51
+        $this->numero = 510; // Perms from 501..519
52
+
53
+        // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
54
+        // It is used to group modules by family in module setup page
55
+        $this->family = "financial";
56
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
+        $this->name = preg_replace('/^mod/i','',get_class($this));
58
+        // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59
+        $this->description = "Payment of salaries";
60
+
61
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
62
+        $this->version = 'dolibarr';
63
+
64
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65
+        $this->picto='bill';
66
+
67
+        // Data directories to create when module is enabled
68
+        $this->dirs = array("/salaries/temp");
69
+
70
+        // Config pages
71
+        //$this->config_page_url = array('salaries.php');
72
+        $this->config_page_url = array();
73
+
74
+        // Dependencies
75
+        $this->hidden = false;			// A condition to hide module
76
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
77
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
78
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
79
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
80
+        $this->langfiles = array("salaries","bills");
81
+
82
+        // Constants
83
+        $this->const = array();
84
+        $this->const[0] = array(
85
+                "SALARIES_ACCOUNTING_ACCOUNT_PAYMENT",
86
+                "chaine",
87
+                "421"
88
+        );
89
+        $this->const[1] = array(
90
+                "SALARIES_ACCOUNTING_ACCOUNT_CHARGE",
91
+                "chaine",
92
+                "641"
93
+        );
94
+
95
+        // Boxes
96
+        $this->boxes = array();
97
+
98
+        // Permissions
99
+        $this->rights = array();
100
+        $this->rights_class = 'salaries';
101
+        $r=0;
102
+
103
+        $r++;
104
+        $this->rights[$r][0] = 511;
105
+        $this->rights[$r][1] = 'Read payments of employee salaries';
106
+        $this->rights[$r][2] = 'r';
107
+        $this->rights[$r][3] = 0;
108
+        $this->rights[$r][4] = 'read';
109
+        $this->rights[$r][5] = '';
110
+
111
+        $r++;
112
+        $this->rights[$r][0] = 512;
113
+        $this->rights[$r][1] = 'Create/modify payments of empoyee salaries';
114
+        $this->rights[$r][2] = 'w';
115
+        $this->rights[$r][3] = 0;
116
+        $this->rights[$r][4] = 'write';
117
+        $this->rights[$r][5] = '';
118
+
119
+        $r++;
120
+        $this->rights[$r][0] = 514;
121
+        $this->rights[$r][1] = 'Delete payments of employee salary';
122
+        $this->rights[$r][2] = 'd';
123
+        $this->rights[$r][3] = 0;
124
+        $this->rights[$r][4] = 'delete';
125
+        $this->rights[$r][5] = '';
126
+
127
+        $r++;
128
+        $this->rights[$r][0] = 517;
129
+        $this->rights[$r][1] = 'Export payments of employee salaries';
130
+        $this->rights[$r][2] = 'r';
131
+        $this->rights[$r][3] = 0;
132
+        $this->rights[$r][4] = 'export';
133
+        $this->rights[$r][5] = '';
134
+
135
+
136
+        // Menus
137
+        //-------
138
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
139
+
140
+
141
+        // Exports
142
+        //--------
143
+        $r=0;
144
+
145
+        $r++;
146
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
147
+        $this->export_label[$r]='Salaries and payments';
148
+        $this->export_permission[$r]=array(array("salaries","export"));
149
+        $this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_payment'=>'Numero','p.label'=>'Label','p.note'=>'Note');
150
+        $this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Numeric",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Numeric','p.num_payment'=>'Numeric','p.label'=>'Text');
151
+        $this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_payment'=>'payment');
152
+
153
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
154
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
155
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
+        $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
158
+    }
159
+
160
+
161
+    /**
162
+     *		Function called when module is enabled.
163
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
164
+     *		It also creates data directories
165
+     *
166
+     *      @param      string	$options    Options when enabling module ('', 'noboxes')
167
+     *      @return     int             	1 if OK, 0 if KO
168
+     */
169
+    function init($options='')
170
+    {
171
+        global $conf;
172
+
173
+        // Clean before activation
174
+        $this->remove($options);
175
+
176
+        $sql = array();
177
+
178
+        return $this->_init($sql,$options);
179
+    }
180 180
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *  \ingroup    salaries
30 30
  *  \brief      File to activate module salaries
31 31
  */
32
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 33
 
34 34
 
35 35
 /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		// It is used to group modules by family in module setup page
55 55
 		$this->family = "financial";
56 56
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
57
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
58 58
 		// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59 59
 		$this->description = "Payment of salaries";
60 60
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->version = 'dolibarr';
63 63
 
64 64
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65
-		$this->picto='bill';
65
+		$this->picto = 'bill';
66 66
 
67 67
 		// Data directories to create when module is enabled
68 68
 		$this->dirs = array("/salaries/temp");
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		$this->config_page_url = array();
73 73
 
74 74
 		// Dependencies
75
-		$this->hidden = false;			// A condition to hide module
76
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
77
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
78
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
79
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
80
-		$this->langfiles = array("salaries","bills");
75
+		$this->hidden = false; // A condition to hide module
76
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
77
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
78
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
79
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
80
+		$this->langfiles = array("salaries", "bills");
81 81
 
82 82
 		// Constants
83 83
 		$this->const = array();
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		// Permissions
99 99
 		$this->rights = array();
100 100
 		$this->rights_class = 'salaries';
101
-		$r=0;
101
+		$r = 0;
102 102
 
103 103
 		$r++;
104 104
 		$this->rights[$r][0] = 511;
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 
136 136
 		// Menus
137 137
 		//-------
138
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
138
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
139 139
 
140 140
 
141 141
 		// Exports
142 142
 		//--------
143
-		$r=0;
143
+		$r = 0;
144 144
 
145 145
 		$r++;
146
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
147
-		$this->export_label[$r]='Salaries and payments';
148
-		$this->export_permission[$r]=array(array("salaries","export"));
149
-		$this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_payment'=>'Numero','p.label'=>'Label','p.note'=>'Note');
150
-		$this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Numeric",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Numeric','p.num_payment'=>'Numeric','p.label'=>'Text');
151
-		$this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_payment'=>'payment');
152
-
153
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
154
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
155
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
146
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
147
+		$this->export_label[$r] = 'Salaries and payments';
148
+		$this->export_permission[$r] = array(array("salaries", "export"));
149
+		$this->export_fields_array[$r] = array('u.firstname'=>"Firstname", 'u.lastname'=>"Lastname", 'u.login'=>"Login", 'u.salary'=>'CurrentSalary', 'p.datep'=>'DatePayment', 'p.datesp'=>'DateStartPeriod', 'p.dateep'=>'DateEndPeriod', 'p.amount'=>'AmountPayment', 'p.num_payment'=>'Numero', 'p.label'=>'Label', 'p.note'=>'Note');
150
+		$this->export_TypeFields_array[$r] = array('u.firstname'=>"Text", 'u.lastname'=>"Text", 'u.login'=>'Text', 'u.salary'=>"Numeric", 'p.datep'=>'Date', 'p.datesp'=>'Date', 'p.dateep'=>'Date', 'p.amount'=>'Numeric', 'p.num_payment'=>'Numeric', 'p.label'=>'Text');
151
+		$this->export_entities_array[$r] = array('u.firstname'=>'user', 'u.lastname'=>'user', 'u.login'=>'user', 'u.salary'=>'user', 'p.datep'=>'payment', 'p.datesp'=>'payment', 'p.dateep'=>'payment', 'p.amount'=>'payment', 'p.label'=>'payment', 'p.note'=>'payment', 'p.num_payment'=>'payment');
152
+
153
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
154
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'user as u';
155
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
156
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
157
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('user').')';
158 158
 	}
159 159
 
160 160
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
167 167
 	 *      @return     int             	1 if OK, 0 if KO
168 168
 	 */
169
-	function init($options='')
169
+	function init($options = '')
170 170
 	{
171 171
 		global $conf;
172 172
 
@@ -175,6 +175,6 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$sql = array();
177 177
 
178
-		return $this->_init($sql,$options);
178
+		return $this->_init($sql, $options);
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modService.class.php 3 patches
Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -35,88 +35,88 @@  discard block
 block discarded – undo
35 35
 class modService 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, $mysoc;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 53;
49
-
50
-		$this->family = "products";
51
-		$this->module_position = '30';
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 = "Service management";
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='service';
61
-
62
-		// Data directories to create when module is enabled
63
-		$this->dirs = array("/product/temp");
64
-
65
-		// Dependencies
66
-		$this->hidden = false;			// A condition to hide module
67
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
69
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
71
-
72
-		// Config pages
73
-		$this->config_page_url = array("product.php@product");
74
-		$this->langfiles = array("products","companies","bills");
75
-
76
-		// Constants
77
-		$this->const = array();
78
-
79
-		// Boxes
80
-		$this->boxes = array(
81
-			0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'),
82
-			1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home')
83
-		);
84
-
85
-		// Permissions
86
-		$this->rights = array();
87
-		$this->rights_class = 'service';
88
-		$r=0;
89
-
90
-		$this->rights[$r][0] = 531; // id de la permission
91
-		$this->rights[$r][1] = 'Read services'; // libelle de la permission
92
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
93
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
94
-		$this->rights[$r][4] = 'lire';
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, $mysoc;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 53;
49
+
50
+        $this->family = "products";
51
+        $this->module_position = '30';
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 = "Service management";
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='service';
61
+
62
+        // Data directories to create when module is enabled
63
+        $this->dirs = array("/product/temp");
64
+
65
+        // Dependencies
66
+        $this->hidden = false;			// A condition to hide module
67
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
69
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
71
+
72
+        // Config pages
73
+        $this->config_page_url = array("product.php@product");
74
+        $this->langfiles = array("products","companies","bills");
75
+
76
+        // Constants
77
+        $this->const = array();
78
+
79
+        // Boxes
80
+        $this->boxes = array(
81
+            0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'),
82
+            1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home')
83
+        );
84
+
85
+        // Permissions
86
+        $this->rights = array();
87
+        $this->rights_class = 'service';
88
+        $r=0;
89
+
90
+        $this->rights[$r][0] = 531; // id de la permission
91
+        $this->rights[$r][1] = 'Read services'; // libelle de la permission
92
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
93
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
94
+        $this->rights[$r][4] = 'lire';
95 95
         $r++;
96 96
 
97
-		$this->rights[$r][0] = 532; // id de la permission
98
-		$this->rights[$r][1] = 'Create/modify services'; // libelle de la permission
99
-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
100
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
101
-		$this->rights[$r][4] = 'creer';
97
+        $this->rights[$r][0] = 532; // id de la permission
98
+        $this->rights[$r][1] = 'Create/modify services'; // libelle de la permission
99
+        $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
100
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
101
+        $this->rights[$r][4] = 'creer';
102 102
         $r++;
103 103
 
104
-		$this->rights[$r][0] = 534; // id de la permission
105
-		$this->rights[$r][1] = 'Delete les services'; // libelle de la permission
106
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
107
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
108
-		$this->rights[$r][4] = 'supprimer';
104
+        $this->rights[$r][0] = 534; // id de la permission
105
+        $this->rights[$r][1] = 'Delete les services'; // libelle de la permission
106
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
107
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
108
+        $this->rights[$r][4] = 'supprimer';
109 109
         $r++;
110 110
 
111
-		$this->rights[$r][0] = 538;	// Must be same permission than in product module
112
-		$this->rights[$r][1] = 'Export services';
113
-		$this->rights[$r][2] = 'r';
114
-		$this->rights[$r][3] = 0;
115
-		$this->rights[$r][4] = 'export';
111
+        $this->rights[$r][0] = 538;	// Must be same permission than in product module
112
+        $this->rights[$r][1] = 'Export services';
113
+        $this->rights[$r][2] = 'r';
114
+        $this->rights[$r][3] = 0;
115
+        $this->rights[$r][4] = 'export';
116 116
         $r++;
117 117
 
118 118
 
119
-		/* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert
119
+        /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert
120 120
 		$r=0;
121 121
 		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
122 122
 								'type'=>'left',			                // This is a Left menu entry
@@ -132,243 +132,243 @@  discard block
 block discarded – undo
132 132
 		*/
133 133
 
134 134
 
135
-		// Menus
136
-		//-------
137
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
135
+        // Menus
136
+        //-------
137
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
138 138
 
139 139
 
140 140
         // Exports
141
-		//--------
142
-		$r=0;
141
+        //--------
142
+        $r=0;
143 143
 
144
-		$r++;
145
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
146
-		$this->export_label[$r]="Services";	// Translation key (used only if key ExportDataset_xxx_z not found)
147
-		$this->export_permission[$r]=array(array("service","export"));
148
-		$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
149
-		if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
150
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
151
-		//$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
152
-		$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
153
-		if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
154
-		if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
155
-		$this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
156
-		if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
157
-		if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
158
-		// Add extra fields
159
-		$sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
-		$resql=$this->db->query($sql);
161
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
162
-		{
163
-		    while ($obj=$this->db->fetch_object($resql))
164
-		    {
165
-		        $fieldname='extra.'.$obj->name;
166
-		        $fieldlabel=ucfirst($obj->label);
167
-		    	$typeFilter="Text";
168
-				switch($obj->type)
169
-				{
170
-					case 'int':
171
-					case 'double':
172
-					case 'price':
173
-						$typeFilter="Numeric";
174
-						break;
175
-					case 'date':
176
-					case 'datetime':
177
-						$typeFilter="Date";
178
-						break;
179
-					case 'boolean':
180
-						$typeFilter="Boolean";
181
-						break;
182
-					case 'sellist':
183
-						$tmp='';
184
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
186
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
187
-						break;
188
-				}
189
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
190
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
191
-				$this->export_entities_array[$r][$fieldname]='product';
192
-		    }
193
-		}
194
-		// End add extra fields
195
-
196
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
144
+        $r++;
145
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
146
+        $this->export_label[$r]="Services";	// Translation key (used only if key ExportDataset_xxx_z not found)
147
+        $this->export_permission[$r]=array(array("service","export"));
148
+        $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
149
+        if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
150
+        if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
151
+        //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
152
+        $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
153
+        if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
154
+        if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
155
+        $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
156
+        if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
157
+        if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
158
+        // Add extra fields
159
+        $sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
+        $resql=$this->db->query($sql);
161
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
162
+        {
163
+            while ($obj=$this->db->fetch_object($resql))
164
+            {
165
+                $fieldname='extra.'.$obj->name;
166
+                $fieldlabel=ucfirst($obj->label);
167
+                $typeFilter="Text";
168
+                switch($obj->type)
169
+                {
170
+                    case 'int':
171
+                    case 'double':
172
+                    case 'price':
173
+                        $typeFilter="Numeric";
174
+                        break;
175
+                    case 'date':
176
+                    case 'datetime':
177
+                        $typeFilter="Date";
178
+                        break;
179
+                    case 'boolean':
180
+                        $typeFilter="Boolean";
181
+                        break;
182
+                    case 'sellist':
183
+                        $tmp='';
184
+                        $tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
+                        if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
186
+                        if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
187
+                        break;
188
+                }
189
+                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
190
+                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
191
+                $this->export_entities_array[$r][$fieldname]='product';
192
+            }
193
+        }
194
+        // End add extra fields
195
+
196
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
197
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
198 198
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
-		if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
199
+        if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
200 200
         $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
201 201
 
202 202
 
203
-		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
204
-		{
205
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
206
-			{
207
-				// Exports product multiprice
208
-				$r++;
209
-				$this->export_code[$r]=$this->rights_class.'_'.$r;
210
-				$this->export_label[$r]="ProductsMultiPrice";	// Translation key (used only if key ExportDataset_xxx_z not found)
211
-				$this->export_permission[$r]=array(array("produit","export"));
212
-				$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",
213
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
214
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
216
-					'pr.tva_tx'=>'PriceLevelVATRate',
217
-					'pr.date_price'=>'DateCreation');
218
-				//$this->export_TypeFields_array[$r]=array(
219
-				//	'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",
220
-				//	'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',
221
-				//	'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
222
-				//	'p.datec'=>'Date','p.tms'=>'Date'
223
-				//);
224
-				$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",
225
-					'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product",
226
-					'pr.price_ttc'=>"product",
227
-					'pr.price_min'=>"product",'pr.price_min_ttc'=>"product",
228
-					'pr.tva_tx'=>'product',
229
-					'pr.date_price'=>"product");
230
-				$this->export_sql_start[$r]='SELECT DISTINCT ';
231
-				$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
232
-				$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
-				$this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
234
-			}
235
-		}
236
-
237
-
238
-		// Imports
239
-		//--------
240
-		$r=0;
203
+        if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
204
+        {
205
+            if (! empty($conf->global->PRODUIT_MULTIPRICES))
206
+            {
207
+                // Exports product multiprice
208
+                $r++;
209
+                $this->export_code[$r]=$this->rights_class.'_'.$r;
210
+                $this->export_label[$r]="ProductsMultiPrice";	// Translation key (used only if key ExportDataset_xxx_z not found)
211
+                $this->export_permission[$r]=array(array("produit","export"));
212
+                $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",
213
+                    'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
214
+                    'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
+                    'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
216
+                    'pr.tva_tx'=>'PriceLevelVATRate',
217
+                    'pr.date_price'=>'DateCreation');
218
+                //$this->export_TypeFields_array[$r]=array(
219
+                //	'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",
220
+                //	'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',
221
+                //	'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
222
+                //	'p.datec'=>'Date','p.tms'=>'Date'
223
+                //);
224
+                $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",
225
+                    'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product",
226
+                    'pr.price_ttc'=>"product",
227
+                    'pr.price_min'=>"product",'pr.price_min_ttc'=>"product",
228
+                    'pr.tva_tx'=>'product',
229
+                    'pr.date_price'=>"product");
230
+                $this->export_sql_start[$r]='SELECT DISTINCT ';
231
+                $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
232
+                $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
+                $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
234
+            }
235
+        }
236
+
237
+
238
+        // Imports
239
+        //--------
240
+        $r=0;
241 241
 
242
-		$r++;
243
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
244
-		$this->import_label[$r]="Products";	// Translation key
245
-		$this->import_icon[$r]=$this->picto;
246
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
247
-		$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
-		$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author');	// Fields to store import user id
242
+        $r++;
243
+        $this->import_code[$r]=$this->rights_class.'_'.$r;
244
+        $this->import_label[$r]="Products";	// Translation key
245
+        $this->import_icon[$r]=$this->picto;
246
+        $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
247
+        $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
+        $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author');	// Fields to store import user id
249 249
         $this->import_fields_array[$r]=array(
250
-			'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
-			'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",
252
-			'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",
253
-			'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
254
-		);
255
-		if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
256
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
250
+            'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
+            'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",
252
+            'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",
253
+            'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
254
+        );
255
+        if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
256
+        if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
257 257
         // Add extra fields
258
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
-		$resql=$this->db->query($sql);
260
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
261
-		{
262
-		    while ($obj=$this->db->fetch_object($resql))
263
-		    {
264
-		        $fieldname='extra.'.$obj->name;
265
-		        $fieldlabel=ucfirst($obj->label);
266
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
267
-		    }
268
-		}
269
-		// End add extra fields
270
-		$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
-		$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
-		$this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
273
-
274
-
275
-		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
276
-		{
277
-			if (! empty($conf->fournisseur->enabled))
278
-			{
279
-				// Import suppliers prices (note: this code is duplicated into module product)
280
-				$r++;
281
-				$this->import_code[$r]=$this->rights_class.'_supplierprices';
282
-				$this->import_label[$r]="SuppliersPricesOfProductsOrServices";	// Translation key
283
-				$this->import_icon[$r]=$this->picto;
284
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
285
-				$this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
-				$this->import_tables_creator_array[$r]=array('sp'=>'fk_user');
287
-				$this->import_fields_array[$r]=array(
288
-					'sp.fk_product'=>"ProductOrService*",
289
-					'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode'
290
-				);
291
-				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
292
-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
-				$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array(
295
-					'sp.price'=>"PriceQtyMinHT*",
296
-					'sp.unitprice'=>'UnitPriceHT*',	// TODO Make this field not required and calculate it from price and qty
297
-					'sp.remise_percent'=>'DiscountQtyMin'
298
-				));
299
-
300
-				$this->import_convertvalue_array[$r]=array(
301
-						'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
302
-						'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
303
-				);
304
-				$this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456",
305
-						'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
306
-						'sp.price'=>"50",
307
-						'sp.unitprice'=>'50',
308
-						'sp.remise_percent'=>'0'
309
-				);
310
-			}
311
-
312
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
313
-			{
314
-				// Import product multiprice
315
-				$r++;
316
-				$this->import_code[$r]=$this->rights_class.'_multiprice';
317
-				$this->import_label[$r]="ProductsOrServiceMultiPrice";	// Translation key
318
-				$this->import_icon[$r]=$this->picto;
319
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
320
-				$this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price');
321
-				$this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author');	// Fields to store import user id
322
-				$this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*",
323
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
324
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
326
-					'pr.tva_tx'=>'PriceLevelVATRate',
327
-					'pr.date_price'=>'DateCreation*');
328
-				$this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
-				$this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1",
330
-					'pr.price_base_type'=>"HT",'pr.price_level'=>"1",
331
-					'pr.price'=>"100",'pr.price_ttc'=>"110",
332
-					'pr.price_min'=>"100",'pr.price_min_ttc'=>"110",
333
-					'pr.tva_tx'=>'19.6',
334
-					'pr.date_price'=>'2013-04-10');
335
-			}
336
-
337
-			if (! empty($conf->global->MAIN_MULTILANGS))
338
-			{
339
-				$r++;
340
-				$this->import_code[$r]=$this->rights_class.'_languages';
341
-				$this->import_label[$r]="ProductsOrServicesTranslations";
342
-				$this->import_icon[$r]=$this->picto;
343
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
344
-				$this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
345
-				// multiline translation, one line per translation
346
-				$this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
347
-				//$this->import_fields_array[$r]['l.note']='TranslatedNote';
348
-				$this->import_convertvalue_array[$r]=array(
349
-				'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
350
-				);
351
-				$this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
352
-				$this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
353
-			}
354
-		}
355
-	}
356
-
357
-
358
-	/**
359
-	 *		Function called when module is enabled.
360
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
361
-	 *		It also creates data directories
362
-	 *
258
+        $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
+        $resql=$this->db->query($sql);
260
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
261
+        {
262
+            while ($obj=$this->db->fetch_object($resql))
263
+            {
264
+                $fieldname='extra.'.$obj->name;
265
+                $fieldlabel=ucfirst($obj->label);
266
+                $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
267
+            }
268
+        }
269
+        // End add extra fields
270
+        $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
+        $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
+        $this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
273
+
274
+
275
+        if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
276
+        {
277
+            if (! empty($conf->fournisseur->enabled))
278
+            {
279
+                // Import suppliers prices (note: this code is duplicated into module product)
280
+                $r++;
281
+                $this->import_code[$r]=$this->rights_class.'_supplierprices';
282
+                $this->import_label[$r]="SuppliersPricesOfProductsOrServices";	// Translation key
283
+                $this->import_icon[$r]=$this->picto;
284
+                $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
285
+                $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
+                $this->import_tables_creator_array[$r]=array('sp'=>'fk_user');
287
+                $this->import_fields_array[$r]=array(
288
+                    'sp.fk_product'=>"ProductOrService*",
289
+                    'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode'
290
+                );
291
+                if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
292
+                if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
+                if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
+                $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array(
295
+                    'sp.price'=>"PriceQtyMinHT*",
296
+                    'sp.unitprice'=>'UnitPriceHT*',	// TODO Make this field not required and calculate it from price and qty
297
+                    'sp.remise_percent'=>'DiscountQtyMin'
298
+                ));
299
+
300
+                $this->import_convertvalue_array[$r]=array(
301
+                        'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
302
+                        'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
303
+                );
304
+                $this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456",
305
+                        'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
306
+                        'sp.price'=>"50",
307
+                        'sp.unitprice'=>'50',
308
+                        'sp.remise_percent'=>'0'
309
+                );
310
+            }
311
+
312
+            if (! empty($conf->global->PRODUIT_MULTIPRICES))
313
+            {
314
+                // Import product multiprice
315
+                $r++;
316
+                $this->import_code[$r]=$this->rights_class.'_multiprice';
317
+                $this->import_label[$r]="ProductsOrServiceMultiPrice";	// Translation key
318
+                $this->import_icon[$r]=$this->picto;
319
+                $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
320
+                $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price');
321
+                $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author');	// Fields to store import user id
322
+                $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*",
323
+                    'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
324
+                    'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
+                    'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
326
+                    'pr.tva_tx'=>'PriceLevelVATRate',
327
+                    'pr.date_price'=>'DateCreation*');
328
+                $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
+                $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1",
330
+                    'pr.price_base_type'=>"HT",'pr.price_level'=>"1",
331
+                    'pr.price'=>"100",'pr.price_ttc'=>"110",
332
+                    'pr.price_min'=>"100",'pr.price_min_ttc'=>"110",
333
+                    'pr.tva_tx'=>'19.6',
334
+                    'pr.date_price'=>'2013-04-10');
335
+            }
336
+
337
+            if (! empty($conf->global->MAIN_MULTILANGS))
338
+            {
339
+                $r++;
340
+                $this->import_code[$r]=$this->rights_class.'_languages';
341
+                $this->import_label[$r]="ProductsOrServicesTranslations";
342
+                $this->import_icon[$r]=$this->picto;
343
+                $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
344
+                $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
345
+                // multiline translation, one line per translation
346
+                $this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
347
+                //$this->import_fields_array[$r]['l.note']='TranslatedNote';
348
+                $this->import_convertvalue_array[$r]=array(
349
+                'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
350
+                );
351
+                $this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
352
+                $this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
353
+            }
354
+        }
355
+    }
356
+
357
+
358
+    /**
359
+     *		Function called when module is enabled.
360
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
361
+     *		It also creates data directories
362
+     *
363 363
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
364
-	 *      @return     int             	1 if OK, 0 if KO
365
-	 */
366
-	function init($options='')
367
-	{
368
-		$this->remove($options);
364
+     *      @return     int             	1 if OK, 0 if KO
365
+     */
366
+    function init($options='')
367
+    {
368
+        $this->remove($options);
369 369
 
370
-		$sql = array();
370
+        $sql = array();
371 371
 
372
-		return $this->_init($sql,$options);
373
-	}
372
+        return $this->_init($sql,$options);
373
+    }
374 374
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\ingroup    service
27 27
  *	\brief      Fichier de description et activation du module Service
28 28
  */
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,42 +50,42 @@  discard block
 block discarded – undo
50 50
 		$this->family = "products";
51 51
 		$this->module_position = '30';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Service management";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='service';
60
+		$this->picto = 'service';
61 61
 
62 62
 		// Data directories to create when module is enabled
63 63
 		$this->dirs = array("/product/temp");
64 64
 
65 65
 		// Dependencies
66
-		$this->hidden = false;			// A condition to hide module
67
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
69
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
66
+		$this->hidden = false; // A condition to hide module
67
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
68
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
69
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
70
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
71 71
 
72 72
 		// Config pages
73 73
 		$this->config_page_url = array("product.php@product");
74
-		$this->langfiles = array("products","companies","bills");
74
+		$this->langfiles = array("products", "companies", "bills");
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array();
78 78
 
79 79
 		// Boxes
80 80
 		$this->boxes = array(
81
-			0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'),
82
-			1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home')
81
+			0=>array('file'=>'box_services_contracts.php', 'enabledbydefaulton'=>'Home'),
82
+			1=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home')
83 83
 		);
84 84
 
85 85
 		// Permissions
86 86
 		$this->rights = array();
87 87
 		$this->rights_class = 'service';
88
-		$r=0;
88
+		$r = 0;
89 89
 
90 90
 		$this->rights[$r][0] = 531; // id de la permission
91 91
 		$this->rights[$r][1] = 'Read services'; // libelle de la permission
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$this->rights[$r][4] = 'supprimer';
109 109
         $r++;
110 110
 
111
-		$this->rights[$r][0] = 538;	// Must be same permission than in product module
111
+		$this->rights[$r][0] = 538; // Must be same permission than in product module
112 112
 		$this->rights[$r][1] = 'Export services';
113 113
 		$this->rights[$r][2] = 'r';
114 114
 		$this->rights[$r][3] = 0;
@@ -134,85 +134,85 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Menus
136 136
 		//-------
137
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
137
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
138 138
 
139 139
 
140 140
         // Exports
141 141
 		//--------
142
-		$r=0;
142
+		$r = 0;
143 143
 
144 144
 		$r++;
145
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
146
-		$this->export_label[$r]="Services";	// Translation key (used only if key ExportDataset_xxx_z not found)
147
-		$this->export_permission[$r]=array(array("service","export"));
148
-		$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
149
-		if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
150
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
145
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
146
+		$this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found)
147
+		$this->export_permission[$r] = array(array("service", "export"));
148
+		$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification');
149
+		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock'));
150
+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
151 151
 		//$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
152
-		$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
153
-		if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
154
-		if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
155
-		$this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
156
-		if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
157
-		if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
152
+		$this->export_TypeFields_array[$r] = array('p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.note'=>"Text", 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date');
153
+		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric'));
154
+		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
155
+		$this->export_entities_array[$r] = array('p.rowid'=>"service", 'p.ref'=>"service", 'p.label'=>"service", 'p.description'=>"service", 'p.accountancy_code_sell'=>'service', 'p.note'=>"service", 'p.price_base_type'=>"service", 'p.price'=>"service", 'p.price_ttc'=>"service", 'p.tva_tx'=>"service", 'p.tosell'=>"service", 'p.tobuy'=>"service", 'p.duration'=>"service", 'p.datec'=>"service", 'p.tms'=>"service");
156
+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'service'));
157
+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'service'));
158 158
 		// Add extra fields
159
-		$sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
-		$resql=$this->db->query($sql);
159
+		$sql = "SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160
+		$resql = $this->db->query($sql);
161 161
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
162 162
 		{
163
-		    while ($obj=$this->db->fetch_object($resql))
163
+		    while ($obj = $this->db->fetch_object($resql))
164 164
 		    {
165
-		        $fieldname='extra.'.$obj->name;
166
-		        $fieldlabel=ucfirst($obj->label);
167
-		    	$typeFilter="Text";
168
-				switch($obj->type)
165
+		        $fieldname = 'extra.'.$obj->name;
166
+		        $fieldlabel = ucfirst($obj->label);
167
+		    	$typeFilter = "Text";
168
+				switch ($obj->type)
169 169
 				{
170 170
 					case 'int':
171 171
 					case 'double':
172 172
 					case 'price':
173
-						$typeFilter="Numeric";
173
+						$typeFilter = "Numeric";
174 174
 						break;
175 175
 					case 'date':
176 176
 					case 'datetime':
177
-						$typeFilter="Date";
177
+						$typeFilter = "Date";
178 178
 						break;
179 179
 					case 'boolean':
180
-						$typeFilter="Boolean";
180
+						$typeFilter = "Boolean";
181 181
 						break;
182 182
 					case 'sellist':
183
-						$tmp='';
184
-						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
186
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
183
+						$tmp = '';
184
+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
186
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
187 187
 						break;
188 188
 				}
189
-				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
190
-				$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
191
-				$this->export_entities_array[$r][$fieldname]='product';
189
+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;
190
+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
191
+				$this->export_entities_array[$r][$fieldname] = 'product';
192 192
 		    }
193 193
 		}
194 194
 		// End add extra fields
195 195
 
196
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
198
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
-		if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
200
-        $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
196
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
197
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
198
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
+		if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
200
+        $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
201 201
 
202 202
 
203 203
 		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
204 204
 		{
205
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
205
+			if (!empty($conf->global->PRODUIT_MULTIPRICES))
206 206
 			{
207 207
 				// Exports product multiprice
208 208
 				$r++;
209
-				$this->export_code[$r]=$this->rights_class.'_'.$r;
210
-				$this->export_label[$r]="ProductsMultiPrice";	// Translation key (used only if key ExportDataset_xxx_z not found)
211
-				$this->export_permission[$r]=array(array("produit","export"));
212
-				$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",
213
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
214
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
209
+				$this->export_code[$r] = $this->rights_class.'_'.$r;
210
+				$this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found)
211
+				$this->export_permission[$r] = array(array("produit", "export"));
212
+				$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",
213
+					'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel",
214
+					'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
215
+					'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
216 216
 					'pr.tva_tx'=>'PriceLevelVATRate',
217 217
 					'pr.date_price'=>'DateCreation');
218 218
 				//$this->export_TypeFields_array[$r]=array(
@@ -221,135 +221,135 @@  discard block
 block discarded – undo
221 221
 				//	'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
222 222
 				//	'p.datec'=>'Date','p.tms'=>'Date'
223 223
 				//);
224
-				$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",
225
-					'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product",
224
+				$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
225
+					'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product",
226 226
 					'pr.price_ttc'=>"product",
227
-					'pr.price_min'=>"product",'pr.price_min_ttc'=>"product",
227
+					'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",
228 228
 					'pr.tva_tx'=>'product',
229 229
 					'pr.date_price'=>"product");
230
-				$this->export_sql_start[$r]='SELECT DISTINCT ';
231
-				$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
232
-				$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
-				$this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
230
+				$this->export_sql_start[$r] = 'SELECT DISTINCT ';
231
+				$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
232
+				$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
233
+				$this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
234 234
 			}
235 235
 		}
236 236
 
237 237
 
238 238
 		// Imports
239 239
 		//--------
240
-		$r=0;
240
+		$r = 0;
241 241
 
242 242
 		$r++;
243
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
244
-		$this->import_label[$r]="Products";	// Translation key
245
-		$this->import_icon[$r]=$this->picto;
246
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
247
-		$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
-		$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author');	// Fields to store import user id
249
-        $this->import_fields_array[$r]=array(
250
-			'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
-			'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",
252
-			'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",
253
-			'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
243
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
244
+		$this->import_label[$r] = "Products"; // Translation key
245
+		$this->import_icon[$r] = $this->picto;
246
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
247
+		$this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields');
248
+		$this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id
249
+        $this->import_fields_array[$r] = array(
250
+			'p.ref'=>"Ref*", 'p.label'=>"Label*", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode",
251
+			'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"Note", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume",
252
+			'p.weight'=>"Weight", 'p.duration'=>"Duration", 'p.customcode'=>'CustomCode', 'p.price'=>"SellingPriceHT", 'p.price_ttc'=>"SellingPriceTTC",
253
+			'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell*", 'p.tobuy'=>"OnBuy*", 'p.fk_product_type'=>"Type*", 'p.finished'=>'Nature', 'p.datec'=>'DateCreation'
254 254
 		);
255
-		if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
256
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
255
+		if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));
256
+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
257 257
         // Add extra fields
258
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
-		$resql=$this->db->query($sql);
258
+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259
+		$resql = $this->db->query($sql);
260 260
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
261 261
 		{
262
-		    while ($obj=$this->db->fetch_object($resql))
262
+		    while ($obj = $this->db->fetch_object($resql))
263 263
 		    {
264
-		        $fieldname='extra.'.$obj->name;
265
-		        $fieldlabel=ucfirst($obj->label);
266
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
264
+		        $fieldname = 'extra.'.$obj->name;
265
+		        $fieldlabel = ucfirst($obj->label);
266
+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
267 267
 		    }
268 268
 		}
269 269
 		// End add extra fields
270
-		$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
-		$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
-		$this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
270
+		$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
271
+		$this->import_regex_array[$r] = array('p.ref'=>'[^ ]', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
272
+		$this->import_examplevalues_array[$r] = array('p.ref'=>"PREF123456", 'p.label'=>"My product", 'p.description'=>"This is a description example for record", 'p.note'=>"Some note", 'p.price'=>"100", 'p.price_ttc'=>"110", 'p.tva_tx'=>'10', 'p.tosell'=>"0 or 1", 'p.tobuy'=>"0 or 1", 'p.fk_product_type'=>"0 for product/1 for service", 'p.finished'=>'', 'p.duration'=>"1y", 'p.datec'=>'2008-12-31');
273 273
 
274 274
 
275 275
 		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
276 276
 		{
277
-			if (! empty($conf->fournisseur->enabled))
277
+			if (!empty($conf->fournisseur->enabled))
278 278
 			{
279 279
 				// Import suppliers prices (note: this code is duplicated into module product)
280 280
 				$r++;
281
-				$this->import_code[$r]=$this->rights_class.'_supplierprices';
282
-				$this->import_label[$r]="SuppliersPricesOfProductsOrServices";	// Translation key
283
-				$this->import_icon[$r]=$this->picto;
284
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
285
-				$this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
-				$this->import_tables_creator_array[$r]=array('sp'=>'fk_user');
287
-				$this->import_fields_array[$r]=array(
281
+				$this->import_code[$r] = $this->rights_class.'_supplierprices';
282
+				$this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key
283
+				$this->import_icon[$r] = $this->picto;
284
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
285
+				$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
286
+				$this->import_tables_creator_array[$r] = array('sp'=>'fk_user');
287
+				$this->import_fields_array[$r] = array(
288 288
 					'sp.fk_product'=>"ProductOrService*",
289 289
 					'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode'
290 290
 				);
291
-				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
292
-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
-				$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array(
291
+				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
292
+				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
+				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
294
+				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
295 295
 					'sp.price'=>"PriceQtyMinHT*",
296
-					'sp.unitprice'=>'UnitPriceHT*',	// TODO Make this field not required and calculate it from price and qty
296
+					'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
297 297
 					'sp.remise_percent'=>'DiscountQtyMin'
298 298
 				));
299 299
 
300
-				$this->import_convertvalue_array[$r]=array(
301
-						'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
302
-						'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
300
+				$this->import_convertvalue_array[$r] = array(
301
+						'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
302
+						'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
303 303
 				);
304
-				$this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456",
305
-						'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
304
+				$this->import_examplevalues_array[$r] = array('sp.fk_product'=>"PREF123456",
305
+						'sp.fk_soc'=>"My Supplier", 'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
306 306
 						'sp.price'=>"50",
307 307
 						'sp.unitprice'=>'50',
308 308
 						'sp.remise_percent'=>'0'
309 309
 				);
310 310
 			}
311 311
 
312
-			if (! empty($conf->global->PRODUIT_MULTIPRICES))
312
+			if (!empty($conf->global->PRODUIT_MULTIPRICES))
313 313
 			{
314 314
 				// Import product multiprice
315 315
 				$r++;
316
-				$this->import_code[$r]=$this->rights_class.'_multiprice';
317
-				$this->import_label[$r]="ProductsOrServiceMultiPrice";	// Translation key
318
-				$this->import_icon[$r]=$this->picto;
319
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
320
-				$this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price');
321
-				$this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author');	// Fields to store import user id
322
-				$this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*",
323
-					'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
324
-					'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
-					'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
316
+				$this->import_code[$r] = $this->rights_class.'_multiprice';
317
+				$this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key
318
+				$this->import_icon[$r] = $this->picto;
319
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
320
+				$this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price');
321
+				$this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id
322
+				$this->import_fields_array[$r] = array('pr.fk_product'=>"ProductRowid*",
323
+					'pr.price_base_type'=>"PriceLevelPriceBase", 'pr.price_level'=>"PriceLevel",
324
+					'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
325
+					'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
326 326
 					'pr.tva_tx'=>'PriceLevelVATRate',
327 327
 					'pr.date_price'=>'DateCreation*');
328
-				$this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
-				$this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1",
330
-					'pr.price_base_type'=>"HT",'pr.price_level'=>"1",
331
-					'pr.price'=>"100",'pr.price_ttc'=>"110",
332
-					'pr.price_min'=>"100",'pr.price_min_ttc'=>"110",
328
+				$this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
329
+				$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"1",
330
+					'pr.price_base_type'=>"HT", 'pr.price_level'=>"1",
331
+					'pr.price'=>"100", 'pr.price_ttc'=>"110",
332
+					'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
333 333
 					'pr.tva_tx'=>'19.6',
334 334
 					'pr.date_price'=>'2013-04-10');
335 335
 			}
336 336
 
337
-			if (! empty($conf->global->MAIN_MULTILANGS))
337
+			if (!empty($conf->global->MAIN_MULTILANGS))
338 338
 			{
339 339
 				$r++;
340
-				$this->import_code[$r]=$this->rights_class.'_languages';
341
-				$this->import_label[$r]="ProductsOrServicesTranslations";
342
-				$this->import_icon[$r]=$this->picto;
343
-				$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
344
-				$this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang');
340
+				$this->import_code[$r] = $this->rights_class.'_languages';
341
+				$this->import_label[$r] = "ProductsOrServicesTranslations";
342
+				$this->import_icon[$r] = $this->picto;
343
+				$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
344
+				$this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');
345 345
 				// multiline translation, one line per translation
346
-				$this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
346
+				$this->import_fields_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
347 347
 				//$this->import_fields_array[$r]['l.note']='TranslatedNote';
348
-				$this->import_convertvalue_array[$r]=array(
349
-				'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
348
+				$this->import_convertvalue_array[$r] = array(
349
+				'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
350 350
 				);
351
-				$this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
352
-				$this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
351
+				$this->import_examplevalues_array[$r] = array('l.fk_product'=>'MyProductRef', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');
352
+				$this->import_updatekeys_array[$r] = array('l.fk_product'=>'Ref', 'l.lang'=>'Language');
353 353
 			}
354 354
 		}
355 355
 	}
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
364 364
 	 *      @return     int             	1 if OK, 0 if KO
365 365
 	 */
366
-	function init($options='')
366
+	function init($options = '')
367 367
 	{
368 368
 		$this->remove($options);
369 369
 
370 370
 		$sql = array();
371 371
 
372
-		return $this->_init($sql,$options);
372
+		return $this->_init($sql, $options);
373 373
 	}
374 374
 }
Please login to merge, or discard this patch.
Braces   +54 added lines, -18 removed lines patch added patch discarded remove patch
@@ -146,23 +146,37 @@  discard block
 block discarded – undo
146 146
 		$this->export_label[$r]="Services";	// Translation key (used only if key ExportDataset_xxx_z not found)
147 147
 		$this->export_permission[$r]=array(array("service","export"));
148 148
 		$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
149
-		if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
150
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
149
+		if (! empty($conf->stock->enabled)) {
150
+		    $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock'));
151
+		}
152
+		if (! empty($conf->global->PRODUCT_USE_UNITS)) {
153
+		    $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
154
+		}
151 155
 		//$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
152 156
 		$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date');
153
-		if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
154
-		if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
157
+		if (! empty($conf->stock->enabled)) {
158
+		    $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric'));
159
+		}
160
+		if (! empty($conf->barcode->enabled)) {
161
+		    $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
162
+		}
155 163
 		$this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
156
-		if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
157
-		if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
164
+		if (! empty($conf->stock->enabled)) {
165
+		    $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service'));
166
+		}
167
+		if (! empty($conf->barcode->enabled)) {
168
+		    $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service'));
169
+		}
158 170
 		// Add extra fields
159 171
 		$sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'";
160 172
 		$resql=$this->db->query($sql);
161
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
173
+		if ($resql) {
174
+		    // This can fail when class is used on old database (during migration for example)
162 175
 		{
163 176
 		    while ($obj=$this->db->fetch_object($resql))
164 177
 		    {
165 178
 		        $fieldname='extra.'.$obj->name;
179
+		}
166 180
 		        $fieldlabel=ucfirst($obj->label);
167 181
 		    	$typeFilter="Text";
168 182
 				switch($obj->type)
@@ -182,8 +196,12 @@  discard block
 block discarded – undo
182 196
 					case 'sellist':
183 197
 						$tmp='';
184 198
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
185
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
186
-						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
199
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {
200
+						    $tmp=array_shift(array_keys($tmpparam['options']));
201
+						}
202
+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
203
+						    $typeFilter="List:".$tmp;
204
+						}
187 205
 						break;
188 206
 				}
189 207
 				$this->export_fields_array[$r][$fieldname]=$fieldlabel;
@@ -196,16 +214,20 @@  discard block
 block discarded – undo
196 214
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
197 215
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p';
198 216
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
199
-		if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
217
+		if (! empty($conf->fournisseur->enabled)) {
218
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
219
+		}
200 220
         $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
201 221
 
202 222
 
203
-		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
223
+		if (empty($conf->product->enabled)) {
224
+		    // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
204 225
 		{
205 226
 			if (! empty($conf->global->PRODUIT_MULTIPRICES))
206 227
 			{
207 228
 				// Exports product multiprice
208 229
 				$r++;
230
+		}
209 231
 				$this->export_code[$r]=$this->rights_class.'_'.$r;
210 232
 				$this->export_label[$r]="ProductsMultiPrice";	// Translation key (used only if key ExportDataset_xxx_z not found)
211 233
 				$this->export_permission[$r]=array(array("produit","export"));
@@ -252,16 +274,22 @@  discard block
 block discarded – undo
252 274
 			'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",
253 275
 			'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
254 276
 		);
255
-		if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
256
-		if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
277
+		if (! empty($conf->barcode->enabled)) {
278
+		    $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
279
+		}
280
+		if (! empty($conf->global->PRODUCT_USE_UNITS)) {
281
+		    $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
282
+		}
257 283
         // Add extra fields
258 284
 		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
259 285
 		$resql=$this->db->query($sql);
260
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
286
+		if ($resql) {
287
+		    // This can fail when class is used on old database (during migration for example)
261 288
 		{
262 289
 		    while ($obj=$this->db->fetch_object($resql))
263 290
 		    {
264 291
 		        $fieldname='extra.'.$obj->name;
292
+		}
265 293
 		        $fieldlabel=ucfirst($obj->label);
266 294
 		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
267 295
 		    }
@@ -272,12 +300,14 @@  discard block
 block discarded – undo
272 300
 		$this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
273 301
 
274 302
 
275
-		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)
303
+		if (empty($conf->product->enabled)) {
304
+		    // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
276 305
 		{
277 306
 			if (! empty($conf->fournisseur->enabled))
278 307
 			{
279 308
 				// Import suppliers prices (note: this code is duplicated into module product)
280 309
 				$r++;
310
+		}
281 311
 				$this->import_code[$r]=$this->rights_class.'_supplierprices';
282 312
 				$this->import_label[$r]="SuppliersPricesOfProductsOrServices";	// Translation key
283 313
 				$this->import_icon[$r]=$this->picto;
@@ -288,9 +318,15 @@  discard block
 block discarded – undo
288 318
 					'sp.fk_product'=>"ProductOrService*",
289 319
 					'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode'
290 320
 				);
291
-				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
292
-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
293
-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
321
+				if (is_object($mysoc) && $mysoc->useNPR()) {
322
+				    $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'VATNPR'));
323
+				}
324
+				if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
325
+				    $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
326
+				}
327
+				if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
328
+				    $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
329
+				}
294 330
 				$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array(
295 331
 					'sp.price'=>"PriceQtyMinHT*",
296 332
 					'sp.unitprice'=>'UnitPriceHT*',	// TODO Make this field not required and calculate it from price and qty
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modECM.class.php 2 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -32,151 +32,151 @@
 block discarded – undo
32 32
 class modECM extends DolibarrModules
33 33
 {
34 34
 
35
-   /**
36
-	 *   Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 *   @param      DoliDB		$db      Database handler
39
-    */
40
-	function __construct($db)
41
-	{
42
-		$this->db = $db;
43
-
44
-		// Id for module (must be unique).
45
-		// Use here a free id.
46
-		$this->numero = 2500;
47
-
48
-		// Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
49
-		// It is used to sort modules in module setup page
50
-		$this->family = "ecm";
51
-		$this->module_position = '10';
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
-		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55
-		$this->description = "Electronic Content Management";
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-		// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		// Name of png file (without png) used for this module
61
-		$this->picto='dir';
62
-
63
-		// Data directories to create when module is enabled
64
-		$this->dirs = array("/ecm/temp");
65
-
66
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module
67
-		$this->config_page_url = array('ecm.php');
68
-
69
-		// Dependencies
70
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
71
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
72
-
73
-		// Constants
74
-		$this->const = array();			// List of parameters
75
-		$r=0;
76
-
77
-		$this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";
78
-		$this->const[$r][1] = "chaine";
79
-		$this->const[$r][2] = "1";
80
-		$this->const[$r][3] = 'Auto tree is enabled by default';
81
-		$this->const[$r][4] = 0;
82
-
83
-		// Boxes
84
-		$this->boxes = array();			// List of boxes
85
-		$r=0;
86
-
87
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
88
-		// Example:
35
+    /**
36
+     *   Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     *   @param      DoliDB		$db      Database handler
39
+     */
40
+    function __construct($db)
41
+    {
42
+        $this->db = $db;
43
+
44
+        // Id for module (must be unique).
45
+        // Use here a free id.
46
+        $this->numero = 2500;
47
+
48
+        // Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
49
+        // It is used to sort modules in module setup page
50
+        $this->family = "ecm";
51
+        $this->module_position = '10';
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
+        // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55
+        $this->description = "Electronic Content Management";
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+        // Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        // Name of png file (without png) used for this module
61
+        $this->picto='dir';
62
+
63
+        // Data directories to create when module is enabled
64
+        $this->dirs = array("/ecm/temp");
65
+
66
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module
67
+        $this->config_page_url = array('ecm.php');
68
+
69
+        // Dependencies
70
+        $this->depends = array();		// List of modules id that must be enabled if this module is enabled
71
+        $this->requiredby = array();	// List of modules id to disable if this one is disabled
72
+
73
+        // Constants
74
+        $this->const = array();			// List of parameters
75
+        $r=0;
76
+
77
+        $this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";
78
+        $this->const[$r][1] = "chaine";
79
+        $this->const[$r][2] = "1";
80
+        $this->const[$r][3] = 'Auto tree is enabled by default';
81
+        $this->const[$r][4] = 0;
82
+
83
+        // Boxes
84
+        $this->boxes = array();			// List of boxes
85
+        $r=0;
86
+
87
+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
88
+        // Example:
89 89
         //$this->boxes[$r][1] = "myboxa.php";
90
-    	//$r++;
90
+        //$r++;
91 91
         //$this->boxes[$r][1] = "myboxb.php";
92
-    	//$r++;
93
-
94
-		// Permissions
95
-		$this->rights_class = 'ecm';	// Permission key
96
-		$this->rights = array();		// Permission array used by this module
97
-
98
-		$r++;
99
-		$this->rights[$r][0] = 2501;
100
-		$this->rights[$r][1] = 'Consulter/Télécharger les documents';
101
-		$this->rights[$r][2] = 'r';
102
-		$this->rights[$r][3] = 0;
103
-		$this->rights[$r][4] = 'read';
104
-
105
-		$r++;
106
-		$this->rights[$r][0] = 2503;
107
-		$this->rights[$r][1] = 'Soumettre ou supprimer des documents';
108
-		$this->rights[$r][2] = 'w';
109
-		$this->rights[$r][3] = 0;
110
-		$this->rights[$r][4] = 'upload';
111
-
112
-		$r++;
113
-		$this->rights[$r][0] = 2515;
114
-		$this->rights[$r][1] = 'Administrer les rubriques de documents';
115
-		$this->rights[$r][2] = 'w';
116
-		$this->rights[$r][3] = 0;
117
-		$this->rights[$r][4] = 'setup';
92
+        //$r++;
93
+
94
+        // Permissions
95
+        $this->rights_class = 'ecm';	// Permission key
96
+        $this->rights = array();		// Permission array used by this module
97
+
98
+        $r++;
99
+        $this->rights[$r][0] = 2501;
100
+        $this->rights[$r][1] = 'Consulter/Télécharger les documents';
101
+        $this->rights[$r][2] = 'r';
102
+        $this->rights[$r][3] = 0;
103
+        $this->rights[$r][4] = 'read';
104
+
105
+        $r++;
106
+        $this->rights[$r][0] = 2503;
107
+        $this->rights[$r][1] = 'Soumettre ou supprimer des documents';
108
+        $this->rights[$r][2] = 'w';
109
+        $this->rights[$r][3] = 0;
110
+        $this->rights[$r][4] = 'upload';
111
+
112
+        $r++;
113
+        $this->rights[$r][0] = 2515;
114
+        $this->rights[$r][1] = 'Administrer les rubriques de documents';
115
+        $this->rights[$r][2] = 'w';
116
+        $this->rights[$r][3] = 0;
117
+        $this->rights[$r][4] = 'setup';
118 118
 
119 119
 
120 120
         // Menus
121
-		//------
122
-		$this->menus = array();			// List of menus to add
123
-		$r=0;
124
-
125
-		// Top menu
126
-		$this->menu[$r]=array('fk_menu'=>0,
127
-							  'type'=>'top',
128
-							  'titre'=>'MenuECM',
129
-							  'mainmenu'=>'ecm',
130
-							  'url'=>'/ecm/index.php',
131
-							  'langs'=>'ecm',
132
-							  'position'=>82,
133
-							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',
134
-							  'enabled'=>'$conf->ecm->enabled',
135
-							  'target'=>'',
136
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
137
-		$r++;
138
-
139
-		// Left menu linked to top menu
140
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm',
141
-							  'type'=>'left',
142
-							  'titre'=>'ECMArea',
143
-							  'mainmenu'=>'ecm',
144
-							  'leftmenu'=>'ecm',
145
-							  'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm',
146
-							  'langs'=>'ecm',
147
-							  'position'=>101,
148
-							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
149
-							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
150
-							  'target'=>'',
151
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
152
-		$r++;
153
-
154
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
155
-							  'type'=>'left',
156
-							  'titre'=>'ECMSectionsManual',
157
-							  'mainmenu'=>'ecm',
158
-							  'leftmenu'=>'ecm_manual',
159
-							  'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
160
-							  'langs'=>'ecm',
161
-							  'position'=>102,
162
-							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
163
-							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
164
-							  'target'=>'',
165
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
166
-		$r++;
167
-
168
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
169
-							  'type'=>'left',
170
-							  'titre'=>'ECMSectionsAuto',
171
-							  'mainmenu'=>'ecm',
172
-							  'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
173
-							  'langs'=>'ecm',
174
-							  'position'=>103,
175
-							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
176
-							  'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)',
177
-							  'target'=>'',
178
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
179
-		$r++;
180
-	}
121
+        //------
122
+        $this->menus = array();			// List of menus to add
123
+        $r=0;
124
+
125
+        // Top menu
126
+        $this->menu[$r]=array('fk_menu'=>0,
127
+                                'type'=>'top',
128
+                                'titre'=>'MenuECM',
129
+                                'mainmenu'=>'ecm',
130
+                                'url'=>'/ecm/index.php',
131
+                                'langs'=>'ecm',
132
+                                'position'=>82,
133
+                                'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',
134
+                                'enabled'=>'$conf->ecm->enabled',
135
+                                'target'=>'',
136
+                                'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
137
+        $r++;
138
+
139
+        // Left menu linked to top menu
140
+        $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm',
141
+                                'type'=>'left',
142
+                                'titre'=>'ECMArea',
143
+                                'mainmenu'=>'ecm',
144
+                                'leftmenu'=>'ecm',
145
+                                'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm',
146
+                                'langs'=>'ecm',
147
+                                'position'=>101,
148
+                                'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
149
+                                'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
150
+                                'target'=>'',
151
+                                'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
152
+        $r++;
153
+
154
+        $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
155
+                                'type'=>'left',
156
+                                'titre'=>'ECMSectionsManual',
157
+                                'mainmenu'=>'ecm',
158
+                                'leftmenu'=>'ecm_manual',
159
+                                'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
160
+                                'langs'=>'ecm',
161
+                                'position'=>102,
162
+                                'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
163
+                                'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
164
+                                'target'=>'',
165
+                                'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
166
+        $r++;
167
+
168
+        $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
169
+                                'type'=>'left',
170
+                                'titre'=>'ECMSectionsAuto',
171
+                                'mainmenu'=>'ecm',
172
+                                'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
173
+                                'langs'=>'ecm',
174
+                                'position'=>103,
175
+                                'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
176
+                                'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)',
177
+                                'target'=>'',
178
+                                'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
179
+        $r++;
180
+    }
181 181
 }
182 182
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \brief      Description and activation file for module ECM
24 24
  */
25 25
 
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 
29 29
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->family = "ecm";
51 51
 		$this->module_position = '10';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55 55
 		$this->description = "Electronic Content Management";
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		// Name of png file (without png) used for this module
61
-		$this->picto='dir';
61
+		$this->picto = 'dir';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array("/ecm/temp");
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 		$this->config_page_url = array('ecm.php');
68 68
 
69 69
 		// Dependencies
70
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
71
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
70
+		$this->depends = array(); // List of modules id that must be enabled if this module is enabled
71
+		$this->requiredby = array(); // List of modules id to disable if this one is disabled
72 72
 
73 73
 		// Constants
74
-		$this->const = array();			// List of parameters
75
-		$r=0;
74
+		$this->const = array(); // List of parameters
75
+		$r = 0;
76 76
 
77 77
 		$this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";
78 78
 		$this->const[$r][1] = "chaine";
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 		$this->const[$r][4] = 0;
82 82
 
83 83
 		// Boxes
84
-		$this->boxes = array();			// List of boxes
85
-		$r=0;
84
+		$this->boxes = array(); // List of boxes
85
+		$r = 0;
86 86
 
87 87
 		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
88 88
 		// Example:
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     	//$r++;
93 93
 
94 94
 		// Permissions
95
-		$this->rights_class = 'ecm';	// Permission key
96
-		$this->rights = array();		// Permission array used by this module
95
+		$this->rights_class = 'ecm'; // Permission key
96
+		$this->rights = array(); // Permission array used by this module
97 97
 
98 98
 		$r++;
99 99
 		$this->rights[$r][0] = 2501;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
         // Menus
121 121
 		//------
122
-		$this->menus = array();			// List of menus to add
123
-		$r=0;
122
+		$this->menus = array(); // List of menus to add
123
+		$r = 0;
124 124
 
125 125
 		// Top menu
126
-		$this->menu[$r]=array('fk_menu'=>0,
126
+		$this->menu[$r] = array('fk_menu'=>0,
127 127
 							  'type'=>'top',
128 128
 							  'titre'=>'MenuECM',
129 129
 							  'mainmenu'=>'ecm',
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',
134 134
 							  'enabled'=>'$conf->ecm->enabled',
135 135
 							  'target'=>'',
136
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
136
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
137 137
 		$r++;
138 138
 
139 139
 		// Left menu linked to top menu
140
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm',
140
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm',
141 141
 							  'type'=>'left',
142 142
 							  'titre'=>'ECMArea',
143 143
 							  'mainmenu'=>'ecm',
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
149 149
 							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
150 150
 							  'target'=>'',
151
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
151
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
152 152
 		$r++;
153 153
 
154
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
154
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
155 155
 							  'type'=>'left',
156 156
 							  'titre'=>'ECMSectionsManual',
157 157
 							  'mainmenu'=>'ecm',
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
163 163
 							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
164 164
 							  'target'=>'',
165
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
165
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
166 166
 		$r++;
167 167
 
168
-		$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
168
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
169 169
 							  'type'=>'left',
170 170
 							  'titre'=>'ECMSectionsAuto',
171 171
 							  'mainmenu'=>'ecm',
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
176 176
 							  'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)',
177 177
 							  'target'=>'',
178
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
178
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
179 179
 		$r++;
180 180
 	}
181 181
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/reception/doc/pdf_squille.modules.php 3 patches
Indentation   +886 added lines, -886 removed lines patch added patch discarded remove patch
@@ -32,106 +32,106 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class pdf_squille extends ModelePdfReception
34 34
 {
35
-	var $emetteur;	// Objet societe qui emet
36
-
37
-
38
-	/**
39
-	 *	Constructor
40
-	 *
41
-	 *	@param	DoliDB	$db		Database handler
42
-	 */
43
-	function __construct($db=0)
44
-	{
45
-		global $conf,$langs,$mysoc;
46
-
47
-		$this->db = $db;
48
-		$this->name = "squille";
49
-		$this->description = $langs->trans("DocumentModelStandardPDF");
50
-
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->option_logo = 1;
62
-
63
-		// Get source company
64
-		$this->emetteur=$mysoc;
65
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
66
-
67
-		// Define position of columns
68
-		$this->posxdesc=$this->marge_gauche+1;
69
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
70
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
71
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
72
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
73
-
74
-		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
75
-
76
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
77
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
78
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
79
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
80
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
81
-		}
82
-
83
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
84
-
85
-		if ($this->page_largeur < 210) // To work with US executive format
86
-		{
87
-		    $this->posxweightvol-=20;
88
-		    $this->posxpicture-=20;
89
-		    $this->posxqtyordered-=20;
90
-		    $this->posxqtytoship-=20;
91
-		}
35
+    var $emetteur;	// Objet societe qui emet
92 36
 
93
-		if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
94
-		{
95
-		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
96
-		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
97
-		    $this->posxqtyordered = $this->posxqtytoship;
98
-		}
99
-	}
100
-
101
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
102
-	/**
103
-	 *	Function to build pdf onto disk
104
-	 *
105
-	 *	@param		Object		$object			Object reception to generate (or id if old method)
106
-	 *	@param		Translate	$outputlangs		Lang output object
37
+
38
+    /**
39
+     *	Constructor
40
+     *
41
+     *	@param	DoliDB	$db		Database handler
42
+     */
43
+    function __construct($db=0)
44
+    {
45
+        global $conf,$langs,$mysoc;
46
+
47
+        $this->db = $db;
48
+        $this->name = "squille";
49
+        $this->description = $langs->trans("DocumentModelStandardPDF");
50
+
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->option_logo = 1;
62
+
63
+        // Get source company
64
+        $this->emetteur=$mysoc;
65
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
66
+
67
+        // Define position of columns
68
+        $this->posxdesc=$this->marge_gauche+1;
69
+        $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
70
+        $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
71
+        $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
72
+        $this->posxpuht=$this->page_largeur - $this->marge_droite;
73
+
74
+        if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
75
+
76
+            $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
77
+            $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
78
+            $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
79
+            $this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
80
+            $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
81
+        }
82
+
83
+        $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
84
+
85
+        if ($this->page_largeur < 210) // To work with US executive format
86
+        {
87
+            $this->posxweightvol-=20;
88
+            $this->posxpicture-=20;
89
+            $this->posxqtyordered-=20;
90
+            $this->posxqtytoship-=20;
91
+        }
92
+
93
+        if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
94
+        {
95
+            $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
96
+            $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
97
+            $this->posxqtyordered = $this->posxqtytoship;
98
+        }
99
+    }
100
+
101
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
102
+    /**
103
+     *	Function to build pdf onto disk
104
+     *
105
+     *	@param		Object		$object			Object reception to generate (or id if old method)
106
+     *	@param		Translate	$outputlangs		Lang output object
107 107
      *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
108 108
      *  @param		int			$hidedetails		Do not show line details
109 109
      *  @param		int			$hidedesc			Do not show desc
110 110
      *  @param		int			$hideref			Do not show ref
111 111
      *  @return     int         	    			1=OK, 0=KO
112
-	 */
113
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
114
-	{
115
-		// phpcs:enable
116
-		global $user,$conf,$langs,$hookmanager;
117
-
118
-		$object->fetch_thirdparty();
119
-
120
-		if (! is_object($outputlangs)) $outputlangs=$langs;
121
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
122
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
123
-
124
-		$outputlangs->load("main");
125
-		$outputlangs->load("dict");
126
-		$outputlangs->load("companies");
127
-		$outputlangs->load("bills");
128
-		$outputlangs->load("products");
129
-		$outputlangs->load("propal");
130
-		$outputlangs->load("deliveries");
112
+     */
113
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
114
+    {
115
+        // phpcs:enable
116
+        global $user,$conf,$langs,$hookmanager;
117
+
118
+        $object->fetch_thirdparty();
119
+
120
+        if (! is_object($outputlangs)) $outputlangs=$langs;
121
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
122
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
123
+
124
+        $outputlangs->load("main");
125
+        $outputlangs->load("dict");
126
+        $outputlangs->load("companies");
127
+        $outputlangs->load("bills");
128
+        $outputlangs->load("products");
129
+        $outputlangs->load("propal");
130
+        $outputlangs->load("deliveries");
131 131
         $outputlangs->load("receptions");
132
-		$outputlangs->load("productbatch");
132
+        $outputlangs->load("productbatch");
133 133
 
134
-		$nblignes = count($object->lines);
134
+        $nblignes = count($object->lines);
135 135
 
136 136
         // Loop on each lines to detect if there is at least one image to show
137 137
         $realpatharray=array();
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
             {
144 144
                 if (empty($object->lines[$i]->fk_product)) continue;
145 145
 
146
-				$objphoto = new Product($this->db);
147
-				$objphoto->fetch($object->lines[$i]->fk_product);
146
+                $objphoto = new Product($this->db);
147
+                $objphoto->fetch($object->lines[$i]->fk_product);
148 148
 
149
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
150
-				$dir = $conf->product->dir_output.'/'.$pdir;
149
+                $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
150
+                $dir = $conf->product->dir_output.'/'.$pdir;
151 151
 
152
-				$realpath='';
152
+                $realpath='';
153 153
 
154 154
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
155 155
                         {
@@ -179,51 +179,51 @@  discard block
 block discarded – undo
179 179
 
180 180
         if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
181 181
 
182
-		if ($conf->reception->dir_output)
183
-		{
184
-			// Definition de $dir et $file
185
-			if ($object->specimen)
186
-			{
187
-				$dir = $conf->reception->dir_output;
188
-				$file = $dir . "/SPECIMEN.pdf";
189
-			}
190
-			else
191
-			{
192
-				$rcpref = dol_sanitizeFileName($object->ref);
193
-				$dir = $conf->reception->dir_output."/" . $rcpref;
194
-				$file = $dir . "/" . $rcpref . ".pdf";
195
-			}
196
-
197
-			if (! file_exists($dir))
198
-			{
199
-				if (dol_mkdir($dir) < 0)
200
-				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
-					return 0;
203
-				}
204
-			}
205
-
206
-			if (file_exists($dir))
207
-			{
208
-				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
210
-				{
211
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
213
-				}
214
-				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
-				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
-
219
-				// Set nblignes with the new facture lines content after hook
220
-				$nblignes = count($object->lines);
221
-
222
-				$pdf=pdf_getInstance($this->format);
223
-				$default_font_size = pdf_getPDFFontSize($outputlangs);
224
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
225
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
226
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
182
+        if ($conf->reception->dir_output)
183
+        {
184
+            // Definition de $dir et $file
185
+            if ($object->specimen)
186
+            {
187
+                $dir = $conf->reception->dir_output;
188
+                $file = $dir . "/SPECIMEN.pdf";
189
+            }
190
+            else
191
+            {
192
+                $rcpref = dol_sanitizeFileName($object->ref);
193
+                $dir = $conf->reception->dir_output."/" . $rcpref;
194
+                $file = $dir . "/" . $rcpref . ".pdf";
195
+            }
196
+
197
+            if (! file_exists($dir))
198
+            {
199
+                if (dol_mkdir($dir) < 0)
200
+                {
201
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
+                    return 0;
203
+                }
204
+            }
205
+
206
+            if (file_exists($dir))
207
+            {
208
+                // Add pdfgeneration hook
209
+                if (! is_object($hookmanager))
210
+                {
211
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
+                    $hookmanager=new HookManager($this->db);
213
+                }
214
+                $hookmanager->initHooks(array('pdfgeneration'));
215
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
+                global $action;
217
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
+
219
+                // Set nblignes with the new facture lines content after hook
220
+                $nblignes = count($object->lines);
221
+
222
+                $pdf=pdf_getInstance($this->format);
223
+                $default_font_size = pdf_getPDFFontSize($outputlangs);
224
+                $heightforinfotot = 8;	// Height reserved to output the info and total part
225
+                $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
226
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227 227
                 $pdf->SetAutoPageBreak(1,0);
228 228
 
229 229
                 if (class_exists('TCPDF'))
@@ -239,803 +239,803 @@  discard block
 block discarded – undo
239 239
                     $tplidx = $pdf->importPage(1);
240 240
                 }
241 241
 
242
-				$pdf->Open();
243
-				$pagenb=0;
244
-				$pdf->SetDrawColor(128,128,128);
245
-
246
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
247
-
248
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
249
-				$pdf->SetSubject($outputlangs->transnoentities("Reception"));
250
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
251
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
252
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
253
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
254
-
255
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
256
-
257
-				// New page
258
-				$pdf->AddPage();
259
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
260
-				$pagenb++;
261
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
262
-				$pdf->SetFont('','', $default_font_size - 1);
263
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
264
-				$pdf->SetTextColor(0,0,0);
265
-
266
-				$tab_top = 90;
267
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
268
-				$tab_height = 130;
269
-				$tab_height_newpage = 150;
270
-
271
-				// Incoterm
272
-				$height_incoterms = 0;
273
-				if ($conf->incoterm->enabled)
274
-				{
275
-					$desc_incoterms = $object->getIncotermsForPDF();
276
-					if ($desc_incoterms)
277
-					{
278
-						$tab_top = 88;
279
-
280
-						$pdf->SetFont('','', $default_font_size - 1);
281
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
282
-						$nexY = $pdf->GetY();
283
-						$height_incoterms=$nexY-$tab_top;
284
-
285
-						// Rect prend une longueur en 3eme param
286
-						$pdf->SetDrawColor(192,192,192);
287
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
288
-
289
-						$tab_top = $nexY+6;
290
-						$height_incoterms += 4;
291
-					}
292
-				}
293
-
294
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
295
-				{
296
-					$tab_top = 88 + $height_incoterms;
297
-					$tab_top_alt = $tab_top;
298
-
299
-					$pdf->SetFont('','B', $default_font_size - 2);
300
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
301
-
302
-					$tab_top_alt = $pdf->GetY();
303
-					//$tab_top_alt += 1;
304
-
305
-					// Tracking number
306
-					if (! empty($object->tracking_number))
307
-					{
308
-						$object->getUrlTrackingStatus($object->tracking_number);
309
-						if (! empty($object->tracking_url))
310
-						{
311
-							if ($object->reception_method_id > 0)
312
-							{
313
-								// Get code using getLabelFromKey
314
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code');
315
-								$label='';
316
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
-								$label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
318
-								//var_dump($object->tracking_url != $object->tracking_number);exit;
319
-								if ($object->tracking_url != $object->tracking_number)
320
-								{
321
-									$label.=" : ";
322
-									$label.=$object->tracking_url;
323
-								}
324
-								$pdf->SetFont('','B', $default_font_size - 2);
325
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
326
-
327
-								$tab_top_alt = $pdf->GetY();
328
-							}
329
-						}
330
-					}
331
-
332
-					// Notes
333
-					if (! empty($object->note_public))
334
-					{
335
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
336
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
337
-					}
338
-
339
-					$nexY = $pdf->GetY();
340
-					$height_note=$nexY-$tab_top;
341
-
342
-					// Rect prend une longueur en 3eme param
343
-					$pdf->SetDrawColor(192,192,192);
344
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
345
-
346
-					$tab_height = $tab_height - $height_note;
347
-					$tab_top = $nexY+6;
348
-				}
349
-				else
350
-				{
351
-					$height_note=0;
352
-				}
353
-
354
-				$iniY = $tab_top + 7;
355
-				$curY = $tab_top + 7;
356
-				$nexY = $tab_top + 7;
357
-				$fk_commandefourndet=0;
358
-				$totalOrdered=0;
359
-				// Loop on each lines
360
-				for ($i = 0; $i < $nblignes; $i++)
361
-				{
362
-					$curY = $nexY;
363
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
364
-					$pdf->SetTextColor(0,0,0);
365
-
366
-					// Define size of image if we need it
367
-					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
369
-
370
-					$pdf->setTopMargin($tab_top_newpage);
371
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
372
-					$pageposbefore=$pdf->getPage();
373
-
374
-					$showpricebeforepagebreak=1;
375
-					$posYAfterImage=0;
376
-					$posYAfterDescription=0;
377
-
378
-					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
380
-					{
381
-						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
383
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
384
-						$pdf->setPage($pageposbefore+1);
385
-
386
-						$curY = $tab_top_newpage;
387
-						$showpricebeforepagebreak=0;
388
-					}
389
-
390
-					if (isset($imglinesize['width']) && isset($imglinesize['height']))
391
-					{
392
-						$curX = $this->posxpicture-1;
393
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
394
-						// $pdf->Image does not increase value return by getY, so we save it manually
395
-						$posYAfterImage=$curY+$imglinesize['height'];
396
-					}
397
-
398
-					// Description of product line
399
-					$curX = $this->posxdesc-1;
400
-
401
-					$pdf->startTransaction();
402
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
403
-
404
-					$pageposafter=$pdf->getPage();
405
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
406
-					{
407
-						$pdf->rollbackTransaction(true);
408
-						$pageposafter=$pageposbefore;
409
-						//print $pageposafter.'-'.$pageposbefore;exit;
410
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
411
-
412
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
413
-
414
-						$pageposafter=$pdf->getPage();
415
-						$posyafter=$pdf->GetY();
416
-						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
417
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
418
-						{
419
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
420
-							{
421
-								$pdf->AddPage('','',true);
422
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
423
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424
-								$pdf->setPage($pageposafter+1);
425
-							}
426
-						}
427
-						else
428
-						{
429
-							// We found a page break
430
-							$showpricebeforepagebreak=0;
431
-						}
432
-					}
433
-					else	// No pagebreak
434
-					{
435
-						$pdf->commitTransaction();
436
-					}
437
-					$posYAfterDescription=$pdf->GetY();
438
-
439
-					$nexY = $pdf->GetY();
440
-					$pageposafter=$pdf->getPage();
441
-
442
-					$pdf->setPage($pageposbefore);
443
-					$pdf->setTopMargin($this->marge_haute);
444
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
445
-
446
-					// We suppose that a too long description or photo were moved completely on next page
447
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
448
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
449
-					}
450
-
451
-					// We suppose that a too long description is moved completely on next page
452
-					if ($pageposafter > $pageposbefore) {
453
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
454
-					}
455
-
456
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
457
-
458
-					$pdf->SetXY($this->posxweightvol, $curY);
459
-					$weighttxt='';
460
-					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight)
461
-					{
462
-					    $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight");
463
-					}
464
-					$voltxt='';
465
-					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume)
466
-					{
467
-					    $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume");
468
-					}
469
-
470
-					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
471
-					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
472
-
473
-					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
474
-					{
475
-					   $pdf->SetXY($this->posxqtyordered, $curY);
476
-					   if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
477
-						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
478
-						   $totalOrdered+=$object->lines[$i]->qty_asked;
479
-					   }
480
-					   $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
481
-					}
482
-
483
-					$pdf->SetXY($this->posxqtytoship, $curY);
484
-					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C');
485
-
486
-					if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
487
-					{
488
-						$pdf->SetXY($this->posxpuht, $curY);
489
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
490
-
491
-						$pdf->SetXY($this->posxtotalht, $curY);
492
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
493
-					}
494
-
495
-					$nexY+=3;
496
-					if ($weighttxt && $voltxt) $nexY+=2;
497
-
498
-					// Add line
499
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
500
-					{
501
-						$pdf->setPage($pageposafter);
502
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
503
-						//$pdf->SetDrawColor(190,190,200);
504
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
505
-						$pdf->SetLineStyle(array('dash'=>0));
506
-					}
507
-
508
-					// Detect if some page were added automatically and output _tableau for past pages
509
-					while ($pagenb < $pageposafter)
510
-					{
511
-						$pdf->setPage($pagenb);
512
-						if ($pagenb == 1)
513
-						{
514
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
515
-						}
516
-						else
517
-						{
518
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
519
-						}
520
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
521
-						$pagenb++;
522
-						$pdf->setPage($pagenb);
523
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
524
-					}
525
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
526
-					{
527
-						if ($pagenb == 1)
528
-						{
529
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
530
-						}
531
-						else
532
-						{
533
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
534
-						}
535
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
536
-						// New page
537
-						$pdf->AddPage();
538
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
539
-						$pagenb++;
540
-					}
541
-				}
542
-
543
-				// Show square
544
-				if ($pagenb == 1)
545
-				{
546
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
547
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548
-				}
549
-				else
550
-				{
551
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
552
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
553
-				}
554
-
555
-				// Affiche zone totaux
556
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
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
-				return 1;	// No error
576
-			}
577
-			else
578
-			{
579
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
580
-				return 0;
581
-			}
582
-		}
583
-		else
584
-		{
585
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
586
-			return 0;
587
-		}
588
-	}
589
-
590
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
591
-	/**
592
-	 *	Show total to pay
593
-	 *
594
-	 *	@param	PDF			$pdf            Object PDF
595
-	 *	@param  Facture		$object         Object invoice
596
-	 *	@param  int			$deja_regle     Montant deja regle
597
-	 *	@param	int			$posy			Position depart
598
-	 *	@param	Translate	$outputlangs	Objet langs
599
-	 *  @param	int			$totalOrdered	Total ordered
600
-	 *	@return int							Position pour suite
601
-	 */
602
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
603
-	{
604
-		// phpcs:enable
605
-		global $conf,$mysoc;
242
+                $pdf->Open();
243
+                $pagenb=0;
244
+                $pdf->SetDrawColor(128,128,128);
245
+
246
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
247
+
248
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
249
+                $pdf->SetSubject($outputlangs->transnoentities("Reception"));
250
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
251
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
252
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
253
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
254
+
255
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
256
+
257
+                // New page
258
+                $pdf->AddPage();
259
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
260
+                $pagenb++;
261
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
262
+                $pdf->SetFont('','', $default_font_size - 1);
263
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
264
+                $pdf->SetTextColor(0,0,0);
265
+
266
+                $tab_top = 90;
267
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
268
+                $tab_height = 130;
269
+                $tab_height_newpage = 150;
270
+
271
+                // Incoterm
272
+                $height_incoterms = 0;
273
+                if ($conf->incoterm->enabled)
274
+                {
275
+                    $desc_incoterms = $object->getIncotermsForPDF();
276
+                    if ($desc_incoterms)
277
+                    {
278
+                        $tab_top = 88;
279
+
280
+                        $pdf->SetFont('','', $default_font_size - 1);
281
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
282
+                        $nexY = $pdf->GetY();
283
+                        $height_incoterms=$nexY-$tab_top;
284
+
285
+                        // Rect prend une longueur en 3eme param
286
+                        $pdf->SetDrawColor(192,192,192);
287
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
288
+
289
+                        $tab_top = $nexY+6;
290
+                        $height_incoterms += 4;
291
+                    }
292
+                }
293
+
294
+                if (! empty($object->note_public) || ! empty($object->tracking_number))
295
+                {
296
+                    $tab_top = 88 + $height_incoterms;
297
+                    $tab_top_alt = $tab_top;
298
+
299
+                    $pdf->SetFont('','B', $default_font_size - 2);
300
+                    $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
301
+
302
+                    $tab_top_alt = $pdf->GetY();
303
+                    //$tab_top_alt += 1;
304
+
305
+                    // Tracking number
306
+                    if (! empty($object->tracking_number))
307
+                    {
308
+                        $object->getUrlTrackingStatus($object->tracking_number);
309
+                        if (! empty($object->tracking_url))
310
+                        {
311
+                            if ($object->reception_method_id > 0)
312
+                            {
313
+                                // Get code using getLabelFromKey
314
+                                $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code');
315
+                                $label='';
316
+                                if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
+                                $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
318
+                                //var_dump($object->tracking_url != $object->tracking_number);exit;
319
+                                if ($object->tracking_url != $object->tracking_number)
320
+                                {
321
+                                    $label.=" : ";
322
+                                    $label.=$object->tracking_url;
323
+                                }
324
+                                $pdf->SetFont('','B', $default_font_size - 2);
325
+                                $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
326
+
327
+                                $tab_top_alt = $pdf->GetY();
328
+                            }
329
+                        }
330
+                    }
331
+
332
+                    // Notes
333
+                    if (! empty($object->note_public))
334
+                    {
335
+                        $pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
336
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
337
+                    }
338
+
339
+                    $nexY = $pdf->GetY();
340
+                    $height_note=$nexY-$tab_top;
341
+
342
+                    // Rect prend une longueur en 3eme param
343
+                    $pdf->SetDrawColor(192,192,192);
344
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
345
+
346
+                    $tab_height = $tab_height - $height_note;
347
+                    $tab_top = $nexY+6;
348
+                }
349
+                else
350
+                {
351
+                    $height_note=0;
352
+                }
353
+
354
+                $iniY = $tab_top + 7;
355
+                $curY = $tab_top + 7;
356
+                $nexY = $tab_top + 7;
357
+                $fk_commandefourndet=0;
358
+                $totalOrdered=0;
359
+                // Loop on each lines
360
+                for ($i = 0; $i < $nblignes; $i++)
361
+                {
362
+                    $curY = $nexY;
363
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
364
+                    $pdf->SetTextColor(0,0,0);
365
+
366
+                    // Define size of image if we need it
367
+                    $imglinesize=array();
368
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
369
+
370
+                    $pdf->setTopMargin($tab_top_newpage);
371
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
372
+                    $pageposbefore=$pdf->getPage();
373
+
374
+                    $showpricebeforepagebreak=1;
375
+                    $posYAfterImage=0;
376
+                    $posYAfterDescription=0;
377
+
378
+                    // We start with Photo of product line
379
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
380
+                    {
381
+                        $pdf->AddPage('','',true);
382
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
383
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
384
+                        $pdf->setPage($pageposbefore+1);
385
+
386
+                        $curY = $tab_top_newpage;
387
+                        $showpricebeforepagebreak=0;
388
+                    }
389
+
390
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']))
391
+                    {
392
+                        $curX = $this->posxpicture-1;
393
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
394
+                        // $pdf->Image does not increase value return by getY, so we save it manually
395
+                        $posYAfterImage=$curY+$imglinesize['height'];
396
+                    }
397
+
398
+                    // Description of product line
399
+                    $curX = $this->posxdesc-1;
400
+
401
+                    $pdf->startTransaction();
402
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
403
+
404
+                    $pageposafter=$pdf->getPage();
405
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
406
+                    {
407
+                        $pdf->rollbackTransaction(true);
408
+                        $pageposafter=$pageposbefore;
409
+                        //print $pageposafter.'-'.$pageposbefore;exit;
410
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
411
+
412
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
413
+
414
+                        $pageposafter=$pdf->getPage();
415
+                        $posyafter=$pdf->GetY();
416
+                        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
417
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
418
+                        {
419
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
420
+                            {
421
+                                $pdf->AddPage('','',true);
422
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
423
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424
+                                $pdf->setPage($pageposafter+1);
425
+                            }
426
+                        }
427
+                        else
428
+                        {
429
+                            // We found a page break
430
+                            $showpricebeforepagebreak=0;
431
+                        }
432
+                    }
433
+                    else	// No pagebreak
434
+                    {
435
+                        $pdf->commitTransaction();
436
+                    }
437
+                    $posYAfterDescription=$pdf->GetY();
438
+
439
+                    $nexY = $pdf->GetY();
440
+                    $pageposafter=$pdf->getPage();
441
+
442
+                    $pdf->setPage($pageposbefore);
443
+                    $pdf->setTopMargin($this->marge_haute);
444
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
445
+
446
+                    // We suppose that a too long description or photo were moved completely on next page
447
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
448
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
449
+                    }
450
+
451
+                    // We suppose that a too long description is moved completely on next page
452
+                    if ($pageposafter > $pageposbefore) {
453
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
454
+                    }
455
+
456
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
457
+
458
+                    $pdf->SetXY($this->posxweightvol, $curY);
459
+                    $weighttxt='';
460
+                    if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight)
461
+                    {
462
+                        $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight");
463
+                    }
464
+                    $voltxt='';
465
+                    if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume)
466
+                    {
467
+                        $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume");
468
+                    }
469
+
470
+                    $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
471
+                    //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
472
+
473
+                    if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
474
+                    {
475
+                        $pdf->SetXY($this->posxqtyordered, $curY);
476
+                        if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
477
+                            $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
478
+                            $totalOrdered+=$object->lines[$i]->qty_asked;
479
+                        }
480
+                        $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
481
+                    }
482
+
483
+                    $pdf->SetXY($this->posxqtytoship, $curY);
484
+                    $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C');
485
+
486
+                    if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
487
+                    {
488
+                        $pdf->SetXY($this->posxpuht, $curY);
489
+                        $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
490
+
491
+                        $pdf->SetXY($this->posxtotalht, $curY);
492
+                        $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
493
+                    }
494
+
495
+                    $nexY+=3;
496
+                    if ($weighttxt && $voltxt) $nexY+=2;
497
+
498
+                    // Add line
499
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
500
+                    {
501
+                        $pdf->setPage($pageposafter);
502
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
503
+                        //$pdf->SetDrawColor(190,190,200);
504
+                        $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
505
+                        $pdf->SetLineStyle(array('dash'=>0));
506
+                    }
507
+
508
+                    // Detect if some page were added automatically and output _tableau for past pages
509
+                    while ($pagenb < $pageposafter)
510
+                    {
511
+                        $pdf->setPage($pagenb);
512
+                        if ($pagenb == 1)
513
+                        {
514
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
515
+                        }
516
+                        else
517
+                        {
518
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
519
+                        }
520
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
521
+                        $pagenb++;
522
+                        $pdf->setPage($pagenb);
523
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
524
+                    }
525
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
526
+                    {
527
+                        if ($pagenb == 1)
528
+                        {
529
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
530
+                        }
531
+                        else
532
+                        {
533
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
534
+                        }
535
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
536
+                        // New page
537
+                        $pdf->AddPage();
538
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
539
+                        $pagenb++;
540
+                    }
541
+                }
542
+
543
+                // Show square
544
+                if ($pagenb == 1)
545
+                {
546
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
547
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548
+                }
549
+                else
550
+                {
551
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
552
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
553
+                }
554
+
555
+                // Affiche zone totaux
556
+                $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
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
+                return 1;	// No error
576
+            }
577
+            else
578
+            {
579
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
580
+                return 0;
581
+            }
582
+        }
583
+        else
584
+        {
585
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
586
+            return 0;
587
+        }
588
+    }
589
+
590
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
591
+    /**
592
+     *	Show total to pay
593
+     *
594
+     *	@param	PDF			$pdf            Object PDF
595
+     *	@param  Facture		$object         Object invoice
596
+     *	@param  int			$deja_regle     Montant deja regle
597
+     *	@param	int			$posy			Position depart
598
+     *	@param	Translate	$outputlangs	Objet langs
599
+     *  @param	int			$totalOrdered	Total ordered
600
+     *	@return int							Position pour suite
601
+     */
602
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
603
+    {
604
+        // phpcs:enable
605
+        global $conf,$mysoc;
606 606
 
607 607
         $sign=1;
608 608
 
609 609
         $default_font_size = pdf_getPDFFontSize($outputlangs);
610 610
 
611
-		$tab2_top = $posy;
612
-		$tab2_hl = 4;
613
-		$pdf->SetFont('','B', $default_font_size - 1);
611
+        $tab2_top = $posy;
612
+        $tab2_hl = 4;
613
+        $pdf->SetFont('','B', $default_font_size - 1);
614 614
 
615
-		// Tableau total
616
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
617
-		/*if ($this->page_largeur < 210) // To work with US executive format
615
+        // Tableau total
616
+        $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
617
+        /*if ($this->page_largeur < 210) // To work with US executive format
618 618
 		{
619 619
 			$col2x-=20;
620 620
 		}*/
621
-		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
622
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
621
+        if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
622
+        else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
623 623
 
624
-		$useborder=0;
625
-		$index = 0;
624
+        $useborder=0;
625
+        $index = 0;
626 626
 
627
-		$totalWeighttoshow='';
628
-		$totalVolumetoshow='';
627
+        $totalWeighttoshow='';
628
+        $totalVolumetoshow='';
629 629
 
630
-		// Load dim data
631
-		$tmparray=$object->getTotalWeightVolume();
632
-		$totalWeight=$tmparray['weight'];
633
-		$totalVolume=$tmparray['volume'];
634
-		$totalToShip=$tmparray['toship'];
630
+        // Load dim data
631
+        $tmparray=$object->getTotalWeightVolume();
632
+        $totalWeight=$tmparray['weight'];
633
+        $totalVolume=$tmparray['volume'];
634
+        $totalToShip=$tmparray['toship'];
635 635
 
636 636
 
637
-		// Set trueVolume and volume_units not currently stored into database
638
-		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
639
-		{
640
-		    $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
-		    $object->volume_units=$object->size_units * 3;
642
-		}
637
+        // Set trueVolume and volume_units not currently stored into database
638
+        if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
639
+        {
640
+            $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
+            $object->volume_units=$object->size_units * 3;
642
+        }
643 643
 
644
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
644
+        if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
+        if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
+        if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
+        if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
648 648
 
649
-    	$pdf->SetFillColor(255,255,255);
650
-    	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
651
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
649
+        $pdf->SetFillColor(255,255,255);
650
+        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
651
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
652 652
 
653 653
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
654 654
         {
655 655
             $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
656
-        	$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
656
+            $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
657 657
         }
658 658
 
659
-    	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
660
-    	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
659
+        $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
660
+        $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
661
+
662
+        if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
661 663
 
662
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
664
+            $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
665
+            $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
663 666
 
664
-	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
665
-	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
667
+            $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
668
+            $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
669
+        }
666 670
 
667
-	    	$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
668
-	    	$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
669
-		}
671
+        // Total Weight
672
+        if ($totalWeighttoshow)
673
+        {
674
+            $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
675
+            $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
670 676
 
671
-		// Total Weight
672
-		if ($totalWeighttoshow)
673
-		{
674
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
675
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
677
+            $index++;
678
+        }
679
+        if ($totalVolumetoshow)
680
+        {
681
+            $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
682
+            $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
676 683
 
677
-    		$index++;
678
-		}
679
-		if ($totalVolumetoshow)
680
-		{
681
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
682
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
683
-
684
-		    $index++;
685
-		}
686
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
687
-
688
-		$pdf->SetTextColor(0,0,0);
689
-
690
-		return ($tab2_top + ($tab2_hl * $index));
691
-	}
692
-
693
-	/**
694
-	 *   Show table for lines
695
-	 *
696
-	 *   @param		PDF			$pdf     		Object PDF
697
-	 *   @param		string		$tab_top		Top position of table
698
-	 *   @param		string		$tab_height		Height of table (rectangle)
699
-	 *   @param		int			$nexY			Y
700
-	 *   @param		Translate	$outputlangs	Langs object
701
-	 *   @param		int			$hidetop		Hide top bar of array
702
-	 *   @param		int			$hidebottom		Hide bottom bar of array
703
-	 *   @return	void
704
-	 */
705
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
706
-	{
707
-		global $conf;
708
-
709
-		// Force to disable hidetop and hidebottom
710
-		$hidebottom=0;
711
-		if ($hidetop) $hidetop=-1;
712
-
713
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
714
-
715
-		// Amount in (at tab_top - 1)
716
-		$pdf->SetTextColor(0,0,0);
717
-		$pdf->SetFont('','',$default_font_size - 2);
718
-
719
-		// Output Rect
720
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
721
-
722
-		$pdf->SetDrawColor(128,128,128);
723
-		$pdf->SetFont('','', $default_font_size - 1);
724
-
725
-		if (empty($hidetop))
726
-		{
727
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
684
+            $index++;
685
+        }
686
+        if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
728 687
 
729
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
730
-			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
731
-		}
688
+        $pdf->SetTextColor(0,0,0);
732 689
 
733
-		$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
734
-		if (empty($hidetop))
735
-		{
736
-			$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
737
-			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
738
-		}
690
+        return ($tab2_top + ($tab2_hl * $index));
691
+    }
692
+
693
+    /**
694
+     *   Show table for lines
695
+     *
696
+     *   @param		PDF			$pdf     		Object PDF
697
+     *   @param		string		$tab_top		Top position of table
698
+     *   @param		string		$tab_height		Height of table (rectangle)
699
+     *   @param		int			$nexY			Y
700
+     *   @param		Translate	$outputlangs	Langs object
701
+     *   @param		int			$hidetop		Hide top bar of array
702
+     *   @param		int			$hidebottom		Hide bottom bar of array
703
+     *   @return	void
704
+     */
705
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
706
+    {
707
+        global $conf;
708
+
709
+        // Force to disable hidetop and hidebottom
710
+        $hidebottom=0;
711
+        if ($hidetop) $hidetop=-1;
712
+
713
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
714
+
715
+        // Amount in (at tab_top - 1)
716
+        $pdf->SetTextColor(0,0,0);
717
+        $pdf->SetFont('','',$default_font_size - 2);
718
+
719
+        // Output Rect
720
+        $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
721
+
722
+        $pdf->SetDrawColor(128,128,128);
723
+        $pdf->SetFont('','', $default_font_size - 1);
724
+
725
+        if (empty($hidetop))
726
+        {
727
+            $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
728
+
729
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
730
+            $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
731
+        }
732
+
733
+        $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
734
+        if (empty($hidetop))
735
+        {
736
+            $pdf->SetXY($this->posxweightvol-1, $tab_top+1);
737
+            $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
738
+        }
739 739
 
740 740
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
741 741
         {
742 742
             $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
743
-    		if (empty($hidetop))
744
-    		{
745
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
746
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
747
-    		}
743
+            if (empty($hidetop))
744
+            {
745
+                $pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
746
+                $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
747
+            }
748 748
         }
749 749
 
750
-		$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
751
-		if (empty($hidetop))
752
-		{
753
-			$pdf->SetXY($this->posxqtytoship, $tab_top+1);
754
-			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C');
755
-		}
756
-
757
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
758
-
759
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
760
-			if (empty($hidetop))
761
-			{
762
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
763
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
764
-			}
765
-
766
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
767
-			if (empty($hidetop))
768
-			{
769
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
770
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
771
-			}
772
-		}
773
-	}
774
-
775
-	/**
776
-	 *  Show top header of page.
777
-	 *
778
-	 *  @param	PDF			$pdf     		Object PDF
779
-	 *  @param  Object		$object     	Object to show
780
-	 *  @param  int	    	$showaddress    0=no, 1=yes
781
-	 *  @param  Translate	$outputlangs	Object lang for output
782
-	 *  @return	void
783
-	 */
784
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
785
-	{
786
-		global $conf,$langs,$mysoc;
787
-
788
-		$langs->load("orders");
789
-
790
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
791
-
792
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
793
-
794
-		// Show Draft Watermark
795
-		if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) )
796
-		{
797
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK);
798
-		}
750
+        $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
751
+        if (empty($hidetop))
752
+        {
753
+            $pdf->SetXY($this->posxqtytoship, $tab_top+1);
754
+            $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C');
755
+        }
799 756
 
800
-		//Prepare la suite
801
-		$pdf->SetTextColor(0,0,60);
802
-		$pdf->SetFont('','B', $default_font_size + 3);
757
+        if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
803 758
 
804
-		$w = 110;
759
+            $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
760
+            if (empty($hidetop))
761
+            {
762
+                $pdf->SetXY($this->posxpuht-1, $tab_top+1);
763
+                $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
764
+            }
805 765
 
806
-		$posy=$this->marge_haute;
807
-		$posx=$this->page_largeur-$this->marge_droite-$w;
766
+            $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
767
+            if (empty($hidetop))
768
+            {
769
+                $pdf->SetXY($this->posxtotalht-1, $tab_top+1);
770
+                $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
771
+            }
772
+        }
773
+    }
808 774
 
809
-		$pdf->SetXY($this->marge_gauche,$posy);
775
+    /**
776
+     *  Show top header of page.
777
+     *
778
+     *  @param	PDF			$pdf     		Object PDF
779
+     *  @param  Object		$object     	Object to show
780
+     *  @param  int	    	$showaddress    0=no, 1=yes
781
+     *  @param  Translate	$outputlangs	Object lang for output
782
+     *  @return	void
783
+     */
784
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
785
+    {
786
+        global $conf,$langs,$mysoc;
787
+
788
+        $langs->load("orders");
810 789
 
811
-		// Logo
812
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
813
-		if ($this->emetteur->logo)
814
-		{
815
-			if (is_readable($logo))
816
-			{
817
-			    $height=pdf_getHeightForLogo($logo);
818
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
819
-			}
820
-			else
821
-			{
822
-				$pdf->SetTextColor(200,0,0);
823
-				$pdf->SetFont('','B', $default_font_size - 2);
824
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
825
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
826
-			}
827
-		}
828
-		else
829
-		{
830
-			$text=$this->emetteur->name;
831
-			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
832
-		}
790
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
833 791
 
834
-		// Show barcode
835
-		if (! empty($conf->barcode->enabled))
836
-		{
837
-			$posx=105;
838
-		}
839
-		else
840
-		{
841
-			$posx=$this->marge_gauche+3;
842
-		}
843
-		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
844
-		if (! empty($conf->barcode->enabled))
845
-		{
846
-			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
847
-			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
848
-			//$pdf->Image($logo,10, 5, 0, 24);
849
-		}
792
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
850 793
 
851
-		$pdf->SetDrawColor(128,128,128);
852
-		if (! empty($conf->barcode->enabled))
853
-		{
854
-			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
855
-			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
856
-			//$pdf->Image($logo,10, 5, 0, 24);
857
-		}
794
+        // Show Draft Watermark
795
+        if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) )
796
+        {
797
+                    pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK);
798
+        }
858 799
 
800
+        //Prepare la suite
801
+        $pdf->SetTextColor(0,0,60);
802
+        $pdf->SetFont('','B', $default_font_size + 3);
859 803
 
860
-		$posx=$this->page_largeur - $w - $this->marge_droite;
861
-		$posy=$this->marge_haute;
804
+        $w = 110;
862 805
 
863
-		$pdf->SetFont('','B', $default_font_size + 2);
864
-		$pdf->SetXY($posx,$posy);
865
-		$pdf->SetTextColor(0,0,60);
866
-		$title=$outputlangs->transnoentities("ReceptionSheet");
867
-		$pdf->MultiCell($w, 4, $title, '', 'R');
806
+        $posy=$this->marge_haute;
807
+        $posx=$this->page_largeur-$this->marge_droite-$w;
868 808
 
869
-		$pdf->SetFont('','', $default_font_size + 1);
809
+        $pdf->SetXY($this->marge_gauche,$posy);
870 810
 
871
-		$posy+=5;
811
+        // Logo
812
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
813
+        if ($this->emetteur->logo)
814
+        {
815
+            if (is_readable($logo))
816
+            {
817
+                $height=pdf_getHeightForLogo($logo);
818
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
819
+            }
820
+            else
821
+            {
822
+                $pdf->SetTextColor(200,0,0);
823
+                $pdf->SetFont('','B', $default_font_size - 2);
824
+                $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
825
+                $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
826
+            }
827
+        }
828
+        else
829
+        {
830
+            $text=$this->emetteur->name;
831
+            $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
832
+        }
872 833
 
873
-		$pdf->SetXY($posx,$posy);
874
-		$pdf->SetTextColor(0,0,60);
875
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R');
834
+        // Show barcode
835
+        if (! empty($conf->barcode->enabled))
836
+        {
837
+            $posx=105;
838
+        }
839
+        else
840
+        {
841
+            $posx=$this->marge_gauche+3;
842
+        }
843
+        //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
844
+        if (! empty($conf->barcode->enabled))
845
+        {
846
+            // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
847
+            //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
848
+            //$pdf->Image($logo,10, 5, 0, 24);
849
+        }
876 850
 
877
-		// Date planned delivery
878
-		if (! empty($object->date_delivery))
879
-		{
880
-    			$posy+=4;
881
-    			$pdf->SetXY($posx,$posy);
882
-    			$pdf->SetTextColor(0,0,60);
883
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
884
-		}
851
+        $pdf->SetDrawColor(128,128,128);
852
+        if (! empty($conf->barcode->enabled))
853
+        {
854
+            // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
855
+            //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
856
+            //$pdf->Image($logo,10, 5, 0, 24);
857
+        }
885 858
 
886
-		if (! empty($object->thirdparty->code_fournisseur))
887
-		{
888
-			$posy+=4;
889
-			$pdf->SetXY($posx,$posy);
890
-			$pdf->SetTextColor(0,0,60);
891
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
892
-		}
893 859
 
860
+        $posx=$this->page_largeur - $w - $this->marge_droite;
861
+        $posy=$this->marge_haute;
894 862
 
895
-		$pdf->SetFont('','', $default_font_size + 3);
896
-		$Yoff=25;
863
+        $pdf->SetFont('','B', $default_font_size + 2);
864
+        $pdf->SetXY($posx,$posy);
865
+        $pdf->SetTextColor(0,0,60);
866
+        $title=$outputlangs->transnoentities("ReceptionSheet");
867
+        $pdf->MultiCell($w, 4, $title, '', 'R');
897 868
 
898
-		// Add list of linked orders
899
-		$origin 	= $object->origin;
900
-		$origin_id 	= $object->origin_id;
869
+        $pdf->SetFont('','', $default_font_size + 1);
901 870
 
902
-	    // TODO move to external function
903
-		if (! empty($conf->fournisseur->enabled))     // commonly $origin='commande'
904
-		{
905
-			$outputlangs->load('orders');
906
-
907
-			$classname = 'CommandeFournisseur';
908
-			$linkedobject = new $classname($this->db);
909
-			$result=$linkedobject->fetch($origin_id);
910
-			if ($result >= 0)
911
-			{
912
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
913
-
914
-				$pdf->SetFont('','', $default_font_size - 2);
915
-				$text=$linkedobject->ref;
916
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
917
-				$Yoff = $Yoff+8;
918
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
919
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
920
-				$Yoff = $Yoff+3;
921
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
922
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
923
-			}
924
-		}
925
-
926
-		if ($showaddress)
927
-		{
928
-			// Sender properties
929
-			$carac_emetteur='';
930
-		 	// Add internal contact of origin element if defined
931
-			$arrayidcontact=array();
932
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
933
-			if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
934
-		 	if (count($arrayidcontact) > 0)
935
-		 	{
936
-		 		$object->fetch_user(reset($arrayidcontact));
937
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
938
-		 	}
939
-
940
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
941
-
942
-			// Show sender
943
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
-			$posx=$this->marge_gauche;
945
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
946
-
947
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
949
-
950
-			// Show sender frame
951
-			$pdf->SetTextColor(0,0,0);
952
-			$pdf->SetFont('','', $default_font_size - 2);
953
-			$pdf->SetXY($posx,$posy-5);
954
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
-			$pdf->SetXY($posx,$posy);
956
-			$pdf->SetFillColor(230,230,230);
957
-			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
958
-			$pdf->SetTextColor(0,0,60);
959
-			$pdf->SetFillColor(255,255,255);
960
-
961
-			// If RECEPTION contact defined, we use it
962
-			$usecontact=false;
963
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
964
-
965
-			if (count($arrayidcontact) > 0)
966
-			{
967
-				$usecontact=true;
968
-				$result=$object->fetch_contact($arrayidcontact[0]);
969
-			}
970
-
971
-			//Recipient name
972
-			// On peut utiliser le nom de la societe du contact
973
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
974
-				$thirdparty = $object->contact;
975
-			} else {
976
-				$thirdparty = $object->thirdparty;
977
-			}
978
-
979
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
980
-
981
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
982
-
983
-				// Show recipient name
984
-			$pdf->SetXY($posx+2,$posy+3);
985
-			$pdf->SetFont('','B', $default_font_size);
986
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L');
987
-
988
-			$posy = $pdf->getY();
989
-
990
-			// Show recipient information
991
-			$pdf->SetFont('','', $default_font_size - 1);
992
-			$pdf->SetXY($posx+2,$posy);
993
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L');
994
-
995
-			// Show recipient
996
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
998
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1000
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1001
-
1002
-			// Show recipient frame
1003
-			$pdf->SetTextColor(0,0,0);
1004
-			$pdf->SetFont('','', $default_font_size - 2);
1005
-			$pdf->SetXY($posx+2,$posy-5);
1006
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1007
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1008
-
1009
-
1010
-
1011
-			// Show sender name
1012
-			$pdf->SetXY($posx+2,$posy+3);
1013
-			$pdf->SetFont('','B',$default_font_size);
1014
-			$pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1015
-			$posy=$pdf->getY();
1016
-
1017
-			// Show sender information
1018
-			$pdf->SetXY($posx+2,$posy);
1019
-			$pdf->SetFont('','', $default_font_size - 1);
1020
-			$pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1021
-		}
1022
-
1023
-		$pdf->SetTextColor(0,0,0);
1024
-	}
1025
-
1026
-	/**
1027
-	 *   	Show footer of page. Need this->emetteur object
871
+        $posy+=5;
872
+
873
+        $pdf->SetXY($posx,$posy);
874
+        $pdf->SetTextColor(0,0,60);
875
+        $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R');
876
+
877
+        // Date planned delivery
878
+        if (! empty($object->date_delivery))
879
+        {
880
+                $posy+=4;
881
+                $pdf->SetXY($posx,$posy);
882
+                $pdf->SetTextColor(0,0,60);
883
+                $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
884
+        }
885
+
886
+        if (! empty($object->thirdparty->code_fournisseur))
887
+        {
888
+            $posy+=4;
889
+            $pdf->SetXY($posx,$posy);
890
+            $pdf->SetTextColor(0,0,60);
891
+            $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
892
+        }
893
+
894
+
895
+        $pdf->SetFont('','', $default_font_size + 3);
896
+        $Yoff=25;
897
+
898
+        // Add list of linked orders
899
+        $origin 	= $object->origin;
900
+        $origin_id 	= $object->origin_id;
901
+
902
+        // TODO move to external function
903
+        if (! empty($conf->fournisseur->enabled))     // commonly $origin='commande'
904
+        {
905
+            $outputlangs->load('orders');
906
+
907
+            $classname = 'CommandeFournisseur';
908
+            $linkedobject = new $classname($this->db);
909
+            $result=$linkedobject->fetch($origin_id);
910
+            if ($result >= 0)
911
+            {
912
+                //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
913
+
914
+                $pdf->SetFont('','', $default_font_size - 2);
915
+                $text=$linkedobject->ref;
916
+                if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
917
+                $Yoff = $Yoff+8;
918
+                $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
919
+                $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
920
+                $Yoff = $Yoff+3;
921
+                $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
922
+                $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
923
+            }
924
+        }
925
+
926
+        if ($showaddress)
927
+        {
928
+            // Sender properties
929
+            $carac_emetteur='';
930
+                // Add internal contact of origin element if defined
931
+            $arrayidcontact=array();
932
+            if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
933
+            if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
934
+                if (count($arrayidcontact) > 0)
935
+                {
936
+                    $object->fetch_user(reset($arrayidcontact));
937
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
938
+                }
939
+
940
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
941
+
942
+            // Show sender
943
+            $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
+            $posx=$this->marge_gauche;
945
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
946
+
947
+            $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
+            $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
949
+
950
+            // Show sender frame
951
+            $pdf->SetTextColor(0,0,0);
952
+            $pdf->SetFont('','', $default_font_size - 2);
953
+            $pdf->SetXY($posx,$posy-5);
954
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
+            $pdf->SetXY($posx,$posy);
956
+            $pdf->SetFillColor(230,230,230);
957
+            $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
958
+            $pdf->SetTextColor(0,0,60);
959
+            $pdf->SetFillColor(255,255,255);
960
+
961
+            // If RECEPTION contact defined, we use it
962
+            $usecontact=false;
963
+            $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
964
+
965
+            if (count($arrayidcontact) > 0)
966
+            {
967
+                $usecontact=true;
968
+                $result=$object->fetch_contact($arrayidcontact[0]);
969
+            }
970
+
971
+            //Recipient name
972
+            // On peut utiliser le nom de la societe du contact
973
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
974
+                $thirdparty = $object->contact;
975
+            } else {
976
+                $thirdparty = $object->thirdparty;
977
+            }
978
+
979
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
980
+
981
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
982
+
983
+                // Show recipient name
984
+            $pdf->SetXY($posx+2,$posy+3);
985
+            $pdf->SetFont('','B', $default_font_size);
986
+            $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L');
987
+
988
+            $posy = $pdf->getY();
989
+
990
+            // Show recipient information
991
+            $pdf->SetFont('','', $default_font_size - 1);
992
+            $pdf->SetXY($posx+2,$posy);
993
+            $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L');
994
+
995
+            // Show recipient
996
+            $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
998
+            $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
+            $posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1000
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1001
+
1002
+            // Show recipient frame
1003
+            $pdf->SetTextColor(0,0,0);
1004
+            $pdf->SetFont('','', $default_font_size - 2);
1005
+            $pdf->SetXY($posx+2,$posy-5);
1006
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1007
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1008
+
1009
+
1010
+
1011
+            // Show sender name
1012
+            $pdf->SetXY($posx+2,$posy+3);
1013
+            $pdf->SetFont('','B',$default_font_size);
1014
+            $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1015
+            $posy=$pdf->getY();
1016
+
1017
+            // Show sender information
1018
+            $pdf->SetXY($posx+2,$posy);
1019
+            $pdf->SetFont('','', $default_font_size - 1);
1020
+            $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1021
+        }
1022
+
1023
+        $pdf->SetTextColor(0,0,0);
1024
+    }
1025
+
1026
+    /**
1027
+     *   	Show footer of page. Need this->emetteur object
1028 1028
      *
1029
-	 *   	@param	PDF		$pdf     			PDF
1030
-	 * 		@param	Object		$object				Object to show
1031
-	 *      @param	Translate	$outputlangs		Object lang for output
1032
-	 *      @param	int			$hidefreetext		1=Hide free text
1033
-	 *      @return	int								Return height of bottom margin including footer text
1034
-	 */
1035
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1036
-	{
1037
-		global $conf;
1038
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
-		return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1040
-	}
1029
+     *   	@param	PDF		$pdf     			PDF
1030
+     * 		@param	Object		$object				Object to show
1031
+     *      @param	Translate	$outputlangs		Object lang for output
1032
+     *      @param	int			$hidefreetext		1=Hide free text
1033
+     *      @return	int								Return height of bottom margin including footer text
1034
+     */
1035
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1036
+    {
1037
+        global $conf;
1038
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
+        return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1040
+    }
1041 1041
 }
Please login to merge, or discard this patch.
Spacing   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class pdf_squille extends ModelePdfReception
34 34
 {
35
-	var $emetteur;	// Objet societe qui emet
35
+	var $emetteur; // Objet societe qui emet
36 36
 
37 37
 
38 38
 	/**
@@ -40,57 +40,57 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 *	@param	DoliDB	$db		Database handler
42 42
 	 */
43
-	function __construct($db=0)
43
+	function __construct($db = 0)
44 44
 	{
45
-		global $conf,$langs,$mysoc;
45
+		global $conf, $langs, $mysoc;
46 46
 
47 47
 		$this->db = $db;
48 48
 		$this->name = "squille";
49 49
 		$this->description = $langs->trans("DocumentModelStandardPDF");
50 50
 
51 51
 		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
52
+		$formatarray = pdf_getFormat();
53 53
 		$this->page_largeur = $formatarray['width'];
54 54
 		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
55
+		$this->format = array($this->page_largeur, $this->page_hauteur);
56
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
57
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
58
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
59
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
60 60
 
61 61
 		$this->option_logo = 1;
62 62
 
63 63
 		// Get source company
64
-		$this->emetteur=$mysoc;
65
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
64
+		$this->emetteur = $mysoc;
65
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
66 66
 
67 67
 		// Define position of columns
68
-		$this->posxdesc=$this->marge_gauche+1;
69
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
70
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
71
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
72
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
68
+		$this->posxdesc = $this->marge_gauche + 1;
69
+		$this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
70
+		$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
71
+		$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
72
+		$this->posxpuht = $this->page_largeur - $this->marge_droite;
73 73
 
74 74
 		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
75 75
 
76
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
77
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
78
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
79
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
80
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
76
+			$this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
77
+			$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
78
+			$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
79
+			$this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
80
+			$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
81 81
 		}
82 82
 
83
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
83
+		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
84 84
 
85 85
 		if ($this->page_largeur < 210) // To work with US executive format
86 86
 		{
87
-		    $this->posxweightvol-=20;
88
-		    $this->posxpicture-=20;
89
-		    $this->posxqtyordered-=20;
90
-		    $this->posxqtytoship-=20;
87
+		    $this->posxweightvol -= 20;
88
+		    $this->posxpicture -= 20;
89
+		    $this->posxqtyordered -= 20;
90
+		    $this->posxqtytoship -= 20;
91 91
 		}
92 92
 
93
-		if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
93
+		if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
94 94
 		{
95 95
 		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
96 96
 		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
      *  @param		int			$hideref			Do not show ref
111 111
      *  @return     int         	    			1=OK, 0=KO
112 112
 	 */
113
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
113
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
114 114
 	{
115 115
 		// phpcs:enable
116
-		global $user,$conf,$langs,$hookmanager;
116
+		global $user, $conf, $langs, $hookmanager;
117 117
 
118 118
 		$object->fetch_thirdparty();
119 119
 
120
-		if (! is_object($outputlangs)) $outputlangs=$langs;
120
+		if (!is_object($outputlangs)) $outputlangs = $langs;
121 121
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
122
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
122
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
123 123
 
124 124
 		$outputlangs->load("main");
125 125
 		$outputlangs->load("dict");
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 		$nblignes = count($object->lines);
135 135
 
136 136
         // Loop on each lines to detect if there is at least one image to show
137
-        $realpatharray=array();
138
-        if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
137
+        $realpatharray = array();
138
+        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
139 139
         {
140 140
             $objphoto = new Product($this->db);
141 141
 
142
-            for ($i = 0 ; $i < $nblignes ; $i++)
142
+            for ($i = 0; $i < $nblignes; $i++)
143 143
             {
144 144
                 if (empty($object->lines[$i]->fk_product)) continue;
145 145
 
146 146
 				$objphoto = new Product($this->db);
147 147
 				$objphoto->fetch($object->lines[$i]->fk_product);
148 148
 
149
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
149
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
150 150
 				$dir = $conf->product->dir_output.'/'.$pdir;
151 151
 
152
-				$realpath='';
152
+				$realpath = '';
153 153
 
154
-                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
154
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
155 155
                         {
156 156
                             if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
157 157
                             {
158 158
                                 if ($obj['photo_vignette'])
159 159
                                 {
160
-                                    $filename= $obj['photo_vignette'];
160
+                                    $filename = $obj['photo_vignette'];
161 161
                                 }
162 162
                                 else
163 163
                                 {
164
-                                    $filename=$obj['photo'];
164
+                                    $filename = $obj['photo'];
165 165
                                 }
166 166
                             }
167 167
                             else
168 168
                             {
169
-                                $filename=$obj['photo'];
169
+                                $filename = $obj['photo'];
170 170
                             }
171 171
 
172 172
                             $realpath = $dir.$filename;
173 173
                             break;
174 174
                 }
175 175
 
176
-                if ($realpath) $realpatharray[$i]=$realpath;
176
+                if ($realpath) $realpatharray[$i] = $realpath;
177 177
             }
178 178
         }
179 179
 
180
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
180
+        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
181 181
 
182 182
 		if ($conf->reception->dir_output)
183 183
 		{
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 			if ($object->specimen)
186 186
 			{
187 187
 				$dir = $conf->reception->dir_output;
188
-				$file = $dir . "/SPECIMEN.pdf";
188
+				$file = $dir."/SPECIMEN.pdf";
189 189
 			}
190 190
 			else
191 191
 			{
192 192
 				$rcpref = dol_sanitizeFileName($object->ref);
193
-				$dir = $conf->reception->dir_output."/" . $rcpref;
194
-				$file = $dir . "/" . $rcpref . ".pdf";
193
+				$dir = $conf->reception->dir_output."/".$rcpref;
194
+				$file = $dir."/".$rcpref.".pdf";
195 195
 			}
196 196
 
197
-			if (! file_exists($dir))
197
+			if (!file_exists($dir))
198 198
 			{
199 199
 				if (dol_mkdir($dir) < 0)
200 200
 				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
201
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
202 202
 					return 0;
203 203
 				}
204 204
 			}
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
 			if (file_exists($dir))
207 207
 			{
208 208
 				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
209
+				if (!is_object($hookmanager))
210 210
 				{
211 211
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
212
+					$hookmanager = new HookManager($this->db);
213 213
 				}
214 214
 				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
216 216
 				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
218 218
 
219 219
 				// Set nblignes with the new facture lines content after hook
220 220
 				$nblignes = count($object->lines);
221 221
 
222
-				$pdf=pdf_getInstance($this->format);
222
+				$pdf = pdf_getInstance($this->format);
223 223
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
224
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
225
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
226
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-                $pdf->SetAutoPageBreak(1,0);
224
+				$heightforinfotot = 8; // Height reserved to output the info and total part
225
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
226
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
227
+                $pdf->SetAutoPageBreak(1, 0);
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -233,38 +233,38 @@  discard block
 block discarded – undo
233 233
                 }
234 234
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
235 235
                 // Set path to the background PDF File
236
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237 237
                 {
238 238
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239 239
                     $tplidx = $pdf->importPage(1);
240 240
                 }
241 241
 
242 242
 				$pdf->Open();
243
-				$pagenb=0;
244
-				$pdf->SetDrawColor(128,128,128);
243
+				$pagenb = 0;
244
+				$pdf->SetDrawColor(128, 128, 128);
245 245
 
246
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
246
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
247 247
 
248 248
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
249 249
 				$pdf->SetSubject($outputlangs->transnoentities("Reception"));
250 250
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
251 251
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
252 252
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
253
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
253
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
254 254
 
255
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
255
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
256 256
 
257 257
 				// New page
258 258
 				$pdf->AddPage();
259
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
259
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
260 260
 				$pagenb++;
261 261
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
262
-				$pdf->SetFont('','', $default_font_size - 1);
263
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
264
-				$pdf->SetTextColor(0,0,0);
262
+				$pdf->SetFont('', '', $default_font_size - 1);
263
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
264
+				$pdf->SetTextColor(0, 0, 0);
265 265
 
266 266
 				$tab_top = 90;
267
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
267
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
268 268
 				$tab_height = 130;
269 269
 				$tab_height_newpage = 150;
270 270
 
@@ -277,52 +277,52 @@  discard block
 block discarded – undo
277 277
 					{
278 278
 						$tab_top = 88;
279 279
 
280
-						$pdf->SetFont('','', $default_font_size - 1);
281
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
280
+						$pdf->SetFont('', '', $default_font_size - 1);
281
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
282 282
 						$nexY = $pdf->GetY();
283
-						$height_incoterms=$nexY-$tab_top;
283
+						$height_incoterms = $nexY - $tab_top;
284 284
 
285 285
 						// Rect prend une longueur en 3eme param
286
-						$pdf->SetDrawColor(192,192,192);
287
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
286
+						$pdf->SetDrawColor(192, 192, 192);
287
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
288 288
 
289
-						$tab_top = $nexY+6;
289
+						$tab_top = $nexY + 6;
290 290
 						$height_incoterms += 4;
291 291
 					}
292 292
 				}
293 293
 
294
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
294
+				if (!empty($object->note_public) || !empty($object->tracking_number))
295 295
 				{
296 296
 					$tab_top = 88 + $height_incoterms;
297 297
 					$tab_top_alt = $tab_top;
298 298
 
299
-					$pdf->SetFont('','B', $default_font_size - 2);
300
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
299
+					$pdf->SetFont('', 'B', $default_font_size - 2);
300
+					$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
301 301
 
302 302
 					$tab_top_alt = $pdf->GetY();
303 303
 					//$tab_top_alt += 1;
304 304
 
305 305
 					// Tracking number
306
-					if (! empty($object->tracking_number))
306
+					if (!empty($object->tracking_number))
307 307
 					{
308 308
 						$object->getUrlTrackingStatus($object->tracking_number);
309
-						if (! empty($object->tracking_url))
309
+						if (!empty($object->tracking_url))
310 310
 						{
311 311
 							if ($object->reception_method_id > 0)
312 312
 							{
313 313
 								// Get code using getLabelFromKey
314
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code');
315
-								$label='';
316
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
-								$label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
314
+								$code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code');
315
+								$label = '';
316
+								if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
317
+								$label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
318 318
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
319 319
 								if ($object->tracking_url != $object->tracking_number)
320 320
 								{
321
-									$label.=" : ";
322
-									$label.=$object->tracking_url;
321
+									$label .= " : ";
322
+									$label .= $object->tracking_url;
323 323
 								}
324
-								$pdf->SetFont('','B', $default_font_size - 2);
325
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
324
+								$pdf->SetFont('', 'B', $default_font_size - 2);
325
+								$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
326 326
 
327 327
 								$tab_top_alt = $pdf->GetY();
328 328
 							}
@@ -330,118 +330,118 @@  discard block
 block discarded – undo
330 330
 					}
331 331
 
332 332
 					// Notes
333
-					if (! empty($object->note_public))
333
+					if (!empty($object->note_public))
334 334
 					{
335
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
336
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
335
+						$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
336
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
337 337
 					}
338 338
 
339 339
 					$nexY = $pdf->GetY();
340
-					$height_note=$nexY-$tab_top;
340
+					$height_note = $nexY - $tab_top;
341 341
 
342 342
 					// Rect prend une longueur en 3eme param
343
-					$pdf->SetDrawColor(192,192,192);
344
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
343
+					$pdf->SetDrawColor(192, 192, 192);
344
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
345 345
 
346 346
 					$tab_height = $tab_height - $height_note;
347
-					$tab_top = $nexY+6;
347
+					$tab_top = $nexY + 6;
348 348
 				}
349 349
 				else
350 350
 				{
351
-					$height_note=0;
351
+					$height_note = 0;
352 352
 				}
353 353
 
354 354
 				$iniY = $tab_top + 7;
355 355
 				$curY = $tab_top + 7;
356 356
 				$nexY = $tab_top + 7;
357
-				$fk_commandefourndet=0;
358
-				$totalOrdered=0;
357
+				$fk_commandefourndet = 0;
358
+				$totalOrdered = 0;
359 359
 				// Loop on each lines
360 360
 				for ($i = 0; $i < $nblignes; $i++)
361 361
 				{
362 362
 					$curY = $nexY;
363
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
364
-					$pdf->SetTextColor(0,0,0);
363
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
364
+					$pdf->SetTextColor(0, 0, 0);
365 365
 
366 366
 					// Define size of image if we need it
367
-					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
367
+					$imglinesize = array();
368
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
369 369
 
370 370
 					$pdf->setTopMargin($tab_top_newpage);
371
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
372
-					$pageposbefore=$pdf->getPage();
371
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
372
+					$pageposbefore = $pdf->getPage();
373 373
 
374
-					$showpricebeforepagebreak=1;
375
-					$posYAfterImage=0;
376
-					$posYAfterDescription=0;
374
+					$showpricebeforepagebreak = 1;
375
+					$posYAfterImage = 0;
376
+					$posYAfterDescription = 0;
377 377
 
378 378
 					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
379
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
380 380
 					{
381
-						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
+						$pdf->AddPage('', '', true);
382
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
383 383
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
384
-						$pdf->setPage($pageposbefore+1);
384
+						$pdf->setPage($pageposbefore + 1);
385 385
 
386 386
 						$curY = $tab_top_newpage;
387
-						$showpricebeforepagebreak=0;
387
+						$showpricebeforepagebreak = 0;
388 388
 					}
389 389
 
390 390
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
391 391
 					{
392
-						$curX = $this->posxpicture-1;
393
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
392
+						$curX = $this->posxpicture - 1;
393
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
394 394
 						// $pdf->Image does not increase value return by getY, so we save it manually
395
-						$posYAfterImage=$curY+$imglinesize['height'];
395
+						$posYAfterImage = $curY + $imglinesize['height'];
396 396
 					}
397 397
 
398 398
 					// Description of product line
399
-					$curX = $this->posxdesc-1;
399
+					$curX = $this->posxdesc - 1;
400 400
 
401 401
 					$pdf->startTransaction();
402
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
402
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
403 403
 
404
-					$pageposafter=$pdf->getPage();
404
+					$pageposafter = $pdf->getPage();
405 405
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
406 406
 					{
407 407
 						$pdf->rollbackTransaction(true);
408
-						$pageposafter=$pageposbefore;
408
+						$pageposafter = $pageposbefore;
409 409
 						//print $pageposafter.'-'.$pageposbefore;exit;
410
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
410
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
411 411
 
412
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
412
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
413 413
 
414
-						$pageposafter=$pdf->getPage();
415
-						$posyafter=$pdf->GetY();
414
+						$pageposafter = $pdf->getPage();
415
+						$posyafter = $pdf->GetY();
416 416
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
417
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
417
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
418 418
 						{
419
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
419
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
420 420
 							{
421
-								$pdf->AddPage('','',true);
422
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
421
+								$pdf->AddPage('', '', true);
422
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
423 423
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424
-								$pdf->setPage($pageposafter+1);
424
+								$pdf->setPage($pageposafter + 1);
425 425
 							}
426 426
 						}
427 427
 						else
428 428
 						{
429 429
 							// We found a page break
430
-							$showpricebeforepagebreak=0;
430
+							$showpricebeforepagebreak = 0;
431 431
 						}
432 432
 					}
433 433
 					else	// No pagebreak
434 434
 					{
435 435
 						$pdf->commitTransaction();
436 436
 					}
437
-					$posYAfterDescription=$pdf->GetY();
437
+					$posYAfterDescription = $pdf->GetY();
438 438
 
439 439
 					$nexY = $pdf->GetY();
440
-					$pageposafter=$pdf->getPage();
440
+					$pageposafter = $pdf->getPage();
441 441
 
442 442
 					$pdf->setPage($pageposbefore);
443 443
 					$pdf->setTopMargin($this->marge_haute);
444
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
444
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
445 445
 
446 446
 					// We suppose that a too long description or photo were moved completely on next page
447 447
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -453,55 +453,55 @@  discard block
 block discarded – undo
453 453
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
454 454
 					}
455 455
 
456
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
456
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
457 457
 
458 458
 					$pdf->SetXY($this->posxweightvol, $curY);
459
-					$weighttxt='';
459
+					$weighttxt = '';
460 460
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight)
461 461
 					{
462
-					    $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight");
462
+					    $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units, "weight");
463 463
 					}
464
-					$voltxt='';
464
+					$voltxt = '';
465 465
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume)
466 466
 					{
467
-					    $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume");
467
+					    $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, "volume");
468 468
 					}
469 469
 
470
-					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
470
+					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
471 471
 					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
472 472
 
473 473
 					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
474 474
 					{
475 475
 					   $pdf->SetXY($this->posxqtyordered, $curY);
476
-					   if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
477
-						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
478
-						   $totalOrdered+=$object->lines[$i]->qty_asked;
476
+					   if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
477
+						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
478
+						   $totalOrdered += $object->lines[$i]->qty_asked;
479 479
 					   }
480 480
 					   $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
481 481
 					}
482 482
 
483 483
 					$pdf->SetXY($this->posxqtytoship, $curY);
484
-					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C');
484
+					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C');
485 485
 
486
-					if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
486
+					if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
487 487
 					{
488 488
 						$pdf->SetXY($this->posxpuht, $curY);
489
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
489
+						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
490 490
 
491 491
 						$pdf->SetXY($this->posxtotalht, $curY);
492
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
492
+						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
493 493
 					}
494 494
 
495
-					$nexY+=3;
496
-					if ($weighttxt && $voltxt) $nexY+=2;
495
+					$nexY += 3;
496
+					if ($weighttxt && $voltxt) $nexY += 2;
497 497
 
498 498
 					// Add line
499
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
499
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
500 500
 					{
501 501
 						$pdf->setPage($pageposafter);
502
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
502
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
503 503
 						//$pdf->SetDrawColor(190,190,200);
504
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
504
+						$pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
505 505
 						$pdf->SetLineStyle(array('dash'=>0));
506 506
 					}
507 507
 
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 						{
518 518
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
519 519
 						}
520
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
520
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
521 521
 						$pagenb++;
522 522
 						$pdf->setPage($pagenb);
523
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
523
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
524 524
 					}
525
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
525
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
526 526
 					{
527 527
 						if ($pagenb == 1)
528 528
 						{
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
 						{
533 533
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
534 534
 						}
535
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
535
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
536 536
 						// New page
537 537
 						$pdf->AddPage();
538
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
538
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
539 539
 						$pagenb++;
540 540
 					}
541 541
 				}
@@ -544,45 +544,45 @@  discard block
 block discarded – undo
544 544
 				if ($pagenb == 1)
545 545
 				{
546 546
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
547
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
547
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548 548
 				}
549 549
 				else
550 550
 				{
551 551
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
552
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
552
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
553 553
 				}
554 554
 
555 555
 				// Affiche zone totaux
556
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
556
+				$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
557 557
 
558 558
 				// Pied de page
559
-				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
559
+				$this->_pagefoot($pdf, $object, $outputlangs);
560
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
561 561
 
562 562
 				$pdf->Close();
563 563
 
564
-				$pdf->Output($file,'F');
564
+				$pdf->Output($file, 'F');
565 565
 
566 566
 				// Add pdfgeneration hook
567 567
 				$hookmanager->initHooks(array('pdfgeneration'));
568
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
568
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
569 569
 				global $action;
570
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
571 571
 
572
-				if (! empty($conf->global->MAIN_UMASK))
572
+				if (!empty($conf->global->MAIN_UMASK))
573 573
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
574 574
 
575
-				return 1;	// No error
575
+				return 1; // No error
576 576
 			}
577 577
 			else
578 578
 			{
579
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
579
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
580 580
 				return 0;
581 581
 			}
582 582
 		}
583 583
 		else
584 584
 		{
585
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
585
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
586 586
 			return 0;
587 587
 		}
588 588
 	}
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
603 603
 	{
604 604
 		// phpcs:enable
605
-		global $conf,$mysoc;
605
+		global $conf, $mysoc;
606 606
 
607
-        $sign=1;
607
+        $sign = 1;
608 608
 
609 609
         $default_font_size = pdf_getPDFFontSize($outputlangs);
610 610
 
611 611
 		$tab2_top = $posy;
612 612
 		$tab2_hl = 4;
613
-		$pdf->SetFont('','B', $default_font_size - 1);
613
+		$pdf->SetFont('', 'B', $default_font_size - 1);
614 614
 
615 615
 		// Tableau total
616
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
616
+		$col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
617 617
 		/*if ($this->page_largeur < 210) // To work with US executive format
618 618
 		{
619 619
 			$col2x-=20;
@@ -621,34 +621,34 @@  discard block
 block discarded – undo
621 621
 		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
622 622
 		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
623 623
 
624
-		$useborder=0;
624
+		$useborder = 0;
625 625
 		$index = 0;
626 626
 
627
-		$totalWeighttoshow='';
628
-		$totalVolumetoshow='';
627
+		$totalWeighttoshow = '';
628
+		$totalVolumetoshow = '';
629 629
 
630 630
 		// Load dim data
631
-		$tmparray=$object->getTotalWeightVolume();
632
-		$totalWeight=$tmparray['weight'];
633
-		$totalVolume=$tmparray['volume'];
634
-		$totalToShip=$tmparray['toship'];
631
+		$tmparray = $object->getTotalWeightVolume();
632
+		$totalWeight = $tmparray['weight'];
633
+		$totalVolume = $tmparray['volume'];
634
+		$totalToShip = $tmparray['toship'];
635 635
 
636 636
 
637 637
 		// Set trueVolume and volume_units not currently stored into database
638 638
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
639 639
 		{
640
-		    $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
-		    $object->volume_units=$object->size_units * 3;
640
+		    $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
641
+		    $object->volume_units = $object->size_units * 3;
642 642
 		}
643 643
 
644
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
644
+		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
+		if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
+		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
+		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
648 648
 
649
-    	$pdf->SetFillColor(255,255,255);
649
+    	$pdf->SetFillColor(255, 255, 255);
650 650
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
651
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
651
+    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
652 652
 
653 653
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
654 654
         {
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
660 660
     	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
661 661
 
662
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
662
+		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
663 663
 
664 664
 	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
665 665
 	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 
684 684
 		    $index++;
685 685
 		}
686
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
686
+		if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
687 687
 
688
-		$pdf->SetTextColor(0,0,0);
688
+		$pdf->SetTextColor(0, 0, 0);
689 689
 
690 690
 		return ($tab2_top + ($tab2_hl * $index));
691 691
 	}
@@ -702,72 +702,72 @@  discard block
 block discarded – undo
702 702
 	 *   @param		int			$hidebottom		Hide bottom bar of array
703 703
 	 *   @return	void
704 704
 	 */
705
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
705
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
706 706
 	{
707 707
 		global $conf;
708 708
 
709 709
 		// Force to disable hidetop and hidebottom
710
-		$hidebottom=0;
711
-		if ($hidetop) $hidetop=-1;
710
+		$hidebottom = 0;
711
+		if ($hidetop) $hidetop = -1;
712 712
 
713 713
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
714 714
 
715 715
 		// Amount in (at tab_top - 1)
716
-		$pdf->SetTextColor(0,0,0);
717
-		$pdf->SetFont('','',$default_font_size - 2);
716
+		$pdf->SetTextColor(0, 0, 0);
717
+		$pdf->SetFont('', '', $default_font_size - 2);
718 718
 
719 719
 		// Output Rect
720
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
720
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
721 721
 
722
-		$pdf->SetDrawColor(128,128,128);
723
-		$pdf->SetFont('','', $default_font_size - 1);
722
+		$pdf->SetDrawColor(128, 128, 128);
723
+		$pdf->SetFont('', '', $default_font_size - 1);
724 724
 
725 725
 		if (empty($hidetop))
726 726
 		{
727
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
727
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
728 728
 
729
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
729
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
730 730
 			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
731 731
 		}
732 732
 
733
-		$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
733
+		$pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
734 734
 		if (empty($hidetop))
735 735
 		{
736
-			$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
737
-			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
736
+			$pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
737
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
738 738
 		}
739 739
 
740 740
         if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
741 741
         {
742
-            $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
742
+            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
743 743
     		if (empty($hidetop))
744 744
     		{
745
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
746
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
745
+    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
746
+    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
747 747
     		}
748 748
         }
749 749
 
750
-		$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
750
+		$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
751 751
 		if (empty($hidetop))
752 752
 		{
753
-			$pdf->SetXY($this->posxqtytoship, $tab_top+1);
754
-			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C');
753
+			$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
754
+			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C');
755 755
 		}
756 756
 
757
-		if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
757
+		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
758 758
 
759
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
759
+			$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
760 760
 			if (empty($hidetop))
761 761
 			{
762
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
763
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
762
+				$pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
763
+				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
764 764
 			}
765 765
 
766
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
766
+			$pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
767 767
 			if (empty($hidetop))
768 768
 			{
769
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
770
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
769
+				$pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
770
+				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
771 771
 			}
772 772
 		}
773 773
 	}
@@ -783,73 +783,73 @@  discard block
 block discarded – undo
783 783
 	 */
784 784
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
785 785
 	{
786
-		global $conf,$langs,$mysoc;
786
+		global $conf, $langs, $mysoc;
787 787
 
788 788
 		$langs->load("orders");
789 789
 
790 790
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
791 791
 
792
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
792
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
793 793
 
794 794
 		// Show Draft Watermark
795
-		if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) )
795
+		if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK)))
796 796
 		{
797
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK);
797
+            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
798 798
 		}
799 799
 
800 800
 		//Prepare la suite
801
-		$pdf->SetTextColor(0,0,60);
802
-		$pdf->SetFont('','B', $default_font_size + 3);
801
+		$pdf->SetTextColor(0, 0, 60);
802
+		$pdf->SetFont('', 'B', $default_font_size + 3);
803 803
 
804 804
 		$w = 110;
805 805
 
806
-		$posy=$this->marge_haute;
807
-		$posx=$this->page_largeur-$this->marge_droite-$w;
806
+		$posy = $this->marge_haute;
807
+		$posx = $this->page_largeur - $this->marge_droite - $w;
808 808
 
809
-		$pdf->SetXY($this->marge_gauche,$posy);
809
+		$pdf->SetXY($this->marge_gauche, $posy);
810 810
 
811 811
 		// Logo
812
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
812
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
813 813
 		if ($this->emetteur->logo)
814 814
 		{
815 815
 			if (is_readable($logo))
816 816
 			{
817
-			    $height=pdf_getHeightForLogo($logo);
818
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
817
+			    $height = pdf_getHeightForLogo($logo);
818
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
819 819
 			}
820 820
 			else
821 821
 			{
822
-				$pdf->SetTextColor(200,0,0);
823
-				$pdf->SetFont('','B', $default_font_size - 2);
824
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
822
+				$pdf->SetTextColor(200, 0, 0);
823
+				$pdf->SetFont('', 'B', $default_font_size - 2);
824
+				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
825 825
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
826 826
 			}
827 827
 		}
828 828
 		else
829 829
 		{
830
-			$text=$this->emetteur->name;
830
+			$text = $this->emetteur->name;
831 831
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
832 832
 		}
833 833
 
834 834
 		// Show barcode
835
-		if (! empty($conf->barcode->enabled))
835
+		if (!empty($conf->barcode->enabled))
836 836
 		{
837
-			$posx=105;
837
+			$posx = 105;
838 838
 		}
839 839
 		else
840 840
 		{
841
-			$posx=$this->marge_gauche+3;
841
+			$posx = $this->marge_gauche + 3;
842 842
 		}
843 843
 		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
844
-		if (! empty($conf->barcode->enabled))
844
+		if (!empty($conf->barcode->enabled))
845 845
 		{
846 846
 			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
847 847
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
848 848
 			//$pdf->Image($logo,10, 5, 0, 24);
849 849
 		}
850 850
 
851
-		$pdf->SetDrawColor(128,128,128);
852
-		if (! empty($conf->barcode->enabled))
851
+		$pdf->SetDrawColor(128, 128, 128);
852
+		if (!empty($conf->barcode->enabled))
853 853
 		{
854 854
 			// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
855 855
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@@ -857,115 +857,115 @@  discard block
 block discarded – undo
857 857
 		}
858 858
 
859 859
 
860
-		$posx=$this->page_largeur - $w - $this->marge_droite;
861
-		$posy=$this->marge_haute;
860
+		$posx = $this->page_largeur - $w - $this->marge_droite;
861
+		$posy = $this->marge_haute;
862 862
 
863
-		$pdf->SetFont('','B', $default_font_size + 2);
864
-		$pdf->SetXY($posx,$posy);
865
-		$pdf->SetTextColor(0,0,60);
866
-		$title=$outputlangs->transnoentities("ReceptionSheet");
863
+		$pdf->SetFont('', 'B', $default_font_size + 2);
864
+		$pdf->SetXY($posx, $posy);
865
+		$pdf->SetTextColor(0, 0, 60);
866
+		$title = $outputlangs->transnoentities("ReceptionSheet");
867 867
 		$pdf->MultiCell($w, 4, $title, '', 'R');
868 868
 
869
-		$pdf->SetFont('','', $default_font_size + 1);
869
+		$pdf->SetFont('', '', $default_font_size + 1);
870 870
 
871
-		$posy+=5;
871
+		$posy += 5;
872 872
 
873
-		$pdf->SetXY($posx,$posy);
874
-		$pdf->SetTextColor(0,0,60);
875
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R');
873
+		$pdf->SetXY($posx, $posy);
874
+		$pdf->SetTextColor(0, 0, 60);
875
+		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R');
876 876
 
877 877
 		// Date planned delivery
878
-		if (! empty($object->date_delivery))
878
+		if (!empty($object->date_delivery))
879 879
 		{
880
-    			$posy+=4;
881
-    			$pdf->SetXY($posx,$posy);
882
-    			$pdf->SetTextColor(0,0,60);
883
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
880
+    			$posy += 4;
881
+    			$pdf->SetXY($posx, $posy);
882
+    			$pdf->SetTextColor(0, 0, 60);
883
+    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
884 884
 		}
885 885
 
886
-		if (! empty($object->thirdparty->code_fournisseur))
886
+		if (!empty($object->thirdparty->code_fournisseur))
887 887
 		{
888
-			$posy+=4;
889
-			$pdf->SetXY($posx,$posy);
890
-			$pdf->SetTextColor(0,0,60);
891
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
888
+			$posy += 4;
889
+			$pdf->SetXY($posx, $posy);
890
+			$pdf->SetTextColor(0, 0, 60);
891
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
892 892
 		}
893 893
 
894 894
 
895
-		$pdf->SetFont('','', $default_font_size + 3);
896
-		$Yoff=25;
895
+		$pdf->SetFont('', '', $default_font_size + 3);
896
+		$Yoff = 25;
897 897
 
898 898
 		// Add list of linked orders
899
-		$origin 	= $object->origin;
900
-		$origin_id 	= $object->origin_id;
899
+		$origin = $object->origin;
900
+		$origin_id = $object->origin_id;
901 901
 
902 902
 	    // TODO move to external function
903
-		if (! empty($conf->fournisseur->enabled))     // commonly $origin='commande'
903
+		if (!empty($conf->fournisseur->enabled))     // commonly $origin='commande'
904 904
 		{
905 905
 			$outputlangs->load('orders');
906 906
 
907 907
 			$classname = 'CommandeFournisseur';
908 908
 			$linkedobject = new $classname($this->db);
909
-			$result=$linkedobject->fetch($origin_id);
909
+			$result = $linkedobject->fetch($origin_id);
910 910
 			if ($result >= 0)
911 911
 			{
912 912
 			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
913 913
 
914
-				$pdf->SetFont('','', $default_font_size - 2);
915
-				$text=$linkedobject->ref;
916
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
917
-				$Yoff = $Yoff+8;
918
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
919
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
920
-				$Yoff = $Yoff+3;
921
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
922
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
914
+				$pdf->SetFont('', '', $default_font_size - 2);
915
+				$text = $linkedobject->ref;
916
+				if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
917
+				$Yoff = $Yoff + 8;
918
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
919
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
920
+				$Yoff = $Yoff + 3;
921
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
922
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
923 923
 			}
924 924
 		}
925 925
 
926 926
 		if ($showaddress)
927 927
 		{
928 928
 			// Sender properties
929
-			$carac_emetteur='';
929
+			$carac_emetteur = '';
930 930
 		 	// Add internal contact of origin element if defined
931
-			$arrayidcontact=array();
932
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
933
-			if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
931
+			$arrayidcontact = array();
932
+			if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
933
+			if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
934 934
 		 	if (count($arrayidcontact) > 0)
935 935
 		 	{
936 936
 		 		$object->fetch_user(reset($arrayidcontact));
937
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
937
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
938 938
 		 	}
939 939
 
940 940
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
941 941
 
942 942
 			// Show sender
943
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
-			$posx=$this->marge_gauche;
945
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
943
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944
+			$posx = $this->marge_gauche;
945
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
946 946
 
947
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
947
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
949 949
 
950 950
 			// Show sender frame
951
-			$pdf->SetTextColor(0,0,0);
952
-			$pdf->SetFont('','', $default_font_size - 2);
953
-			$pdf->SetXY($posx,$posy-5);
954
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
-			$pdf->SetXY($posx,$posy);
956
-			$pdf->SetFillColor(230,230,230);
951
+			$pdf->SetTextColor(0, 0, 0);
952
+			$pdf->SetFont('', '', $default_font_size - 2);
953
+			$pdf->SetXY($posx, $posy - 5);
954
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
955
+			$pdf->SetXY($posx, $posy);
956
+			$pdf->SetFillColor(230, 230, 230);
957 957
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
958
-			$pdf->SetTextColor(0,0,60);
959
-			$pdf->SetFillColor(255,255,255);
958
+			$pdf->SetTextColor(0, 0, 60);
959
+			$pdf->SetFillColor(255, 255, 255);
960 960
 
961 961
 			// If RECEPTION contact defined, we use it
962
-			$usecontact=false;
963
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
962
+			$usecontact = false;
963
+			$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
964 964
 
965 965
 			if (count($arrayidcontact) > 0)
966 966
 			{
967
-				$usecontact=true;
968
-				$result=$object->fetch_contact($arrayidcontact[0]);
967
+				$usecontact = true;
968
+				$result = $object->fetch_contact($arrayidcontact[0]);
969 969
 			}
970 970
 
971 971
 			//Recipient name
@@ -976,51 +976,51 @@  discard block
 block discarded – undo
976 976
 				$thirdparty = $object->thirdparty;
977 977
 			}
978 978
 
979
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
979
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
980 980
 
981
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
981
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
982 982
 
983 983
 				// Show recipient name
984
-			$pdf->SetXY($posx+2,$posy+3);
985
-			$pdf->SetFont('','B', $default_font_size);
986
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L');
984
+			$pdf->SetXY($posx + 2, $posy + 3);
985
+			$pdf->SetFont('', 'B', $default_font_size);
986
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L');
987 987
 
988 988
 			$posy = $pdf->getY();
989 989
 
990 990
 			// Show recipient information
991
-			$pdf->SetFont('','', $default_font_size - 1);
992
-			$pdf->SetXY($posx+2,$posy);
993
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L');
991
+			$pdf->SetFont('', '', $default_font_size - 1);
992
+			$pdf->SetXY($posx + 2, $posy);
993
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L');
994 994
 
995 995
 			// Show recipient
996
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
998
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1000
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
996
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
998
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1000
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1001 1001
 
1002 1002
 			// Show recipient frame
1003
-			$pdf->SetTextColor(0,0,0);
1004
-			$pdf->SetFont('','', $default_font_size - 2);
1005
-			$pdf->SetXY($posx+2,$posy-5);
1003
+			$pdf->SetTextColor(0, 0, 0);
1004
+			$pdf->SetFont('', '', $default_font_size - 2);
1005
+			$pdf->SetXY($posx + 2, $posy - 5);
1006 1006
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1007 1007
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1008 1008
 
1009 1009
 
1010 1010
 
1011 1011
 			// Show sender name
1012
-			$pdf->SetXY($posx+2,$posy+3);
1013
-			$pdf->SetFont('','B',$default_font_size);
1012
+			$pdf->SetXY($posx + 2, $posy + 3);
1013
+			$pdf->SetFont('', 'B', $default_font_size);
1014 1014
 			$pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1015
-			$posy=$pdf->getY();
1015
+			$posy = $pdf->getY();
1016 1016
 
1017 1017
 			// Show sender information
1018
-			$pdf->SetXY($posx+2,$posy);
1019
-			$pdf->SetFont('','', $default_font_size - 1);
1018
+			$pdf->SetXY($posx + 2, $posy);
1019
+			$pdf->SetFont('', '', $default_font_size - 1);
1020 1020
 			$pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1021 1021
 		}
1022 1022
 
1023
-		$pdf->SetTextColor(0,0,0);
1023
+		$pdf->SetTextColor(0, 0, 0);
1024 1024
 	}
1025 1025
 
1026 1026
 	/**
@@ -1032,10 +1032,10 @@  discard block
 block discarded – undo
1032 1032
 	 *      @param	int			$hidefreetext		1=Hide free text
1033 1033
 	 *      @return	int								Return height of bottom margin including footer text
1034 1034
 	 */
1035
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1035
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1036 1036
 	{
1037 1037
 		global $conf;
1038
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
-		return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1038
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1039
+		return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1040 1040
 	}
1041 1041
 }
Please login to merge, or discard this patch.
Braces   +132 added lines, -68 removed lines patch added patch discarded remove patch
@@ -62,7 +62,10 @@  discard block
 block discarded – undo
62 62
 
63 63
 		// Get source company
64 64
 		$this->emetteur=$mysoc;
65
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
65
+		if (! $this->emetteur->country_code) {
66
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
67
+		}
68
+		// By default if not defined
66 69
 
67 70
 		// Define position of columns
68 71
 		$this->posxdesc=$this->marge_gauche+1;
@@ -82,9 +85,11 @@  discard block
 block discarded – undo
82 85
 
83 86
 		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
84 87
 
85
-		if ($this->page_largeur < 210) // To work with US executive format
88
+		if ($this->page_largeur < 210) {
89
+		    // To work with US executive format
86 90
 		{
87 91
 		    $this->posxweightvol-=20;
92
+		}
88 93
 		    $this->posxpicture-=20;
89 94
 		    $this->posxqtyordered-=20;
90 95
 		    $this->posxqtytoship-=20;
@@ -117,9 +122,13 @@  discard block
 block discarded – undo
117 122
 
118 123
 		$object->fetch_thirdparty();
119 124
 
120
-		if (! is_object($outputlangs)) $outputlangs=$langs;
125
+		if (! is_object($outputlangs)) {
126
+		    $outputlangs=$langs;
127
+		}
121 128
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
122
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
129
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
130
+		    $outputlangs->charset_output='ISO-8859-1';
131
+		}
123 132
 
124 133
 		$outputlangs->load("main");
125 134
 		$outputlangs->load("dict");
@@ -141,7 +150,9 @@  discard block
 block discarded – undo
141 150
 
142 151
             for ($i = 0 ; $i < $nblignes ; $i++)
143 152
             {
144
-                if (empty($object->lines[$i]->fk_product)) continue;
153
+                if (empty($object->lines[$i]->fk_product)) {
154
+                    continue;
155
+                }
145 156
 
146 157
 				$objphoto = new Product($this->db);
147 158
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -153,18 +164,18 @@  discard block
 block discarded – undo
153 164
 
154 165
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
155 166
                         {
156
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
167
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
168
+                                // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
157 169
                             {
158 170
                                 if ($obj['photo_vignette'])
159 171
                                 {
160 172
                                     $filename= $obj['photo_vignette'];
161
-                                }
162
-                                else
173
+                            }
174
+                                } else
163 175
                                 {
164 176
                                     $filename=$obj['photo'];
165 177
                                 }
166
-                            }
167
-                            else
178
+                            } else
168 179
                             {
169 180
                                 $filename=$obj['photo'];
170 181
                             }
@@ -173,11 +184,15 @@  discard block
 block discarded – undo
173 184
                             break;
174 185
                 }
175 186
 
176
-                if ($realpath) $realpatharray[$i]=$realpath;
187
+                if ($realpath) {
188
+                    $realpatharray[$i]=$realpath;
189
+                }
177 190
             }
178 191
         }
179 192
 
180
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
193
+        if (count($realpatharray) == 0) {
194
+            $this->posxpicture=$this->posxweightvol;
195
+        }
181 196
 
182 197
 		if ($conf->reception->dir_output)
183 198
 		{
@@ -186,8 +201,7 @@  discard block
 block discarded – undo
186 201
 			{
187 202
 				$dir = $conf->reception->dir_output;
188 203
 				$file = $dir . "/SPECIMEN.pdf";
189
-			}
190
-			else
204
+			} else
191 205
 			{
192 206
 				$rcpref = dol_sanitizeFileName($object->ref);
193 207
 				$dir = $conf->reception->dir_output."/" . $rcpref;
@@ -243,20 +257,26 @@  discard block
 block discarded – undo
243 257
 				$pagenb=0;
244 258
 				$pdf->SetDrawColor(128,128,128);
245 259
 
246
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
260
+				if (method_exists($pdf,'AliasNbPages')) {
261
+				    $pdf->AliasNbPages();
262
+				}
247 263
 
248 264
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
249 265
 				$pdf->SetSubject($outputlangs->transnoentities("Reception"));
250 266
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
251 267
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
252 268
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
253
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
269
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
270
+				    $pdf->SetCompression(false);
271
+				}
254 272
 
255 273
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
256 274
 
257 275
 				// New page
258 276
 				$pdf->AddPage();
259
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
277
+				if (! empty($tplidx)) {
278
+				    $pdf->useTemplate($tplidx);
279
+				}
260 280
 				$pagenb++;
261 281
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
262 282
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -313,7 +333,9 @@  discard block
 block discarded – undo
313 333
 								// Get code using getLabelFromKey
314 334
 								$code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code');
315 335
 								$label='';
316
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
336
+								if ($object->tracking_url != $object->tracking_number) {
337
+								    $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
338
+								}
317 339
 								$label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
318 340
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
319 341
 								if ($object->tracking_url != $object->tracking_number)
@@ -345,8 +367,7 @@  discard block
 block discarded – undo
345 367
 
346 368
 					$tab_height = $tab_height - $height_note;
347 369
 					$tab_top = $nexY+6;
348
-				}
349
-				else
370
+				} else
350 371
 				{
351 372
 					$height_note=0;
352 373
 				}
@@ -365,7 +386,9 @@  discard block
 block discarded – undo
365 386
 
366 387
 					// Define size of image if we need it
367 388
 					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
389
+					if (! empty($realpatharray[$i])) {
390
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
391
+					}
369 392
 
370 393
 					$pdf->setTopMargin($tab_top_newpage);
371 394
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -376,11 +399,17 @@  discard block
 block discarded – undo
376 399
 					$posYAfterDescription=0;
377 400
 
378 401
 					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
402
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
403
+					    // If photo too high, we moved completely on new page
380 404
 					{
381 405
 						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
383
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
406
+					}
407
+						if (! empty($tplidx)) {
408
+						    $pdf->useTemplate($tplidx);
409
+						}
410
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
411
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
412
+						}
384 413
 						$pdf->setPage($pageposbefore+1);
385 414
 
386 415
 						$curY = $tab_top_newpage;
@@ -402,9 +431,11 @@  discard block
 block discarded – undo
402 431
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
403 432
 
404 433
 					$pageposafter=$pdf->getPage();
405
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
434
+					if ($pageposafter > $pageposbefore) {
435
+					    // There is a pagebreak
406 436
 					{
407 437
 						$pdf->rollbackTransaction(true);
438
+					}
408 439
 						$pageposafter=$pageposbefore;
409 440
 						//print $pageposafter.'-'.$pageposbefore;exit;
410 441
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -414,23 +445,27 @@  discard block
 block discarded – undo
414 445
 						$pageposafter=$pdf->getPage();
415 446
 						$posyafter=$pdf->GetY();
416 447
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
417
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
448
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
449
+						    // There is no space left for total+free text
418 450
 						{
419 451
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
420 452
 							{
421 453
 								$pdf->AddPage('','',true);
422
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
423
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
454
+						}
455
+								if (! empty($tplidx)) {
456
+								    $pdf->useTemplate($tplidx);
457
+								}
458
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
459
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
460
+								}
424 461
 								$pdf->setPage($pageposafter+1);
425 462
 							}
426
-						}
427
-						else
463
+						} else
428 464
 						{
429 465
 							// We found a page break
430 466
 							$showpricebeforepagebreak=0;
431 467
 						}
432
-					}
433
-					else	// No pagebreak
468
+					} else	// No pagebreak
434 469
 					{
435 470
 						$pdf->commitTransaction();
436 471
 					}
@@ -493,7 +528,9 @@  discard block
 block discarded – undo
493 528
 					}
494 529
 
495 530
 					$nexY+=3;
496
-					if ($weighttxt && $voltxt) $nexY+=2;
531
+					if ($weighttxt && $voltxt) {
532
+					    $nexY+=2;
533
+					}
497 534
 
498 535
 					// Add line
499 536
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -512,8 +549,7 @@  discard block
 block discarded – undo
512 549
 						if ($pagenb == 1)
513 550
 						{
514 551
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
515
-						}
516
-						else
552
+						} else
517 553
 						{
518 554
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
519 555
 						}
@@ -527,15 +563,16 @@  discard block
 block discarded – undo
527 563
 						if ($pagenb == 1)
528 564
 						{
529 565
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
530
-						}
531
-						else
566
+						} else
532 567
 						{
533 568
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
534 569
 						}
535 570
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
536 571
 						// New page
537 572
 						$pdf->AddPage();
538
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
573
+						if (! empty($tplidx)) {
574
+						    $pdf->useTemplate($tplidx);
575
+						}
539 576
 						$pagenb++;
540 577
 					}
541 578
 				}
@@ -545,8 +582,7 @@  discard block
 block discarded – undo
545 582
 				{
546 583
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
547 584
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548
-				}
549
-				else
585
+				} else
550 586
 				{
551 587
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
552 588
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -557,7 +593,9 @@  discard block
 block discarded – undo
557 593
 
558 594
 				// Pied de page
559 595
 				$this->_pagefoot($pdf,$object,$outputlangs);
560
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
596
+				if (method_exists($pdf,'AliasNbPages')) {
597
+				    $pdf->AliasNbPages();
598
+				}
561 599
 
562 600
 				$pdf->Close();
563 601
 
@@ -569,18 +607,17 @@  discard block
 block discarded – undo
569 607
 				global $action;
570 608
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
571 609
 
572
-				if (! empty($conf->global->MAIN_UMASK))
573
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
610
+				if (! empty($conf->global->MAIN_UMASK)) {
611
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
612
+				}
574 613
 
575 614
 				return 1;	// No error
576
-			}
577
-			else
615
+			} else
578 616
 			{
579 617
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
580 618
 				return 0;
581 619
 			}
582
-		}
583
-		else
620
+		} else
584 621
 		{
585 622
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
586 623
 			return 0;
@@ -618,8 +655,11 @@  discard block
 block discarded – undo
618 655
 		{
619 656
 			$col2x-=20;
620 657
 		}*/
621
-		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
622
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
658
+		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
659
+		    $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
660
+		} else {
661
+		    $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
662
+		}
623 663
 
624 664
 		$useborder=0;
625 665
 		$index = 0;
@@ -641,10 +681,18 @@  discard block
 block discarded – undo
641 681
 		    $object->volume_units=$object->size_units * 3;
642 682
 		}
643 683
 
644
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
645
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
646
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
647
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
684
+		if ($totalWeight!='') {
685
+		    $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
686
+		}
687
+		if ($totalVolume!='') {
688
+		    $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
689
+		}
690
+		if ($object->trueWeight) {
691
+		    $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
692
+		}
693
+		if ($object->trueVolume) {
694
+		    $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
695
+		}
648 696
 
649 697
     	$pdf->SetFillColor(255,255,255);
650 698
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -683,7 +731,9 @@  discard block
 block discarded – undo
683 731
 
684 732
 		    $index++;
685 733
 		}
686
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
734
+		if (! $totalWeighttoshow && ! $totalVolumetoshow) {
735
+		    $index++;
736
+		}
687 737
 
688 738
 		$pdf->SetTextColor(0,0,0);
689 739
 
@@ -708,7 +758,9 @@  discard block
 block discarded – undo
708 758
 
709 759
 		// Force to disable hidetop and hidebottom
710 760
 		$hidebottom=0;
711
-		if ($hidetop) $hidetop=-1;
761
+		if ($hidetop) {
762
+		    $hidetop=-1;
763
+		}
712 764
 
713 765
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
714 766
 
@@ -816,16 +868,14 @@  discard block
 block discarded – undo
816 868
 			{
817 869
 			    $height=pdf_getHeightForLogo($logo);
818 870
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
819
-			}
820
-			else
871
+			} else
821 872
 			{
822 873
 				$pdf->SetTextColor(200,0,0);
823 874
 				$pdf->SetFont('','B', $default_font_size - 2);
824 875
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
825 876
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
826 877
 			}
827
-		}
828
-		else
878
+		} else
829 879
 		{
830 880
 			$text=$this->emetteur->name;
831 881
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -835,8 +885,7 @@  discard block
 block discarded – undo
835 885
 		if (! empty($conf->barcode->enabled))
836 886
 		{
837 887
 			$posx=105;
838
-		}
839
-		else
888
+		} else
840 889
 		{
841 890
 			$posx=$this->marge_gauche+3;
842 891
 		}
@@ -900,9 +949,11 @@  discard block
 block discarded – undo
900 949
 		$origin_id 	= $object->origin_id;
901 950
 
902 951
 	    // TODO move to external function
903
-		if (! empty($conf->fournisseur->enabled))     // commonly $origin='commande'
952
+		if (! empty($conf->fournisseur->enabled)) {
953
+		    // commonly $origin='commande'
904 954
 		{
905 955
 			$outputlangs->load('orders');
956
+		}
906 957
 
907 958
 			$classname = 'CommandeFournisseur';
908 959
 			$linkedobject = new $classname($this->db);
@@ -913,7 +964,9 @@  discard block
 block discarded – undo
913 964
 
914 965
 				$pdf->SetFont('','', $default_font_size - 2);
915 966
 				$text=$linkedobject->ref;
916
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
967
+				if ($linkedobject->ref_client) {
968
+				    $text.=' ('.$linkedobject->ref_client.')';
969
+				}
917 970
 				$Yoff = $Yoff+8;
918 971
 				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
919 972
 				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
@@ -929,8 +982,12 @@  discard block
 block discarded – undo
929 982
 			$carac_emetteur='';
930 983
 		 	// Add internal contact of origin element if defined
931 984
 			$arrayidcontact=array();
932
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
933
-			if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
985
+			if (! empty($origin) && is_object($object->$origin)) {
986
+			    $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
987
+			}
988
+			if(empty($arrayidcontact)) {
989
+			    $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING');
990
+			}
934 991
 		 	if (count($arrayidcontact) > 0)
935 992
 		 	{
936 993
 		 		$object->fetch_user(reset($arrayidcontact));
@@ -942,7 +999,9 @@  discard block
 block discarded – undo
942 999
 			// Show sender
943 1000
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
944 1001
 			$posx=$this->marge_gauche;
945
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1002
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1003
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1004
+			}
946 1005
 
947 1006
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
948 1007
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -994,10 +1053,15 @@  discard block
 block discarded – undo
994 1053
 
995 1054
 			// Show recipient
996 1055
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
997
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1056
+			if ($this->page_largeur < 210) {
1057
+			    $widthrecbox=84;
1058
+			}
1059
+			// To work with US executive format
998 1060
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
999 1061
 			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1000
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1062
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1063
+			    $posx=$this->marge_gauche;
1064
+			}
1001 1065
 
1002 1066
 			// Show recipient frame
1003 1067
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php 3 patches
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -35,488 +35,488 @@
 block discarded – undo
35 35
  */
36 36
 class doc_generic_reception_odt extends ModelePdfReception
37 37
 {
38
-	var $emetteur;	// Objet societe qui emet
39
-
40
-	var $phpmin = array(5,2,0);	// Minimum version of PHP required by module
41
-	var $version = 'dolibarr';
42
-
43
-
44
-	/**
45
-	 *	Constructor
46
-	 *
47
-	 *  @param		DoliDB		$db      Database handler
48
-	 */
49
-	function __construct($db)
50
-	{
51
-		global $conf,$langs,$mysoc;
52
-
53
-		$langs->load("main");
54
-		$langs->load("companies");
55
-
56
-		$this->db = $db;
57
-		$this->name = "ODT templates";
58
-		$this->description = $langs->trans("DocumentModelOdt");
59
-		$this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
60
-
61
-		// Dimension page pour format A4
62
-		$this->type = 'odt';
63
-		$this->page_largeur = 0;
64
-		$this->page_hauteur = 0;
65
-		$this->format = array($this->page_largeur,$this->page_hauteur);
66
-		$this->marge_gauche=0;
67
-		$this->marge_droite=0;
68
-		$this->marge_haute=0;
69
-		$this->marge_basse=0;
70
-
71
-		$this->option_logo = 1;                    // Affiche logo
72
-		$this->option_tva = 0;                     // Gere option tva RECEPTION_TVAOPTION
73
-		$this->option_modereg = 0;                 // Affiche mode reglement
74
-		$this->option_condreg = 0;                 // Affiche conditions reglement
75
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
76
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
77
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
78
-		$this->option_credit_note = 0;             // Support credit notes
79
-		$this->option_freetext = 1;				   // Support add of a personalised text
80
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
81
-
82
-		// Recupere emetteur
83
-		$this->emetteur=$mysoc;
84
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
85
-	}
86
-
87
-
88
-	/**
89
-	 *	Return description of a module
90
-	 *
91
-	 *	@param	Translate	$langs      Lang object to use for output
92
-	 *	@return string       			Description
93
-	 */
94
-	function info($langs)
95
-	{
96
-		global $conf,$langs;
97
-
98
-		$langs->load("companies");
99
-		$langs->load("errors");
100
-
101
-		$form = new Form($this->db);
102
-
103
-		$texte = $this->description.".<br>\n";
104
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
105
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
106
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
107
-		$texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">';
108
-		$texte.= '<table class="nobordernopadding" width="100%">';
109
-
110
-		// List of directories area
111
-		$texte.= '<tr><td>';
112
-		$texttitle=$langs->trans("ListOfDirectories");
113
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)));
114
-		$listoffiles=array();
115
-		foreach($listofdir as $key=>$tmpdir)
116
-		{
117
-			$tmpdir=trim($tmpdir);
118
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
119
-			if (! $tmpdir) {
120
-				unset($listofdir[$key]); continue;
121
-			}
122
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
123
-			else
124
-			{
125
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
126
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
127
-			}
128
-		}
129
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
130
-		// Add list of substitution keys
131
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
132
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
133
-
134
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
135
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
136
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
137
-		$texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
138
-		$texte.= '</textarea>';
139
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
140
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
141
-		$texte.= '<br></div></div>';
142
-
143
-		// Scan directories
144
-		$nbofiles=count($listoffiles);
145
-		if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
146
-		{
147
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
148
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
149
-			$texte.=count($listoffiles);
150
-			//$texte.=$nbofiles?'</a>':'';
151
-			$texte.='</b>';
152
-		}
153
-		if ($nbofiles)
154
-		{
155
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
156
-   			foreach($listoffiles as $file)
157
-   			{
38
+    var $emetteur;	// Objet societe qui emet
39
+
40
+    var $phpmin = array(5,2,0);	// Minimum version of PHP required by module
41
+    var $version = 'dolibarr';
42
+
43
+
44
+    /**
45
+     *	Constructor
46
+     *
47
+     *  @param		DoliDB		$db      Database handler
48
+     */
49
+    function __construct($db)
50
+    {
51
+        global $conf,$langs,$mysoc;
52
+
53
+        $langs->load("main");
54
+        $langs->load("companies");
55
+
56
+        $this->db = $db;
57
+        $this->name = "ODT templates";
58
+        $this->description = $langs->trans("DocumentModelOdt");
59
+        $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
60
+
61
+        // Dimension page pour format A4
62
+        $this->type = 'odt';
63
+        $this->page_largeur = 0;
64
+        $this->page_hauteur = 0;
65
+        $this->format = array($this->page_largeur,$this->page_hauteur);
66
+        $this->marge_gauche=0;
67
+        $this->marge_droite=0;
68
+        $this->marge_haute=0;
69
+        $this->marge_basse=0;
70
+
71
+        $this->option_logo = 1;                    // Affiche logo
72
+        $this->option_tva = 0;                     // Gere option tva RECEPTION_TVAOPTION
73
+        $this->option_modereg = 0;                 // Affiche mode reglement
74
+        $this->option_condreg = 0;                 // Affiche conditions reglement
75
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
76
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
77
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
78
+        $this->option_credit_note = 0;             // Support credit notes
79
+        $this->option_freetext = 1;				   // Support add of a personalised text
80
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
81
+
82
+        // Recupere emetteur
83
+        $this->emetteur=$mysoc;
84
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
85
+    }
86
+
87
+
88
+    /**
89
+     *	Return description of a module
90
+     *
91
+     *	@param	Translate	$langs      Lang object to use for output
92
+     *	@return string       			Description
93
+     */
94
+    function info($langs)
95
+    {
96
+        global $conf,$langs;
97
+
98
+        $langs->load("companies");
99
+        $langs->load("errors");
100
+
101
+        $form = new Form($this->db);
102
+
103
+        $texte = $this->description.".<br>\n";
104
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
105
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
106
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
107
+        $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">';
108
+        $texte.= '<table class="nobordernopadding" width="100%">';
109
+
110
+        // List of directories area
111
+        $texte.= '<tr><td>';
112
+        $texttitle=$langs->trans("ListOfDirectories");
113
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)));
114
+        $listoffiles=array();
115
+        foreach($listofdir as $key=>$tmpdir)
116
+        {
117
+            $tmpdir=trim($tmpdir);
118
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
119
+            if (! $tmpdir) {
120
+                unset($listofdir[$key]); continue;
121
+            }
122
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
123
+            else
124
+            {
125
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
126
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
127
+            }
128
+        }
129
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
130
+        // Add list of substitution keys
131
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
132
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
133
+
134
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
135
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
136
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
137
+        $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
138
+        $texte.= '</textarea>';
139
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
140
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
141
+        $texte.= '<br></div></div>';
142
+
143
+        // Scan directories
144
+        $nbofiles=count($listoffiles);
145
+        if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
146
+        {
147
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
148
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
149
+            $texte.=count($listoffiles);
150
+            //$texte.=$nbofiles?'</a>':'';
151
+            $texte.='</b>';
152
+        }
153
+        if ($nbofiles)
154
+        {
155
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
156
+                foreach($listoffiles as $file)
157
+                {
158 158
                 $texte.=$file['name'].'<br>';
159
-   			}
160
-   			$texte.='<div id="div_'.get_class($this).'">';
161
-		}
162
-
163
-		$texte.= '</td>';
164
-
165
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
166
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
167
-		$texte.= '</td>';
168
-		$texte.= '</tr>';
169
-
170
-		$texte.= '</table>';
171
-		$texte.= '</form>';
172
-
173
-		return $texte;
174
-	}
175
-
176
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
177
-	/**
178
-	 *	Function to build a document on disk using the generic odt module.
179
-	 *
180
-	 *	@param		Reception	$object				Object source to build document
181
-	 *	@param		Translate	$outputlangs		Lang output object
182
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
183
-	 *  @param		int			$hidedetails		Do not show line details
184
-	 *  @param		int			$hidedesc			Do not show desc
185
-	 *  @param		int			$hideref			Do not show ref
186
-	 *	@return		int         					1 if OK, <=0 if KO
187
-	 */
188
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
189
-	{
190
-		// phpcs:enable
191
-		global $user,$langs,$conf,$mysoc,$hookmanager;
192
-
193
-		if (empty($srctemplatepath))
194
-		{
195
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
196
-			return -1;
197
-		}
198
-
199
-		// Add odtgeneration hook
200
-		if (! is_object($hookmanager))
201
-		{
202
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
203
-			$hookmanager=new HookManager($this->db);
204
-		}
205
-		$hookmanager->initHooks(array('odtgeneration'));
206
-		global $action;
207
-
208
-		if (! is_object($outputlangs)) $outputlangs=$langs;
209
-		$sav_charset_output=$outputlangs->charset_output;
210
-		$outputlangs->charset_output='UTF-8';
211
-
212
-		$outputlangs->load("main");
213
-		$outputlangs->load("dict");
214
-		$outputlangs->load("companies");
215
-		$outputlangs->load("bills");
216
-
217
-		if ($conf->reception->dir_output."/reception")
218
-		{
219
-			// If $object is id instead of object
220
-			if (! is_object($object))
221
-			{
222
-				$id = $object;
223
-				$object = new Reception($this->db);
224
-				$result=$object->fetch($id);
225
-				if ($result < 0)
226
-				{
227
-					dol_print_error($this->db,$object->error);
228
-					return -1;
229
-				}
230
-			}
231
-
232
-			$dir = $conf->reception->dir_output."/reception";
233
-			$objectref = dol_sanitizeFileName($object->ref);
234
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
235
-			$file = $dir . "/" . $objectref . ".odt";
236
-
237
-			if (! file_exists($dir))
238
-			{
239
-				if (dol_mkdir($dir) < 0)
240
-				{
241
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
242
-					return -1;
243
-				}
244
-			}
245
-
246
-			if (file_exists($dir))
247
-			{
248
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
249
-				$newfile=basename($srctemplatepath);
250
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
251
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
252
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
253
-				$newfiletmp=$objectref.'_'.$newfiletmp;
254
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
255
-				// Get extension (ods or odt)
256
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
257
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
258
-				{
259
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
260
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
261
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
262
-				}
263
-				else
264
-				{
265
-					$filename=$newfiletmp.'.'.$newfileformat;
266
-				}
267
-				$file=$dir.'/'.$filename;
268
-				//print "newdir=".$dir;
269
-				//print "newfile=".$newfile;
270
-				//print "file=".$file;
271
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
272
-
273
-				dol_mkdir($conf->reception->dir_temp);
274
-
275
-
276
-				// If BILLING contact defined on invoice, we use it
277
-				$usecontact=false;
278
-				$arrayidcontact=$object->getIdContact('external','BILLING');
279
-				if (count($arrayidcontact) > 0)
280
-				{
281
-					$usecontact=true;
282
-					$result=$object->fetch_contact($arrayidcontact[0]);
283
-				}
284
-
285
-				// Recipient name
286
-				if (! empty($usecontact))
287
-				{
288
-					// On peut utiliser le nom de la societe du contact
289
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
290
-					else $socobject = $object->thirdparty;
291
-				}
292
-				else
293
-				{
294
-					$socobject=$object->thirdparty;
295
-				}
296
-
297
-				// Make substitution
298
-				$substitutionarray=array(
299
-				'__FROM_NAME__' => $this->emetteur->name,
300
-				'__FROM_EMAIL__' => $this->emetteur->email,
301
-				'__TOTAL_TTC__' => $object->total_ttc,
302
-				'__TOTAL_HT__' => $object->total_ht,
303
-				'__TOTAL_VAT__' => $object->total_vat
304
-				);
305
-				complete_substitutions_array($substitutionarray, $langs, $object);
306
-				// Call the ODTSubstitution hook
307
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
308
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
309
-
310
-				// Line of free text
311
-				$newfreetext='';
312
-				$paramfreetext='RECEPTION_FREE_TEXT';
313
-				if (! empty($conf->global->$paramfreetext))
314
-				{
315
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
316
-				}
317
-
318
-				// Open and load template
319
-				require_once ODTPHP_PATH.'odf.php';
320
-				try {
321
-					$odfHandler = new odf(
322
-						$srctemplatepath,
323
-						array(
324
-						'PATH_TO_TMP'	  => $conf->reception->dir_temp,
325
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
326
-						'DELIMITER_LEFT'  => '{',
327
-						'DELIMITER_RIGHT' => '}'
328
-						)
329
-					);
330
-				}
331
-				catch(Exception $e)
332
-				{
333
-					$this->error=$e->getMessage();
334
-					return -1;
335
-				}
336
-				// After construction $odfHandler->contentXml contains content and
337
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
338
-				// [!-- BEGIN lines --]*[!-- END lines --]
339
-				//print html_entity_decode($odfHandler->__toString());
340
-				//print exit;
341
-
342
-
343
-				// Make substitutions into odt of freetext
344
-				try {
345
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
346
-				}
347
-				catch(OdfException $e)
348
-				{
349
-				}
350
-
351
-				// Make substitutions into odt of user info
352
-				$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
353
-				//var_dump($tmparray); exit;
354
-				foreach($tmparray as $key=>$value)
355
-				{
356
-					try {
357
-						if (preg_match('/logo$/',$key)) // Image
358
-						{
359
-							//var_dump($value);exit;
360
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
361
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
362
-						}
363
-						else    // Text
364
-						{
365
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
366
-						}
367
-					}
368
-					catch(OdfException $e)
369
-					{
370
-					}
371
-				}
372
-				// Make substitutions into odt of mysoc
373
-				$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
374
-				//var_dump($tmparray); exit;
375
-				foreach($tmparray as $key=>$value)
376
-				{
377
-					try {
378
-						if (preg_match('/logo$/',$key))	// Image
379
-						{
380
-							//var_dump($value);exit;
381
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
382
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
-						}
384
-						else	// Text
385
-						{
386
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
387
-						}
388
-					}
389
-					catch(OdfException $e)
390
-					{
391
-					}
392
-				}
393
-				// Make substitutions into odt of thirdparty
394
-				$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
395
-				foreach($tmparray as $key=>$value)
396
-				{
397
-					try {
398
-						if (preg_match('/logo$/',$key))	// Image
399
-						{
400
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
401
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
402
-						}
403
-						else	// Text
404
-						{
405
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
406
-						}
407
-					}
408
-					catch(OdfException $e)
409
-					{
410
-					}
411
-				}
412
-				// Replace tags of object + external modules
413
-				$tmparray=$this->get_substitutionarray_reception($object,$outputlangs);
414
-				complete_substitutions_array($tmparray, $outputlangs, $object);
415
-				// Call the ODTSubstitution hook
416
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
417
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
-				foreach($tmparray as $key=>$value)
419
-				{
420
-					try {
421
-						if (preg_match('/logo$/',$key)) // Image
422
-						{
423
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
424
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
-						}
426
-						else    // Text
427
-						{
428
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
429
-						}
430
-					}
431
-					catch(OdfException $e)
432
-					{
433
-					}
434
-				}
435
-				// Replace tags of lines
436
-				try
437
-				{
438
-					$listlines = $odfHandler->setSegment('lines');
439
-					foreach ($object->lines as $line)
440
-					{
441
-						$tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs);
442
-						complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
443
-						// Call the ODTSubstitutionLine hook
444
-						$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
445
-						$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
-						foreach($tmparray as $key => $val)
447
-						{
448
-							try
449
-							{
450
-								$listlines->setVars($key, $val, true, 'UTF-8');
451
-							}
452
-							catch(OdfException $e)
453
-							{
454
-							}
455
-							catch(SegmentException $e)
456
-							{
457
-							}
458
-						}
459
-						$listlines->merge();
460
-					}
461
-					$odfHandler->mergeSegment($listlines);
462
-				}
463
-				catch(OdfException $e)
464
-				{
465
-					$this->error=$e->getMessage();
466
-					dol_syslog($this->error, LOG_WARNING);
467
-					return -1;
468
-				}
469
-
470
-				// Replace labels translated
471
-				$tmparray=$outputlangs->get_translations_for_substitutions();
472
-				foreach($tmparray as $key=>$value)
473
-				{
474
-					try {
475
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
476
-					}
477
-					catch(OdfException $e)
478
-					{
479
-					}
480
-				}
481
-
482
-				// Call the beforeODTSave hook
483
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
484
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
485
-
486
-				// Write new file
487
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
488
-					try {
489
-						$odfHandler->exportAsAttachedPDF($file);
490
-					}catch (Exception $e){
491
-						$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
-						return -1;
501
-					}
502
-				}
503
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
504
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
-
506
-				if (! empty($conf->global->MAIN_UMASK))
507
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
508
-
509
-				$odfHandler=null;	// Destroy object
510
-
511
-				return 1;   // Success
512
-			}
513
-			else
514
-			{
515
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
516
-				return -1;
517
-			}
518
-		}
519
-
520
-		return -1;
521
-	}
159
+                }
160
+                $texte.='<div id="div_'.get_class($this).'">';
161
+        }
162
+
163
+        $texte.= '</td>';
164
+
165
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
166
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
167
+        $texte.= '</td>';
168
+        $texte.= '</tr>';
169
+
170
+        $texte.= '</table>';
171
+        $texte.= '</form>';
172
+
173
+        return $texte;
174
+    }
175
+
176
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
177
+    /**
178
+     *	Function to build a document on disk using the generic odt module.
179
+     *
180
+     *	@param		Reception	$object				Object source to build document
181
+     *	@param		Translate	$outputlangs		Lang output object
182
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
183
+     *  @param		int			$hidedetails		Do not show line details
184
+     *  @param		int			$hidedesc			Do not show desc
185
+     *  @param		int			$hideref			Do not show ref
186
+     *	@return		int         					1 if OK, <=0 if KO
187
+     */
188
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
189
+    {
190
+        // phpcs:enable
191
+        global $user,$langs,$conf,$mysoc,$hookmanager;
192
+
193
+        if (empty($srctemplatepath))
194
+        {
195
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
196
+            return -1;
197
+        }
198
+
199
+        // Add odtgeneration hook
200
+        if (! is_object($hookmanager))
201
+        {
202
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
203
+            $hookmanager=new HookManager($this->db);
204
+        }
205
+        $hookmanager->initHooks(array('odtgeneration'));
206
+        global $action;
207
+
208
+        if (! is_object($outputlangs)) $outputlangs=$langs;
209
+        $sav_charset_output=$outputlangs->charset_output;
210
+        $outputlangs->charset_output='UTF-8';
211
+
212
+        $outputlangs->load("main");
213
+        $outputlangs->load("dict");
214
+        $outputlangs->load("companies");
215
+        $outputlangs->load("bills");
216
+
217
+        if ($conf->reception->dir_output."/reception")
218
+        {
219
+            // If $object is id instead of object
220
+            if (! is_object($object))
221
+            {
222
+                $id = $object;
223
+                $object = new Reception($this->db);
224
+                $result=$object->fetch($id);
225
+                if ($result < 0)
226
+                {
227
+                    dol_print_error($this->db,$object->error);
228
+                    return -1;
229
+                }
230
+            }
231
+
232
+            $dir = $conf->reception->dir_output."/reception";
233
+            $objectref = dol_sanitizeFileName($object->ref);
234
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
235
+            $file = $dir . "/" . $objectref . ".odt";
236
+
237
+            if (! file_exists($dir))
238
+            {
239
+                if (dol_mkdir($dir) < 0)
240
+                {
241
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
242
+                    return -1;
243
+                }
244
+            }
245
+
246
+            if (file_exists($dir))
247
+            {
248
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
249
+                $newfile=basename($srctemplatepath);
250
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
251
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
252
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
253
+                $newfiletmp=$objectref.'_'.$newfiletmp;
254
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
255
+                // Get extension (ods or odt)
256
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
257
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
258
+                {
259
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
260
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
261
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
262
+                }
263
+                else
264
+                {
265
+                    $filename=$newfiletmp.'.'.$newfileformat;
266
+                }
267
+                $file=$dir.'/'.$filename;
268
+                //print "newdir=".$dir;
269
+                //print "newfile=".$newfile;
270
+                //print "file=".$file;
271
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
272
+
273
+                dol_mkdir($conf->reception->dir_temp);
274
+
275
+
276
+                // If BILLING contact defined on invoice, we use it
277
+                $usecontact=false;
278
+                $arrayidcontact=$object->getIdContact('external','BILLING');
279
+                if (count($arrayidcontact) > 0)
280
+                {
281
+                    $usecontact=true;
282
+                    $result=$object->fetch_contact($arrayidcontact[0]);
283
+                }
284
+
285
+                // Recipient name
286
+                if (! empty($usecontact))
287
+                {
288
+                    // On peut utiliser le nom de la societe du contact
289
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
290
+                    else $socobject = $object->thirdparty;
291
+                }
292
+                else
293
+                {
294
+                    $socobject=$object->thirdparty;
295
+                }
296
+
297
+                // Make substitution
298
+                $substitutionarray=array(
299
+                '__FROM_NAME__' => $this->emetteur->name,
300
+                '__FROM_EMAIL__' => $this->emetteur->email,
301
+                '__TOTAL_TTC__' => $object->total_ttc,
302
+                '__TOTAL_HT__' => $object->total_ht,
303
+                '__TOTAL_VAT__' => $object->total_vat
304
+                );
305
+                complete_substitutions_array($substitutionarray, $langs, $object);
306
+                // Call the ODTSubstitution hook
307
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
308
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
309
+
310
+                // Line of free text
311
+                $newfreetext='';
312
+                $paramfreetext='RECEPTION_FREE_TEXT';
313
+                if (! empty($conf->global->$paramfreetext))
314
+                {
315
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
316
+                }
317
+
318
+                // Open and load template
319
+                require_once ODTPHP_PATH.'odf.php';
320
+                try {
321
+                    $odfHandler = new odf(
322
+                        $srctemplatepath,
323
+                        array(
324
+                        'PATH_TO_TMP'	  => $conf->reception->dir_temp,
325
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
326
+                        'DELIMITER_LEFT'  => '{',
327
+                        'DELIMITER_RIGHT' => '}'
328
+                        )
329
+                    );
330
+                }
331
+                catch(Exception $e)
332
+                {
333
+                    $this->error=$e->getMessage();
334
+                    return -1;
335
+                }
336
+                // After construction $odfHandler->contentXml contains content and
337
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
338
+                // [!-- BEGIN lines --]*[!-- END lines --]
339
+                //print html_entity_decode($odfHandler->__toString());
340
+                //print exit;
341
+
342
+
343
+                // Make substitutions into odt of freetext
344
+                try {
345
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
346
+                }
347
+                catch(OdfException $e)
348
+                {
349
+                }
350
+
351
+                // Make substitutions into odt of user info
352
+                $tmparray=$this->get_substitutionarray_user($user,$outputlangs);
353
+                //var_dump($tmparray); exit;
354
+                foreach($tmparray as $key=>$value)
355
+                {
356
+                    try {
357
+                        if (preg_match('/logo$/',$key)) // Image
358
+                        {
359
+                            //var_dump($value);exit;
360
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
361
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
362
+                        }
363
+                        else    // Text
364
+                        {
365
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
366
+                        }
367
+                    }
368
+                    catch(OdfException $e)
369
+                    {
370
+                    }
371
+                }
372
+                // Make substitutions into odt of mysoc
373
+                $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
374
+                //var_dump($tmparray); exit;
375
+                foreach($tmparray as $key=>$value)
376
+                {
377
+                    try {
378
+                        if (preg_match('/logo$/',$key))	// Image
379
+                        {
380
+                            //var_dump($value);exit;
381
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
382
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
+                        }
384
+                        else	// Text
385
+                        {
386
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
387
+                        }
388
+                    }
389
+                    catch(OdfException $e)
390
+                    {
391
+                    }
392
+                }
393
+                // Make substitutions into odt of thirdparty
394
+                $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
395
+                foreach($tmparray as $key=>$value)
396
+                {
397
+                    try {
398
+                        if (preg_match('/logo$/',$key))	// Image
399
+                        {
400
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
401
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
402
+                        }
403
+                        else	// Text
404
+                        {
405
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
406
+                        }
407
+                    }
408
+                    catch(OdfException $e)
409
+                    {
410
+                    }
411
+                }
412
+                // Replace tags of object + external modules
413
+                $tmparray=$this->get_substitutionarray_reception($object,$outputlangs);
414
+                complete_substitutions_array($tmparray, $outputlangs, $object);
415
+                // Call the ODTSubstitution hook
416
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
417
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
+                foreach($tmparray as $key=>$value)
419
+                {
420
+                    try {
421
+                        if (preg_match('/logo$/',$key)) // Image
422
+                        {
423
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
424
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
+                        }
426
+                        else    // Text
427
+                        {
428
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
429
+                        }
430
+                    }
431
+                    catch(OdfException $e)
432
+                    {
433
+                    }
434
+                }
435
+                // Replace tags of lines
436
+                try
437
+                {
438
+                    $listlines = $odfHandler->setSegment('lines');
439
+                    foreach ($object->lines as $line)
440
+                    {
441
+                        $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs);
442
+                        complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
443
+                        // Call the ODTSubstitutionLine hook
444
+                        $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
445
+                        $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
+                        foreach($tmparray as $key => $val)
447
+                        {
448
+                            try
449
+                            {
450
+                                $listlines->setVars($key, $val, true, 'UTF-8');
451
+                            }
452
+                            catch(OdfException $e)
453
+                            {
454
+                            }
455
+                            catch(SegmentException $e)
456
+                            {
457
+                            }
458
+                        }
459
+                        $listlines->merge();
460
+                    }
461
+                    $odfHandler->mergeSegment($listlines);
462
+                }
463
+                catch(OdfException $e)
464
+                {
465
+                    $this->error=$e->getMessage();
466
+                    dol_syslog($this->error, LOG_WARNING);
467
+                    return -1;
468
+                }
469
+
470
+                // Replace labels translated
471
+                $tmparray=$outputlangs->get_translations_for_substitutions();
472
+                foreach($tmparray as $key=>$value)
473
+                {
474
+                    try {
475
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
476
+                    }
477
+                    catch(OdfException $e)
478
+                    {
479
+                    }
480
+                }
481
+
482
+                // Call the beforeODTSave hook
483
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
484
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
485
+
486
+                // Write new file
487
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
488
+                    try {
489
+                        $odfHandler->exportAsAttachedPDF($file);
490
+                    }catch (Exception $e){
491
+                        $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
+                        return -1;
501
+                    }
502
+                }
503
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
504
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
+
506
+                if (! empty($conf->global->MAIN_UMASK))
507
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
508
+
509
+                $odfHandler=null;	// Destroy object
510
+
511
+                return 1;   // Success
512
+            }
513
+            else
514
+            {
515
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
516
+                return -1;
517
+            }
518
+        }
519
+
520
+        return -1;
521
+    }
522 522
 }
523 523
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class doc_generic_reception_odt extends ModelePdfReception
37 37
 {
38
-	var $emetteur;	// Objet societe qui emet
38
+	var $emetteur; // Objet societe qui emet
39 39
 
40
-	var $phpmin = array(5,2,0);	// Minimum version of PHP required by module
40
+	var $phpmin = array(5, 2, 0); // Minimum version of PHP required by module
41 41
 	var $version = 'dolibarr';
42 42
 
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	function __construct($db)
50 50
 	{
51
-		global $conf,$langs,$mysoc;
51
+		global $conf, $langs, $mysoc;
52 52
 
53 53
 		$langs->load("main");
54 54
 		$langs->load("companies");
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
 		$this->db = $db;
57 57
 		$this->name = "ODT templates";
58 58
 		$this->description = $langs->trans("DocumentModelOdt");
59
-		$this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
59
+		$this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
60 60
 
61 61
 		// Dimension page pour format A4
62 62
 		$this->type = 'odt';
63 63
 		$this->page_largeur = 0;
64 64
 		$this->page_hauteur = 0;
65
-		$this->format = array($this->page_largeur,$this->page_hauteur);
66
-		$this->marge_gauche=0;
67
-		$this->marge_droite=0;
68
-		$this->marge_haute=0;
69
-		$this->marge_basse=0;
70
-
71
-		$this->option_logo = 1;                    // Affiche logo
72
-		$this->option_tva = 0;                     // Gere option tva RECEPTION_TVAOPTION
73
-		$this->option_modereg = 0;                 // Affiche mode reglement
74
-		$this->option_condreg = 0;                 // Affiche conditions reglement
75
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
76
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
77
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
78
-		$this->option_credit_note = 0;             // Support credit notes
79
-		$this->option_freetext = 1;				   // Support add of a personalised text
80
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
65
+		$this->format = array($this->page_largeur, $this->page_hauteur);
66
+		$this->marge_gauche = 0;
67
+		$this->marge_droite = 0;
68
+		$this->marge_haute = 0;
69
+		$this->marge_basse = 0;
70
+
71
+		$this->option_logo = 1; // Affiche logo
72
+		$this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION
73
+		$this->option_modereg = 0; // Affiche mode reglement
74
+		$this->option_condreg = 0; // Affiche conditions reglement
75
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
76
+		$this->option_multilang = 1; // Dispo en plusieurs langues
77
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
78
+		$this->option_credit_note = 0; // Support credit notes
79
+		$this->option_freetext = 1; // Support add of a personalised text
80
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
81 81
 
82 82
 		// Recupere emetteur
83
-		$this->emetteur=$mysoc;
84
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
83
+		$this->emetteur = $mysoc;
84
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
85 85
 	}
86 86
 
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	function info($langs)
95 95
 	{
96
-		global $conf,$langs;
96
+		global $conf, $langs;
97 97
 
98 98
 		$langs->load("companies");
99 99
 		$langs->load("errors");
@@ -101,74 +101,74 @@  discard block
 block discarded – undo
101 101
 		$form = new Form($this->db);
102 102
 
103 103
 		$texte = $this->description.".<br>\n";
104
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
105
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
106
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
107
-		$texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">';
108
-		$texte.= '<table class="nobordernopadding" width="100%">';
104
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
105
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
106
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
107
+		$texte .= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">';
108
+		$texte .= '<table class="nobordernopadding" width="100%">';
109 109
 
110 110
 		// List of directories area
111
-		$texte.= '<tr><td>';
112
-		$texttitle=$langs->trans("ListOfDirectories");
113
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)));
114
-		$listoffiles=array();
115
-		foreach($listofdir as $key=>$tmpdir)
111
+		$texte .= '<tr><td>';
112
+		$texttitle = $langs->trans("ListOfDirectories");
113
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)));
114
+		$listoffiles = array();
115
+		foreach ($listofdir as $key=>$tmpdir)
116 116
 		{
117
-			$tmpdir=trim($tmpdir);
118
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
119
-			if (! $tmpdir) {
117
+			$tmpdir = trim($tmpdir);
118
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
119
+			if (!$tmpdir) {
120 120
 				unset($listofdir[$key]); continue;
121 121
 			}
122
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
122
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
123 123
 			else
124 124
 			{
125
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
126
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
125
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
126
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
127 127
 			}
128 128
 		}
129
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
129
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
130 130
 		// Add list of substitution keys
131
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
132
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
133
-
134
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
135
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
136
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
137
-		$texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
138
-		$texte.= '</textarea>';
139
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
140
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
141
-		$texte.= '<br></div></div>';
131
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
132
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
133
+
134
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
135
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
136
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
137
+		$texte .= $conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
138
+		$texte .= '</textarea>';
139
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
140
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
141
+		$texte .= '<br></div></div>';
142 142
 
143 143
 		// Scan directories
144
-		$nbofiles=count($listoffiles);
145
-		if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
144
+		$nbofiles = count($listoffiles);
145
+		if (!empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
146 146
 		{
147
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
147
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
148 148
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
149
-			$texte.=count($listoffiles);
149
+			$texte .= count($listoffiles);
150 150
 			//$texte.=$nbofiles?'</a>':'';
151
-			$texte.='</b>';
151
+			$texte .= '</b>';
152 152
 		}
153 153
 		if ($nbofiles)
154 154
 		{
155
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
156
-   			foreach($listoffiles as $file)
155
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
156
+   			foreach ($listoffiles as $file)
157 157
    			{
158
-                $texte.=$file['name'].'<br>';
158
+                $texte .= $file['name'].'<br>';
159 159
    			}
160
-   			$texte.='<div id="div_'.get_class($this).'">';
160
+   			$texte .= '<div id="div_'.get_class($this).'">';
161 161
 		}
162 162
 
163
-		$texte.= '</td>';
163
+		$texte .= '</td>';
164 164
 
165
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
166
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
167
-		$texte.= '</td>';
168
-		$texte.= '</tr>';
165
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
166
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
167
+		$texte .= '</td>';
168
+		$texte .= '</tr>';
169 169
 
170
-		$texte.= '</table>';
171
-		$texte.= '</form>';
170
+		$texte .= '</table>';
171
+		$texte .= '</form>';
172 172
 
173 173
 		return $texte;
174 174
 	}
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 	 *  @param		int			$hideref			Do not show ref
186 186
 	 *	@return		int         					1 if OK, <=0 if KO
187 187
 	 */
188
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
188
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
189 189
 	{
190 190
 		// phpcs:enable
191
-		global $user,$langs,$conf,$mysoc,$hookmanager;
191
+		global $user, $langs, $conf, $mysoc, $hookmanager;
192 192
 
193 193
 		if (empty($srctemplatepath))
194 194
 		{
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 		}
198 198
 
199 199
 		// Add odtgeneration hook
200
-		if (! is_object($hookmanager))
200
+		if (!is_object($hookmanager))
201 201
 		{
202 202
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
203
-			$hookmanager=new HookManager($this->db);
203
+			$hookmanager = new HookManager($this->db);
204 204
 		}
205 205
 		$hookmanager->initHooks(array('odtgeneration'));
206 206
 		global $action;
207 207
 
208
-		if (! is_object($outputlangs)) $outputlangs=$langs;
209
-		$sav_charset_output=$outputlangs->charset_output;
210
-		$outputlangs->charset_output='UTF-8';
208
+		if (!is_object($outputlangs)) $outputlangs = $langs;
209
+		$sav_charset_output = $outputlangs->charset_output;
210
+		$outputlangs->charset_output = 'UTF-8';
211 211
 
212 212
 		$outputlangs->load("main");
213 213
 		$outputlangs->load("dict");
@@ -217,28 +217,28 @@  discard block
 block discarded – undo
217 217
 		if ($conf->reception->dir_output."/reception")
218 218
 		{
219 219
 			// If $object is id instead of object
220
-			if (! is_object($object))
220
+			if (!is_object($object))
221 221
 			{
222 222
 				$id = $object;
223 223
 				$object = new Reception($this->db);
224
-				$result=$object->fetch($id);
224
+				$result = $object->fetch($id);
225 225
 				if ($result < 0)
226 226
 				{
227
-					dol_print_error($this->db,$object->error);
227
+					dol_print_error($this->db, $object->error);
228 228
 					return -1;
229 229
 				}
230 230
 			}
231 231
 
232 232
 			$dir = $conf->reception->dir_output."/reception";
233 233
 			$objectref = dol_sanitizeFileName($object->ref);
234
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
235
-			$file = $dir . "/" . $objectref . ".odt";
234
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
235
+			$file = $dir."/".$objectref.".odt";
236 236
 
237
-			if (! file_exists($dir))
237
+			if (!file_exists($dir))
238 238
 			{
239 239
 				if (dol_mkdir($dir) < 0)
240 240
 				{
241
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
241
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
242 242
 					return -1;
243 243
 				}
244 244
 			}
@@ -246,25 +246,25 @@  discard block
 block discarded – undo
246 246
 			if (file_exists($dir))
247 247
 			{
248 248
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
249
-				$newfile=basename($srctemplatepath);
250
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
251
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
252
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
253
-				$newfiletmp=$objectref.'_'.$newfiletmp;
249
+				$newfile = basename($srctemplatepath);
250
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
251
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
252
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
253
+				$newfiletmp = $objectref.'_'.$newfiletmp;
254 254
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
255 255
 				// Get extension (ods or odt)
256
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
257
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
256
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
257
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
258 258
 				{
259
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
260
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
261
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
259
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
260
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
261
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
262 262
 				}
263 263
 				else
264 264
 				{
265
-					$filename=$newfiletmp.'.'.$newfileformat;
265
+					$filename = $newfiletmp.'.'.$newfileformat;
266 266
 				}
267
-				$file=$dir.'/'.$filename;
267
+				$file = $dir.'/'.$filename;
268 268
 				//print "newdir=".$dir;
269 269
 				//print "newfile=".$newfile;
270 270
 				//print "file=".$file;
@@ -274,28 +274,28 @@  discard block
 block discarded – undo
274 274
 
275 275
 
276 276
 				// If BILLING contact defined on invoice, we use it
277
-				$usecontact=false;
278
-				$arrayidcontact=$object->getIdContact('external','BILLING');
277
+				$usecontact = false;
278
+				$arrayidcontact = $object->getIdContact('external', 'BILLING');
279 279
 				if (count($arrayidcontact) > 0)
280 280
 				{
281
-					$usecontact=true;
282
-					$result=$object->fetch_contact($arrayidcontact[0]);
281
+					$usecontact = true;
282
+					$result = $object->fetch_contact($arrayidcontact[0]);
283 283
 				}
284 284
 
285 285
 				// Recipient name
286
-				if (! empty($usecontact))
286
+				if (!empty($usecontact))
287 287
 				{
288 288
 					// On peut utiliser le nom de la societe du contact
289
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
289
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
290 290
 					else $socobject = $object->thirdparty;
291 291
 				}
292 292
 				else
293 293
 				{
294
-					$socobject=$object->thirdparty;
294
+					$socobject = $object->thirdparty;
295 295
 				}
296 296
 
297 297
 				// Make substitution
298
-				$substitutionarray=array(
298
+				$substitutionarray = array(
299 299
 				'__FROM_NAME__' => $this->emetteur->name,
300 300
 				'__FROM_EMAIL__' => $this->emetteur->email,
301 301
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -304,15 +304,15 @@  discard block
 block discarded – undo
304 304
 				);
305 305
 				complete_substitutions_array($substitutionarray, $langs, $object);
306 306
 				// Call the ODTSubstitution hook
307
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
308
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
307
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
308
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
309 309
 
310 310
 				// Line of free text
311
-				$newfreetext='';
312
-				$paramfreetext='RECEPTION_FREE_TEXT';
313
-				if (! empty($conf->global->$paramfreetext))
311
+				$newfreetext = '';
312
+				$paramfreetext = 'RECEPTION_FREE_TEXT';
313
+				if (!empty($conf->global->$paramfreetext))
314 314
 				{
315
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
315
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
316 316
 				}
317 317
 
318 318
 				// Open and load template
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 						$srctemplatepath,
323 323
 						array(
324 324
 						'PATH_TO_TMP'	  => $conf->reception->dir_temp,
325
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
325
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
326 326
 						'DELIMITER_LEFT'  => '{',
327 327
 						'DELIMITER_RIGHT' => '}'
328 328
 						)
329 329
 					);
330 330
 				}
331
-				catch(Exception $e)
331
+				catch (Exception $e)
332 332
 				{
333
-					$this->error=$e->getMessage();
333
+					$this->error = $e->getMessage();
334 334
 					return -1;
335 335
 				}
336 336
 				// After construction $odfHandler->contentXml contains content and
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 				try {
345 345
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
346 346
 				}
347
-				catch(OdfException $e)
347
+				catch (OdfException $e)
348 348
 				{
349 349
 				}
350 350
 
351 351
 				// Make substitutions into odt of user info
352
-				$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
352
+				$tmparray = $this->get_substitutionarray_user($user, $outputlangs);
353 353
 				//var_dump($tmparray); exit;
354
-				foreach($tmparray as $key=>$value)
354
+				foreach ($tmparray as $key=>$value)
355 355
 				{
356 356
 					try {
357
-						if (preg_match('/logo$/',$key)) // Image
357
+						if (preg_match('/logo$/', $key)) // Image
358 358
 						{
359 359
 							//var_dump($value);exit;
360 360
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
@@ -365,17 +365,17 @@  discard block
 block discarded – undo
365 365
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
366 366
 						}
367 367
 					}
368
-					catch(OdfException $e)
368
+					catch (OdfException $e)
369 369
 					{
370 370
 					}
371 371
 				}
372 372
 				// Make substitutions into odt of mysoc
373
-				$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
373
+				$tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
374 374
 				//var_dump($tmparray); exit;
375
-				foreach($tmparray as $key=>$value)
375
+				foreach ($tmparray as $key=>$value)
376 376
 				{
377 377
 					try {
378
-						if (preg_match('/logo$/',$key))	// Image
378
+						if (preg_match('/logo$/', $key))	// Image
379 379
 						{
380 380
 							//var_dump($value);exit;
381 381
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
387 387
 						}
388 388
 					}
389
-					catch(OdfException $e)
389
+					catch (OdfException $e)
390 390
 					{
391 391
 					}
392 392
 				}
393 393
 				// Make substitutions into odt of thirdparty
394
-				$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
395
-				foreach($tmparray as $key=>$value)
394
+				$tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
395
+				foreach ($tmparray as $key=>$value)
396 396
 				{
397 397
 					try {
398
-						if (preg_match('/logo$/',$key))	// Image
398
+						if (preg_match('/logo$/', $key))	// Image
399 399
 						{
400 400
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
401 401
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -405,20 +405,20 @@  discard block
 block discarded – undo
405 405
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
406 406
 						}
407 407
 					}
408
-					catch(OdfException $e)
408
+					catch (OdfException $e)
409 409
 					{
410 410
 					}
411 411
 				}
412 412
 				// Replace tags of object + external modules
413
-				$tmparray=$this->get_substitutionarray_reception($object,$outputlangs);
413
+				$tmparray = $this->get_substitutionarray_reception($object, $outputlangs);
414 414
 				complete_substitutions_array($tmparray, $outputlangs, $object);
415 415
 				// Call the ODTSubstitution hook
416
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
417
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
-				foreach($tmparray as $key=>$value)
416
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
417
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
418
+				foreach ($tmparray as $key=>$value)
419 419
 				{
420 420
 					try {
421
-						if (preg_match('/logo$/',$key)) // Image
421
+						if (preg_match('/logo$/', $key)) // Image
422 422
 						{
423 423
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
424 424
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
429 429
 						}
430 430
 					}
431
-					catch(OdfException $e)
431
+					catch (OdfException $e)
432 432
 					{
433 433
 					}
434 434
 				}
@@ -438,21 +438,21 @@  discard block
 block discarded – undo
438 438
 					$listlines = $odfHandler->setSegment('lines');
439 439
 					foreach ($object->lines as $line)
440 440
 					{
441
-						$tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs);
441
+						$tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs);
442 442
 						complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
443 443
 						// Call the ODTSubstitutionLine hook
444
-						$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
445
-						$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
-						foreach($tmparray as $key => $val)
444
+						$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
445
+						$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
446
+						foreach ($tmparray as $key => $val)
447 447
 						{
448 448
 							try
449 449
 							{
450 450
 								$listlines->setVars($key, $val, true, 'UTF-8');
451 451
 							}
452
-							catch(OdfException $e)
452
+							catch (OdfException $e)
453 453
 							{
454 454
 							}
455
-							catch(SegmentException $e)
455
+							catch (SegmentException $e)
456 456
 							{
457 457
 							}
458 458
 						}
@@ -460,59 +460,59 @@  discard block
 block discarded – undo
460 460
 					}
461 461
 					$odfHandler->mergeSegment($listlines);
462 462
 				}
463
-				catch(OdfException $e)
463
+				catch (OdfException $e)
464 464
 				{
465
-					$this->error=$e->getMessage();
465
+					$this->error = $e->getMessage();
466 466
 					dol_syslog($this->error, LOG_WARNING);
467 467
 					return -1;
468 468
 				}
469 469
 
470 470
 				// Replace labels translated
471
-				$tmparray=$outputlangs->get_translations_for_substitutions();
472
-				foreach($tmparray as $key=>$value)
471
+				$tmparray = $outputlangs->get_translations_for_substitutions();
472
+				foreach ($tmparray as $key=>$value)
473 473
 				{
474 474
 					try {
475 475
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
476 476
 					}
477
-					catch(OdfException $e)
477
+					catch (OdfException $e)
478 478
 					{
479 479
 					}
480 480
 				}
481 481
 
482 482
 				// Call the beforeODTSave hook
483
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
484
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
483
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
484
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
485 485
 
486 486
 				// Write new file
487 487
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
488 488
 					try {
489 489
 						$odfHandler->exportAsAttachedPDF($file);
490
-					}catch (Exception $e){
491
-						$this->error=$e->getMessage();
490
+					} catch (Exception $e) {
491
+						$this->error = $e->getMessage();
492 492
 						return -1;
493 493
 					}
494 494
 				}
495 495
 				else {
496 496
 					try {
497 497
 					$odfHandler->saveToDisk($file);
498
-					}catch (Exception $e){
499
-						$this->error=$e->getMessage();
498
+					} catch (Exception $e) {
499
+						$this->error = $e->getMessage();
500 500
 						return -1;
501 501
 					}
502 502
 				}
503
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
504
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
503
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
504
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
505 505
 
506
-				if (! empty($conf->global->MAIN_UMASK))
506
+				if (!empty($conf->global->MAIN_UMASK))
507 507
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
508 508
 
509
-				$odfHandler=null;	// Destroy object
509
+				$odfHandler = null; // Destroy object
510 510
 
511
-				return 1;   // Success
511
+				return 1; // Success
512 512
 			}
513 513
 			else
514 514
 			{
515
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
515
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
516 516
 				return -1;
517 517
 			}
518 518
 		}
Please login to merge, or discard this patch.
Braces   +67 added lines, -57 removed lines patch added patch discarded remove patch
@@ -81,7 +81,10 @@  discard block
 block discarded – undo
81 81
 
82 82
 		// Recupere emetteur
83 83
 		$this->emetteur=$mysoc;
84
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
84
+		if (! $this->emetteur->country_code) {
85
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
86
+		}
87
+		// By default if not defined
85 88
 	}
86 89
 
87 90
 
@@ -119,11 +122,14 @@  discard block
 block discarded – undo
119 122
 			if (! $tmpdir) {
120 123
 				unset($listofdir[$key]); continue;
121 124
 			}
122
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
123
-			else
125
+			if (! is_dir($tmpdir)) {
126
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
127
+			} else
124 128
 			{
125 129
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
126
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
130
+				if (count($tmpfiles)) {
131
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
132
+				}
127 133
 			}
128 134
 		}
129 135
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -205,7 +211,9 @@  discard block
 block discarded – undo
205 211
 		$hookmanager->initHooks(array('odtgeneration'));
206 212
 		global $action;
207 213
 
208
-		if (! is_object($outputlangs)) $outputlangs=$langs;
214
+		if (! is_object($outputlangs)) {
215
+		    $outputlangs=$langs;
216
+		}
209 217
 		$sav_charset_output=$outputlangs->charset_output;
210 218
 		$outputlangs->charset_output='UTF-8';
211 219
 
@@ -231,7 +239,9 @@  discard block
 block discarded – undo
231 239
 
232 240
 			$dir = $conf->reception->dir_output."/reception";
233 241
 			$objectref = dol_sanitizeFileName($object->ref);
234
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
242
+			if (! preg_match('/specimen/i',$objectref)) {
243
+			    $dir.= "/" . $objectref;
244
+			}
235 245
 			$file = $dir . "/" . $objectref . ".odt";
236 246
 
237 247
 			if (! file_exists($dir))
@@ -257,10 +267,11 @@  discard block
 block discarded – undo
257 267
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
258 268
 				{
259 269
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
260
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
270
+				    if ($format == '1') {
271
+				        $format='%Y%m%d%H%M%S';
272
+				    }
261 273
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
262
-				}
263
-				else
274
+				} else
264 275
 				{
265 276
 					$filename=$newfiletmp.'.'.$newfileformat;
266 277
 				}
@@ -286,10 +297,12 @@  discard block
 block discarded – undo
286 297
 				if (! empty($usecontact))
287 298
 				{
288 299
 					// On peut utiliser le nom de la societe du contact
289
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
290
-					else $socobject = $object->thirdparty;
291
-				}
292
-				else
300
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
301
+					    $socobject = $object->contact;
302
+					} else {
303
+					    $socobject = $object->thirdparty;
304
+					}
305
+				} else
293 306
 				{
294 307
 					$socobject=$object->thirdparty;
295 308
 				}
@@ -327,8 +340,7 @@  discard block
 block discarded – undo
327 340
 						'DELIMITER_RIGHT' => '}'
328 341
 						)
329 342
 					);
330
-				}
331
-				catch(Exception $e)
343
+				} catch(Exception $e)
332 344
 				{
333 345
 					$this->error=$e->getMessage();
334 346
 					return -1;
@@ -343,8 +355,7 @@  discard block
 block discarded – undo
343 355
 				// Make substitutions into odt of freetext
344 356
 				try {
345 357
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
346
-				}
347
-				catch(OdfException $e)
358
+				} catch(OdfException $e)
348 359
 				{
349 360
 				}
350 361
 
@@ -354,18 +365,19 @@  discard block
 block discarded – undo
354 365
 				foreach($tmparray as $key=>$value)
355 366
 				{
356 367
 					try {
357
-						if (preg_match('/logo$/',$key)) // Image
368
+						if (preg_match('/logo$/',$key)) {
369
+						    // Image
358 370
 						{
359 371
 							//var_dump($value);exit;
360 372
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
361
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
362
-						}
363
-						else    // Text
373
+						} else {
374
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
375
+							}
376
+						} else    // Text
364 377
 						{
365 378
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
366 379
 						}
367
-					}
368
-					catch(OdfException $e)
380
+					} catch(OdfException $e)
369 381
 					{
370 382
 					}
371 383
 				}
@@ -375,18 +387,19 @@  discard block
 block discarded – undo
375 387
 				foreach($tmparray as $key=>$value)
376 388
 				{
377 389
 					try {
378
-						if (preg_match('/logo$/',$key))	// Image
390
+						if (preg_match('/logo$/',$key)) {
391
+						    // Image
379 392
 						{
380 393
 							//var_dump($value);exit;
381 394
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
382
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
-						}
384
-						else	// Text
395
+						} else {
396
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
397
+							}
398
+						} else	// Text
385 399
 						{
386 400
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
387 401
 						}
388
-					}
389
-					catch(OdfException $e)
402
+					} catch(OdfException $e)
390 403
 					{
391 404
 					}
392 405
 				}
@@ -395,17 +408,18 @@  discard block
 block discarded – undo
395 408
 				foreach($tmparray as $key=>$value)
396 409
 				{
397 410
 					try {
398
-						if (preg_match('/logo$/',$key))	// Image
411
+						if (preg_match('/logo$/',$key)) {
412
+						    // Image
399 413
 						{
400 414
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
401
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
402
-						}
403
-						else	// Text
415
+						} else {
416
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
417
+							}
418
+						} else	// Text
404 419
 						{
405 420
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
406 421
 						}
407
-					}
408
-					catch(OdfException $e)
422
+					} catch(OdfException $e)
409 423
 					{
410 424
 					}
411 425
 				}
@@ -418,17 +432,18 @@  discard block
 block discarded – undo
418 432
 				foreach($tmparray as $key=>$value)
419 433
 				{
420 434
 					try {
421
-						if (preg_match('/logo$/',$key)) // Image
435
+						if (preg_match('/logo$/',$key)) {
436
+						    // Image
422 437
 						{
423 438
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
424
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
-						}
426
-						else    // Text
439
+						} else {
440
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
441
+							}
442
+						} else    // Text
427 443
 						{
428 444
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
429 445
 						}
430
-					}
431
-					catch(OdfException $e)
446
+					} catch(OdfException $e)
432 447
 					{
433 448
 					}
434 449
 				}
@@ -448,19 +463,16 @@  discard block
 block discarded – undo
448 463
 							try
449 464
 							{
450 465
 								$listlines->setVars($key, $val, true, 'UTF-8');
451
-							}
452
-							catch(OdfException $e)
466
+							} catch(OdfException $e)
453 467
 							{
454
-							}
455
-							catch(SegmentException $e)
468
+							} catch(SegmentException $e)
456 469
 							{
457 470
 							}
458 471
 						}
459 472
 						$listlines->merge();
460 473
 					}
461 474
 					$odfHandler->mergeSegment($listlines);
462
-				}
463
-				catch(OdfException $e)
475
+				} catch(OdfException $e)
464 476
 				{
465 477
 					$this->error=$e->getMessage();
466 478
 					dol_syslog($this->error, LOG_WARNING);
@@ -473,8 +485,7 @@  discard block
 block discarded – undo
473 485
 				{
474 486
 					try {
475 487
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
476
-					}
477
-					catch(OdfException $e)
488
+					} catch(OdfException $e)
478 489
 					{
479 490
 					}
480 491
 				}
@@ -487,15 +498,14 @@  discard block
 block discarded – undo
487 498
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
488 499
 					try {
489 500
 						$odfHandler->exportAsAttachedPDF($file);
490
-					}catch (Exception $e){
501
+					} catch (Exception $e){
491 502
 						$this->error=$e->getMessage();
492 503
 						return -1;
493 504
 					}
494
-				}
495
-				else {
505
+				} else {
496 506
 					try {
497 507
 					$odfHandler->saveToDisk($file);
498
-					}catch (Exception $e){
508
+					} catch (Exception $e){
499 509
 						$this->error=$e->getMessage();
500 510
 						return -1;
501 511
 					}
@@ -503,14 +513,14 @@  discard block
 block discarded – undo
503 513
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
504 514
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505 515
 
506
-				if (! empty($conf->global->MAIN_UMASK))
507
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
516
+				if (! empty($conf->global->MAIN_UMASK)) {
517
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
518
+				}
508 519
 
509 520
 				$odfHandler=null;	// Destroy object
510 521
 
511 522
 				return 1;   // Success
512
-			}
513
-			else
523
+			} else
514 524
 			{
515 525
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
516 526
 				return -1;
Please login to merge, or discard this patch.