Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/modules/modExpedition.class.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 		// Data directories to create when module is enabled
65 65
 		$this->dirs = array("/expedition/temp",
66 66
 							"/expedition/sending",
67
-		                    "/expedition/sending/temp",
68
-		                    "/expedition/receipt",
69
-		                    "/expedition/receipt/temp",
67
+							"/expedition/sending/temp",
68
+							"/expedition/receipt",
69
+							"/expedition/receipt/temp",
70 70
 							"/doctemplates/shipment",
71 71
 							"/doctemplates/delivery"
72
-		                    );
72
+							);
73 73
 
74 74
 		// Config pages
75 75
 		$this->config_page_url = array("confexped.php");
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
170 170
 		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
171 171
 		$this->rights[$r][4] = 'shipping_advance';
172
-        $this->rights[$r][5] = 'send';
172
+		$this->rights[$r][5] = 'send';
173 173
 
174 174
 		$r++;
175 175
 		$this->rights[$r][0] = 106;
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 		$this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
252 252
 		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
253 253
 		{
254
-		    $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
255
-		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
254
+			$keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
255
+			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
256 256
 		}
257 257
 		$keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra';
258 258
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
288 288
 	 *		It also creates data directories
289 289
 	 *
290
-     *      @param      string	$options    Options when enabling module ('', 'noboxes')
290
+	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
291 291
 	 *      @return     int             	1 if OK, 0 if KO
292 292
 	 */
293 293
 	function init($options='')
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  *	\brief      Fichier de description et activation du module Expedition
28 28
  */
29 29
 
30
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
30
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
31 31
 
32 32
 
33 33
 /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->family = "crm";
52 52
 		$this->module_position = 40;
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 expeditions";
56 56
 
57 57
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 		$this->depends = array("modCommande");
79 79
 		$this->requiredby = array();
80 80
 		$this->conflictwith = array();
81
-		$this->langfiles = array('deliveries','sendings');
81
+		$this->langfiles = array('deliveries', 'sendings');
82 82
 
83 83
 		// Constants
84 84
 		$this->const = array();
85
-		$r=0;
85
+		$r = 0;
86 86
 
87 87
 		$this->const[$r][0] = "EXPEDITION_ADDON_PDF";
88 88
 		$this->const[$r][1] = "chaine";
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		// Permissions
140 140
 		$this->rights = array();
141 141
 		$this->rights_class = 'expedition';
142
-		$r=0;
142
+		$r = 0;
143 143
 
144 144
 		$r++;
145 145
 		$this->rights[$r][0] = 101;
@@ -221,64 +221,64 @@  discard block
 block discarded – undo
221 221
 
222 222
 		// Menus
223 223
 		//-------
224
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
224
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
225 225
 		
226 226
 		
227 227
 		// Exports
228 228
 		//--------
229
-		$r=0;
229
+		$r = 0;
230 230
 
231 231
 		include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
232
-		$shipment=new Commande($this->db);
233
-		$contact_arrays=$shipment->liste_type_contact('external','',0,0,'');
234
-		if (is_array($contact_arrays) && count($contact_arrays)>0){
235
-			$idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,'')));
232
+		$shipment = new Commande($this->db);
233
+		$contact_arrays = $shipment->liste_type_contact('external', '', 0, 0, '');
234
+		if (is_array($contact_arrays) && count($contact_arrays) > 0) {
235
+			$idcontacts = join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, '')));
236 236
 		} else {
237
-			$idcontacts=0;
237
+			$idcontacts = 0;
238 238
 		}
239 239
 
240 240
 
241 241
 		$r++;
242
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
243
-		$this->export_label[$r]='Shipments';	// Translation key (used only if key ExportDataset_xxx_z not found)
244
-		$this->export_permission[$r]=array(array("expedition","shipment","export"));
245
-		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits');
246
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
242
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
243
+		$this->export_label[$r] = 'Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found)
244
+		$this->export_permission[$r] = array(array("expedition", "shipment", "export"));
245
+		$this->export_fields_array[$r] = array('s.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth", 'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", 'ed.rowid'=>'LineId', 'cd.description'=>'Description', 'ed.qty'=>"Qty", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.weight'=>'ProductWeight', 'p.weight_units'=>'WeightUnits', 'p.volume'=>'ProductVolume', 'p.volume_units'=>'VolumeUnits');
246
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');
247 247
 		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
248
-		$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text');
249
-		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment",'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment",'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment",'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product');
250
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
251
-		$this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
252
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
248
+		$this->export_TypeFields_array[$r] = array('s.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date", 'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'ed.qty'=>"Numeric", 'd.nom'=>'Text');
249
+		$this->export_entities_array[$r] = array('s.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 'c.rowid'=>"shipment", 'c.ref'=>"shipment", 'c.ref_customer'=>"shipment", 'c.fk_soc'=>"shipment", 'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment", 'c.size'=>'shipment', 'c.size_units'=>'shipment', 'c.weight'=>"shipment", 'c.weight_units'=>'shipment', 'c.fk_statut'=>"shipment", 'c.note_public'=>"shipment", 'ed.rowid'=>'shipment_line', 'cd.description'=>'shipment_line', 'ed.qty'=>"shipment_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product');
250
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');
251
+		$this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
252
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
253 253
 		{
254
-		    $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
254
+		    $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3';
255 255
 		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
256 256
 		}
257
-		$keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra';
257
+		$keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra';
258 258
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
259
-		$keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2';
259
+		$keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2';
260 260
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
261 261
 
262
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
263
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expedition as c';
264
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
265
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
266
-		if(!$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';
267
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
268
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
269
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed';
270
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
271
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
272
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
273
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
262
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
263
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'expedition as c';
264
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
265
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
266
+		if (!$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';
267
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
268
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
269
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expeditiondet as ed';
270
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
271
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd';
272
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
273
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
274 274
 		{
275
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
276
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
277
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
275
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
276
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
277
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
278 278
 		}
279
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
280
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')';
281
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
279
+		$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
280
+		$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')';
281
+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
282 282
 	}
283 283
 
284 284
 
@@ -290,27 +290,27 @@  discard block
 block discarded – undo
290 290
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
291 291
 	 *      @return     int             	1 if OK, 0 if KO
292 292
 	 */
293
-	function init($options='')
293
+	function init($options = '')
294 294
 	{
295
-		global $conf,$langs;
295
+		global $conf, $langs;
296 296
 
297 297
 		// Permissions
298 298
 		$this->remove($options);
299 299
 
300 300
 		//ODT template
301
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt';
302
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/shipment';
303
-		$dest=$dirodt.'/template_shipment.odt';
301
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt';
302
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/shipment';
303
+		$dest = $dirodt.'/template_shipment.odt';
304 304
 
305
-		if (file_exists($src) && ! file_exists($dest))
305
+		if (file_exists($src) && !file_exists($dest))
306 306
 		{
307 307
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
308 308
 			dol_mkdir($dirodt);
309
-			$result=dol_copy($src,$dest,0,0);
309
+			$result = dol_copy($src, $dest, 0, 0);
310 310
 			if ($result < 0)
311 311
 			{
312 312
 				$langs->load("errors");
313
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
313
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
314 314
 				return 0;
315 315
 			}
316 316
 		}
@@ -324,6 +324,6 @@  discard block
 block discarded – undo
324 324
 			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".$conf->entity.")",
325 325
 		);
326 326
 
327
-		return $this->_init($sql,$options);
327
+		return $this->_init($sql, $options);
328 328
 	}
329 329
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -243,11 +243,15 @@  discard block
 block discarded – undo
243 243
 		$this->export_label[$r]='Shipments';	// Translation key (used only if key ExportDataset_xxx_z not found)
244 244
 		$this->export_permission[$r]=array(array("expedition","shipment","export"));
245 245
 		$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits');
246
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
246
+		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
247
+			$this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
248
+		}
247 249
 		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
248 250
 		$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text');
249 251
 		$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment",'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment",'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment",'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product');
250
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
252
+		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
253
+			$this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
254
+		}
251 255
 		$this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
252 256
 		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
253 257
 		{
@@ -263,7 +267,9 @@  discard block
 block discarded – undo
263 267
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expedition as c';
264 268
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
265 269
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
266
-		if(!$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';
270
+		if(!$user->rights->societe->client->voir) {
271
+			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
272
+		}
267 273
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
268 274
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
269 275
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed';
@@ -278,7 +284,9 @@  discard block
 block discarded – undo
278 284
 		}
279 285
 		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
280 286
 		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')';
281
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
287
+		if(!$user->rights->societe->client->voir) {
288
+			$this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
289
+		}
282 290
 	}
283 291
 
284 292
 
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/mod_expedition_safor.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@
 block discarded – undo
39 39
 	 *
40 40
 	 *	@return     string      text description
41 41
 	 */
42
-    function info()
43
-    {
44
-    	global $langs;
45
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
46
-    }
42
+	function info()
43
+	{
44
+		global $langs;
45
+	  	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
46
+	}
47 47
 
48 48
 
49 49
 	/**
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,10 +111,12 @@  discard block
 block discarded – undo
111 111
 		if ($resql)
112 112
 		{
113 113
 			$obj = $db->fetch_object($resql);
114
-			if ($obj) $max = intval($obj->max);
115
-			else $max=0;
116
-		}
117
-		else
114
+			if ($obj) {
115
+				$max = intval($obj->max);
116
+			} else {
117
+				$max=0;
118
+			}
119
+		} else
118 120
 		{
119 121
 			dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
120 122
 			return -1;
@@ -123,8 +125,13 @@  discard block
 block discarded – undo
123 125
 		$date=time();
124 126
 		$yymm = strftime("%y%m",$date);
125 127
 
126
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
127
-		else $num = sprintf("%04s",$max+1);
128
+		if ($max >= (pow(10, 4) - 1)) {
129
+			$num=$max+1;
130
+		}
131
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
132
+		else {
133
+			$num = sprintf("%04s",$max+1);
134
+		}
128 135
 
129 136
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
130 137
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
  *  \ingroup    expedition
22 22
  *  \brief      File of class to manage shipments numbering rules Safor
23 23
  */
24
-require_once DOL_DOCUMENT_ROOT .'/core/modules/expedition/modules_expedition.php';
24
+require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
25 25
 
26 26
 /**
27 27
  *	Class to manage expedition numbering rules Safor
28 28
  */
29 29
 class mod_expedition_safor extends ModelNumRefExpedition
30 30
 {
31
-	var $version='dolibarr';
32
-	var $prefix='SH';
33
-	var $error='';
34
-	var $nom='Safor';
31
+	var $version = 'dolibarr';
32
+	var $prefix = 'SH';
33
+	var $error = '';
34
+	var $nom = 'Safor';
35 35
 
36 36
 
37 37
 	/**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     function info()
43 43
     {
44 44
     	global $langs;
45
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
45
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
46 46
     }
47 47
 
48 48
 
@@ -64,26 +64,26 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	function canBeActivated()
66 66
 	{
67
-		global $conf,$langs,$db;
67
+		global $conf, $langs, $db;
68 68
 
69
-		$coyymm=''; $max='';
69
+		$coyymm = ''; $max = '';
70 70
 
71
-		$posindice=8;
71
+		$posindice = 8;
72 72
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
73
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
74
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
75
-		$sql.= " AND entity = ".$conf->entity;
73
+		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
74
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
75
+		$sql .= " AND entity = ".$conf->entity;
76 76
 
77
-		$resql=$db->query($sql);
77
+		$resql = $db->query($sql);
78 78
 		if ($resql)
79 79
 		{
80 80
 			$row = $db->fetch_row($resql);
81
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
81
+			if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
82 82
 		}
83
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
83
+		if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
84 84
 		{
85 85
 			$langs->load("errors");
86
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
86
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
87 87
 			return false;
88 88
 		}
89 89
 
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 	 *	@param	Object		$shipment	Shipment object
98 98
 	 *	@return string      			Value if OK, 0 if KO
99 99
 	 */
100
-	function getNextValue($objsoc,$shipment)
100
+	function getNextValue($objsoc, $shipment)
101 101
 	{
102
-		global $db,$conf;
102
+		global $db, $conf;
103 103
 
104
-		$posindice=8;
104
+		$posindice = 8;
105 105
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
106
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
107
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
108
-		$sql.= " AND entity = ".$conf->entity;
106
+		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
107
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
108
+		$sql .= " AND entity = ".$conf->entity;
109 109
 
110
-		$resql=$db->query($sql);
110
+		$resql = $db->query($sql);
111 111
 		if ($resql)
112 112
 		{
113 113
 			$obj = $db->fetch_object($resql);
114 114
 			if ($obj) $max = intval($obj->max);
115
-			else $max=0;
115
+			else $max = 0;
116 116
 		}
117 117
 		else
118 118
 		{
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			return -1;
121 121
 		}
122 122
 
123
-		$date=time();
124
-		$yymm = strftime("%y%m",$date);
123
+		$date = time();
124
+		$yymm = strftime("%y%m", $date);
125 125
 
126
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
127
-		else $num = sprintf("%04s",$max+1);
126
+		if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
127
+		else $num = sprintf("%04s", $max + 1);
128 128
 
129 129
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
130 130
 		return $this->prefix.$yymm."-".$num;
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 *	@param	Object		$objforref	Shipment object
138 138
 	 *	@return string      			Next free value
139 139
 	 */
140
-	function expedition_get_num($objsoc,$objforref)
140
+	function expedition_get_num($objsoc, $objforref)
141 141
 	{
142
-		return $this->getNextValue($objsoc,$objforref);
142
+		return $this->getNextValue($objsoc, $objforref);
143 143
 	}
144 144
 
145 145
 }
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/modules_expedition.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePdfExpedition extends CommonDocGenerator
38 38
 {
39
-    var $error='';
39
+	var $error='';
40 40
 
41 41
 
42 42
 	/**
43 43
 	 *  Return list of active generation modules
44 44
 	 *
45
-     *  @param	DoliDB	$db     			Database handler
46
-     *  @param  integer	$maxfilenamelength  Max length of value to show
47
-     *  @return	array						List of templates
45
+	 *  @param	DoliDB	$db     			Database handler
46
+	 *  @param  integer	$maxfilenamelength  Max length of value to show
47
+	 *  @return	array						List of templates
48 48
 	 */
49 49
 	static function liste_modeles($db,$maxfilenamelength=0)
50 50
 	{
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePdfExpedition extends CommonDocGenerator
38 38
 {
39
-    var $error='';
39
+    var $error = '';
40 40
 
41 41
 
42 42
 	/**
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
 	 */
49
-	static function liste_modeles($db,$maxfilenamelength=0)
49
+	static function liste_modeles($db, $maxfilenamelength = 0)
50 50
 	{
51 51
 		global $conf;
52 52
 
53
-		$type='shipping';
54
-		$liste=array();
53
+		$type = 'shipping';
54
+		$liste = array();
55 55
 
56 56
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
58 58
 
59 59
 		return $liste;
60 60
 	}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
  */
67 67
 abstract class ModelNumRefExpedition
68 68
 {
69
-	var $error='';
69
+	var $error = '';
70 70
 
71 71
 	/** Return if a model can be used or not
72 72
 	 *
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,18 @@
 block discarded – undo
92 92
 		global $langs;
93 93
 		$langs->load("admin");
94 94
 
95
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
96
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
97
-		if ($this->version == 'dolibarr') return DOL_VERSION;
98
-		if ($this->version) return $this->version;
95
+		if ($this->version == 'development') {
96
+			return $langs->trans("VersionDevelopment");
97
+		}
98
+		if ($this->version == 'experimental') {
99
+			return $langs->trans("VersionExperimental");
100
+		}
101
+		if ($this->version == 'dolibarr') {
102
+			return DOL_VERSION;
103
+		}
104
+		if ($this->version) {
105
+			return $this->version;
106
+		}
99 107
 		return $langs->trans("NotAvailable");
100 108
 	}
101 109
 }
Please login to merge, or discard this patch.
htdocs/core/modules/modUser.class.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 		// Boxes
77 77
 		$this->boxes = array(
78
-		    0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
78
+			0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
79 79
 		);
80 80
 
81 81
 		// Permissions
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 		$this->rights[$r][5] = 'export';
206 206
 
207 207
 		
208
-        // Menus
209
-        //-------
208
+		// Menus
209
+		//-------
210 210
         
211
-        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
211
+		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
212 212
 		
213 213
 		
214 214
 		// Exports
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 		$this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId");
223 223
 		$this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname");
224 224
 		$this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member");
225
-        if (empty($conf->adherent->enabled))
226
-        {
227
-            unset($this->export_fields_array[$r]['u.fk_member']);
228
-            unset($this->export_entities_array[$r]['u.fk_member']);
229
-        }
225
+		if (empty($conf->adherent->enabled))
226
+		{
227
+			unset($this->export_fields_array[$r]['u.fk_member']);
228
+			unset($this->export_entities_array[$r]['u.fk_member']);
229
+		}
230 230
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
231 231
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
232 232
 		$this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
 		$resql=$this->db->query($sql);
249 249
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
250 250
 		{
251
-		    while ($obj=$this->db->fetch_object($resql))
252
-		    {
253
-		        $fieldname='extra.'.$obj->name;
254
-		        $fieldlabel=ucfirst($obj->label);
255
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
256
-		    }
251
+			while ($obj=$this->db->fetch_object($resql))
252
+			{
253
+				$fieldname='extra.'.$obj->name;
254
+				$fieldlabel=ucfirst($obj->label);
255
+				$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
256
+			}
257 257
 		}
258 258
 		// End add extra fields
259 259
 		$this->import_fieldshidden_array[$r]=array('u.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
260 260
 		$this->import_convertvalue_array[$r]=array(
261 261
 			'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
262
-		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
263
-		    'u.salary'=>array('rule'=>'numeric')
262
+			'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
263
+			'u.salary'=>array('rule'=>'numeric')
264 264
 		);
265 265
 		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
266 266
 		$this->import_regex_array[$r]=array('u.employee'=>'^[0|1]','u.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])?$');
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
 	}
271 271
 
272 272
 
273
-    /**
273
+	/**
274 274
 	 *		Function called when module is enabled.
275 275
 	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
276 276
 	 *		It also creates data directories
277 277
 	 *
278
-     *      @param      string	$options    Options when enabling module ('', 'noboxes')
278
+	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
279 279
 	 *      @return     int             	1 if OK, 0 if KO
280
-     */
280
+	 */
281 281
 	function init($options='')
282 282
 	{
283 283
 		global $conf;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *	\brief      Fichier de description et activation du module Utilisateur
26 26
  */
27 27
 
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 /**
31 31
  *	Class to describe and enable module User
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
 		$this->db = $db;
46 46
 		$this->numero = 0;
47 47
 
48
-		$this->family = "hr";		// Family for module (or "base" if core module)
48
+		$this->family = "hr"; // Family for module (or "base" if core module)
49 49
 		$this->module_position = 10;
50 50
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->name = preg_replace('/^mod/i','',get_class($this));
51
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
52 52
 		$this->description = "Gestion des utilisateurs (requis)";
53
-		$this->always_enabled = true;	// Can't be disabled
53
+		$this->always_enabled = true; // Can't be disabled
54 54
 
55 55
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
56 56
 		$this->version = 'dolibarr';
57 57
 
58 58
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59 59
 		$this->special = 0;
60
-		$this->picto='group';
60
+		$this->picto = 'group';
61 61
 
62 62
 		// Data directories to create when module is enabled
63 63
 		$this->dirs = array("/users/temp");
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 		// Dependancies
69 69
 		$this->depends = array();
70 70
 		$this->requiredby = array();
71
-		$this->langfiles = array("main","users","companies","members",'salaries');
71
+		$this->langfiles = array("main", "users", "companies", "members", 'salaries');
72 72
 
73 73
 		// Constants
74 74
 		$this->const = array();
75 75
 
76 76
 		// Boxes
77 77
 		$this->boxes = array(
78
-		    0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
78
+		    0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'),
79 79
 		);
80 80
 
81 81
 		// Permissions
82 82
 		$this->rights = array();
83 83
 		$this->rights_class = 'user';
84
-		$this->rights_admin_allowed = 1;	// Admin is always granted of permission (even when module is disabled)
85
-		$r=0;
84
+		$this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
85
+		$r = 0;
86 86
 
87 87
 		$r++;
88 88
 		$this->rights[$r][0] = 251;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		$this->rights[$r][1] = 'Consulter ses propres permissions';
138 138
 		$this->rights[$r][2] = 'r';
139 139
 		$this->rights[$r][3] = 0;
140
-		$this->rights[$r][4] = 'self_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
140
+		$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
141 141
 		$this->rights[$r][5] = 'readperms';
142 142
 
143 143
 		$r++;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		$this->rights[$r][1] = 'Modifier ses propres permissions';
162 162
 		$this->rights[$r][2] = 'w';
163 163
 		$this->rights[$r][3] = 0;
164
-		$this->rights[$r][4] = 'self_advance';          // Visible if option MAIN_USE_ADVANCED_PERMS is on
164
+		$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
165 165
 		$this->rights[$r][5] = 'writeperms';
166 166
 
167 167
 		$r++;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		$this->rights[$r][1] = 'Consulter les groupes';
170 170
 		$this->rights[$r][2] = 'r';
171 171
 		$this->rights[$r][3] = 0;
172
-		$this->rights[$r][4] = 'group_advance';        // Visible if option MAIN_USE_ADVANCED_PERMS is on
172
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
173 173
 		$this->rights[$r][5] = 'read';
174 174
 
175 175
 		$r++;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		$this->rights[$r][1] = 'Consulter les permissions des groupes';
178 178
 		$this->rights[$r][2] = 'r';
179 179
 		$this->rights[$r][3] = 0;
180
-		$this->rights[$r][4] = 'group_advance';       // Visible if option MAIN_USE_ADVANCED_PERMS is on
180
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
181 181
 		$this->rights[$r][5] = 'readperms';
182 182
 
183 183
 		$r++;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
186 186
 		$this->rights[$r][2] = 'w';
187 187
 		$this->rights[$r][3] = 0;
188
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
188
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
189 189
 		$this->rights[$r][5] = 'write';
190 190
 
191 191
 		$r++;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
194 194
 		$this->rights[$r][2] = 'd';
195 195
 		$this->rights[$r][3] = 0;
196
-		$this->rights[$r][4] = 'group_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
196
+		$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
197 197
 		$this->rights[$r][5] = 'delete';
198 198
 
199 199
 		$r++;
@@ -208,64 +208,64 @@  discard block
 block discarded – undo
208 208
         // Menus
209 209
         //-------
210 210
         
211
-        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
211
+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.
212 212
 		
213 213
 		
214 214
 		// Exports
215 215
 		//--------
216
-		$r=0;
216
+		$r = 0;
217 217
 
218 218
 		$r++;
219
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
220
-		$this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
221
-		$this->export_permission[$r]=array(array("user","user","export"));
222
-		$this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId");
223
-		$this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname");
224
-		$this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member");
219
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
220
+		$this->export_label[$r] = 'Liste des utilisateurs Dolibarr et attributs';
221
+		$this->export_permission[$r] = array(array("user", "user", "export"));
222
+		$this->export_fields_array[$r] = array('u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.accountancy_code'=>"UserAccountancyCode", 'u.office_phone'=>'Phone', 'u.office_fax'=>'Fax', 'u.email'=>'EMail', 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification", 'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.note'=>"Note", 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion', 'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId");
223
+		$this->export_TypeFields_array[$r] = array('u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.accountancy_code'=>'Text', 'u.office_phone'=>'Text', 'u.office_fax'=>'Text', 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname");
224
+		$this->export_entities_array[$r] = array('u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.accountancy_code'=>'user', 'u.office_phone'=>'user', 'u.office_fax'=>'user', 'u.email'=>'user', 'u.datec'=>"user", 'u.tms'=>"user", 'u.admin'=>"user", 'u.statut'=>'user', 'u.note'=>"user", 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member");
225 225
         if (empty($conf->adherent->enabled))
226 226
         {
227 227
             unset($this->export_fields_array[$r]['u.fk_member']);
228 228
             unset($this->export_entities_array[$r]['u.fk_member']);
229 229
         }
230
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
231
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'user as u';
232
-		$this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
230
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
231
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'user as u';
232
+		$this->export_sql_end[$r] .= ' WHERE u.entity IN ('.getEntity('user').')';
233 233
 		
234 234
 		// Imports
235 235
 		//--------
236
-		$r=0;
236
+		$r = 0;
237 237
 
238 238
 		// Import list of users attributes
239 239
 		$r++;
240
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
241
-		$this->import_label[$r]='ImportDataset_user_1';
242
-		$this->import_icon[$r]='user';
243
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
244
-		$this->import_tables_array[$r]=array('u'=>MAIN_DB_PREFIX.'user','extra'=>MAIN_DB_PREFIX.'user_extrafields');	// List of tables to insert into (insert done in same order)
245
-		$this->import_fields_array[$r]=array('u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"Job",'u.gender'=>"Gender",'u.login'=>"Login*",'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature','u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM','u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey','u.datec'=>"DateCreation");
240
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
241
+		$this->import_label[$r] = 'ImportDataset_user_1';
242
+		$this->import_icon[$r] = 'user';
243
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
244
+		$this->import_tables_array[$r] = array('u'=>MAIN_DB_PREFIX.'user', 'extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order)
245
+		$this->import_fields_array[$r] = array('u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"Job", 'u.gender'=>"Gender", 'u.login'=>"Login*", 'u.pass_crypted'=>"Password", 'u.admin'=>"Administrator", 'u.fk_soc'=>"Company*", 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", 'u.fk_state'=>"StateId", 'u.fk_country'=>"CountryCode", 'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax", 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature', 'u.fk_user'=>'Supervisor', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', 'u.datec'=>"DateCreation");
246 246
 		// Add extra fields
247
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity = ".$conf->entity;
248
-		$resql=$this->db->query($sql);
247
+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity = ".$conf->entity;
248
+		$resql = $this->db->query($sql);
249 249
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
250 250
 		{
251
-		    while ($obj=$this->db->fetch_object($resql))
251
+		    while ($obj = $this->db->fetch_object($resql))
252 252
 		    {
253
-		        $fieldname='extra.'.$obj->name;
254
-		        $fieldlabel=ucfirst($obj->label);
255
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
253
+		        $fieldname = 'extra.'.$obj->name;
254
+		        $fieldlabel = ucfirst($obj->label);
255
+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
256 256
 		    }
257 257
 		}
258 258
 		// End add extra fields
259
-		$this->import_fieldshidden_array[$r]=array('u.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
260
-		$this->import_convertvalue_array[$r]=array(
261
-			'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
262
-		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
259
+		$this->import_fieldshidden_array[$r] = array('u.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
260
+		$this->import_convertvalue_array[$r] = array(
261
+			'u.fk_state'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'),
262
+		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'),
263 263
 		    'u.salary'=>array('rule'=>'numeric')
264 264
 		);
265 265
 		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
266
-		$this->import_regex_array[$r]=array('u.employee'=>'^[0|1]','u.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])?$');
267
-		$this->import_examplevalues_array[$r]=array('u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)",'u.fk_soc'=>'0 (internal user) or company name (external user)','u.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'u.address'=>"61 jump street",'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",'u.email'=>"[email protected]",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00");
268
-		$this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login');
266
+		$this->import_regex_array[$r] = array('u.employee'=>'^[0|1]', 'u.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])?$');
267
+		$this->import_examplevalues_array[$r] = array('u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.status'=>"0 (closed) or 1 (active)", 'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street", 'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102", 'u.email'=>"[email protected]", 'u.salary'=>"10000", 'u.note'=>"This is an example of note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00");
268
+		$this->import_updatekeys_array[$r] = array('u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>'Login');
269 269
 		
270 270
 	}
271 271
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
279 279
 	 *      @return     int             	1 if OK, 0 if KO
280 280
      */
281
-	function init($options='')
281
+	function init($options = '')
282 282
 	{
283 283
 		global $conf;
284 284
 
@@ -287,6 +287,6 @@  discard block
 block discarded – undo
287 287
 
288 288
 		$sql = array();
289 289
 
290
-		return $this->_init($sql,$options);
290
+		return $this->_init($sql, $options);
291 291
 	}
292 292
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -246,11 +246,13 @@
 block discarded – undo
246 246
 		// Add extra fields
247 247
 		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity = ".$conf->entity;
248 248
 		$resql=$this->db->query($sql);
249
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
249
+		if ($resql) {
250
+			// This can fail when class is used on old database (during migration for example)
250 251
 		{
251 252
 		    while ($obj=$this->db->fetch_object($resql))
252 253
 		    {
253 254
 		        $fieldname='extra.'.$obj->name;
255
+		}
254 256
 		        $fieldlabel=ucfirst($obj->label);
255 257
 		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
256 258
 		    }
Please login to merge, or discard this patch.
htdocs/core/modules/modStock.class.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -241,10 +241,10 @@
 block discarded – undo
241 241
 			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label')
242 242
 		  );
243 243
 		$this->import_examplevalues_array[$r]=array(
244
-		    'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
244
+			'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
245 245
 		);
246 246
 		$this->import_run_sql_after_array[$r]=array(    // Because we may change data that are denormalized, we must update dernormalized data after.
247
-		    'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
247
+			'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
248 248
 		);
249 249
 
250 250
 	}
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      Fichier de description et activation du module Stock
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->family = "products";
51 51
 		$this->module_position = 40;
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Gestion des stocks";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		$this->special = 0;
61
-		$this->picto='stock';
61
+		$this->picto = 'stock';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		// Constants
74 74
 		$this->const = array(
75
-			0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1)
75
+			0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER', 'chaine', '1', '', 1)
76 76
 		);
77 77
 
78 78
 		// Boxes
@@ -120,63 +120,63 @@  discard block
 block discarded – undo
120 120
 		if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
121 121
 		
122 122
 		$this->rights[5][0] = 1011;
123
-		$this->rights[5][1] = 'inventoryReadPermission';	// Permission label
124
-		$this->rights[5][3] = 0; 					// Permission by default for new user (0/1)
125
-		$this->rights[5][4] = 'advance_inventory';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
126
-		$this->rights[5][5] = 'read';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
123
+		$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
124
+		$this->rights[5][3] = 0; // Permission by default for new user (0/1)
125
+		$this->rights[5][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
126
+		$this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
127 127
 		
128 128
 		$this->rights[6][0] = 1012;
129
-		$this->rights[6][1] = 'inventoryCreatePermission';	// Permission label
130
-		$this->rights[6][3] = 0; 					// Permission by default for new user (0/1)
131
-		$this->rights[6][4] = 'advance_inventory';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
132
-		$this->rights[6][5] = 'create';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
129
+		$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
130
+		$this->rights[6][3] = 0; // Permission by default for new user (0/1)
131
+		$this->rights[6][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
132
+		$this->rights[6][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
133 133
 		
134 134
 		$this->rights[7][0] = 1013;
135
-		$this->rights[7][1] = 'inventoryWritePermission';	// Permission label
136
-		$this->rights[7][3] = 0; 					// Permission by default for new user (0/1)
137
-		$this->rights[7][4] = 'advance_inventory';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
138
-		$this->rights[7][5] = 'write';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
135
+		$this->rights[7][1] = 'inventoryWritePermission'; // Permission label
136
+		$this->rights[7][3] = 0; // Permission by default for new user (0/1)
137
+		$this->rights[7][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
138
+		$this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
139 139
 		
140 140
 		$this->rights[8][0] = 1014;
141
-		$this->rights[8][1] = 'inventoryValidatePermission';	// Permission label
142
-		$this->rights[8][3] = 0; 					// Permission by default for new user (0/1)
143
-		$this->rights[8][4] = 'advance_inventory';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
144
-		$this->rights[8][5] = 'validate';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
141
+		$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label
142
+		$this->rights[8][3] = 0; // Permission by default for new user (0/1)
143
+		$this->rights[8][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
144
+		$this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
145 145
 		
146 146
 		$this->rights[9][0] = 1015;
147
-		$this->rights[9][1] = 'inventoryChangePMPPermission';	// Permission label
148
-		$this->rights[9][3] = 0; 					// Permission by default for new user (0/1)
149
-		$this->rights[9][4] = 'advance_inventory';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
150
-		$this->rights[9][5] = 'changePMP';			// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
147
+		$this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label
148
+		$this->rights[9][3] = 0; // Permission by default for new user (0/1)
149
+		$this->rights[9][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
150
+		$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
151 151
 		
152 152
 		}
153 153
 		
154 154
 		// Main menu entries
155
-		$this->menu = array();			// List of menus to add
156
-		$r=0;
155
+		$this->menu = array(); // List of menus to add
156
+		$r = 0;
157 157
 		
158 158
 		// Menus
159 159
 		//-------
160
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
160
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
161 161
 		
162 162
 		
163 163
 		// Exports
164 164
 		//--------
165
-		$r=0;
165
+		$r = 0;
166 166
 
167 167
 		$r++;
168
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
169
-		$this->export_label[$r]="WarehousesAndProducts";	// Translation key (used only if key ExportDataset_xxx_z not found)
170
-		$this->export_permission[$r]=array(array("stock","lire"));
171
-		$this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','ps.reel'=>'Stock');
172
-		$this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:label','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','ps.reel'=>'Numeric');
173
-		$this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','ps.reel'=>'stock');
174
-		$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
175
-		$this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
176
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
177
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
178
-		$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
179
-		$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
168
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
169
+		$this->export_label[$r] = "WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
170
+		$this->export_permission[$r] = array(array("stock", "lire"));
171
+		$this->export_fields_array[$r] = array('e.rowid'=>'IdWarehouse', 'e.label'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'ps.reel'=>'Stock');
172
+		$this->export_TypeFields_array[$r] = array('e.rowid'=>'List:entrepot:label', 'e.label'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'ps.reel'=>'Numeric');
173
+		$this->export_entities_array[$r] = array('e.rowid'=>'warehouse', 'e.label'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', 'p.tms'=>'product', 'ps.reel'=>'stock');
174
+		$this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet
175
+		$this->export_dependencies_array[$r] = array('stock'=>array('p.rowid', 'e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
176
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
177
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
178
+		$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
179
+		$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
180 180
 
181 181
 		if ($conf->productbatch->enabled)
182 182
 		{
@@ -185,65 +185,65 @@  discard block
 block discarded – undo
185 185
 			// This request is same than previous but without field ps.stock (real stock in warehouse) and with link to subtable productbatch
186 186
 			$r++;
187 187
 
188
-			$this->export_code[$r]=$this->rights_class.'_'.$r;
189
-			$this->export_label[$r]="WarehousesAndProductsBatchDetail";	// Translation key (used only if key ExportDataset_xxx_z not found)
190
-			$this->export_permission[$r]=array(array("stock","lire"));
191
-			$this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.eatby'=>'EatByDate','pb.sellby'=>'SellByDate','pb.qty'=>'Qty');
192
-			$this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:label','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','pb.batch'=>'Text','pb.eatby'=>'Date','pb.sellby'=>'Date','pb.qty'=>'Numeric');
193
-			$this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'batch','pb.batch'=>'batch','pb.eatby'=>'batch','pb.sellby'=>'batch','pb.qty'=>'batch');
194
-			$this->export_aggregate_array[$r]=array('ps.reel'=>'SUM');    // TODO Not used yet
195
-			$this->export_dependencies_array[$r]=array('batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
196
-			$this->export_sql_start[$r]='SELECT DISTINCT ';
197
-			$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e, '.MAIN_DB_PREFIX.'product_batch as pb';
198
-			$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
199
-			$this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')';
188
+			$this->export_code[$r] = $this->rights_class.'_'.$r;
189
+			$this->export_label[$r] = "WarehousesAndProductsBatchDetail"; // Translation key (used only if key ExportDataset_xxx_z not found)
190
+			$this->export_permission[$r] = array(array("stock", "lire"));
191
+			$this->export_fields_array[$r] = array('e.rowid'=>'IdWarehouse', 'e.label'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.eatby'=>'EatByDate', 'pb.sellby'=>'SellByDate', 'pb.qty'=>'Qty');
192
+			$this->export_TypeFields_array[$r] = array('e.rowid'=>'List:entrepot:label', 'e.label'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'pb.batch'=>'Text', 'pb.eatby'=>'Date', 'pb.sellby'=>'Date', 'pb.qty'=>'Numeric');
193
+			$this->export_entities_array[$r] = array('e.rowid'=>'warehouse', 'e.label'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', 'p.tms'=>'product', 'pb.rowid'=>'batch', 'pb.batch'=>'batch', 'pb.eatby'=>'batch', 'pb.sellby'=>'batch', 'pb.qty'=>'batch');
194
+			$this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet
195
+			$this->export_dependencies_array[$r] = array('batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
196
+			$this->export_sql_start[$r] = 'SELECT DISTINCT ';
197
+			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e, '.MAIN_DB_PREFIX.'product_batch as pb';
198
+			$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
199
+			$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
200 200
 		}
201 201
 
202 202
 		// Imports
203 203
 		//--------
204 204
 
205
-		$r=0;
205
+		$r = 0;
206 206
 
207 207
 		// Import warehouses
208 208
 		$r++;
209
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
210
-		$this->import_label[$r]="Warehouses";	// Translation key
211
-		$this->import_icon[$r]=$this->picto;
212
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
213
-		$this->import_tables_array[$r]=array('e'=>MAIN_DB_PREFIX.'entrepot');
214
-		$this->import_tables_creator_array[$r]=array('e'=>'fk_user_author');
215
-		$this->import_fields_array[$r]=array('e.label'=>"LocationSummary*",
216
-				'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse",
217
-				'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode',
209
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
210
+		$this->import_label[$r] = "Warehouses"; // Translation key
211
+		$this->import_icon[$r] = $this->picto;
212
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
213
+		$this->import_tables_array[$r] = array('e'=>MAIN_DB_PREFIX.'entrepot');
214
+		$this->import_tables_creator_array[$r] = array('e'=>'fk_user_author');
215
+		$this->import_fields_array[$r] = array('e.label'=>"LocationSummary*",
216
+				'e.description'=>"DescWareHouse", 'e.lieu'=>"LieuWareHouse",
217
+				'e.address'=>"Address", 'e.zip'=>'Zip', 'e.fk_pays'=>'CountryCode',
218 218
 				'e.statut'=>'Status'
219 219
 		);
220 220
 
221
-		$this->import_convertvalue_array[$r]=array(
222
-				'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry')
221
+		$this->import_convertvalue_array[$r] = array(
222
+				'e.fk_pays'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry')
223 223
 		);
224
-		$this->import_regex_array[$r]=array('e.statut'=>'^[0|1]');
225
-		$this->import_examplevalues_array[$r]=array('e.label'=>"ALM001",
226
-				'e.description'=>"Central Warehouse",'e.lieu'=>"Central",
227
-				'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US',
224
+		$this->import_regex_array[$r] = array('e.statut'=>'^[0|1]');
225
+		$this->import_examplevalues_array[$r] = array('e.label'=>"ALM001",
226
+				'e.description'=>"Central Warehouse", 'e.lieu'=>"Central",
227
+				'e.address'=>"Route 66", 'e.zip'=>'28080', 'e.fk_pays'=>'US',
228 228
 				'e.statut'=>'1');
229 229
 
230 230
 		// Import stocks
231 231
 		$r++;
232
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
233
-		$this->import_label[$r]="Stocks";	// Translation key
234
-		$this->import_icon[$r]=$this->picto;
235
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
236
-		$this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
237
-		$this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*");
238
-
239
-		$this->import_convertvalue_array[$r]=array(
240
-			'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
241
-			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label')
232
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
233
+		$this->import_label[$r] = "Stocks"; // Translation key
234
+		$this->import_icon[$r] = $this->picto;
235
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
236
+		$this->import_tables_array[$r] = array('ps'=>MAIN_DB_PREFIX.'product_stock');
237
+		$this->import_fields_array[$r] = array('ps.fk_product'=>"Product*", 'ps.fk_entrepot'=>"Warehouse*", 'ps.reel'=>"Stock*");
238
+
239
+		$this->import_convertvalue_array[$r] = array(
240
+			'ps.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product'),
241
+			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'label')
242 242
 		  );
243
-		$this->import_examplevalues_array[$r]=array(
244
-		    'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
243
+		$this->import_examplevalues_array[$r] = array(
244
+		    'ps.fk_product'=>"PREF123456", 'ps.fk_entrepot'=>"ALM001", 'ps.reel'=>"10"
245 245
 		);
246
-		$this->import_run_sql_after_array[$r]=array(    // Because we may change data that are denormalized, we must update dernormalized data after.
246
+		$this->import_run_sql_after_array[$r] = array(    // Because we may change data that are denormalized, we must update dernormalized data after.
247 247
 		    'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
248 248
 		);
249 249
 
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 
131 131
 	/**
132
-     *  Function to build pdf onto disk
133
-     *
134
-     *  @param		Object		$object				Object to generate
135
-     *  @param		Translate	$outputlangs		Lang output object
136
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
137
-     *  @param		int			$hidedetails		Do not show line details
138
-     *  @param		int			$hidedesc			Do not show desc
139
-     *  @param		int			$hideref			Do not show ref
140
-     *  @return     int             				1=OK, 0=KO
132
+	 *  Function to build pdf onto disk
133
+	 *
134
+	 *  @param		Object		$object				Object to generate
135
+	 *  @param		Translate	$outputlangs		Lang output object
136
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
137
+	 *  @param		int			$hidedetails		Do not show line details
138
+	 *  @param		int			$hidedesc			Do not show desc
139
+	 *  @param		int			$hideref			Do not show ref
140
+	 *  @return     int             				1=OK, 0=KO
141 141
 	 */
142 142
 	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
143 143
 	{
@@ -234,25 +234,25 @@  discard block
 block discarded – undo
234 234
 				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
235 235
 
236 236
 				// Create pdf instance
237
-                $pdf=pdf_getInstance($this->format);
238
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
239
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
240
-		        $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
241
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
242
-                $pdf->SetAutoPageBreak(1,0);
243
-
244
-                if (class_exists('TCPDF'))
245
-                {
246
-                    $pdf->setPrintHeader(false);
247
-                    $pdf->setPrintFooter(false);
248
-                }
249
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
250
-                // Set path to the background PDF File
251
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
252
-                {
253
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
254
-                    $tplidx = $pdf->importPage(1);
255
-                }
237
+				$pdf=pdf_getInstance($this->format);
238
+				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
239
+				$heightforinfotot = 50;	// Height reserved to output the info and total part
240
+				$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
241
+				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
242
+				$pdf->SetAutoPageBreak(1,0);
243
+
244
+				if (class_exists('TCPDF'))
245
+				{
246
+					$pdf->setPrintHeader(false);
247
+					$pdf->setPrintFooter(false);
248
+				}
249
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
250
+				// Set path to the background PDF File
251
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
252
+				{
253
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
254
+					$tplidx = $pdf->importPage(1);
255
+				}
256 256
 
257 257
 				$pdf->Open();
258 258
 				$pagenb=0;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 						$localtax2_type = $localtaxtmp_array[2];
494 494
 					}
495 495
 
496
-				    // retrieve global local tax
496
+					// retrieve global local tax
497 497
 					if ($localtax1_type && $localtax1ligne != 0)
498 498
 						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
499 499
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 	/**
616 616
 	 *  Show payments table
617 617
 	 *
618
-     *  @param	PDF			$pdf           Object PDF
619
-     *  @param  Object		$object         Object proposal
620
-     *  @param  int			$posy           Position y in PDF
621
-     *  @param  Translate	$outputlangs    Object langs for output
622
-     *  @return int             			<0 if KO, >0 if OK
618
+	 *  @param	PDF			$pdf           Object PDF
619
+	 *  @param  Object		$object         Object proposal
620
+	 *  @param  int			$posy           Position y in PDF
621
+	 *  @param  Translate	$outputlangs    Object langs for output
622
+	 *  @return int             			<0 if KO, >0 if OK
623 623
 	 */
624 624
 	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
625 625
 	{
@@ -645,10 +645,10 @@  discard block
 block discarded – undo
645 645
 
646 646
 		$posxval=52;
647 647
 
648
-        // Show shipping date
649
-        if (! empty($object->date_livraison))
648
+		// Show shipping date
649
+		if (! empty($object->date_livraison))
650 650
 		{
651
-            $outputlangs->load("sendings");
651
+			$outputlangs->load("sendings");
652 652
 			$pdf->SetFont('','B', $default_font_size - 2);
653 653
 			$pdf->SetXY($this->marge_gauche, $posy);
654 654
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
659 659
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
660 660
 
661
-            $posy=$pdf->GetY()+1;
661
+			$posy=$pdf->GetY()+1;
662 662
 		}
663 663
 		else {
664 664
 			$outputlangs->load("sendings");
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
 			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
672 672
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
673 673
 
674
-            $posy=$pdf->GetY()+1;
674
+			$posy=$pdf->GetY()+1;
675 675
 		}
676
-        /* PHFAVRE
676
+		/* PHFAVRE
677 677
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
678 678
 		{
679 679
 			$pdf->SetFont('','B', $default_font_size - 2);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
759 759
 						$posy=$pdf->GetY()+1;
760 760
 
761
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
762
-			            {
761
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
762
+						{
763 763
 							$pdf->SetXY($this->marge_gauche, $posy);
764 764
 							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
765 765
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
766 766
 							$posy=$pdf->GetY()+2;
767
-			            }
767
+						}
768 768
 					}
769 769
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
770 770
 					{
@@ -773,13 +773,13 @@  discard block
 block discarded – undo
773 773
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
774 774
 						$posy=$pdf->GetY()+1;
775 775
 
776
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
777
-			            {
776
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
777
+						{
778 778
 							$pdf->SetXY($this->marge_gauche, $posy);
779 779
 							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
780 780
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
781 781
 							$posy=$pdf->GetY()+2;
782
-			            }
782
+						}
783 783
 					}
784 784
 				}
785 785
 			}
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 							}
890 890
 						}
891 891
 					}
892
-	      		//}
892
+		  		//}
893 893
 				//Local tax 2 before VAT
894 894
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
895 895
 				//{
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 							}
982 982
 						}
983 983
 					}
984
-	      		//}
984
+		  		//}
985 985
 				//Local tax 2 after VAT
986 986
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
987 987
 				//{
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 
992 992
 						foreach( $localtax_rate as $tvakey => $tvaval )
993 993
 						{
994
-						    // retrieve global local tax
994
+							// retrieve global local tax
995 995
 							if ($tvakey != 0)    // On affiche pas taux 0
996 996
 							{
997 997
 								//$this->atleastoneratenotnull++;
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		//  Show Draft Watermark
1212 1212
 		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1213 1213
 		{
1214
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1214
+			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1215 1215
 		}
1216 1216
 
1217 1217
 		$pdf->SetTextColor(0,0,60);
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 		{
1229 1229
 			if (is_readable($logo))
1230 1230
 			{
1231
-			    $height=pdf_getHeightForLogo($logo);
1232
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1231
+				$height=pdf_getHeightForLogo($logo);
1232
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1233 1233
 			}
1234 1234
 			else
1235 1235
 			{
@@ -1286,16 +1286,16 @@  discard block
 block discarded – undo
1286 1286
 		// Get contact
1287 1287
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1288 1288
 		{
1289
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1290
-		    if (count($arrayidcontact) > 0)
1291
-		    {
1292
-		        $usertmp=new User($this->db);
1293
-		        $usertmp->fetch($arrayidcontact[0]);
1294
-                $posy+=4;
1295
-                $pdf->SetXY($posx,$posy);
1296
-		        $pdf->SetTextColor(0,0,60);
1297
-		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1298
-		    }
1289
+			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1290
+			if (count($arrayidcontact) > 0)
1291
+			{
1292
+				$usertmp=new User($this->db);
1293
+				$usertmp->fetch($arrayidcontact[0]);
1294
+				$posy+=4;
1295
+				$pdf->SetXY($posx,$posy);
1296
+				$pdf->SetTextColor(0,0,60);
1297
+				$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1298
+			}
1299 1299
 		}
1300 1300
 		
1301 1301
 		$posy+=2;
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 
1401 1401
 	/**
1402 1402
 	 *   	Show footer of page. Need this->emetteur object
1403
-     *
1403
+	 *
1404 1404
 	 *   	@param	PDF			$pdf     			PDF
1405 1405
 	 * 		@param	Object		$object				Object to show
1406 1406
 	 *      @param	Translate	$outputlangs		Object lang for output
Please login to merge, or discard this patch.
Braces   +173 added lines, -89 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Get source company
101 101
 		$this->emetteur=$mysoc;
102
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
102
+		if (empty($this->emetteur->country_code)) {
103
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
104
+		}
105
+		// By default, if was not defined
103 106
 
104 107
 		// Define position of columns
105 108
 		$this->posxdesc=$this->marge_gauche+1;
@@ -108,11 +111,15 @@  discard block
 block discarded – undo
108 111
 		$this->posxqty=145;
109 112
 		$this->posxdiscount=162;
110 113
 		$this->postotalht=174;
111
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
114
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
115
+			$this->posxup=$this->posxtva;
116
+		}
112 117
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
113
-		if ($this->page_largeur < 210) // To work with US executive format
118
+		if ($this->page_largeur < 210) {
119
+			// To work with US executive format
114 120
 		{
115 121
 			$this->posxpicture-=20;
122
+		}
116 123
 			$this->posxtva-=20;
117 124
 			$this->posxup-=20;
118 125
 			$this->posxqty-=20;
@@ -143,9 +150,13 @@  discard block
 block discarded – undo
143 150
 	{
144 151
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
145 152
 
146
-		if (! is_object($outputlangs)) $outputlangs=$langs;
153
+		if (! is_object($outputlangs)) {
154
+			$outputlangs=$langs;
155
+		}
147 156
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
148
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
157
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
158
+			$outputlangs->charset_output='ISO-8859-1';
159
+		}
149 160
 
150 161
 		$outputlangs->load("main");
151 162
 		$outputlangs->load("dict");
@@ -162,7 +173,9 @@  discard block
 block discarded – undo
162 173
 		{
163 174
 			for ($i = 0 ; $i < $nblignes ; $i++)
164 175
 			{
165
-				if (empty($object->lines[$i]->fk_product)) continue;
176
+				if (empty($object->lines[$i]->fk_product)) {
177
+					continue;
178
+				}
166 179
 
167 180
 				$objphoto = new Product($this->db);
168 181
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -171,8 +184,7 @@  discard block
 block discarded – undo
171 184
 				{
172 185
 					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
173 186
 					$dir = $conf->product->dir_output.'/'.$pdir;
174
-				}
175
-				else
187
+				} else
176 188
 				{
177 189
 					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
178 190
 					$dir = $conf->product->dir_output.'/'.$pdir;
@@ -187,10 +199,14 @@  discard block
 block discarded – undo
187 199
 					break;
188 200
 				}
189 201
 
190
-				if ($realpath) $realpatharray[$i]=$realpath;
202
+				if ($realpath) {
203
+					$realpatharray[$i]=$realpath;
204
+				}
191 205
 			}
192 206
 		}
193
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
207
+		if (count($realpatharray) == 0) {
208
+			$this->posxpicture=$this->posxtva;
209
+		}
194 210
 
195 211
 		if ($conf->supplier_proposal->dir_output)
196 212
 		{
@@ -203,8 +219,7 @@  discard block
 block discarded – undo
203 219
 			{
204 220
 				$dir = $conf->supplier_proposal->dir_output;
205 221
 				$file = $dir . "/SPECIMEN.pdf";
206
-			}
207
-			else
222
+			} else
208 223
 			{
209 224
 				$objectref = dol_sanitizeFileName($object->ref);
210 225
 				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
@@ -263,7 +278,9 @@  discard block
 block discarded – undo
263 278
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
264 279
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
265 280
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
266
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
281
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
282
+					$pdf->SetCompression(false);
283
+				}
267 284
 
268 285
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
269 286
 
@@ -287,7 +304,9 @@  discard block
 block discarded – undo
287 304
 
288 305
 				// New page
289 306
 				$pdf->AddPage();
290
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
307
+				if (! empty($tplidx)) {
308
+					$pdf->useTemplate($tplidx);
309
+				}
291 310
 				$pagenb++;
292 311
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
293 312
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -309,7 +328,9 @@  discard block
 block discarded – undo
309 328
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
310 329
 						$salerepobj=new User($this->db);
311 330
 						$salerepobj->fetch($salereparray[0]['id']);
312
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
331
+						if (! empty($salerepobj->signature)) {
332
+							$notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
333
+						}
313 334
 					}
314 335
 				}
315 336
 				if ($notetoshow)
@@ -327,8 +348,7 @@  discard block
 block discarded – undo
327 348
 
328 349
 					$tab_height = $tab_height - $height_note;
329 350
 					$tab_top = $nexY+6;
330
-				}
331
-				else
351
+				} else
332 352
 				{
333 353
 					$height_note=0;
334 354
 				}
@@ -346,7 +366,9 @@  discard block
 block discarded – undo
346 366
 
347 367
 					// Define size of image if we need it
348 368
 					$imglinesize=array();
349
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
369
+					if (! empty($realpatharray[$i])) {
370
+						$imglinesize=pdf_getSizeForImage($realpatharray[$i]);
371
+					}
350 372
 
351 373
 					$pdf->setTopMargin($tab_top_newpage);
352 374
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -357,11 +379,17 @@  discard block
 block discarded – undo
357 379
 					$posYAfterDescription=0;
358 380
 
359 381
 					// We start with Photo of product line
360
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
382
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
383
+						// If photo too high, we moved completely on new page
361 384
 					{
362 385
 						$pdf->AddPage('','',true);
363
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
364
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
386
+					}
387
+						if (! empty($tplidx)) {
388
+							$pdf->useTemplate($tplidx);
389
+						}
390
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
391
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
392
+						}
365 393
 						$pdf->setPage($pageposbefore+1);
366 394
 
367 395
 						$curY = $tab_top_newpage;
@@ -383,17 +411,18 @@  discard block
 block discarded – undo
383 411
 					if ($posYAfterImage > 0) 
384 412
 					{
385 413
 						$descWidth = $this->posxpicture-$curX;
386
-					} 
387
-					else 
414
+					} else 
388 415
 					{
389 416
 						$descWidth = $this->posxtva-$curX;
390 417
 					}
391 418
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
392 419
 
393 420
 					$pageposafter=$pdf->getPage();
394
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
421
+					if ($pageposafter > $pageposbefore) {
422
+						// There is a pagebreak
395 423
 					{
396 424
 						$pdf->rollbackTransaction(true);
425
+					}
397 426
 						$pageposafter=$pageposbefore;
398 427
 						//print $pageposafter.'-'.$pageposbefore;exit;
399 428
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -402,23 +431,27 @@  discard block
 block discarded – undo
402 431
 						$pageposafter=$pdf->getPage();
403 432
 						$posyafter=$pdf->GetY();
404 433
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
405
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
434
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
435
+							// There is no space left for total+free text
406 436
 						{
407 437
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
408 438
 							{
409 439
 								$pdf->AddPage('','',true);
410
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
411
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
440
+						}
441
+								if (! empty($tplidx)) {
442
+									$pdf->useTemplate($tplidx);
443
+								}
444
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
445
+									$this->_pagehead($pdf, $object, 0, $outputlangs);
446
+								}
412 447
 								$pdf->setPage($pageposafter+1);
413 448
 							}
414
-						}
415
-						else
449
+						} else
416 450
 						{
417 451
 							// We found a page break
418 452
 							$showpricebeforepagebreak=0;
419 453
 						}
420
-					}
421
-					else	// No pagebreak
454
+					} else	// No pagebreak
422 455
 					{
423 456
 						$pdf->commitTransaction();
424 457
 					}
@@ -476,8 +509,11 @@  discard block
 block discarded – undo
476 509
                     */
477 510
 					
478 511
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
479
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
480
-					else $tvaligne=$object->lines[$i]->total_tva;
512
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
513
+						$tvaligne=$object->lines[$i]->multicurrency_total_tva;
514
+					} else {
515
+						$tvaligne=$object->lines[$i]->total_tva;
516
+					}
481 517
 					
482 518
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
483 519
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -486,32 +522,48 @@  discard block
 block discarded – undo
486 522
 					$localtax1_type=$object->lines[$i]->localtax1_type;
487 523
 					$localtax2_type=$object->lines[$i]->localtax2_type;
488 524
 
489
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
490
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
491
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
525
+					if ($object->remise_percent) {
526
+						$tvaligne-=($tvaligne*$object->remise_percent)/100;
527
+					}
528
+					if ($object->remise_percent) {
529
+						$localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
530
+					}
531
+					if ($object->remise_percent) {
532
+						$localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
533
+					}
492 534
 
493 535
 					$vatrate=(string) $object->lines[$i]->tva_tx;
494 536
 
495 537
 					// Retrieve type from database for backward compatibility with old records
496 538
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
497
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
539
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
540
+						// and there is local tax
498 541
 					{
499 542
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
543
+					}
500 544
 						$localtax1_type = $localtaxtmp_array[0];
501 545
 						$localtax2_type = $localtaxtmp_array[2];
502 546
 					}
503 547
 
504 548
 				    // retrieve global local tax
505
-					if ($localtax1_type && $localtax1ligne != 0)
506
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
507
-					if ($localtax2_type && $localtax2ligne != 0)
508
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
549
+					if ($localtax1_type && $localtax1ligne != 0) {
550
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
551
+					}
552
+					if ($localtax2_type && $localtax2ligne != 0) {
553
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
554
+					}
509 555
 
510
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
511
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
556
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
557
+						$vatrate.='*';
558
+					}
559
+					if (! isset($this->tva[$vatrate])) {
560
+						$this->tva[$vatrate]=0;
561
+					}
512 562
 					$this->tva[$vatrate] += $tvaligne;
513 563
 
514
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
564
+					if ($posYAfterImage > $posYAfterDescription) {
565
+						$nexY=$posYAfterImage;
566
+					}
515 567
 
516 568
 					// Add line
517 569
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -532,8 +584,7 @@  discard block
 block discarded – undo
532 584
 						if ($pagenb == 1)
533 585
 						{
534 586
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
535
-						}
536
-						else
587
+						} else
537 588
 						{
538 589
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
539 590
 						}
@@ -541,24 +592,29 @@  discard block
 block discarded – undo
541 592
 						$pagenb++;
542 593
 						$pdf->setPage($pagenb);
543 594
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
544
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
595
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
596
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
597
+						}
545 598
 					}
546 599
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
547 600
 					{
548 601
 						if ($pagenb == 1)
549 602
 						{
550 603
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
551
-						}
552
-						else
604
+						} else
553 605
 						{
554 606
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
555 607
 						}
556 608
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
557 609
 						// New page
558 610
 						$pdf->AddPage();
559
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
611
+						if (! empty($tplidx)) {
612
+							$pdf->useTemplate($tplidx);
613
+						}
560 614
 						$pagenb++;
561
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
615
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
616
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
617
+						}
562 618
 					}
563 619
 				}
564 620
 
@@ -567,8 +623,7 @@  discard block
 block discarded – undo
567 623
 				{
568 624
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
569 625
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
570
-				}
571
-				else
626
+				} else
572 627
 				{
573 628
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
574 629
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -590,7 +645,9 @@  discard block
 block discarded – undo
590 645
 
591 646
 				// Pied de page
592 647
 				$this->_pagefoot($pdf,$object,$outputlangs);
593
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
648
+				if (method_exists($pdf,'AliasNbPages')) {
649
+					$pdf->AliasNbPages();
650
+				}
594 651
 
595 652
 				$pdf->Close();
596 653
 
@@ -602,20 +659,19 @@  discard block
 block discarded – undo
602 659
 				global $action;
603 660
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
604 661
 
605
-				if (! empty($conf->global->MAIN_UMASK))
606
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
662
+				if (! empty($conf->global->MAIN_UMASK)) {
663
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
664
+				}
607 665
 
608 666
 				$this->result = array('fullpath'=>$file);
609 667
 				
610 668
 				return 1;   // Pas d'erreur
611
-			}
612
-			else
669
+			} else
613 670
 			{
614 671
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
615 672
 				return 0;
616 673
 			}
617
-		}
618
-		else
674
+		} else
619 675
 		{
620 676
 			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
621 677
 			return 0;
@@ -669,8 +725,7 @@  discard block
 block discarded – undo
669 725
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
670 726
 
671 727
             $posy=$pdf->GetY()+1;
672
-		}
673
-		else {
728
+		} else {
674 729
 			$outputlangs->load("sendings");
675 730
 			$pdf->SetFont('','B', $default_font_size - 2);
676 731
 			$pdf->SetXY($this->marge_gauche, $posy);
@@ -715,8 +770,7 @@  discard block
 block discarded – undo
715 770
 			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
716 771
 
717 772
 			$posy=$pdf->GetY()+3;
718
-		}
719
-		else {
773
+		} else {
720 774
 			$pdf->SetFont('','B', $default_font_size - 2);
721 775
 			$pdf->SetXY($this->marge_gauche, $posy);
722 776
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
@@ -838,10 +892,12 @@  discard block
 block discarded – undo
838 892
 
839 893
 		// Tableau total
840 894
 		$col1x = 120; $col2x = 170;
841
-		if ($this->page_largeur < 210) // To work with US executive format
895
+		if ($this->page_largeur < 210) {
896
+			// To work with US executive format
842 897
 		{
843 898
 			$col2x-=20;
844 899
 		}
900
+		}
845 901
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
846 902
 
847 903
 		$useborder=0;
@@ -865,23 +921,26 @@  discard block
 block discarded – undo
865 921
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
866 922
 			{
867 923
 				// Nothing to do
868
-			}
869
-			else
924
+			} else
870 925
 			{
871 926
 				//Local tax 1 before VAT
872 927
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
873 928
 				//{
874 929
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
875 930
 					{
876
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
931
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
932
+							continue;
933
+						}
877 934
 
878 935
 						foreach( $localtax_rate as $tvakey => $tvaval )
879 936
 						{
880
-							if ($tvakey!=0)    // On affiche pas taux 0
937
+							if ($tvakey!=0) {
938
+								// On affiche pas taux 0
881 939
 							{
882 940
 								//$this->atleastoneratenotnull++;
883 941
 
884 942
 								$index++;
943
+							}
885 944
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
886 945
 
887 946
 								$tvacompl='';
@@ -905,17 +964,21 @@  discard block
 block discarded – undo
905 964
 				//{
906 965
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
907 966
 					{
908
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
967
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
968
+							continue;
969
+						}
909 970
 
910 971
 						foreach( $localtax_rate as $tvakey => $tvaval )
911 972
 						{
912
-							if ($tvakey!=0)    // On affiche pas taux 0
973
+							if ($tvakey!=0) {
974
+								// On affiche pas taux 0
913 975
 							{
914 976
 								//$this->atleastoneratenotnull++;
915 977
 
916 978
 
917 979
 
918 980
 								$index++;
981
+							}
919 982
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
920 983
 
921 984
 								$tvacompl='';
@@ -938,9 +1001,11 @@  discard block
 block discarded – undo
938 1001
 				// VAT
939 1002
 				foreach($this->tva as $tvakey => $tvaval)
940 1003
 				{
941
-					if ($tvakey > 0)    // On affiche pas taux 0
1004
+					if ($tvakey > 0) {
1005
+						// On affiche pas taux 0
942 1006
 					{
943 1007
 						$this->atleastoneratenotnull++;
1008
+					}
944 1009
 
945 1010
 						$index++;
946 1011
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -965,15 +1030,19 @@  discard block
 block discarded – undo
965 1030
 				//{
966 1031
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
967 1032
 					{
968
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1033
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1034
+							continue;
1035
+						}
969 1036
 
970 1037
 						foreach( $localtax_rate as $tvakey => $tvaval )
971 1038
 						{
972
-							if ($tvakey != 0)    // On affiche pas taux 0
1039
+							if ($tvakey != 0) {
1040
+								// On affiche pas taux 0
973 1041
 							{
974 1042
 								//$this->atleastoneratenotnull++;
975 1043
 
976 1044
 								$index++;
1045
+							}
977 1046
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
978 1047
 
979 1048
 								$tvacompl='';
@@ -997,16 +1066,20 @@  discard block
 block discarded – undo
997 1066
 				//{
998 1067
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
999 1068
 					{
1000
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1069
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1070
+							continue;
1071
+						}
1001 1072
 
1002 1073
 						foreach( $localtax_rate as $tvakey => $tvaval )
1003 1074
 						{
1004 1075
 						    // retrieve global local tax
1005
-							if ($tvakey != 0)    // On affiche pas taux 0
1076
+							if ($tvakey != 0) {
1077
+								// On affiche pas taux 0
1006 1078
 							{
1007 1079
 								//$this->atleastoneratenotnull++;
1008 1080
 
1009 1081
 								$index++;
1082
+							}
1010 1083
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1011 1084
 
1012 1085
 								$tvacompl='';
@@ -1108,7 +1181,9 @@  discard block
 block discarded – undo
1108 1181
 
1109 1182
 		// Force to disable hidetop and hidebottom
1110 1183
 		$hidebottom=0;
1111
-		if ($hidetop) $hidetop=-1;
1184
+		if ($hidetop) {
1185
+			$hidetop=-1;
1186
+		}
1112 1187
 
1113 1188
 		$currency = !empty($currency) ? $currency : $conf->currency;
1114 1189
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1124,7 +1199,9 @@  discard block
 block discarded – undo
1124 1199
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1125 1200
 
1126 1201
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1127
-			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));
1202
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1203
+				$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));
1204
+			}
1128 1205
 		}
1129 1206
 
1130 1207
 		$pdf->SetDrawColor(128,128,128);
@@ -1230,16 +1307,14 @@  discard block
 block discarded – undo
1230 1307
 			{
1231 1308
 			    $height=pdf_getHeightForLogo($logo);
1232 1309
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1233
-			}
1234
-			else
1310
+			} else
1235 1311
 			{
1236 1312
 				$pdf->SetTextColor(200,0,0);
1237 1313
 				$pdf->SetFont('','B',$default_font_size - 2);
1238 1314
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1239 1315
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1240 1316
 			}
1241
-		}
1242
-		else
1317
+		} else
1243 1318
 		{
1244 1319
 			$text=$this->emetteur->name;
1245 1320
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1321,7 +1396,9 @@  discard block
 block discarded – undo
1321 1396
 			// Show sender
1322 1397
 			$posy=42;
1323 1398
 		 	$posx=$this->marge_gauche;
1324
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1399
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1400
+				$posx=$this->page_largeur-$this->marge_droite-80;
1401
+			}
1325 1402
 			$hautcadre=40;
1326 1403
 
1327 1404
 			// Show sender frame
@@ -1359,11 +1436,13 @@  discard block
 block discarded – undo
1359 1436
 			if (! empty($usecontact))
1360 1437
 			{
1361 1438
 				// On peut utiliser le nom de la societe du contact
1362
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1363
-				else $socname = $object->thirdparty->name;
1439
+				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1440
+					$socname = $object->contact->socname;
1441
+				} else {
1442
+					$socname = $object->thirdparty->name;
1443
+				}
1364 1444
 				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1365
-			}
1366
-			else
1445
+			} else
1367 1446
 			{
1368 1447
 				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1369 1448
 			}
@@ -1372,10 +1451,15 @@  discard block
 block discarded – undo
1372 1451
 
1373 1452
 			// Show recipient
1374 1453
 			$widthrecbox=100;
1375
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1454
+			if ($this->page_largeur < 210) {
1455
+				$widthrecbox=84;
1456
+			}
1457
+			// To work with US executive format
1376 1458
 			$posy=42;
1377 1459
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1460
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1461
+				$posx=$this->marge_gauche;
1462
+			}
1379 1463
 
1380 1464
 			// Show recipient frame
1381 1465
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
Spacing   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	var $description;
44 44
 	var $type;
45 45
 
46
-	var $phpmin = array(4,3,0); // Minimum version of PHP required by module
46
+	var $phpmin = array(4, 3, 0); // Minimum version of PHP required by module
47 47
 	var $version = 'dolibarr';
48 48
 
49 49
 	var $page_largeur;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	var	$marge_haute;
55 55
 	var	$marge_basse;
56 56
 
57
-	var $emetteur;	// Objet societe qui emet
57
+	var $emetteur; // Objet societe qui emet
58 58
 
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	function __construct($db)
66 66
 	{
67
-		global $conf,$langs,$mysoc;
67
+		global $conf, $langs, $mysoc;
68 68
 
69 69
 		$langs->load("main");
70 70
 		$langs->load("bills");
@@ -75,57 +75,57 @@  discard block
 block discarded – undo
75 75
 
76 76
 		// Dimension page pour format A4
77 77
 		$this->type = 'pdf';
78
-		$formatarray=pdf_getFormat();
78
+		$formatarray = pdf_getFormat();
79 79
 		$this->page_largeur = $formatarray['width'];
80 80
 		$this->page_hauteur = $formatarray['height'];
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
83
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
84
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
85
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
89
-		$this->option_modereg = 1;                 // Affiche mode reglement
90
-		$this->option_condreg = 1;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 1;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
97
-
98
-		$this->franchise=!$mysoc->tva_assuj;
81
+		$this->format = array($this->page_largeur, $this->page_hauteur);
82
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
83
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
84
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
85
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
86
+
87
+		$this->option_logo = 1; // Affiche logo
88
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
89
+		$this->option_modereg = 1; // Affiche mode reglement
90
+		$this->option_condreg = 1; // Affiche conditions reglement
91
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
92
+		$this->option_multilang = 1; // Dispo en plusieurs langues
93
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
94
+		$this->option_credit_note = 1; // Support credit notes
95
+		$this->option_freetext = 1; // Support add of a personalised text
96
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
97
+
98
+		$this->franchise = !$mysoc->tva_assuj;
99 99
 
100 100
 		// Get source company
101
-		$this->emetteur=$mysoc;
102
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
101
+		$this->emetteur = $mysoc;
102
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
103 103
 
104 104
 		// Define position of columns
105
-		$this->posxdesc=$this->marge_gauche+1;
106
-		$this->posxtva=102;
107
-		$this->posxup=126;
108
-		$this->posxqty=145;
109
-		$this->posxdiscount=162;
110
-		$this->postotalht=174;
111
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
112
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
105
+		$this->posxdesc = $this->marge_gauche + 1;
106
+		$this->posxtva = 102;
107
+		$this->posxup = 126;
108
+		$this->posxqty = 145;
109
+		$this->posxdiscount = 162;
110
+		$this->postotalht = 174;
111
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva;
112
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
113 113
 		if ($this->page_largeur < 210) // To work with US executive format
114 114
 		{
115
-			$this->posxpicture-=20;
116
-			$this->posxtva-=20;
117
-			$this->posxup-=20;
118
-			$this->posxqty-=20;
119
-			$this->posxunit-=20;
120
-			$this->posxdiscount-=20;
121
-			$this->postotalht-=20;
115
+			$this->posxpicture -= 20;
116
+			$this->posxtva -= 20;
117
+			$this->posxup -= 20;
118
+			$this->posxqty -= 20;
119
+			$this->posxunit -= 20;
120
+			$this->posxdiscount -= 20;
121
+			$this->postotalht -= 20;
122 122
 		}
123 123
 
124
-		$this->tva=array();
125
-		$this->localtax1=array();
126
-		$this->localtax2=array();
127
-		$this->atleastoneratenotnull=0;
128
-		$this->atleastonediscount=0;
124
+		$this->tva = array();
125
+		$this->localtax1 = array();
126
+		$this->localtax2 = array();
127
+		$this->atleastoneratenotnull = 0;
128
+		$this->atleastonediscount = 0;
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
      *  @param		int			$hideref			Do not show ref
140 140
      *  @return     int             				1=OK, 0=KO
141 141
 	 */
142
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
142
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
143 143
 	{
144
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
144
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
145 145
 
146
-		if (! is_object($outputlangs)) $outputlangs=$langs;
146
+		if (!is_object($outputlangs)) $outputlangs = $langs;
147 147
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
148
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
148
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
149 149
 
150 150
 		$outputlangs->load("main");
151 151
 		$outputlangs->load("dict");
@@ -157,40 +157,40 @@  discard block
 block discarded – undo
157 157
 		$nblignes = count($object->lines);
158 158
 
159 159
 		// Loop on each lines to detect if there is at least one image to show
160
-		$realpatharray=array();
161
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
160
+		$realpatharray = array();
161
+		if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
162 162
 		{
163
-			for ($i = 0 ; $i < $nblignes ; $i++)
163
+			for ($i = 0; $i < $nblignes; $i++)
164 164
 			{
165 165
 				if (empty($object->lines[$i]->fk_product)) continue;
166 166
 
167 167
 				$objphoto = new Product($this->db);
168 168
 				$objphoto->fetch($object->lines[$i]->fk_product);
169 169
 
170
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
170
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
171 171
 				{
172
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
172
+					$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
173 173
 					$dir = $conf->product->dir_output.'/'.$pdir;
174 174
 				}
175 175
 				else
176 176
 				{
177
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
177
+					$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
178 178
 					$dir = $conf->product->dir_output.'/'.$pdir;
179 179
 				}
180 180
 
181
-				$realpath='';
182
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
181
+				$realpath = '';
182
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
183 183
 				{
184
-					$filename=$obj['photo'];
184
+					$filename = $obj['photo'];
185 185
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
186 186
 					$realpath = $dir.$filename;
187 187
 					break;
188 188
 				}
189 189
 
190
-				if ($realpath) $realpatharray[$i]=$realpath;
190
+				if ($realpath) $realpatharray[$i] = $realpath;
191 191
 			}
192 192
 		}
193
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
193
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
194 194
 
195 195
 		if ($conf->supplier_proposal->dir_output)
196 196
 		{
@@ -202,20 +202,20 @@  discard block
 block discarded – undo
202 202
 			if ($object->specimen)
203 203
 			{
204 204
 				$dir = $conf->supplier_proposal->dir_output;
205
-				$file = $dir . "/SPECIMEN.pdf";
205
+				$file = $dir."/SPECIMEN.pdf";
206 206
 			}
207 207
 			else
208 208
 			{
209 209
 				$objectref = dol_sanitizeFileName($object->ref);
210
-				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
211
-				$file = $dir . "/" . $objectref . ".pdf";
210
+				$dir = $conf->supplier_proposal->dir_output."/".$objectref;
211
+				$file = $dir."/".$objectref.".pdf";
212 212
 			}
213 213
 
214
-			if (! file_exists($dir))
214
+			if (!file_exists($dir))
215 215
 			{
216 216
 				if (dol_mkdir($dir) < 0)
217 217
 				{
218
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
218
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
219 219
 					return 0;
220 220
 				}
221 221
 			}
@@ -223,23 +223,23 @@  discard block
 block discarded – undo
223 223
 			if (file_exists($dir))
224 224
 			{
225 225
 				// Add pdfgeneration hook
226
-				if (! is_object($hookmanager))
226
+				if (!is_object($hookmanager))
227 227
 				{
228 228
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
229
-					$hookmanager=new HookManager($this->db);
229
+					$hookmanager = new HookManager($this->db);
230 230
 				}
231 231
 				$hookmanager->initHooks(array('pdfgeneration'));
232
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
232
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
233 233
 				global $action;
234
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
234
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
235 235
 
236 236
 				// Create pdf instance
237
-                $pdf=pdf_getInstance($this->format);
238
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
239
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
240
-		        $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
241
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
242
-                $pdf->SetAutoPageBreak(1,0);
237
+                $pdf = pdf_getInstance($this->format);
238
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
239
+                $heightforinfotot = 50; // Height reserved to output the info and total part
240
+		        $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
241
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
242
+                $pdf->SetAutoPageBreak(1, 0);
243 243
 
244 244
                 if (class_exists('TCPDF'))
245 245
                 {
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
                 }
249 249
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
250 250
                 // Set path to the background PDF File
251
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
251
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
252 252
                 {
253 253
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
254 254
                     $tplidx = $pdf->importPage(1);
255 255
                 }
256 256
 
257 257
 				$pdf->Open();
258
-				$pagenb=0;
259
-				$pdf->SetDrawColor(128,128,128);
258
+				$pagenb = 0;
259
+				$pdf->SetDrawColor(128, 128, 128);
260 260
 
261 261
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
262 262
 				$pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
263 263
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
264 264
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
265 265
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
266
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
266
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
267 267
 
268
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
268
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
269 269
 
270 270
 				// Positionne $this->atleastonediscount si on a au moins une remise
271
-				for ($i = 0 ; $i < $nblignes ; $i++)
271
+				for ($i = 0; $i < $nblignes; $i++)
272 272
 				{
273 273
 					if ($object->lines[$i]->remise_percent)
274 274
 					{
@@ -277,60 +277,60 @@  discard block
 block discarded – undo
277 277
 				}
278 278
 				if (empty($this->atleastonediscount))
279 279
 				{
280
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
281
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
282
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
283
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
284
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
280
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
281
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
282
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
283
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
284
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
285 285
 					//$this->postotalht;
286 286
 				}
287 287
 
288 288
 				// New page
289 289
 				$pdf->AddPage();
290
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
290
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
291 291
 				$pagenb++;
292 292
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
293
-				$pdf->SetFont('','', $default_font_size - 1);
294
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
295
-				$pdf->SetTextColor(0,0,0);
293
+				$pdf->SetFont('', '', $default_font_size - 1);
294
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
295
+				$pdf->SetTextColor(0, 0, 0);
296 296
 
297 297
 				$tab_top = 90;
298
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
298
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
299 299
 				$tab_height = 130;
300 300
 				$tab_height_newpage = 150;
301 301
 
302 302
 				// Affiche notes
303
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
304
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
303
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
304
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
305 305
 				{
306 306
 					// Get first sale rep
307 307
 					if (is_object($object->thirdparty))
308 308
 					{
309
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
310
-						$salerepobj=new User($this->db);
309
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
310
+						$salerepobj = new User($this->db);
311 311
 						$salerepobj->fetch($salereparray[0]['id']);
312
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
312
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
313 313
 					}
314 314
 				}
315 315
 				if ($notetoshow)
316 316
 				{
317 317
 					$tab_top = 88;
318 318
 
319
-					$pdf->SetFont('','', $default_font_size - 1);
320
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
319
+					$pdf->SetFont('', '', $default_font_size - 1);
320
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
321 321
 					$nexY = $pdf->GetY();
322
-					$height_note=$nexY-$tab_top;
322
+					$height_note = $nexY - $tab_top;
323 323
 
324 324
 					// Rect prend une longueur en 3eme param
325
-					$pdf->SetDrawColor(192,192,192);
326
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
325
+					$pdf->SetDrawColor(192, 192, 192);
326
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
327 327
 
328 328
 					$tab_height = $tab_height - $height_note;
329
-					$tab_top = $nexY+6;
329
+					$tab_top = $nexY + 6;
330 330
 				}
331 331
 				else
332 332
 				{
333
-					$height_note=0;
333
+					$height_note = 0;
334 334
 				}
335 335
 
336 336
 				$iniY = $tab_top + 7;
@@ -338,105 +338,105 @@  discard block
 block discarded – undo
338 338
 				$nexY = $tab_top + 7;
339 339
 
340 340
 				// Loop on each lines
341
-				for ($i = 0 ; $i < $nblignes ; $i++)
341
+				for ($i = 0; $i < $nblignes; $i++)
342 342
 				{
343 343
 					$curY = $nexY;
344
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
345
-					$pdf->SetTextColor(0,0,0);
344
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
345
+					$pdf->SetTextColor(0, 0, 0);
346 346
 
347 347
 					// Define size of image if we need it
348
-					$imglinesize=array();
349
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
348
+					$imglinesize = array();
349
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
350 350
 
351 351
 					$pdf->setTopMargin($tab_top_newpage);
352
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
353
-					$pageposbefore=$pdf->getPage();
352
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
353
+					$pageposbefore = $pdf->getPage();
354 354
 
355
-					$showpricebeforepagebreak=1;
356
-					$posYAfterImage=0;
357
-					$posYAfterDescription=0;
355
+					$showpricebeforepagebreak = 1;
356
+					$posYAfterImage = 0;
357
+					$posYAfterDescription = 0;
358 358
 
359 359
 					// We start with Photo of product line
360
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
360
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
361 361
 					{
362
-						$pdf->AddPage('','',true);
363
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
362
+						$pdf->AddPage('', '', true);
363
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
364 364
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
365
-						$pdf->setPage($pageposbefore+1);
365
+						$pdf->setPage($pageposbefore + 1);
366 366
 
367 367
 						$curY = $tab_top_newpage;
368
-						$showpricebeforepagebreak=0;
368
+						$showpricebeforepagebreak = 0;
369 369
 					}
370 370
 
371 371
 					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
372 372
 					{
373
-						$curX = $this->posxpicture-1;
374
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
373
+						$curX = $this->posxpicture - 1;
374
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
375 375
 						// $pdf->Image does not increase value return by getY, so we save it manually
376
-						$posYAfterImage=$curY+$imglinesize['height'];
376
+						$posYAfterImage = $curY + $imglinesize['height'];
377 377
 					}
378 378
 
379 379
 					// Description of product line
380
-					$curX = $this->posxdesc-1;
380
+					$curX = $this->posxdesc - 1;
381 381
 
382 382
 					$pdf->startTransaction();
383 383
 					if ($posYAfterImage > 0) 
384 384
 					{
385
-						$descWidth = $this->posxpicture-$curX;
385
+						$descWidth = $this->posxpicture - $curX;
386 386
 					} 
387 387
 					else 
388 388
 					{
389
-						$descWidth = $this->posxtva-$curX;
389
+						$descWidth = $this->posxtva - $curX;
390 390
 					}
391
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
391
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
392 392
 
393
-					$pageposafter=$pdf->getPage();
393
+					$pageposafter = $pdf->getPage();
394 394
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
395 395
 					{
396 396
 						$pdf->rollbackTransaction(true);
397
-						$pageposafter=$pageposbefore;
397
+						$pageposafter = $pageposbefore;
398 398
 						//print $pageposafter.'-'.$pageposbefore;exit;
399
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
400
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
399
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
400
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc);
401 401
 
402
-						$pageposafter=$pdf->getPage();
403
-						$posyafter=$pdf->GetY();
402
+						$pageposafter = $pdf->getPage();
403
+						$posyafter = $pdf->GetY();
404 404
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
405
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
405
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
406 406
 						{
407
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
407
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
408 408
 							{
409
-								$pdf->AddPage('','',true);
410
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
409
+								$pdf->AddPage('', '', true);
410
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
411 411
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
412
-								$pdf->setPage($pageposafter+1);
412
+								$pdf->setPage($pageposafter + 1);
413 413
 							}
414 414
 						}
415 415
 						else
416 416
 						{
417 417
 							// We found a page break
418
-							$showpricebeforepagebreak=0;
418
+							$showpricebeforepagebreak = 0;
419 419
 						}
420 420
 					}
421 421
 					else	// No pagebreak
422 422
 					{
423 423
 						$pdf->commitTransaction();
424 424
 					}
425
-					$posYAfterDescription=$pdf->GetY();
425
+					$posYAfterDescription = $pdf->GetY();
426 426
 
427 427
 					$nexY = $pdf->GetY();
428
-					$pageposafter=$pdf->getPage();
428
+					$pageposafter = $pdf->getPage();
429 429
 
430 430
 					$pdf->setPage($pageposbefore);
431 431
 					$pdf->setTopMargin($this->marge_haute);
432
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
432
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
433 433
 
434 434
 					// We suppose that a too long description or photo were moved completely on next page
435 435
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
436 436
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
437 437
 					}
438 438
 
439
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
439
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
440 440
 
441 441
 					// VAT Rate
442 442
 					/*
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 					// Quantity
458 458
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
459 459
 					$pdf->SetXY($this->posxqty, $curY);
460
-					$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');	// Enough for 6 chars
460
+					$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
461 461
 
462 462
 					// Discount on line
463 463
 					/*
@@ -476,54 +476,54 @@  discard block
 block discarded – undo
476 476
                     */
477 477
 
478 478
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
479
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
480
-					else $tvaligne=$object->lines[$i]->total_tva;
479
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
480
+					else $tvaligne = $object->lines[$i]->total_tva;
481 481
 
482
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
483
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
484
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
485
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
486
-					$localtax1_type=$object->lines[$i]->localtax1_type;
487
-					$localtax2_type=$object->lines[$i]->localtax2_type;
482
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
483
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
484
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
485
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
486
+					$localtax1_type = $object->lines[$i]->localtax1_type;
487
+					$localtax2_type = $object->lines[$i]->localtax2_type;
488 488
 
489
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
490
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
491
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
489
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
490
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
491
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
492 492
 
493
-					$vatrate=(string) $object->lines[$i]->tva_tx;
493
+					$vatrate = (string) $object->lines[$i]->tva_tx;
494 494
 
495 495
 					// Retrieve type from database for backward compatibility with old records
496
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
497
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
496
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
497
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
498 498
 					{
499
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
499
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
500 500
 						$localtax1_type = $localtaxtmp_array[0];
501 501
 						$localtax2_type = $localtaxtmp_array[2];
502 502
 					}
503 503
 
504 504
 				    // retrieve global local tax
505 505
 					if ($localtax1_type && $localtax1ligne != 0)
506
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
506
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
507 507
 					if ($localtax2_type && $localtax2ligne != 0)
508
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
508
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
509 509
 
510
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
511
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
510
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
511
+					if (!isset($this->tva[$vatrate]))				$this->tva[$vatrate] = 0;
512 512
 					$this->tva[$vatrate] += $tvaligne;
513 513
 
514
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
514
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
515 515
 
516 516
 					// Add line
517
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
517
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
518 518
 					{
519 519
 						$pdf->setPage($pageposafter);
520
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
520
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
521 521
 						//$pdf->SetDrawColor(190,190,200);
522
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
522
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
523 523
 						$pdf->SetLineStyle(array('dash'=>0));
524 524
 					}
525 525
 
526
-					$nexY+=2;    // Passe espace entre les lignes
526
+					$nexY += 2; // Passe espace entre les lignes
527 527
 
528 528
 					// Detect if some page were added automatically and output _tableau for past pages
529 529
 					while ($pagenb < $pageposafter)
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
 						{
538 538
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
539 539
 						}
540
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
540
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
541 541
 						$pagenb++;
542 542
 						$pdf->setPage($pagenb);
543
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
543
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
544 544
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
545 545
 					}
546
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
546
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
547 547
 					{
548 548
 						if ($pagenb == 1)
549 549
 						{
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
 						{
554 554
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
555 555
 						}
556
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
556
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
557 557
 						// New page
558 558
 						$pdf->AddPage();
559
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
559
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
560 560
 						$pagenb++;
561 561
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
562 562
 					}
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
 				if ($pagenb == 1)
567 567
 				{
568 568
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
569
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
569
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
570 570
 				}
571 571
 				else
572 572
 				{
573 573
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
574
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
574
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
575 575
 				}
576 576
 
577 577
 				// Affiche zone infos
578
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
578
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
579 579
 
580 580
 				// Affiche zone totaux
581 581
 				//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
@@ -589,35 +589,35 @@  discard block
 block discarded – undo
589 589
 				*/
590 590
 
591 591
 				// Pied de page
592
-				$this->_pagefoot($pdf,$object,$outputlangs);
593
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
592
+				$this->_pagefoot($pdf, $object, $outputlangs);
593
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
594 594
 
595 595
 				$pdf->Close();
596 596
 
597
-				$pdf->Output($file,'F');
597
+				$pdf->Output($file, 'F');
598 598
 
599 599
 				//Add pdfgeneration hook
600 600
 				$hookmanager->initHooks(array('pdfgeneration'));
601
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
601
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
602 602
 				global $action;
603
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
603
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
604 604
 
605
-				if (! empty($conf->global->MAIN_UMASK))
605
+				if (!empty($conf->global->MAIN_UMASK))
606 606
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
607 607
 
608 608
 				$this->result = array('fullpath'=>$file);
609 609
 				
610
-				return 1;   // Pas d'erreur
610
+				return 1; // Pas d'erreur
611 611
 			}
612 612
 			else
613 613
 			{
614
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
614
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
615 615
 				return 0;
616 616
 			}
617 617
 		}
618 618
 		else
619 619
 		{
620
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
620
+			$this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
621 621
 			return 0;
622 622
 		}
623 623
 	}
@@ -651,37 +651,37 @@  discard block
 block discarded – undo
651 651
 		global $conf;
652 652
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
653 653
 
654
-		$pdf->SetFont('','', $default_font_size - 1);
654
+		$pdf->SetFont('', '', $default_font_size - 1);
655 655
 
656
-		$posxval=52;
656
+		$posxval = 52;
657 657
 
658 658
         // Show shipping date
659
-        if (! empty($object->date_livraison))
659
+        if (!empty($object->date_livraison))
660 660
 		{
661 661
             $outputlangs->load("sendings");
662
-			$pdf->SetFont('','B', $default_font_size - 2);
662
+			$pdf->SetFont('', 'B', $default_font_size - 2);
663 663
 			$pdf->SetXY($this->marge_gauche, $posy);
664 664
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
665 665
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
666
-			$pdf->SetFont('','', $default_font_size - 2);
666
+			$pdf->SetFont('', '', $default_font_size - 2);
667 667
 			$pdf->SetXY($posxval, $posy);
668
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
668
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
669 669
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
670 670
 
671
-            $posy=$pdf->GetY()+1;
671
+            $posy = $pdf->GetY() + 1;
672 672
 		}
673 673
 		else {
674 674
 			$outputlangs->load("sendings");
675
-			$pdf->SetFont('','B', $default_font_size - 2);
675
+			$pdf->SetFont('', 'B', $default_font_size - 2);
676 676
 			$pdf->SetXY($this->marge_gauche, $posy);
677 677
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
678 678
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
679
-			$pdf->SetFont('','', $default_font_size - 2);
679
+			$pdf->SetFont('', '', $default_font_size - 2);
680 680
 			$pdf->SetXY($posxval, $posy);
681 681
 			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
682 682
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
683 683
 
684
-            $posy=$pdf->GetY()+1;
684
+            $posy = $pdf->GetY() + 1;
685 685
 		}
686 686
         /* PHFAVRE
687 687
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
@@ -703,60 +703,60 @@  discard block
 block discarded – undo
703 703
 		// Show payments conditions
704 704
 		if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
705 705
 		{
706
-			$pdf->SetFont('','B', $default_font_size - 2);
706
+			$pdf->SetFont('', 'B', $default_font_size - 2);
707 707
 			$pdf->SetXY($this->marge_gauche, $posy);
708 708
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
709 709
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
710 710
 
711
-			$pdf->SetFont('','', $default_font_size - 2);
711
+			$pdf->SetFont('', '', $default_font_size - 2);
712 712
 			$pdf->SetXY($posxval, $posy);
713
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
714
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
715
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
713
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
714
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
715
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
716 716
 
717
-			$posy=$pdf->GetY()+3;
717
+			$posy = $pdf->GetY() + 3;
718 718
 		}
719 719
 		else {
720
-			$pdf->SetFont('','B', $default_font_size - 2);
720
+			$pdf->SetFont('', 'B', $default_font_size - 2);
721 721
 			$pdf->SetXY($this->marge_gauche, $posy);
722 722
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
723 723
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
724 724
 
725
-			$pdf->SetFont('','', $default_font_size - 2);
725
+			$pdf->SetFont('', '', $default_font_size - 2);
726 726
 			$pdf->SetXY($posxval, $posy);
727 727
 
728
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
729
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
728
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
729
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
730 730
 
731
-			$posy=$pdf->GetY()+3;
731
+			$posy = $pdf->GetY() + 3;
732 732
 		}
733 733
 
734
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMCOND))
734
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMCOND))
735 735
 		{
736 736
 			// Show payment mode
737 737
 			if ($object->mode_reglement_code
738 738
 			&& $object->mode_reglement_code != 'CHQ'
739 739
 			&& $object->mode_reglement_code != 'VIR')
740 740
 			{
741
-				$pdf->SetFont('','B', $default_font_size - 2);
742
-				$pdf->SetXY($this->marge_gauche, $posy-2);
741
+				$pdf->SetFont('', 'B', $default_font_size - 2);
742
+				$pdf->SetXY($this->marge_gauche, $posy - 2);
743 743
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
744 744
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
745
-				$pdf->SetFont('','', $default_font_size - 2);
746
-				$pdf->SetXY($posxval, $posy-2);
747
-				$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
748
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
745
+				$pdf->SetFont('', '', $default_font_size - 2);
746
+				$pdf->SetXY($posxval, $posy - 2);
747
+				$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
748
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
749 749
 
750
-				$posy=$pdf->GetY()+2;
750
+				$posy = $pdf->GetY() + 2;
751 751
 			}
752 752
 
753 753
 			// Show payment mode CHQ
754 754
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
755 755
 			{
756 756
 				// Si mode reglement non force ou si force a CHQ
757
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
757
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
758 758
 				{
759
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
759
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
760 760
 
761 761
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
762 762
 					{
@@ -764,31 +764,31 @@  discard block
 block discarded – undo
764 764
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
765 765
 
766 766
 						$pdf->SetXY($this->marge_gauche, $posy);
767
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
768
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
769
-						$posy=$pdf->GetY()+1;
767
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
768
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
769
+						$posy = $pdf->GetY() + 1;
770 770
 
771 771
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
772 772
 			            {
773 773
 							$pdf->SetXY($this->marge_gauche, $posy);
774
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
774
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
775 775
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
776
-							$posy=$pdf->GetY()+2;
776
+							$posy = $pdf->GetY() + 2;
777 777
 			            }
778 778
 					}
779 779
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
780 780
 					{
781 781
 						$pdf->SetXY($this->marge_gauche, $posy);
782
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
783
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
784
-						$posy=$pdf->GetY()+1;
782
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
783
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
784
+						$posy = $pdf->GetY() + 1;
785 785
 
786 786
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
787 787
 			            {
788 788
 							$pdf->SetXY($this->marge_gauche, $posy);
789
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
789
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
790 790
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
791
-							$posy=$pdf->GetY()+2;
791
+							$posy = $pdf->GetY() + 2;
792 792
 			            }
793 793
 					}
794 794
 				}
@@ -797,18 +797,18 @@  discard block
 block discarded – undo
797 797
 			// If payment mode not forced or forced to VIR, show payment with BAN
798 798
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
799 799
 			{
800
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
800
+				if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
801 801
 				{
802
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
802
+					$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
803 803
 					$account = new Account($this->db);
804 804
 					$account->fetch($bankid);
805 805
 
806
-					$curx=$this->marge_gauche;
807
-					$cury=$posy;
806
+					$curx = $this->marge_gauche;
807
+					$cury = $posy;
808 808
 
809
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
809
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
810 810
 
811
-					$posy+=2;
811
+					$posy += 2;
812 812
 				}
813 813
 			}
814 814
 		}
@@ -829,40 +829,40 @@  discard block
 block discarded – undo
829 829
 	 */
830 830
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
831 831
 	{
832
-		global $conf,$mysoc;
832
+		global $conf, $mysoc;
833 833
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
834 834
 
835 835
 		$tab2_top = $posy;
836 836
 		$tab2_hl = 4;
837
-		$pdf->SetFont('','', $default_font_size - 1);
837
+		$pdf->SetFont('', '', $default_font_size - 1);
838 838
 
839 839
 		// Tableau total
840 840
 		$col1x = 120; $col2x = 170;
841 841
 		if ($this->page_largeur < 210) // To work with US executive format
842 842
 		{
843
-			$col2x-=20;
843
+			$col2x -= 20;
844 844
 		}
845 845
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
846 846
 
847
-		$useborder=0;
847
+		$useborder = 0;
848 848
 		$index = 0;
849 849
 
850 850
 		// Total HT
851
-		$pdf->SetFillColor(255,255,255);
851
+		$pdf->SetFillColor(255, 255, 255);
852 852
 		$pdf->SetXY($col1x, $tab2_top + 0);
853
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
853
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
854 854
 
855 855
 		$pdf->SetXY($col2x, $tab2_top + 0);
856
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
856
+		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
857 857
 
858 858
 		// Show VAT by rates and total
859
-		$pdf->SetFillColor(248,248,248);
859
+		$pdf->SetFillColor(248, 248, 248);
860 860
 
861
-		$this->atleastoneratenotnull=0;
861
+		$this->atleastoneratenotnull = 0;
862 862
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
863 863
 		{
864
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
865
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
864
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
865
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
866 866
 			{
867 867
 				// Nothing to do
868 868
 			}
@@ -871,28 +871,28 @@  discard block
 block discarded – undo
871 871
 				//Local tax 1 before VAT
872 872
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
873 873
 				//{
874
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
874
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
875 875
 					{
876
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
876
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
877 877
 
878
-						foreach( $localtax_rate as $tvakey => $tvaval )
878
+						foreach ($localtax_rate as $tvakey => $tvaval)
879 879
 						{
880
-							if ($tvakey!=0)    // On affiche pas taux 0
880
+							if ($tvakey != 0)    // On affiche pas taux 0
881 881
 							{
882 882
 								//$this->atleastoneratenotnull++;
883 883
 
884 884
 								$index++;
885 885
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
886 886
 
887
-								$tvacompl='';
888
-								if (preg_match('/\*/',$tvakey))
887
+								$tvacompl = '';
888
+								if (preg_match('/\*/', $tvakey))
889 889
 								{
890
-									$tvakey=str_replace('*','',$tvakey);
890
+									$tvakey = str_replace('*', '', $tvakey);
891 891
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
892 892
 								}
893
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
894
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
895
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
893
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
894
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
895
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
896 896
 
897 897
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
898 898
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -903,13 +903,13 @@  discard block
 block discarded – undo
903 903
 				//Local tax 2 before VAT
904 904
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
905 905
 				//{
906
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
906
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
907 907
 					{
908
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
908
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
909 909
 
910
-						foreach( $localtax_rate as $tvakey => $tvaval )
910
+						foreach ($localtax_rate as $tvakey => $tvaval)
911 911
 						{
912
-							if ($tvakey!=0)    // On affiche pas taux 0
912
+							if ($tvakey != 0)    // On affiche pas taux 0
913 913
 							{
914 914
 								//$this->atleastoneratenotnull++;
915 915
 
@@ -918,15 +918,15 @@  discard block
 block discarded – undo
918 918
 								$index++;
919 919
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
920 920
 
921
-								$tvacompl='';
922
-								if (preg_match('/\*/',$tvakey))
921
+								$tvacompl = '';
922
+								if (preg_match('/\*/', $tvakey))
923 923
 								{
924
-									$tvakey=str_replace('*','',$tvakey);
924
+									$tvakey = str_replace('*', '', $tvakey);
925 925
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
926 926
 								}
927 927
 								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
928
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
929
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
928
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
929
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
930 930
 
931 931
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
932 932
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 					}
937 937
 				//}
938 938
 				// VAT
939
-				foreach($this->tva as $tvakey => $tvaval)
939
+				foreach ($this->tva as $tvakey => $tvaval)
940 940
 				{
941 941
 					if ($tvakey > 0)    // On affiche pas taux 0
942 942
 					{
@@ -945,15 +945,15 @@  discard block
 block discarded – undo
945 945
 						$index++;
946 946
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
947 947
 
948
-						$tvacompl='';
949
-						if (preg_match('/\*/',$tvakey))
948
+						$tvacompl = '';
949
+						if (preg_match('/\*/', $tvakey))
950 950
 						{
951
-							$tvakey=str_replace('*','',$tvakey);
951
+							$tvakey = str_replace('*', '', $tvakey);
952 952
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
953 953
 						}
954
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
955
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
956
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
954
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
955
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
956
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
957 957
 
958 958
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
959 959
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -963,11 +963,11 @@  discard block
 block discarded – undo
963 963
 				//Local tax 1 after VAT
964 964
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
965 965
 				//{
966
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
966
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
967 967
 					{
968
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
968
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
969 969
 
970
-						foreach( $localtax_rate as $tvakey => $tvaval )
970
+						foreach ($localtax_rate as $tvakey => $tvaval)
971 971
 						{
972 972
 							if ($tvakey != 0)    // On affiche pas taux 0
973 973
 							{
@@ -976,16 +976,16 @@  discard block
 block discarded – undo
976 976
 								$index++;
977 977
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
978 978
 
979
-								$tvacompl='';
980
-								if (preg_match('/\*/',$tvakey))
979
+								$tvacompl = '';
980
+								if (preg_match('/\*/', $tvakey))
981 981
 								{
982
-									$tvakey=str_replace('*','',$tvakey);
982
+									$tvakey = str_replace('*', '', $tvakey);
983 983
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
984 984
 								}
985
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
985
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
986 986
 
987
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
988
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
987
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
988
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
989 989
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
990 990
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
991 991
 							}
@@ -995,11 +995,11 @@  discard block
 block discarded – undo
995 995
 				//Local tax 2 after VAT
996 996
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
997 997
 				//{
998
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
998
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
999 999
 					{
1000
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1000
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1001 1001
 
1002
-						foreach( $localtax_rate as $tvakey => $tvaval )
1002
+						foreach ($localtax_rate as $tvakey => $tvaval)
1003 1003
 						{
1004 1004
 						    // retrieve global local tax
1005 1005
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1009,16 +1009,16 @@  discard block
 block discarded – undo
1009 1009
 								$index++;
1010 1010
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1011 1011
 
1012
-								$tvacompl='';
1013
-								if (preg_match('/\*/',$tvakey))
1012
+								$tvacompl = '';
1013
+								if (preg_match('/\*/', $tvakey))
1014 1014
 								{
1015
-									$tvakey=str_replace('*','',$tvakey);
1015
+									$tvakey = str_replace('*', '', $tvakey);
1016 1016
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1017 1017
 								}
1018
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1018
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1019 1019
 
1020
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1021
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1020
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1021
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1022 1022
 
1023 1023
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1024 1024
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1030,16 +1030,16 @@  discard block
 block discarded – undo
1030 1030
 				// Total TTC
1031 1031
 				$index++;
1032 1032
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1033
-				$pdf->SetTextColor(0,0,60);
1034
-				$pdf->SetFillColor(224,224,224);
1035
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1033
+				$pdf->SetTextColor(0, 0, 60);
1034
+				$pdf->SetFillColor(224, 224, 224);
1035
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1036 1036
 
1037 1037
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1038 1038
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1039 1039
 			}
1040 1040
 		}
1041 1041
 
1042
-		$pdf->SetTextColor(0,0,0);
1042
+		$pdf->SetTextColor(0, 0, 0);
1043 1043
 
1044 1044
 		/*
1045 1045
 		$resteapayer = $object->total_ttc - $deja_regle;
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 			$index++;
1052 1052
 
1053 1053
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1054
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1054
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1055 1055
 
1056 1056
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057 1057
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1073,16 +1073,16 @@  discard block
 block discarded – undo
1073 1073
 			*/
1074 1074
 
1075 1075
 			$index++;
1076
-			$pdf->SetTextColor(0,0,60);
1077
-			$pdf->SetFillColor(224,224,224);
1076
+			$pdf->SetTextColor(0, 0, 60);
1077
+			$pdf->SetFillColor(224, 224, 224);
1078 1078
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1079
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1079
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1080 1080
 
1081 1081
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1082 1082
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1083 1083
 
1084
-			$pdf->SetFont('','', $default_font_size - 1);
1085
-			$pdf->SetTextColor(0,0,0);
1084
+			$pdf->SetFont('', '', $default_font_size - 1);
1085
+			$pdf->SetTextColor(0, 0, 0);
1086 1086
 		}
1087 1087
 
1088 1088
 		$index++;
@@ -1102,43 +1102,43 @@  discard block
 block discarded – undo
1102 1102
 	 *   @param		string		$currency		Currency code
1103 1103
 	 *   @return	void
1104 1104
 	 */
1105
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1105
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1106 1106
 	{
1107 1107
 		global $conf;
1108 1108
 
1109 1109
 		// Force to disable hidetop and hidebottom
1110
-		$hidebottom=0;
1111
-		if ($hidetop) $hidetop=-1;
1110
+		$hidebottom = 0;
1111
+		if ($hidetop) $hidetop = -1;
1112 1112
 
1113 1113
 		$currency = !empty($currency) ? $currency : $conf->currency;
1114 1114
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1115 1115
 
1116 1116
 		// Amount in (at tab_top - 1)
1117
-		$pdf->SetTextColor(0,0,0);
1118
-		$pdf->SetFont('','',$default_font_size - 2);
1117
+		$pdf->SetTextColor(0, 0, 0);
1118
+		$pdf->SetFont('', '', $default_font_size - 2);
1119 1119
 
1120 1120
 		if (empty($hidetop))
1121 1121
 		{
1122
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1123
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1122
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1123
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1124 1124
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1125 1125
 
1126 1126
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1127
-			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));
1127
+			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));
1128 1128
 		}
1129 1129
 
1130
-		$pdf->SetDrawColor(128,128,128);
1131
-		$pdf->SetFont('','',$default_font_size - 1);
1130
+		$pdf->SetDrawColor(128, 128, 128);
1131
+		$pdf->SetFont('', '', $default_font_size - 1);
1132 1132
 
1133 1133
 		// Output Rect
1134
-		$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
1134
+		$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
1135 1135
 
1136 1136
 		if (empty($hidetop))
1137 1137
 		{
1138
-			$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
1138
+			$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
1139 1139
 
1140
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1141
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1140
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1141
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1142 1142
 		}
1143 1143
 
1144 1144
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1147,32 +1147,32 @@  discard block
 block discarded – undo
1147 1147
 			//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1148 1148
 			if (empty($hidetop))
1149 1149
 			{
1150
-				$pdf->SetXY($this->posxtva-5, $tab_top+1);
1151
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1150
+				$pdf->SetXY($this->posxtva - 5, $tab_top + 1);
1151
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1152 1152
 			}
1153 1153
 		}
1154 1154
 
1155
-		$pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1155
+		$pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height);
1156 1156
 		if (empty($hidetop))
1157 1157
 		{
1158
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1159
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1158
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1159
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1160 1160
 		}
1161 1161
 
1162
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1162
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1163 1163
 		if (empty($hidetop))
1164 1164
 		{
1165
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1166
-			$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1165
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1166
+			$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1167 1167
 		}
1168 1168
 
1169
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1169
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1170 1170
 		if (empty($hidetop))
1171 1171
 		{
1172 1172
 			if ($this->atleastonediscount)
1173 1173
 			{
1174
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1175
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1174
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1175
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1176 1176
 			}
1177 1177
 		}
1178 1178
 		if ($this->atleastonediscount)
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
 		}
1182 1182
 		if (empty($hidetop))
1183 1183
 		{
1184
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1185
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1184
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1185
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1186 1186
 		}
1187 1187
 	}
1188 1188
 
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1199 1199
 	{
1200
-		global $conf,$langs;
1200
+		global $conf, $langs;
1201 1201
 
1202 1202
 		$outputlangs->load("main");
1203 1203
 		$outputlangs->load("bills");
@@ -1206,67 +1206,67 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1208 1208
 
1209
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1209
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1210 1210
 
1211 1211
 		//  Show Draft Watermark
1212
-		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1212
+		if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)))
1213 1213
 		{
1214
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1214
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1215 1215
 		}
1216 1216
 
1217
-		$pdf->SetTextColor(0,0,60);
1218
-		$pdf->SetFont('','B', $default_font_size + 3);
1217
+		$pdf->SetTextColor(0, 0, 60);
1218
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1219 1219
 
1220
-		$posy=$this->marge_haute;
1221
-		$posx=$this->page_largeur-$this->marge_droite-100;
1220
+		$posy = $this->marge_haute;
1221
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1222 1222
 
1223
-		$pdf->SetXY($this->marge_gauche,$posy);
1223
+		$pdf->SetXY($this->marge_gauche, $posy);
1224 1224
 
1225 1225
 		// Logo
1226
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1226
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1227 1227
 		if ($this->emetteur->logo)
1228 1228
 		{
1229 1229
 			if (is_readable($logo))
1230 1230
 			{
1231
-			    $height=pdf_getHeightForLogo($logo);
1232
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1231
+			    $height = pdf_getHeightForLogo($logo);
1232
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1233 1233
 			}
1234 1234
 			else
1235 1235
 			{
1236
-				$pdf->SetTextColor(200,0,0);
1237
-				$pdf->SetFont('','B',$default_font_size - 2);
1238
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1236
+				$pdf->SetTextColor(200, 0, 0);
1237
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1238
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1239 1239
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1240 1240
 			}
1241 1241
 		}
1242 1242
 		else
1243 1243
 		{
1244
-			$text=$this->emetteur->name;
1244
+			$text = $this->emetteur->name;
1245 1245
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1246 1246
 		}
1247 1247
 
1248
-		$pdf->SetFont('','B',$default_font_size + 3);
1249
-		$pdf->SetXY($posx,$posy);
1250
-		$pdf->SetTextColor(0,0,60);
1251
-		$title=$outputlangs->transnoentities("CommercialAsk");
1248
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1249
+		$pdf->SetXY($posx, $posy);
1250
+		$pdf->SetTextColor(0, 0, 60);
1251
+		$title = $outputlangs->transnoentities("CommercialAsk");
1252 1252
 		$pdf->MultiCell(100, 4, $title, '', 'R');
1253 1253
 
1254
-		$pdf->SetFont('','B',$default_font_size);
1254
+		$pdf->SetFont('', 'B', $default_font_size);
1255 1255
 
1256
-		$posy+=5;
1257
-		$pdf->SetXY($posx,$posy);
1258
-		$pdf->SetTextColor(0,0,60);
1259
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1256
+		$posy += 5;
1257
+		$pdf->SetXY($posx, $posy);
1258
+		$pdf->SetTextColor(0, 0, 60);
1259
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1260 1260
 
1261
-		$posy+=1;
1262
-		$pdf->SetFont('','', $default_font_size - 2);
1261
+		$posy += 1;
1262
+		$pdf->SetFont('', '', $default_font_size - 2);
1263 1263
 
1264 1264
 		if ($object->ref_client)
1265 1265
 		{
1266
-			$posy+=4;
1267
-			$pdf->SetXY($posx,$posy);
1268
-			$pdf->SetTextColor(0,0,60);
1269
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1266
+			$posy += 4;
1267
+			$pdf->SetXY($posx, $posy);
1268
+			$pdf->SetTextColor(0, 0, 60);
1269
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1270 1270
 		}
1271 1271
 /* PHFAVRE
1272 1272
 		$posy+=4;
@@ -1277,28 +1277,28 @@  discard block
 block discarded – undo
1277 1277
 
1278 1278
 		if ($object->thirdparty->code_fournisseur)
1279 1279
 		{
1280
-			$posy+=4;
1281
-			$pdf->SetXY($posx,$posy);
1282
-			$pdf->SetTextColor(0,0,60);
1283
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1280
+			$posy += 4;
1281
+			$pdf->SetXY($posx, $posy);
1282
+			$pdf->SetTextColor(0, 0, 60);
1283
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1284 1284
 		}
1285 1285
 
1286 1286
 		// Get contact
1287 1287
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1288 1288
 		{
1289
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1289
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1290 1290
 		    if (count($arrayidcontact) > 0)
1291 1291
 		    {
1292
-		        $usertmp=new User($this->db);
1292
+		        $usertmp = new User($this->db);
1293 1293
 		        $usertmp->fetch($arrayidcontact[0]);
1294
-                $posy+=4;
1295
-                $pdf->SetXY($posx,$posy);
1296
-		        $pdf->SetTextColor(0,0,60);
1294
+                $posy += 4;
1295
+                $pdf->SetXY($posx, $posy);
1296
+		        $pdf->SetTextColor(0, 0, 60);
1297 1297
 		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1298 1298
 		    }
1299 1299
 		}
1300 1300
 
1301
-		$posy+=2;
1301
+		$posy += 2;
1302 1302
 
1303 1303
 		// Show list of linked objects
1304 1304
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1306,96 +1306,96 @@  discard block
 block discarded – undo
1306 1306
 		if ($showaddress)
1307 1307
 		{
1308 1308
 			// Sender properties
1309
-			$carac_emetteur='';
1309
+			$carac_emetteur = '';
1310 1310
 		 	// Add internal contact of proposal if defined
1311
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1311
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1312 1312
 		 	if (count($arrayidcontact) > 0)
1313 1313
 		 	{
1314 1314
 		 		$object->fetch_user($arrayidcontact[0]);
1315
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1316
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1315
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1316
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1317 1317
 		 	}
1318 1318
 
1319 1319
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1320 1320
 
1321 1321
 			// Show sender
1322
-			$posy=42;
1323
-		 	$posx=$this->marge_gauche;
1324
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1325
-			$hautcadre=40;
1322
+			$posy = 42;
1323
+		 	$posx = $this->marge_gauche;
1324
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1325
+			$hautcadre = 40;
1326 1326
 
1327 1327
 			// Show sender frame
1328
-			$pdf->SetTextColor(0,0,0);
1329
-			$pdf->SetFont('','', $default_font_size - 2);
1330
-			$pdf->SetXY($posx,$posy-5);
1331
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1332
-			$pdf->SetXY($posx,$posy);
1333
-			$pdf->SetFillColor(230,230,230);
1328
+			$pdf->SetTextColor(0, 0, 0);
1329
+			$pdf->SetFont('', '', $default_font_size - 2);
1330
+			$pdf->SetXY($posx, $posy - 5);
1331
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1332
+			$pdf->SetXY($posx, $posy);
1333
+			$pdf->SetFillColor(230, 230, 230);
1334 1334
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1335
-			$pdf->SetTextColor(0,0,60);
1335
+			$pdf->SetTextColor(0, 0, 60);
1336 1336
 
1337 1337
 			// Show sender name
1338
-			$pdf->SetXY($posx+2,$posy+3);
1339
-			$pdf->SetFont('','B', $default_font_size);
1338
+			$pdf->SetXY($posx + 2, $posy + 3);
1339
+			$pdf->SetFont('', 'B', $default_font_size);
1340 1340
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1341
-			$posy=$pdf->getY();
1341
+			$posy = $pdf->getY();
1342 1342
 
1343 1343
 			// Show sender information
1344
-			$pdf->SetXY($posx+2,$posy);
1345
-			$pdf->SetFont('','', $default_font_size - 1);
1344
+			$pdf->SetXY($posx + 2, $posy);
1345
+			$pdf->SetFont('', '', $default_font_size - 1);
1346 1346
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1347 1347
 
1348 1348
 
1349 1349
 			// If CUSTOMER contact defined, we use it
1350
-			$usecontact=false;
1351
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1350
+			$usecontact = false;
1351
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1352 1352
 			if (count($arrayidcontact) > 0)
1353 1353
 			{
1354
-				$usecontact=true;
1355
-				$result=$object->fetch_contact($arrayidcontact[0]);
1354
+				$usecontact = true;
1355
+				$result = $object->fetch_contact($arrayidcontact[0]);
1356 1356
 			}
1357 1357
 
1358 1358
 			// Recipient name
1359
-			if (! empty($usecontact))
1359
+			if (!empty($usecontact))
1360 1360
 			{
1361 1361
 				// On peut utiliser le nom de la societe du contact
1362
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1362
+				if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1363 1363
 				else $socname = $object->thirdparty->name;
1364
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1364
+				$carac_client_name = $outputlangs->convToOutputCharset($socname);
1365 1365
 			}
1366 1366
 			else
1367 1367
 			{
1368
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1368
+				$carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
1369 1369
 			}
1370 1370
 
1371
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1371
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1372 1372
 
1373 1373
 			// Show recipient
1374
-			$widthrecbox=100;
1375
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1376
-			$posy=42;
1377
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1374
+			$widthrecbox = 100;
1375
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1376
+			$posy = 42;
1377
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1378
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1379 1379
 
1380 1380
 			// Show recipient frame
1381
-			$pdf->SetTextColor(0,0,0);
1382
-			$pdf->SetFont('','', $default_font_size - 2);
1383
-			$pdf->SetXY($posx+2,$posy-5);
1381
+			$pdf->SetTextColor(0, 0, 0);
1382
+			$pdf->SetFont('', '', $default_font_size - 2);
1383
+			$pdf->SetXY($posx + 2, $posy - 5);
1384 1384
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1385 1385
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1386 1386
 
1387 1387
 			// Show recipient name
1388
-			$pdf->SetXY($posx+2,$posy+3);
1389
-			$pdf->SetFont('','B', $default_font_size);
1388
+			$pdf->SetXY($posx + 2, $posy + 3);
1389
+			$pdf->SetFont('', 'B', $default_font_size);
1390 1390
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1391 1391
 
1392 1392
 			// Show recipient information
1393
-			$pdf->SetFont('','', $default_font_size - 1);
1394
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1393
+			$pdf->SetFont('', '', $default_font_size - 1);
1394
+			$pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1395 1395
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1396 1396
 		}
1397 1397
 
1398
-		$pdf->SetTextColor(0,0,0);
1398
+		$pdf->SetTextColor(0, 0, 0);
1399 1399
 	}
1400 1400
 
1401 1401
 	/**
@@ -1407,11 +1407,11 @@  discard block
 block discarded – undo
1407 1407
 	 *      @param	int			$hidefreetext		1=Hide free text
1408 1408
 	 *      @return	int								Return height of bottom margin including footer text
1409 1409
 	 */
1410
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1410
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1411 1411
 	{
1412 1412
 		global $conf;
1413
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1414
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1413
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1414
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1415 1415
 	}
1416 1416
 
1417 1417
 }
Please login to merge, or discard this patch.
modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
165 165
    			foreach($listoffiles as $file)
166 166
    			{
167
-                $texte.=$file['name'].'<br>';
167
+				$texte.=$file['name'].'<br>';
168 168
    			}
169 169
    			$texte.='<div id="div_'.get_class($this).'">';
170 170
 
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
290 290
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
291 291
 				{
292
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
293
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
292
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
293
+					if ($format == '1') $format='%Y%m%d%H%M%S';
294 294
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
295 295
 				}
296 296
 				else
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
39 39
 {
40
-	var $emetteur;	// Objet societe qui emet
40
+	var $emetteur; // Objet societe qui emet
41 41
 
42
-	var $phpmin = array(5,2,0);	// Minimum version of PHP required by module
42
+	var $phpmin = array(5, 2, 0); // Minimum version of PHP required by module
43 43
 	var $version = 'dolibarr';
44 44
 
45 45
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct($db)
52 52
 	{
53
-		global $conf,$langs,$mysoc;
53
+		global $conf, $langs, $mysoc;
54 54
 
55 55
 		$langs->load("main");
56 56
 		$langs->load("companies");
@@ -58,32 +58,32 @@  discard block
 block discarded – undo
58 58
 		$this->db = $db;
59 59
 		$this->name = "ODT templates";
60 60
 		$this->description = $langs->trans("DocumentModelOdt");
61
-		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
61
+		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
62 62
 
63 63
 		// Dimension page pour format A4
64 64
 		$this->type = 'odt';
65 65
 		$this->page_largeur = 0;
66 66
 		$this->page_hauteur = 0;
67
-		$this->format = array($this->page_largeur,$this->page_hauteur);
68
-		$this->marge_gauche=0;
69
-		$this->marge_droite=0;
70
-		$this->marge_haute=0;
71
-		$this->marge_basse=0;
72
-
73
-		$this->option_logo = 1;                    // Affiche logo
74
-		$this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
75
-		$this->option_modereg = 0;                 // Affiche mode reglement
76
-		$this->option_condreg = 0;                 // Affiche conditions reglement
77
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
78
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
79
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
80
-		$this->option_credit_note = 0;             // Support credit notes
81
-		$this->option_freetext = 1;				   // Support add of a personalised text
82
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
67
+		$this->format = array($this->page_largeur, $this->page_hauteur);
68
+		$this->marge_gauche = 0;
69
+		$this->marge_droite = 0;
70
+		$this->marge_haute = 0;
71
+		$this->marge_basse = 0;
72
+
73
+		$this->option_logo = 1; // Affiche logo
74
+		$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
75
+		$this->option_modereg = 0; // Affiche mode reglement
76
+		$this->option_condreg = 0; // Affiche conditions reglement
77
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
78
+		$this->option_multilang = 1; // Dispo en plusieurs langues
79
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
80
+		$this->option_credit_note = 0; // Support credit notes
81
+		$this->option_freetext = 1; // Support add of a personalised text
82
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
83 83
 
84 84
 		// Recupere emetteur
85
-		$this->emetteur=$mysoc;
86
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
85
+		$this->emetteur = $mysoc;
86
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
87 87
 	}
88 88
 
89 89
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function info($langs)
97 97
 	{
98
-		global $conf,$langs;
98
+		global $conf, $langs;
99 99
 
100 100
 		$langs->load("companies");
101 101
 		$langs->load("errors");
@@ -103,106 +103,106 @@  discard block
 block discarded – undo
103 103
 		$form = new Form($this->db);
104 104
 
105 105
 		$texte = $this->description.".<br>\n";
106
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
107
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
108
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
109
-		$texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
106
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
107
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
108
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
109
+		$texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
110 110
 		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
111 111
 		{
112
-			$texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
113
-			$texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
114
-			$texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
112
+			$texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
113
+			$texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
114
+			$texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
115 115
 		}
116
-		$texte.= '<table class="nobordernopadding" width="100%">';
116
+		$texte .= '<table class="nobordernopadding" width="100%">';
117 117
 
118 118
 		// List of directories area
119
-		$texte.= '<tr><td>';
120
-		$texttitle=$langs->trans("ListOfDirectories");
121
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
122
-		$listoffiles=array();
123
-		foreach($listofdir as $key=>$tmpdir)
119
+		$texte .= '<tr><td>';
120
+		$texttitle = $langs->trans("ListOfDirectories");
121
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
122
+		$listoffiles = array();
123
+		foreach ($listofdir as $key=>$tmpdir)
124 124
 		{
125
-			$tmpdir=trim($tmpdir);
126
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
127
-			if (! $tmpdir) {
125
+			$tmpdir = trim($tmpdir);
126
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
127
+			if (!$tmpdir) {
128 128
 				unset($listofdir[$key]); continue;
129 129
 			}
130
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
130
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
131 131
 			else
132 132
 			{
133
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
134
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
133
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
134
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
135 135
 			}
136 136
 		}
137
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
137
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
138 138
 		// Add list of substitution keys
139
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
140
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
141
-
142
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
143
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
144
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
145
-		$texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
146
-		$texte.= '</textarea>';
147
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
148
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
149
-		$texte.= '<br></div></div>';
139
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
140
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
141
+
142
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
143
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
144
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
145
+		$texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
146
+		$texte .= '</textarea>';
147
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
148
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
149
+		$texte .= '<br></div></div>';
150 150
 
151 151
 		// Scan directories
152
-		$nbofiles=count($listoffiles);
153
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
152
+		$nbofiles = count($listoffiles);
153
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
154 154
 		{
155
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
155
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
156 156
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
157
-			$texte.=count($listoffiles);
157
+			$texte .= count($listoffiles);
158 158
 			//$texte.=$nbofiles?'</a>':'';
159
-			$texte.='</b>';
159
+			$texte .= '</b>';
160 160
 		}
161 161
 
162 162
 		if ($nbofiles)
163 163
 		{
164
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
165
-   			foreach($listoffiles as $file)
164
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
165
+   			foreach ($listoffiles as $file)
166 166
    			{
167
-                $texte.=$file['name'].'<br>';
167
+                $texte .= $file['name'].'<br>';
168 168
    			}
169
-   			$texte.='<div id="div_'.get_class($this).'">';
169
+   			$texte .= '<div id="div_'.get_class($this).'">';
170 170
 
171 171
 			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
172 172
 			{
173 173
 				// Model for creation
174
-				$liste=ModelePDFSupplierProposal::liste_modeles($this->db);
175
-				$texte.= '<table width="50%;">';
176
-				$texte.= '<tr>';
177
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
178
-				$texte.= '<td colspan="">';
179
-				$texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
180
-				$texte.= "</td></tr>";
181
-
182
-				$texte.= '<tr>';
183
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
184
-				$texte.= '<td colspan="">';
185
-				$texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
186
-				$texte.= "</td></tr>";
187
-				$texte.= '<tr>';
188
-
189
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
190
-				$texte.= '<td colspan="">';
191
-				$texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
192
-				$texte.= "</td></tr>";
193
-				$texte.= '</table>';
174
+				$liste = ModelePDFSupplierProposal::liste_modeles($this->db);
175
+				$texte .= '<table width="50%;">';
176
+				$texte .= '<tr>';
177
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
178
+				$texte .= '<td colspan="">';
179
+				$texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
180
+				$texte .= "</td></tr>";
181
+
182
+				$texte .= '<tr>';
183
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
184
+				$texte .= '<td colspan="">';
185
+				$texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
186
+				$texte .= "</td></tr>";
187
+				$texte .= '<tr>';
188
+
189
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
190
+				$texte .= '<td colspan="">';
191
+				$texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
192
+				$texte .= "</td></tr>";
193
+				$texte .= '</table>';
194 194
 			}
195 195
 		}
196 196
 
197
-		$texte.= '</td>';
197
+		$texte .= '</td>';
198 198
 
199
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
200
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
201
-		$texte.= '</td>';
202
-		$texte.= '</tr>';
199
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
200
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
201
+		$texte .= '</td>';
202
+		$texte .= '</tr>';
203 203
 
204
-		$texte.= '</table>';
205
-		$texte.= '</form>';
204
+		$texte .= '</table>';
205
+		$texte .= '</form>';
206 206
 
207 207
 		return $texte;
208 208
 	}
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	 *  @param		int			$hideref			Do not show ref
219 219
 	 *	@return		int         					1 if OK, <=0 if KO
220 220
 	 */
221
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
221
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
222 222
 	{
223
-		global $user,$langs,$conf,$mysoc,$hookmanager;
223
+		global $user, $langs, $conf, $mysoc, $hookmanager;
224 224
 
225 225
 		if (empty($srctemplatepath))
226 226
 		{
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		}
230 230
 
231 231
 		// Add odtgeneration hook
232
-		if (! is_object($hookmanager))
232
+		if (!is_object($hookmanager))
233 233
 		{
234 234
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
235
-			$hookmanager=new HookManager($this->db);
235
+			$hookmanager = new HookManager($this->db);
236 236
 		}
237 237
 		$hookmanager->initHooks(array('odtgeneration'));
238 238
 		global $action;
239 239
 
240
-		if (! is_object($outputlangs)) $outputlangs=$langs;
241
-		$sav_charset_output=$outputlangs->charset_output;
242
-		$outputlangs->charset_output='UTF-8';
240
+		if (!is_object($outputlangs)) $outputlangs = $langs;
241
+		$sav_charset_output = $outputlangs->charset_output;
242
+		$outputlangs->charset_output = 'UTF-8';
243 243
 
244 244
 		$outputlangs->load("main");
245 245
 		$outputlangs->load("dict");
@@ -249,28 +249,28 @@  discard block
 block discarded – undo
249 249
 		if ($conf->supplier_proposal->dir_output)
250 250
 		{
251 251
 			// If $object is id instead of object
252
-			if (! is_object($object))
252
+			if (!is_object($object))
253 253
 			{
254 254
 				$id = $object;
255 255
 				$object = new SupplierProposal($this->db);
256
-				$result=$object->fetch($id);
256
+				$result = $object->fetch($id);
257 257
 				if ($result < 0)
258 258
 				{
259
-					dol_print_error($this->db,$object->error);
259
+					dol_print_error($this->db, $object->error);
260 260
 					return -1;
261 261
 				}
262 262
 			}
263 263
 
264 264
 			$dir = $conf->supplier_proposal->dir_output;
265 265
 			$objectref = dol_sanitizeFileName($object->ref);
266
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
267
-			$file = $dir . "/" . $objectref . ".odt";
266
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
267
+			$file = $dir."/".$objectref.".odt";
268 268
 
269
-			if (! file_exists($dir))
269
+			if (!file_exists($dir))
270 270
 			{
271 271
 				if (dol_mkdir($dir) < 0)
272 272
 				{
273
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
273
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
274 274
 					return -1;
275 275
 				}
276 276
 			}
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			if (file_exists($dir))
279 279
 			{
280 280
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
281
-				$newfile=basename($srctemplatepath);
282
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
283
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
284
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
281
+				$newfile = basename($srctemplatepath);
282
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
283
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
284
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
285 285
 
286
-				$newfiletmp=$objectref.'_'.$newfiletmp;
286
+				$newfiletmp = $objectref.'_'.$newfiletmp;
287 287
 
288 288
 				// Get extension (ods or odt)
289
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
290
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
289
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
290
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
291 291
 				{
292
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
293
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
294
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
292
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
293
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
294
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
295 295
 				}
296 296
 				else
297 297
 				{
298
-					$filename=$newfiletmp.'.'.$newfileformat;
298
+					$filename = $newfiletmp.'.'.$newfileformat;
299 299
 				}
300
-				$file=$dir.'/'.$filename;
300
+				$file = $dir.'/'.$filename;
301 301
 				//print "newdir=".$dir;
302 302
 				//print "newfile=".$newfile;
303 303
 				//print "file=".$file;
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
 
308 308
 
309 309
 				// If BILLING contact defined on invoice, we use it
310
-				$usecontact=false;
311
-				$arrayidcontact=$object->getIdContact('external','BILLING');
310
+				$usecontact = false;
311
+				$arrayidcontact = $object->getIdContact('external', 'BILLING');
312 312
 				if (count($arrayidcontact) > 0)
313 313
 				{
314
-					$usecontact=true;
315
-					$result=$object->fetch_contact($arrayidcontact[0]);
314
+					$usecontact = true;
315
+					$result = $object->fetch_contact($arrayidcontact[0]);
316 316
 				}
317 317
 
318 318
 				// Recipient name
319
-				if (! empty($usecontact))
319
+				if (!empty($usecontact))
320 320
 				{
321 321
 					// On peut utiliser le nom de la societe du contact
322
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
322
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
323 323
 					else $socobject = $object->thirdparty;
324 324
 				}
325 325
 				else
326 326
 				{
327
-					$socobject=$object->thirdparty;
327
+					$socobject = $object->thirdparty;
328 328
 				}
329 329
 
330 330
 				// Make substitution
331
-				$substitutionarray=array(
331
+				$substitutionarray = array(
332 332
 				'__FROM_NAME__' => $this->emetteur->name,
333 333
 				'__FROM_EMAIL__' => $this->emetteur->email,
334 334
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 				);
338 338
 				complete_substitutions_array($substitutionarray, $langs, $object);
339 339
 				// Call the ODTSubstitution hook
340
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
341
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
340
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
341
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
342 342
 
343 343
 				// Line of free text
344
-				$newfreetext='';
345
-				$paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
346
-				if (! empty($conf->global->$paramfreetext))
344
+				$newfreetext = '';
345
+				$paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT';
346
+				if (!empty($conf->global->$paramfreetext))
347 347
 				{
348
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
348
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
349 349
 				}
350 350
 
351 351
 				// Open and load template
@@ -355,15 +355,15 @@  discard block
 block discarded – undo
355 355
 						$srctemplatepath,
356 356
 						array(
357 357
 						'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
358
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
358
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
359 359
 						'DELIMITER_LEFT'  => '{',
360 360
 						'DELIMITER_RIGHT' => '}'
361 361
 						)
362 362
 					);
363 363
 				}
364
-				catch(Exception $e)
364
+				catch (Exception $e)
365 365
 				{
366
-					$this->error=$e->getMessage();
366
+					$this->error = $e->getMessage();
367 367
 					return -1;
368 368
 				}
369 369
 				// After construction $odfHandler->contentXml contains content and
@@ -377,26 +377,26 @@  discard block
 block discarded – undo
377 377
 				try {
378 378
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
379 379
 				}
380
-				catch(OdfException $e)
380
+				catch (OdfException $e)
381 381
 				{
382 382
 				}
383 383
 
384 384
 				// Make substitutions into odt
385
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
386
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
387
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
388
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
389
-				$array_other=$this->get_substitutionarray_other($outputlangs);
385
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
386
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
387
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
388
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
389
+				$array_other = $this->get_substitutionarray_other($outputlangs);
390 390
 
391
-				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
391
+				$tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
392 392
 				complete_substitutions_array($tmparray, $outputlangs, $object);
393 393
 				// Call the ODTSubstitution hook
394
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
395
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
396
-				foreach($tmparray as $key=>$value)
394
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
395
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
396
+				foreach ($tmparray as $key=>$value)
397 397
 				{
398 398
 					try {
399
-						if (preg_match('/logo$/',$key)) // Image
399
+						if (preg_match('/logo$/', $key)) // Image
400 400
 						{
401 401
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
402 402
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
407 407
 						}
408 408
 					}
409
-					catch(OdfException $e)
409
+					catch (OdfException $e)
410 410
 					{
411 411
 					}
412 412
 				}
@@ -416,21 +416,21 @@  discard block
 block discarded – undo
416 416
 					$listlines = $odfHandler->setSegment('lines');
417 417
 					foreach ($object->lines as $line)
418 418
 					{
419
-						$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
419
+						$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
420 420
 						complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
421 421
 						// Call the ODTSubstitutionLine hook
422
-						$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
423
-						$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
424
-						foreach($tmparray as $key => $val)
422
+						$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
423
+						$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
424
+						foreach ($tmparray as $key => $val)
425 425
 						{
426 426
 							try
427 427
 							{
428 428
 								$listlines->setVars($key, $val, true, 'UTF-8');
429 429
 							}
430
-							catch(OdfException $e)
430
+							catch (OdfException $e)
431 431
 							{
432 432
 							}
433
-							catch(SegmentException $e)
433
+							catch (SegmentException $e)
434 434
 							{
435 435
 							}
436 436
 						}
@@ -438,61 +438,61 @@  discard block
 block discarded – undo
438 438
 					}
439 439
 					$odfHandler->mergeSegment($listlines);
440 440
 				}
441
-				catch(OdfException $e)
441
+				catch (OdfException $e)
442 442
 				{
443
-					$this->error=$e->getMessage();
443
+					$this->error = $e->getMessage();
444 444
 					dol_syslog($this->error, LOG_WARNING);
445 445
 					return -1;
446 446
 				}
447 447
 
448 448
 				// Replace labels translated
449
-				$tmparray=$outputlangs->get_translations_for_substitutions();
450
-				foreach($tmparray as $key=>$value)
449
+				$tmparray = $outputlangs->get_translations_for_substitutions();
450
+				foreach ($tmparray as $key=>$value)
451 451
 				{
452 452
 					try {
453 453
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
454 454
 					}
455
-					catch(OdfException $e)
455
+					catch (OdfException $e)
456 456
 					{
457 457
 					}
458 458
 				}
459 459
 
460 460
 				// Call the beforeODTSave hook
461
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
462
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
462
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
463 463
 
464 464
 				// Write new file
465 465
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
466 466
 					try {
467 467
 						$odfHandler->exportAsAttachedPDF($file);
468
-					}catch (Exception $e){
469
-						$this->error=$e->getMessage();
468
+					} catch (Exception $e) {
469
+						$this->error = $e->getMessage();
470 470
 						return -1;
471 471
 					}
472 472
 				}
473 473
 				else {
474 474
 					try {
475 475
 					$odfHandler->saveToDisk($file);
476
-					}catch (Exception $e){
477
-						$this->error=$e->getMessage();
476
+					} catch (Exception $e) {
477
+						$this->error = $e->getMessage();
478 478
 						return -1;
479 479
 					}
480 480
 				}
481
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
482
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
481
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
482
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
483 483
 
484
-				if (! empty($conf->global->MAIN_UMASK))
484
+				if (!empty($conf->global->MAIN_UMASK))
485 485
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
486 486
 
487
-				$odfHandler=null;	// Destroy object
487
+				$odfHandler = null; // Destroy object
488 488
 
489 489
 				$this->result = array('fullpath'=>$file);
490 490
 				
491
-				return 1;   // Success
491
+				return 1; // Success
492 492
 			}
493 493
 			else
494 494
 			{
495
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
495
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
496 496
 				return -1;
497 497
 			}
498 498
 		}
Please login to merge, or discard this patch.
Braces   +46 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,7 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
 		// Recupere emetteur
85 85
 		$this->emetteur=$mysoc;
86
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
86
+		if (! $this->emetteur->country_code) {
87
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
88
+		}
89
+		// By default if not defined
87 90
 	}
88 91
 
89 92
 
@@ -127,11 +130,14 @@  discard block
 block discarded – undo
127 130
 			if (! $tmpdir) {
128 131
 				unset($listofdir[$key]); continue;
129 132
 			}
130
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
131
-			else
133
+			if (! is_dir($tmpdir)) {
134
+				$texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
135
+			} else
132 136
 			{
133 137
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
134
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
138
+				if (count($tmpfiles)) {
139
+					$listoffiles=array_merge($listoffiles,$tmpfiles);
140
+				}
135 141
 			}
136 142
 		}
137 143
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -237,7 +243,9 @@  discard block
 block discarded – undo
237 243
 		$hookmanager->initHooks(array('odtgeneration'));
238 244
 		global $action;
239 245
 
240
-		if (! is_object($outputlangs)) $outputlangs=$langs;
246
+		if (! is_object($outputlangs)) {
247
+			$outputlangs=$langs;
248
+		}
241 249
 		$sav_charset_output=$outputlangs->charset_output;
242 250
 		$outputlangs->charset_output='UTF-8';
243 251
 
@@ -263,7 +271,9 @@  discard block
 block discarded – undo
263 271
 
264 272
 			$dir = $conf->supplier_proposal->dir_output;
265 273
 			$objectref = dol_sanitizeFileName($object->ref);
266
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
274
+			if (! preg_match('/specimen/i',$objectref)) {
275
+				$dir.= "/" . $objectref;
276
+			}
267 277
 			$file = $dir . "/" . $objectref . ".odt";
268 278
 
269 279
 			if (! file_exists($dir))
@@ -290,10 +300,11 @@  discard block
 block discarded – undo
290 300
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
291 301
 				{
292 302
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
293
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
303
+				    if ($format == '1') {
304
+				    	$format='%Y%m%d%H%M%S';
305
+				    }
294 306
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
295
-				}
296
-				else
307
+				} else
297 308
 				{
298 309
 					$filename=$newfiletmp.'.'.$newfileformat;
299 310
 				}
@@ -319,10 +330,12 @@  discard block
 block discarded – undo
319 330
 				if (! empty($usecontact))
320 331
 				{
321 332
 					// On peut utiliser le nom de la societe du contact
322
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
323
-					else $socobject = $object->thirdparty;
324
-				}
325
-				else
333
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
334
+						$socobject = $object->contact;
335
+					} else {
336
+						$socobject = $object->thirdparty;
337
+					}
338
+				} else
326 339
 				{
327 340
 					$socobject=$object->thirdparty;
328 341
 				}
@@ -360,8 +373,7 @@  discard block
 block discarded – undo
360 373
 						'DELIMITER_RIGHT' => '}'
361 374
 						)
362 375
 					);
363
-				}
364
-				catch(Exception $e)
376
+				} catch(Exception $e)
365 377
 				{
366 378
 					$this->error=$e->getMessage();
367 379
 					return -1;
@@ -376,8 +388,7 @@  discard block
 block discarded – undo
376 388
 				// Make substitutions into odt of freetext
377 389
 				try {
378 390
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
379
-				}
380
-				catch(OdfException $e)
391
+				} catch(OdfException $e)
381 392
 				{
382 393
 				}
383 394
 
@@ -396,17 +407,18 @@  discard block
 block discarded – undo
396 407
 				foreach($tmparray as $key=>$value)
397 408
 				{
398 409
 					try {
399
-						if (preg_match('/logo$/',$key)) // Image
410
+						if (preg_match('/logo$/',$key)) {
411
+							// Image
400 412
 						{
401 413
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
402
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
403
-						}
404
-						else    // Text
414
+						} else {
415
+								$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
416
+							}
417
+						} else    // Text
405 418
 						{
406 419
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
407 420
 						}
408
-					}
409
-					catch(OdfException $e)
421
+					} catch(OdfException $e)
410 422
 					{
411 423
 					}
412 424
 				}
@@ -426,19 +438,16 @@  discard block
 block discarded – undo
426 438
 							try
427 439
 							{
428 440
 								$listlines->setVars($key, $val, true, 'UTF-8');
429
-							}
430
-							catch(OdfException $e)
441
+							} catch(OdfException $e)
431 442
 							{
432
-							}
433
-							catch(SegmentException $e)
443
+							} catch(SegmentException $e)
434 444
 							{
435 445
 							}
436 446
 						}
437 447
 						$listlines->merge();
438 448
 					}
439 449
 					$odfHandler->mergeSegment($listlines);
440
-				}
441
-				catch(OdfException $e)
450
+				} catch(OdfException $e)
442 451
 				{
443 452
 					$this->error=$e->getMessage();
444 453
 					dol_syslog($this->error, LOG_WARNING);
@@ -451,8 +460,7 @@  discard block
 block discarded – undo
451 460
 				{
452 461
 					try {
453 462
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
454
-					}
455
-					catch(OdfException $e)
463
+					} catch(OdfException $e)
456 464
 					{
457 465
 					}
458 466
 				}
@@ -465,15 +473,14 @@  discard block
 block discarded – undo
465 473
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
466 474
 					try {
467 475
 						$odfHandler->exportAsAttachedPDF($file);
468
-					}catch (Exception $e){
476
+					} catch (Exception $e){
469 477
 						$this->error=$e->getMessage();
470 478
 						return -1;
471 479
 					}
472
-				}
473
-				else {
480
+				} else {
474 481
 					try {
475 482
 					$odfHandler->saveToDisk($file);
476
-					}catch (Exception $e){
483
+					} catch (Exception $e){
477 484
 						$this->error=$e->getMessage();
478 485
 						return -1;
479 486
 					}
@@ -481,16 +488,16 @@  discard block
 block discarded – undo
481 488
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
482 489
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
483 490
 
484
-				if (! empty($conf->global->MAIN_UMASK))
485
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
491
+				if (! empty($conf->global->MAIN_UMASK)) {
492
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
493
+				}
486 494
 
487 495
 				$odfHandler=null;	// Destroy object
488 496
 
489 497
 				$this->result = array('fullpath'=>$file);
490 498
 				
491 499
 				return 1;   // Success
492
-			}
493
-			else
500
+			} else
494 501
 			{
495 502
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
496 503
 				return -1;
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php 3 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';   // Requis car utilise dans les classes qui heritent
31
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
32 32
 
33 33
 
34 34
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePDFSupplierProposal extends CommonDocGenerator
38 38
 {
39
-	var $error='';
39
+	var $error = '';
40 40
 
41 41
 
42 42
 	/**
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
 	 */
49
-	static function liste_modeles($db,$maxfilenamelength=0)
49
+	static function liste_modeles($db, $maxfilenamelength = 0)
50 50
 	{
51 51
 		global $conf;
52 52
 
53
-		$type='supplier_proposal';
54
-		$liste=array();
53
+		$type = 'supplier_proposal';
54
+		$liste = array();
55 55
 
56 56
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
58 58
 
59 59
 		return $liste;
60 60
 	}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
  */
67 67
 abstract class ModeleNumRefSupplierProposal
68 68
 {
69
-	var $error='';
69
+	var $error = '';
70 70
 
71 71
 	/**
72 72
 	 * Return if a module can be used or not
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 *	@param		Propal		$propal		Object commercial proposal
121 121
 	 *	@return     string      Valeur
122 122
 	 */
123
-	function getNextValue($objsoc,$propal)
123
+	function getNextValue($objsoc, $propal)
124 124
 	{
125 125
 		global $langs;
126 126
 		return $langs->trans("NotAvailable");
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@
 block discarded – undo
37 37
 	/**
38 38
 	 *  Return list of active generation modules
39 39
 	 *
40
-     *  @param	DoliDB	$db     			Database handler
41
-     *  @param  integer	$maxfilenamelength  Max length of value to show
42
-     *  @return	array						List of templates
40
+	 *  @param	DoliDB	$db     			Database handler
41
+	 *  @param  integer	$maxfilenamelength  Max length of value to show
42
+	 *  @return	array						List of templates
43 43
 	 */
44 44
 	static function liste_modeles($db,$maxfilenamelength=0)
45 45
 	{
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,18 @@
 block discarded – undo
92 92
 		global $langs;
93 93
 		$langs->load("admin");
94 94
 
95
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
96
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
97
-		if ($this->version == 'dolibarr') return DOL_VERSION;
98
-		if ($this->version) return $this->version;
95
+		if ($this->version == 'development') {
96
+			return $langs->trans("VersionDevelopment");
97
+		}
98
+		if ($this->version == 'experimental') {
99
+			return $langs->trans("VersionExperimental");
100
+		}
101
+		if ($this->version == 'dolibarr') {
102
+			return DOL_VERSION;
103
+		}
104
+		if ($this->version) {
105
+			return $this->version;
106
+		}
99 107
 		return $langs->trans("NotAvailable");
100 108
 	}
101 109
 }
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	var $nom = 'Saphir';
39 39
 
40 40
 
41
-    /**
42
-     *  Return description of module
43
-     *
44
-     *  @return     string      Texte descripif
45
-     */
41
+	/**
42
+	 *  Return description of module
43
+	 *
44
+	 *  @return     string      Texte descripif
45
+	 */
46 46
 	function info()
47
-    {
48
-    	global $conf,$langs;
47
+	{
48
+		global $conf,$langs;
49 49
 
50 50
 		$langs->load("bills");
51 51
 
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
 		$texte.= '</form>';
77 77
 
78 78
 		return $texte;
79
-    }
80
-
81
-    /**
82
-     *  Renvoi un exemple de numerotation
83
-     *
84
-     *  @return     string      Example
85
-     */
86
-    function getExample()
87
-    {
88
-     	global $conf,$langs,$mysoc;
89
-
90
-    	$old_code_client=$mysoc->code_client;
91
-    	$mysoc->code_client='CCCCCCCCCC';
92
-     	$numExample = $this->getNextValue($mysoc,'');
79
+	}
80
+
81
+	/**
82
+	 *  Renvoi un exemple de numerotation
83
+	 *
84
+	 *  @return     string      Example
85
+	 */
86
+	function getExample()
87
+	{
88
+	 	global $conf,$langs,$mysoc;
89
+
90
+		$old_code_client=$mysoc->code_client;
91
+		$mysoc->code_client='CCCCCCCCCC';
92
+	 	$numExample = $this->getNextValue($mysoc,'');
93 93
 		$mysoc->code_client=$old_code_client;
94 94
 
95 95
 		if (! $numExample)
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			$numExample = 'NotConfigured';
98 98
 		}
99 99
 		return $numExample;
100
-    }
100
+	}
101 101
 
102 102
 	/**
103 103
 	 *  Return next value
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * \brief      File that contains the numbering module rules Saphir
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplier_proposal.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
29 29
 
30 30
 
31 31
 /**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
35 35
 {
36
-	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
36
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
37 37
 	var $error = '';
38 38
 	var $nom = 'Saphir';
39 39
 
@@ -45,35 +45,35 @@  discard block
 block discarded – undo
45 45
      */
46 46
 	function info()
47 47
     {
48
-    	global $conf,$langs;
48
+    	global $conf, $langs;
49 49
 
50 50
 		$langs->load("bills");
51 51
 
52 52
 		$form = new Form($this->db);
53 53
 
54 54
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
55
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
56
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
57
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
58
-		$texte.= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
59
-		$texte.= '<table class="nobordernopadding" width="100%">';
60
-
61
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
62
-		$tooltip.=$langs->trans("GenericMaskCodes2");
63
-		$tooltip.=$langs->trans("GenericMaskCodes3");
64
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
65
-		$tooltip.=$langs->trans("GenericMaskCodes5");
55
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
56
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
57
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
58
+		$texte .= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
59
+		$texte .= '<table class="nobordernopadding" width="100%">';
60
+
61
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CommRequest"), $langs->transnoentities("CommRequest"));
62
+		$tooltip .= $langs->trans("GenericMaskCodes2");
63
+		$tooltip .= $langs->trans("GenericMaskCodes3");
64
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CommRequest"), $langs->transnoentities("CommRequest"));
65
+		$tooltip .= $langs->trans("GenericMaskCodes5");
66 66
 
67 67
 		// Parametrage du prefix
68
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
69
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
68
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
69
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
70 70
 
71
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
71
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
72 72
 
73
-		$texte.= '</tr>';
73
+		$texte .= '</tr>';
74 74
 
75
-		$texte.= '</table>';
76
-		$texte.= '</form>';
75
+		$texte .= '</table>';
76
+		$texte .= '</form>';
77 77
 
78 78
 		return $texte;
79 79
     }
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
      */
86 86
     function getExample()
87 87
     {
88
-     	global $conf,$langs,$mysoc;
88
+     	global $conf, $langs, $mysoc;
89 89
 
90
-    	$old_code_client=$mysoc->code_client;
91
-    	$mysoc->code_client='CCCCCCCCCC';
92
-     	$numExample = $this->getNextValue($mysoc,'');
93
-		$mysoc->code_client=$old_code_client;
90
+    	$old_code_client = $mysoc->code_client;
91
+    	$mysoc->code_client = 'CCCCCCCCCC';
92
+     	$numExample = $this->getNextValue($mysoc, '');
93
+		$mysoc->code_client = $old_code_client;
94 94
 
95
-		if (! $numExample)
95
+		if (!$numExample)
96 96
 		{
97 97
 			$numExample = 'NotConfigured';
98 98
 		}
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
 	 * 	@param	Propal		$supplier_proposal	Object supplier_proposal
107 107
 	 *  @return string      					Value if OK, 0 if KO
108 108
 	 */
109
-	function getNextValue($objsoc,$supplier_proposal)
109
+	function getNextValue($objsoc, $supplier_proposal)
110 110
 	{
111
-		global $db,$conf;
111
+		global $db, $conf;
112 112
 
113
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
113
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
114 114
 
115 115
 		// On defini critere recherche compteur
116
-		$mask=$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
116
+		$mask = $conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
117 117
 
118
-		if (! $mask)
118
+		if (!$mask)
119 119
 		{
120
-			$this->error='NotConfigured';
120
+			$this->error = 'NotConfigured';
121 121
 			return 0;
122 122
 		}
123 123
 
124
-		$date=$supplier_proposal->datep;
125
-		$customercode=$objsoc->code_client;
126
-		$numFinal=get_next_value($db,$mask,'supplier_proposal','ref','',$customercode,$date);
124
+		$date = $supplier_proposal->datep;
125
+		$customercode = $objsoc->code_client;
126
+		$numFinal = get_next_value($db, $mask, 'supplier_proposal', 'ref', '', $customercode, $date);
127 127
 
128 128
 		return  $numFinal;
129 129
 	}
Please login to merge, or discard this patch.