Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/modCommande.class.php 3 patches
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -38,259 +38,259 @@
 block discarded – undo
38 38
 class modCommande extends DolibarrModules
39 39
 {
40 40
 
41
-	/**
42
-	 *   Constructor. Define names, constants, directories, boxes, permissions
43
-	 *
44
-	 *   @param      DoliDB		$db      Database handler
45
-	 */
46
-	function __construct($db)
47
-	{
48
-		global $conf, $user;
49
-
50
-		$this->db = $db;
51
-		$this->numero = 25;
52
-
53
-		$this->family = "crm";
54
-		$this->module_position = '30';
55
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56
-		$this->name = preg_replace('/^mod/i','',get_class($this));
57
-		$this->description = "Gestion des commandes clients";
58
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
-		$this->version = 'dolibarr';
60
-
61
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		$this->picto='order';
63
-
64
-		// Data directories to create when module is enabled
65
-		$this->dirs = array("/commande/temp");
66
-
67
-		// Config pages
68
-		$this->config_page_url = array("commande.php");
69
-
70
-		// Dependancies
71
-		$this->depends = array("modSociete");
72
-		$this->requiredby = array("modExpedition");
73
-		$this->conflictwith = array();
74
-		$this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings');
75
-
76
-		// Constants
77
-		$this->const = array();
78
-		$r=0;
79
-
80
-		$this->const[$r][0] = "COMMANDE_ADDON_PDF";
81
-		$this->const[$r][1] = "chaine";
82
-		$this->const[$r][2] = "einstein";
83
-		$this->const[$r][3] = 'Name of PDF model of order';
84
-		$this->const[$r][4] = 0;
85
-
86
-		$r++;
87
-		$this->const[$r][0] = "COMMANDE_ADDON";
88
-		$this->const[$r][1] = "chaine";
89
-		$this->const[$r][2] = "mod_commande_marbre";
90
-		$this->const[$r][3] = 'Name of numbering numerotation rules of order';
91
-		$this->const[$r][4] = 0;
92
-
93
-		$r++;
94
-		$this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH";
95
-		$this->const[$r][1] = "chaine";
96
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/orders";
97
-		$this->const[$r][3] = "";
98
-		$this->const[$r][4] = 0;
99
-
100
-		/*$r++;
41
+    /**
42
+     *   Constructor. Define names, constants, directories, boxes, permissions
43
+     *
44
+     *   @param      DoliDB		$db      Database handler
45
+     */
46
+    function __construct($db)
47
+    {
48
+        global $conf, $user;
49
+
50
+        $this->db = $db;
51
+        $this->numero = 25;
52
+
53
+        $this->family = "crm";
54
+        $this->module_position = '30';
55
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56
+        $this->name = preg_replace('/^mod/i','',get_class($this));
57
+        $this->description = "Gestion des commandes clients";
58
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
+        $this->version = 'dolibarr';
60
+
61
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
+        $this->picto='order';
63
+
64
+        // Data directories to create when module is enabled
65
+        $this->dirs = array("/commande/temp");
66
+
67
+        // Config pages
68
+        $this->config_page_url = array("commande.php");
69
+
70
+        // Dependancies
71
+        $this->depends = array("modSociete");
72
+        $this->requiredby = array("modExpedition");
73
+        $this->conflictwith = array();
74
+        $this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings');
75
+
76
+        // Constants
77
+        $this->const = array();
78
+        $r=0;
79
+
80
+        $this->const[$r][0] = "COMMANDE_ADDON_PDF";
81
+        $this->const[$r][1] = "chaine";
82
+        $this->const[$r][2] = "einstein";
83
+        $this->const[$r][3] = 'Name of PDF model of order';
84
+        $this->const[$r][4] = 0;
85
+
86
+        $r++;
87
+        $this->const[$r][0] = "COMMANDE_ADDON";
88
+        $this->const[$r][1] = "chaine";
89
+        $this->const[$r][2] = "mod_commande_marbre";
90
+        $this->const[$r][3] = 'Name of numbering numerotation rules of order';
91
+        $this->const[$r][4] = 0;
92
+
93
+        $r++;
94
+        $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH";
95
+        $this->const[$r][1] = "chaine";
96
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/orders";
97
+        $this->const[$r][3] = "";
98
+        $this->const[$r][4] = 0;
99
+
100
+        /*$r++;
101 101
 		$this->const[$r][0] = "COMMANDE_DRAFT_WATERMARK";
102 102
 		$this->const[$r][1] = "chaine";
103 103
 		$this->const[$r][2] = "__(Draft)__";
104 104
 		$this->const[$r][3] = 'Watermark to show on draft orders';
105 105
 		$this->const[$r][4] = 0;*/
106 106
 
107
-		// Boxes
108
-		$this->boxes = array(
109
-			0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),
110
-			2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')
111
-		);
112
-
113
-		// Permissions
114
-		$this->rights = array();
115
-		$this->rights_class = 'commande';
116
-
117
-		$r=0;
118
-
119
-		$r++;
120
-		$this->rights[$r][0] = 81;
121
-		$this->rights[$r][1] = 'Lire les commandes clients';
122
-		$this->rights[$r][2] = 'r';
123
-		$this->rights[$r][3] = 0;
124
-		$this->rights[$r][4] = 'lire';
125
-
126
-		$r++;
127
-		$this->rights[$r][0] = 82;
128
-		$this->rights[$r][1] = 'Creer/modifier les commandes clients';
129
-		$this->rights[$r][2] = 'w';
130
-		$this->rights[$r][3] = 0;
131
-		$this->rights[$r][4] = 'creer';
132
-
133
-		$r++;
134
-		$this->rights[$r][0] = 84;
135
-		$this->rights[$r][1] = 'Valider les commandes clients';
136
-		$this->rights[$r][2] = 'd';
137
-		$this->rights[$r][3] = 0;
138
-		$this->rights[$r][4] = 'order_advance';
139
-		$this->rights[$r][5] = 'validate';
140
-
141
-		$r++;
142
-		$this->rights[$r][0] = 86;
143
-		$this->rights[$r][1] = 'Envoyer les commandes clients';
144
-		$this->rights[$r][2] = 'd';
145
-		$this->rights[$r][3] = 0;
146
-		$this->rights[$r][4] = 'order_advance';
107
+        // Boxes
108
+        $this->boxes = array(
109
+            0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),
110
+            2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')
111
+        );
112
+
113
+        // Permissions
114
+        $this->rights = array();
115
+        $this->rights_class = 'commande';
116
+
117
+        $r=0;
118
+
119
+        $r++;
120
+        $this->rights[$r][0] = 81;
121
+        $this->rights[$r][1] = 'Lire les commandes clients';
122
+        $this->rights[$r][2] = 'r';
123
+        $this->rights[$r][3] = 0;
124
+        $this->rights[$r][4] = 'lire';
125
+
126
+        $r++;
127
+        $this->rights[$r][0] = 82;
128
+        $this->rights[$r][1] = 'Creer/modifier les commandes clients';
129
+        $this->rights[$r][2] = 'w';
130
+        $this->rights[$r][3] = 0;
131
+        $this->rights[$r][4] = 'creer';
132
+
133
+        $r++;
134
+        $this->rights[$r][0] = 84;
135
+        $this->rights[$r][1] = 'Valider les commandes clients';
136
+        $this->rights[$r][2] = 'd';
137
+        $this->rights[$r][3] = 0;
138
+        $this->rights[$r][4] = 'order_advance';
139
+        $this->rights[$r][5] = 'validate';
140
+
141
+        $r++;
142
+        $this->rights[$r][0] = 86;
143
+        $this->rights[$r][1] = 'Envoyer les commandes clients';
144
+        $this->rights[$r][2] = 'd';
145
+        $this->rights[$r][3] = 0;
146
+        $this->rights[$r][4] = 'order_advance';
147 147
         $this->rights[$r][5] = 'send';
148 148
 
149
-		$r++;
150
-		$this->rights[$r][0] = 87;
151
-		$this->rights[$r][1] = 'Cloturer les commandes clients';
152
-		$this->rights[$r][2] = 'd';
153
-		$this->rights[$r][3] = 0;
154
-		$this->rights[$r][4] = 'cloturer';
155
-
156
-		$r++;
157
-		$this->rights[$r][0] = 88;
158
-		$this->rights[$r][1] = 'Annuler les commandes clients';
159
-		$this->rights[$r][2] = 'd';
160
-		$this->rights[$r][3] = 0;
161
-		$this->rights[$r][4] = 'order_advance';
162
-		$this->rights[$r][5] = 'annuler';
163
-
164
-		$r++;
165
-		$this->rights[$r][0] = 89;
166
-		$this->rights[$r][1] = 'Supprimer les commandes clients';
167
-		$this->rights[$r][2] = 'd';
168
-		$this->rights[$r][3] = 0;
169
-		$this->rights[$r][4] = 'supprimer';
170
-
171
-		$r++;
172
-		$this->rights[$r][0] = 1421;
173
-		$this->rights[$r][1] = 'Exporter les commandes clients et attributs';
174
-		$this->rights[$r][2] = 'r';
175
-		$this->rights[$r][3] = 0;
176
-		$this->rights[$r][4] = 'commande';
177
-		$this->rights[$r][5] = 'export';
178
-
179
-
180
-		// Menus
181
-		//-------
182
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
183
-
184
-
185
-		// Exports
186
-		//--------
187
-		$r=0;
188
-
189
-		$r++;
190
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
191
-		$this->export_label[$r]='CustomersOrdersAndOrdersLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
192
-		$this->export_permission[$r]=array(array("commande","commande","export"));
193
-		$this->export_fields_array[$r]=array(
194
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country',
195
-			'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",
196
-			'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",
197
-			'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",
198
-			'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate',
199
-			'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin',
200
-			'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct',
201
-			'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",
202
-			'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'
203
-		);
204
-		//$this->export_TypeFields_array[$r]=array(
205
-		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
206
-		//	'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",
207
-		//	'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
208
-		//	'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",
209
-		//	'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",
210
-		//	'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'
211
-		//);
212
-		$this->export_TypeFields_array[$r]=array(
213
-			'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',
214
-			's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",
215
-			'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
216
-			'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text',
217
-			'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",
218
-			'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text'
219
-		);
220
-		$this->export_entities_array[$r]=array(
221
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company',
222
-			'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",
223
-			'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",
224
-			'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",
225
-			'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",
226
-			'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",
227
-			'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'
228
-		);
229
-		$this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
230
-		$keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra';
231
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
232
-		$keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2';
233
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
234
-		$keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3';
235
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
236
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
237
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
238
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
239
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
240
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
241
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c';
242
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid';
243
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid';
244
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid';
245
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object';
246
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
247
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object';
248
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
249
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
250
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
251
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')';
252
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id);
253
-	}
254
-
255
-
256
-	/**
257
-	 *		Function called when module is enabled.
258
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
259
-	 *		It also creates data directories
260
-	 *
149
+        $r++;
150
+        $this->rights[$r][0] = 87;
151
+        $this->rights[$r][1] = 'Cloturer les commandes clients';
152
+        $this->rights[$r][2] = 'd';
153
+        $this->rights[$r][3] = 0;
154
+        $this->rights[$r][4] = 'cloturer';
155
+
156
+        $r++;
157
+        $this->rights[$r][0] = 88;
158
+        $this->rights[$r][1] = 'Annuler les commandes clients';
159
+        $this->rights[$r][2] = 'd';
160
+        $this->rights[$r][3] = 0;
161
+        $this->rights[$r][4] = 'order_advance';
162
+        $this->rights[$r][5] = 'annuler';
163
+
164
+        $r++;
165
+        $this->rights[$r][0] = 89;
166
+        $this->rights[$r][1] = 'Supprimer les commandes clients';
167
+        $this->rights[$r][2] = 'd';
168
+        $this->rights[$r][3] = 0;
169
+        $this->rights[$r][4] = 'supprimer';
170
+
171
+        $r++;
172
+        $this->rights[$r][0] = 1421;
173
+        $this->rights[$r][1] = 'Exporter les commandes clients et attributs';
174
+        $this->rights[$r][2] = 'r';
175
+        $this->rights[$r][3] = 0;
176
+        $this->rights[$r][4] = 'commande';
177
+        $this->rights[$r][5] = 'export';
178
+
179
+
180
+        // Menus
181
+        //-------
182
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
183
+
184
+
185
+        // Exports
186
+        //--------
187
+        $r=0;
188
+
189
+        $r++;
190
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
191
+        $this->export_label[$r]='CustomersOrdersAndOrdersLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
192
+        $this->export_permission[$r]=array(array("commande","commande","export"));
193
+        $this->export_fields_array[$r]=array(
194
+            's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country',
195
+            'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",
196
+            'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",
197
+            'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",
198
+            'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate',
199
+            'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin',
200
+            'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct',
201
+            'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",
202
+            'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'
203
+        );
204
+        //$this->export_TypeFields_array[$r]=array(
205
+        //	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
206
+        //	'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",
207
+        //	'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
208
+        //	'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",
209
+        //	'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",
210
+        //	'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'
211
+        //);
212
+        $this->export_TypeFields_array[$r]=array(
213
+            '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',
214
+            's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",
215
+            'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
216
+            'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text',
217
+            'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",
218
+            'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text'
219
+        );
220
+        $this->export_entities_array[$r]=array(
221
+            's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company',
222
+            'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",
223
+            'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",
224
+            'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",
225
+            'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",
226
+            'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",
227
+            'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'
228
+        );
229
+        $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
230
+        $keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra';
231
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
232
+        $keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2';
233
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
234
+        $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3';
235
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
236
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
237
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
238
+        if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
239
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
240
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
241
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c';
242
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid';
243
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid';
244
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid';
245
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object';
246
+        $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
247
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object';
248
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
249
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
250
+        $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
251
+        $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')';
252
+        if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id);
253
+    }
254
+
255
+
256
+    /**
257
+     *		Function called when module is enabled.
258
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
259
+     *		It also creates data directories
260
+     *
261 261
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
262
-	 *      @return     int             	1 if OK, 0 if KO
263
-	 */
264
-	function init($options='')
265
-	{
266
-		global $conf,$langs;
267
-
268
-		// Permissions
269
-		$this->remove($options);
270
-
271
-		//ODT template
272
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';
273
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/orders';
274
-		$dest=$dirodt.'/template_order.odt';
275
-
276
-		if (file_exists($src) && ! file_exists($dest))
277
-		{
278
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
279
-			dol_mkdir($dirodt);
280
-			$result=dol_copy($src,$dest,0,0);
281
-			if ($result < 0)
282
-			{
283
-				$langs->load("errors");
284
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
285
-				return 0;
286
-			}
287
-		}
288
-
289
-		$sql = array(
290
-				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".$conf->entity,
291
-				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")"
292
-		);
293
-
294
-		 return $this->_init($sql,$options);
295
-	}
262
+     *      @return     int             	1 if OK, 0 if KO
263
+     */
264
+    function init($options='')
265
+    {
266
+        global $conf,$langs;
267
+
268
+        // Permissions
269
+        $this->remove($options);
270
+
271
+        //ODT template
272
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';
273
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/orders';
274
+        $dest=$dirodt.'/template_order.odt';
275
+
276
+        if (file_exists($src) && ! file_exists($dest))
277
+        {
278
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
279
+            dol_mkdir($dirodt);
280
+            $result=dol_copy($src,$dest,0,0);
281
+            if ($result < 0)
282
+            {
283
+                $langs->load("errors");
284
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
285
+                return 0;
286
+            }
287
+        }
288
+
289
+        $sql = array(
290
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".$conf->entity,
291
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")"
292
+        );
293
+
294
+            return $this->_init($sql,$options);
295
+    }
296 296
 }
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *		\brief      Fichier de description et activation du module Commande
30 30
  */
31 31
 
32
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 33
 
34 34
 
35 35
 /**
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 		$this->family = "crm";
54 54
 		$this->module_position = '30';
55 55
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56
-		$this->name = preg_replace('/^mod/i','',get_class($this));
56
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
57 57
 		$this->description = "Gestion des commandes clients";
58 58
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59 59
 		$this->version = 'dolibarr';
60 60
 
61 61
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
-		$this->picto='order';
62
+		$this->picto = 'order';
63 63
 
64 64
 		// Data directories to create when module is enabled
65 65
 		$this->dirs = array("/commande/temp");
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 		$this->depends = array("modSociete");
72 72
 		$this->requiredby = array("modExpedition");
73 73
 		$this->conflictwith = array();
74
-		$this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings');
74
+		$this->langfiles = array('orders', 'bills', 'companies', 'products', 'deliveries', 'sendings');
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array();
78
-		$r=0;
78
+		$r = 0;
79 79
 
80 80
 		$this->const[$r][0] = "COMMANDE_ADDON_PDF";
81 81
 		$this->const[$r][1] = "chaine";
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 
107 107
 		// Boxes
108 108
 		$this->boxes = array(
109
-			0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),
110
-			2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')
109
+			0=>array('file'=>'box_commandes.php', 'enabledbydefaulton'=>'Home'),
110
+			2=>array('file'=>'box_graph_orders_permonth.php', 'enabledbydefaulton'=>'Home')
111 111
 		);
112 112
 
113 113
 		// Permissions
114 114
 		$this->rights = array();
115 115
 		$this->rights_class = 'commande';
116 116
 
117
-		$r=0;
117
+		$r = 0;
118 118
 
119 119
 		$r++;
120 120
 		$this->rights[$r][0] = 81;
@@ -179,27 +179,27 @@  discard block
 block discarded – undo
179 179
 
180 180
 		// Menus
181 181
 		//-------
182
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
182
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
183 183
 
184 184
 
185 185
 		// Exports
186 186
 		//--------
187
-		$r=0;
187
+		$r = 0;
188 188
 
189 189
 		$r++;
190
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
191
-		$this->export_label[$r]='CustomersOrdersAndOrdersLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
192
-		$this->export_permission[$r]=array(array("commande","commande","export"));
193
-		$this->export_fields_array[$r]=array(
194
-			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country',
195
-			'co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",
196
-			'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",
197
-			'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",
198
-			'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate',
199
-			'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin',
200
-			'pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct',
201
-			'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",
202
-			'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'
190
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
191
+		$this->export_label[$r] = 'CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
192
+		$this->export_permission[$r] = array(array("commande", "commande", "export"));
193
+		$this->export_fields_array[$r] = array(
194
+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',
195
+			'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id",
196
+			'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate",
197
+			'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT",
198
+			'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
199
+			'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
200
+			'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
201
+			'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
202
+			'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel'
203 203
 		);
204 204
 		//$this->export_TypeFields_array[$r]=array(
205 205
 		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
@@ -209,47 +209,47 @@  discard block
 block discarded – undo
209 209
 		//	'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",
210 210
 		//	'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'
211 211
 		//);
212
-		$this->export_TypeFields_array[$r]=array(
213
-			'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',
214
-			's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",
215
-			'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
216
-			'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text',
217
-			'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",
218
-			'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text'
212
+		$this->export_TypeFields_array[$r] = array(
213
+			'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',
214
+			's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date",
215
+			'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric",
216
+			'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text',
217
+			'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric",
218
+			'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text'
219 219
 		);
220
-		$this->export_entities_array[$r]=array(
221
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company',
222
-			'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",
223
-			'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",
224
-			'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",
225
-			'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",
226
-			'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",
227
-			'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'
220
+		$this->export_entities_array[$r] = array(
221
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',
222
+			'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"order",
223
+			'c.ref'=>"order", 'c.ref_client'=>"order", 'c.fk_soc'=>"order", 'c.date_creation'=>"order", 'c.date_commande'=>"order", 'c.amount_ht'=>"order",
224
+			'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",
225
+			'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line",
226
+			'cd.product_type'=>'order_line', 'cd.tva_tx'=>"order_line", 'cd.qty'=>"order_line", 'cd.total_ht'=>"order_line", 'cd.total_tva'=>"order_line",
227
+			'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
228 228
 		);
229
-		$this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
230
-		$keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra';
229
+		$this->export_dependencies_array[$r] = array('order_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
230
+		$keyforselect = 'commande'; $keyforelement = 'order'; $keyforaliasextra = 'extra';
231 231
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
232
-		$keyforselect='commandedet'; $keyforelement='order_line'; $keyforaliasextra='extra2';
232
+		$keyforselect = 'commandedet'; $keyforelement = 'order_line'; $keyforaliasextra = 'extra2';
233 233
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
234
-		$keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3';
234
+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';
235 235
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
236
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
237
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
238
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
239
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
240
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
241
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c';
242
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid';
243
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid';
244
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid';
245
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object';
246
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
247
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object';
248
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
249
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
250
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
251
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')';
252
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id);
236
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
237
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
238
+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
239
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
240
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
241
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande as c';
242
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid';
243
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid';
244
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid';
245
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object';
246
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd';
247
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet_extrafields as extra2 on cd.rowid = extra2.fk_object';
248
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
249
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
250
+		$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
251
+		$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('commande').')';
252
+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
253 253
 	}
254 254
 
255 255
 
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
262 262
 	 *      @return     int             	1 if OK, 0 if KO
263 263
 	 */
264
-	function init($options='')
264
+	function init($options = '')
265 265
 	{
266
-		global $conf,$langs;
266
+		global $conf, $langs;
267 267
 
268 268
 		// Permissions
269 269
 		$this->remove($options);
270 270
 
271 271
 		//ODT template
272
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';
273
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/orders';
274
-		$dest=$dirodt.'/template_order.odt';
272
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';
273
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/orders';
274
+		$dest = $dirodt.'/template_order.odt';
275 275
 
276
-		if (file_exists($src) && ! file_exists($dest))
276
+		if (file_exists($src) && !file_exists($dest))
277 277
 		{
278 278
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
279 279
 			dol_mkdir($dirodt);
280
-			$result=dol_copy($src,$dest,0,0);
280
+			$result = dol_copy($src, $dest, 0, 0);
281 281
 			if ($result < 0)
282 282
 			{
283 283
 				$langs->load("errors");
284
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
284
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
285 285
 				return 0;
286 286
 			}
287 287
 		}
@@ -291,6 +291,6 @@  discard block
 block discarded – undo
291 291
 				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")"
292 292
 		);
293 293
 
294
-		 return $this->_init($sql,$options);
294
+		 return $this->_init($sql, $options);
295 295
 	}
296 296
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -235,7 +235,9 @@  discard block
 block discarded – undo
235 235
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
236 236
 		$this->export_sql_start[$r]='SELECT DISTINCT ';
237 237
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
238
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
238
+		if (empty($user->rights->societe->client->voir)) {
239
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
240
+		}
239 241
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
240 242
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
241 243
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c';
@@ -249,7 +251,9 @@  discard block
 block discarded – undo
249 251
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
250 252
 		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
251 253
 		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')';
252
-		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id);
254
+		if (empty($user->rights->societe->client->voir)) {
255
+		    $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id);
256
+		}
253 257
 	}
254 258
 
255 259
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php 3 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -31,235 +31,235 @@
 block discarded – undo
31 31
  */
32 32
 class modTcpdfbarcode extends ModeleBarCode
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	/**
41
-	 * @var string Error code (or message)
42
-	 */
43
-	public $error='';
40
+    /**
41
+     * @var string Error code (or message)
42
+     */
43
+    public $error='';
44 44
 
45
-	public $is2d = false;
45
+    public $is2d = false;
46 46
 
47
-	/**
48
-	 *	Return description of numbering model
49
-	 *
50
-	 *	@return		string		Text with description
51
-	 */
52
-	function info()
53
-	{
54
-		global $langs;
47
+    /**
48
+     *	Return description of numbering model
49
+     *
50
+     *	@return		string		Text with description
51
+     */
52
+    function info()
53
+    {
54
+        global $langs;
55 55
 
56
-		return 'TCPDF-barcode';
57
-	}
56
+        return 'TCPDF-barcode';
57
+    }
58 58
 
59
-	/**
60
-	 *	Return if a module can be used or not
61
-	 *
62
-	 *	@return		boolean		true if module can be used
63
-	 */
64
-	function isEnabled()
65
-	{
66
-		return true;
67
-	}
59
+    /**
60
+     *	Return if a module can be used or not
61
+     *
62
+     *	@return		boolean		true if module can be used
63
+     */
64
+    function isEnabled()
65
+    {
66
+        return true;
67
+    }
68 68
 
69
-	/**
70
-	 *	Test si les numeros deja en vigueur dans la base ne provoquent pas de
71
-	 *	de conflits qui empechera cette numerotation de fonctionner.
72
-	 *
73
-	 *	@return		boolean		false si conflit, true si ok
74
-	 */
75
-	function canBeActivated()
76
-	{
77
-		global $langs;
69
+    /**
70
+     *	Test si les numeros deja en vigueur dans la base ne provoquent pas de
71
+     *	de conflits qui empechera cette numerotation de fonctionner.
72
+     *
73
+     *	@return		boolean		false si conflit, true si ok
74
+     */
75
+    function canBeActivated()
76
+    {
77
+        global $langs;
78 78
 
79
-		return true;
80
-	}
79
+        return true;
80
+    }
81 81
 
82
-	/**
83
-	 *	Return true if encoding is supported
84
-	 *
85
-	 *	@param	string	$encoding		Encoding norm
86
-	 *	@return	int						>0 if supported, 0 if not
87
-	 */
88
-	function encodingIsSupported($encoding)
89
-	{
90
-		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
91
-		if (empty($tcpdfEncoding)) {
92
-			return 0;
93
-		} else {
94
-			return 1;
95
-		}
96
-	}
82
+    /**
83
+     *	Return true if encoding is supported
84
+     *
85
+     *	@param	string	$encoding		Encoding norm
86
+     *	@return	int						>0 if supported, 0 if not
87
+     */
88
+    function encodingIsSupported($encoding)
89
+    {
90
+        $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
91
+        if (empty($tcpdfEncoding)) {
92
+            return 0;
93
+        } else {
94
+            return 1;
95
+        }
96
+    }
97 97
 
98
-	/**
99
-	 *	Return an image file on the fly (no need to write on disk)
100
-	 *
101
-	 *	@param	   string	    $code		      Value to encode
102
-	 *	@param	   string	    $encoding	      Mode of encoding
103
-	 *	@param	   string	    $readable	      Code can be read
104
-	 *	@param	   integer		$scale			  Scale (not used with this engine)
105
-	 *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
106
-	 *	@return	   int			                  <0 if KO, >0 if OK
107
-	 */
108
-	function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
109
-	{
110
-		global $_GET;
98
+    /**
99
+     *	Return an image file on the fly (no need to write on disk)
100
+     *
101
+     *	@param	   string	    $code		      Value to encode
102
+     *	@param	   string	    $encoding	      Mode of encoding
103
+     *	@param	   string	    $readable	      Code can be read
104
+     *	@param	   integer		$scale			  Scale (not used with this engine)
105
+     *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
106
+     *	@return	   int			                  <0 if KO, >0 if OK
107
+     */
108
+    function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
109
+    {
110
+        global $_GET;
111 111
 
112
-		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
113
-		if (empty($tcpdfEncoding)) return -1;
112
+        $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
113
+        if (empty($tcpdfEncoding)) return -1;
114 114
 
115
-		$color = array(0,0,0);
115
+        $color = array(0,0,0);
116 116
 
117
-		$_GET["code"]=$code;
118
-		$_GET["type"]=$encoding;
119
-		$_GET["height"]=$height;
120
-		$_GET["readable"]=$readable;
117
+        $_GET["code"]=$code;
118
+        $_GET["type"]=$encoding;
119
+        $_GET["height"]=$height;
120
+        $_GET["readable"]=$readable;
121 121
 
122
-		if ($code) {
123
-			// Load the tcpdf barcode class
124
-			if ($this->is2d) {
125
-				$height = 3;
126
-				$width = 3;
127
-				require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
128
-				$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
129
-			} else {
130
-				$height = 50;
131
-				$width = 1;
132
-				require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
133
-				$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
134
-			}
122
+        if ($code) {
123
+            // Load the tcpdf barcode class
124
+            if ($this->is2d) {
125
+                $height = 3;
126
+                $width = 3;
127
+                require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
128
+                $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
129
+            } else {
130
+                $height = 50;
131
+                $width = 1;
132
+                require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
133
+                $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
134
+            }
135 135
 
136
-			dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
137
-			$barcodeobj->getBarcodePNG($width, $height, $color);
136
+            dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
137
+            $barcodeobj->getBarcodePNG($width, $height, $color);
138 138
 
139
-			return 1;
140
-		} else {
141
-			return -2;
142
-		}
143
-	}
139
+            return 1;
140
+        } else {
141
+            return -2;
142
+        }
143
+    }
144 144
 
145
-	/**
146
-	 *	Save an image file on disk (with no output)
147
-	 *
148
-	 *	@param	   string	    $code		      Value to encode
149
-	 *	@param	   string	    $encoding	      Mode of encoding
150
-	 *	@param	   string	    $readable	      Code can be read
151
-	 *	@param	   integer		$scale			  Scale (not used with this engine)
152
-	 *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
153
-	 *	@return	   int			                  <0 if KO, >0 if OK
154
-	 */
155
-	function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
156
-	{
157
-		global $conf,$_GET;
145
+    /**
146
+     *	Save an image file on disk (with no output)
147
+     *
148
+     *	@param	   string	    $code		      Value to encode
149
+     *	@param	   string	    $encoding	      Mode of encoding
150
+     *	@param	   string	    $readable	      Code can be read
151
+     *	@param	   integer		$scale			  Scale (not used with this engine)
152
+     *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
153
+     *	@return	   int			                  <0 if KO, >0 if OK
154
+     */
155
+    function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
156
+    {
157
+        global $conf,$_GET;
158 158
 
159
-		dol_mkdir($conf->barcode->dir_temp);
160
-		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
159
+        dol_mkdir($conf->barcode->dir_temp);
160
+        $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
161 161
 
162
-		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
163
-		if (empty($tcpdfEncoding)) return -1;
162
+        $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
163
+        if (empty($tcpdfEncoding)) return -1;
164 164
 
165
-		$color = array(0,0,0);
165
+        $color = array(0,0,0);
166 166
 
167
-		$_GET["code"]=$code;
168
-		$_GET["type"]=$encoding;
169
-		$_GET["height"]=$height;
170
-		$_GET["readable"]=$readable;
167
+        $_GET["code"]=$code;
168
+        $_GET["type"]=$encoding;
169
+        $_GET["height"]=$height;
170
+        $_GET["readable"]=$readable;
171 171
 
172
-		if ($code) {
173
-			// Load the tcpdf barcode class
174
-			if ($this->is2d) {
175
-				$height = 1;
176
-				$width = 1;
177
-				require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
178
-				$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
179
-			} else {
180
-				$height = 50;
181
-				$width = 1;
182
-				require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
183
-				$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
184
-			}
172
+        if ($code) {
173
+            // Load the tcpdf barcode class
174
+            if ($this->is2d) {
175
+                $height = 1;
176
+                $width = 1;
177
+                require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
178
+                $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
179
+            } else {
180
+                $height = 50;
181
+                $width = 1;
182
+                require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
183
+                $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
184
+            }
185 185
 
186
-			dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
187
-			if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
188
-				if (function_exists('imagecreate')) {
189
-					$imageData = imagecreatefromstring($imageData);
190
-				}
191
-				if (imagepng($imageData, $file)) {
192
-					return 1;
193
-				} else {
194
-					return -3;
195
-				}
196
-			} else {
197
-				return -4;
198
-			}
199
-		} else {
200
-			return -2;
201
-		}
202
-	}
186
+            dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
187
+            if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
188
+                if (function_exists('imagecreate')) {
189
+                    $imageData = imagecreatefromstring($imageData);
190
+                }
191
+                if (imagepng($imageData, $file)) {
192
+                    return 1;
193
+                } else {
194
+                    return -3;
195
+                }
196
+            } else {
197
+                return -4;
198
+            }
199
+        } else {
200
+            return -2;
201
+        }
202
+    }
203 203
 
204
-	/**
205
-	 *	get available output_modes for tcpdf class wth its translated description
206
-	 *
207
-	 * @param	string $dolEncodingType dolibarr barcode encoding type
208
-	 * @return	string tcpdf encoding type
209
-	 */
210
-	public function getTcpdfEncodingType($dolEncodingType)
211
-	{
212
-		$tcpdf1dEncodingTypes = array(
213
-						'C39' => 'C39',
214
-						'C39+' => 'C39+',
215
-						'C39E' => 'C39E',
216
-						'C39E+' => 'C39E+',
217
-						'S25' => 'S25',
218
-						'S25+' => 'S25+',
219
-						'I25' => 'I25',
220
-						'I25+' => 'I25+',
221
-						'C128' => 'C128',
222
-						'C128A' => 'C128A',
223
-						'C128B' => 'C128B',
224
-						'C128C' => 'C128C',
225
-						'EAN2' => 'EAN2',
226
-						'EAN5' => 'EAN5',
227
-						'EAN8' => 'EAN8',
228
-						'EAN13' => 'EAN13',
229
-						'ISBN' => 'EAN13',
230
-						'UPC' => 'UPCA',
231
-						'UPCE' => 'UPCE',
232
-						'MSI' => 'MSI',
233
-						'MSI+' => 'MSI+',
234
-						'POSTNET' => 'POSTNET',
235
-						'PLANET' => 'PLANET',
236
-						'RMS4CC' => 'RMS4CC',
237
-						'KIX' => 'KIX',
238
-						'IMB' => 'IMB',
239
-						'CODABAR' => 'CODABAR',
240
-						'CODE11' => 'CODE11',
241
-						'PHARMA' => 'PHARMA',
242
-						'PHARMA2T' => 'PHARMA2T'
243
-		);
204
+    /**
205
+     *	get available output_modes for tcpdf class wth its translated description
206
+     *
207
+     * @param	string $dolEncodingType dolibarr barcode encoding type
208
+     * @return	string tcpdf encoding type
209
+     */
210
+    public function getTcpdfEncodingType($dolEncodingType)
211
+    {
212
+        $tcpdf1dEncodingTypes = array(
213
+                        'C39' => 'C39',
214
+                        'C39+' => 'C39+',
215
+                        'C39E' => 'C39E',
216
+                        'C39E+' => 'C39E+',
217
+                        'S25' => 'S25',
218
+                        'S25+' => 'S25+',
219
+                        'I25' => 'I25',
220
+                        'I25+' => 'I25+',
221
+                        'C128' => 'C128',
222
+                        'C128A' => 'C128A',
223
+                        'C128B' => 'C128B',
224
+                        'C128C' => 'C128C',
225
+                        'EAN2' => 'EAN2',
226
+                        'EAN5' => 'EAN5',
227
+                        'EAN8' => 'EAN8',
228
+                        'EAN13' => 'EAN13',
229
+                        'ISBN' => 'EAN13',
230
+                        'UPC' => 'UPCA',
231
+                        'UPCE' => 'UPCE',
232
+                        'MSI' => 'MSI',
233
+                        'MSI+' => 'MSI+',
234
+                        'POSTNET' => 'POSTNET',
235
+                        'PLANET' => 'PLANET',
236
+                        'RMS4CC' => 'RMS4CC',
237
+                        'KIX' => 'KIX',
238
+                        'IMB' => 'IMB',
239
+                        'CODABAR' => 'CODABAR',
240
+                        'CODE11' => 'CODE11',
241
+                        'PHARMA' => 'PHARMA',
242
+                        'PHARMA2T' => 'PHARMA2T'
243
+        );
244 244
 
245
-		$tcpdf2dEncodingTypes = array(
246
-						'DATAMATRIX' => 'DATAMATRIX',
247
-						'PDF417' => 'PDF417',
248
-						'QRCODE' => 'QRCODE,L',
249
-						'QRCODE,L' => 'QRCODE,L',
250
-						'QRCODE,M' => 'QRCODE,M',
251
-						'QRCODE,Q' => 'QRCODE,Q',
252
-						'QRCODE,H' => 'QRCODE,H'
253
-		);
245
+        $tcpdf2dEncodingTypes = array(
246
+                        'DATAMATRIX' => 'DATAMATRIX',
247
+                        'PDF417' => 'PDF417',
248
+                        'QRCODE' => 'QRCODE,L',
249
+                        'QRCODE,L' => 'QRCODE,L',
250
+                        'QRCODE,M' => 'QRCODE,M',
251
+                        'QRCODE,Q' => 'QRCODE,Q',
252
+                        'QRCODE,H' => 'QRCODE,H'
253
+        );
254 254
 
255
-		if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
256
-			$this->is2d = false;
257
-			return $tcpdf1dEncodingTypes[$dolEncodingType];
258
-		} else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
259
-			$this->is2d = true;
260
-			return $tcpdf2dEncodingTypes[$dolEncodingType];
261
-		} else {
262
-			return '';
263
-		}
264
-	}
255
+        if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
256
+            $this->is2d = false;
257
+            return $tcpdf1dEncodingTypes[$dolEncodingType];
258
+        } else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
259
+            $this->is2d = true;
260
+            return $tcpdf2dEncodingTypes[$dolEncodingType];
261
+        } else {
262
+            return '';
263
+        }
264
+    }
265 265
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 
26 26
 require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
27
-require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php';	   // This is to include def like $genbarcode_loc and $font_loc
27
+require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc
28 28
 
29 29
 /**
30 30
  *	Class to generate barcode images using tcpdf barcode generator
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40 40
 	/**
41 41
 	 * @var string Error code (or message)
42 42
 	 */
43
-	public $error='';
43
+	public $error = '';
44 44
 
45 45
 	public $is2d = false;
46 46
 
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
 	 *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
106 106
 	 *	@return	   int			                  <0 if KO, >0 if OK
107 107
 	 */
108
-	function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
108
+	function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
109 109
 	{
110 110
 		global $_GET;
111 111
 
112 112
 		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
113 113
 		if (empty($tcpdfEncoding)) return -1;
114 114
 
115
-		$color = array(0,0,0);
115
+		$color = array(0, 0, 0);
116 116
 
117
-		$_GET["code"]=$code;
118
-		$_GET["type"]=$encoding;
119
-		$_GET["height"]=$height;
120
-		$_GET["readable"]=$readable;
117
+		$_GET["code"] = $code;
118
+		$_GET["type"] = $encoding;
119
+		$_GET["height"] = $height;
120
+		$_GET["readable"] = $readable;
121 121
 
122 122
 		if ($code) {
123 123
 			// Load the tcpdf barcode class
@@ -152,22 +152,22 @@  discard block
 block discarded – undo
152 152
 	 *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
153 153
 	 *	@return	   int			                  <0 if KO, >0 if OK
154 154
 	 */
155
-	function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
155
+	function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
156 156
 	{
157
-		global $conf,$_GET;
157
+		global $conf, $_GET;
158 158
 
159 159
 		dol_mkdir($conf->barcode->dir_temp);
160
-		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
160
+		$file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
161 161
 
162 162
 		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
163 163
 		if (empty($tcpdfEncoding)) return -1;
164 164
 
165
-		$color = array(0,0,0);
165
+		$color = array(0, 0, 0);
166 166
 
167
-		$_GET["code"]=$code;
168
-		$_GET["type"]=$encoding;
169
-		$_GET["height"]=$height;
170
-		$_GET["readable"]=$readable;
167
+		$_GET["code"] = $code;
168
+		$_GET["type"] = $encoding;
169
+		$_GET["height"] = $height;
170
+		$_GET["readable"] = $readable;
171 171
 
172 172
 		if ($code) {
173 173
 			// Load the tcpdf barcode class
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,7 +110,9 @@  discard block
 block discarded – undo
110 110
 		global $_GET;
111 111
 
112 112
 		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
113
-		if (empty($tcpdfEncoding)) return -1;
113
+		if (empty($tcpdfEncoding)) {
114
+		    return -1;
115
+		}
114 116
 
115 117
 		$color = array(0,0,0);
116 118
 
@@ -160,7 +162,9 @@  discard block
 block discarded – undo
160 162
 		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
161 163
 
162 164
 		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
163
-		if (empty($tcpdfEncoding)) return -1;
165
+		if (empty($tcpdfEncoding)) {
166
+		    return -1;
167
+		}
164 168
 
165 169
 		$color = array(0,0,0);
166 170
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/barcode/doc/phpbarcode.modules.php 3 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -32,147 +32,147 @@
 block discarded – undo
32 32
  */
33 33
 class modPhpbarcode extends ModeleBarCode
34 34
 {
35
-	/**
35
+    /**
36 36
      * Dolibarr version of the loaded document
37 37
      * @public string
38 38
      */
39
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
-
41
-	/**
42
-	 * @var string Error code (or message)
43
-	 */
44
-	public $error='';
45
-
46
-
47
-	/**
48
-	 * 	Return if a module can be used or not
49
-	 *
50
-	 *  @return		boolean     true if module can be used
51
-	 */
52
-	function isEnabled()
53
-	{
54
-		return true;
55
-	}
56
-
57
-
58
-	/**
59
-	 * 	Return description
60
-	 *
61
-	 * 	@return     string      Texte descripif
62
-	 */
63
-	function info()
64
-	{
65
-		global $langs;
66
-
67
-		$key = 'BarcodeInternalEngine';
68
-		$trans = $langs->trans('BarcodeInternalEngine');
69
-
70
-		return ($trans != $key) ? $trans : 'Internal engine';
71
-	}
72
-
73
-	/**
74
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
75
-	 *  de conflits qui empechera cette numerotation de fonctionner.
76
-	 *
77
-	 *	@return     boolean     false si conflit, true si ok
78
-	 */
79
-	function canBeActivated()
80
-	{
81
-		global $langs;
82
-
83
-		return true;
84
-	}
85
-
86
-
87
-	/**
88
-	 *	Return true if encoding is supported
89
-	 *
90
-	 *	@param	string	$encoding		Encoding norm
91
-	 *	@return	int						>0 if supported, 0 if not
92
-	 */
93
-	function encodingIsSupported($encoding)
94
-	{
95
-		global $genbarcode_loc;
39
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+
41
+    /**
42
+     * @var string Error code (or message)
43
+     */
44
+    public $error='';
45
+
46
+
47
+    /**
48
+     * 	Return if a module can be used or not
49
+     *
50
+     *  @return		boolean     true if module can be used
51
+     */
52
+    function isEnabled()
53
+    {
54
+        return true;
55
+    }
56
+
57
+
58
+    /**
59
+     * 	Return description
60
+     *
61
+     * 	@return     string      Texte descripif
62
+     */
63
+    function info()
64
+    {
65
+        global $langs;
66
+
67
+        $key = 'BarcodeInternalEngine';
68
+        $trans = $langs->trans('BarcodeInternalEngine');
69
+
70
+        return ($trans != $key) ? $trans : 'Internal engine';
71
+    }
72
+
73
+    /**
74
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
75
+     *  de conflits qui empechera cette numerotation de fonctionner.
76
+     *
77
+     *	@return     boolean     false si conflit, true si ok
78
+     */
79
+    function canBeActivated()
80
+    {
81
+        global $langs;
82
+
83
+        return true;
84
+    }
85
+
86
+
87
+    /**
88
+     *	Return true if encoding is supported
89
+     *
90
+     *	@param	string	$encoding		Encoding norm
91
+     *	@return	int						>0 if supported, 0 if not
92
+     */
93
+    function encodingIsSupported($encoding)
94
+    {
95
+        global $genbarcode_loc;
96 96
         //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit;
97 97
 
98
-		$supported=0;
99
-		if ($encoding == 'EAN13') $supported=1;
100
-		if ($encoding == 'ISBN')  $supported=1;
101
-		// Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not
102
-		// activated on Windows)
103
-		if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"]))
104
-		{
105
-			if ($encoding == 'EAN8')  $supported=1;
106
-			if ($encoding == 'UPC')   $supported=1;
107
-			if ($encoding == 'C39')   $supported=1;
108
-			if ($encoding == 'C128')  $supported=1;
109
-		}
110
-		return $supported;
111
-	}
98
+        $supported=0;
99
+        if ($encoding == 'EAN13') $supported=1;
100
+        if ($encoding == 'ISBN')  $supported=1;
101
+        // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not
102
+        // activated on Windows)
103
+        if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"]))
104
+        {
105
+            if ($encoding == 'EAN8')  $supported=1;
106
+            if ($encoding == 'UPC')   $supported=1;
107
+            if ($encoding == 'C39')   $supported=1;
108
+            if ($encoding == 'C128')  $supported=1;
109
+        }
110
+        return $supported;
111
+    }
112 112
 
113 113
     /**
114
-	 *	Return an image file on the fly (no need to write on disk)
115
-	 *
116
-	 *	@param	string   	$code			  Value to encode
117
-	 *	@param  string	 	$encoding		  Mode of encoding
118
-	 *	@param  string	 	$readable		  Code can be read
119
-	 *	@param	integer		$scale			  Scale
120
-	 *  @param  integer     $nooutputiferror  No output if error
121
-	 *	@return	int							  <0 if KO, >0 if OK
114
+     *	Return an image file on the fly (no need to write on disk)
115
+     *
116
+     *	@param	string   	$code			  Value to encode
117
+     *	@param  string	 	$encoding		  Mode of encoding
118
+     *	@param  string	 	$readable		  Code can be read
119
+     *	@param	integer		$scale			  Scale
120
+     *  @param  integer     $nooutputiferror  No output if error
121
+     *	@return	int							  <0 if KO, >0 if OK
122 122
      */
123
-	function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
124
-	{
125
-		global $_GET,$_SERVER;
126
-		global $conf;
127
-		global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
123
+    function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
124
+    {
125
+        global $_GET,$_SERVER;
126
+        global $conf;
127
+        global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
128 128
 
129
-		if (! $this->encodingIsSupported($encoding)) return -1;
129
+        if (! $this->encodingIsSupported($encoding)) return -1;
130 130
 
131
-		if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
132
-		if ($encoding == 'C39' || $encoding == 'C128')   $encoding = substr($encoding,1);
131
+        if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
132
+        if ($encoding == 'C39' || $encoding == 'C128')   $encoding = substr($encoding,1);
133 133
 
134
-		$mode='png';
134
+        $mode='png';
135 135
 
136
-		$_GET["code"]=$code;
137
-		$_GET["encoding"]=$encoding;
138
-		$_GET["scale"]=$scale;
139
-		$_GET["mode"]=$mode;
136
+        $_GET["code"]=$code;
137
+        $_GET["encoding"]=$encoding;
138
+        $_GET["scale"]=$scale;
139
+        $_GET["mode"]=$mode;
140 140
 
141
-		dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode");
142
-		if ($code) $result=barcode_print($code,$encoding,$scale,$mode);
141
+        dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode");
142
+        if ($code) $result=barcode_print($code,$encoding,$scale,$mode);
143 143
 
144
-		if (! is_array($result))
145
-		{
146
-			$this->error=$result;
147
-			if (empty($nooutputiferror)) print $this->error;
148
-			return -1;
149
-		}
144
+        if (! is_array($result))
145
+        {
146
+            $this->error=$result;
147
+            if (empty($nooutputiferror)) print $this->error;
148
+            return -1;
149
+        }
150 150
 
151
-		return 1;
152
-	}
151
+        return 1;
152
+    }
153 153
 
154
-	/**
155
-	 *	Save an image file on disk (with no output)
156
-	 *
157
-	 *	@param	string   	$code			  Value to encode
158
-	 *	@param	string   	$encoding		  Mode of encoding
159
-	 *	@param  string	 	$readable		  Code can be read
160
-	 *	@param	integer		$scale			  Scale
161
-	 *  @param  integer     $nooutputiferror  No output if error
162
-	 *	@return	int							  <0 if KO, >0 if OK
163
-	 */
164
-	function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
165
-	{
166
-		global $conf,$filebarcode;
154
+    /**
155
+     *	Save an image file on disk (with no output)
156
+     *
157
+     *	@param	string   	$code			  Value to encode
158
+     *	@param	string   	$encoding		  Mode of encoding
159
+     *	@param  string	 	$readable		  Code can be read
160
+     *	@param	integer		$scale			  Scale
161
+     *  @param  integer     $nooutputiferror  No output if error
162
+     *	@return	int							  <0 if KO, >0 if OK
163
+     */
164
+    function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
165
+    {
166
+        global $conf,$filebarcode;
167 167
 
168
-		dol_mkdir($conf->barcode->dir_temp);
168
+        dol_mkdir($conf->barcode->dir_temp);
169 169
 
170
-		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
170
+        $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
171 171
 
172
-		$filebarcode=$file;	// global var to be used in barcode_outimage called by barcode_print in buildBarCode
172
+        $filebarcode=$file;	// global var to be used in barcode_outimage called by barcode_print in buildBarCode
173 173
 
174
-		$result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror);
174
+        $result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror);
175 175
 
176
-		return $result;
177
-	}
176
+        return $result;
177
+    }
178 178
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 
26 26
 require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
27
-require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php';    // This is to include def like $genbarcode_loc and $font_loc
27
+require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc
28 28
 
29 29
 
30 30
 /**
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
      * Dolibarr version of the loaded document
37 37
      * @public string
38 38
      */
39
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
40 40
 
41 41
 	/**
42 42
 	 * @var string Error code (or message)
43 43
 	 */
44
-	public $error='';
44
+	public $error = '';
45 45
 
46 46
 
47 47
 	/**
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 		global $genbarcode_loc;
96 96
         //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit;
97 97
 
98
-		$supported=0;
99
-		if ($encoding == 'EAN13') $supported=1;
100
-		if ($encoding == 'ISBN')  $supported=1;
98
+		$supported = 0;
99
+		if ($encoding == 'EAN13') $supported = 1;
100
+		if ($encoding == 'ISBN')  $supported = 1;
101 101
 		// Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not
102 102
 		// activated on Windows)
103 103
 		if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"]))
104 104
 		{
105
-			if ($encoding == 'EAN8')  $supported=1;
106
-			if ($encoding == 'UPC')   $supported=1;
107
-			if ($encoding == 'C39')   $supported=1;
108
-			if ($encoding == 'C128')  $supported=1;
105
+			if ($encoding == 'EAN8')  $supported = 1;
106
+			if ($encoding == 'UPC')   $supported = 1;
107
+			if ($encoding == 'C39')   $supported = 1;
108
+			if ($encoding == 'C128')  $supported = 1;
109 109
 		}
110 110
 		return $supported;
111 111
 	}
@@ -120,30 +120,30 @@  discard block
 block discarded – undo
120 120
 	 *  @param  integer     $nooutputiferror  No output if error
121 121
 	 *	@return	int							  <0 if KO, >0 if OK
122 122
      */
123
-	function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
123
+	function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
124 124
 	{
125
-		global $_GET,$_SERVER;
125
+		global $_GET, $_SERVER;
126 126
 		global $conf;
127 127
 		global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
128 128
 
129
-		if (! $this->encodingIsSupported($encoding)) return -1;
129
+		if (!$this->encodingIsSupported($encoding)) return -1;
130 130
 
131 131
 		if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
132
-		if ($encoding == 'C39' || $encoding == 'C128')   $encoding = substr($encoding,1);
132
+		if ($encoding == 'C39' || $encoding == 'C128')   $encoding = substr($encoding, 1);
133 133
 
134
-		$mode='png';
134
+		$mode = 'png';
135 135
 
136
-		$_GET["code"]=$code;
137
-		$_GET["encoding"]=$encoding;
138
-		$_GET["scale"]=$scale;
139
-		$_GET["mode"]=$mode;
136
+		$_GET["code"] = $code;
137
+		$_GET["encoding"] = $encoding;
138
+		$_GET["scale"] = $scale;
139
+		$_GET["mode"] = $mode;
140 140
 
141 141
 		dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode");
142
-		if ($code) $result=barcode_print($code,$encoding,$scale,$mode);
142
+		if ($code) $result = barcode_print($code, $encoding, $scale, $mode);
143 143
 
144
-		if (! is_array($result))
144
+		if (!is_array($result))
145 145
 		{
146
-			$this->error=$result;
146
+			$this->error = $result;
147 147
 			if (empty($nooutputiferror)) print $this->error;
148 148
 			return -1;
149 149
 		}
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 	 *  @param  integer     $nooutputiferror  No output if error
162 162
 	 *	@return	int							  <0 if KO, >0 if OK
163 163
 	 */
164
-	function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
164
+	function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
165 165
 	{
166
-		global $conf,$filebarcode;
166
+		global $conf, $filebarcode;
167 167
 
168 168
 		dol_mkdir($conf->barcode->dir_temp);
169 169
 
170
-		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
170
+		$file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
171 171
 
172
-		$filebarcode=$file;	// global var to be used in barcode_outimage called by barcode_print in buildBarCode
172
+		$filebarcode = $file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode
173 173
 
174
-		$result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror);
174
+		$result = $this->buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror);
175 175
 
176 176
 		return $result;
177 177
 	}
Please login to merge, or discard this patch.
Braces   +33 added lines, -11 removed lines patch added patch discarded remove patch
@@ -96,16 +96,28 @@  discard block
 block discarded – undo
96 96
         //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit;
97 97
 
98 98
 		$supported=0;
99
-		if ($encoding == 'EAN13') $supported=1;
100
-		if ($encoding == 'ISBN')  $supported=1;
99
+		if ($encoding == 'EAN13') {
100
+		    $supported=1;
101
+		}
102
+		if ($encoding == 'ISBN') {
103
+		    $supported=1;
104
+		}
101 105
 		// Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not
102 106
 		// activated on Windows)
103 107
 		if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"]))
104 108
 		{
105
-			if ($encoding == 'EAN8')  $supported=1;
106
-			if ($encoding == 'UPC')   $supported=1;
107
-			if ($encoding == 'C39')   $supported=1;
108
-			if ($encoding == 'C128')  $supported=1;
109
+			if ($encoding == 'EAN8') {
110
+			    $supported=1;
111
+			}
112
+			if ($encoding == 'UPC') {
113
+			    $supported=1;
114
+			}
115
+			if ($encoding == 'C39') {
116
+			    $supported=1;
117
+			}
118
+			if ($encoding == 'C128') {
119
+			    $supported=1;
120
+			}
109 121
 		}
110 122
 		return $supported;
111 123
 	}
@@ -126,10 +138,16 @@  discard block
 block discarded – undo
126 138
 		global $conf;
127 139
 		global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
128 140
 
129
-		if (! $this->encodingIsSupported($encoding)) return -1;
141
+		if (! $this->encodingIsSupported($encoding)) {
142
+		    return -1;
143
+		}
130 144
 
131
-		if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
132
-		if ($encoding == 'C39' || $encoding == 'C128')   $encoding = substr($encoding,1);
145
+		if ($encoding == 'EAN8' || $encoding == 'EAN13') {
146
+		    $encoding = 'EAN';
147
+		}
148
+		if ($encoding == 'C39' || $encoding == 'C128') {
149
+		    $encoding = substr($encoding,1);
150
+		}
133 151
 
134 152
 		$mode='png';
135 153
 
@@ -139,12 +157,16 @@  discard block
 block discarded – undo
139 157
 		$_GET["mode"]=$mode;
140 158
 
141 159
 		dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode");
142
-		if ($code) $result=barcode_print($code,$encoding,$scale,$mode);
160
+		if ($code) {
161
+		    $result=barcode_print($code,$encoding,$scale,$mode);
162
+		}
143 163
 
144 164
 		if (! is_array($result))
145 165
 		{
146 166
 			$this->error=$result;
147
-			if (empty($nooutputiferror)) print $this->error;
167
+			if (empty($nooutputiferror)) {
168
+			    print $this->error;
169
+			}
148 170
 			return -1;
149 171
 		}
150 172
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/barcode/mod_barcode_product_standard.php 3 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -33,286 +33,286 @@
 block discarded – undo
33 33
  */
34 34
 class mod_barcode_product_standard extends ModeleNumRefBarCode
35 35
 {
36
-	public $name='Standard';				// Model Name
36
+    public $name='Standard';				// Model Name
37 37
 
38
-	public $code_modifiable;				// Editable code
38
+    public $code_modifiable;				// Editable code
39 39
 
40
-	public $code_modifiable_invalide;		// Modified code if it is invalid
40
+    public $code_modifiable_invalide;		// Modified code if it is invalid
41 41
 
42
-	public $code_modifiable_null;			// Modified code if it is null
42
+    public $code_modifiable_null;			// Modified code if it is null
43 43
 
44
-	public $code_null;						// Optional code
44
+    public $code_null;						// Optional code
45 45
 
46
-	/**
46
+    /**
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
51
-
52
-	public $code_auto;                     // Automatic Numbering
53
-
54
-	public $searchcode; // Search string
55
-
56
-	public $numbitcounter; // Number of digits the counter
57
-
58
-	public $prefixIsRequired; // The prefix field of third party must be filled when using {pre}
59
-
60
-
61
-	/**
62
-	 *	Constructor
63
-	 */
64
-	function __construct()
65
-	{
66
-		$this->code_null = 0;
67
-		$this->code_modifiable = 1;
68
-		$this->code_modifiable_invalide = 1;
69
-		$this->code_modifiable_null = 1;
70
-		$this->code_auto = 1;
71
-		$this->prefixIsRequired = 0;
72
-	}
73
-
74
-
75
-	/**		Return description of module
76
-	 *
77
-	 * 		@param	Translate 		$langs		Object langs
78
-	 * 		@return string      			Description of module
79
-	 */
80
-	function info($langs)
81
-	{
82
-		global $conf, $mc;
83
-		global $form;
84
-
85
-		$langs->load("products");
86
-
87
-		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
88
-
89
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
90
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
91
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
92
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
93
-		$texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
94
-		$texte.= '<table class="nobordernopadding" width="100%">';
95
-
96
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode"));
97
-		$tooltip.=$langs->trans("GenericMaskCodes3");
98
-		$tooltip.=$langs->trans("GenericMaskCodes4c");
99
-		$tooltip.=$langs->trans("GenericMaskCodes5");
100
-
101
-		// Mask parameter
102
-		//$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
103
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
104
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
105
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
106
-		$texte.= '</tr>';
107
-
108
-		$texte.= '</table>';
109
-		$texte.= '</form>';
110
-
111
-		return $texte;
112
-	}
113
-
114
-
115
-	/**
116
-	 * Return an example of result returned by getNextValue
117
-	 *
118
-	 * @param	Translate	$langs			Object langs
119
-	 * @param	Product		$objproduct		Object product
120
-	 * @return	string						Return string example
121
-	 */
122
-	function getExample($langs,$objproduct=0)
123
-	{
124
-		$examplebarcode = $this->getNextValue($objproduct,'');
125
-		if (! $examplebarcode)
126
-		{
127
-			$examplebarcode = $langs->trans('NotConfigured');
128
-		}
129
-		if($examplebarcode=="ErrorBadMask")
130
-		{
131
-			$langs->load("errors");
132
-			$examplebarcode=$langs->trans($examplebarcode);
133
-		}
134
-
135
-		return $examplebarcode;
136
-	}
137
-
138
-	/**
139
-	 * Return next value
140
-	 *
141
-	 * @param	Product		$objproduct     Object product
142
-	 * @param	string		$type       	Type of barcode (EAN, ISBN, ...)
143
-	 * @return 	string      				Value if OK, '' if module not configured, <0 if KO
144
-	 */
145
-	function getNextValue($objproduct=null,$type='')
146
-	{
147
-		global $db,$conf;
148
-
149
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
150
-
151
-		// TODO
152
-
153
-		// Get Mask value
154
-		$mask = '';
155
-		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
156
-
157
-		if (empty($mask))
158
-		{
159
-			$this->error='NotConfigured';
160
-			return '';
161
-		}
162
-
163
-		$field='barcode';$where='';
164
-
165
-		$now=dol_now();
166
-
167
-		$numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now);
168
-
169
-		return  $numFinal;
170
-	}
171
-
172
-
173
-	/**
174
-	 * 	Check validity of code according to its rules
175
-	 *
176
-	 *	@param	DoliDB		$db					Database handler
177
-	 *	@param	string		$code				Code to check/correct
178
-	 *	@param	Product		$product			Object product
179
-	 *  @param  int		  	$thirdparty_type   	0 = customer/prospect , 1 = supplier
180
-	 *  @param	string		$type       	    type of barcode (EAN, ISBN, ...)
181
-	 *  @return int								0 if OK
182
-	 * 											-1 ErrorBadCustomerCodeSyntax
183
-	 * 											-2 ErrorCustomerCodeRequired
184
-	 * 											-3 ErrorCustomerCodeAlreadyUsed
185
-	 * 											-4 ErrorPrefixRequired
186
-	 */
187
-	function verif($db, &$code, $product, $thirdparty_type, $type)
188
-	{
189
-		global $conf;
190
-
191
-		//var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit;
192
-
193
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
194
-
195
-		$result=0;
196
-		$code = strtoupper(trim($code));
197
-
198
-		if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
199
-		{
200
-			$result=0;
201
-		}
202
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
203
-		{
204
-			$result=-2;
205
-		}
206
-		else
207
-		{
208
-			if ($this->verif_syntax($code, $type) >= 0)
209
-			{
210
-				$is_dispo = $this->verif_dispo($db, $code, $product);
211
-				if ($is_dispo <> 0)
212
-				{
213
-					$result=-3;
214
-				}
215
-				else
216
-				{
217
-					$result=0;
218
-				}
219
-			}
220
-			else
221
-			{
222
-				if (dol_strlen($code) == 0)
223
-				{
224
-					$result=-2;
225
-				}
226
-				else
227
-				{
228
-					$result=-1;
229
-				}
230
-			}
231
-		}
232
-
233
-		dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result);
234
-		return $result;
235
-	}
50
+    public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
51
+
52
+    public $code_auto;                     // Automatic Numbering
53
+
54
+    public $searchcode; // Search string
55
+
56
+    public $numbitcounter; // Number of digits the counter
57
+
58
+    public $prefixIsRequired; // The prefix field of third party must be filled when using {pre}
59
+
60
+
61
+    /**
62
+     *	Constructor
63
+     */
64
+    function __construct()
65
+    {
66
+        $this->code_null = 0;
67
+        $this->code_modifiable = 1;
68
+        $this->code_modifiable_invalide = 1;
69
+        $this->code_modifiable_null = 1;
70
+        $this->code_auto = 1;
71
+        $this->prefixIsRequired = 0;
72
+    }
73
+
74
+
75
+    /**		Return description of module
76
+     *
77
+     * 		@param	Translate 		$langs		Object langs
78
+     * 		@return string      			Description of module
79
+     */
80
+    function info($langs)
81
+    {
82
+        global $conf, $mc;
83
+        global $form;
84
+
85
+        $langs->load("products");
86
+
87
+        $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
88
+
89
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
90
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
91
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
92
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
93
+        $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
94
+        $texte.= '<table class="nobordernopadding" width="100%">';
95
+
96
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode"));
97
+        $tooltip.=$langs->trans("GenericMaskCodes3");
98
+        $tooltip.=$langs->trans("GenericMaskCodes4c");
99
+        $tooltip.=$langs->trans("GenericMaskCodes5");
100
+
101
+        // Mask parameter
102
+        //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
103
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
104
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
105
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
106
+        $texte.= '</tr>';
107
+
108
+        $texte.= '</table>';
109
+        $texte.= '</form>';
110
+
111
+        return $texte;
112
+    }
113
+
114
+
115
+    /**
116
+     * Return an example of result returned by getNextValue
117
+     *
118
+     * @param	Translate	$langs			Object langs
119
+     * @param	Product		$objproduct		Object product
120
+     * @return	string						Return string example
121
+     */
122
+    function getExample($langs,$objproduct=0)
123
+    {
124
+        $examplebarcode = $this->getNextValue($objproduct,'');
125
+        if (! $examplebarcode)
126
+        {
127
+            $examplebarcode = $langs->trans('NotConfigured');
128
+        }
129
+        if($examplebarcode=="ErrorBadMask")
130
+        {
131
+            $langs->load("errors");
132
+            $examplebarcode=$langs->trans($examplebarcode);
133
+        }
134
+
135
+        return $examplebarcode;
136
+    }
137
+
138
+    /**
139
+     * Return next value
140
+     *
141
+     * @param	Product		$objproduct     Object product
142
+     * @param	string		$type       	Type of barcode (EAN, ISBN, ...)
143
+     * @return 	string      				Value if OK, '' if module not configured, <0 if KO
144
+     */
145
+    function getNextValue($objproduct=null,$type='')
146
+    {
147
+        global $db,$conf;
148
+
149
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
150
+
151
+        // TODO
152
+
153
+        // Get Mask value
154
+        $mask = '';
155
+        if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
156
+
157
+        if (empty($mask))
158
+        {
159
+            $this->error='NotConfigured';
160
+            return '';
161
+        }
162
+
163
+        $field='barcode';$where='';
164
+
165
+        $now=dol_now();
166
+
167
+        $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now);
168
+
169
+        return  $numFinal;
170
+    }
171
+
172
+
173
+    /**
174
+     * 	Check validity of code according to its rules
175
+     *
176
+     *	@param	DoliDB		$db					Database handler
177
+     *	@param	string		$code				Code to check/correct
178
+     *	@param	Product		$product			Object product
179
+     *  @param  int		  	$thirdparty_type   	0 = customer/prospect , 1 = supplier
180
+     *  @param	string		$type       	    type of barcode (EAN, ISBN, ...)
181
+     *  @return int								0 if OK
182
+     * 											-1 ErrorBadCustomerCodeSyntax
183
+     * 											-2 ErrorCustomerCodeRequired
184
+     * 											-3 ErrorCustomerCodeAlreadyUsed
185
+     * 											-4 ErrorPrefixRequired
186
+     */
187
+    function verif($db, &$code, $product, $thirdparty_type, $type)
188
+    {
189
+        global $conf;
190
+
191
+        //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit;
192
+
193
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
194
+
195
+        $result=0;
196
+        $code = strtoupper(trim($code));
197
+
198
+        if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
199
+        {
200
+            $result=0;
201
+        }
202
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
203
+        {
204
+            $result=-2;
205
+        }
206
+        else
207
+        {
208
+            if ($this->verif_syntax($code, $type) >= 0)
209
+            {
210
+                $is_dispo = $this->verif_dispo($db, $code, $product);
211
+                if ($is_dispo <> 0)
212
+                {
213
+                    $result=-3;
214
+                }
215
+                else
216
+                {
217
+                    $result=0;
218
+                }
219
+            }
220
+            else
221
+            {
222
+                if (dol_strlen($code) == 0)
223
+                {
224
+                    $result=-2;
225
+                }
226
+                else
227
+                {
228
+                    $result=-1;
229
+                }
230
+            }
231
+        }
232
+
233
+        dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result);
234
+        return $result;
235
+    }
236 236
 
237 237
 
238 238
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
239
-	/**
240
-	 *	Return if a code is used (by other element)
241
-	 *
242
-	 *	@param	DoliDB		$db			Handler acces base
243
-	 *	@param	string		$code		Code to check
244
-	 *	@param	Product		$product	Objet product
245
-	 *	@return	int						0 if available, <0 if KO
246
-	 */
247
-	function verif_dispo($db, $code, $product)
248
-	{
239
+    /**
240
+     *	Return if a code is used (by other element)
241
+     *
242
+     *	@param	DoliDB		$db			Handler acces base
243
+     *	@param	string		$code		Code to check
244
+     *	@param	Product		$product	Objet product
245
+     *	@return	int						0 if available, <0 if KO
246
+     */
247
+    function verif_dispo($db, $code, $product)
248
+    {
249 249
         // phpcs:enable
250
-		$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
251
-		$sql.= " WHERE barcode = '".$code."'";
252
-		if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
253
-
254
-		$resql=$db->query($sql);
255
-		if ($resql)
256
-		{
257
-			if ($db->num_rows($resql) == 0)
258
-			{
259
-				return 0;
260
-			}
261
-			else
262
-			{
263
-				return -1;
264
-			}
265
-		}
266
-		else
267
-		{
268
-			return -2;
269
-		}
270
-	}
250
+        $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
251
+        $sql.= " WHERE barcode = '".$code."'";
252
+        if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
253
+
254
+        $resql=$db->query($sql);
255
+        if ($resql)
256
+        {
257
+            if ($db->num_rows($resql) == 0)
258
+            {
259
+                return 0;
260
+            }
261
+            else
262
+            {
263
+                return -1;
264
+            }
265
+        }
266
+        else
267
+        {
268
+            return -2;
269
+        }
270
+    }
271 271
 
272 272
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
273
-	/**
274
-	 *	Return if a barcode value match syntax
275
-	 *
276
-	 *	@param	string	$codefortest	Code to check syntax
273
+    /**
274
+     *	Return if a barcode value match syntax
275
+     *
276
+     *	@param	string	$codefortest	Code to check syntax
277 277
      *  @param	string	$typefortest	Type of barcode (ISBN, EAN, ...)
278
-	 *	@return	int						0 if OK, <0 if KO
279
-	 */
280
-	function verif_syntax($codefortest, $typefortest)
281
-	{
278
+     *	@return	int						0 if OK, <0 if KO
279
+     */
280
+    function verif_syntax($codefortest, $typefortest)
281
+    {
282 282
         // phpcs:enable
283
-		global $conf;
284
-
285
-		$result = 0;
286
-
287
-		// Get Mask value
288
-		$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
289
-		if (! $mask)
290
-		{
291
-			$this->error='NotConfigured';
292
-			return -1;
293
-		}
294
-
295
-		dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
296
-
297
-		$newcodefortest=$codefortest;
298
-
299
-		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
300
-		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
301
-		{
302
-    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
303
-    	    {
304
-    	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
305
-    	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
306
-    	    }
307
-		}
308
-
309
-		$result=check_value($mask,$newcodefortest);
310
-		if (is_string($result))
311
-		{
312
-			$this->error = $result;
313
-			return -1;
314
-		}
315
-
316
-		return $result;
317
-	}
283
+        global $conf;
284
+
285
+        $result = 0;
286
+
287
+        // Get Mask value
288
+        $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
289
+        if (! $mask)
290
+        {
291
+            $this->error='NotConfigured';
292
+            return -1;
293
+        }
294
+
295
+        dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
296
+
297
+        $newcodefortest=$codefortest;
298
+
299
+        // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
300
+        if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
301
+        {
302
+            if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
303
+            {
304
+                if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
305
+                dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
306
+            }
307
+        }
308
+
309
+        $result=check_value($mask,$newcodefortest);
310
+        if (is_string($result))
311
+        {
312
+            $this->error = $result;
313
+            return -1;
314
+        }
315
+
316
+        return $result;
317
+    }
318 318
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -33,23 +33,23 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_barcode_product_standard extends ModeleNumRefBarCode
35 35
 {
36
-	public $name='Standard';				// Model Name
36
+	public $name = 'Standard'; // Model Name
37 37
 
38
-	public $code_modifiable;				// Editable code
38
+	public $code_modifiable; // Editable code
39 39
 
40
-	public $code_modifiable_invalide;		// Modified code if it is invalid
40
+	public $code_modifiable_invalide; // Modified code if it is invalid
41 41
 
42
-	public $code_modifiable_null;			// Modified code if it is null
42
+	public $code_modifiable_null; // Modified code if it is null
43 43
 
44
-	public $code_null;						// Optional code
44
+	public $code_null; // Optional code
45 45
 
46 46
 	/**
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
50
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
51 51
 
52
-	public $code_auto;                     // Automatic Numbering
52
+	public $code_auto; // Automatic Numbering
53 53
 
54 54
 	public $searchcode; // Search string
55 55
 
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
 
85 85
 		$langs->load("products");
86 86
 
87
-		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
87
+		$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
88 88
 
89 89
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
90
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
91
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
92
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
93
-		$texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
94
-		$texte.= '<table class="nobordernopadding" width="100%">';
90
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
91
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
92
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
93
+		$texte .= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
94
+		$texte .= '<table class="nobordernopadding" width="100%">';
95 95
 
96
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode"));
97
-		$tooltip.=$langs->trans("GenericMaskCodes3");
98
-		$tooltip.=$langs->trans("GenericMaskCodes4c");
99
-		$tooltip.=$langs->trans("GenericMaskCodes5");
96
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode"));
97
+		$tooltip .= $langs->trans("GenericMaskCodes3");
98
+		$tooltip .= $langs->trans("GenericMaskCodes4c");
99
+		$tooltip .= $langs->trans("GenericMaskCodes5");
100 100
 
101 101
 		// Mask parameter
102 102
 		//$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
103
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
104
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
105
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
106
-		$texte.= '</tr>';
103
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
104
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
105
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
106
+		$texte .= '</tr>';
107 107
 
108
-		$texte.= '</table>';
109
-		$texte.= '</form>';
108
+		$texte .= '</table>';
109
+		$texte .= '</form>';
110 110
 
111 111
 		return $texte;
112 112
 	}
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	 * @param	Product		$objproduct		Object product
120 120
 	 * @return	string						Return string example
121 121
 	 */
122
-	function getExample($langs,$objproduct=0)
122
+	function getExample($langs, $objproduct = 0)
123 123
 	{
124
-		$examplebarcode = $this->getNextValue($objproduct,'');
125
-		if (! $examplebarcode)
124
+		$examplebarcode = $this->getNextValue($objproduct, '');
125
+		if (!$examplebarcode)
126 126
 		{
127 127
 			$examplebarcode = $langs->trans('NotConfigured');
128 128
 		}
129
-		if($examplebarcode=="ErrorBadMask")
129
+		if ($examplebarcode == "ErrorBadMask")
130 130
 		{
131 131
 			$langs->load("errors");
132
-			$examplebarcode=$langs->trans($examplebarcode);
132
+			$examplebarcode = $langs->trans($examplebarcode);
133 133
 		}
134 134
 
135 135
 		return $examplebarcode;
@@ -142,29 +142,29 @@  discard block
 block discarded – undo
142 142
 	 * @param	string		$type       	Type of barcode (EAN, ISBN, ...)
143 143
 	 * @return 	string      				Value if OK, '' if module not configured, <0 if KO
144 144
 	 */
145
-	function getNextValue($objproduct=null,$type='')
145
+	function getNextValue($objproduct = null, $type = '')
146 146
 	{
147
-		global $db,$conf;
147
+		global $db, $conf;
148 148
 
149
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
149
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
150 150
 
151 151
 		// TODO
152 152
 
153 153
 		// Get Mask value
154 154
 		$mask = '';
155
-		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
155
+		if (!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
156 156
 
157 157
 		if (empty($mask))
158 158
 		{
159
-			$this->error='NotConfigured';
159
+			$this->error = 'NotConfigured';
160 160
 			return '';
161 161
 		}
162 162
 
163
-		$field='barcode';$where='';
163
+		$field = 'barcode'; $where = '';
164 164
 
165
-		$now=dol_now();
165
+		$now = dol_now();
166 166
 
167
-		$numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now);
167
+		$numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
168 168
 
169 169
 		return  $numFinal;
170 170
 	}
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 
191 191
 		//var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit;
192 192
 
193
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
193
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
194 194
 
195
-		$result=0;
195
+		$result = 0;
196 196
 		$code = strtoupper(trim($code));
197 197
 
198 198
 		if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
199 199
 		{
200
-			$result=0;
200
+			$result = 0;
201 201
 		}
202
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
202
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)))
203 203
 		{
204
-			$result=-2;
204
+			$result = -2;
205 205
 		}
206 206
 		else
207 207
 		{
@@ -210,22 +210,22 @@  discard block
 block discarded – undo
210 210
 				$is_dispo = $this->verif_dispo($db, $code, $product);
211 211
 				if ($is_dispo <> 0)
212 212
 				{
213
-					$result=-3;
213
+					$result = -3;
214 214
 				}
215 215
 				else
216 216
 				{
217
-					$result=0;
217
+					$result = 0;
218 218
 				}
219 219
 			}
220 220
 			else
221 221
 			{
222 222
 				if (dol_strlen($code) == 0)
223 223
 				{
224
-					$result=-2;
224
+					$result = -2;
225 225
 				}
226 226
 				else
227 227
 				{
228
-					$result=-1;
228
+					$result = -1;
229 229
 				}
230 230
 			}
231 231
 		}
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 	{
249 249
         // phpcs:enable
250 250
 		$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
251
-		$sql.= " WHERE barcode = '".$code."'";
252
-		if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
251
+		$sql .= " WHERE barcode = '".$code."'";
252
+		if ($product->id > 0) $sql .= " AND rowid <> ".$product->id;
253 253
 
254
-		$resql=$db->query($sql);
254
+		$resql = $db->query($sql);
255 255
 		if ($resql)
256 256
 		{
257 257
 			if ($db->num_rows($resql) == 0)
@@ -285,28 +285,28 @@  discard block
 block discarded – undo
285 285
 		$result = 0;
286 286
 
287 287
 		// Get Mask value
288
-		$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
289
-		if (! $mask)
288
+		$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? '' : $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
289
+		if (!$mask)
290 290
 		{
291
-			$this->error='NotConfigured';
291
+			$this->error = 'NotConfigured';
292 292
 			return -1;
293 293
 		}
294 294
 
295 295
 		dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
296 296
 
297
-		$newcodefortest=$codefortest;
297
+		$newcodefortest = $codefortest;
298 298
 
299 299
 		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
300
-		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
300
+		if (in_array($typefortest, array('EAN13', 'ISBN')))	// We remove the CRC char not included into mask
301 301
 		{
302
-    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
302
+    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg))
303 303
     	    {
304
-    	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
304
+    	        if (strlen($reg[1]) == 12) $newcodefortest = substr($newcodefortest, 0, 12);
305 305
     	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
306 306
     	    }
307 307
 		}
308 308
 
309
-		$result=check_value($mask,$newcodefortest);
309
+		$result = check_value($mask, $newcodefortest);
310 310
 		if (is_string($result))
311 311
 		{
312 312
 			$this->error = $result;
Please login to merge, or discard this patch.
Braces   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -152,7 +152,9 @@  discard block
 block discarded – undo
152 152
 
153 153
 		// Get Mask value
154 154
 		$mask = '';
155
-		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
155
+		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
156
+		    $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
157
+		}
156 158
 
157 159
 		if (empty($mask))
158 160
 		{
@@ -198,12 +200,10 @@  discard block
 block discarded – undo
198 200
 		if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
199 201
 		{
200 202
 			$result=0;
201
-		}
202
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
203
+		} else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
203 204
 		{
204 205
 			$result=-2;
205
-		}
206
-		else
206
+		} else
207 207
 		{
208 208
 			if ($this->verif_syntax($code, $type) >= 0)
209 209
 			{
@@ -211,19 +211,16 @@  discard block
 block discarded – undo
211 211
 				if ($is_dispo <> 0)
212 212
 				{
213 213
 					$result=-3;
214
-				}
215
-				else
214
+				} else
216 215
 				{
217 216
 					$result=0;
218 217
 				}
219
-			}
220
-			else
218
+			} else
221 219
 			{
222 220
 				if (dol_strlen($code) == 0)
223 221
 				{
224 222
 					$result=-2;
225
-				}
226
-				else
223
+				} else
227 224
 				{
228 225
 					$result=-1;
229 226
 				}
@@ -249,7 +246,9 @@  discard block
 block discarded – undo
249 246
         // phpcs:enable
250 247
 		$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
251 248
 		$sql.= " WHERE barcode = '".$code."'";
252
-		if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
249
+		if ($product->id > 0) {
250
+		    $sql.= " AND rowid <> ".$product->id;
251
+		}
253 252
 
254 253
 		$resql=$db->query($sql);
255 254
 		if ($resql)
@@ -257,13 +256,11 @@  discard block
 block discarded – undo
257 256
 			if ($db->num_rows($resql) == 0)
258 257
 			{
259 258
 				return 0;
260
-			}
261
-			else
259
+			} else
262 260
 			{
263 261
 				return -1;
264 262
 			}
265
-		}
266
-		else
263
+		} else
267 264
 		{
268 265
 			return -2;
269 266
 		}
@@ -297,11 +294,13 @@  discard block
 block discarded – undo
297 294
 		$newcodefortest=$codefortest;
298 295
 
299 296
 		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
300
-		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
297
+		if (in_array($typefortest,array('EAN13','ISBN'))) {
298
+		    // We remove the CRC char not included into mask
301 299
 		{
302 300
     		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
303 301
     	    {
304 302
     	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
303
+		}
305 304
     	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
306 305
     	    }
307 306
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/barcode/modules_barcode.class.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
  */
30 30
 abstract class ModeleBarCode
31 31
 {
32
-	/**
33
-	 * @var string Error code (or message)
34
-	 */
35
-	public $error='';
36
-
37
-
38
-	/**
39
-	 * Return if a model can be used or not
40
-	 *
41
-	 * @return		boolean     true if model can be used
42
-	 */
43
-	function isEnabled()
44
-	{
45
-		return true;
46
-	}
32
+    /**
33
+     * @var string Error code (or message)
34
+     */
35
+    public $error='';
36
+
37
+
38
+    /**
39
+     * Return if a model can be used or not
40
+     *
41
+     * @return		boolean     true if model can be used
42
+     */
43
+    function isEnabled()
44
+    {
45
+        return true;
46
+    }
47 47
 }
48 48
 
49 49
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
  */
53 53
 abstract class ModeleNumRefBarCode
54 54
 {
55
-	/**
56
-	 * @var string Error code (or message)
57
-	 */
58
-	public $error='';
55
+    /**
56
+     * @var string Error code (or message)
57
+     */
58
+    public $error='';
59 59
 
60 60
     /**     Return default description of numbering model
61 61
      *
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         return $langs->trans("Function_getNextValue_InModuleNotWorking");
103 103
     }
104 104
 
105
-	/**     Return version of module
105
+    /**     Return version of module
106 106
      *
107 107
      *      @return     string      Version
108 108
      */
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @var string Error code (or message)
34 34
 	 */
35
-	public $error='';
35
+	public $error = '';
36 36
 
37 37
 
38 38
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @var string Error code (or message)
57 57
 	 */
58
-	public $error='';
58
+	public $error = '';
59 59
 
60 60
     /**     Return default description of numbering model
61 61
      *
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     function getNom($langs)
77 77
     {
78
-        return empty($this->name)?$this->nom:$this->name;
78
+        return empty($this->name) ? $this->nom : $this->name;
79 79
     }
80 80
 
81 81
     /**     Return a numbering example
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      *	@param	string		$type		Type of barcode (EAN, ISBN, ...)
97 97
      *  @return string      			Value
98 98
      */
99
-    function getNextValue($objproduct,$type='')
99
+    function getNextValue($objproduct, $type = '')
100 100
     {
101 101
         global $langs;
102 102
         return $langs->trans("Function_getNextValue_InModuleNotWorking");
@@ -126,53 +126,53 @@  discard block
 block discarded – undo
126 126
      *		@param	int			$type		-1=Nothing, 0=Product, 1=Service
127 127
      *		@return	string					HTML translated description
128 128
      */
129
-    function getToolTip($langs,$soc,$type)
129
+    function getToolTip($langs, $soc, $type)
130 130
     {
131 131
         global $conf;
132 132
 
133 133
         $langs->load("admin");
134 134
 
135
-        $s='';
136
-        $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
137
-        $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
138
-        if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
139
-        $s.='<br>';
140
-        $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
135
+        $s = '';
136
+        $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
137
+        $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
138
+        if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
139
+        $s .= '<br>';
140
+        $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
141 141
         if ($type == 0)
142 142
         {
143
-            $s.=$langs->trans("RequiredIfProduct").': ';
144
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
145
-            $s.=yn(!$this->code_null,1,2);
146
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
147
-            $s.='<br>';
143
+            $s .= $langs->trans("RequiredIfProduct").': ';
144
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
145
+            $s .= yn(!$this->code_null, 1, 2);
146
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
147
+            $s .= '<br>';
148 148
         }
149 149
         if ($type == 1)
150 150
         {
151
-            $s.=$langs->trans("RequiredIfService").': ';
152
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
153
-            $s.=yn(!$this->code_null,1,2);
154
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
155
-            $s.='<br>';
151
+            $s .= $langs->trans("RequiredIfService").': ';
152
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
153
+            $s .= yn(!$this->code_null, 1, 2);
154
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
155
+            $s .= '<br>';
156 156
         }
157 157
         if ($type == -1)
158 158
         {
159
-            $s.=$langs->trans("Required").': ';
160
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
161
-            $s.=yn(!$this->code_null,1,2);
162
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
163
-            $s.='<br>';
159
+            $s .= $langs->trans("Required").': ';
160
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
161
+            $s .= yn(!$this->code_null, 1, 2);
162
+            if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
163
+            $s .= '<br>';
164 164
         }
165 165
         /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
166 166
         $s.=yn($this->code_modifiable,1,2);
167 167
         $s.='<br>';
168 168
         $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
169 169
         */
170
-        $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
171
-        $s.='<br>';
170
+        $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
171
+        $s .= '<br>';
172 172
 
173
-        $nextval=$this->getNextValue($soc,'');
174
-        if (empty($nextval)) $nextval=$langs->trans("Undefined");
175
-        $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
173
+        $nextval = $this->getNextValue($soc, '');
174
+        if (empty($nextval)) $nextval = $langs->trans("Undefined");
175
+        $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
176 176
 
177 177
         return $s;
178 178
     }
Please login to merge, or discard this patch.
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -111,10 +111,18 @@  discard block
 block discarded – undo
111 111
         global $langs;
112 112
         $langs->load("admin");
113 113
 
114
-        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
115
-        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
116
-        if ($this->version == 'dolibarr') return DOL_VERSION;
117
-        if ($this->version) return $this->version;
114
+        if ($this->version == 'development') {
115
+            return $langs->trans("VersionDevelopment");
116
+        }
117
+        if ($this->version == 'experimental') {
118
+            return $langs->trans("VersionExperimental");
119
+        }
120
+        if ($this->version == 'dolibarr') {
121
+            return DOL_VERSION;
122
+        }
123
+        if ($this->version) {
124
+            return $this->version;
125
+        }
118 126
         return $langs->trans("NotAvailable");
119 127
     }
120 128
 
@@ -135,31 +143,45 @@  discard block
 block discarded – undo
135 143
         $s='';
136 144
         $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
137 145
         $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
138
-        if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
146
+        if ($type != -1) {
147
+            $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
148
+        }
139 149
         $s.='<br>';
140 150
         $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
141 151
         if ($type == 0)
142 152
         {
143 153
             $s.=$langs->trans("RequiredIfProduct").': ';
144
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
154
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
155
+                $s.='<strike>';
156
+            }
145 157
             $s.=yn(!$this->code_null,1,2);
146
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
158
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
159
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
160
+            }
147 161
             $s.='<br>';
148 162
         }
149 163
         if ($type == 1)
150 164
         {
151 165
             $s.=$langs->trans("RequiredIfService").': ';
152
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
166
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
167
+                $s.='<strike>';
168
+            }
153 169
             $s.=yn(!$this->code_null,1,2);
154
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
170
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
171
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
172
+            }
155 173
             $s.='<br>';
156 174
         }
157 175
         if ($type == -1)
158 176
         {
159 177
             $s.=$langs->trans("Required").': ';
160
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
178
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
179
+                $s.='<strike>';
180
+            }
161 181
             $s.=yn(!$this->code_null,1,2);
162
-            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
182
+            if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
183
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
184
+            }
163 185
             $s.='<br>';
164 186
         }
165 187
         /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
@@ -171,7 +193,9 @@  discard block
 block discarded – undo
171 193
         $s.='<br>';
172 194
 
173 195
         $nextval=$this->getNextValue($soc,'');
174
-        if (empty($nextval)) $nextval=$langs->trans("Undefined");
196
+        if (empty($nextval)) {
197
+            $nextval=$langs->trans("Undefined");
198
+        }
175 199
         $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
176 200
 
177 201
         return $s;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modLdap.class.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@
 block discarded – undo
32 32
  */
33 33
 class modLdap extends DolibarrModules
34 34
 {
35
-	/**
36
-	 *   Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 *   @param      DoliDB		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-		$this->db = $db;
43
-		$this->numero = 200;
35
+    /**
36
+     *   Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     *   @param      DoliDB		$db      Database handler
39
+     */
40
+    function __construct($db)
41
+    {
42
+        $this->db = $db;
43
+        $this->numero = 200;
44 44
 
45
-		$this->family = "interface";
46
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
47
-		$this->module_position = '30';
48
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Synchronisation Ldap";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		// Name of image file used for this module.
55
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
56
-		// If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
57
-		$this->picto = 'technic';
45
+        $this->family = "interface";
46
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
47
+        $this->module_position = '30';
48
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Synchronisation Ldap";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        // Name of image file used for this module.
55
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
56
+        // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png'
57
+        $this->picto = 'technic';
58 58
 
59
-		// Data directories to create when module is enabled
60
-		$this->dirs = array("/ldap/temp");
59
+        // Data directories to create when module is enabled
60
+        $this->dirs = array("/ldap/temp");
61 61
 
62
-		// Config pages
63
-		$this->config_page_url = array("ldap.php");
62
+        // Config pages
63
+        $this->config_page_url = array("ldap.php");
64 64
 
65
-		// Dependencies
66
-		$this->hidden = false;			// A condition to hide module
67
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
69
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
65
+        // Dependencies
66
+        $this->hidden = false;			// A condition to hide module
67
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
69
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
71 71
 
72
-		// Constants
73
-		$this->const = array(
74
-		0=>array('LDAP_SERVER_TYPE','chaine','openldap','',0),
75
-		1=>array('LDAP_SERVER_PROTOCOLVERSION','chaine','3','',0),
76
-		2=>array('LDAP_SERVER_HOST','chaine','localhost','',0),
77
-		3=>array('LDAP_USER_DN','chaine','ou=users,dc=example,dc=com','',0),
78
-		4=>array('LDAP_GROUP_DN','chaine','ou=groups,dc=example,dc=com','',0),
79
-		5=>array('LDAP_FILTER_CONNECTION','chaine','&(objectClass=inetOrgPerson)','',0),
80
-		6=>array('LDAP_FIELD_LOGIN','chaine','uid','',0),
81
-		7=>array('LDAP_FIELD_FULLNAME','chaine','cn','',0),
82
-		8=>array('LDAP_FIELD_NAME','chaine','sn','',0),
83
-		9=>array('LDAP_FIELD_FIRSTNAME','chaine','givenname','',0),
84
-		10=>array('LDAP_FIELD_MAIL','chaine','mail','',0),
85
-		11=>array('LDAP_FIELD_PHONE','chaine','telephonenumber','',0),
86
-		12=>array('LDAP_FIELD_FAX','chaine','facsimiletelephonenumber','',0),
87
-		13=>array('LDAP_FIELD_MOBILE','chaine','mobile','',0),
88
-		);
72
+        // Constants
73
+        $this->const = array(
74
+        0=>array('LDAP_SERVER_TYPE','chaine','openldap','',0),
75
+        1=>array('LDAP_SERVER_PROTOCOLVERSION','chaine','3','',0),
76
+        2=>array('LDAP_SERVER_HOST','chaine','localhost','',0),
77
+        3=>array('LDAP_USER_DN','chaine','ou=users,dc=example,dc=com','',0),
78
+        4=>array('LDAP_GROUP_DN','chaine','ou=groups,dc=example,dc=com','',0),
79
+        5=>array('LDAP_FILTER_CONNECTION','chaine','&(objectClass=inetOrgPerson)','',0),
80
+        6=>array('LDAP_FIELD_LOGIN','chaine','uid','',0),
81
+        7=>array('LDAP_FIELD_FULLNAME','chaine','cn','',0),
82
+        8=>array('LDAP_FIELD_NAME','chaine','sn','',0),
83
+        9=>array('LDAP_FIELD_FIRSTNAME','chaine','givenname','',0),
84
+        10=>array('LDAP_FIELD_MAIL','chaine','mail','',0),
85
+        11=>array('LDAP_FIELD_PHONE','chaine','telephonenumber','',0),
86
+        12=>array('LDAP_FIELD_FAX','chaine','facsimiletelephonenumber','',0),
87
+        13=>array('LDAP_FIELD_MOBILE','chaine','mobile','',0),
88
+        );
89 89
 
90
-		// Boxes
91
-		$this->boxes = array();
90
+        // Boxes
91
+        $this->boxes = array();
92 92
 
93
-		// Permissions
94
-		$this->rights = array();
95
-		$this->rights_class = 'ldap';
96
-	}
93
+        // Permissions
94
+        $this->rights = array();
95
+        $this->rights_class = 'ldap';
96
+    }
97 97
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\ingroup    ldap
25 25
  *	\brief		File to describe and activate Ldap module
26 26
  */
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		// Module position in the family on 2 digits ('01', '10', '20', ...)
47 47
 		$this->module_position = '30';
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Synchronisation Ldap";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
@@ -63,28 +63,28 @@  discard block
 block discarded – undo
63 63
 		$this->config_page_url = array("ldap.php");
64 64
 
65 65
 		// Dependencies
66
-		$this->hidden = false;			// A condition to hide module
67
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
68
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
69
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
70
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
66
+		$this->hidden = false; // A condition to hide module
67
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
68
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
69
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
70
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
71 71
 
72 72
 		// Constants
73 73
 		$this->const = array(
74
-		0=>array('LDAP_SERVER_TYPE','chaine','openldap','',0),
75
-		1=>array('LDAP_SERVER_PROTOCOLVERSION','chaine','3','',0),
76
-		2=>array('LDAP_SERVER_HOST','chaine','localhost','',0),
77
-		3=>array('LDAP_USER_DN','chaine','ou=users,dc=example,dc=com','',0),
78
-		4=>array('LDAP_GROUP_DN','chaine','ou=groups,dc=example,dc=com','',0),
79
-		5=>array('LDAP_FILTER_CONNECTION','chaine','&(objectClass=inetOrgPerson)','',0),
80
-		6=>array('LDAP_FIELD_LOGIN','chaine','uid','',0),
81
-		7=>array('LDAP_FIELD_FULLNAME','chaine','cn','',0),
82
-		8=>array('LDAP_FIELD_NAME','chaine','sn','',0),
83
-		9=>array('LDAP_FIELD_FIRSTNAME','chaine','givenname','',0),
84
-		10=>array('LDAP_FIELD_MAIL','chaine','mail','',0),
85
-		11=>array('LDAP_FIELD_PHONE','chaine','telephonenumber','',0),
86
-		12=>array('LDAP_FIELD_FAX','chaine','facsimiletelephonenumber','',0),
87
-		13=>array('LDAP_FIELD_MOBILE','chaine','mobile','',0),
74
+		0=>array('LDAP_SERVER_TYPE', 'chaine', 'openldap', '', 0),
75
+		1=>array('LDAP_SERVER_PROTOCOLVERSION', 'chaine', '3', '', 0),
76
+		2=>array('LDAP_SERVER_HOST', 'chaine', 'localhost', '', 0),
77
+		3=>array('LDAP_USER_DN', 'chaine', 'ou=users,dc=example,dc=com', '', 0),
78
+		4=>array('LDAP_GROUP_DN', 'chaine', 'ou=groups,dc=example,dc=com', '', 0),
79
+		5=>array('LDAP_FILTER_CONNECTION', 'chaine', '&(objectClass=inetOrgPerson)', '', 0),
80
+		6=>array('LDAP_FIELD_LOGIN', 'chaine', 'uid', '', 0),
81
+		7=>array('LDAP_FIELD_FULLNAME', 'chaine', 'cn', '', 0),
82
+		8=>array('LDAP_FIELD_NAME', 'chaine', 'sn', '', 0),
83
+		9=>array('LDAP_FIELD_FIRSTNAME', 'chaine', 'givenname', '', 0),
84
+		10=>array('LDAP_FIELD_MAIL', 'chaine', 'mail', '', 0),
85
+		11=>array('LDAP_FIELD_PHONE', 'chaine', 'telephonenumber', '', 0),
86
+		12=>array('LDAP_FIELD_FAX', 'chaine', 'facsimiletelephonenumber', '', 0),
87
+		13=>array('LDAP_FIELD_MOBILE', 'chaine', 'mobile', '', 0),
88 88
 		);
89 89
 
90 90
 		// Boxes
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modImport.class.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -33,63 +33,63 @@
 block discarded – undo
33 33
 class modImport extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-		$this->numero = 250;
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+        $this->numero = 250;
45 45
 
46
-		$this->family = "technic";
46
+        $this->family = "technic";
47 47
         $this->module_position = '70';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto = 'technic';
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto = 'technic';
55 55
 
56
-		// Data directories to create when module is enabled
57
-		$this->dirs = array("/import/temp");
56
+        // Data directories to create when module is enabled
57
+        $this->dirs = array("/import/temp");
58 58
 
59
-		// Config pages
60
-		$this->config_page_url = array();
59
+        // Config pages
60
+        $this->config_page_url = array();
61 61
 
62
-		// Dependencies
63
-		$this->hidden = false;			// A condition to hide module
64
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
66
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68
-		$this->phpmax = array();
69
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
70
-		$this->need_javascript_ajax = 1;
62
+        // Dependencies
63
+        $this->hidden = false;			// A condition to hide module
64
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
66
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68
+        $this->phpmax = array();
69
+        $this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
70
+        $this->need_javascript_ajax = 1;
71 71
 
72
-		// Constants
73
-		$this->const = array();
72
+        // Constants
73
+        $this->const = array();
74 74
 
75
-		// Boxes
76
-		$this->boxes = array();
75
+        // Boxes
76
+        $this->boxes = array();
77 77
 
78
-		// Permissions
79
-		$this->rights = array();
80
-		$this->rights_class = 'import';
81
-		$r=0;
78
+        // Permissions
79
+        $this->rights = array();
80
+        $this->rights_class = 'import';
81
+        $r=0;
82 82
 
83
-		$r++;
84
-		$this->rights[$r][0] = 1251;
85
-		$this->rights[$r][1] = 'Run mass imports of external data (data load)';
86
-		$this->rights[$r][2] = 'r';
87
-		$this->rights[$r][3] = 0;
88
-		$this->rights[$r][4] = 'run';
83
+        $r++;
84
+        $this->rights[$r][0] = 1251;
85
+        $this->rights[$r][1] = 'Run mass imports of external data (data load)';
86
+        $this->rights[$r][2] = 'r';
87
+        $this->rights[$r][3] = 0;
88
+        $this->rights[$r][4] = 'run';
89 89
 
90 90
 
91
-		// Menus
92
-		//-------
93
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
94
-	}
91
+        // Menus
92
+        //-------
93
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
94
+    }
95 95
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module Import
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->family = "technic";
47 47
         $this->module_position = '70';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52 52
 		$this->version = 'dolibarr';
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$this->config_page_url = array();
61 61
 
62 62
 		// Dependencies
63
-		$this->hidden = false;			// A condition to hide module
64
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
66
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
63
+		$this->hidden = false; // A condition to hide module
64
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
65
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
66
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
67
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68 68
 		$this->phpmax = array();
69
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
69
+		$this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module
70 70
 		$this->need_javascript_ajax = 1;
71 71
 
72 72
 		// Constants
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		// Permissions
79 79
 		$this->rights = array();
80 80
 		$this->rights_class = 'import';
81
-		$r=0;
81
+		$r = 0;
82 82
 
83 83
 		$r++;
84 84
 		$this->rights[$r][0] = 1251;
@@ -90,6 +90,6 @@  discard block
 block discarded – undo
90 90
 
91 91
 		// Menus
92 92
 		//-------
93
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
93
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php 3 patches
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -38,502 +38,502 @@
 block discarded – undo
38 38
  */
39 39
 class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
40 40
 {
41
-	/**
42
-	 * Issuer
43
-	 * @var Societe
44
-	 */
45
-	public $emetteur;
46
-
47
-	/**
48
-   * @var array() Minimum version of PHP required by module.
49
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
50
-   */
51
-	public $phpmin = array(5, 4);
52
-
53
-	/**
54
-   * Dolibarr version of the loaded document
55
-   * @public string
56
-   */
57
-	public $version = 'dolibarr';
58
-
59
-
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *  @param		DoliDB		$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs, $mysoc;
68
-
69
-		// Load translation files required by the page
41
+    /**
42
+     * Issuer
43
+     * @var Societe
44
+     */
45
+    public $emetteur;
46
+
47
+    /**
48
+     * @var array() Minimum version of PHP required by module.
49
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
50
+     */
51
+    public $phpmin = array(5, 4);
52
+
53
+    /**
54
+     * Dolibarr version of the loaded document
55
+     * @public string
56
+     */
57
+    public $version = 'dolibarr';
58
+
59
+
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *  @param		DoliDB		$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs, $mysoc;
68
+
69
+        // Load translation files required by the page
70 70
         $langs->loadLangs(array("main","companies"));
71 71
 
72
-		$this->db = $db;
73
-		$this->name = "ODT templates";
74
-		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
-
77
-		// Dimension page pour format A4
78
-		$this->type = 'odt';
79
-		$this->page_largeur = 0;
80
-		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
-
98
-		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
-	}
102
-
103
-
104
-	/**
105
-	 *	Return description of a module
106
-	 *
107
-	 *	@param	Translate	$langs      Lang object to use for output
108
-	 *	@return string       			Description
109
-	 */
110
-	function info($langs)
111
-	{
112
-		global $conf, $langs;
113
-
114
-		// Load translation files required by the page
72
+        $this->db = $db;
73
+        $this->name = "ODT templates";
74
+        $this->description = $langs->trans("DocumentModelOdt");
75
+        $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
+
77
+        // Dimension page pour format A4
78
+        $this->type = 'odt';
79
+        $this->page_largeur = 0;
80
+        $this->page_hauteur = 0;
81
+        $this->format = array($this->page_largeur,$this->page_hauteur);
82
+        $this->marge_gauche=0;
83
+        $this->marge_droite=0;
84
+        $this->marge_haute=0;
85
+        $this->marge_basse=0;
86
+
87
+        $this->option_logo = 1;                    // Affiche logo
88
+        $this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
+        $this->option_modereg = 0;                 // Affiche mode reglement
90
+        $this->option_condreg = 0;                 // Affiche conditions reglement
91
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
92
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
93
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
94
+        $this->option_credit_note = 0;             // Support credit notes
95
+        $this->option_freetext = 1;				   // Support add of a personalised text
96
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+
98
+        // Recupere emetteur
99
+        $this->emetteur=$mysoc;
100
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+    }
102
+
103
+
104
+    /**
105
+     *	Return description of a module
106
+     *
107
+     *	@param	Translate	$langs      Lang object to use for output
108
+     *	@return string       			Description
109
+     */
110
+    function info($langs)
111
+    {
112
+        global $conf, $langs;
113
+
114
+        // Load translation files required by the page
115 115
         $langs->loadLangs(array('companies', 'errors'));
116 116
 
117
-		$form = new Form($this->db);
118
-
119
-		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124
-		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125
-		{
126
-			$texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129
-		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
131
-
132
-		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
138
-		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
142
-				unset($listofdir[$key]); continue;
143
-			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
146
-			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
-			}
150
-		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
-		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
164
-
165
-		// Scan directories
166
-		$nbofiles=count($listoffiles);
167
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168
-		{
169
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
170
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
-			$texte.=count($listoffiles);
172
-			//$texte.=$nbofiles?'</a>':'';
173
-			$texte.='</b>';
174
-		}
175
-
176
-		if ($nbofiles)
177
-		{
178
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
-   			foreach($listoffiles as $file)
180
-   			{
117
+        $form = new Form($this->db);
118
+
119
+        $texte = $this->description.".<br>\n";
120
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
+        $texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124
+        if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125
+        {
126
+            $texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
+            $texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
+            $texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129
+        }
130
+        $texte.= '<table class="nobordernopadding" width="100%">';
131
+
132
+        // List of directories area
133
+        $texte.= '<tr><td>';
134
+        $texttitle=$langs->trans("ListOfDirectories");
135
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
+        $listoffiles=array();
137
+        foreach($listofdir as $key=>$tmpdir)
138
+        {
139
+            $tmpdir=trim($tmpdir);
140
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
+            if (! $tmpdir) {
142
+                unset($listofdir[$key]); continue;
143
+            }
144
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+            else
146
+            {
147
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
+            }
150
+        }
151
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
+        // Add list of substitution keys
153
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
+
156
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
159
+        $texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
+        $texte.= '</textarea>';
161
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+        $texte.= '<br></div></div>';
164
+
165
+        // Scan directories
166
+        $nbofiles=count($listoffiles);
167
+        if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168
+        {
169
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
170
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
+            $texte.=count($listoffiles);
172
+            //$texte.=$nbofiles?'</a>':'';
173
+            $texte.='</b>';
174
+        }
175
+
176
+        if ($nbofiles)
177
+        {
178
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
+                foreach($listoffiles as $file)
180
+                {
181 181
                 $texte.=$file['name'].'<br>';
182
-   			}
183
-   			$texte.='<div id="div_'.get_class($this).'">';
184
-
185
-			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186
-			{
187
-				// Model for creation
188
-				$liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
-				$texte.= '<table width="50%;">';
190
-				$texte.= '<tr>';
191
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
-				$texte.= '<td colspan="">';
193
-				$texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
-				$texte.= "</td></tr>";
195
-
196
-				$texte.= '<tr>';
197
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
-				$texte.= '<td colspan="">';
199
-				$texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
-				$texte.= "</td></tr>";
201
-				$texte.= '<tr>';
202
-
203
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
-				$texte.= '<td colspan="">';
205
-				$texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
-				$texte.= "</td></tr>";
207
-				$texte.= '</table>';
208
-			}
209
-		}
210
-
211
-		$texte.= '</td>';
212
-
213
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
-		$texte.= '</td>';
216
-		$texte.= '</tr>';
217
-
218
-		$texte.= '</table>';
219
-		$texte.= '</form>';
220
-
221
-		return $texte;
222
-	}
182
+                }
183
+                $texte.='<div id="div_'.get_class($this).'">';
184
+
185
+            if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186
+            {
187
+                // Model for creation
188
+                $liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
+                $texte.= '<table width="50%;">';
190
+                $texte.= '<tr>';
191
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
+                $texte.= '<td colspan="">';
193
+                $texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
+                $texte.= "</td></tr>";
195
+
196
+                $texte.= '<tr>';
197
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
+                $texte.= '<td colspan="">';
199
+                $texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
+                $texte.= "</td></tr>";
201
+                $texte.= '<tr>';
202
+
203
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
+                $texte.= '<td colspan="">';
205
+                $texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
+                $texte.= "</td></tr>";
207
+                $texte.= '</table>';
208
+            }
209
+        }
210
+
211
+        $texte.= '</td>';
212
+
213
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
+        $texte.= '</td>';
216
+        $texte.= '</tr>';
217
+
218
+        $texte.= '</table>';
219
+        $texte.= '</form>';
220
+
221
+        return $texte;
222
+    }
223 223
 
224 224
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
225
-	/**
226
-	 *	Function to build a document on disk using the generic odt module.
227
-	 *
228
-	 *	@param		Propale		$object				Object source to build document
229
-	 *	@param		Translate	$outputlangs		Lang output object
230
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
231
-	 *  @param		int			$hidedetails		Do not show line details
232
-	 *  @param		int			$hidedesc			Do not show desc
233
-	 *  @param		int			$hideref			Do not show ref
234
-	 *	@return		int         					1 if OK, <=0 if KO
235
-	 */
236
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
237
-	{
225
+    /**
226
+     *	Function to build a document on disk using the generic odt module.
227
+     *
228
+     *	@param		Propale		$object				Object source to build document
229
+     *	@param		Translate	$outputlangs		Lang output object
230
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
231
+     *  @param		int			$hidedetails		Do not show line details
232
+     *  @param		int			$hidedesc			Do not show desc
233
+     *  @param		int			$hideref			Do not show ref
234
+     *	@return		int         					1 if OK, <=0 if KO
235
+     */
236
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
237
+    {
238 238
         // phpcs:enable
239
-		global $user, $langs, $conf, $mysoc, $hookmanager;
240
-
241
-		if (empty($srctemplatepath))
242
-		{
243
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
244
-			return -1;
245
-		}
246
-
247
-		// Add odtgeneration hook
248
-		if (! is_object($hookmanager))
249
-		{
250
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
-			$hookmanager=new HookManager($this->db);
252
-		}
253
-		$hookmanager->initHooks(array('odtgeneration'));
254
-		global $action;
255
-
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
257
-		$sav_charset_output=$outputlangs->charset_output;
258
-		$outputlangs->charset_output='UTF-8';
259
-
260
-		// Load translation files required by the page
261
-		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
262
-
263
-		if ($conf->supplier_proposal->dir_output)
264
-		{
265
-			// If $object is id instead of object
266
-			if (! is_object($object))
267
-			{
268
-				$id = $object;
269
-				$object = new SupplierProposal($this->db);
270
-				$result=$object->fetch($id);
271
-				if ($result < 0)
272
-				{
273
-					dol_print_error($this->db,$object->error);
274
-					return -1;
275
-				}
276
-			}
277
-
278
-			$dir = $conf->supplier_proposal->dir_output;
279
-			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
-			$file = $dir . "/" . $objectref . ".odt";
282
-
283
-			if (! file_exists($dir))
284
-			{
285
-				if (dol_mkdir($dir) < 0)
286
-				{
287
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
288
-					return -1;
289
-				}
290
-			}
291
-
292
-			if (file_exists($dir))
293
-			{
294
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
295
-				$newfile=basename($srctemplatepath);
296
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
299
-
300
-				$newfiletmp=$objectref.'_'.$newfiletmp;
301
-
302
-				// Get extension (ods or odt)
303
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305
-				{
306
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
308
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
-				}
310
-				else
311
-				{
312
-					$filename=$newfiletmp.'.'.$newfileformat;
313
-				}
314
-				$file=$dir.'/'.$filename;
315
-				//print "newdir=".$dir;
316
-				//print "newfile=".$newfile;
317
-				//print "file=".$file;
318
-				//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
319
-
320
-				dol_mkdir($conf->supplier_proposal->dir_temp);
321
-
322
-
323
-				// If BILLING contact defined on invoice, we use it
324
-				$usecontact=false;
325
-				$arrayidcontact=$object->getIdContact('external','BILLING');
326
-				if (count($arrayidcontact) > 0)
327
-				{
328
-					$usecontact=true;
329
-					$result=$object->fetch_contact($arrayidcontact[0]);
330
-				}
331
-
332
-				// Recipient name
333
-				if (! empty($usecontact))
334
-				{
335
-					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
-					else $socobject = $object->thirdparty;
338
-				}
339
-				else
340
-				{
341
-					$socobject=$object->thirdparty;
342
-				}
343
-
344
-				// Make substitution
345
-				$substitutionarray=array(
346
-				'__FROM_NAME__' => $this->emetteur->name,
347
-				'__FROM_EMAIL__' => $this->emetteur->email,
348
-				'__TOTAL_TTC__' => $object->total_ttc,
349
-				'__TOTAL_HT__' => $object->total_ht,
350
-				'__TOTAL_VAT__' => $object->total_vat
351
-				);
352
-				complete_substitutions_array($substitutionarray, $langs, $object);
353
-				// Call the ODTSubstitution hook
354
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
356
-
357
-				// Line of free text
358
-				$newfreetext='';
359
-				$paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
-				if (! empty($conf->global->$paramfreetext))
361
-				{
362
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
363
-				}
364
-
365
-				// Open and load template
366
-				require_once ODTPHP_PATH.'odf.php';
367
-				try {
368
-					$odfHandler = new odf(
369
-						$srctemplatepath,
370
-						array(
371
-							'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373
-							'DELIMITER_LEFT'  => '{',
374
-							'DELIMITER_RIGHT' => '}'
375
-						)
376
-					);
377
-				}
378
-				catch (Exception $e)
379
-				{
380
-					$this->error=$e->getMessage();
381
-					dol_syslog($e->getMessage(), LOG_INFO);
382
-					return -1;
383
-				}
384
-				// After construction $odfHandler->contentXml contains content and
385
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
386
-				// [!-- BEGIN lines --]*[!-- END lines --]
387
-				//print html_entity_decode($odfHandler->__toString());
388
-				//print exit;
389
-
390
-
391
-				// Make substitutions into odt of freetext
392
-				try {
393
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
-				}
395
-				catch (OdfException $e)
396
-				{
397
-					dol_syslog($e->getMessage(), LOG_INFO);
398
-				}
399
-
400
-				// Define substitution array
401
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
-				$array_other=$this->get_substitutionarray_other($outputlangs);
407
-
408
-				$tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
409
-				complete_substitutions_array($tmparray, $outputlangs, $object);
410
-
411
-				// Call the ODTSubstitution hook
412
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
414
-
415
-				foreach($tmparray as $key=>$value)
416
-				{
417
-					try {
418
-						if (preg_match('/logo$/',$key)) // Image
419
-						{
420
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
421
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
-						}
423
-						else    // Text
424
-						{
425
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
426
-						}
427
-					}
428
-					catch(OdfException $e)
429
-					{
239
+        global $user, $langs, $conf, $mysoc, $hookmanager;
240
+
241
+        if (empty($srctemplatepath))
242
+        {
243
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
244
+            return -1;
245
+        }
246
+
247
+        // Add odtgeneration hook
248
+        if (! is_object($hookmanager))
249
+        {
250
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
+            $hookmanager=new HookManager($this->db);
252
+        }
253
+        $hookmanager->initHooks(array('odtgeneration'));
254
+        global $action;
255
+
256
+        if (! is_object($outputlangs)) $outputlangs=$langs;
257
+        $sav_charset_output=$outputlangs->charset_output;
258
+        $outputlangs->charset_output='UTF-8';
259
+
260
+        // Load translation files required by the page
261
+        $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
262
+
263
+        if ($conf->supplier_proposal->dir_output)
264
+        {
265
+            // If $object is id instead of object
266
+            if (! is_object($object))
267
+            {
268
+                $id = $object;
269
+                $object = new SupplierProposal($this->db);
270
+                $result=$object->fetch($id);
271
+                if ($result < 0)
272
+                {
273
+                    dol_print_error($this->db,$object->error);
274
+                    return -1;
275
+                }
276
+            }
277
+
278
+            $dir = $conf->supplier_proposal->dir_output;
279
+            $objectref = dol_sanitizeFileName($object->ref);
280
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
+            $file = $dir . "/" . $objectref . ".odt";
282
+
283
+            if (! file_exists($dir))
284
+            {
285
+                if (dol_mkdir($dir) < 0)
286
+                {
287
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
288
+                    return -1;
289
+                }
290
+            }
291
+
292
+            if (file_exists($dir))
293
+            {
294
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
295
+                $newfile=basename($srctemplatepath);
296
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
299
+
300
+                $newfiletmp=$objectref.'_'.$newfiletmp;
301
+
302
+                // Get extension (ods or odt)
303
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305
+                {
306
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
308
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
+                }
310
+                else
311
+                {
312
+                    $filename=$newfiletmp.'.'.$newfileformat;
313
+                }
314
+                $file=$dir.'/'.$filename;
315
+                //print "newdir=".$dir;
316
+                //print "newfile=".$newfile;
317
+                //print "file=".$file;
318
+                //print "conf->propal->dir_temp=".$conf->propal->dir_temp;
319
+
320
+                dol_mkdir($conf->supplier_proposal->dir_temp);
321
+
322
+
323
+                // If BILLING contact defined on invoice, we use it
324
+                $usecontact=false;
325
+                $arrayidcontact=$object->getIdContact('external','BILLING');
326
+                if (count($arrayidcontact) > 0)
327
+                {
328
+                    $usecontact=true;
329
+                    $result=$object->fetch_contact($arrayidcontact[0]);
330
+                }
331
+
332
+                // Recipient name
333
+                if (! empty($usecontact))
334
+                {
335
+                    // On peut utiliser le nom de la societe du contact
336
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
+                    else $socobject = $object->thirdparty;
338
+                }
339
+                else
340
+                {
341
+                    $socobject=$object->thirdparty;
342
+                }
343
+
344
+                // Make substitution
345
+                $substitutionarray=array(
346
+                '__FROM_NAME__' => $this->emetteur->name,
347
+                '__FROM_EMAIL__' => $this->emetteur->email,
348
+                '__TOTAL_TTC__' => $object->total_ttc,
349
+                '__TOTAL_HT__' => $object->total_ht,
350
+                '__TOTAL_VAT__' => $object->total_vat
351
+                );
352
+                complete_substitutions_array($substitutionarray, $langs, $object);
353
+                // Call the ODTSubstitution hook
354
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
356
+
357
+                // Line of free text
358
+                $newfreetext='';
359
+                $paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
+                if (! empty($conf->global->$paramfreetext))
361
+                {
362
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
363
+                }
364
+
365
+                // Open and load template
366
+                require_once ODTPHP_PATH.'odf.php';
367
+                try {
368
+                    $odfHandler = new odf(
369
+                        $srctemplatepath,
370
+                        array(
371
+                            'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
+                            'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373
+                            'DELIMITER_LEFT'  => '{',
374
+                            'DELIMITER_RIGHT' => '}'
375
+                        )
376
+                    );
377
+                }
378
+                catch (Exception $e)
379
+                {
380
+                    $this->error=$e->getMessage();
381
+                    dol_syslog($e->getMessage(), LOG_INFO);
382
+                    return -1;
383
+                }
384
+                // After construction $odfHandler->contentXml contains content and
385
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
386
+                // [!-- BEGIN lines --]*[!-- END lines --]
387
+                //print html_entity_decode($odfHandler->__toString());
388
+                //print exit;
389
+
390
+
391
+                // Make substitutions into odt of freetext
392
+                try {
393
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
+                }
395
+                catch (OdfException $e)
396
+                {
397
+                    dol_syslog($e->getMessage(), LOG_INFO);
398
+                }
399
+
400
+                // Define substitution array
401
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
+                $array_other=$this->get_substitutionarray_other($outputlangs);
407
+
408
+                $tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
409
+                complete_substitutions_array($tmparray, $outputlangs, $object);
410
+
411
+                // Call the ODTSubstitution hook
412
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
414
+
415
+                foreach($tmparray as $key=>$value)
416
+                {
417
+                    try {
418
+                        if (preg_match('/logo$/',$key)) // Image
419
+                        {
420
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
421
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
+                        }
423
+                        else    // Text
424
+                        {
425
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
426
+                        }
427
+                    }
428
+                    catch(OdfException $e)
429
+                    {
430 430
                         dol_syslog($e->getMessage(), LOG_INFO);
431
-					}
432
-				}
433
-				// Replace tags of lines
434
-				try
435
-				{
436
-					$foundtagforlines = 1;
437
-					try {
438
-						$listlines = $odfHandler->setSegment('lines');
439
-					}
440
-					catch(OdfException $e)
441
-					{
442
-						// We may arrive here if tags for lines not present into template
443
-						$foundtagforlines = 0;
444
-						dol_syslog($e->getMessage(), LOG_INFO);
445
-					}
446
-					if ($foundtagforlines)
447
-					{
448
-						foreach ($object->lines as $line)
449
-						{
450
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
451
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452
-							// Call the ODTSubstitutionLine hook
453
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
-							foreach($tmparray as $key => $val)
456
-							{
457
-								try
458
-								{
459
-									$listlines->setVars($key, $val, true, 'UTF-8');
460
-								}
461
-								catch(OdfException $e)
462
-								{
463
-									dol_syslog($e->getMessage(), LOG_INFO);
464
-								}
465
-								catch(SegmentException $e)
466
-								{
467
-									dol_syslog($e->getMessage(), LOG_INFO);
468
-								}
469
-							}
470
-							$listlines->merge();
471
-						}
472
-						$odfHandler->mergeSegment($listlines);
473
-					}
474
-				}
475
-				catch(OdfException $e)
476
-				{
477
-					$this->error=$e->getMessage();
478
-					dol_syslog($this->error, LOG_WARNING);
479
-					return -1;
480
-				}
481
-
482
-				// Replace labels translated
483
-				$tmparray=$outputlangs->get_translations_for_substitutions();
484
-				foreach($tmparray as $key=>$value)
485
-				{
486
-					try {
487
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
488
-					}
489
-					catch(OdfException $e)
490
-					{
431
+                    }
432
+                }
433
+                // Replace tags of lines
434
+                try
435
+                {
436
+                    $foundtagforlines = 1;
437
+                    try {
438
+                        $listlines = $odfHandler->setSegment('lines');
439
+                    }
440
+                    catch(OdfException $e)
441
+                    {
442
+                        // We may arrive here if tags for lines not present into template
443
+                        $foundtagforlines = 0;
491 444
                         dol_syslog($e->getMessage(), LOG_INFO);
492
-					}
493
-				}
494
-
495
-				// Call the beforeODTSave hook
496
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
-
499
-				// Write new file
500
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501
-					try {
502
-						$odfHandler->exportAsAttachedPDF($file);
503
-					} catch (Exception $e) {
504
-						$this->error=$e->getMessage();
445
+                    }
446
+                    if ($foundtagforlines)
447
+                    {
448
+                        foreach ($object->lines as $line)
449
+                        {
450
+                            $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
451
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452
+                            // Call the ODTSubstitutionLine hook
453
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
+                            foreach($tmparray as $key => $val)
456
+                            {
457
+                                try
458
+                                {
459
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
460
+                                }
461
+                                catch(OdfException $e)
462
+                                {
463
+                                    dol_syslog($e->getMessage(), LOG_INFO);
464
+                                }
465
+                                catch(SegmentException $e)
466
+                                {
467
+                                    dol_syslog($e->getMessage(), LOG_INFO);
468
+                                }
469
+                            }
470
+                            $listlines->merge();
471
+                        }
472
+                        $odfHandler->mergeSegment($listlines);
473
+                    }
474
+                }
475
+                catch(OdfException $e)
476
+                {
477
+                    $this->error=$e->getMessage();
478
+                    dol_syslog($this->error, LOG_WARNING);
479
+                    return -1;
480
+                }
481
+
482
+                // Replace labels translated
483
+                $tmparray=$outputlangs->get_translations_for_substitutions();
484
+                foreach($tmparray as $key=>$value)
485
+                {
486
+                    try {
487
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
488
+                    }
489
+                    catch(OdfException $e)
490
+                    {
505 491
                         dol_syslog($e->getMessage(), LOG_INFO);
506
-						return -1;
507
-					}
508
-				}
509
-				else {
510
-					try {
511
-						$odfHandler->saveToDisk($file);
512
-					} catch (Exception $e) {
513
-						$this->error=$e->getMessage();
492
+                    }
493
+                }
494
+
495
+                // Call the beforeODTSave hook
496
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
+
499
+                // Write new file
500
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501
+                    try {
502
+                        $odfHandler->exportAsAttachedPDF($file);
503
+                    } catch (Exception $e) {
504
+                        $this->error=$e->getMessage();
514 505
                         dol_syslog($e->getMessage(), LOG_INFO);
515
-						return -1;
516
-					}
517
-				}
518
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520
-
521
-				if (! empty($conf->global->MAIN_UMASK))
522
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
523
-
524
-				$odfHandler=null;	// Destroy object
525
-
526
-				$this->result = array('fullpath'=>$file);
527
-
528
-				return 1;   // Success
529
-			}
530
-			else
531
-			{
532
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533
-				return -1;
534
-			}
535
-		}
536
-
537
-		return -1;
538
-	}
506
+                        return -1;
507
+                    }
508
+                }
509
+                else {
510
+                    try {
511
+                        $odfHandler->saveToDisk($file);
512
+                    } catch (Exception $e) {
513
+                        $this->error=$e->getMessage();
514
+                        dol_syslog($e->getMessage(), LOG_INFO);
515
+                        return -1;
516
+                    }
517
+                }
518
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520
+
521
+                if (! empty($conf->global->MAIN_UMASK))
522
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
523
+
524
+                $odfHandler=null;	// Destroy object
525
+
526
+                $this->result = array('fullpath'=>$file);
527
+
528
+                return 1;   // Success
529
+            }
530
+            else
531
+            {
532
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533
+                return -1;
534
+            }
535
+        }
536
+
537
+        return -1;
538
+    }
539 539
 }
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 		global $conf, $langs, $mysoc;
68 68
 
69 69
 		// Load translation files required by the page
70
-        $langs->loadLangs(array("main","companies"));
70
+        $langs->loadLangs(array("main", "companies"));
71 71
 
72 72
 		$this->db = $db;
73 73
 		$this->name = "ODT templates";
74 74
 		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
+		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
76 76
 
77 77
 		// Dimension page pour format A4
78 78
 		$this->type = 'odt';
79 79
 		$this->page_largeur = 0;
80 80
 		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
81
+		$this->format = array($this->page_largeur, $this->page_hauteur);
82
+		$this->marge_gauche = 0;
83
+		$this->marge_droite = 0;
84
+		$this->marge_haute = 0;
85
+		$this->marge_basse = 0;
86
+
87
+		$this->option_logo = 1; // Affiche logo
88
+		$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
89
+		$this->option_modereg = 0; // Affiche mode reglement
90
+		$this->option_condreg = 0; // Affiche conditions reglement
91
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
92
+		$this->option_multilang = 1; // Dispo en plusieurs langues
93
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
94
+		$this->option_credit_note = 0; // Support credit notes
95
+		$this->option_freetext = 1; // Support add of a personalised text
96
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
97 97
 
98 98
 		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
+		$this->emetteur = $mysoc;
100
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
101 101
 	}
102 102
 
103 103
 
@@ -117,106 +117,106 @@  discard block
 block discarded – undo
117 117
 		$form = new Form($this->db);
118 118
 
119 119
 		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
120
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
123
+		$texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124 124
 		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125 125
 		{
126
-			$texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
126
+			$texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
+			$texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
+			$texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129 129
 		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
130
+		$texte .= '<table class="nobordernopadding" width="100%">';
131 131
 
132 132
 		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
133
+		$texte .= '<tr><td>';
134
+		$texttitle = $langs->trans("ListOfDirectories");
135
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
+		$listoffiles = array();
137
+		foreach ($listofdir as $key=>$tmpdir)
138 138
 		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
139
+			$tmpdir = trim($tmpdir);
140
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
141
+			if (!$tmpdir) {
142 142
 				unset($listofdir[$key]); continue;
143 143
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
145 145
 			else
146 146
 			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
148
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
149 149
 			}
150 150
 		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
151
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
152 152
 		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
153
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
155
+
156
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
157
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
159
+		$texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
+		$texte .= '</textarea>';
161
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+		$texte .= '<br></div></div>';
164 164
 
165 165
 		// Scan directories
166
-		$nbofiles=count($listoffiles);
167
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
166
+		$nbofiles = count($listoffiles);
167
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168 168
 		{
169
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
169
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
170 170
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
-			$texte.=count($listoffiles);
171
+			$texte .= count($listoffiles);
172 172
 			//$texte.=$nbofiles?'</a>':'';
173
-			$texte.='</b>';
173
+			$texte .= '</b>';
174 174
 		}
175 175
 
176 176
 		if ($nbofiles)
177 177
 		{
178
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
-   			foreach($listoffiles as $file)
178
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
179
+   			foreach ($listoffiles as $file)
180 180
    			{
181
-                $texte.=$file['name'].'<br>';
181
+                $texte .= $file['name'].'<br>';
182 182
    			}
183
-   			$texte.='<div id="div_'.get_class($this).'">';
183
+   			$texte .= '<div id="div_'.get_class($this).'">';
184 184
 
185 185
 			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186 186
 			{
187 187
 				// Model for creation
188
-				$liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
-				$texte.= '<table width="50%;">';
190
-				$texte.= '<tr>';
191
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
-				$texte.= '<td colspan="">';
193
-				$texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
-				$texte.= "</td></tr>";
195
-
196
-				$texte.= '<tr>';
197
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
-				$texte.= '<td colspan="">';
199
-				$texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
-				$texte.= "</td></tr>";
201
-				$texte.= '<tr>';
202
-
203
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
-				$texte.= '<td colspan="">';
205
-				$texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
-				$texte.= "</td></tr>";
207
-				$texte.= '</table>';
188
+				$liste = ModelePDFSupplierProposal::liste_modeles($this->db);
189
+				$texte .= '<table width="50%;">';
190
+				$texte .= '<tr>';
191
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
+				$texte .= '<td colspan="">';
193
+				$texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
+				$texte .= "</td></tr>";
195
+
196
+				$texte .= '<tr>';
197
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
+				$texte .= '<td colspan="">';
199
+				$texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
+				$texte .= "</td></tr>";
201
+				$texte .= '<tr>';
202
+
203
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
+				$texte .= '<td colspan="">';
205
+				$texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
+				$texte .= "</td></tr>";
207
+				$texte .= '</table>';
208 208
 			}
209 209
 		}
210 210
 
211
-		$texte.= '</td>';
211
+		$texte .= '</td>';
212 212
 
213
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
-		$texte.= '</td>';
216
-		$texte.= '</tr>';
213
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
215
+		$texte .= '</td>';
216
+		$texte .= '</tr>';
217 217
 
218
-		$texte.= '</table>';
219
-		$texte.= '</form>';
218
+		$texte .= '</table>';
219
+		$texte .= '</form>';
220 220
 
221 221
 		return $texte;
222 222
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 *  @param		int			$hideref			Do not show ref
234 234
 	 *	@return		int         					1 if OK, <=0 if KO
235 235
 	 */
236
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
236
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
237 237
 	{
238 238
         // phpcs:enable
239 239
 		global $user, $langs, $conf, $mysoc, $hookmanager;
@@ -245,17 +245,17 @@  discard block
 block discarded – undo
245 245
 		}
246 246
 
247 247
 		// Add odtgeneration hook
248
-		if (! is_object($hookmanager))
248
+		if (!is_object($hookmanager))
249 249
 		{
250 250
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
-			$hookmanager=new HookManager($this->db);
251
+			$hookmanager = new HookManager($this->db);
252 252
 		}
253 253
 		$hookmanager->initHooks(array('odtgeneration'));
254 254
 		global $action;
255 255
 
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
257
-		$sav_charset_output=$outputlangs->charset_output;
258
-		$outputlangs->charset_output='UTF-8';
256
+		if (!is_object($outputlangs)) $outputlangs = $langs;
257
+		$sav_charset_output = $outputlangs->charset_output;
258
+		$outputlangs->charset_output = 'UTF-8';
259 259
 
260 260
 		// Load translation files required by the page
261 261
 		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
@@ -263,28 +263,28 @@  discard block
 block discarded – undo
263 263
 		if ($conf->supplier_proposal->dir_output)
264 264
 		{
265 265
 			// If $object is id instead of object
266
-			if (! is_object($object))
266
+			if (!is_object($object))
267 267
 			{
268 268
 				$id = $object;
269 269
 				$object = new SupplierProposal($this->db);
270
-				$result=$object->fetch($id);
270
+				$result = $object->fetch($id);
271 271
 				if ($result < 0)
272 272
 				{
273
-					dol_print_error($this->db,$object->error);
273
+					dol_print_error($this->db, $object->error);
274 274
 					return -1;
275 275
 				}
276 276
 			}
277 277
 
278 278
 			$dir = $conf->supplier_proposal->dir_output;
279 279
 			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
-			$file = $dir . "/" . $objectref . ".odt";
280
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
281
+			$file = $dir."/".$objectref.".odt";
282 282
 
283
-			if (! file_exists($dir))
283
+			if (!file_exists($dir))
284 284
 			{
285 285
 				if (dol_mkdir($dir) < 0)
286 286
 				{
287
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
287
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
288 288
 					return -1;
289 289
 				}
290 290
 			}
@@ -292,26 +292,26 @@  discard block
 block discarded – undo
292 292
 			if (file_exists($dir))
293 293
 			{
294 294
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
295
-				$newfile=basename($srctemplatepath);
296
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
295
+				$newfile = basename($srctemplatepath);
296
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
297
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
298
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
299 299
 
300
-				$newfiletmp=$objectref.'_'.$newfiletmp;
300
+				$newfiletmp = $objectref.'_'.$newfiletmp;
301 301
 
302 302
 				// Get extension (ods or odt)
303
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
303
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
304
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
305 305
 				{
306
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
308
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
306
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
307
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
308
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
309 309
 				}
310 310
 				else
311 311
 				{
312
-					$filename=$newfiletmp.'.'.$newfileformat;
312
+					$filename = $newfiletmp.'.'.$newfileformat;
313 313
 				}
314
-				$file=$dir.'/'.$filename;
314
+				$file = $dir.'/'.$filename;
315 315
 				//print "newdir=".$dir;
316 316
 				//print "newfile=".$newfile;
317 317
 				//print "file=".$file;
@@ -321,28 +321,28 @@  discard block
 block discarded – undo
321 321
 
322 322
 
323 323
 				// If BILLING contact defined on invoice, we use it
324
-				$usecontact=false;
325
-				$arrayidcontact=$object->getIdContact('external','BILLING');
324
+				$usecontact = false;
325
+				$arrayidcontact = $object->getIdContact('external', 'BILLING');
326 326
 				if (count($arrayidcontact) > 0)
327 327
 				{
328
-					$usecontact=true;
329
-					$result=$object->fetch_contact($arrayidcontact[0]);
328
+					$usecontact = true;
329
+					$result = $object->fetch_contact($arrayidcontact[0]);
330 330
 				}
331 331
 
332 332
 				// Recipient name
333
-				if (! empty($usecontact))
333
+				if (!empty($usecontact))
334 334
 				{
335 335
 					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
336
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337 337
 					else $socobject = $object->thirdparty;
338 338
 				}
339 339
 				else
340 340
 				{
341
-					$socobject=$object->thirdparty;
341
+					$socobject = $object->thirdparty;
342 342
 				}
343 343
 
344 344
 				// Make substitution
345
-				$substitutionarray=array(
345
+				$substitutionarray = array(
346 346
 				'__FROM_NAME__' => $this->emetteur->name,
347 347
 				'__FROM_EMAIL__' => $this->emetteur->email,
348 348
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 				);
352 352
 				complete_substitutions_array($substitutionarray, $langs, $object);
353 353
 				// Call the ODTSubstitution hook
354
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
354
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
355
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
356 356
 
357 357
 				// Line of free text
358
-				$newfreetext='';
359
-				$paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
-				if (! empty($conf->global->$paramfreetext))
358
+				$newfreetext = '';
359
+				$paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT';
360
+				if (!empty($conf->global->$paramfreetext))
361 361
 				{
362
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
362
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
363 363
 				}
364 364
 
365 365
 				// Open and load template
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 						$srctemplatepath,
370 370
 						array(
371 371
 							'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
372
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373 373
 							'DELIMITER_LEFT'  => '{',
374 374
 							'DELIMITER_RIGHT' => '}'
375 375
 						)
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 				}
378 378
 				catch (Exception $e)
379 379
 				{
380
-					$this->error=$e->getMessage();
380
+					$this->error = $e->getMessage();
381 381
 					dol_syslog($e->getMessage(), LOG_INFO);
382 382
 					return -1;
383 383
 				}
@@ -399,23 +399,23 @@  discard block
 block discarded – undo
399 399
 
400 400
 				// Define substitution array
401 401
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
-				$array_other=$this->get_substitutionarray_other($outputlangs);
402
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
403
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
404
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
405
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
406
+				$array_other = $this->get_substitutionarray_other($outputlangs);
407 407
 
408
-				$tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
408
+				$tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
409 409
 				complete_substitutions_array($tmparray, $outputlangs, $object);
410 410
 
411 411
 				// Call the ODTSubstitution hook
412
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
412
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
413
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
414 414
 
415
-				foreach($tmparray as $key=>$value)
415
+				foreach ($tmparray as $key=>$value)
416 416
 				{
417 417
 					try {
418
-						if (preg_match('/logo$/',$key)) // Image
418
+						if (preg_match('/logo$/', $key)) // Image
419 419
 						{
420 420
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
421 421
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
426 426
 						}
427 427
 					}
428
-					catch(OdfException $e)
428
+					catch (OdfException $e)
429 429
 					{
430 430
                         dol_syslog($e->getMessage(), LOG_INFO);
431 431
 					}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 					try {
438 438
 						$listlines = $odfHandler->setSegment('lines');
439 439
 					}
440
-					catch(OdfException $e)
440
+					catch (OdfException $e)
441 441
 					{
442 442
 						// We may arrive here if tags for lines not present into template
443 443
 						$foundtagforlines = 0;
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
 					{
448 448
 						foreach ($object->lines as $line)
449 449
 						{
450
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
450
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
451 451
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452 452
 							// Call the ODTSubstitutionLine hook
453
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
-							foreach($tmparray as $key => $val)
453
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
454
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
455
+							foreach ($tmparray as $key => $val)
456 456
 							{
457 457
 								try
458 458
 								{
459 459
 									$listlines->setVars($key, $val, true, 'UTF-8');
460 460
 								}
461
-								catch(OdfException $e)
461
+								catch (OdfException $e)
462 462
 								{
463 463
 									dol_syslog($e->getMessage(), LOG_INFO);
464 464
 								}
465
-								catch(SegmentException $e)
465
+								catch (SegmentException $e)
466 466
 								{
467 467
 									dol_syslog($e->getMessage(), LOG_INFO);
468 468
 								}
@@ -472,36 +472,36 @@  discard block
 block discarded – undo
472 472
 						$odfHandler->mergeSegment($listlines);
473 473
 					}
474 474
 				}
475
-				catch(OdfException $e)
475
+				catch (OdfException $e)
476 476
 				{
477
-					$this->error=$e->getMessage();
477
+					$this->error = $e->getMessage();
478 478
 					dol_syslog($this->error, LOG_WARNING);
479 479
 					return -1;
480 480
 				}
481 481
 
482 482
 				// Replace labels translated
483
-				$tmparray=$outputlangs->get_translations_for_substitutions();
484
-				foreach($tmparray as $key=>$value)
483
+				$tmparray = $outputlangs->get_translations_for_substitutions();
484
+				foreach ($tmparray as $key=>$value)
485 485
 				{
486 486
 					try {
487 487
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
488 488
 					}
489
-					catch(OdfException $e)
489
+					catch (OdfException $e)
490 490
 					{
491 491
                         dol_syslog($e->getMessage(), LOG_INFO);
492 492
 					}
493 493
 				}
494 494
 
495 495
 				// Call the beforeODTSave hook
496
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
496
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
497
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
498 498
 
499 499
 				// Write new file
500 500
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501 501
 					try {
502 502
 						$odfHandler->exportAsAttachedPDF($file);
503 503
 					} catch (Exception $e) {
504
-						$this->error=$e->getMessage();
504
+						$this->error = $e->getMessage();
505 505
                         dol_syslog($e->getMessage(), LOG_INFO);
506 506
 						return -1;
507 507
 					}
@@ -510,26 +510,26 @@  discard block
 block discarded – undo
510 510
 					try {
511 511
 						$odfHandler->saveToDisk($file);
512 512
 					} catch (Exception $e) {
513
-						$this->error=$e->getMessage();
513
+						$this->error = $e->getMessage();
514 514
                         dol_syslog($e->getMessage(), LOG_INFO);
515 515
 						return -1;
516 516
 					}
517 517
 				}
518
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
518
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
519
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
520 520
 
521
-				if (! empty($conf->global->MAIN_UMASK))
521
+				if (!empty($conf->global->MAIN_UMASK))
522 522
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
523 523
 
524
-				$odfHandler=null;	// Destroy object
524
+				$odfHandler = null; // Destroy object
525 525
 
526 526
 				$this->result = array('fullpath'=>$file);
527 527
 
528
-				return 1;   // Success
528
+				return 1; // Success
529 529
 			}
530 530
 			else
531 531
 			{
532
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
532
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
533 533
 				return -1;
534 534
 			}
535 535
 		}
Please login to merge, or discard this patch.
Braces   +45 added lines, -39 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 
98 98
 		// Recupere emetteur
99 99
 		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
100
+		if (! $this->emetteur->country_code) {
101
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
102
+		}
103
+		// By default if not defined
101 104
 	}
102 105
 
103 106
 
@@ -141,11 +144,14 @@  discard block
 block discarded – undo
141 144
 			if (! $tmpdir) {
142 145
 				unset($listofdir[$key]); continue;
143 146
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
147
+			if (! is_dir($tmpdir)) {
148
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
149
+			} else
146 150
 			{
147 151
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
152
+				if (count($tmpfiles)) {
153
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
154
+				}
149 155
 			}
150 156
 		}
151 157
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -253,7 +259,9 @@  discard block
 block discarded – undo
253 259
 		$hookmanager->initHooks(array('odtgeneration'));
254 260
 		global $action;
255 261
 
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
262
+		if (! is_object($outputlangs)) {
263
+		    $outputlangs=$langs;
264
+		}
257 265
 		$sav_charset_output=$outputlangs->charset_output;
258 266
 		$outputlangs->charset_output='UTF-8';
259 267
 
@@ -277,7 +285,9 @@  discard block
 block discarded – undo
277 285
 
278 286
 			$dir = $conf->supplier_proposal->dir_output;
279 287
 			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
288
+			if (! preg_match('/specimen/i',$objectref)) {
289
+			    $dir.= "/" . $objectref;
290
+			}
281 291
 			$file = $dir . "/" . $objectref . ".odt";
282 292
 
283 293
 			if (! file_exists($dir))
@@ -304,10 +314,11 @@  discard block
 block discarded – undo
304 314
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305 315
 				{
306 316
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
317
+				    if ($format == '1') {
318
+				        $format='%Y%m%d%H%M%S';
319
+				    }
308 320
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
-				}
310
-				else
321
+				} else
311 322
 				{
312 323
 					$filename=$newfiletmp.'.'.$newfileformat;
313 324
 				}
@@ -333,10 +344,12 @@  discard block
 block discarded – undo
333 344
 				if (! empty($usecontact))
334 345
 				{
335 346
 					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
-					else $socobject = $object->thirdparty;
338
-				}
339
-				else
347
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
348
+					    $socobject = $object->contact;
349
+					} else {
350
+					    $socobject = $object->thirdparty;
351
+					}
352
+				} else
340 353
 				{
341 354
 					$socobject=$object->thirdparty;
342 355
 				}
@@ -374,8 +387,7 @@  discard block
 block discarded – undo
374 387
 							'DELIMITER_RIGHT' => '}'
375 388
 						)
376 389
 					);
377
-				}
378
-				catch (Exception $e)
390
+				} catch (Exception $e)
379 391
 				{
380 392
 					$this->error=$e->getMessage();
381 393
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -391,8 +403,7 @@  discard block
 block discarded – undo
391 403
 				// Make substitutions into odt of freetext
392 404
 				try {
393 405
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
-				}
395
-				catch (OdfException $e)
406
+				} catch (OdfException $e)
396 407
 				{
397 408
 					dol_syslog($e->getMessage(), LOG_INFO);
398 409
 				}
@@ -415,17 +426,18 @@  discard block
 block discarded – undo
415 426
 				foreach($tmparray as $key=>$value)
416 427
 				{
417 428
 					try {
418
-						if (preg_match('/logo$/',$key)) // Image
429
+						if (preg_match('/logo$/',$key)) {
430
+						    // Image
419 431
 						{
420 432
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
421
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
-						}
423
-						else    // Text
433
+						} else {
434
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
435
+							}
436
+						} else    // Text
424 437
 						{
425 438
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
426 439
 						}
427
-					}
428
-					catch(OdfException $e)
440
+					} catch(OdfException $e)
429 441
 					{
430 442
                         dol_syslog($e->getMessage(), LOG_INFO);
431 443
 					}
@@ -436,8 +448,7 @@  discard block
 block discarded – undo
436 448
 					$foundtagforlines = 1;
437 449
 					try {
438 450
 						$listlines = $odfHandler->setSegment('lines');
439
-					}
440
-					catch(OdfException $e)
451
+					} catch(OdfException $e)
441 452
 					{
442 453
 						// We may arrive here if tags for lines not present into template
443 454
 						$foundtagforlines = 0;
@@ -457,12 +468,10 @@  discard block
 block discarded – undo
457 468
 								try
458 469
 								{
459 470
 									$listlines->setVars($key, $val, true, 'UTF-8');
460
-								}
461
-								catch(OdfException $e)
471
+								} catch(OdfException $e)
462 472
 								{
463 473
 									dol_syslog($e->getMessage(), LOG_INFO);
464
-								}
465
-								catch(SegmentException $e)
474
+								} catch(SegmentException $e)
466 475
 								{
467 476
 									dol_syslog($e->getMessage(), LOG_INFO);
468 477
 								}
@@ -471,8 +480,7 @@  discard block
 block discarded – undo
471 480
 						}
472 481
 						$odfHandler->mergeSegment($listlines);
473 482
 					}
474
-				}
475
-				catch(OdfException $e)
483
+				} catch(OdfException $e)
476 484
 				{
477 485
 					$this->error=$e->getMessage();
478 486
 					dol_syslog($this->error, LOG_WARNING);
@@ -485,8 +493,7 @@  discard block
 block discarded – undo
485 493
 				{
486 494
 					try {
487 495
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
488
-					}
489
-					catch(OdfException $e)
496
+					} catch(OdfException $e)
490 497
 					{
491 498
                         dol_syslog($e->getMessage(), LOG_INFO);
492 499
 					}
@@ -505,8 +512,7 @@  discard block
 block discarded – undo
505 512
                         dol_syslog($e->getMessage(), LOG_INFO);
506 513
 						return -1;
507 514
 					}
508
-				}
509
-				else {
515
+				} else {
510 516
 					try {
511 517
 						$odfHandler->saveToDisk($file);
512 518
 					} catch (Exception $e) {
@@ -518,16 +524,16 @@  discard block
 block discarded – undo
518 524
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519 525
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520 526
 
521
-				if (! empty($conf->global->MAIN_UMASK))
522
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
527
+				if (! empty($conf->global->MAIN_UMASK)) {
528
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
529
+				}
523 530
 
524 531
 				$odfHandler=null;	// Destroy object
525 532
 
526 533
 				$this->result = array('fullpath'=>$file);
527 534
 
528 535
 				return 1;   // Success
529
-			}
530
-			else
536
+			} else
531 537
 			{
532 538
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533 539
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php 3 patches
Indentation   +1228 added lines, -1228 removed lines patch added patch discarded remove patch
@@ -38,160 +38,160 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class pdf_aurore extends ModelePDFSupplierProposal
40 40
 {
41
-	/**
41
+    /**
42 42
      * @var DoliDb Database handler
43 43
      */
44 44
     public $db;
45 45
 
46
-	/**
46
+    /**
47 47
      * @var string model name
48 48
      */
49 49
     public $name;
50 50
 
51
-	/**
51
+    /**
52 52
      * @var string model description (short text)
53 53
      */
54 54
     public $description;
55 55
 
56
-	/**
56
+    /**
57 57
      * @var string document type
58 58
      */
59 59
     public $type;
60 60
 
61
-	/**
61
+    /**
62 62
      * @var array() Minimum version of PHP required by module.
63
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
63
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
64 64
      */
65
-	public $phpmin = array(5, 4);
65
+    public $phpmin = array(5, 4);
66 66
 
67
-	/**
67
+    /**
68 68
      * Dolibarr version of the loaded document
69 69
      * @public string
70 70
      */
71
-	public $version = 'dolibarr';
71
+    public $version = 'dolibarr';
72 72
 
73
-	/**
73
+    /**
74 74
      * @var int page_largeur
75 75
      */
76 76
     public $page_largeur;
77 77
 
78
-	/**
78
+    /**
79 79
      * @var int page_hauteur
80 80
      */
81 81
     public $page_hauteur;
82 82
 
83
-	/**
83
+    /**
84 84
      * @var array format
85 85
      */
86 86
     public $format;
87 87
 
88
-	/**
88
+    /**
89 89
      * @var int marge_gauche
90 90
      */
91
-	public $marge_gauche;
91
+    public $marge_gauche;
92 92
 
93
-	/**
93
+    /**
94 94
      * @var int marge_droite
95 95
      */
96
-	public $marge_droite;
96
+    public $marge_droite;
97 97
 
98
-	/**
98
+    /**
99 99
      * @var int marge_haute
100 100
      */
101
-	public $marge_haute;
101
+    public $marge_haute;
102 102
 
103
-	/**
103
+    /**
104 104
      * @var int marge_basse
105 105
      */
106
-	public $marge_basse;
107
-
108
-	/**
109
-	* Issuer
110
-	* @var Societe
111
-	*/
112
-	public $emetteur;
113
-
114
-
115
-	/**
116
-	 *	Constructor
117
-	 *
118
-	 *  @param		DoliDB		$db      Database handler
119
-	 */
120
-	public function __construct($db)
121
-	{
122
-		global $conf, $langs, $mysoc;
123
-
124
-		// Translations
125
-		$langs->loadLangs(array("main", "bills"));
126
-
127
-		$this->db = $db;
128
-		$this->name = "aurore";
129
-		$this->description = $langs->trans('DocModelAuroreDescription');
130
-
131
-		// Dimension page pour format A4
132
-		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
134
-		$this->page_largeur = $formatarray['width'];
135
-		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
-
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
148
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
149
-		$this->option_credit_note = 1;             // Support credit notes
150
-		$this->option_freetext = 1;				   // Support add of a personalised text
151
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
-
153
-		$this->franchise=!$mysoc->tva_assuj;
154
-
155
-		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
158
-
159
-		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
161
-		$this->posxdiscount=162;
162
-		$this->postotalht=174;
163
-
164
-		if ($conf->global->PRODUCT_USE_UNITS)
165
-		{
166
-		    $this->posxtva=101;
167
-		    $this->posxup=118;
168
-		    $this->posxqty=135;
169
-		    $this->posxunit=151;
170
-		} else {
171
-		    $this->posxtva=102;
172
-		    $this->posxup=126;
173
-		    $this->posxqty=145;
174
-		}
175
-
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
-		if ($this->page_largeur < 210) // To work with US executive format
179
-		{
180
-			$this->posxpicture-=20;
181
-			$this->posxtva-=20;
182
-			$this->posxup-=20;
183
-			$this->posxqty-=20;
184
-			$this->posxunit-=20;
185
-			$this->posxdiscount-=20;
186
-			$this->postotalht-=20;
187
-		}
188
-
189
-		$this->tva=array();
190
-		$this->localtax1=array();
191
-		$this->localtax2=array();
192
-		$this->atleastoneratenotnull=0;
193
-		$this->atleastonediscount=0;
194
-	}
106
+    public $marge_basse;
107
+
108
+    /**
109
+     * Issuer
110
+     * @var Societe
111
+     */
112
+    public $emetteur;
113
+
114
+
115
+    /**
116
+     *	Constructor
117
+     *
118
+     *  @param		DoliDB		$db      Database handler
119
+     */
120
+    public function __construct($db)
121
+    {
122
+        global $conf, $langs, $mysoc;
123
+
124
+        // Translations
125
+        $langs->loadLangs(array("main", "bills"));
126
+
127
+        $this->db = $db;
128
+        $this->name = "aurore";
129
+        $this->description = $langs->trans('DocModelAuroreDescription');
130
+
131
+        // Dimension page pour format A4
132
+        $this->type = 'pdf';
133
+        $formatarray=pdf_getFormat();
134
+        $this->page_largeur = $formatarray['width'];
135
+        $this->page_hauteur = $formatarray['height'];
136
+        $this->format = array($this->page_largeur,$this->page_hauteur);
137
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
+
142
+        $this->option_logo = 1;                    // Affiche logo
143
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
+        $this->option_modereg = 1;                 // Affiche mode reglement
145
+        $this->option_condreg = 1;                 // Affiche conditions reglement
146
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
147
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
148
+        $this->option_escompte = 1;                // Affiche si il y a eu escompte
149
+        $this->option_credit_note = 1;             // Support credit notes
150
+        $this->option_freetext = 1;				   // Support add of a personalised text
151
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
+
153
+        $this->franchise=!$mysoc->tva_assuj;
154
+
155
+        // Get source company
156
+        $this->emetteur=$mysoc;
157
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
158
+
159
+        // Define position of columns
160
+        $this->posxdesc=$this->marge_gauche+1;
161
+        $this->posxdiscount=162;
162
+        $this->postotalht=174;
163
+
164
+        if ($conf->global->PRODUCT_USE_UNITS)
165
+        {
166
+            $this->posxtva=101;
167
+            $this->posxup=118;
168
+            $this->posxqty=135;
169
+            $this->posxunit=151;
170
+        } else {
171
+            $this->posxtva=102;
172
+            $this->posxup=126;
173
+            $this->posxqty=145;
174
+        }
175
+
176
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
+        if ($this->page_largeur < 210) // To work with US executive format
179
+        {
180
+            $this->posxpicture-=20;
181
+            $this->posxtva-=20;
182
+            $this->posxup-=20;
183
+            $this->posxqty-=20;
184
+            $this->posxunit-=20;
185
+            $this->posxdiscount-=20;
186
+            $this->postotalht-=20;
187
+        }
188
+
189
+        $this->tva=array();
190
+        $this->localtax1=array();
191
+        $this->localtax2=array();
192
+        $this->atleastoneratenotnull=0;
193
+        $this->atleastonediscount=0;
194
+    }
195 195
 
196 196
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
197 197
     /**
@@ -204,105 +204,105 @@  discard block
 block discarded – undo
204 204
      *  @param		int			$hidedesc			Do not show desc
205 205
      *  @param		int			$hideref			Do not show ref
206 206
      *  @return     int             				1=OK, 0=KO
207
-	 */
208
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
209
-	{
207
+     */
208
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
209
+    {
210 210
         // phpcs:enable
211
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
211
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
212 212
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
214
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
213
+        if (! is_object($outputlangs)) $outputlangs=$langs;
214
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
216 216
 
217
-		// Load traductions files requiredby by page
218
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
217
+        // Load traductions files requiredby by page
218
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
219 219
 
220
-		$nblignes = count($object->lines);
220
+        $nblignes = count($object->lines);
221 221
 
222
-		// Loop on each lines to detect if there is at least one image to show
223
-		$realpatharray=array();
224
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225
-		{
226
-			for ($i = 0 ; $i < $nblignes ; $i++)
227
-			{
228
-				if (empty($object->lines[$i]->fk_product)) continue;
229
-
230
-				$objphoto = new Product($this->db);
231
-				$objphoto->fetch($object->lines[$i]->fk_product);
222
+        // Loop on each lines to detect if there is at least one image to show
223
+        $realpatharray=array();
224
+        if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225
+        {
226
+            for ($i = 0 ; $i < $nblignes ; $i++)
227
+            {
228
+                if (empty($object->lines[$i]->fk_product)) continue;
232 229
 
233
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234
-				{
235
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236
-					$dir = $conf->product->dir_output.'/'.$pdir;
237
-				}
238
-				else
239
-				{
240
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241
-					$dir = $conf->product->dir_output.'/'.$pdir;
242
-				}
243
-
244
-				$realpath='';
245
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
246
-				{
247
-					$filename=$obj['photo'];
248
-					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249
-					$realpath = $dir.$filename;
250
-					break;
251
-				}
252
-
253
-				if ($realpath) $realpatharray[$i]=$realpath;
254
-			}
255
-		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
257
-
258
-		if ($conf->supplier_proposal->dir_output)
259
-		{
260
-			$object->fetch_thirdparty();
230
+                $objphoto = new Product($this->db);
231
+                $objphoto->fetch($object->lines[$i]->fk_product);
261 232
 
262
-			// $deja_regle = 0;
233
+                if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234
+                {
235
+                    $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236
+                    $dir = $conf->product->dir_output.'/'.$pdir;
237
+                }
238
+                else
239
+                {
240
+                    $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241
+                    $dir = $conf->product->dir_output.'/'.$pdir;
242
+                }
263 243
 
264
-			// Definition of $dir and $file
265
-			if ($object->specimen)
266
-			{
267
-				$dir = $conf->supplier_proposal->dir_output;
268
-				$file = $dir . "/SPECIMEN.pdf";
269
-			}
270
-			else
271
-			{
272
-				$objectref = dol_sanitizeFileName($object->ref);
273
-				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
-				$file = $dir . "/" . $objectref . ".pdf";
275
-			}
244
+                $realpath='';
245
+                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
246
+                {
247
+                    $filename=$obj['photo'];
248
+                    //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249
+                    $realpath = $dir.$filename;
250
+                    break;
251
+                }
276 252
 
277
-			if (! file_exists($dir))
278
-			{
279
-				if (dol_mkdir($dir) < 0)
280
-				{
281
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
282
-					return 0;
283
-				}
284
-			}
253
+                if ($realpath) $realpatharray[$i]=$realpath;
254
+            }
255
+        }
256
+        if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
257
+
258
+        if ($conf->supplier_proposal->dir_output)
259
+        {
260
+            $object->fetch_thirdparty();
261
+
262
+            // $deja_regle = 0;
263
+
264
+            // Definition of $dir and $file
265
+            if ($object->specimen)
266
+            {
267
+                $dir = $conf->supplier_proposal->dir_output;
268
+                $file = $dir . "/SPECIMEN.pdf";
269
+            }
270
+            else
271
+            {
272
+                $objectref = dol_sanitizeFileName($object->ref);
273
+                $dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
+                $file = $dir . "/" . $objectref . ".pdf";
275
+            }
276
+
277
+            if (! file_exists($dir))
278
+            {
279
+                if (dol_mkdir($dir) < 0)
280
+                {
281
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
282
+                    return 0;
283
+                }
284
+            }
285 285
 
286
-			if (file_exists($dir))
287
-			{
288
-				// Add pdfgeneration hook
289
-				if (! is_object($hookmanager))
290
-				{
291
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
-					$hookmanager=new HookManager($this->db);
293
-				}
294
-				$hookmanager->initHooks(array('pdfgeneration'));
295
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
296
-				global $action;
297
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
286
+            if (file_exists($dir))
287
+            {
288
+                // Add pdfgeneration hook
289
+                if (! is_object($hookmanager))
290
+                {
291
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
+                    $hookmanager=new HookManager($this->db);
293
+                }
294
+                $hookmanager->initHooks(array('pdfgeneration'));
295
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
296
+                global $action;
297
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
298 298
 
299
-				// Create pdf instance
299
+                // Create pdf instance
300 300
                 $pdf=pdf_getInstance($this->format);
301 301
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
302 302
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
303
-		        $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
304
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
303
+                $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
304
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
306 306
                 $pdf->SetAutoPageBreak(1,0);
307 307
 
308 308
                 if (class_exists('TCPDF'))
@@ -318,189 +318,189 @@  discard block
 block discarded – undo
318 318
                     $tplidx = $pdf->importPage(1);
319 319
                 }
320 320
 
321
-				$pdf->Open();
322
-				$pagenb=0;
323
-				$pdf->SetDrawColor(128,128,128);
321
+                $pdf->Open();
322
+                $pagenb=0;
323
+                $pdf->SetDrawColor(128,128,128);
324 324
 
325
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326
-				$pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
325
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326
+                $pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
328
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
331 331
 
332
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
332
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
333 333
 
334
-				// Positionne $this->atleastonediscount si on a au moins une remise
335
-				for ($i = 0 ; $i < $nblignes ; $i++)
336
-				{
337
-					if ($object->lines[$i]->remise_percent)
338
-					{
339
-						$this->atleastonediscount++;
340
-					}
341
-				}
342
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343
-				{
344
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
346
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
347
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
348
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
349
-					//$this->postotalht;
350
-				}
334
+                // Positionne $this->atleastonediscount si on a au moins une remise
335
+                for ($i = 0 ; $i < $nblignes ; $i++)
336
+                {
337
+                    if ($object->lines[$i]->remise_percent)
338
+                    {
339
+                        $this->atleastonediscount++;
340
+                    }
341
+                }
342
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343
+                {
344
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
346
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
347
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
348
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
349
+                    //$this->postotalht;
350
+                }
351 351
 
352
-				// New page
353
-				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
-				$pagenb++;
356
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
-				$pdf->SetFont('','', $default_font_size - 1);
358
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
359
-				$pdf->SetTextColor(0,0,0);
360
-
361
-				$tab_top = 90+$top_shift;
362
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
363
-
364
-				// Affiche notes
365
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
366
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367
-				{
368
-					// Get first sale rep
369
-					if (is_object($object->thirdparty))
370
-					{
371
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
-						$salerepobj=new User($this->db);
373
-						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
375
-					}
376
-				}
377
-				if ($notetoshow)
378
-				{
379
-					$tab_top -= 2;
352
+                // New page
353
+                $pdf->AddPage();
354
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
+                $pagenb++;
356
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
+                $pdf->SetFont('','', $default_font_size - 1);
358
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
359
+                $pdf->SetTextColor(0,0,0);
360
+
361
+                $tab_top = 90+$top_shift;
362
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
363
+
364
+                // Affiche notes
365
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
366
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367
+                {
368
+                    // Get first sale rep
369
+                    if (is_object($object->thirdparty))
370
+                    {
371
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
+                        $salerepobj=new User($this->db);
373
+                        $salerepobj->fetch($salereparray[0]['id']);
374
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
375
+                    }
376
+                }
377
+                if ($notetoshow)
378
+                {
379
+                    $tab_top -= 2;
380 380
 
381 381
                     $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
382
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
383
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
384
-
385
-					$pdf->SetFont('','', $default_font_size - 1);
386
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
387
-					$nexY = $pdf->GetY();
388
-					$height_note=$nexY-$tab_top;
389
-
390
-					// Rect prend une longueur en 3eme param
391
-					$pdf->SetDrawColor(192,192,192);
392
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
393
-
394
-					$tab_top = $nexY+6;
395
-				}
396
-
397
-				$iniY = $tab_top + 7;
398
-				$curY = $tab_top + 7;
399
-				$nexY = $tab_top + 7;
400
-
401
-				// Loop on each lines
402
-				for ($i = 0 ; $i < $nblignes ; $i++)
403
-				{
404
-					$curY = $nexY;
405
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
-					$pdf->SetTextColor(0,0,0);
407
-
408
-					// Define size of image if we need it
409
-					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
411
-
412
-					$pdf->setTopMargin($tab_top_newpage);
413
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
-					$pageposbefore=$pdf->getPage();
415
-
416
-					$showpricebeforepagebreak=1;
417
-					$posYAfterImage=0;
418
-					$posYAfterDescription=0;
419
-
420
-					// We start with Photo of product line
421
-					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
422
-					{
423
-						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
-						$pdf->setPage($pageposbefore+1);
427
-
428
-						$curY = $tab_top_newpage;
429
-						$showpricebeforepagebreak=0;
430
-					}
431
-
432
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433
-					{
434
-						$curX = $this->posxpicture-1;
435
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
436
-						// $pdf->Image does not increase value return by getY, so we save it manually
437
-						$posYAfterImage=$curY+$imglinesize['height'];
438
-					}
382
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
383
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
439 384
 
440
-					// Description of product line
441
-					$curX = $this->posxdesc-1;
385
+                    $pdf->SetFont('','', $default_font_size - 1);
386
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
387
+                    $nexY = $pdf->GetY();
388
+                    $height_note=$nexY-$tab_top;
442 389
 
443
-					$pdf->startTransaction();
444
-					if ($posYAfterImage > 0)
445
-					{
446
-						$descWidth = $this->posxpicture-$curX;
447
-					}
448
-					else
449
-					{
450
-						$descWidth = $this->posxtva-$curX;
451
-					}
452
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453
-
454
-					$pageposafter=$pdf->getPage();
455
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
456
-					{
457
-						$pdf->rollbackTransaction(true);
458
-						$pageposafter=$pageposbefore;
459
-						//print $pageposafter.'-'.$pageposbefore;exit;
460
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
462
-
463
-						$pageposafter=$pdf->getPage();
464
-						$posyafter=$pdf->GetY();
465
-						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
467
-						{
468
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469
-							{
470
-								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
-								$pdf->setPage($pageposafter+1);
474
-							}
475
-						}
476
-						else
477
-						{
478
-							// We found a page break
479
-							$showpricebeforepagebreak=0;
480
-						}
481
-					}
482
-					else	// No pagebreak
483
-					{
484
-						$pdf->commitTransaction();
485
-					}
486
-					$posYAfterDescription=$pdf->GetY();
487
-
488
-					$nexY = $pdf->GetY();
489
-					$pageposafter=$pdf->getPage();
390
+                    // Rect prend une longueur en 3eme param
391
+                    $pdf->SetDrawColor(192,192,192);
392
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
490 393
 
491
-					$pdf->setPage($pageposbefore);
492
-					$pdf->setTopMargin($this->marge_haute);
493
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
494
-
495
-					// We suppose that a too long description or photo were moved completely on next page
496
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498
-					}
394
+                    $tab_top = $nexY+6;
395
+                }
499 396
 
500
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
397
+                $iniY = $tab_top + 7;
398
+                $curY = $tab_top + 7;
399
+                $nexY = $tab_top + 7;
501 400
 
502
-					// VAT Rate
503
-					/*
401
+                // Loop on each lines
402
+                for ($i = 0 ; $i < $nblignes ; $i++)
403
+                {
404
+                    $curY = $nexY;
405
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
+                    $pdf->SetTextColor(0,0,0);
407
+
408
+                    // Define size of image if we need it
409
+                    $imglinesize=array();
410
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
411
+
412
+                    $pdf->setTopMargin($tab_top_newpage);
413
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
+                    $pageposbefore=$pdf->getPage();
415
+
416
+                    $showpricebeforepagebreak=1;
417
+                    $posYAfterImage=0;
418
+                    $posYAfterDescription=0;
419
+
420
+                    // We start with Photo of product line
421
+                    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
422
+                    {
423
+                        $pdf->AddPage('','',true);
424
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
+                        $pdf->setPage($pageposbefore+1);
427
+
428
+                        $curY = $tab_top_newpage;
429
+                        $showpricebeforepagebreak=0;
430
+                    }
431
+
432
+                    if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433
+                    {
434
+                        $curX = $this->posxpicture-1;
435
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
436
+                        // $pdf->Image does not increase value return by getY, so we save it manually
437
+                        $posYAfterImage=$curY+$imglinesize['height'];
438
+                    }
439
+
440
+                    // Description of product line
441
+                    $curX = $this->posxdesc-1;
442
+
443
+                    $pdf->startTransaction();
444
+                    if ($posYAfterImage > 0)
445
+                    {
446
+                        $descWidth = $this->posxpicture-$curX;
447
+                    }
448
+                    else
449
+                    {
450
+                        $descWidth = $this->posxtva-$curX;
451
+                    }
452
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453
+
454
+                    $pageposafter=$pdf->getPage();
455
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
456
+                    {
457
+                        $pdf->rollbackTransaction(true);
458
+                        $pageposafter=$pageposbefore;
459
+                        //print $pageposafter.'-'.$pageposbefore;exit;
460
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
462
+
463
+                        $pageposafter=$pdf->getPage();
464
+                        $posyafter=$pdf->GetY();
465
+                        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
467
+                        {
468
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469
+                            {
470
+                                $pdf->AddPage('','',true);
471
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
+                                $pdf->setPage($pageposafter+1);
474
+                            }
475
+                        }
476
+                        else
477
+                        {
478
+                            // We found a page break
479
+                            $showpricebeforepagebreak=0;
480
+                        }
481
+                    }
482
+                    else	// No pagebreak
483
+                    {
484
+                        $pdf->commitTransaction();
485
+                    }
486
+                    $posYAfterDescription=$pdf->GetY();
487
+
488
+                    $nexY = $pdf->GetY();
489
+                    $pageposafter=$pdf->getPage();
490
+
491
+                    $pdf->setPage($pageposbefore);
492
+                    $pdf->setTopMargin($this->marge_haute);
493
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
494
+
495
+                    // We suppose that a too long description or photo were moved completely on next page
496
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498
+                    }
499
+
500
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
501
+
502
+                    // VAT Rate
503
+                    /*
504 504
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
505 505
 					{
506 506
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
@@ -515,29 +515,29 @@  discard block
 block discarded – undo
515 515
 						$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
516 516
                     */
517 517
 
518
-					// Quantity
519
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520
-					$pdf->SetXY($this->posxqty, $curY);
521
-					// Enough for 6 chars
522
-					if($conf->global->PRODUCT_USE_UNITS)
523
-					{
524
-					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
-					}
526
-					else
527
-					{
528
-					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529
-					}
530
-
531
-					// Unit
532
-					if($conf->global->PRODUCT_USE_UNITS)
533
-					{
534
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535
-					    $pdf->SetXY($this->posxunit, $curY);
536
-					    $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
537
-					}
538
-
539
-					// Discount on line
540
-					/*
518
+                    // Quantity
519
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520
+                    $pdf->SetXY($this->posxqty, $curY);
521
+                    // Enough for 6 chars
522
+                    if($conf->global->PRODUCT_USE_UNITS)
523
+                    {
524
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
+                    }
526
+                    else
527
+                    {
528
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529
+                    }
530
+
531
+                    // Unit
532
+                    if($conf->global->PRODUCT_USE_UNITS)
533
+                    {
534
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535
+                        $pdf->SetXY($this->posxunit, $curY);
536
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
537
+                    }
538
+
539
+                    // Discount on line
540
+                    /*
541 541
 					if ($object->lines[$i]->remise_percent)
542 542
 					{
543 543
 						$pdf->SetXY($this->posxdiscount-2, $curY);
@@ -552,217 +552,217 @@  discard block
 block discarded – undo
552 552
 						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
553 553
                     */
554 554
 
555
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
558
-
559
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
560
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
561
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
562
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
563
-					$localtax1_type=$object->lines[$i]->localtax1_type;
564
-					$localtax2_type=$object->lines[$i]->localtax2_type;
565
-
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
569
-
570
-					$vatrate=(string) $object->lines[$i]->tva_tx;
571
-
572
-					// Retrieve type from database for backward compatibility with old records
573
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
575
-					{
576
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
577
-						$localtax1_type = $localtaxtmp_array[0];
578
-						$localtax2_type = $localtaxtmp_array[2];
579
-					}
580
-
581
-				    // retrieve global local tax
582
-					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
-					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
586
-
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
589
-					$this->tva[$vatrate] += $tvaligne;
590
-
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
592
-
593
-					// Add line
594
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595
-					{
596
-						$pdf->setPage($pageposafter);
597
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
598
-						//$pdf->SetDrawColor(190,190,200);
599
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
600
-						$pdf->SetLineStyle(array('dash'=>0));
601
-					}
602
-
603
-					$nexY+=2;    // Passe espace entre les lignes
604
-
605
-					// Detect if some page were added automatically and output _tableau for past pages
606
-					while ($pagenb < $pageposafter)
607
-					{
608
-						$pdf->setPage($pagenb);
609
-						if ($pagenb == 1)
610
-						{
611
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
-						}
613
-						else
614
-						{
615
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616
-						}
617
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
618
-						$pagenb++;
619
-						$pdf->setPage($pagenb);
620
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622
-					}
623
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624
-					{
625
-						if ($pagenb == 1)
626
-						{
627
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
-						}
629
-						else
630
-						{
631
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632
-						}
633
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
634
-						// New page
635
-						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
637
-						$pagenb++;
638
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639
-					}
640
-				}
555
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
+                    else $tvaligne=$object->lines[$i]->total_tva;
558
+
559
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
560
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
561
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
562
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
563
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
564
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
565
+
566
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
569
+
570
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
571
+
572
+                    // Retrieve type from database for backward compatibility with old records
573
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
575
+                    {
576
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
577
+                        $localtax1_type = $localtaxtmp_array[0];
578
+                        $localtax2_type = $localtaxtmp_array[2];
579
+                    }
580
+
581
+                    // retrieve global local tax
582
+                    if ($localtax1_type && $localtax1ligne != 0)
583
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
+                    if ($localtax2_type && $localtax2ligne != 0)
585
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
586
+
587
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
+                    if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
589
+                    $this->tva[$vatrate] += $tvaligne;
590
+
591
+                    if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
592
+
593
+                    // Add line
594
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595
+                    {
596
+                        $pdf->setPage($pageposafter);
597
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
598
+                        //$pdf->SetDrawColor(190,190,200);
599
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
600
+                        $pdf->SetLineStyle(array('dash'=>0));
601
+                    }
602
+
603
+                    $nexY+=2;    // Passe espace entre les lignes
604
+
605
+                    // Detect if some page were added automatically and output _tableau for past pages
606
+                    while ($pagenb < $pageposafter)
607
+                    {
608
+                        $pdf->setPage($pagenb);
609
+                        if ($pagenb == 1)
610
+                        {
611
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
+                        }
613
+                        else
614
+                        {
615
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616
+                        }
617
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
618
+                        $pagenb++;
619
+                        $pdf->setPage($pagenb);
620
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622
+                    }
623
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624
+                    {
625
+                        if ($pagenb == 1)
626
+                        {
627
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
+                        }
629
+                        else
630
+                        {
631
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632
+                        }
633
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
634
+                        // New page
635
+                        $pdf->AddPage();
636
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
637
+                        $pagenb++;
638
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639
+                    }
640
+                }
641 641
 
642
-				// Show square
643
-				if ($pagenb == 1)
644
-				{
645
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
-				}
648
-				else
649
-				{
650
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
-				}
642
+                // Show square
643
+                if ($pagenb == 1)
644
+                {
645
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
+                }
648
+                else
649
+                {
650
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
+                }
653 653
 
654
-				// Affiche zone infos
655
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
654
+                // Affiche zone infos
655
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
656 656
 
657
-				// Affiche zone totaux
658
-				//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
657
+                // Affiche zone totaux
658
+                //$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
659 659
 
660
-				// Affiche zone versements
661
-				/*
660
+                // Affiche zone versements
661
+                /*
662 662
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
663 663
 				{
664 664
 					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
665 665
 				}
666 666
 				*/
667 667
 
668
-				// Pied de page
669
-				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
668
+                // Pied de page
669
+                $this->_pagefoot($pdf,$object,$outputlangs);
670
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
671 671
 
672
-				$pdf->Close();
672
+                $pdf->Close();
673 673
 
674
-				$pdf->Output($file,'F');
674
+                $pdf->Output($file,'F');
675 675
 
676
-				//Add pdfgeneration hook
677
-				$hookmanager->initHooks(array('pdfgeneration'));
678
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
679
-				global $action;
680
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
676
+                //Add pdfgeneration hook
677
+                $hookmanager->initHooks(array('pdfgeneration'));
678
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
679
+                global $action;
680
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
681 681
 
682
-				if (! empty($conf->global->MAIN_UMASK))
683
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
682
+                if (! empty($conf->global->MAIN_UMASK))
683
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
684 684
 
685
-				$this->result = array('fullpath'=>$file);
685
+                $this->result = array('fullpath'=>$file);
686 686
 
687
-				return 1;   // Pas d'erreur
688
-			}
689
-			else
690
-			{
691
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692
-				return 0;
693
-			}
694
-		}
695
-		else
696
-		{
697
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698
-			return 0;
699
-		}
700
-	}
687
+                return 1;   // Pas d'erreur
688
+            }
689
+            else
690
+            {
691
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692
+                return 0;
693
+            }
694
+        }
695
+        else
696
+        {
697
+            $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698
+            return 0;
699
+        }
700
+    }
701 701
 
702 702
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
703
-	/**
704
-	 *  Show payments table
705
-	 *
703
+    /**
704
+     *  Show payments table
705
+     *
706 706
      *  @param	PDF			$pdf           Object PDF
707 707
      *  @param  Object		$object         Object proposal
708 708
      *  @param  int			$posy           Position y in PDF
709 709
      *  @param  Translate	$outputlangs    Object langs for output
710 710
      *  @return int             			<0 if KO, >0 if OK
711
-	 */
712
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
713
-	{
711
+     */
712
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
713
+    {
714 714
         // phpcs:enable
715
-	}
715
+    }
716 716
 
717 717
 
718 718
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
719
-	/**
720
-	 *   Show miscellaneous information (payment mode, payment term, ...)
721
-	 *
722
-	 *   @param		PDF			$pdf     		Object PDF
723
-	 *   @param		Object		$object			Object to show
724
-	 *   @param		int			$posy			Y
725
-	 *   @param		Translate	$outputlangs	Langs object
726
-	 *   @return	void
727
-	 */
728
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
729
-	{
719
+    /**
720
+     *   Show miscellaneous information (payment mode, payment term, ...)
721
+     *
722
+     *   @param		PDF			$pdf     		Object PDF
723
+     *   @param		Object		$object			Object to show
724
+     *   @param		int			$posy			Y
725
+     *   @param		Translate	$outputlangs	Langs object
726
+     *   @return	void
727
+     */
728
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
729
+    {
730 730
         // phpcs:enable
731
-		global $conf;
732
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
731
+        global $conf;
732
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
733 733
 
734
-		$pdf->SetFont('','', $default_font_size - 1);
734
+        $pdf->SetFont('','', $default_font_size - 1);
735 735
 
736
-		$posxval=52;
736
+        $posxval=52;
737 737
 
738 738
         // Show shipping date
739 739
         if (! empty($object->date_livraison))
740
-		{
740
+        {
741 741
             $outputlangs->load("sendings");
742
-			$pdf->SetFont('','B', $default_font_size - 2);
743
-			$pdf->SetXY($this->marge_gauche, $posy);
744
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
746
-			$pdf->SetFont('','', $default_font_size - 2);
747
-			$pdf->SetXY($posxval, $posy);
748
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
749
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
742
+            $pdf->SetFont('','B', $default_font_size - 2);
743
+            $pdf->SetXY($this->marge_gauche, $posy);
744
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
746
+            $pdf->SetFont('','', $default_font_size - 2);
747
+            $pdf->SetXY($posxval, $posy);
748
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
749
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 750
 
751 751
             $posy=$pdf->GetY()+1;
752
-		}
753
-		else {
754
-			$outputlangs->load("sendings");
755
-			$pdf->SetFont('','B', $default_font_size - 2);
756
-			$pdf->SetXY($this->marge_gauche, $posy);
757
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
759
-			$pdf->SetFont('','', $default_font_size - 2);
760
-			$pdf->SetXY($posxval, $posy);
761
-			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752
+        }
753
+        else {
754
+            $outputlangs->load("sendings");
755
+            $pdf->SetFont('','B', $default_font_size - 2);
756
+            $pdf->SetXY($this->marge_gauche, $posy);
757
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
759
+            $pdf->SetFont('','', $default_font_size - 2);
760
+            $pdf->SetXY($posxval, $posy);
761
+            //$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
763 763
 
764 764
             $posy=$pdf->GetY()+1;
765
-		}
765
+        }
766 766
         /* PHFAVRE
767 767
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
768 768
 		{
@@ -780,350 +780,350 @@  discard block
 block discarded – undo
780 780
 			$posy=$pdf->GetY()+1;
781 781
 		}*/
782 782
 
783
-		// Show payments conditions
784
-		if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785
-		{
786
-			$pdf->SetFont('','B', $default_font_size - 2);
787
-			$pdf->SetXY($this->marge_gauche, $posy);
788
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
789
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
790
-
791
-			$pdf->SetFont('','', $default_font_size - 2);
792
-			$pdf->SetXY($posxval, $posy);
793
-			$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);
794
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
796
-
797
-			$posy=$pdf->GetY()+3;
798
-		}
799
-
800
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801
-		{
802
-			// Show payment mode
803
-			if ($object->mode_reglement_code
804
-			&& $object->mode_reglement_code != 'CHQ'
805
-			&& $object->mode_reglement_code != 'VIR')
806
-			{
807
-				$pdf->SetFont('','B', $default_font_size - 2);
808
-				$pdf->SetXY($this->marge_gauche, $posy-2);
809
-				$titre = $outputlangs->transnoentities("PaymentMode").':';
810
-				$pdf->MultiCell(80, 5, $titre, 0, 'L');
811
-				$pdf->SetFont('','', $default_font_size - 2);
812
-				$pdf->SetXY($posxval, $posy-2);
813
-				$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);
814
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
815
-
816
-				$posy=$pdf->GetY()+2;
817
-			}
818
-
819
-			// Show payment mode CHQ
820
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821
-			{
822
-				// Si mode reglement non force ou si force a CHQ
823
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
824
-				{
825
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
826
-
827
-					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828
-					{
829
-						$account = new Account($this->db);
830
-						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831
-
832
-						$pdf->SetXY($this->marge_gauche, $posy);
833
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
-						$posy=$pdf->GetY()+1;
836
-
837
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838
-			            {
839
-							$pdf->SetXY($this->marge_gauche, $posy);
840
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
841
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
-							$posy=$pdf->GetY()+2;
843
-			            }
844
-					}
845
-					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846
-					{
847
-						$pdf->SetXY($this->marge_gauche, $posy);
848
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
-						$posy=$pdf->GetY()+1;
851
-
852
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853
-			            {
854
-							$pdf->SetXY($this->marge_gauche, $posy);
855
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
856
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
-							$posy=$pdf->GetY()+2;
858
-			            }
859
-					}
860
-				}
861
-			}
783
+        // Show payments conditions
784
+        if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785
+        {
786
+            $pdf->SetFont('','B', $default_font_size - 2);
787
+            $pdf->SetXY($this->marge_gauche, $posy);
788
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
789
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
790
+
791
+            $pdf->SetFont('','', $default_font_size - 2);
792
+            $pdf->SetXY($posxval, $posy);
793
+            $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);
794
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
+            $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
796
+
797
+            $posy=$pdf->GetY()+3;
798
+        }
799
+
800
+        if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801
+        {
802
+            // Show payment mode
803
+            if ($object->mode_reglement_code
804
+            && $object->mode_reglement_code != 'CHQ'
805
+            && $object->mode_reglement_code != 'VIR')
806
+            {
807
+                $pdf->SetFont('','B', $default_font_size - 2);
808
+                $pdf->SetXY($this->marge_gauche, $posy-2);
809
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
810
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
811
+                $pdf->SetFont('','', $default_font_size - 2);
812
+                $pdf->SetXY($posxval, $posy-2);
813
+                $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);
814
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
815
+
816
+                $posy=$pdf->GetY()+2;
817
+            }
818
+
819
+            // Show payment mode CHQ
820
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821
+            {
822
+                // Si mode reglement non force ou si force a CHQ
823
+                if (! empty($conf->global->FACTURE_CHQ_NUMBER))
824
+                {
825
+                    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
826
+
827
+                    if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828
+                    {
829
+                        $account = new Account($this->db);
830
+                        $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831
+
832
+                        $pdf->SetXY($this->marge_gauche, $posy);
833
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
+                        $posy=$pdf->GetY()+1;
836
+
837
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838
+                        {
839
+                            $pdf->SetXY($this->marge_gauche, $posy);
840
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
841
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
+                            $posy=$pdf->GetY()+2;
843
+                        }
844
+                    }
845
+                    if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846
+                    {
847
+                        $pdf->SetXY($this->marge_gauche, $posy);
848
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
+                        $posy=$pdf->GetY()+1;
851
+
852
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853
+                        {
854
+                            $pdf->SetXY($this->marge_gauche, $posy);
855
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
856
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
+                            $posy=$pdf->GetY()+2;
858
+                        }
859
+                    }
860
+                }
861
+            }
862 862
 
863
-			// If payment mode not forced or forced to VIR, show payment with BAN
864
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865
-			{
866
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
867
-				{
868
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
869
-					$account = new Account($this->db);
870
-					$account->fetch($bankid);
863
+            // If payment mode not forced or forced to VIR, show payment with BAN
864
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865
+            {
866
+                if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
867
+                {
868
+                    $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
869
+                    $account = new Account($this->db);
870
+                    $account->fetch($bankid);
871 871
 
872
-					$curx=$this->marge_gauche;
873
-					$cury=$posy;
872
+                    $curx=$this->marge_gauche;
873
+                    $cury=$posy;
874 874
 
875
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
875
+                    $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
876 876
 
877
-					$posy+=2;
878
-				}
879
-			}
880
-		}
877
+                    $posy+=2;
878
+                }
879
+            }
880
+        }
881 881
 
882
-		return $posy;
883
-	}
882
+        return $posy;
883
+    }
884 884
 
885 885
 
886 886
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
887
-	/**
888
-	 *	Show total to pay
889
-	 *
890
-	 *	@param	PDF			$pdf            Object PDF
891
-	 *	@param  Facture		$object         Object invoice
892
-	 *	@param  int			$deja_regle     Montant deja regle
893
-	 *	@param	int			$posy			Position depart
894
-	 *	@param	Translate	$outputlangs	Objet langs
895
-	 *	@return int							Position pour suite
896
-	 */
897
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898
-	{
887
+    /**
888
+     *	Show total to pay
889
+     *
890
+     *	@param	PDF			$pdf            Object PDF
891
+     *	@param  Facture		$object         Object invoice
892
+     *	@param  int			$deja_regle     Montant deja regle
893
+     *	@param	int			$posy			Position depart
894
+     *	@param	Translate	$outputlangs	Objet langs
895
+     *	@return int							Position pour suite
896
+     */
897
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898
+    {
899 899
         // phpcs:enable
900
-		global $conf,$mysoc;
901
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
902
-
903
-		$tab2_top = $posy;
904
-		$tab2_hl = 4;
905
-		$pdf->SetFont('','', $default_font_size - 1);
906
-
907
-		// Tableau total
908
-		$col1x = 120; $col2x = 170;
909
-		if ($this->page_largeur < 210) // To work with US executive format
910
-		{
911
-			$col2x-=20;
912
-		}
913
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914
-
915
-		$useborder=0;
916
-		$index = 0;
917
-
918
-		// Total HT
919
-		$pdf->SetFillColor(255,255,255);
920
-		$pdf->SetXY($col1x, $tab2_top + 0);
921
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922
-
923
-		$pdf->SetXY($col2x, $tab2_top + 0);
924
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
925
-
926
-		// Show VAT by rates and total
927
-		$pdf->SetFillColor(248,248,248);
928
-
929
-		$this->atleastoneratenotnull=0;
930
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931
-		{
932
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934
-			{
935
-				// Nothing to do
936
-			}
937
-			else
938
-			{
939
-				//Local tax 1 before VAT
940
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941
-				//{
942
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943
-					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
945
-
946
-						foreach( $localtax_rate as $tvakey => $tvaval )
947
-						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
949
-							{
950
-								//$this->atleastoneratenotnull++;
951
-
952
-								$index++;
953
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954
-
955
-								$tvacompl='';
956
-								if (preg_match('/\*/',$tvakey))
957
-								{
958
-									$tvakey=str_replace('*','',$tvakey);
959
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960
-								}
961
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964
-
965
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
967
-							}
968
-						}
969
-					}
970
-	      		//}
971
-				//Local tax 2 before VAT
972
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973
-				//{
974
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975
-					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
977
-
978
-						foreach( $localtax_rate as $tvakey => $tvaval )
979
-						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
981
-							{
982
-								//$this->atleastoneratenotnull++;
983
-
984
-
985
-
986
-								$index++;
987
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988
-
989
-								$tvacompl='';
990
-								if (preg_match('/\*/',$tvakey))
991
-								{
992
-									$tvakey=str_replace('*','',$tvakey);
993
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994
-								}
995
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998
-
999
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1001
-							}
1002
-						}
1003
-					}
1004
-				//}
1005
-				// VAT
1006
-				foreach($this->tva as $tvakey => $tvaval)
1007
-				{
1008
-					if ($tvakey > 0)    // On affiche pas taux 0
1009
-					{
1010
-						$this->atleastoneratenotnull++;
1011
-
1012
-						$index++;
1013
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014
-
1015
-						$tvacompl='';
1016
-						if (preg_match('/\*/',$tvakey))
1017
-						{
1018
-							$tvakey=str_replace('*','',$tvakey);
1019
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020
-						}
1021
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1023
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
-
1025
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1027
-					}
1028
-				}
1029
-
1030
-				//Local tax 1 after VAT
1031
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032
-				//{
1033
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034
-					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1036
-
1037
-						foreach( $localtax_rate as $tvakey => $tvaval )
1038
-						{
1039
-							if ($tvakey != 0)    // On affiche pas taux 0
1040
-							{
1041
-								//$this->atleastoneratenotnull++;
1042
-
1043
-								$index++;
1044
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045
-
1046
-								$tvacompl='';
1047
-								if (preg_match('/\*/',$tvakey))
1048
-								{
1049
-									$tvakey=str_replace('*','',$tvakey);
1050
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051
-								}
1052
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1053
-
1054
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058
-							}
1059
-						}
1060
-					}
1061
-	      		//}
1062
-				//Local tax 2 after VAT
1063
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064
-				//{
1065
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066
-					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1068
-
1069
-						foreach( $localtax_rate as $tvakey => $tvaval )
1070
-						{
1071
-						    // retrieve global local tax
1072
-							if ($tvakey != 0)    // On affiche pas taux 0
1073
-							{
1074
-								//$this->atleastoneratenotnull++;
1075
-
1076
-								$index++;
1077
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078
-
1079
-								$tvacompl='';
1080
-								if (preg_match('/\*/',$tvakey))
1081
-								{
1082
-									$tvakey=str_replace('*','',$tvakey);
1083
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084
-								}
1085
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1086
-
1087
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089
-
1090
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1092
-							}
1093
-						}
1094
-					}
1095
-				//}
1096
-
1097
-				// Total TTC
1098
-				$index++;
1099
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
-				$pdf->SetTextColor(0,0,60);
1101
-				$pdf->SetFillColor(224,224,224);
1102
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103
-
1104
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106
-			}
1107
-		}
1108
-
1109
-		$pdf->SetTextColor(0,0,0);
900
+        global $conf,$mysoc;
901
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
902
+
903
+        $tab2_top = $posy;
904
+        $tab2_hl = 4;
905
+        $pdf->SetFont('','', $default_font_size - 1);
906
+
907
+        // Tableau total
908
+        $col1x = 120; $col2x = 170;
909
+        if ($this->page_largeur < 210) // To work with US executive format
910
+        {
911
+            $col2x-=20;
912
+        }
913
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914
+
915
+        $useborder=0;
916
+        $index = 0;
917
+
918
+        // Total HT
919
+        $pdf->SetFillColor(255,255,255);
920
+        $pdf->SetXY($col1x, $tab2_top + 0);
921
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922
+
923
+        $pdf->SetXY($col2x, $tab2_top + 0);
924
+        $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
925
+
926
+        // Show VAT by rates and total
927
+        $pdf->SetFillColor(248,248,248);
928
+
929
+        $this->atleastoneratenotnull=0;
930
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931
+        {
932
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934
+            {
935
+                // Nothing to do
936
+            }
937
+            else
938
+            {
939
+                //Local tax 1 before VAT
940
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941
+                //{
942
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943
+                    {
944
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
945
+
946
+                        foreach( $localtax_rate as $tvakey => $tvaval )
947
+                        {
948
+                            if ($tvakey!=0)    // On affiche pas taux 0
949
+                            {
950
+                                //$this->atleastoneratenotnull++;
951
+
952
+                                $index++;
953
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954
+
955
+                                $tvacompl='';
956
+                                if (preg_match('/\*/',$tvakey))
957
+                                {
958
+                                    $tvakey=str_replace('*','',$tvakey);
959
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960
+                                }
961
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964
+
965
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
967
+                            }
968
+                        }
969
+                    }
970
+                    //}
971
+                //Local tax 2 before VAT
972
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973
+                //{
974
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975
+                    {
976
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
977
+
978
+                        foreach( $localtax_rate as $tvakey => $tvaval )
979
+                        {
980
+                            if ($tvakey!=0)    // On affiche pas taux 0
981
+                            {
982
+                                //$this->atleastoneratenotnull++;
983
+
984
+
985
+
986
+                                $index++;
987
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988
+
989
+                                $tvacompl='';
990
+                                if (preg_match('/\*/',$tvakey))
991
+                                {
992
+                                    $tvakey=str_replace('*','',$tvakey);
993
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994
+                                }
995
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998
+
999
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1001
+                            }
1002
+                        }
1003
+                    }
1004
+                //}
1005
+                // VAT
1006
+                foreach($this->tva as $tvakey => $tvaval)
1007
+                {
1008
+                    if ($tvakey > 0)    // On affiche pas taux 0
1009
+                    {
1010
+                        $this->atleastoneratenotnull++;
1011
+
1012
+                        $index++;
1013
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014
+
1015
+                        $tvacompl='';
1016
+                        if (preg_match('/\*/',$tvakey))
1017
+                        {
1018
+                            $tvakey=str_replace('*','',$tvakey);
1019
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020
+                        }
1021
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
1023
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
+
1025
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1027
+                    }
1028
+                }
1110 1029
 
1111
-		/*
1030
+                //Local tax 1 after VAT
1031
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032
+                //{
1033
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034
+                    {
1035
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1036
+
1037
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1038
+                        {
1039
+                            if ($tvakey != 0)    // On affiche pas taux 0
1040
+                            {
1041
+                                //$this->atleastoneratenotnull++;
1042
+
1043
+                                $index++;
1044
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045
+
1046
+                                $tvacompl='';
1047
+                                if (preg_match('/\*/',$tvakey))
1048
+                                {
1049
+                                    $tvakey=str_replace('*','',$tvakey);
1050
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051
+                                }
1052
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1053
+
1054
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058
+                            }
1059
+                        }
1060
+                    }
1061
+                    //}
1062
+                //Local tax 2 after VAT
1063
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064
+                //{
1065
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066
+                    {
1067
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1068
+
1069
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1070
+                        {
1071
+                            // retrieve global local tax
1072
+                            if ($tvakey != 0)    // On affiche pas taux 0
1073
+                            {
1074
+                                //$this->atleastoneratenotnull++;
1075
+
1076
+                                $index++;
1077
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078
+
1079
+                                $tvacompl='';
1080
+                                if (preg_match('/\*/',$tvakey))
1081
+                                {
1082
+                                    $tvakey=str_replace('*','',$tvakey);
1083
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084
+                                }
1085
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1086
+
1087
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089
+
1090
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1092
+                            }
1093
+                        }
1094
+                    }
1095
+                //}
1096
+
1097
+                // Total TTC
1098
+                $index++;
1099
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
+                $pdf->SetTextColor(0,0,60);
1101
+                $pdf->SetFillColor(224,224,224);
1102
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103
+
1104
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106
+            }
1107
+        }
1108
+
1109
+        $pdf->SetTextColor(0,0,0);
1110
+
1111
+        /*
1112 1112
 		$resteapayer = $object->total_ttc - $deja_regle;
1113 1113
 		if (! empty($object->paye)) $resteapayer=0;
1114 1114
 		*/
1115 1115
 
1116
-		if ($deja_regle > 0)
1117
-		{
1118
-			$index++;
1116
+        if ($deja_regle > 0)
1117
+        {
1118
+            $index++;
1119 1119
 
1120
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1120
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1122 1122
 
1123
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1123
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1125 1125
 
1126
-			/*
1126
+            /*
1127 1127
 			if ($object->close_code == 'discount_vat')
1128 1128
 			{
1129 1129
 				$index++;
@@ -1139,216 +1139,216 @@  discard block
 block discarded – undo
1139 1139
 			}
1140 1140
 			*/
1141 1141
 
1142
-			$index++;
1143
-			$pdf->SetTextColor(0,0,60);
1144
-			$pdf->SetFillColor(224,224,224);
1145
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1142
+            $index++;
1143
+            $pdf->SetTextColor(0,0,60);
1144
+            $pdf->SetFillColor(224,224,224);
1145
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1147 1147
 
1148
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1148
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1150 1150
 
1151
-			$pdf->SetFont('','', $default_font_size - 1);
1152
-			$pdf->SetTextColor(0,0,0);
1153
-		}
1154
-
1155
-		$index++;
1156
-		return ($tab2_top + ($tab2_hl * $index));
1157
-	}
1158
-
1159
-	/**
1160
-	 *   Show table for lines
1161
-	 *
1162
-	 *   @param		PDF			$pdf     		Object PDF
1163
-	 *   @param		string		$tab_top		Top position of table
1164
-	 *   @param		string		$tab_height		Height of table (rectangle)
1165
-	 *   @param		int			$nexY			Y (not used)
1166
-	 *   @param		Translate	$outputlangs	Langs object
1167
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1168
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1169
-	 *   @param		string		$currency		Currency code
1170
-	 *   @return	void
1171
-	 */
1172
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1173
-	{
1174
-		global $conf;
1175
-
1176
-		// Force to disable hidetop and hidebottom
1177
-		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1179
-
1180
-		$currency = !empty($currency) ? $currency : $conf->currency;
1181
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1182
-
1183
-		// Amount in (at tab_top - 1)
1184
-		$pdf->SetTextColor(0,0,0);
1185
-		$pdf->SetFont('','',$default_font_size - 2);
1186
-
1187
-		if (empty($hidetop))
1188
-		{
1189
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1191
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1151
+            $pdf->SetFont('','', $default_font_size - 1);
1152
+            $pdf->SetTextColor(0,0,0);
1153
+        }
1192 1154
 
1193
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1195
-		}
1155
+        $index++;
1156
+        return ($tab2_top + ($tab2_hl * $index));
1157
+    }
1196 1158
 
1197
-		$pdf->SetDrawColor(128,128,128);
1198
-		$pdf->SetFont('','',$default_font_size - 1);
1199
-
1200
-		// Output Rect
1201
-		$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
1159
+    /**
1160
+     *   Show table for lines
1161
+     *
1162
+     *   @param		PDF			$pdf     		Object PDF
1163
+     *   @param		string		$tab_top		Top position of table
1164
+     *   @param		string		$tab_height		Height of table (rectangle)
1165
+     *   @param		int			$nexY			Y (not used)
1166
+     *   @param		Translate	$outputlangs	Langs object
1167
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1168
+     *   @param		int			$hidebottom		Hide bottom bar of array
1169
+     *   @param		string		$currency		Currency code
1170
+     *   @return	void
1171
+     */
1172
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1173
+    {
1174
+        global $conf;
1175
+
1176
+        // Force to disable hidetop and hidebottom
1177
+        $hidebottom=0;
1178
+        if ($hidetop) $hidetop=-1;
1179
+
1180
+        $currency = !empty($currency) ? $currency : $conf->currency;
1181
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1182
+
1183
+        // Amount in (at tab_top - 1)
1184
+        $pdf->SetTextColor(0,0,0);
1185
+        $pdf->SetFont('','',$default_font_size - 2);
1186
+
1187
+        if (empty($hidetop))
1188
+        {
1189
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1191
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192
+
1193
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
+            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));
1195
+        }
1196
+
1197
+        $pdf->SetDrawColor(128,128,128);
1198
+        $pdf->SetFont('','',$default_font_size - 1);
1199
+
1200
+        // Output Rect
1201
+        $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
1202
+
1203
+        if (empty($hidetop))
1204
+        {
1205
+            $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
1206
+
1207
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1209
+        }
1210
+
1211
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1212
+        {
1213
+            $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1214
+            //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215
+            if (empty($hidetop))
1216
+            {
1217
+                $pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1219
+            }
1220
+        }
1221
+
1222
+        $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1223
+        if (empty($hidetop))
1224
+        {
1225
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1226
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1227
+        }
1228
+
1229
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1230
+        if (empty($hidetop))
1231
+        {
1232
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
+            if($conf->global->PRODUCT_USE_UNITS)
1234
+            {
1235
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
+            }
1237
+            else
1238
+            {
1239
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240
+            }
1241
+        }
1242
+
1243
+        if($conf->global->PRODUCT_USE_UNITS) {
1244
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245
+            if (empty($hidetop)) {
1246
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1248
+                    'C');
1249
+            }
1250
+        }
1251
+
1252
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1253
+        if (empty($hidetop))
1254
+        {
1255
+            if ($this->atleastonediscount)
1256
+            {
1257
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1259
+            }
1260
+        }
1261
+        if ($this->atleastonediscount)
1262
+        {
1263
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1264
+        }
1265
+        if (empty($hidetop))
1266
+        {
1267
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1269
+        }
1270
+    }
1202 1271
 
1203
-		if (empty($hidetop))
1204
-		{
1205
-			$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
1272
+    /**
1273
+     *  Show top header of page.
1274
+     *
1275
+     *  @param	PDF			$pdf     		Object PDF
1276
+     *  @param  Object		$object     	Object to show
1277
+     *  @param  int	    	$showaddress    0=no, 1=yes
1278
+     *  @param  Translate	$outputlangs	Object lang for output
1279
+     *  @return	void
1280
+     */
1281
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1282
+    {
1283
+        global $conf, $langs;
1206 1284
 
1207
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1209
-		}
1285
+        // Load traductions files requiredby by page
1286
+        $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies"));
1210 1287
 
1211
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1212
-		{
1213
-			$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1214
-			//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215
-			if (empty($hidetop))
1216
-			{
1217
-				$pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1219
-			}
1220
-		}
1288
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1221 1289
 
1222
-		$pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1223
-		if (empty($hidetop))
1224
-		{
1225
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1226
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1227
-		}
1290
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1228 1291
 
1229
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1230
-		if (empty($hidetop))
1231
-		{
1232
-		    $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
-		    if($conf->global->PRODUCT_USE_UNITS)
1234
-		    {
1235
-		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
-		    }
1237
-		    else
1238
-		    {
1239
-		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240
-		    }
1241
-		}
1242
-
1243
-		if($conf->global->PRODUCT_USE_UNITS) {
1244
-		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245
-		    if (empty($hidetop)) {
1246
-		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247
-		        $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1248
-		            'C');
1249
-		    }
1250
-		}
1251
-
1252
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1253
-		if (empty($hidetop))
1254
-		{
1255
-			if ($this->atleastonediscount)
1256
-			{
1257
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1259
-			}
1260
-		}
1261
-		if ($this->atleastonediscount)
1262
-		{
1263
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1264
-		}
1265
-		if (empty($hidetop))
1266
-		{
1267
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1269
-		}
1270
-	}
1271
-
1272
-	/**
1273
-	 *  Show top header of page.
1274
-	 *
1275
-	 *  @param	PDF			$pdf     		Object PDF
1276
-	 *  @param  Object		$object     	Object to show
1277
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1278
-	 *  @param  Translate	$outputlangs	Object lang for output
1279
-	 *  @return	void
1280
-	 */
1281
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1282
-	{
1283
-		global $conf, $langs;
1284
-
1285
-		// Load traductions files requiredby by page
1286
-		$outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies"));
1287
-
1288
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1289
-
1290
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1291
-
1292
-		//  Show Draft Watermark
1293
-		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1294
-		{
1292
+        //  Show Draft Watermark
1293
+        if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1294
+        {
1295 1295
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1296
-		}
1297
-
1298
-		$pdf->SetTextColor(0,0,60);
1299
-		$pdf->SetFont('','B', $default_font_size + 3);
1300
-
1301
-		$posy=$this->marge_haute;
1302
-		$posx=$this->page_largeur-$this->marge_droite-100;
1303
-
1304
-		$pdf->SetXY($this->marge_gauche,$posy);
1305
-
1306
-		// Logo
1307
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308
-		if ($this->emetteur->logo)
1309
-		{
1310
-			if (is_readable($logo))
1311
-			{
1312
-			    $height=pdf_getHeightForLogo($logo);
1313
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
-			}
1315
-			else
1316
-			{
1317
-				$pdf->SetTextColor(200,0,0);
1318
-				$pdf->SetFont('','B',$default_font_size - 2);
1319
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321
-			}
1322
-		}
1323
-		else
1324
-		{
1325
-			$text=$this->emetteur->name;
1326
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327
-		}
1328
-
1329
-		$pdf->SetFont('','B',$default_font_size + 3);
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$title=$outputlangs->transnoentities("CommercialAsk");
1333
-		$pdf->MultiCell(100, 4, $title, '', 'R');
1334
-
1335
-		$pdf->SetFont('','B',$default_font_size);
1336
-
1337
-		$posy+=5;
1338
-		$pdf->SetXY($posx,$posy);
1339
-		$pdf->SetTextColor(0,0,60);
1340
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1341
-
1342
-		$posy+=1;
1343
-		$pdf->SetFont('','', $default_font_size - 2);
1344
-
1345
-		if ($object->ref_client)
1346
-		{
1347
-			$posy+=4;
1348
-			$pdf->SetXY($posx,$posy);
1349
-			$pdf->SetTextColor(0,0,60);
1350
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351
-		}
1296
+        }
1297
+
1298
+        $pdf->SetTextColor(0,0,60);
1299
+        $pdf->SetFont('','B', $default_font_size + 3);
1300
+
1301
+        $posy=$this->marge_haute;
1302
+        $posx=$this->page_largeur-$this->marge_droite-100;
1303
+
1304
+        $pdf->SetXY($this->marge_gauche,$posy);
1305
+
1306
+        // Logo
1307
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308
+        if ($this->emetteur->logo)
1309
+        {
1310
+            if (is_readable($logo))
1311
+            {
1312
+                $height=pdf_getHeightForLogo($logo);
1313
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
+            }
1315
+            else
1316
+            {
1317
+                $pdf->SetTextColor(200,0,0);
1318
+                $pdf->SetFont('','B',$default_font_size - 2);
1319
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321
+            }
1322
+        }
1323
+        else
1324
+        {
1325
+            $text=$this->emetteur->name;
1326
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327
+        }
1328
+
1329
+        $pdf->SetFont('','B',$default_font_size + 3);
1330
+        $pdf->SetXY($posx,$posy);
1331
+        $pdf->SetTextColor(0,0,60);
1332
+        $title=$outputlangs->transnoentities("CommercialAsk");
1333
+        $pdf->MultiCell(100, 4, $title, '', 'R');
1334
+
1335
+        $pdf->SetFont('','B',$default_font_size);
1336
+
1337
+        $posy+=5;
1338
+        $pdf->SetXY($posx,$posy);
1339
+        $pdf->SetTextColor(0,0,60);
1340
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1341
+
1342
+        $posy+=1;
1343
+        $pdf->SetFont('','', $default_font_size - 2);
1344
+
1345
+        if ($object->ref_client)
1346
+        {
1347
+            $posy+=4;
1348
+            $pdf->SetXY($posx,$posy);
1349
+            $pdf->SetTextColor(0,0,60);
1350
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351
+        }
1352 1352
 /* PHFAVRE
1353 1353
 		$posy+=4;
1354 1354
 		$pdf->SetXY($posx,$posy);
@@ -1356,149 +1356,149 @@  discard block
 block discarded – undo
1356 1356
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
1357 1357
 */
1358 1358
 
1359
-		if ($object->thirdparty->code_fournisseur)
1360
-		{
1361
-			$posy+=4;
1362
-			$pdf->SetXY($posx,$posy);
1363
-			$pdf->SetTextColor(0,0,60);
1364
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365
-		}
1366
-
1367
-		// Get contact
1368
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369
-		{
1370
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1371
-		    if (count($arrayidcontact) > 0)
1372
-		    {
1373
-		        $usertmp=new User($this->db);
1374
-		        $usertmp->fetch($arrayidcontact[0]);
1359
+        if ($object->thirdparty->code_fournisseur)
1360
+        {
1361
+            $posy+=4;
1362
+            $pdf->SetXY($posx,$posy);
1363
+            $pdf->SetTextColor(0,0,60);
1364
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365
+        }
1366
+
1367
+        // Get contact
1368
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369
+        {
1370
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1371
+            if (count($arrayidcontact) > 0)
1372
+            {
1373
+                $usertmp=new User($this->db);
1374
+                $usertmp->fetch($arrayidcontact[0]);
1375 1375
                 $posy+=4;
1376 1376
                 $pdf->SetXY($posx,$posy);
1377
-		        $pdf->SetTextColor(0,0,60);
1378
-		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379
-		    }
1380
-		}
1381
-
1382
-		$posy+=2;
1383
-
1384
-		$top_shift = 0;
1385
-		// Show list of linked objects
1386
-		$current_y = $pdf->getY();
1387
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1388
-		if ($current_y < $pdf->getY())
1389
-		{
1390
-			$top_shift = $pdf->getY() - $current_y;
1391
-		}
1392
-
1393
-		if ($showaddress)
1394
-		{
1395
-			// Sender properties
1396
-			$carac_emetteur='';
1397
-		 	// Add internal contact of proposal if defined
1398
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1399
-		 	if (count($arrayidcontact) > 0)
1400
-		 	{
1401
-		 		$object->fetch_user($arrayidcontact[0]);
1402
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404
-		 	}
1405
-
1406
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407
-
1408
-			// Show sender
1409
-			$posy=42+$top_shift;
1410
-		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
-			$hautcadre=40;
1413
-
1414
-			// Show sender frame
1415
-			$pdf->SetTextColor(0,0,0);
1416
-			$pdf->SetFont('','', $default_font_size - 2);
1417
-			$pdf->SetXY($posx,$posy-5);
1418
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
-			$pdf->SetXY($posx,$posy);
1420
-			$pdf->SetFillColor(230,230,230);
1421
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
-			$pdf->SetTextColor(0,0,60);
1423
-
1424
-			// Show sender name
1425
-			$pdf->SetXY($posx+2,$posy+3);
1426
-			$pdf->SetFont('','B', $default_font_size);
1427
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
-			$posy=$pdf->getY();
1429
-
1430
-			// Show sender information
1431
-			$pdf->SetXY($posx+2,$posy);
1432
-			$pdf->SetFont('','', $default_font_size - 1);
1433
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434
-
1435
-
1436
-			// If CUSTOMER contact defined, we use it
1437
-			$usecontact=false;
1438
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1439
-			if (count($arrayidcontact) > 0)
1440
-			{
1441
-				$usecontact=true;
1442
-				$result=$object->fetch_contact($arrayidcontact[0]);
1443
-			}
1444
-
1445
-			// Recipient name
1446
-			if (! empty($usecontact))
1447
-			{
1448
-				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
-				else $socname = $object->thirdparty->name;
1451
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
-			}
1453
-			else
1454
-			{
1455
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456
-			}
1457
-
1458
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1377
+                $pdf->SetTextColor(0,0,60);
1378
+                $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379
+            }
1380
+        }
1381
+
1382
+        $posy+=2;
1383
+
1384
+        $top_shift = 0;
1385
+        // Show list of linked objects
1386
+        $current_y = $pdf->getY();
1387
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1388
+        if ($current_y < $pdf->getY())
1389
+        {
1390
+            $top_shift = $pdf->getY() - $current_y;
1391
+        }
1392
+
1393
+        if ($showaddress)
1394
+        {
1395
+            // Sender properties
1396
+            $carac_emetteur='';
1397
+                // Add internal contact of proposal if defined
1398
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1399
+                if (count($arrayidcontact) > 0)
1400
+                {
1401
+                    $object->fetch_user($arrayidcontact[0]);
1402
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404
+                }
1459 1405
 
1460
-			// Show recipient
1461
-			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
-			$posy=42+$top_shift;
1464
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1406
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407
+
1408
+            // Show sender
1409
+            $posy=42+$top_shift;
1410
+                $posx=$this->marge_gauche;
1411
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
+            $hautcadre=40;
1413
+
1414
+            // Show sender frame
1415
+            $pdf->SetTextColor(0,0,0);
1416
+            $pdf->SetFont('','', $default_font_size - 2);
1417
+            $pdf->SetXY($posx,$posy-5);
1418
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
+            $pdf->SetXY($posx,$posy);
1420
+            $pdf->SetFillColor(230,230,230);
1421
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
+            $pdf->SetTextColor(0,0,60);
1423
+
1424
+            // Show sender name
1425
+            $pdf->SetXY($posx+2,$posy+3);
1426
+            $pdf->SetFont('','B', $default_font_size);
1427
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
+            $posy=$pdf->getY();
1429
+
1430
+            // Show sender information
1431
+            $pdf->SetXY($posx+2,$posy);
1432
+            $pdf->SetFont('','', $default_font_size - 1);
1433
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434
+
1435
+
1436
+            // If CUSTOMER contact defined, we use it
1437
+            $usecontact=false;
1438
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1439
+            if (count($arrayidcontact) > 0)
1440
+            {
1441
+                $usecontact=true;
1442
+                $result=$object->fetch_contact($arrayidcontact[0]);
1443
+            }
1444
+
1445
+            // Recipient name
1446
+            if (! empty($usecontact))
1447
+            {
1448
+                // On peut utiliser le nom de la societe du contact
1449
+                if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
+                else $socname = $object->thirdparty->name;
1451
+                $carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
+            }
1453
+            else
1454
+            {
1455
+                $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456
+            }
1457
+
1458
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1459
+
1460
+            // Show recipient
1461
+            $widthrecbox=100;
1462
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
+            $posy=42+$top_shift;
1464
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1466
+
1467
+            // Show recipient frame
1468
+            $pdf->SetTextColor(0,0,0);
1469
+            $pdf->SetFont('','', $default_font_size - 2);
1470
+            $pdf->SetXY($posx+2,$posy-5);
1471
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473
+
1474
+            // Show recipient name
1475
+            $pdf->SetXY($posx+2,$posy+3);
1476
+            $pdf->SetFont('','B', $default_font_size);
1477
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478
+
1479
+            // Show recipient information
1480
+            $pdf->SetFont('','', $default_font_size - 1);
1481
+            $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1482
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483
+        }
1484
+
1485
+        $pdf->SetTextColor(0,0,0);
1486
+        return $top_shift;
1487
+    }
1466 1488
 
1467
-			// Show recipient frame
1468
-			$pdf->SetTextColor(0,0,0);
1469
-			$pdf->SetFont('','', $default_font_size - 2);
1470
-			$pdf->SetXY($posx+2,$posy-5);
1471
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473
-
1474
-			// Show recipient name
1475
-			$pdf->SetXY($posx+2,$posy+3);
1476
-			$pdf->SetFont('','B', $default_font_size);
1477
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478
-
1479
-			// Show recipient information
1480
-			$pdf->SetFont('','', $default_font_size - 1);
1481
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1482
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483
-		}
1484
-
1485
-		$pdf->SetTextColor(0,0,0);
1486
-		return $top_shift;
1487
-	}
1488
-
1489
-	/**
1490
-	 *   	Show footer of page. Need this->emetteur object
1489
+    /**
1490
+     *   	Show footer of page. Need this->emetteur object
1491 1491
      *
1492
-	 *   	@param	PDF			$pdf     			PDF
1493
-	 * 		@param	Object		$object				Object to show
1494
-	 *      @param	Translate	$outputlangs		Object lang for output
1495
-	 *      @param	int			$hidefreetext		1=Hide free text
1496
-	 *      @return	int								Return height of bottom margin including footer text
1497
-	 */
1498
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1499
-	{
1500
-		global $conf;
1501
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1503
-	}
1492
+     *   	@param	PDF			$pdf     			PDF
1493
+     * 		@param	Object		$object				Object to show
1494
+     *      @param	Translate	$outputlangs		Object lang for output
1495
+     *      @param	int			$hidefreetext		1=Hide free text
1496
+     *      @return	int								Return height of bottom margin including footer text
1497
+     */
1498
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1499
+    {
1500
+        global $conf;
1501
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
+        return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1503
+    }
1504 1504
 }
Please login to merge, or discard this patch.
Spacing   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -130,67 +130,67 @@  discard block
 block discarded – undo
130 130
 
131 131
 		// Dimension page pour format A4
132 132
 		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
133
+		$formatarray = pdf_getFormat();
134 134
 		$this->page_largeur = $formatarray['width'];
135 135
 		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
-
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
148
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
149
-		$this->option_credit_note = 1;             // Support credit notes
150
-		$this->option_freetext = 1;				   // Support add of a personalised text
151
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
-
153
-		$this->franchise=!$mysoc->tva_assuj;
136
+		$this->format = array($this->page_largeur, $this->page_hauteur);
137
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
138
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
139
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
140
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
141
+
142
+		$this->option_logo = 1; // Affiche logo
143
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
144
+		$this->option_modereg = 1; // Affiche mode reglement
145
+		$this->option_condreg = 1; // Affiche conditions reglement
146
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
147
+		$this->option_multilang = 1; // Dispo en plusieurs langues
148
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
149
+		$this->option_credit_note = 1; // Support credit notes
150
+		$this->option_freetext = 1; // Support add of a personalised text
151
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
152
+
153
+		$this->franchise = !$mysoc->tva_assuj;
154 154
 
155 155
 		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
156
+		$this->emetteur = $mysoc;
157
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
158 158
 
159 159
 		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
161
-		$this->posxdiscount=162;
162
-		$this->postotalht=174;
160
+		$this->posxdesc = $this->marge_gauche + 1;
161
+		$this->posxdiscount = 162;
162
+		$this->postotalht = 174;
163 163
 
164 164
 		if ($conf->global->PRODUCT_USE_UNITS)
165 165
 		{
166
-		    $this->posxtva=101;
167
-		    $this->posxup=118;
168
-		    $this->posxqty=135;
169
-		    $this->posxunit=151;
166
+		    $this->posxtva = 101;
167
+		    $this->posxup = 118;
168
+		    $this->posxqty = 135;
169
+		    $this->posxunit = 151;
170 170
 		} else {
171
-		    $this->posxtva=102;
172
-		    $this->posxup=126;
173
-		    $this->posxqty=145;
171
+		    $this->posxtva = 102;
172
+		    $this->posxup = 126;
173
+		    $this->posxqty = 145;
174 174
 		}
175 175
 
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
176
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva;
177
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
178 178
 		if ($this->page_largeur < 210) // To work with US executive format
179 179
 		{
180
-			$this->posxpicture-=20;
181
-			$this->posxtva-=20;
182
-			$this->posxup-=20;
183
-			$this->posxqty-=20;
184
-			$this->posxunit-=20;
185
-			$this->posxdiscount-=20;
186
-			$this->postotalht-=20;
180
+			$this->posxpicture -= 20;
181
+			$this->posxtva -= 20;
182
+			$this->posxup -= 20;
183
+			$this->posxqty -= 20;
184
+			$this->posxunit -= 20;
185
+			$this->posxdiscount -= 20;
186
+			$this->postotalht -= 20;
187 187
 		}
188 188
 
189
-		$this->tva=array();
190
-		$this->localtax1=array();
191
-		$this->localtax2=array();
192
-		$this->atleastoneratenotnull=0;
193
-		$this->atleastonediscount=0;
189
+		$this->tva = array();
190
+		$this->localtax1 = array();
191
+		$this->localtax2 = array();
192
+		$this->atleastoneratenotnull = 0;
193
+		$this->atleastonediscount = 0;
194 194
 	}
195 195
 
196 196
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
      *  @param		int			$hideref			Do not show ref
206 206
      *  @return     int             				1=OK, 0=KO
207 207
 	 */
208
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
208
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
209 209
 	{
210 210
         // phpcs:enable
211
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
211
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
212 212
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
213
+		if (!is_object($outputlangs)) $outputlangs = $langs;
214 214
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
215
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
216 216
 
217 217
 		// Load traductions files requiredby by page
218 218
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
@@ -220,40 +220,40 @@  discard block
 block discarded – undo
220 220
 		$nblignes = count($object->lines);
221 221
 
222 222
 		// Loop on each lines to detect if there is at least one image to show
223
-		$realpatharray=array();
224
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
223
+		$realpatharray = array();
224
+		if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225 225
 		{
226
-			for ($i = 0 ; $i < $nblignes ; $i++)
226
+			for ($i = 0; $i < $nblignes; $i++)
227 227
 			{
228 228
 				if (empty($object->lines[$i]->fk_product)) continue;
229 229
 
230 230
 				$objphoto = new Product($this->db);
231 231
 				$objphoto->fetch($object->lines[$i]->fk_product);
232 232
 
233
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
233
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234 234
 				{
235
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
235
+					$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
236 236
 					$dir = $conf->product->dir_output.'/'.$pdir;
237 237
 				}
238 238
 				else
239 239
 				{
240
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
240
+					$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
241 241
 					$dir = $conf->product->dir_output.'/'.$pdir;
242 242
 				}
243 243
 
244
-				$realpath='';
245
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
244
+				$realpath = '';
245
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
246 246
 				{
247
-					$filename=$obj['photo'];
247
+					$filename = $obj['photo'];
248 248
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249 249
 					$realpath = $dir.$filename;
250 250
 					break;
251 251
 				}
252 252
 
253
-				if ($realpath) $realpatharray[$i]=$realpath;
253
+				if ($realpath) $realpatharray[$i] = $realpath;
254 254
 			}
255 255
 		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
256
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
257 257
 
258 258
 		if ($conf->supplier_proposal->dir_output)
259 259
 		{
@@ -265,20 +265,20 @@  discard block
 block discarded – undo
265 265
 			if ($object->specimen)
266 266
 			{
267 267
 				$dir = $conf->supplier_proposal->dir_output;
268
-				$file = $dir . "/SPECIMEN.pdf";
268
+				$file = $dir."/SPECIMEN.pdf";
269 269
 			}
270 270
 			else
271 271
 			{
272 272
 				$objectref = dol_sanitizeFileName($object->ref);
273
-				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
-				$file = $dir . "/" . $objectref . ".pdf";
273
+				$dir = $conf->supplier_proposal->dir_output."/".$objectref;
274
+				$file = $dir."/".$objectref.".pdf";
275 275
 			}
276 276
 
277
-			if (! file_exists($dir))
277
+			if (!file_exists($dir))
278 278
 			{
279 279
 				if (dol_mkdir($dir) < 0)
280 280
 				{
281
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
281
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
282 282
 					return 0;
283 283
 				}
284 284
 			}
@@ -286,24 +286,24 @@  discard block
 block discarded – undo
286 286
 			if (file_exists($dir))
287 287
 			{
288 288
 				// Add pdfgeneration hook
289
-				if (! is_object($hookmanager))
289
+				if (!is_object($hookmanager))
290 290
 				{
291 291
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
-					$hookmanager=new HookManager($this->db);
292
+					$hookmanager = new HookManager($this->db);
293 293
 				}
294 294
 				$hookmanager->initHooks(array('pdfgeneration'));
295
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
295
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
296 296
 				global $action;
297
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
297
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
298 298
 
299 299
 				// Create pdf instance
300
-                $pdf=pdf_getInstance($this->format);
301
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
302
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
303
-		        $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
304
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
306
-                $pdf->SetAutoPageBreak(1,0);
300
+                $pdf = pdf_getInstance($this->format);
301
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
302
+                $heightforinfotot = 50; // Height reserved to output the info and total part
303
+		        $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
304
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
305
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
306
+                $pdf->SetAutoPageBreak(1, 0);
307 307
 
308 308
                 if (class_exists('TCPDF'))
309 309
                 {
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
                 }
313 313
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
314 314
                 // Set path to the background PDF File
315
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
315
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
316 316
                 {
317 317
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
318 318
                     $tplidx = $pdf->importPage(1);
319 319
                 }
320 320
 
321 321
 				$pdf->Open();
322
-				$pagenb=0;
323
-				$pdf->SetDrawColor(128,128,128);
322
+				$pagenb = 0;
323
+				$pdf->SetDrawColor(128, 128, 128);
324 324
 
325 325
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326 326
 				$pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327 327
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328 328
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329 329
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
330
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
331 331
 
332
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
332
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
333 333
 
334 334
 				// Positionne $this->atleastonediscount si on a au moins une remise
335
-				for ($i = 0 ; $i < $nblignes ; $i++)
335
+				for ($i = 0; $i < $nblignes; $i++)
336 336
 				{
337 337
 					if ($object->lines[$i]->remise_percent)
338 338
 					{
@@ -341,57 +341,57 @@  discard block
 block discarded – undo
341 341
 				}
342 342
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343 343
 				{
344
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
346
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
347
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
348
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
344
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
345
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
346
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
347
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
348
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
349 349
 					//$this->postotalht;
350 350
 				}
351 351
 
352 352
 				// New page
353 353
 				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
354
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
355 355
 				$pagenb++;
356 356
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
-				$pdf->SetFont('','', $default_font_size - 1);
358
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
359
-				$pdf->SetTextColor(0,0,0);
357
+				$pdf->SetFont('', '', $default_font_size - 1);
358
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
359
+				$pdf->SetTextColor(0, 0, 0);
360 360
 
361
-				$tab_top = 90+$top_shift;
362
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
361
+				$tab_top = 90 + $top_shift;
362
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
363 363
 
364 364
 				// Affiche notes
365
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
366
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
365
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
366
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367 367
 				{
368 368
 					// Get first sale rep
369 369
 					if (is_object($object->thirdparty))
370 370
 					{
371
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
-						$salerepobj=new User($this->db);
371
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
372
+						$salerepobj = new User($this->db);
373 373
 						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
374
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
375 375
 					}
376 376
 				}
377 377
 				if ($notetoshow)
378 378
 				{
379 379
 					$tab_top -= 2;
380 380
 
381
-                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
381
+                    $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
382 382
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
383 383
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
384 384
 
385
-					$pdf->SetFont('','', $default_font_size - 1);
386
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
385
+					$pdf->SetFont('', '', $default_font_size - 1);
386
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
387 387
 					$nexY = $pdf->GetY();
388
-					$height_note=$nexY-$tab_top;
388
+					$height_note = $nexY - $tab_top;
389 389
 
390 390
 					// Rect prend une longueur en 3eme param
391
-					$pdf->SetDrawColor(192,192,192);
392
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
391
+					$pdf->SetDrawColor(192, 192, 192);
392
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
393 393
 
394
-					$tab_top = $nexY+6;
394
+					$tab_top = $nexY + 6;
395 395
 				}
396 396
 
397 397
 				$iniY = $tab_top + 7;
@@ -399,105 +399,105 @@  discard block
 block discarded – undo
399 399
 				$nexY = $tab_top + 7;
400 400
 
401 401
 				// Loop on each lines
402
-				for ($i = 0 ; $i < $nblignes ; $i++)
402
+				for ($i = 0; $i < $nblignes; $i++)
403 403
 				{
404 404
 					$curY = $nexY;
405
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
-					$pdf->SetTextColor(0,0,0);
405
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
406
+					$pdf->SetTextColor(0, 0, 0);
407 407
 
408 408
 					// Define size of image if we need it
409
-					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
409
+					$imglinesize = array();
410
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
411 411
 
412 412
 					$pdf->setTopMargin($tab_top_newpage);
413
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
-					$pageposbefore=$pdf->getPage();
413
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
414
+					$pageposbefore = $pdf->getPage();
415 415
 
416
-					$showpricebeforepagebreak=1;
417
-					$posYAfterImage=0;
418
-					$posYAfterDescription=0;
416
+					$showpricebeforepagebreak = 1;
417
+					$posYAfterImage = 0;
418
+					$posYAfterDescription = 0;
419 419
 
420 420
 					// We start with Photo of product line
421
-					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
421
+					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
422 422
 					{
423
-						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
423
+						$pdf->AddPage('', '', true);
424
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
425 425
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
-						$pdf->setPage($pageposbefore+1);
426
+						$pdf->setPage($pageposbefore + 1);
427 427
 
428 428
 						$curY = $tab_top_newpage;
429
-						$showpricebeforepagebreak=0;
429
+						$showpricebeforepagebreak = 0;
430 430
 					}
431 431
 
432 432
 					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433 433
 					{
434
-						$curX = $this->posxpicture-1;
435
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
434
+						$curX = $this->posxpicture - 1;
435
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
436 436
 						// $pdf->Image does not increase value return by getY, so we save it manually
437
-						$posYAfterImage=$curY+$imglinesize['height'];
437
+						$posYAfterImage = $curY + $imglinesize['height'];
438 438
 					}
439 439
 
440 440
 					// Description of product line
441
-					$curX = $this->posxdesc-1;
441
+					$curX = $this->posxdesc - 1;
442 442
 
443 443
 					$pdf->startTransaction();
444 444
 					if ($posYAfterImage > 0)
445 445
 					{
446
-						$descWidth = $this->posxpicture-$curX;
446
+						$descWidth = $this->posxpicture - $curX;
447 447
 					}
448 448
 					else
449 449
 					{
450
-						$descWidth = $this->posxtva-$curX;
450
+						$descWidth = $this->posxtva - $curX;
451 451
 					}
452
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
452
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
453 453
 
454
-					$pageposafter=$pdf->getPage();
454
+					$pageposafter = $pdf->getPage();
455 455
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
456 456
 					{
457 457
 						$pdf->rollbackTransaction(true);
458
-						$pageposafter=$pageposbefore;
458
+						$pageposafter = $pageposbefore;
459 459
 						//print $pageposafter.'-'.$pageposbefore;exit;
460
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
460
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
461
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc);
462 462
 
463
-						$pageposafter=$pdf->getPage();
464
-						$posyafter=$pdf->GetY();
463
+						$pageposafter = $pdf->getPage();
464
+						$posyafter = $pdf->GetY();
465 465
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
466
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
467 467
 						{
468
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
468
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
469 469
 							{
470
-								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
470
+								$pdf->AddPage('', '', true);
471
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
472 472
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
-								$pdf->setPage($pageposafter+1);
473
+								$pdf->setPage($pageposafter + 1);
474 474
 							}
475 475
 						}
476 476
 						else
477 477
 						{
478 478
 							// We found a page break
479
-							$showpricebeforepagebreak=0;
479
+							$showpricebeforepagebreak = 0;
480 480
 						}
481 481
 					}
482 482
 					else	// No pagebreak
483 483
 					{
484 484
 						$pdf->commitTransaction();
485 485
 					}
486
-					$posYAfterDescription=$pdf->GetY();
486
+					$posYAfterDescription = $pdf->GetY();
487 487
 
488 488
 					$nexY = $pdf->GetY();
489
-					$pageposafter=$pdf->getPage();
489
+					$pageposafter = $pdf->getPage();
490 490
 
491 491
 					$pdf->setPage($pageposbefore);
492 492
 					$pdf->setTopMargin($this->marge_haute);
493
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
493
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
494 494
 
495 495
 					// We suppose that a too long description or photo were moved completely on next page
496 496
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497 497
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498 498
 					}
499 499
 
500
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
500
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
501 501
 
502 502
 					// VAT Rate
503 503
 					/*
@@ -519,21 +519,21 @@  discard block
 block discarded – undo
519 519
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520 520
 					$pdf->SetXY($this->posxqty, $curY);
521 521
 					// Enough for 6 chars
522
-					if($conf->global->PRODUCT_USE_UNITS)
522
+					if ($conf->global->PRODUCT_USE_UNITS)
523 523
 					{
524
-					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
524
+					    $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 3, $qty, 0, 'R');
525 525
 					}
526 526
 					else
527 527
 					{
528
-					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
528
+					    $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R');
529 529
 					}
530 530
 
531 531
 					// Unit
532
-					if($conf->global->PRODUCT_USE_UNITS)
532
+					if ($conf->global->PRODUCT_USE_UNITS)
533 533
 					{
534 534
 					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535 535
 					    $pdf->SetXY($this->posxunit, $curY);
536
-					    $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
536
+					    $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
537 537
 					}
538 538
 
539 539
 					// Discount on line
@@ -553,54 +553,54 @@  discard block
 block discarded – undo
553 553
                     */
554 554
 
555 555
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
556
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
557
+					else $tvaligne = $object->lines[$i]->total_tva;
558 558
 
559
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
560
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
561
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
562
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
563
-					$localtax1_type=$object->lines[$i]->localtax1_type;
564
-					$localtax2_type=$object->lines[$i]->localtax2_type;
559
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
560
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
561
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
562
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
563
+					$localtax1_type = $object->lines[$i]->localtax1_type;
564
+					$localtax2_type = $object->lines[$i]->localtax2_type;
565 565
 
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
566
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
567
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
568
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
569 569
 
570
-					$vatrate=(string) $object->lines[$i]->tva_tx;
570
+					$vatrate = (string) $object->lines[$i]->tva_tx;
571 571
 
572 572
 					// Retrieve type from database for backward compatibility with old records
573
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
573
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
574
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
575 575
 					{
576
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
576
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
577 577
 						$localtax1_type = $localtaxtmp_array[0];
578 578
 						$localtax2_type = $localtaxtmp_array[2];
579 579
 					}
580 580
 
581 581
 				    // retrieve global local tax
582 582
 					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
583
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
584 584
 					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
585
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
586 586
 
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
587
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
588
+					if (!isset($this->tva[$vatrate]))				$this->tva[$vatrate] = 0;
589 589
 					$this->tva[$vatrate] += $tvaligne;
590 590
 
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
591
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
592 592
 
593 593
 					// Add line
594
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
594
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595 595
 					{
596 596
 						$pdf->setPage($pageposafter);
597
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
597
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
598 598
 						//$pdf->SetDrawColor(190,190,200);
599
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
599
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
600 600
 						$pdf->SetLineStyle(array('dash'=>0));
601 601
 					}
602 602
 
603
-					$nexY+=2;    // Passe espace entre les lignes
603
+					$nexY += 2; // Passe espace entre les lignes
604 604
 
605 605
 					// Detect if some page were added automatically and output _tableau for past pages
606 606
 					while ($pagenb < $pageposafter)
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 						{
615 615
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616 616
 						}
617
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
617
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
618 618
 						$pagenb++;
619 619
 						$pdf->setPage($pagenb);
620
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
620
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
621 621
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622 622
 					}
623
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
623
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
624 624
 					{
625 625
 						if ($pagenb == 1)
626 626
 						{
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 						{
631 631
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632 632
 						}
633
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
633
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
634 634
 						// New page
635 635
 						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
636
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
637 637
 						$pagenb++;
638 638
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639 639
 					}
@@ -643,16 +643,16 @@  discard block
 block discarded – undo
643 643
 				if ($pagenb == 1)
644 644
 				{
645 645
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
646
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647 647
 				}
648 648
 				else
649 649
 				{
650 650
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
651
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652 652
 				}
653 653
 
654 654
 				// Affiche zone infos
655
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
655
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
656 656
 
657 657
 				// Affiche zone totaux
658 658
 				//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
@@ -666,35 +666,35 @@  discard block
 block discarded – undo
666 666
 				*/
667 667
 
668 668
 				// Pied de page
669
-				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
669
+				$this->_pagefoot($pdf, $object, $outputlangs);
670
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
671 671
 
672 672
 				$pdf->Close();
673 673
 
674
-				$pdf->Output($file,'F');
674
+				$pdf->Output($file, 'F');
675 675
 
676 676
 				//Add pdfgeneration hook
677 677
 				$hookmanager->initHooks(array('pdfgeneration'));
678
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
678
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
679 679
 				global $action;
680
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
680
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
681 681
 
682
-				if (! empty($conf->global->MAIN_UMASK))
682
+				if (!empty($conf->global->MAIN_UMASK))
683 683
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
684 684
 
685 685
 				$this->result = array('fullpath'=>$file);
686 686
 
687
-				return 1;   // Pas d'erreur
687
+				return 1; // Pas d'erreur
688 688
 			}
689 689
 			else
690 690
 			{
691
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
691
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
692 692
 				return 0;
693 693
 			}
694 694
 		}
695 695
 		else
696 696
 		{
697
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
697
+			$this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
698 698
 			return 0;
699 699
 		}
700 700
 	}
@@ -731,37 +731,37 @@  discard block
 block discarded – undo
731 731
 		global $conf;
732 732
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
733 733
 
734
-		$pdf->SetFont('','', $default_font_size - 1);
734
+		$pdf->SetFont('', '', $default_font_size - 1);
735 735
 
736
-		$posxval=52;
736
+		$posxval = 52;
737 737
 
738 738
         // Show shipping date
739
-        if (! empty($object->date_livraison))
739
+        if (!empty($object->date_livraison))
740 740
 		{
741 741
             $outputlangs->load("sendings");
742
-			$pdf->SetFont('','B', $default_font_size - 2);
742
+			$pdf->SetFont('', 'B', $default_font_size - 2);
743 743
 			$pdf->SetXY($this->marge_gauche, $posy);
744 744
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745 745
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
746
-			$pdf->SetFont('','', $default_font_size - 2);
746
+			$pdf->SetFont('', '', $default_font_size - 2);
747 747
 			$pdf->SetXY($posxval, $posy);
748
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
748
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
749 749
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 750
 
751
-            $posy=$pdf->GetY()+1;
751
+            $posy = $pdf->GetY() + 1;
752 752
 		}
753 753
 		else {
754 754
 			$outputlangs->load("sendings");
755
-			$pdf->SetFont('','B', $default_font_size - 2);
755
+			$pdf->SetFont('', 'B', $default_font_size - 2);
756 756
 			$pdf->SetXY($this->marge_gauche, $posy);
757 757
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758 758
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
759
-			$pdf->SetFont('','', $default_font_size - 2);
759
+			$pdf->SetFont('', '', $default_font_size - 2);
760 760
 			$pdf->SetXY($posxval, $posy);
761 761
 			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762 762
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
763 763
 
764
-            $posy=$pdf->GetY()+1;
764
+            $posy = $pdf->GetY() + 1;
765 765
 		}
766 766
         /* PHFAVRE
767 767
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
@@ -783,46 +783,46 @@  discard block
 block discarded – undo
783 783
 		// Show payments conditions
784 784
 		if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785 785
 		{
786
-			$pdf->SetFont('','B', $default_font_size - 2);
786
+			$pdf->SetFont('', 'B', $default_font_size - 2);
787 787
 			$pdf->SetXY($this->marge_gauche, $posy);
788 788
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
789 789
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
790 790
 
791
-			$pdf->SetFont('','', $default_font_size - 2);
791
+			$pdf->SetFont('', '', $default_font_size - 2);
792 792
 			$pdf->SetXY($posxval, $posy);
793
-			$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);
794
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
793
+			$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);
794
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
795
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
796 796
 
797
-			$posy=$pdf->GetY()+3;
797
+			$posy = $pdf->GetY() + 3;
798 798
 		}
799 799
 
800
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
800
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801 801
 		{
802 802
 			// Show payment mode
803 803
 			if ($object->mode_reglement_code
804 804
 			&& $object->mode_reglement_code != 'CHQ'
805 805
 			&& $object->mode_reglement_code != 'VIR')
806 806
 			{
807
-				$pdf->SetFont('','B', $default_font_size - 2);
808
-				$pdf->SetXY($this->marge_gauche, $posy-2);
807
+				$pdf->SetFont('', 'B', $default_font_size - 2);
808
+				$pdf->SetXY($this->marge_gauche, $posy - 2);
809 809
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
810 810
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
811
-				$pdf->SetFont('','', $default_font_size - 2);
812
-				$pdf->SetXY($posxval, $posy-2);
813
-				$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);
814
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
811
+				$pdf->SetFont('', '', $default_font_size - 2);
812
+				$pdf->SetXY($posxval, $posy - 2);
813
+				$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);
814
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
815 815
 
816
-				$posy=$pdf->GetY()+2;
816
+				$posy = $pdf->GetY() + 2;
817 817
 			}
818 818
 
819 819
 			// Show payment mode CHQ
820 820
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821 821
 			{
822 822
 				// Si mode reglement non force ou si force a CHQ
823
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
823
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
824 824
 				{
825
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
825
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
826 826
 
827 827
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828 828
 					{
@@ -830,31 +830,31 @@  discard block
 block discarded – undo
830 830
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831 831
 
832 832
 						$pdf->SetXY($this->marge_gauche, $posy);
833
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
-						$posy=$pdf->GetY()+1;
833
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
834
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
835
+						$posy = $pdf->GetY() + 1;
836 836
 
837 837
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838 838
 			            {
839 839
 							$pdf->SetXY($this->marge_gauche, $posy);
840
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
840
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
841 841
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
-							$posy=$pdf->GetY()+2;
842
+							$posy = $pdf->GetY() + 2;
843 843
 			            }
844 844
 					}
845 845
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846 846
 					{
847 847
 						$pdf->SetXY($this->marge_gauche, $posy);
848
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
-						$posy=$pdf->GetY()+1;
848
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
849
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
850
+						$posy = $pdf->GetY() + 1;
851 851
 
852 852
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853 853
 			            {
854 854
 							$pdf->SetXY($this->marge_gauche, $posy);
855
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
855
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
856 856
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
-							$posy=$pdf->GetY()+2;
857
+							$posy = $pdf->GetY() + 2;
858 858
 			            }
859 859
 					}
860 860
 				}
@@ -863,18 +863,18 @@  discard block
 block discarded – undo
863 863
 			// If payment mode not forced or forced to VIR, show payment with BAN
864 864
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865 865
 			{
866
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
866
+				if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
867 867
 				{
868
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
868
+					$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
869 869
 					$account = new Account($this->db);
870 870
 					$account->fetch($bankid);
871 871
 
872
-					$curx=$this->marge_gauche;
873
-					$cury=$posy;
872
+					$curx = $this->marge_gauche;
873
+					$cury = $posy;
874 874
 
875
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
875
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
876 876
 
877
-					$posy+=2;
877
+					$posy += 2;
878 878
 				}
879 879
 			}
880 880
 		}
@@ -897,40 +897,40 @@  discard block
 block discarded – undo
897 897
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898 898
 	{
899 899
         // phpcs:enable
900
-		global $conf,$mysoc;
900
+		global $conf, $mysoc;
901 901
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
902 902
 
903 903
 		$tab2_top = $posy;
904 904
 		$tab2_hl = 4;
905
-		$pdf->SetFont('','', $default_font_size - 1);
905
+		$pdf->SetFont('', '', $default_font_size - 1);
906 906
 
907 907
 		// Tableau total
908 908
 		$col1x = 120; $col2x = 170;
909 909
 		if ($this->page_largeur < 210) // To work with US executive format
910 910
 		{
911
-			$col2x-=20;
911
+			$col2x -= 20;
912 912
 		}
913 913
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914 914
 
915
-		$useborder=0;
915
+		$useborder = 0;
916 916
 		$index = 0;
917 917
 
918 918
 		// Total HT
919
-		$pdf->SetFillColor(255,255,255);
919
+		$pdf->SetFillColor(255, 255, 255);
920 920
 		$pdf->SetXY($col1x, $tab2_top + 0);
921
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
921
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922 922
 
923 923
 		$pdf->SetXY($col2x, $tab2_top + 0);
924
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
924
+		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
925 925
 
926 926
 		// Show VAT by rates and total
927
-		$pdf->SetFillColor(248,248,248);
927
+		$pdf->SetFillColor(248, 248, 248);
928 928
 
929
-		$this->atleastoneratenotnull=0;
929
+		$this->atleastoneratenotnull = 0;
930 930
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931 931
 		{
932
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
932
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934 934
 			{
935 935
 				// Nothing to do
936 936
 			}
@@ -939,28 +939,28 @@  discard block
 block discarded – undo
939 939
 				//Local tax 1 before VAT
940 940
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941 941
 				//{
942
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
942
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
943 943
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
944
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
945 945
 
946
-						foreach( $localtax_rate as $tvakey => $tvaval )
946
+						foreach ($localtax_rate as $tvakey => $tvaval)
947 947
 						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
948
+							if ($tvakey != 0)    // On affiche pas taux 0
949 949
 							{
950 950
 								//$this->atleastoneratenotnull++;
951 951
 
952 952
 								$index++;
953 953
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954 954
 
955
-								$tvacompl='';
956
-								if (preg_match('/\*/',$tvakey))
955
+								$tvacompl = '';
956
+								if (preg_match('/\*/', $tvakey))
957 957
 								{
958
-									$tvakey=str_replace('*','',$tvakey);
958
+									$tvakey = str_replace('*', '', $tvakey);
959 959
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960 960
 								}
961
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
961
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
962
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
963
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964 964
 
965 965
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966 966
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -971,13 +971,13 @@  discard block
 block discarded – undo
971 971
 				//Local tax 2 before VAT
972 972
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973 973
 				//{
974
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
974
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
975 975
 					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
976
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
977 977
 
978
-						foreach( $localtax_rate as $tvakey => $tvaval )
978
+						foreach ($localtax_rate as $tvakey => $tvaval)
979 979
 						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
980
+							if ($tvakey != 0)    // On affiche pas taux 0
981 981
 							{
982 982
 								//$this->atleastoneratenotnull++;
983 983
 
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 								$index++;
987 987
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988 988
 
989
-								$tvacompl='';
990
-								if (preg_match('/\*/',$tvakey))
989
+								$tvacompl = '';
990
+								if (preg_match('/\*/', $tvakey))
991 991
 								{
992
-									$tvakey=str_replace('*','',$tvakey);
992
+									$tvakey = str_replace('*', '', $tvakey);
993 993
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994 994
 								}
995 995
 								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
996
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
997
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998 998
 
999 999
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000 1000
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 					}
1004 1004
 				//}
1005 1005
 				// VAT
1006
-				foreach($this->tva as $tvakey => $tvaval)
1006
+				foreach ($this->tva as $tvakey => $tvaval)
1007 1007
 				{
1008 1008
 					if ($tvakey > 0)    // On affiche pas taux 0
1009 1009
 					{
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 						$index++;
1013 1013
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014 1014
 
1015
-						$tvacompl='';
1016
-						if (preg_match('/\*/',$tvakey))
1015
+						$tvacompl = '';
1016
+						if (preg_match('/\*/', $tvakey))
1017 1017
 						{
1018
-							$tvakey=str_replace('*','',$tvakey);
1018
+							$tvakey = str_replace('*', '', $tvakey);
1019 1019
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020 1020
 						}
1021
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1023
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1021
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1022
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1023
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024 1024
 
1025 1025
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026 1026
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 				//Local tax 1 after VAT
1031 1031
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032 1032
 				//{
1033
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1033
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1034 1034
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1035
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1036 1036
 
1037
-						foreach( $localtax_rate as $tvakey => $tvaval )
1037
+						foreach ($localtax_rate as $tvakey => $tvaval)
1038 1038
 						{
1039 1039
 							if ($tvakey != 0)    // On affiche pas taux 0
1040 1040
 							{
@@ -1043,16 +1043,16 @@  discard block
 block discarded – undo
1043 1043
 								$index++;
1044 1044
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1045
 
1046
-								$tvacompl='';
1047
-								if (preg_match('/\*/',$tvakey))
1046
+								$tvacompl = '';
1047
+								if (preg_match('/\*/', $tvakey))
1048 1048
 								{
1049
-									$tvakey=str_replace('*','',$tvakey);
1049
+									$tvakey = str_replace('*', '', $tvakey);
1050 1050
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051 1051
 								}
1052
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1052
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1053 1053
 
1054
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1054
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1055
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056 1056
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057 1057
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058 1058
 							}
@@ -1062,11 +1062,11 @@  discard block
 block discarded – undo
1062 1062
 				//Local tax 2 after VAT
1063 1063
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064 1064
 				//{
1065
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1065
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1066 1066
 					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1067
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1068 1068
 
1069
-						foreach( $localtax_rate as $tvakey => $tvaval )
1069
+						foreach ($localtax_rate as $tvakey => $tvaval)
1070 1070
 						{
1071 1071
 						    // retrieve global local tax
1072 1072
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1076,16 +1076,16 @@  discard block
 block discarded – undo
1076 1076
 								$index++;
1077 1077
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 1078
 
1079
-								$tvacompl='';
1080
-								if (preg_match('/\*/',$tvakey))
1079
+								$tvacompl = '';
1080
+								if (preg_match('/\*/', $tvakey))
1081 1081
 								{
1082
-									$tvakey=str_replace('*','',$tvakey);
1082
+									$tvakey = str_replace('*', '', $tvakey);
1083 1083
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084 1084
 								}
1085
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1085
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1086 1086
 
1087
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1087
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1088
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089 1089
 
1090 1090
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091 1091
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1097,16 +1097,16 @@  discard block
 block discarded – undo
1097 1097
 				// Total TTC
1098 1098
 				$index++;
1099 1099
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
-				$pdf->SetTextColor(0,0,60);
1101
-				$pdf->SetFillColor(224,224,224);
1102
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1100
+				$pdf->SetTextColor(0, 0, 60);
1101
+				$pdf->SetFillColor(224, 224, 224);
1102
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103 1103
 
1104 1104
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 1105
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106 1106
 			}
1107 1107
 		}
1108 1108
 
1109
-		$pdf->SetTextColor(0,0,0);
1109
+		$pdf->SetTextColor(0, 0, 0);
1110 1110
 
1111 1111
 		/*
1112 1112
 		$resteapayer = $object->total_ttc - $deja_regle;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 			$index++;
1119 1119
 
1120 1120
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1121
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1122 1122
 
1123 1123
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124 1124
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1140,16 +1140,16 @@  discard block
 block discarded – undo
1140 1140
 			*/
1141 1141
 
1142 1142
 			$index++;
1143
-			$pdf->SetTextColor(0,0,60);
1144
-			$pdf->SetFillColor(224,224,224);
1143
+			$pdf->SetTextColor(0, 0, 60);
1144
+			$pdf->SetFillColor(224, 224, 224);
1145 1145
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1146
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1147 1147
 
1148 1148
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149 1149
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1150 1150
 
1151
-			$pdf->SetFont('','', $default_font_size - 1);
1152
-			$pdf->SetTextColor(0,0,0);
1151
+			$pdf->SetFont('', '', $default_font_size - 1);
1152
+			$pdf->SetTextColor(0, 0, 0);
1153 1153
 		}
1154 1154
 
1155 1155
 		$index++;
@@ -1169,43 +1169,43 @@  discard block
 block discarded – undo
1169 1169
 	 *   @param		string		$currency		Currency code
1170 1170
 	 *   @return	void
1171 1171
 	 */
1172
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1172
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1173 1173
 	{
1174 1174
 		global $conf;
1175 1175
 
1176 1176
 		// Force to disable hidetop and hidebottom
1177
-		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1177
+		$hidebottom = 0;
1178
+		if ($hidetop) $hidetop = -1;
1179 1179
 
1180 1180
 		$currency = !empty($currency) ? $currency : $conf->currency;
1181 1181
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1182 1182
 
1183 1183
 		// Amount in (at tab_top - 1)
1184
-		$pdf->SetTextColor(0,0,0);
1185
-		$pdf->SetFont('','',$default_font_size - 2);
1184
+		$pdf->SetTextColor(0, 0, 0);
1185
+		$pdf->SetFont('', '', $default_font_size - 2);
1186 1186
 
1187 1187
 		if (empty($hidetop))
1188 1188
 		{
1189
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1189
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1191 1191
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192 1192
 
1193 1193
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1194
+			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));
1195 1195
 		}
1196 1196
 
1197
-		$pdf->SetDrawColor(128,128,128);
1198
-		$pdf->SetFont('','',$default_font_size - 1);
1197
+		$pdf->SetDrawColor(128, 128, 128);
1198
+		$pdf->SetFont('', '', $default_font_size - 1);
1199 1199
 
1200 1200
 		// Output Rect
1201
-		$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
1201
+		$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
1202 1202
 
1203 1203
 		if (empty($hidetop))
1204 1204
 		{
1205
-			$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
1205
+			$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
1206 1206
 
1207
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1207
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1208
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1209 1209
 		}
1210 1210
 
1211 1211
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1214,33 +1214,33 @@  discard block
 block discarded – undo
1214 1214
 			//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215 1215
 			if (empty($hidetop))
1216 1216
 			{
1217
-				$pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1217
+				$pdf->SetXY($this->posxtva - 5, $tab_top + 1);
1218
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1219 1219
 			}
1220 1220
 		}
1221 1221
 
1222
-		$pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1222
+		$pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height);
1223 1223
 		if (empty($hidetop))
1224 1224
 		{
1225
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1226
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1225
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1226
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1227 1227
 		}
1228 1228
 
1229
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1229
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1230 1230
 		if (empty($hidetop))
1231 1231
 		{
1232
-		    $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
-		    if($conf->global->PRODUCT_USE_UNITS)
1232
+		    $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1233
+		    if ($conf->global->PRODUCT_USE_UNITS)
1234 1234
 		    {
1235
-		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1235
+		        $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1236 1236
 		    }
1237 1237
 		    else
1238 1238
 		    {
1239
-		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1239
+		        $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1240 1240
 		    }
1241 1241
 		}
1242 1242
 
1243
-		if($conf->global->PRODUCT_USE_UNITS) {
1243
+		if ($conf->global->PRODUCT_USE_UNITS) {
1244 1244
 		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245 1245
 		    if (empty($hidetop)) {
1246 1246
 		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1249,13 +1249,13 @@  discard block
 block discarded – undo
1249 1249
 		    }
1250 1250
 		}
1251 1251
 
1252
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1252
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1253 1253
 		if (empty($hidetop))
1254 1254
 		{
1255 1255
 			if ($this->atleastonediscount)
1256 1256
 			{
1257
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1257
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1258
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1259 1259
 			}
1260 1260
 		}
1261 1261
 		if ($this->atleastonediscount)
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
 		}
1265 1265
 		if (empty($hidetop))
1266 1266
 		{
1267
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1267
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1268
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1269 1269
 		}
1270 1270
 	}
1271 1271
 
@@ -1287,67 +1287,67 @@  discard block
 block discarded – undo
1287 1287
 
1288 1288
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1289 1289
 
1290
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1290
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1291 1291
 
1292 1292
 		//  Show Draft Watermark
1293
-		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1293
+		if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)))
1294 1294
 		{
1295
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1295
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1296 1296
 		}
1297 1297
 
1298
-		$pdf->SetTextColor(0,0,60);
1299
-		$pdf->SetFont('','B', $default_font_size + 3);
1298
+		$pdf->SetTextColor(0, 0, 60);
1299
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1300 1300
 
1301
-		$posy=$this->marge_haute;
1302
-		$posx=$this->page_largeur-$this->marge_droite-100;
1301
+		$posy = $this->marge_haute;
1302
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1303 1303
 
1304
-		$pdf->SetXY($this->marge_gauche,$posy);
1304
+		$pdf->SetXY($this->marge_gauche, $posy);
1305 1305
 
1306 1306
 		// Logo
1307
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1307
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308 1308
 		if ($this->emetteur->logo)
1309 1309
 		{
1310 1310
 			if (is_readable($logo))
1311 1311
 			{
1312
-			    $height=pdf_getHeightForLogo($logo);
1313
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1312
+			    $height = pdf_getHeightForLogo($logo);
1313
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1314 1314
 			}
1315 1315
 			else
1316 1316
 			{
1317
-				$pdf->SetTextColor(200,0,0);
1318
-				$pdf->SetFont('','B',$default_font_size - 2);
1319
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1317
+				$pdf->SetTextColor(200, 0, 0);
1318
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1319
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1320 1320
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321 1321
 			}
1322 1322
 		}
1323 1323
 		else
1324 1324
 		{
1325
-			$text=$this->emetteur->name;
1325
+			$text = $this->emetteur->name;
1326 1326
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327 1327
 		}
1328 1328
 
1329
-		$pdf->SetFont('','B',$default_font_size + 3);
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$title=$outputlangs->transnoentities("CommercialAsk");
1329
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1330
+		$pdf->SetXY($posx, $posy);
1331
+		$pdf->SetTextColor(0, 0, 60);
1332
+		$title = $outputlangs->transnoentities("CommercialAsk");
1333 1333
 		$pdf->MultiCell(100, 4, $title, '', 'R');
1334 1334
 
1335
-		$pdf->SetFont('','B',$default_font_size);
1335
+		$pdf->SetFont('', 'B', $default_font_size);
1336 1336
 
1337
-		$posy+=5;
1338
-		$pdf->SetXY($posx,$posy);
1339
-		$pdf->SetTextColor(0,0,60);
1340
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1337
+		$posy += 5;
1338
+		$pdf->SetXY($posx, $posy);
1339
+		$pdf->SetTextColor(0, 0, 60);
1340
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1341 1341
 
1342
-		$posy+=1;
1343
-		$pdf->SetFont('','', $default_font_size - 2);
1342
+		$posy += 1;
1343
+		$pdf->SetFont('', '', $default_font_size - 2);
1344 1344
 
1345 1345
 		if ($object->ref_client)
1346 1346
 		{
1347
-			$posy+=4;
1348
-			$pdf->SetXY($posx,$posy);
1349
-			$pdf->SetTextColor(0,0,60);
1350
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1347
+			$posy += 4;
1348
+			$pdf->SetXY($posx, $posy);
1349
+			$pdf->SetTextColor(0, 0, 60);
1350
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351 1351
 		}
1352 1352
 /* PHFAVRE
1353 1353
 		$posy+=4;
@@ -1358,28 +1358,28 @@  discard block
 block discarded – undo
1358 1358
 
1359 1359
 		if ($object->thirdparty->code_fournisseur)
1360 1360
 		{
1361
-			$posy+=4;
1362
-			$pdf->SetXY($posx,$posy);
1363
-			$pdf->SetTextColor(0,0,60);
1364
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1361
+			$posy += 4;
1362
+			$pdf->SetXY($posx, $posy);
1363
+			$pdf->SetTextColor(0, 0, 60);
1364
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365 1365
 		}
1366 1366
 
1367 1367
 		// Get contact
1368 1368
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369 1369
 		{
1370
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1370
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1371 1371
 		    if (count($arrayidcontact) > 0)
1372 1372
 		    {
1373
-		        $usertmp=new User($this->db);
1373
+		        $usertmp = new User($this->db);
1374 1374
 		        $usertmp->fetch($arrayidcontact[0]);
1375
-                $posy+=4;
1376
-                $pdf->SetXY($posx,$posy);
1377
-		        $pdf->SetTextColor(0,0,60);
1375
+                $posy += 4;
1376
+                $pdf->SetXY($posx, $posy);
1377
+		        $pdf->SetTextColor(0, 0, 60);
1378 1378
 		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379 1379
 		    }
1380 1380
 		}
1381 1381
 
1382
-		$posy+=2;
1382
+		$posy += 2;
1383 1383
 
1384 1384
 		$top_shift = 0;
1385 1385
 		// Show list of linked objects
@@ -1393,96 +1393,96 @@  discard block
 block discarded – undo
1393 1393
 		if ($showaddress)
1394 1394
 		{
1395 1395
 			// Sender properties
1396
-			$carac_emetteur='';
1396
+			$carac_emetteur = '';
1397 1397
 		 	// Add internal contact of proposal if defined
1398
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1398
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1399 1399
 		 	if (count($arrayidcontact) > 0)
1400 1400
 		 	{
1401 1401
 		 		$object->fetch_user($arrayidcontact[0]);
1402
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1402
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1403
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404 1404
 		 	}
1405 1405
 
1406 1406
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407 1407
 
1408 1408
 			// Show sender
1409
-			$posy=42+$top_shift;
1410
-		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
-			$hautcadre=40;
1409
+			$posy = 42 + $top_shift;
1410
+		 	$posx = $this->marge_gauche;
1411
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1412
+			$hautcadre = 40;
1413 1413
 
1414 1414
 			// Show sender frame
1415
-			$pdf->SetTextColor(0,0,0);
1416
-			$pdf->SetFont('','', $default_font_size - 2);
1417
-			$pdf->SetXY($posx,$posy-5);
1418
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
-			$pdf->SetXY($posx,$posy);
1420
-			$pdf->SetFillColor(230,230,230);
1415
+			$pdf->SetTextColor(0, 0, 0);
1416
+			$pdf->SetFont('', '', $default_font_size - 2);
1417
+			$pdf->SetXY($posx, $posy - 5);
1418
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
+			$pdf->SetXY($posx, $posy);
1420
+			$pdf->SetFillColor(230, 230, 230);
1421 1421
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
-			$pdf->SetTextColor(0,0,60);
1422
+			$pdf->SetTextColor(0, 0, 60);
1423 1423
 
1424 1424
 			// Show sender name
1425
-			$pdf->SetXY($posx+2,$posy+3);
1426
-			$pdf->SetFont('','B', $default_font_size);
1425
+			$pdf->SetXY($posx + 2, $posy + 3);
1426
+			$pdf->SetFont('', 'B', $default_font_size);
1427 1427
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
-			$posy=$pdf->getY();
1428
+			$posy = $pdf->getY();
1429 1429
 
1430 1430
 			// Show sender information
1431
-			$pdf->SetXY($posx+2,$posy);
1432
-			$pdf->SetFont('','', $default_font_size - 1);
1431
+			$pdf->SetXY($posx + 2, $posy);
1432
+			$pdf->SetFont('', '', $default_font_size - 1);
1433 1433
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434 1434
 
1435 1435
 
1436 1436
 			// If CUSTOMER contact defined, we use it
1437
-			$usecontact=false;
1438
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1437
+			$usecontact = false;
1438
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1439 1439
 			if (count($arrayidcontact) > 0)
1440 1440
 			{
1441
-				$usecontact=true;
1442
-				$result=$object->fetch_contact($arrayidcontact[0]);
1441
+				$usecontact = true;
1442
+				$result = $object->fetch_contact($arrayidcontact[0]);
1443 1443
 			}
1444 1444
 
1445 1445
 			// Recipient name
1446
-			if (! empty($usecontact))
1446
+			if (!empty($usecontact))
1447 1447
 			{
1448 1448
 				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1449
+				if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450 1450
 				else $socname = $object->thirdparty->name;
1451
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1451
+				$carac_client_name = $outputlangs->convToOutputCharset($socname);
1452 1452
 			}
1453 1453
 			else
1454 1454
 			{
1455
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1455
+				$carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
1456 1456
 			}
1457 1457
 
1458
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1458
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1459 1459
 
1460 1460
 			// Show recipient
1461
-			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
-			$posy=42+$top_shift;
1464
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1461
+			$widthrecbox = 100;
1462
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1463
+			$posy = 42 + $top_shift;
1464
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1465
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1466 1466
 
1467 1467
 			// Show recipient frame
1468
-			$pdf->SetTextColor(0,0,0);
1469
-			$pdf->SetFont('','', $default_font_size - 2);
1470
-			$pdf->SetXY($posx+2,$posy-5);
1468
+			$pdf->SetTextColor(0, 0, 0);
1469
+			$pdf->SetFont('', '', $default_font_size - 2);
1470
+			$pdf->SetXY($posx + 2, $posy - 5);
1471 1471
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472 1472
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473 1473
 
1474 1474
 			// Show recipient name
1475
-			$pdf->SetXY($posx+2,$posy+3);
1476
-			$pdf->SetFont('','B', $default_font_size);
1475
+			$pdf->SetXY($posx + 2, $posy + 3);
1476
+			$pdf->SetFont('', 'B', $default_font_size);
1477 1477
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478 1478
 
1479 1479
 			// Show recipient information
1480
-			$pdf->SetFont('','', $default_font_size - 1);
1481
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1480
+			$pdf->SetFont('', '', $default_font_size - 1);
1481
+			$pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1482 1482
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483 1483
 		}
1484 1484
 
1485
-		$pdf->SetTextColor(0,0,0);
1485
+		$pdf->SetTextColor(0, 0, 0);
1486 1486
 		return $top_shift;
1487 1487
 	}
1488 1488
 
@@ -1495,10 +1495,10 @@  discard block
 block discarded – undo
1495 1495
 	 *      @param	int			$hidefreetext		1=Hide free text
1496 1496
 	 *      @return	int								Return height of bottom margin including footer text
1497 1497
 	 */
1498
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1498
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1499 1499
 	{
1500 1500
 		global $conf;
1501
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1501
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1503 1503
 	}
1504 1504
 }
Please login to merge, or discard this patch.
Braces   +176 added lines, -90 removed lines patch added patch discarded remove patch
@@ -154,7 +154,10 @@  discard block
 block discarded – undo
154 154
 
155 155
 		// Get source company
156 156
 		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
157
+		if (empty($this->emetteur->country_code)) {
158
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
159
+		}
160
+		// By default, if was not defined
158 161
 
159 162
 		// Define position of columns
160 163
 		$this->posxdesc=$this->marge_gauche+1;
@@ -173,11 +176,15 @@  discard block
 block discarded – undo
173 176
 		    $this->posxqty=145;
174 177
 		}
175 178
 
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
179
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
180
+		    $this->posxup=$this->posxtva;
181
+		}
177 182
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
-		if ($this->page_largeur < 210) // To work with US executive format
183
+		if ($this->page_largeur < 210) {
184
+		    // To work with US executive format
179 185
 		{
180 186
 			$this->posxpicture-=20;
187
+		}
181 188
 			$this->posxtva-=20;
182 189
 			$this->posxup-=20;
183 190
 			$this->posxqty-=20;
@@ -210,9 +217,13 @@  discard block
 block discarded – undo
210 217
         // phpcs:enable
211 218
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
212 219
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
220
+		if (! is_object($outputlangs)) {
221
+		    $outputlangs=$langs;
222
+		}
214 223
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
224
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
225
+		    $outputlangs->charset_output='ISO-8859-1';
226
+		}
216 227
 
217 228
 		// Load traductions files requiredby by page
218 229
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
@@ -225,7 +236,9 @@  discard block
 block discarded – undo
225 236
 		{
226 237
 			for ($i = 0 ; $i < $nblignes ; $i++)
227 238
 			{
228
-				if (empty($object->lines[$i]->fk_product)) continue;
239
+				if (empty($object->lines[$i]->fk_product)) {
240
+				    continue;
241
+				}
229 242
 
230 243
 				$objphoto = new Product($this->db);
231 244
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -234,8 +247,7 @@  discard block
 block discarded – undo
234 247
 				{
235 248
 					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236 249
 					$dir = $conf->product->dir_output.'/'.$pdir;
237
-				}
238
-				else
250
+				} else
239 251
 				{
240 252
 					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241 253
 					$dir = $conf->product->dir_output.'/'.$pdir;
@@ -250,10 +262,14 @@  discard block
 block discarded – undo
250 262
 					break;
251 263
 				}
252 264
 
253
-				if ($realpath) $realpatharray[$i]=$realpath;
265
+				if ($realpath) {
266
+				    $realpatharray[$i]=$realpath;
267
+				}
254 268
 			}
255 269
 		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
270
+		if (count($realpatharray) == 0) {
271
+		    $this->posxpicture=$this->posxtva;
272
+		}
257 273
 
258 274
 		if ($conf->supplier_proposal->dir_output)
259 275
 		{
@@ -266,8 +282,7 @@  discard block
 block discarded – undo
266 282
 			{
267 283
 				$dir = $conf->supplier_proposal->dir_output;
268 284
 				$file = $dir . "/SPECIMEN.pdf";
269
-			}
270
-			else
285
+			} else
271 286
 			{
272 287
 				$objectref = dol_sanitizeFileName($object->ref);
273 288
 				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
@@ -302,7 +317,9 @@  discard block
 block discarded – undo
302 317
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
303 318
 		        $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
304 319
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
320
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
321
+	                $heightforfooter+= 6;
322
+	            }
306 323
                 $pdf->SetAutoPageBreak(1,0);
307 324
 
308 325
                 if (class_exists('TCPDF'))
@@ -327,7 +344,9 @@  discard block
 block discarded – undo
327 344
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328 345
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329 346
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
347
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
348
+				    $pdf->SetCompression(false);
349
+				}
331 350
 
332 351
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
333 352
 
@@ -351,7 +370,9 @@  discard block
 block discarded – undo
351 370
 
352 371
 				// New page
353 372
 				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
373
+				if (! empty($tplidx)) {
374
+				    $pdf->useTemplate($tplidx);
375
+				}
355 376
 				$pagenb++;
356 377
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357 378
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -371,7 +392,9 @@  discard block
 block discarded – undo
371 392
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372 393
 						$salerepobj=new User($this->db);
373 394
 						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
395
+						if (! empty($salerepobj->signature)) {
396
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
397
+						}
375 398
 					}
376 399
 				}
377 400
 				if ($notetoshow)
@@ -407,7 +430,9 @@  discard block
 block discarded – undo
407 430
 
408 431
 					// Define size of image if we need it
409 432
 					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
433
+					if (! empty($realpatharray[$i])) {
434
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
435
+					}
411 436
 
412 437
 					$pdf->setTopMargin($tab_top_newpage);
413 438
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -418,11 +443,17 @@  discard block
 block discarded – undo
418 443
 					$posYAfterDescription=0;
419 444
 
420 445
 					// We start with Photo of product line
421
-					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
446
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
447
+					    // If photo too high, we moved completely on new page
422 448
 					{
423 449
 						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
450
+					}
451
+						if (! empty($tplidx)) {
452
+						    $pdf->useTemplate($tplidx);
453
+						}
454
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
455
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
456
+						}
426 457
 						$pdf->setPage($pageposbefore+1);
427 458
 
428 459
 						$curY = $tab_top_newpage;
@@ -444,17 +475,18 @@  discard block
 block discarded – undo
444 475
 					if ($posYAfterImage > 0)
445 476
 					{
446 477
 						$descWidth = $this->posxpicture-$curX;
447
-					}
448
-					else
478
+					} else
449 479
 					{
450 480
 						$descWidth = $this->posxtva-$curX;
451 481
 					}
452 482
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453 483
 
454 484
 					$pageposafter=$pdf->getPage();
455
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
485
+					if ($pageposafter > $pageposbefore) {
486
+					    // There is a pagebreak
456 487
 					{
457 488
 						$pdf->rollbackTransaction(true);
489
+					}
458 490
 						$pageposafter=$pageposbefore;
459 491
 						//print $pageposafter.'-'.$pageposbefore;exit;
460 492
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -463,23 +495,27 @@  discard block
 block discarded – undo
463 495
 						$pageposafter=$pdf->getPage();
464 496
 						$posyafter=$pdf->GetY();
465 497
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
498
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
499
+						    // There is no space left for total+free text
467 500
 						{
468 501
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469 502
 							{
470 503
 								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
504
+						}
505
+								if (! empty($tplidx)) {
506
+								    $pdf->useTemplate($tplidx);
507
+								}
508
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
509
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
510
+								}
473 511
 								$pdf->setPage($pageposafter+1);
474 512
 							}
475
-						}
476
-						else
513
+						} else
477 514
 						{
478 515
 							// We found a page break
479 516
 							$showpricebeforepagebreak=0;
480 517
 						}
481
-					}
482
-					else	// No pagebreak
518
+					} else	// No pagebreak
483 519
 					{
484 520
 						$pdf->commitTransaction();
485 521
 					}
@@ -522,8 +558,7 @@  discard block
 block discarded – undo
522 558
 					if($conf->global->PRODUCT_USE_UNITS)
523 559
 					{
524 560
 					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
-					}
526
-					else
561
+					} else
527 562
 					{
528 563
 					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529 564
 					}
@@ -553,8 +588,11 @@  discard block
 block discarded – undo
553 588
                     */
554 589
 
555 590
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
591
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
592
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
593
+					} else {
594
+					    $tvaligne=$object->lines[$i]->total_tva;
595
+					}
558 596
 
559 597
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
560 598
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -563,32 +601,48 @@  discard block
 block discarded – undo
563 601
 					$localtax1_type=$object->lines[$i]->localtax1_type;
564 602
 					$localtax2_type=$object->lines[$i]->localtax2_type;
565 603
 
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
604
+					if ($object->remise_percent) {
605
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
606
+					}
607
+					if ($object->remise_percent) {
608
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
609
+					}
610
+					if ($object->remise_percent) {
611
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
612
+					}
569 613
 
570 614
 					$vatrate=(string) $object->lines[$i]->tva_tx;
571 615
 
572 616
 					// Retrieve type from database for backward compatibility with old records
573 617
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
618
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
619
+					    // and there is local tax
575 620
 					{
576 621
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
622
+					}
577 623
 						$localtax1_type = $localtaxtmp_array[0];
578 624
 						$localtax2_type = $localtaxtmp_array[2];
579 625
 					}
580 626
 
581 627
 				    // retrieve global local tax
582
-					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
-					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
628
+					if ($localtax1_type && $localtax1ligne != 0) {
629
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
630
+					}
631
+					if ($localtax2_type && $localtax2ligne != 0) {
632
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
633
+					}
586 634
 
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
635
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
636
+					    $vatrate.='*';
637
+					}
638
+					if (! isset($this->tva[$vatrate])) {
639
+					    $this->tva[$vatrate]=0;
640
+					}
589 641
 					$this->tva[$vatrate] += $tvaligne;
590 642
 
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
643
+					if ($posYAfterImage > $posYAfterDescription) {
644
+					    $nexY=$posYAfterImage;
645
+					}
592 646
 
593 647
 					// Add line
594 648
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -609,8 +663,7 @@  discard block
 block discarded – undo
609 663
 						if ($pagenb == 1)
610 664
 						{
611 665
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
-						}
613
-						else
666
+						} else
614 667
 						{
615 668
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616 669
 						}
@@ -618,24 +671,29 @@  discard block
 block discarded – undo
618 671
 						$pagenb++;
619 672
 						$pdf->setPage($pagenb);
620 673
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
674
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
675
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
676
+						}
622 677
 					}
623 678
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624 679
 					{
625 680
 						if ($pagenb == 1)
626 681
 						{
627 682
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
-						}
629
-						else
683
+						} else
630 684
 						{
631 685
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632 686
 						}
633 687
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
634 688
 						// New page
635 689
 						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
690
+						if (! empty($tplidx)) {
691
+						    $pdf->useTemplate($tplidx);
692
+						}
637 693
 						$pagenb++;
638
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
694
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
695
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
696
+						}
639 697
 					}
640 698
 				}
641 699
 
@@ -644,8 +702,7 @@  discard block
 block discarded – undo
644 702
 				{
645 703
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646 704
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
-				}
648
-				else
705
+				} else
649 706
 				{
650 707
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651 708
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -667,7 +724,9 @@  discard block
 block discarded – undo
667 724
 
668 725
 				// Pied de page
669 726
 				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
727
+				if (method_exists($pdf,'AliasNbPages')) {
728
+				    $pdf->AliasNbPages();
729
+				}
671 730
 
672 731
 				$pdf->Close();
673 732
 
@@ -679,20 +738,19 @@  discard block
 block discarded – undo
679 738
 				global $action;
680 739
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
681 740
 
682
-				if (! empty($conf->global->MAIN_UMASK))
683
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
741
+				if (! empty($conf->global->MAIN_UMASK)) {
742
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
743
+				}
684 744
 
685 745
 				$this->result = array('fullpath'=>$file);
686 746
 
687 747
 				return 1;   // Pas d'erreur
688
-			}
689
-			else
748
+			} else
690 749
 			{
691 750
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692 751
 				return 0;
693 752
 			}
694
-		}
695
-		else
753
+		} else
696 754
 		{
697 755
 			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698 756
 			return 0;
@@ -749,8 +807,7 @@  discard block
 block discarded – undo
749 807
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 808
 
751 809
             $posy=$pdf->GetY()+1;
752
-		}
753
-		else {
810
+		} else {
754 811
 			$outputlangs->load("sendings");
755 812
 			$pdf->SetFont('','B', $default_font_size - 2);
756 813
 			$pdf->SetXY($this->marge_gauche, $posy);
@@ -906,10 +963,12 @@  discard block
 block discarded – undo
906 963
 
907 964
 		// Tableau total
908 965
 		$col1x = 120; $col2x = 170;
909
-		if ($this->page_largeur < 210) // To work with US executive format
966
+		if ($this->page_largeur < 210) {
967
+		    // To work with US executive format
910 968
 		{
911 969
 			$col2x-=20;
912 970
 		}
971
+		}
913 972
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914 973
 
915 974
 		$useborder=0;
@@ -933,23 +992,26 @@  discard block
 block discarded – undo
933 992
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934 993
 			{
935 994
 				// Nothing to do
936
-			}
937
-			else
995
+			} else
938 996
 			{
939 997
 				//Local tax 1 before VAT
940 998
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941 999
 				//{
942 1000
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943 1001
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1002
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1003
+						    continue;
1004
+						}
945 1005
 
946 1006
 						foreach( $localtax_rate as $tvakey => $tvaval )
947 1007
 						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
1008
+							if ($tvakey!=0) {
1009
+							    // On affiche pas taux 0
949 1010
 							{
950 1011
 								//$this->atleastoneratenotnull++;
951 1012
 
952 1013
 								$index++;
1014
+							}
953 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954 1016
 
955 1017
 								$tvacompl='';
@@ -973,17 +1035,21 @@  discard block
 block discarded – undo
973 1035
 				//{
974 1036
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975 1037
 					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1038
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1039
+						    continue;
1040
+						}
977 1041
 
978 1042
 						foreach( $localtax_rate as $tvakey => $tvaval )
979 1043
 						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
1044
+							if ($tvakey!=0) {
1045
+							    // On affiche pas taux 0
981 1046
 							{
982 1047
 								//$this->atleastoneratenotnull++;
983 1048
 
984 1049
 
985 1050
 
986 1051
 								$index++;
1052
+							}
987 1053
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988 1054
 
989 1055
 								$tvacompl='';
@@ -1005,9 +1071,11 @@  discard block
 block discarded – undo
1005 1071
 				// VAT
1006 1072
 				foreach($this->tva as $tvakey => $tvaval)
1007 1073
 				{
1008
-					if ($tvakey > 0)    // On affiche pas taux 0
1074
+					if ($tvakey > 0) {
1075
+					    // On affiche pas taux 0
1009 1076
 					{
1010 1077
 						$this->atleastoneratenotnull++;
1078
+					}
1011 1079
 
1012 1080
 						$index++;
1013 1081
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1032,15 +1100,19 @@  discard block
 block discarded – undo
1032 1100
 				//{
1033 1101
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034 1102
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1103
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1104
+						    continue;
1105
+						}
1036 1106
 
1037 1107
 						foreach( $localtax_rate as $tvakey => $tvaval )
1038 1108
 						{
1039
-							if ($tvakey != 0)    // On affiche pas taux 0
1109
+							if ($tvakey != 0) {
1110
+							    // On affiche pas taux 0
1040 1111
 							{
1041 1112
 								//$this->atleastoneratenotnull++;
1042 1113
 
1043 1114
 								$index++;
1115
+							}
1044 1116
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1117
 
1046 1118
 								$tvacompl='';
@@ -1064,16 +1136,20 @@  discard block
 block discarded – undo
1064 1136
 				//{
1065 1137
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066 1138
 					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1139
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1140
+						    continue;
1141
+						}
1068 1142
 
1069 1143
 						foreach( $localtax_rate as $tvakey => $tvaval )
1070 1144
 						{
1071 1145
 						    // retrieve global local tax
1072
-							if ($tvakey != 0)    // On affiche pas taux 0
1146
+							if ($tvakey != 0) {
1147
+							    // On affiche pas taux 0
1073 1148
 							{
1074 1149
 								//$this->atleastoneratenotnull++;
1075 1150
 
1076 1151
 								$index++;
1152
+							}
1077 1153
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 1154
 
1079 1155
 								$tvacompl='';
@@ -1175,7 +1251,9 @@  discard block
 block discarded – undo
1175 1251
 
1176 1252
 		// Force to disable hidetop and hidebottom
1177 1253
 		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1254
+		if ($hidetop) {
1255
+		    $hidetop=-1;
1256
+		}
1179 1257
 
1180 1258
 		$currency = !empty($currency) ? $currency : $conf->currency;
1181 1259
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1191,7 +1269,9 @@  discard block
 block discarded – undo
1191 1269
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192 1270
 
1193 1271
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1272
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1273
+			    $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));
1274
+			}
1195 1275
 		}
1196 1276
 
1197 1277
 		$pdf->SetDrawColor(128,128,128);
@@ -1233,8 +1313,7 @@  discard block
 block discarded – undo
1233 1313
 		    if($conf->global->PRODUCT_USE_UNITS)
1234 1314
 		    {
1235 1315
 		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
-		    }
1237
-		    else
1316
+		    } else
1238 1317
 		    {
1239 1318
 		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240 1319
 		    }
@@ -1311,16 +1390,14 @@  discard block
 block discarded – undo
1311 1390
 			{
1312 1391
 			    $height=pdf_getHeightForLogo($logo);
1313 1392
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
-			}
1315
-			else
1393
+			} else
1316 1394
 			{
1317 1395
 				$pdf->SetTextColor(200,0,0);
1318 1396
 				$pdf->SetFont('','B',$default_font_size - 2);
1319 1397
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320 1398
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321 1399
 			}
1322
-		}
1323
-		else
1400
+		} else
1324 1401
 		{
1325 1402
 			$text=$this->emetteur->name;
1326 1403
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1408,7 +1485,9 @@  discard block
 block discarded – undo
1408 1485
 			// Show sender
1409 1486
 			$posy=42+$top_shift;
1410 1487
 		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1488
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1489
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1490
+			}
1412 1491
 			$hautcadre=40;
1413 1492
 
1414 1493
 			// Show sender frame
@@ -1446,11 +1525,13 @@  discard block
 block discarded – undo
1446 1525
 			if (! empty($usecontact))
1447 1526
 			{
1448 1527
 				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
-				else $socname = $object->thirdparty->name;
1528
+				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1529
+				    $socname = $object->contact->socname;
1530
+				} else {
1531
+				    $socname = $object->thirdparty->name;
1532
+				}
1451 1533
 				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
-			}
1453
-			else
1534
+			} else
1454 1535
 			{
1455 1536
 				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456 1537
 			}
@@ -1459,10 +1540,15 @@  discard block
 block discarded – undo
1459 1540
 
1460 1541
 			// Show recipient
1461 1542
 			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1543
+			if ($this->page_largeur < 210) {
1544
+			    $widthrecbox=84;
1545
+			}
1546
+			// To work with US executive format
1463 1547
 			$posy=42+$top_shift;
1464 1548
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1549
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1550
+			    $posx=$this->marge_gauche;
1551
+			}
1466 1552
 
1467 1553
 			// Show recipient frame
1468 1554
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.