Completed
Branch develop (c604ce)
by
unknown
32:31
created
htdocs/core/class/commondocgenerator.class.php 1 patch
Indentation   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -41,181 +41,181 @@  discard block
 block discarded – undo
41 41
 	 *	Constructor
42 42
 	 *
43 43
 	 *  @param		DoliDB		$db      Database handler
44
-	*/
44
+	 */
45 45
 	public function __construct($db) {
46 46
 		$this->db = $db;
47 47
 		return 1;
48 48
 	}
49 49
 
50 50
 
51
-    /**
52
-     * Define array with couple subtitution key => subtitution value
53
-     *
54
-     * @param   User		$user           User
55
-     * @param   Translate	$outputlangs    Language object for output
56
-     * @return	array						Array of substitution key->code
57
-     */
58
-    function get_substitutionarray_user($user,$outputlangs)
59
-    {
60
-        global $conf;
61
-
62
-        $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo;
63
-
64
-        return array(
65
-            'myuser_lastname'=>$user->lastname,
66
-            'myuser_firstname'=>$user->firstname,
67
-            'myuser_fullname'=>$user->getFullName($outputlangs,1),
68
-            'myuser_login'=>$user->login,
69
-            'myuser_phone'=>$user->office_phone,
70
-       		'myuser_address'=>$user->address,
71
-       		'myuser_zip'=>$user->zip,
72
-       		'myuser_town'=>$user->town,
73
-       		'myuser_country'=>$user->country,
74
-        	'myuser_country_code'=>$user->country_code,
75
-       		'myuser_state'=>$user->state,
76
-        	'myuser_state_code'=>$user->state_code,
77
-        	'myuser_fax'=>$user->office_fax,
78
-            'myuser_mobile'=>$user->user_mobile,
79
-            'myuser_email'=>$user->email,
80
-        	'myuser_logo'=>$logotouse,
81
-        	'myuser_job'=>$user->job,
82
-            'myuser_web'=>''	// url not exist in $user object
83
-        );
84
-    }
85
-
86
-
87
-    /**
88
-     * Define array with couple subtitution key => subtitution value
89
-     *
90
-     * @param   Societe		$mysoc			Object thirdparty
91
-     * @param   Translate	$outputlangs    Language object for output
92
-     * @return	array						Array of substitution key->code
93
-     */
94
-    function get_substitutionarray_mysoc($mysoc,$outputlangs)
95
-    {
96
-        global $conf;
97
-
98
-        if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code))
99
-        {
100
-            $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code);
101
-        }
102
-        if (empty($mysoc->country) && ! empty($mysoc->country_code))
103
-        {
104
-        	$mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code);
105
-        }
106
-        if (empty($mysoc->state) && ! empty($mysoc->state_code))
107
-        {
108
-        	$mysoc->state=getState($mysoc->state_code,0);
109
-        }
110
-
111
-        $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
112
-
113
-        return array(
114
-            'mycompany_logo'=>$logotouse,
115
-            'mycompany_name'=>$mysoc->name,
116
-            'mycompany_email'=>$mysoc->email,
117
-            'mycompany_phone'=>$mysoc->phone,
118
-            'mycompany_fax'=>$mysoc->fax,
119
-            'mycompany_address'=>$mysoc->address,
120
-            'mycompany_zip'=>$mysoc->zip,
121
-            'mycompany_town'=>$mysoc->town,
122
-            'mycompany_country'=>$mysoc->country,
123
-            'mycompany_country_code'=>$mysoc->country_code,
124
-            'mycompany_state'=>$mysoc->state,
125
-            'mycompany_state_code'=>$mysoc->state_code,
126
-        	'mycompany_web'=>$mysoc->url,
127
-            'mycompany_juridicalstatus'=>$mysoc->forme_juridique,
128
-            'mycompany_managers'=>$mysoc->managers,
129
-            'mycompany_capital'=>$mysoc->capital,
130
-            'mycompany_barcode'=>$mysoc->barcode,
131
-            'mycompany_idprof1'=>$mysoc->idprof1,
132
-            'mycompany_idprof2'=>$mysoc->idprof2,
133
-            'mycompany_idprof3'=>$mysoc->idprof3,
134
-            'mycompany_idprof4'=>$mysoc->idprof4,
135
-            'mycompany_idprof5'=>$mysoc->idprof5,
136
-            'mycompany_idprof6'=>$mysoc->idprof6,
137
-        	'mycompany_vatnumber'=>$mysoc->tva_intra,
51
+	/**
52
+	 * Define array with couple subtitution key => subtitution value
53
+	 *
54
+	 * @param   User		$user           User
55
+	 * @param   Translate	$outputlangs    Language object for output
56
+	 * @return	array						Array of substitution key->code
57
+	 */
58
+	function get_substitutionarray_user($user,$outputlangs)
59
+	{
60
+		global $conf;
61
+
62
+		$logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo;
63
+
64
+		return array(
65
+			'myuser_lastname'=>$user->lastname,
66
+			'myuser_firstname'=>$user->firstname,
67
+			'myuser_fullname'=>$user->getFullName($outputlangs,1),
68
+			'myuser_login'=>$user->login,
69
+			'myuser_phone'=>$user->office_phone,
70
+	   		'myuser_address'=>$user->address,
71
+	   		'myuser_zip'=>$user->zip,
72
+	   		'myuser_town'=>$user->town,
73
+	   		'myuser_country'=>$user->country,
74
+			'myuser_country_code'=>$user->country_code,
75
+	   		'myuser_state'=>$user->state,
76
+			'myuser_state_code'=>$user->state_code,
77
+			'myuser_fax'=>$user->office_fax,
78
+			'myuser_mobile'=>$user->user_mobile,
79
+			'myuser_email'=>$user->email,
80
+			'myuser_logo'=>$logotouse,
81
+			'myuser_job'=>$user->job,
82
+			'myuser_web'=>''	// url not exist in $user object
83
+		);
84
+	}
85
+
86
+
87
+	/**
88
+	 * Define array with couple subtitution key => subtitution value
89
+	 *
90
+	 * @param   Societe		$mysoc			Object thirdparty
91
+	 * @param   Translate	$outputlangs    Language object for output
92
+	 * @return	array						Array of substitution key->code
93
+	 */
94
+	function get_substitutionarray_mysoc($mysoc,$outputlangs)
95
+	{
96
+		global $conf;
97
+
98
+		if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code))
99
+		{
100
+			$mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code);
101
+		}
102
+		if (empty($mysoc->country) && ! empty($mysoc->country_code))
103
+		{
104
+			$mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code);
105
+		}
106
+		if (empty($mysoc->state) && ! empty($mysoc->state_code))
107
+		{
108
+			$mysoc->state=getState($mysoc->state_code,0);
109
+		}
110
+
111
+		$logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
112
+
113
+		return array(
114
+			'mycompany_logo'=>$logotouse,
115
+			'mycompany_name'=>$mysoc->name,
116
+			'mycompany_email'=>$mysoc->email,
117
+			'mycompany_phone'=>$mysoc->phone,
118
+			'mycompany_fax'=>$mysoc->fax,
119
+			'mycompany_address'=>$mysoc->address,
120
+			'mycompany_zip'=>$mysoc->zip,
121
+			'mycompany_town'=>$mysoc->town,
122
+			'mycompany_country'=>$mysoc->country,
123
+			'mycompany_country_code'=>$mysoc->country_code,
124
+			'mycompany_state'=>$mysoc->state,
125
+			'mycompany_state_code'=>$mysoc->state_code,
126
+			'mycompany_web'=>$mysoc->url,
127
+			'mycompany_juridicalstatus'=>$mysoc->forme_juridique,
128
+			'mycompany_managers'=>$mysoc->managers,
129
+			'mycompany_capital'=>$mysoc->capital,
130
+			'mycompany_barcode'=>$mysoc->barcode,
131
+			'mycompany_idprof1'=>$mysoc->idprof1,
132
+			'mycompany_idprof2'=>$mysoc->idprof2,
133
+			'mycompany_idprof3'=>$mysoc->idprof3,
134
+			'mycompany_idprof4'=>$mysoc->idprof4,
135
+			'mycompany_idprof5'=>$mysoc->idprof5,
136
+			'mycompany_idprof6'=>$mysoc->idprof6,
137
+			'mycompany_vatnumber'=>$mysoc->tva_intra,
138 138
 			'mycompany_object'=>$mysoc->object,
139
-            'mycompany_note_private'=>$mysoc->note_private,
140
-            //'mycompany_note_public'=>$mysoc->note_public,        // Only private not exists for "mysoc" but both for thirdparties
141
-        );
142
-    }
143
-
144
-
145
-    /**
146
-     * Define array with couple subtitution key => subtitution value
147
-     *
148
-     * @param	Object		$object			Object
149
-     * @param   Translate	$outputlangs    Language object for output
150
-     * @return	array						Array of substitution key->code
151
-     */
152
-    function get_substitutionarray_thirdparty($object,$outputlangs)
153
-    {
154
-        global $conf;
155
-
156
-        if (empty($object->country) && ! empty($object->country_code))
157
-        {
158
-        	$object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code);
159
-        }
160
-        if (empty($object->state) && ! empty($object->state_code))
161
-        {
162
-        	$object->state=getState($object->state_code,0);
163
-        }
164
-
165
-        $array_thirdparty = array(
166
-            'company_name'=>$object->name,
167
-	        'company_name_alias' => $object->name_alias,
168
-            'company_email'=>$object->email,
169
-            'company_phone'=>$object->phone,
170
-            'company_fax'=>$object->fax,
171
-            'company_address'=>$object->address,
172
-            'company_zip'=>$object->zip,
173
-            'company_town'=>$object->town,
174
-            'company_country'=>$object->country,
175
-        	'company_country_code'=>$object->country_code,
176
-            'company_state'=>$object->state,
177
-        	'company_state_code'=>$object->state_code,
178
-        	'company_web'=>$object->url,
179
-            'company_barcode'=>$object->barcode,
180
-            'company_vatnumber'=>$object->tva_intra,
181
-            'company_customercode'=>$object->code_client,
182
-            'company_suppliercode'=>$object->code_fournisseur,
183
-            'company_customeraccountancycode'=>$object->code_compta,
184
-            'company_supplieraccountancycode'=>$object->code_compta_fournisseur,
185
-            'company_juridicalstatus'=>$object->forme_juridique,
186
-            'company_outstanding_limit'=>$object->outstanding_limit,
187
-            'company_capital'=>$object->capital,
188
-            'company_idprof1'=>$object->idprof1,
189
-            'company_idprof2'=>$object->idprof2,
190
-            'company_idprof3'=>$object->idprof3,
191
-            'company_idprof4'=>$object->idprof4,
192
-            'company_idprof5'=>$object->idprof5,
193
-            'company_idprof6'=>$object->idprof6,
194
-            'company_note_public'=>$object->note_public,
195
-            'company_note_private'=>$object->note_private,
196
-            'company_default_bank_iban'=>$object->bank_account->iban,
197
-            'company_default_bank_bic'=>$object->bank_account->bic
198
-        );
199
-
200
-        // Retrieve extrafields
201
-        if(is_array($object->array_options) && count($object->array_options))
202
-        {
203
-        	require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
204
-        	$extrafields = new ExtraFields($this->db);
205
-        	$extralabels = $extrafields->fetch_name_optionals_label('societe',true);
206
-        	$object->fetch_optionals();
207
-
208
-        	foreach($extrafields->attribute_label as $key=>$label)
209
-        	{
210
-        		if($extrafields->attribute_type[$key] == 'price')
211
-        		{
212
-        			$object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency);
213
-        		}
214
-        		else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox')
215
-        		{
216
-        			$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
217
-        		}
218
-        		$array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key]));
139
+			'mycompany_note_private'=>$mysoc->note_private,
140
+			//'mycompany_note_public'=>$mysoc->note_public,        // Only private not exists for "mysoc" but both for thirdparties
141
+		);
142
+	}
143
+
144
+
145
+	/**
146
+	 * Define array with couple subtitution key => subtitution value
147
+	 *
148
+	 * @param	Object		$object			Object
149
+	 * @param   Translate	$outputlangs    Language object for output
150
+	 * @return	array						Array of substitution key->code
151
+	 */
152
+	function get_substitutionarray_thirdparty($object,$outputlangs)
153
+	{
154
+		global $conf;
155
+
156
+		if (empty($object->country) && ! empty($object->country_code))
157
+		{
158
+			$object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code);
159
+		}
160
+		if (empty($object->state) && ! empty($object->state_code))
161
+		{
162
+			$object->state=getState($object->state_code,0);
163
+		}
164
+
165
+		$array_thirdparty = array(
166
+			'company_name'=>$object->name,
167
+			'company_name_alias' => $object->name_alias,
168
+			'company_email'=>$object->email,
169
+			'company_phone'=>$object->phone,
170
+			'company_fax'=>$object->fax,
171
+			'company_address'=>$object->address,
172
+			'company_zip'=>$object->zip,
173
+			'company_town'=>$object->town,
174
+			'company_country'=>$object->country,
175
+			'company_country_code'=>$object->country_code,
176
+			'company_state'=>$object->state,
177
+			'company_state_code'=>$object->state_code,
178
+			'company_web'=>$object->url,
179
+			'company_barcode'=>$object->barcode,
180
+			'company_vatnumber'=>$object->tva_intra,
181
+			'company_customercode'=>$object->code_client,
182
+			'company_suppliercode'=>$object->code_fournisseur,
183
+			'company_customeraccountancycode'=>$object->code_compta,
184
+			'company_supplieraccountancycode'=>$object->code_compta_fournisseur,
185
+			'company_juridicalstatus'=>$object->forme_juridique,
186
+			'company_outstanding_limit'=>$object->outstanding_limit,
187
+			'company_capital'=>$object->capital,
188
+			'company_idprof1'=>$object->idprof1,
189
+			'company_idprof2'=>$object->idprof2,
190
+			'company_idprof3'=>$object->idprof3,
191
+			'company_idprof4'=>$object->idprof4,
192
+			'company_idprof5'=>$object->idprof5,
193
+			'company_idprof6'=>$object->idprof6,
194
+			'company_note_public'=>$object->note_public,
195
+			'company_note_private'=>$object->note_private,
196
+			'company_default_bank_iban'=>$object->bank_account->iban,
197
+			'company_default_bank_bic'=>$object->bank_account->bic
198
+		);
199
+
200
+		// Retrieve extrafields
201
+		if(is_array($object->array_options) && count($object->array_options))
202
+		{
203
+			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
204
+			$extrafields = new ExtraFields($this->db);
205
+			$extralabels = $extrafields->fetch_name_optionals_label('societe',true);
206
+			$object->fetch_optionals();
207
+
208
+			foreach($extrafields->attribute_label as $key=>$label)
209
+			{
210
+				if($extrafields->attribute_type[$key] == 'price')
211
+				{
212
+					$object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency);
213
+				}
214
+				else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox')
215
+				{
216
+					$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
217
+				}
218
+				$array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key]));
219 219
 			}
220 220
 		}
221 221
 		return $array_thirdparty;
@@ -242,32 +242,32 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 
244 244
 		$array_contact = array (
245
-		    $array_key . '_fullname' => $object->getFullName($outputlangs, 1),
246
-            $array_key . '_lastname' => $object->lastname,
247
-            $array_key . '_firstname' => $object->firstname,
248
-            $array_key . '_address' => $object->address,
249
-            $array_key . '_zip' => $object->zip,
250
-            $array_key . '_town' => $object->town,
251
-            $array_key . '_state_id' => $object->state_id,
252
-            $array_key . '_state_code' => $object->state_code,
253
-            $array_key . '_state' => $object->state,
254
-            $array_key . '_country_id' => $object->country_id,
255
-            $array_key . '_country_code' => $object->country_code,
256
-            $array_key . '_country' => $object->country,
257
-            $array_key . '_poste' => $object->poste,
258
-            $array_key . '_socid' => $object->socid,
259
-            $array_key . '_statut' => $object->statut,
260
-            $array_key . '_code' => $object->code,
261
-            $array_key . '_email' => $object->email,
262
-            $array_key . '_jabberid' => $object->jabberid,
263
-            $array_key . '_phone_pro' => $object->phone_pro,
264
-            $array_key . '_phone_perso' => $object->phone_perso,
265
-            $array_key . '_phone_mobile' => $object->phone_mobile,
266
-            $array_key . '_fax' => $object->fax,
267
-            $array_key . '_birthday' => $object->birthday,
268
-            $array_key . '_default_lang' => $object->default_lang,
269
-            $array_key . '_note_public' => $object->note_public,
270
-            $array_key . '_note_private' => $object->note_private
245
+			$array_key . '_fullname' => $object->getFullName($outputlangs, 1),
246
+			$array_key . '_lastname' => $object->lastname,
247
+			$array_key . '_firstname' => $object->firstname,
248
+			$array_key . '_address' => $object->address,
249
+			$array_key . '_zip' => $object->zip,
250
+			$array_key . '_town' => $object->town,
251
+			$array_key . '_state_id' => $object->state_id,
252
+			$array_key . '_state_code' => $object->state_code,
253
+			$array_key . '_state' => $object->state,
254
+			$array_key . '_country_id' => $object->country_id,
255
+			$array_key . '_country_code' => $object->country_code,
256
+			$array_key . '_country' => $object->country,
257
+			$array_key . '_poste' => $object->poste,
258
+			$array_key . '_socid' => $object->socid,
259
+			$array_key . '_statut' => $object->statut,
260
+			$array_key . '_code' => $object->code,
261
+			$array_key . '_email' => $object->email,
262
+			$array_key . '_jabberid' => $object->jabberid,
263
+			$array_key . '_phone_pro' => $object->phone_pro,
264
+			$array_key . '_phone_perso' => $object->phone_perso,
265
+			$array_key . '_phone_mobile' => $object->phone_mobile,
266
+			$array_key . '_fax' => $object->fax,
267
+			$array_key . '_birthday' => $object->birthday,
268
+			$array_key . '_default_lang' => $object->default_lang,
269
+			$array_key . '_note_public' => $object->note_public,
270
+			$array_key . '_note_private' => $object->note_private
271 271
 		);
272 272
 
273 273
 		// Retrieve extrafields
@@ -292,40 +292,40 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 
295
-    /**
296
-     * Define array with couple subtitution key => subtitution value
297
-     *
298
-     * @param   Translate	$outputlangs    Language object for output
299
-     * @return	array						Array of substitution key->code
300
-     */
301
-    function get_substitutionarray_other($outputlangs)
302
-    {
303
-    	global $conf;
304
-
305
-    	$now=dol_now('gmt');	// gmt
306
-    	$array_other = array(
307
-    	    // Date in default language
308
-    	    'current_date'=>dol_print_date($now,'day','tzuser'),
309
-    	    'current_datehour'=>dol_print_date($now,'dayhour','tzuser'),
295
+	/**
296
+	 * Define array with couple subtitution key => subtitution value
297
+	 *
298
+	 * @param   Translate	$outputlangs    Language object for output
299
+	 * @return	array						Array of substitution key->code
300
+	 */
301
+	function get_substitutionarray_other($outputlangs)
302
+	{
303
+		global $conf;
304
+
305
+		$now=dol_now('gmt');	// gmt
306
+		$array_other = array(
307
+			// Date in default language
308
+			'current_date'=>dol_print_date($now,'day','tzuser'),
309
+			'current_datehour'=>dol_print_date($now,'dayhour','tzuser'),
310 310
    			'current_server_date'=>dol_print_date($now,'day','tzserver'),
311 311
    			'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'),
312
-    	    // Date in requested output language
313
-    	    'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs),
312
+			// Date in requested output language
313
+			'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs),
314 314
    			'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs),
315 315
    			'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs),
316 316
    			'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs),
317
-    	);
317
+		);
318 318
 
319 319
 
320
-    	foreach($conf->global as $key => $val)
321
-    	{
322
-    		if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****';
323
-    		else $newval = $val;
324
-    		$array_other['__['.$key.']__'] = $newval;
325
-    	}
320
+		foreach($conf->global as $key => $val)
321
+		{
322
+			if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****';
323
+			else $newval = $val;
324
+			$array_other['__['.$key.']__'] = $newval;
325
+		}
326 326
 
327
-    	return $array_other;
328
-    }
327
+		return $array_other;
328
+	}
329 329
 
330 330
 
331 331
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @param   Object			$object             Main object to use as data source
335 335
 	 * @param   Translate		$outputlangs        Lang object to use for output
336
-     * @param   string		    $array_key	        Name of the key for return array
336
+	 * @param   string		    $array_key	        Name of the key for return array
337 337
 	 * @return	array								Array of substitution
338 338
 	 */
339 339
 	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 		$array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)),
364 364
 		$array_key.'_source_invoice_ref'=>$invoice_source->ref,
365 365
 		// Dates
366
-        $array_key.'_hour'=>dol_print_date($date,'hour'),
366
+		$array_key.'_hour'=>dol_print_date($date,'hour'),
367 367
 		$array_key.'_date'=>dol_print_date($date,'day'),
368 368
 		$array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'),
369 369
 		$array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''),
370
-	    $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''),
370
+		$array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''),
371 371
 		$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
372 372
 		$array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
373 373
 		$array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''),
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 
394 394
 		$array_key.'_multicurrency_code' => price2num($object->multicurrency_code),
395 395
 		$array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx),
396
-	    $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht),
397
-	    $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva),
396
+		$array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht),
397
+		$array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva),
398 398
 		$array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc),
399 399
 		$array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs),
400 400
 		$array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs),
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 		{
449 449
 			foreach ($object->lines as $line)
450 450
 			{
451
-			    // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility
451
+				// $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility
452 452
 				if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0;
453 453
 				$resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
454 454
 				$resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]);
455
-			    // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example)
455
+				// $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example)
456 456
 				$vatformated=vatrate($line->tva_tx);
457 457
 				if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0;
458 458
 				$resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva;
@@ -502,30 +502,30 @@  discard block
 block discarded – undo
502 502
 			'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs),
503 503
 			'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs),
504 504
 			'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs),
505
-		    // Dates
505
+			// Dates
506 506
 			'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'),
507 507
 			'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs),
508
-		    'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'),
509
-		    'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'),
510
-		    'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs),
511
-		    'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'),
512
-
513
-		    'line_multicurrency_code' => price2num($line->multicurrency_code),
514
-		    'line_multicurrency_subprice' => price2num($line->multicurrency_subprice),
515
-		    'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht),
516
-		    'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva),
517
-		    'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc),
518
-		    'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs),
519
-		    'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs),
520
-		    'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs),
521
-		    'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs),
508
+			'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'),
509
+			'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'),
510
+			'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs),
511
+			'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'),
512
+
513
+			'line_multicurrency_code' => price2num($line->multicurrency_code),
514
+			'line_multicurrency_subprice' => price2num($line->multicurrency_subprice),
515
+			'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht),
516
+			'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva),
517
+			'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc),
518
+			'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs),
519
+			'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs),
520
+			'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs),
521
+			'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs),
522 522
 		);
523 523
 
524
-		    // Units
524
+			// Units
525 525
 		if ($conf->global->PRODUCT_USE_UNITS)
526 526
 		{
527
-		      $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long'));
528
-		      $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short'));
527
+			  $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long'));
528
+			  $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short'));
529 529
 		}
530 530
 
531 531
 		// Retrieve extrafields
@@ -550,54 +550,54 @@  discard block
 block discarded – undo
550 550
 		return $resarray;
551 551
 	}
552 552
 
553
-    /**
554
-     * Define array with couple substitution key => substitution value
555
-     *
556
-     * @param   Expedition			$object             Main object to use as data source
557
-     * @param   Translate		$outputlangs        Lang object to use for output
558
-     * @param   array_key		$array_key	        Name of the key for return array
559
-     * @return	array								Array of substitution
560
-     */
561
-    function get_substitutionarray_shipment($object,$outputlangs,$array_key='object')
562
-    {
563
-    	global $conf;
553
+	/**
554
+	 * Define array with couple substitution key => substitution value
555
+	 *
556
+	 * @param   Expedition			$object             Main object to use as data source
557
+	 * @param   Translate		$outputlangs        Lang object to use for output
558
+	 * @param   array_key		$array_key	        Name of the key for return array
559
+	 * @return	array								Array of substitution
560
+	 */
561
+	function get_substitutionarray_shipment($object,$outputlangs,$array_key='object')
562
+	{
563
+		global $conf;
564 564
 		dol_include_once('/core/lib/product.lib.php');
565 565
 		$object->list_delivery_methods($object->shipping_method_id);
566 566
 		$calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth);
567 567
 
568
-    	$array_shipment=array(
569
-	    	$array_key.'_id'=>$object->id,
570
-	    	$array_key.'_ref'=>$object->ref,
571
-	    	$array_key.'_ref_ext'=>$object->ref_ext,
572
-	    	$array_key.'_ref_customer'=>$object->ref_customer,
573
-	    	$array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'),
574
-	    	$array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'),
575
-	    	$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
576
-	    	$array_key.'_total_ht'=>price($object->total_ht),
577
-	    	$array_key.'_total_vat'=>price($object->total_tva),
578
-	    	$array_key.'_total_ttc'=>price($object->total_ttc),
579
-	    	$array_key.'_total_discount_ht' => price($object->getTotalDiscount()),
580
-	    	$array_key.'_note_private'=>$object->note_private,
581
-	    	$array_key.'_note'=>$object->note_public,
582
-	    	$array_key.'_tracking_number'=>$object->tracking_number,
583
-	    	$array_key.'_tracking_url'=>$object->tracking_url,
584
-	    	$array_key.'_shipping_method'=>$object->listmeths[0]['libelle'],
585
-	    	$array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'),
586
-	    	$array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'),
587
-	    	$array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'),
588
-	    	$array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'),
589
-	    	$array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'),
590
-    	);
591
-
592
-    	// Add vat by rates
593
-    	foreach ($object->lines as $line)
594
-    	{
595
-    		if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0;
596
-    		$array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
597
-    	}
568
+		$array_shipment=array(
569
+			$array_key.'_id'=>$object->id,
570
+			$array_key.'_ref'=>$object->ref,
571
+			$array_key.'_ref_ext'=>$object->ref_ext,
572
+			$array_key.'_ref_customer'=>$object->ref_customer,
573
+			$array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'),
574
+			$array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'),
575
+			$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
576
+			$array_key.'_total_ht'=>price($object->total_ht),
577
+			$array_key.'_total_vat'=>price($object->total_tva),
578
+			$array_key.'_total_ttc'=>price($object->total_ttc),
579
+			$array_key.'_total_discount_ht' => price($object->getTotalDiscount()),
580
+			$array_key.'_note_private'=>$object->note_private,
581
+			$array_key.'_note'=>$object->note_public,
582
+			$array_key.'_tracking_number'=>$object->tracking_number,
583
+			$array_key.'_tracking_url'=>$object->tracking_url,
584
+			$array_key.'_shipping_method'=>$object->listmeths[0]['libelle'],
585
+			$array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'),
586
+			$array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'),
587
+			$array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'),
588
+			$array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'),
589
+			$array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'),
590
+		);
591
+
592
+		// Add vat by rates
593
+		foreach ($object->lines as $line)
594
+		{
595
+			if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0;
596
+			$array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
597
+		}
598 598
 
599
-    	// Retrieve extrafields
600
-    	/*if(is_array($object->array_options) && count($object->array_options))
599
+		// Retrieve extrafields
600
+		/*if(is_array($object->array_options) && count($object->array_options))
601 601
     	{
602 602
     		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
603 603
     		$extrafields = new ExtraFields($this->db);
@@ -606,80 +606,80 @@  discard block
 block discarded – undo
606 606
 
607 607
     		$array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs);
608 608
     	}*/
609
-    	return $array_shipment;
610
-    }
611
-
612
-
613
-    /**
614
-     *	Define array with couple substitution key => substitution value
615
-     *
616
-     *	@param  array			$line				Array of lines
617
-     *	@param  Translate		$outputlangs        Lang object to use for output
618
-     *	@return	array								Substitution array
619
-     */
620
-    function get_substitutionarray_shipment_lines($line,$outputlangs)
621
-    {
622
-    	global $conf;
609
+		return $array_shipment;
610
+	}
611
+
612
+
613
+	/**
614
+	 *	Define array with couple substitution key => substitution value
615
+	 *
616
+	 *	@param  array			$line				Array of lines
617
+	 *	@param  Translate		$outputlangs        Lang object to use for output
618
+	 *	@return	array								Substitution array
619
+	 */
620
+	function get_substitutionarray_shipment_lines($line,$outputlangs)
621
+	{
622
+		global $conf;
623 623
 		dol_include_once('/core/lib/product.lib.php');
624 624
 
625
-    	return array(
626
-	    	'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
627
-	    	'line_product_ref'=>$line->product_ref,
628
-	    	'line_product_label'=>$line->product_label,
629
-	    	'line_desc'=>$line->desc,
630
-	    	'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
631
-	    	'line_up'=>price($line->subprice),
632
-	    	'line_qty'=>$line->qty,
633
-	    	'line_qty_shipped'=>$line->qty_shipped,
634
-	    	'line_qty_asked'=>$line->qty_asked,
635
-	    	'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
636
-	    	'line_price_ht'=>price($line->total_ht),
637
-	    	'line_price_ttc'=>price($line->total_ttc),
638
-	    	'line_price_vat'=>price($line->total_tva),
639
-	    	'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'),
640
-	    	'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'),
641
-	    	'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'),
642
-	    	'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'),
643
-    	);
644
-    }
645
-
646
-
647
-    /**
648
-     * Define array with couple subtitution key => subtitution value
649
-     *
650
-     * @param   Object		$object    		Dolibarr Object
651
-     * @param   Translate	$outputlangs    Language object for output
652
-     * @param   boolean		$recursive    	Want to fetch child array or child object
653
-     * @return	array						Array of substitution key->code
654
-     */
655
-    function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) {
656
-        $array_other = array();
657
-        if(!empty($object)) {
658
-            foreach($object as $key => $value) {
659
-                if(!empty($value)) {
660
-                    if(!is_array($value) && !is_object($value)) {
661
-                        $array_other['object_'.$key] = $value;
662
-                    }
663
-                    if(is_array($value) && $recursive){
664
-                        $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false);
665
-                    }
666
-                }
667
-            }
668
-        }
669
-        return $array_other;
670
-    }
671
-
672
-
673
-    /**
674
-     *	Fill array with couple extrafield key => extrafield value
675
-     *
676
-     *	@param  Object			$object				Object with extrafields (must have $object->array_options filled)
677
-     *	@param  array			$array_to_fill      Substitution array
678
-     *  @param  Extrafields		$extrafields        Extrafields object
679
-     *  @param  string			$array_key	        Prefix for name of the keys into returned array
680
-     *  @param  Translate		$outputlangs        Lang object to use for output
681
-     *	@return	array								Substitution array
682
-     */
625
+		return array(
626
+			'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
627
+			'line_product_ref'=>$line->product_ref,
628
+			'line_product_label'=>$line->product_label,
629
+			'line_desc'=>$line->desc,
630
+			'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
631
+			'line_up'=>price($line->subprice),
632
+			'line_qty'=>$line->qty,
633
+			'line_qty_shipped'=>$line->qty_shipped,
634
+			'line_qty_asked'=>$line->qty_asked,
635
+			'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
636
+			'line_price_ht'=>price($line->total_ht),
637
+			'line_price_ttc'=>price($line->total_ttc),
638
+			'line_price_vat'=>price($line->total_tva),
639
+			'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'),
640
+			'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'),
641
+			'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'),
642
+			'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'),
643
+		);
644
+	}
645
+
646
+
647
+	/**
648
+	 * Define array with couple subtitution key => subtitution value
649
+	 *
650
+	 * @param   Object		$object    		Dolibarr Object
651
+	 * @param   Translate	$outputlangs    Language object for output
652
+	 * @param   boolean		$recursive    	Want to fetch child array or child object
653
+	 * @return	array						Array of substitution key->code
654
+	 */
655
+	function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) {
656
+		$array_other = array();
657
+		if(!empty($object)) {
658
+			foreach($object as $key => $value) {
659
+				if(!empty($value)) {
660
+					if(!is_array($value) && !is_object($value)) {
661
+						$array_other['object_'.$key] = $value;
662
+					}
663
+					if(is_array($value) && $recursive){
664
+						$array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false);
665
+					}
666
+				}
667
+			}
668
+		}
669
+		return $array_other;
670
+	}
671
+
672
+
673
+	/**
674
+	 *	Fill array with couple extrafield key => extrafield value
675
+	 *
676
+	 *	@param  Object			$object				Object with extrafields (must have $object->array_options filled)
677
+	 *	@param  array			$array_to_fill      Substitution array
678
+	 *  @param  Extrafields		$extrafields        Extrafields object
679
+	 *  @param  string			$array_key	        Prefix for name of the keys into returned array
680
+	 *  @param  Translate		$outputlangs        Lang object to use for output
681
+	 *	@return	array								Substitution array
682
+	 */
683 683
 	function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs)
684 684
 	{
685 685
 		global $conf;
@@ -743,12 +743,12 @@  discard block
 block discarded – undo
743 743
 	 * @param	int		$hidebottom		Hide bottom
744 744
 	 * @return	void
745 745
 	 */
746
-    function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
747
-    {
748
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
749
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
750
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
751
-	    $pdf->line($x, $y+$h, $x, $y);
752
-    }
746
+	function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
747
+	{
748
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
749
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
750
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
751
+		$pdf->line($x, $y+$h, $x, $y);
752
+	}
753 753
 }
754 754
 
Please login to merge, or discard this patch.
htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
    			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
159 159
    			foreach($listoffiles as $file)
160 160
    			{
161
-                $texte.=$file['name'].'<br>';
161
+				$texte.=$file['name'].'<br>';
162 162
    			}
163 163
    			$texte.='<div id="div_'.get_class($this).'">';
164 164
 		}
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
259 259
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
260 260
 				{
261
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
262
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
261
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
262
+					if ($format == '1') $format='%Y%m%d%H%M%S';
263 263
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
264 264
 				}
265 265
 				else
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 					// On peut utiliser le nom de la societe du contact
292 292
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
293 293
 					else {
294
-			                        $socobject = $object->thirdparty;
295
-                        			// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
296
-                        			$contactobject = $object->contact;
297
-                    			}
294
+									$socobject = $object->thirdparty;
295
+									// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
296
+									$contactobject = $object->contact;
297
+								}
298 298
 				}
299 299
 				else
300 300
 				{
Please login to merge, or discard this patch.
htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param   Project			$object             Main object to use as data source
110 110
 	 * @param   Translate		$outputlangs        Lang object to use for output
111
-     * @param   string		    $array_key	        Name of the key for return array
111
+	 * @param   string		    $array_key	        Name of the key for return array
112 112
 	 * @return	array								Array of substitution
113 113
 	 */
114 114
 	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		global $conf;
117 117
 
118 118
 		$resarray=array(
119
-		    $array_key.'_id'=>$object->id,
120
-            $array_key.'_ref'=>$object->ref,
121
-            $array_key.'_title'=>$object->title,
122
-            $array_key.'_description'=>$object->description,
123
-            $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
124
-            $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
125
-            $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
126
-            $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
127
-            $array_key.'_note_private'=>$object->note_private,
128
-            $array_key.'_note_public'=>$object->note_public,
129
-            $array_key.'_public'=>$object->public,
130
-            $array_key.'_statut'=>$object->getLibStatut()
119
+			$array_key.'_id'=>$object->id,
120
+			$array_key.'_ref'=>$object->ref,
121
+			$array_key.'_title'=>$object->title,
122
+			$array_key.'_description'=>$object->description,
123
+			$array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
124
+			$array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
125
+			$array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
126
+			$array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
127
+			$array_key.'_note_private'=>$object->note_private,
128
+			$array_key.'_note_public'=>$object->note_public,
129
+			$array_key.'_public'=>$object->public,
130
+			$array_key.'_statut'=>$object->getLibStatut()
131 131
 		);
132 132
 
133 133
 		// Retrieve extrafields
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
    			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
405 405
    			foreach($listoffiles as $file)
406 406
    			{
407
-                $texte.=$file['name'].'<br>';
407
+				$texte.=$file['name'].'<br>';
408 408
    			}
409 409
    			$texte.='<div id="div_'.get_class($this).'">';
410 410
 		}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
501 501
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
502 502
 				{
503
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
504
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
503
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
504
+					if ($format == '1') $format='%Y%m%d%H%M%S';
505 505
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
506 506
 				}
507 507
 				else
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 				// Recipient name
529 529
 				if (! empty($usecontact))
530 530
 				{
531
-        			// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
532
-        			$contactobject = $object->contact;
531
+					// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
532
+					$contactobject = $object->contact;
533 533
 				}
534 534
 
535 535
 				$socobject=$object->thirdparty;
Please login to merge, or discard this patch.
htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
153 153
 		$texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
154 154
 		$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
155
-        $texte.= '</div>';
155
+		$texte.= '</div>';
156 156
 
157 157
 		$texte.= '</td>';
158 158
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
250 250
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
251 251
 				{
252
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
253
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
252
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
253
+					if ($format == '1') $format='%Y%m%d%H%M%S';
254 254
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
255 255
 				}
256 256
 				else
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
 					// On peut utiliser le nom de la societe du contact
282 282
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
283 283
 					else {
284
-                        			$socobject = $object->thirdparty;
285
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
286
-                        			$contactobject = $object->contact;
287
-                    			}
284
+									$socobject = $object->thirdparty;
285
+									// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
286
+									$contactobject = $object->contact;
287
+								}
288 288
 				}
289 289
 				else
290 290
 				{
Please login to merge, or discard this patch.
htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
    			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
160 160
    			foreach($listoffiles as $file)
161 161
    			{
162
-                $texte.=$file['name'].'<br>';
162
+				$texte.=$file['name'].'<br>';
163 163
    			}
164 164
    			$texte.='<div id="div_'.get_class($this).'">';
165 165
 		}
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
259 259
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
260 260
 				{
261
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
262
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
261
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
262
+					if ($format == '1') $format='%Y%m%d%H%M%S';
263 263
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
264 264
 				}
265 265
 				else
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 					// On peut utiliser le nom de la societe du contact
291 291
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
292 292
 					else {
293
-                        $socobject = $object->thirdparty;
294
-               			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
295
-            			$contactobject = $object->contact;
296
-                    }
293
+						$socobject = $object->thirdparty;
294
+			   			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
295
+						$contactobject = $object->contact;
296
+					}
297 297
 				}
298 298
 				else
299 299
 				{
Please login to merge, or discard this patch.
htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
165 165
    			foreach($listoffiles as $file)
166 166
    			{
167
-                $texte.=$file['name'].'<br>';
167
+				$texte.=$file['name'].'<br>';
168 168
    			}
169 169
    			$texte.='<div id="div_'.get_class($this).'">';
170 170
 
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
290 290
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
291 291
 				{
292
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
293
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
292
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
293
+					if ($format == '1') $format='%Y%m%d%H%M%S';
294 294
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
295 295
 				}
296 296
 				else
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 					// On peut utiliser le nom de la societe du contact
322 322
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
323 323
 					else {
324
-                        			$socobject = $object->thirdparty;
325
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
326
-                        			$contactobject = $object->contact;
327
-                    			}
324
+									$socobject = $object->thirdparty;
325
+									// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
326
+									$contactobject = $object->contact;
327
+								}
328 328
 				}
329 329
 				else
330 330
 				{
Please login to merge, or discard this patch.
htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
276 276
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
277 277
 				{
278
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
279
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
278
+					$format=$conf->global->MAIN_DOC_USE_TIMING;
279
+					if ($format == '1') $format='%Y%m%d%H%M%S';
280 280
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
281 281
 				}
282 282
 				else
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 					// On peut utiliser le nom de la societe du contact
308 308
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
309 309
 					else {
310
-                        			$socobject = $object->thirdparty;
311
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
312
-                        			$contactobject = $object->contact;
313
-                    			}
310
+									$socobject = $object->thirdparty;
311
+									// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
312
+									$contactobject = $object->contact;
313
+								}
314 314
 				}
315 315
 				else
316 316
 				{
Please login to merge, or discard this patch.
htdocs/install/step1.php 1 patch
Indentation   +696 added lines, -696 removed lines patch added patch discarded remove patch
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 // Test if we can run a first install process
146 146
 if (! is_writable($conffile))
147 147
 {
148
-    print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
149
-    pFooter(1,$setuplang,'jscheckparam');
150
-    exit;
148
+	print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
149
+	pFooter(1,$setuplang,'jscheckparam');
150
+	exit;
151 151
 }
152 152
 
153 153
 
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
 $is_sqlite = false;
156 156
 if (empty($db_type))
157 157
 {
158
-    print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
159
-    $error++;
158
+	print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
159
+	$error++;
160 160
 } else {
161 161
 	$is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3' );
162 162
 }
163 163
 if (empty($db_host) && ! $is_sqlite)
164 164
 {
165
-    print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
166
-    $error++;
165
+	print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
166
+	$error++;
167 167
 }
168 168
 if (empty($db_name))
169 169
 {
170
-    print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
171
-    $error++;
170
+	print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
171
+	$error++;
172 172
 }
173 173
 if (empty($db_user)  && ! $is_sqlite)
174 174
 {
175
-    print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>';
176
-    $error++;
175
+	print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>';
176
+	$error++;
177 177
 }
178 178
 if (! empty($db_port) && ! is_numeric($db_port))
179 179
 {
180
-    print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$db_port,$langs->transnoentities("Port")).'</div>';
181
-    $error++;
180
+	print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$db_port,$langs->transnoentities("Port")).'</div>';
181
+	$error++;
182 182
 }
183 183
 if (! empty($db_prefix) && ! preg_match('/^[a-z0-9]+_$/i', $db_prefix))
184 184
 {
@@ -190,596 +190,596 @@  discard block
 block discarded – undo
190 190
 // Remove last / into dans main_dir
191 191
 if (substr($main_dir, dol_strlen($main_dir) -1) == "/")
192 192
 {
193
-    $main_dir = substr($main_dir, 0, dol_strlen($main_dir)-1);
193
+	$main_dir = substr($main_dir, 0, dol_strlen($main_dir)-1);
194 194
 }
195 195
 
196 196
 // Remove last / into dans main_url
197 197
 if (! empty($main_url) && substr($main_url, dol_strlen($main_url) -1) == "/")
198 198
 {
199
-    $main_url = substr($main_url, 0, dol_strlen($main_url)-1);
199
+	$main_url = substr($main_url, 0, dol_strlen($main_url)-1);
200 200
 }
201 201
 
202 202
 // Test database connection
203 203
 if (! $error) {
204
-    $result=@include_once $main_dir."/core/db/".$db_type.'.class.php';
205
-    if ($result)
206
-    {
207
-        // If we ask database or user creation we need to connect as root, so we need root login
208
-        if (!empty($db_create_database) && !$userroot) {
209
-            print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$db_name).'</div>';
210
-            print '<br>';
211
-            print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
212
-            print $langs->trans("ErrorGoBackAndCorrectParameters");
213
-            $error++;
214
-        }
215
-        if (!empty($db_create_user) && !$userroot) {
216
-            print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$db_user).'</div>';
217
-            print '<br>';
218
-            print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
219
-            print $langs->trans("ErrorGoBackAndCorrectParameters");
220
-            $error++;
221
-        }
222
-
223
-        // If we need root access
224
-        if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
225
-            $databasefortest=$db_name;
226
-            if (!empty($db_create_database)) {
227
-                if ($db_type == 'mysql' || $db_type == 'mysqli')
228
-                {
229
-                    $databasefortest='mysql';
230
-                }
231
-                elseif ($db_type == 'pgsql')
232
-                {
233
-                    $databasefortest='postgres';
234
-                }
235
-                else
236
-                {
237
-                    $databasefortest='master';
238
-                }
239
-            }
240
-            //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
241
-
242
-            $db=getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
243
-
244
-            dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG);
245
-            //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
204
+	$result=@include_once $main_dir."/core/db/".$db_type.'.class.php';
205
+	if ($result)
206
+	{
207
+		// If we ask database or user creation we need to connect as root, so we need root login
208
+		if (!empty($db_create_database) && !$userroot) {
209
+			print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$db_name).'</div>';
210
+			print '<br>';
211
+			print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
212
+			print $langs->trans("ErrorGoBackAndCorrectParameters");
213
+			$error++;
214
+		}
215
+		if (!empty($db_create_user) && !$userroot) {
216
+			print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$db_user).'</div>';
217
+			print '<br>';
218
+			print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
219
+			print $langs->trans("ErrorGoBackAndCorrectParameters");
220
+			$error++;
221
+		}
222
+
223
+		// If we need root access
224
+		if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
225
+			$databasefortest=$db_name;
226
+			if (!empty($db_create_database)) {
227
+				if ($db_type == 'mysql' || $db_type == 'mysqli')
228
+				{
229
+					$databasefortest='mysql';
230
+				}
231
+				elseif ($db_type == 'pgsql')
232
+				{
233
+					$databasefortest='postgres';
234
+				}
235
+				else
236
+				{
237
+					$databasefortest='master';
238
+				}
239
+			}
240
+			//print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
241
+
242
+			$db=getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
243
+
244
+			dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG);
245
+			//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
246 246
 
247 247
 			if (empty($db_create_database) && $db->connected && !$db->database_selected) {
248
-                print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>';
249
-                print '<br>';
250
-                if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
251
-                print $langs->trans("ErrorGoBackAndCorrectParameters");
252
-                $error++;
253
-            } elseif ($db->error && ! (! empty($db_create_database) && $db->connected)) {
254
-            	// Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
255
-                if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
256
-                else print '<div class="error">'.$db->error.'</div>';
257
-                if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
258
-                //print '<a href="#" onClick="javascript: history.back();">';
259
-                print $langs->trans("ErrorGoBackAndCorrectParameters");
260
-                //print '</a>';
261
-                $error++;
262
-            }
263
-        }
264
-        // If we need simple access
265
-        if (!$error && (empty($db_create_database) && empty($db_create_user))) {
266
-            $db=getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
267
-
268
-            if ($db->error)
269
-            {
270
-                print '<div class="error">'.$db->error.'</div>';
271
-                if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
272
-                //print '<a href="#" onClick="javascript: history.back();">';
273
-                print $langs->trans("ErrorGoBackAndCorrectParameters");
274
-                //print '</a>';
275
-                $error++;
276
-            }
277
-        }
278
-    }
279
-    else
280
-    {
281
-        print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$db_type.".class.php\")<br>\n";
282
-        print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
283
-        //print '<a href="#" onClick="javascript: history.back();">';
284
-        print $langs->trans("ErrorGoBackAndCorrectParameters");
285
-        //print '</a>';
286
-        $error++;
287
-    }
248
+				print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>';
249
+				print '<br>';
250
+				if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
251
+				print $langs->trans("ErrorGoBackAndCorrectParameters");
252
+				$error++;
253
+			} elseif ($db->error && ! (! empty($db_create_database) && $db->connected)) {
254
+				// Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
255
+				if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
256
+				else print '<div class="error">'.$db->error.'</div>';
257
+				if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
258
+				//print '<a href="#" onClick="javascript: history.back();">';
259
+				print $langs->trans("ErrorGoBackAndCorrectParameters");
260
+				//print '</a>';
261
+				$error++;
262
+			}
263
+		}
264
+		// If we need simple access
265
+		if (!$error && (empty($db_create_database) && empty($db_create_user))) {
266
+			$db=getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
267
+
268
+			if ($db->error)
269
+			{
270
+				print '<div class="error">'.$db->error.'</div>';
271
+				if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
272
+				//print '<a href="#" onClick="javascript: history.back();">';
273
+				print $langs->trans("ErrorGoBackAndCorrectParameters");
274
+				//print '</a>';
275
+				$error++;
276
+			}
277
+		}
278
+	}
279
+	else
280
+	{
281
+		print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$db_type.".class.php\")<br>\n";
282
+		print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
283
+		//print '<a href="#" onClick="javascript: history.back();">';
284
+		print $langs->trans("ErrorGoBackAndCorrectParameters");
285
+		//print '</a>';
286
+		$error++;
287
+	}
288 288
 }
289 289
 
290 290
 else
291 291
 {
292
-    if (isset($db)) print $db->lasterror();
293
-    if (isset($db) && ! $db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
294
-    print $langs->trans("ErrorGoBackAndCorrectParameters");
295
-    $error++;
292
+	if (isset($db)) print $db->lasterror();
293
+	if (isset($db) && ! $db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
294
+	print $langs->trans("ErrorGoBackAndCorrectParameters");
295
+	$error++;
296 296
 }
297 297
 
298 298
 if (! $error && $db->connected)
299 299
 {
300
-    if (! empty($db_create_database)) {
301
-        $result=$db->select_db($db_name);
302
-        if ($result)
303
-        {
304
-            print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
305
-            print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
306
-            print $langs->trans("ErrorGoBackAndCorrectParameters");
307
-            $error++;
308
-        }
309
-    }
300
+	if (! empty($db_create_database)) {
301
+		$result=$db->select_db($db_name);
302
+		if ($result)
303
+		{
304
+			print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
305
+			print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
306
+			print $langs->trans("ErrorGoBackAndCorrectParameters");
307
+			$error++;
308
+		}
309
+	}
310 310
 }
311 311
 
312 312
 // Define $defaultCharacterSet and $defaultDBSortingCollation
313 313
 if (! $error && $db->connected)
314 314
 {
315
-    if (!empty($db_create_database))    // If we create database, we force default value
316
-    {
317
-        // Default values come from the database handler
318
-
319
-        $defaultCharacterSet=$db->forcecharset;
320
-    	$defaultDBSortingCollation=$db->forcecollate;
321
-    }
322
-    else	// If already created, we take current value
323
-    {
324
-        $defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
325
-        $defaultDBSortingCollation=$db->getDefaultCollationDatabase();
326
-    }
327
-
328
-    // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
329
-    // TODO Remove this when utf8mb4 is supported
330
-    if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci')
331
-    {
332
-        $defaultCharacterSet = 'utf8';
333
-        $defaultDBSortingCollation = 'utf8_unicode_ci';
334
-    }
335
-
336
-    print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
337
-    print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
338
-    $db_character_set=$defaultCharacterSet;
339
-    $db_collation=$defaultDBSortingCollation;
340
-    dolibarr_install_syslog("step1: db_character_set=" . $db_character_set . " db_collation=" . $db_collation);
315
+	if (!empty($db_create_database))    // If we create database, we force default value
316
+	{
317
+		// Default values come from the database handler
318
+
319
+		$defaultCharacterSet=$db->forcecharset;
320
+		$defaultDBSortingCollation=$db->forcecollate;
321
+	}
322
+	else	// If already created, we take current value
323
+	{
324
+		$defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
325
+		$defaultDBSortingCollation=$db->getDefaultCollationDatabase();
326
+	}
327
+
328
+	// Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
329
+	// TODO Remove this when utf8mb4 is supported
330
+	if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci')
331
+	{
332
+		$defaultCharacterSet = 'utf8';
333
+		$defaultDBSortingCollation = 'utf8_unicode_ci';
334
+	}
335
+
336
+	print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
337
+	print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
338
+	$db_character_set=$defaultCharacterSet;
339
+	$db_collation=$defaultDBSortingCollation;
340
+	dolibarr_install_syslog("step1: db_character_set=" . $db_character_set . " db_collation=" . $db_collation);
341 341
 }
342 342
 
343 343
 
344 344
 // Create config file
345 345
 if (! $error && $db->connected && $action == "set")
346 346
 {
347
-    umask(0);
348
-    if (is_array($_POST))
349
-    {
350
-        foreach($_POST as $key => $value)
351
-        {
352
-            if (! preg_match('/^db_pass/i', $key)) {
353
-    			dolibarr_install_syslog("step1: choice for " . $key . " = " . $value);
354
-    		}
355
-        }
356
-    }
357
-
358
-    // Show title of step
359
-    print '<h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans("ConfigurationFile").'</h3>';
360
-    print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
361
-
362
-    // Check parameter main_dir
363
-    if (! $error)
364
-    {
365
-        if (! is_dir($main_dir))
366
-        {
367
-            dolibarr_install_syslog("step1: directory '" . $main_dir . "' is unavailable or can't be accessed");
368
-
369
-            print "<tr><td>";
370
-            print $langs->trans("ErrorDirDoesNotExists",$main_dir).'<br>';
371
-            print $langs->trans("ErrorWrongValueForParameter",$langs->trans("WebPagesDirectory")).'<br>';
372
-            print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
373
-            print '</td><td>';
374
-            print $langs->trans("Error");
375
-            print "</td></tr>";
376
-            $error++;
377
-        }
378
-    }
379
-
380
-    if (! $error)
381
-    {
382
-        dolibarr_install_syslog("step1: directory '" . $main_dir . "' exists");
383
-    }
384
-
385
-
386
-    // Create subdirectory main_data_dir
387
-    if (! $error)
388
-    {
389
-        // Create directory for documents
390
-        if (! is_dir($main_data_dir))
391
-        {
392
-            dol_mkdir($main_data_dir);
393
-        }
394
-
395
-        if (! is_dir($main_data_dir))
396
-        {
397
-            print "<tr><td>".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
398
-            print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
399
-            print '</td><td>';
400
-            print '<font class="error">'.$langs->trans("Error").'</font>';
401
-            print "</td></tr>";
402
-            print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
403
-            $error++;
404
-        }
405
-        else
406
-        {
407
-            // Create .htaccess file in document directory
408
-            $pathhtaccess=$main_data_dir.'/.htaccess';
409
-            if (! file_exists($pathhtaccess))
410
-            {
411
-                dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '" . $main_data_dir . "'");
412
-                $handlehtaccess=@fopen($pathhtaccess,'w');
413
-                if ($handlehtaccess)
414
-                {
415
-                    fwrite($handlehtaccess,'Order allow,deny'."\n");
416
-                    fwrite($handlehtaccess,'Deny from all'."\n");
417
-
418
-                    fclose($handlehtaccess);
419
-                    dolibarr_install_syslog("step1: .htaccess file created");
420
-                }
421
-            }
422
-
423
-            // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification
424
-            $dir=array();
425
-            $dir[] = $main_data_dir."/mycompany";
426
-            $dir[] = $main_data_dir."/medias";
427
-            $dir[] = $main_data_dir."/users";
428
-            $dir[] = $main_data_dir."/facture";
429
-            $dir[] = $main_data_dir."/propale";
430
-            $dir[] = $main_data_dir."/ficheinter";
431
-            $dir[] = $main_data_dir."/produit";
432
-            $dir[] = $main_data_dir."/doctemplates";
433
-
434
-            // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
435
-            $num=count($dir);
436
-            for ($i = 0; $i < $num; $i++)
437
-            {
438
-                if (is_dir($dir[$i]))
439
-                {
440
-                    dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' exists");
441
-                }
442
-                else
443
-                {
444
-                    if (dol_mkdir($dir[$i]) < 0)
445
-                    {
446
-                        print "<tr><td>";
447
-                        print "Failed to create directory: ".$dir[$i];
448
-                        print '</td><td>';
449
-                        print $langs->trans("Error");
450
-                        print "</td></tr>";
451
-                        $error++;
452
-                    }
453
-                    else
454
-                    {
455
-                        dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' created");
456
-                    }
457
-                }
458
-            }
459
-
460
-            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
461
-
462
-            // Copy directory medias
463
-            $srcroot=$main_dir.'/install/medias';
464
-            $destroot=$main_data_dir.'/medias';
465
-            dolCopyDir($srcroot, $destroot, 0, 0);
466
-
467
-            if ($error)
468
-            {
469
-                print "<tr><td>".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
470
-                print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
471
-                print '</td><td>';
472
-                print '<font class="error">'.$langs->trans("Error").'</font>';
473
-                print "</td></tr>";
474
-                print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
475
-            }
476
-            else
477
-            {
478
-            	//ODT templates
479
-            	$srcroot=$main_dir.'/install/doctemplates';
480
-            	$destroot=$main_data_dir.'/doctemplates';
481
-            	$docs=array(
482
-            		'contracts' => 'contract',
483
-            		'invoices' => 'invoice',
484
-            		'orders' => 'order',
485
-            		'products' => 'product',
486
-            		'projects' => 'project',
487
-            		'proposals' => 'proposal',
488
-            		'shipment' => 'shipment',
489
-            		'supplier_proposal' => 'supplier_proposal',
490
-            		'tasks' => 'task_summary',
491
-            		'thirdparties' => 'thirdparty',
492
-            		'usergroups' => 'usergroups',
493
-            		'users' => 'user',
494
-            		'usergroups' => 'usergroups',
495
-            	);
496
-            	foreach($docs as $cursordir => $cursorfile)
497
-            	{
498
-            		$src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
499
-            		$dirodt=$destroot.'/'.$cursordir;
500
-            		$dest=$dirodt.'/template_'.$cursorfile.'.odt';
501
-
502
-            		dol_mkdir($dirodt);
503
-            		$result=dol_copy($src,$dest,0,0);
504
-            		if ($result < 0)
505
-            		{
506
-            			print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile',$src,$dest).'</td></tr>';
507
-            		}
508
-            	}
509
-            }
510
-        }
511
-    }
512
-
513
-    // Table prefix
514
-    $main_db_prefix = (! empty($db_prefix) ? $db_prefix : 'llx_');
515
-
516
-    // Write conf file on disk
517
-    if (! $error)
518
-    {
519
-        // Save old conf file on disk
520
-        if (file_exists("$conffile"))
521
-        {
522
-            // We must ignore errors as an existing old file may already exists and not be replacable or
523
-            // the installer (like for ubuntu) may not have permission to create another file than conf.php.
524
-            // Also no other process must be able to read file or we expose the new file, so content with password.
525
-            @dol_copy($conffile, $conffile.'.old', '0400');
526
-        }
527
-
528
-        $error+=write_conf_file($conffile);
529
-    }
530
-
531
-    // Create database and admin user database
532
-    if (! $error)
533
-    {
534
-        // We reload configuration file
535
-        conf($dolibarr_main_document_root);
536
-
537
-        print '<tr><td>';
538
-        print $langs->trans("ConfFileReload");
539
-        print '</td>';
540
-        print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
541
-
542
-        // Si creation utilisateur admin demandee, on le cree
543
-        if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) {
544
-            dolibarr_install_syslog("step1: create database user: " . $dolibarr_main_db_user);
545
-
546
-            //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
547
-            $databasefortest=$conf->db->name;
548
-            if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
549
-            {
550
-                $databasefortest='mysql';
551
-            }
552
-            else if ($conf->db->type == 'pgsql')
553
-            {
554
-                $databasefortest='postgres';
555
-            }
556
-            else if ($conf->db->type == 'mssql')
557
-            {
558
-                $databasefortest='master';
559
-            }
560
-
561
-            // Creation handler de base, verification du support et connexion
562
-
563
-            $db=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest,$conf->db->port);
564
-
565
-            if ($db->error)
566
-            {
567
-                print '<div class="error">'.$db->error.'</div>';
568
-                $error++;
569
-            }
570
-
571
-            if (! $error)
572
-            {
573
-                if ($db->connected)
574
-                {
575
-                    $resultbis = 1;
576
-
577
-                    // Create user
578
-                    $result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
579
-                    // Create user bis
580
-                    if ($databasefortest == 'mysql')
581
-                    {
582
-                        if (! in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local')))
583
-                        {
584
-                            $resultbis=$db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
585
-                        }
586
-                    }
587
-
588
-                    if ($result > 0 && $resultbis > 0)
589
-                    {
590
-
591
-                        print '<tr><td>';
592
-                        print $langs->trans("UserCreation").' : ';
593
-                        print $dolibarr_main_db_user;
594
-                        print '</td>';
595
-                        print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
596
-                    }
597
-                    else
598
-                    {
599
-                        if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
600
-                        || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
601
-                        || $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS')
602
-                        {
603
-                            dolibarr_install_syslog("step1: user already exists");
604
-                            print '<tr><td>';
605
-                            print $langs->trans("UserCreation").' : ';
606
-                            print $dolibarr_main_db_user;
607
-                            print '</td>';
608
-                            print '<td>'.$langs->trans("LoginAlreadyExists").'</td></tr>';
609
-                        }
610
-                        else
611
-                        {
612
-                            dolibarr_install_syslog("step1: failed to create user", LOG_ERR);
613
-                            print '<tr><td>';
614
-                            print $langs->trans("UserCreation").' : ';
615
-                            print $dolibarr_main_db_user;
616
-                            print '</td>';
617
-                            print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error()."</td></tr>";
618
-                        }
619
-                    }
620
-
621
-                    $db->close();
622
-                }
623
-                else
624
-                {
625
-                    print '<tr><td>';
626
-                    print $langs->trans("UserCreation").' : ';
627
-                    print $dolibarr_main_db_user;
628
-                    print '</td>';
629
-                    print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
630
-                    print '</tr>';
631
-
632
-                    // Affiche aide diagnostique
633
-                    print '<tr><td colspan="2"><br>';
634
-                    print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
635
-                    print '<br>';
636
-                    print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
637
-                    print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
638
-                    print '</td></tr>';
639
-
640
-                    $error++;
641
-                }
642
-            }
643
-        }   // Fin si "creation utilisateur"
644
-
645
-
646
-        // If database creation is asked, we create it
647
-        if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) {
648
-            dolibarr_install_syslog("step1: create database: " . $dolibarr_main_db_name . " " . $dolibarr_main_db_character_set . " " . $dolibarr_main_db_collation . " " . $dolibarr_main_db_user);
649
-        	$newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port);
650
-            //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
651
-
652
-            if ($newdb->connected)
653
-            {
654
-                $result=$newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
655
-
656
-                if ($result)
657
-                {
658
-                    print '<tr><td>';
659
-                    print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
660
-                    print $dolibarr_main_db_name;
661
-                    print '</td>';
662
-                    print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
663
-
664
-                    $newdb->select_db($dolibarr_main_db_name);
665
-                    $check1=$newdb->getDefaultCharacterSetDatabase();
666
-                    $check2=$newdb->getDefaultCollationDatabase();
667
-                    dolibarr_install_syslog('step1: new database is using charset=' . $check1 . ' collation=' . $check2);
668
-
669
-                    // If values differs, we save conf file again
670
-                    //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING);
671
-                    //if ($check2 != $dolibarr_main_db_collation)     dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING);
672
-                }
673
-                else
674
-                {
675
-                    // Affiche aide diagnostique
676
-                    print '<tr><td colspan="2"><br>';
677
-                    print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).'<br>';
678
-                    print $newdb->lasterror().'<br>';
679
-                    print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
680
-                    print '<br>';
681
-                    print '</td></tr>';
682
-
683
-                    dolibarr_install_syslog('step1: failed to create database ' . $dolibarr_main_db_name . ' ' . $newdb->lasterrno() . ' ' . $newdb->lasterror(), LOG_ERR);
684
-                    $error++;
685
-                }
686
-                $newdb->close();
687
-            }
688
-            else {
689
-                print '<tr><td>';
690
-                print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
691
-                print $dolibarr_main_db_name;
692
-                print '</td>';
693
-                print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
694
-                print '</tr>';
695
-
696
-                // Affiche aide diagnostique
697
-                print '<tr><td colspan="2"><br>';
698
-                print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
699
-                print '<br>';
700
-                print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
701
-                print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
702
-                print '</td></tr>';
703
-
704
-                $error++;
705
-            }
706
-        }   // Fin si "creation database"
707
-
708
-
709
-        // We test access with dolibarr database user (not admin)
710
-        if (! $error)
711
-        {
712
-            dolibarr_install_syslog("step1: connection type=" . $conf->db->type . " on host=" . $conf->db->host . " port=" . $conf->db->port . " user=" . $conf->db->user . " name=" . $conf->db->name);
713
-            //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
714
-
715
-            $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
716
-
717
-            if ($db->connected)
718
-            {
719
-                dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " ok");
720
-                print "<tr><td>";
721
-                print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
722
-                print $dolibarr_main_db_host;
723
-                print "</td><td>";
724
-                print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
725
-                print "</td></tr>";
726
-
727
-                // si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root.
728
-                if ($db->database_selected)
729
-                {
730
-                    dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " ok");
731
-                    print "<tr><td>";
732
-                    print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
733
-                    print $dolibarr_main_db_name;
734
-                    print "</td><td>";
735
-                    print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
736
-                    print "</td></tr>";
737
-
738
-                    $error = 0;
739
-                }
740
-                else
741
-                {
742
-                    dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " failed", LOG_ERR);
743
-                    print "<tr><td>";
744
-                    print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
745
-                    print $dolibarr_main_db_name;
746
-                    print '</td><td>';
747
-                    print '<img src="../theme/eldy/img/error.png" alt="Error">';
748
-                    print "</td></tr>";
749
-
750
-                    // Affiche aide diagnostique
751
-                    print '<tr><td colspan="2"><br>';
752
-                    print $langs->trans('CheckThatDatabasenameIsCorrect',$dolibarr_main_db_name).'<br>';
753
-                    print $langs->trans('IfAlreadyExistsCheckOption').'<br>';
754
-                    print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
755
-                    print '</td></tr>';
756
-
757
-                    $error++;
758
-                }
759
-            }
760
-            else
761
-            {
762
-                dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " failed", LOG_ERR);
763
-                print "<tr><td>";
764
-                print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
765
-                print $dolibarr_main_db_host;
766
-                print '</td><td>';
767
-                print '<img src="../theme/eldy/img/error.png" alt="Error">';
768
-                print "</td></tr>";
769
-
770
-                // Affiche aide diagnostique
771
-                print '<tr><td colspan="2"><br>';
772
-                print $langs->trans("ErrorConnection",$conf->db->host,$conf->db->name,$conf->db->user);
773
-                print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').'<br>';
774
-                print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
775
-                print '</td></tr>';
776
-
777
-                $error++;
778
-            }
779
-        }
780
-    }
781
-
782
-    print '</table>';
347
+	umask(0);
348
+	if (is_array($_POST))
349
+	{
350
+		foreach($_POST as $key => $value)
351
+		{
352
+			if (! preg_match('/^db_pass/i', $key)) {
353
+				dolibarr_install_syslog("step1: choice for " . $key . " = " . $value);
354
+			}
355
+		}
356
+	}
357
+
358
+	// Show title of step
359
+	print '<h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans("ConfigurationFile").'</h3>';
360
+	print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
361
+
362
+	// Check parameter main_dir
363
+	if (! $error)
364
+	{
365
+		if (! is_dir($main_dir))
366
+		{
367
+			dolibarr_install_syslog("step1: directory '" . $main_dir . "' is unavailable or can't be accessed");
368
+
369
+			print "<tr><td>";
370
+			print $langs->trans("ErrorDirDoesNotExists",$main_dir).'<br>';
371
+			print $langs->trans("ErrorWrongValueForParameter",$langs->trans("WebPagesDirectory")).'<br>';
372
+			print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
373
+			print '</td><td>';
374
+			print $langs->trans("Error");
375
+			print "</td></tr>";
376
+			$error++;
377
+		}
378
+	}
379
+
380
+	if (! $error)
381
+	{
382
+		dolibarr_install_syslog("step1: directory '" . $main_dir . "' exists");
383
+	}
384
+
385
+
386
+	// Create subdirectory main_data_dir
387
+	if (! $error)
388
+	{
389
+		// Create directory for documents
390
+		if (! is_dir($main_data_dir))
391
+		{
392
+			dol_mkdir($main_data_dir);
393
+		}
394
+
395
+		if (! is_dir($main_data_dir))
396
+		{
397
+			print "<tr><td>".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
398
+			print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
399
+			print '</td><td>';
400
+			print '<font class="error">'.$langs->trans("Error").'</font>';
401
+			print "</td></tr>";
402
+			print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
403
+			$error++;
404
+		}
405
+		else
406
+		{
407
+			// Create .htaccess file in document directory
408
+			$pathhtaccess=$main_data_dir.'/.htaccess';
409
+			if (! file_exists($pathhtaccess))
410
+			{
411
+				dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '" . $main_data_dir . "'");
412
+				$handlehtaccess=@fopen($pathhtaccess,'w');
413
+				if ($handlehtaccess)
414
+				{
415
+					fwrite($handlehtaccess,'Order allow,deny'."\n");
416
+					fwrite($handlehtaccess,'Deny from all'."\n");
417
+
418
+					fclose($handlehtaccess);
419
+					dolibarr_install_syslog("step1: .htaccess file created");
420
+				}
421
+			}
422
+
423
+			// Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification
424
+			$dir=array();
425
+			$dir[] = $main_data_dir."/mycompany";
426
+			$dir[] = $main_data_dir."/medias";
427
+			$dir[] = $main_data_dir."/users";
428
+			$dir[] = $main_data_dir."/facture";
429
+			$dir[] = $main_data_dir."/propale";
430
+			$dir[] = $main_data_dir."/ficheinter";
431
+			$dir[] = $main_data_dir."/produit";
432
+			$dir[] = $main_data_dir."/doctemplates";
433
+
434
+			// Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
435
+			$num=count($dir);
436
+			for ($i = 0; $i < $num; $i++)
437
+			{
438
+				if (is_dir($dir[$i]))
439
+				{
440
+					dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' exists");
441
+				}
442
+				else
443
+				{
444
+					if (dol_mkdir($dir[$i]) < 0)
445
+					{
446
+						print "<tr><td>";
447
+						print "Failed to create directory: ".$dir[$i];
448
+						print '</td><td>';
449
+						print $langs->trans("Error");
450
+						print "</td></tr>";
451
+						$error++;
452
+					}
453
+					else
454
+					{
455
+						dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' created");
456
+					}
457
+				}
458
+			}
459
+
460
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
461
+
462
+			// Copy directory medias
463
+			$srcroot=$main_dir.'/install/medias';
464
+			$destroot=$main_data_dir.'/medias';
465
+			dolCopyDir($srcroot, $destroot, 0, 0);
466
+
467
+			if ($error)
468
+			{
469
+				print "<tr><td>".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
470
+				print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
471
+				print '</td><td>';
472
+				print '<font class="error">'.$langs->trans("Error").'</font>';
473
+				print "</td></tr>";
474
+				print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
475
+			}
476
+			else
477
+			{
478
+				//ODT templates
479
+				$srcroot=$main_dir.'/install/doctemplates';
480
+				$destroot=$main_data_dir.'/doctemplates';
481
+				$docs=array(
482
+					'contracts' => 'contract',
483
+					'invoices' => 'invoice',
484
+					'orders' => 'order',
485
+					'products' => 'product',
486
+					'projects' => 'project',
487
+					'proposals' => 'proposal',
488
+					'shipment' => 'shipment',
489
+					'supplier_proposal' => 'supplier_proposal',
490
+					'tasks' => 'task_summary',
491
+					'thirdparties' => 'thirdparty',
492
+					'usergroups' => 'usergroups',
493
+					'users' => 'user',
494
+					'usergroups' => 'usergroups',
495
+				);
496
+				foreach($docs as $cursordir => $cursorfile)
497
+				{
498
+					$src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
499
+					$dirodt=$destroot.'/'.$cursordir;
500
+					$dest=$dirodt.'/template_'.$cursorfile.'.odt';
501
+
502
+					dol_mkdir($dirodt);
503
+					$result=dol_copy($src,$dest,0,0);
504
+					if ($result < 0)
505
+					{
506
+						print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile',$src,$dest).'</td></tr>';
507
+					}
508
+				}
509
+			}
510
+		}
511
+	}
512
+
513
+	// Table prefix
514
+	$main_db_prefix = (! empty($db_prefix) ? $db_prefix : 'llx_');
515
+
516
+	// Write conf file on disk
517
+	if (! $error)
518
+	{
519
+		// Save old conf file on disk
520
+		if (file_exists("$conffile"))
521
+		{
522
+			// We must ignore errors as an existing old file may already exists and not be replacable or
523
+			// the installer (like for ubuntu) may not have permission to create another file than conf.php.
524
+			// Also no other process must be able to read file or we expose the new file, so content with password.
525
+			@dol_copy($conffile, $conffile.'.old', '0400');
526
+		}
527
+
528
+		$error+=write_conf_file($conffile);
529
+	}
530
+
531
+	// Create database and admin user database
532
+	if (! $error)
533
+	{
534
+		// We reload configuration file
535
+		conf($dolibarr_main_document_root);
536
+
537
+		print '<tr><td>';
538
+		print $langs->trans("ConfFileReload");
539
+		print '</td>';
540
+		print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
541
+
542
+		// Si creation utilisateur admin demandee, on le cree
543
+		if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) {
544
+			dolibarr_install_syslog("step1: create database user: " . $dolibarr_main_db_user);
545
+
546
+			//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
547
+			$databasefortest=$conf->db->name;
548
+			if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
549
+			{
550
+				$databasefortest='mysql';
551
+			}
552
+			else if ($conf->db->type == 'pgsql')
553
+			{
554
+				$databasefortest='postgres';
555
+			}
556
+			else if ($conf->db->type == 'mssql')
557
+			{
558
+				$databasefortest='master';
559
+			}
560
+
561
+			// Creation handler de base, verification du support et connexion
562
+
563
+			$db=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest,$conf->db->port);
564
+
565
+			if ($db->error)
566
+			{
567
+				print '<div class="error">'.$db->error.'</div>';
568
+				$error++;
569
+			}
570
+
571
+			if (! $error)
572
+			{
573
+				if ($db->connected)
574
+				{
575
+					$resultbis = 1;
576
+
577
+					// Create user
578
+					$result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
579
+					// Create user bis
580
+					if ($databasefortest == 'mysql')
581
+					{
582
+						if (! in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local')))
583
+						{
584
+							$resultbis=$db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
585
+						}
586
+					}
587
+
588
+					if ($result > 0 && $resultbis > 0)
589
+					{
590
+
591
+						print '<tr><td>';
592
+						print $langs->trans("UserCreation").' : ';
593
+						print $dolibarr_main_db_user;
594
+						print '</td>';
595
+						print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
596
+					}
597
+					else
598
+					{
599
+						if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
600
+						|| $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
601
+						|| $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS')
602
+						{
603
+							dolibarr_install_syslog("step1: user already exists");
604
+							print '<tr><td>';
605
+							print $langs->trans("UserCreation").' : ';
606
+							print $dolibarr_main_db_user;
607
+							print '</td>';
608
+							print '<td>'.$langs->trans("LoginAlreadyExists").'</td></tr>';
609
+						}
610
+						else
611
+						{
612
+							dolibarr_install_syslog("step1: failed to create user", LOG_ERR);
613
+							print '<tr><td>';
614
+							print $langs->trans("UserCreation").' : ';
615
+							print $dolibarr_main_db_user;
616
+							print '</td>';
617
+							print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error()."</td></tr>";
618
+						}
619
+					}
620
+
621
+					$db->close();
622
+				}
623
+				else
624
+				{
625
+					print '<tr><td>';
626
+					print $langs->trans("UserCreation").' : ';
627
+					print $dolibarr_main_db_user;
628
+					print '</td>';
629
+					print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
630
+					print '</tr>';
631
+
632
+					// Affiche aide diagnostique
633
+					print '<tr><td colspan="2"><br>';
634
+					print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
635
+					print '<br>';
636
+					print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
637
+					print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
638
+					print '</td></tr>';
639
+
640
+					$error++;
641
+				}
642
+			}
643
+		}   // Fin si "creation utilisateur"
644
+
645
+
646
+		// If database creation is asked, we create it
647
+		if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) {
648
+			dolibarr_install_syslog("step1: create database: " . $dolibarr_main_db_name . " " . $dolibarr_main_db_character_set . " " . $dolibarr_main_db_collation . " " . $dolibarr_main_db_user);
649
+			$newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port);
650
+			//print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
651
+
652
+			if ($newdb->connected)
653
+			{
654
+				$result=$newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
655
+
656
+				if ($result)
657
+				{
658
+					print '<tr><td>';
659
+					print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
660
+					print $dolibarr_main_db_name;
661
+					print '</td>';
662
+					print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
663
+
664
+					$newdb->select_db($dolibarr_main_db_name);
665
+					$check1=$newdb->getDefaultCharacterSetDatabase();
666
+					$check2=$newdb->getDefaultCollationDatabase();
667
+					dolibarr_install_syslog('step1: new database is using charset=' . $check1 . ' collation=' . $check2);
668
+
669
+					// If values differs, we save conf file again
670
+					//if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING);
671
+					//if ($check2 != $dolibarr_main_db_collation)     dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING);
672
+				}
673
+				else
674
+				{
675
+					// Affiche aide diagnostique
676
+					print '<tr><td colspan="2"><br>';
677
+					print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).'<br>';
678
+					print $newdb->lasterror().'<br>';
679
+					print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
680
+					print '<br>';
681
+					print '</td></tr>';
682
+
683
+					dolibarr_install_syslog('step1: failed to create database ' . $dolibarr_main_db_name . ' ' . $newdb->lasterrno() . ' ' . $newdb->lasterror(), LOG_ERR);
684
+					$error++;
685
+				}
686
+				$newdb->close();
687
+			}
688
+			else {
689
+				print '<tr><td>';
690
+				print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
691
+				print $dolibarr_main_db_name;
692
+				print '</td>';
693
+				print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
694
+				print '</tr>';
695
+
696
+				// Affiche aide diagnostique
697
+				print '<tr><td colspan="2"><br>';
698
+				print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
699
+				print '<br>';
700
+				print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
701
+				print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
702
+				print '</td></tr>';
703
+
704
+				$error++;
705
+			}
706
+		}   // Fin si "creation database"
707
+
708
+
709
+		// We test access with dolibarr database user (not admin)
710
+		if (! $error)
711
+		{
712
+			dolibarr_install_syslog("step1: connection type=" . $conf->db->type . " on host=" . $conf->db->host . " port=" . $conf->db->port . " user=" . $conf->db->user . " name=" . $conf->db->name);
713
+			//print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
714
+
715
+			$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
716
+
717
+			if ($db->connected)
718
+			{
719
+				dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " ok");
720
+				print "<tr><td>";
721
+				print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
722
+				print $dolibarr_main_db_host;
723
+				print "</td><td>";
724
+				print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
725
+				print "</td></tr>";
726
+
727
+				// si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root.
728
+				if ($db->database_selected)
729
+				{
730
+					dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " ok");
731
+					print "<tr><td>";
732
+					print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
733
+					print $dolibarr_main_db_name;
734
+					print "</td><td>";
735
+					print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
736
+					print "</td></tr>";
737
+
738
+					$error = 0;
739
+				}
740
+				else
741
+				{
742
+					dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " failed", LOG_ERR);
743
+					print "<tr><td>";
744
+					print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
745
+					print $dolibarr_main_db_name;
746
+					print '</td><td>';
747
+					print '<img src="../theme/eldy/img/error.png" alt="Error">';
748
+					print "</td></tr>";
749
+
750
+					// Affiche aide diagnostique
751
+					print '<tr><td colspan="2"><br>';
752
+					print $langs->trans('CheckThatDatabasenameIsCorrect',$dolibarr_main_db_name).'<br>';
753
+					print $langs->trans('IfAlreadyExistsCheckOption').'<br>';
754
+					print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
755
+					print '</td></tr>';
756
+
757
+					$error++;
758
+				}
759
+			}
760
+			else
761
+			{
762
+				dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " failed", LOG_ERR);
763
+				print "<tr><td>";
764
+				print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
765
+				print $dolibarr_main_db_host;
766
+				print '</td><td>';
767
+				print '<img src="../theme/eldy/img/error.png" alt="Error">';
768
+				print "</td></tr>";
769
+
770
+				// Affiche aide diagnostique
771
+				print '<tr><td colspan="2"><br>';
772
+				print $langs->trans("ErrorConnection",$conf->db->host,$conf->db->name,$conf->db->user);
773
+				print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').'<br>';
774
+				print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
775
+				print '</td></tr>';
776
+
777
+				$error++;
778
+			}
779
+		}
780
+	}
781
+
782
+	print '</table>';
783 783
 }
784 784
 
785 785
 ?>
@@ -814,15 +814,15 @@  discard block
 block discarded – undo
814 814
  */
815 815
 function write_main_file($mainfile,$main_dir)
816 816
 {
817
-    $fp = @fopen("$mainfile", "w");
818
-    if($fp)
819
-    {
820
-        clearstatcache();
821
-        fputs($fp, '<?php'."\n");
822
-        fputs($fp, "// Wrapper to include main into htdocs\n");
823
-        fputs($fp, "include_once '".$main_dir."/main.inc.php';\n");
824
-        fclose($fp);
825
-    }
817
+	$fp = @fopen("$mainfile", "w");
818
+	if($fp)
819
+	{
820
+		clearstatcache();
821
+		fputs($fp, '<?php'."\n");
822
+		fputs($fp, "// Wrapper to include main into htdocs\n");
823
+		fputs($fp, "include_once '".$main_dir."/main.inc.php';\n");
824
+		fclose($fp);
825
+	}
826 826
 }
827 827
 
828 828
 
@@ -835,15 +835,15 @@  discard block
 block discarded – undo
835 835
  */
836 836
 function write_master_file($masterfile,$main_dir)
837 837
 {
838
-    $fp = @fopen("$masterfile", "w");
839
-    if($fp)
840
-    {
841
-        clearstatcache();
842
-        fputs($fp, '<?php'."\n");
843
-        fputs($fp, "// Wrapper to include master into htdocs\n");
844
-        fputs($fp, "include_once '".$main_dir."/master.inc.php';\n");
845
-        fclose($fp);
846
-    }
838
+	$fp = @fopen("$masterfile", "w");
839
+	if($fp)
840
+	{
841
+		clearstatcache();
842
+		fputs($fp, '<?php'."\n");
843
+		fputs($fp, "// Wrapper to include master into htdocs\n");
844
+		fputs($fp, "include_once '".$main_dir."/master.inc.php';\n");
845
+		fclose($fp);
846
+	}
847 847
 }
848 848
 
849 849
 
@@ -855,47 +855,47 @@  discard block
 block discarded – undo
855 855
  */
856 856
 function write_conf_file($conffile)
857 857
 {
858
-    global $conf,$langs;
859
-    global $main_url,$main_dir,$main_data_dir,$main_force_https,$main_use_alt_dir,$main_alt_dir_name,$main_db_prefix;
860
-    global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
861
-    global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
862
-    global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
863
-    global $db_host,$db_port,$db_name,$db_user,$db_pass,$db_type,$db_character_set,$db_collation;
864
-    global $conffile,$conffiletoshow,$conffiletoshowshort;
865
-    global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
866
-    global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
867
-    global $force_dolibarr_lib_PHPEXCEL_PATH, $force_dolibarr_lib_GEOIP_PATH;
868
-    global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
869
-    global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI, $force_dolibarr_js_JQUERY_FLOT;
870
-    global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
871
-
872
-    $error=0;
873
-
874
-    $key = md5(uniqid(mt_rand(),TRUE)); // Generate random hash
875
-
876
-    $fp = fopen("$conffile", "w");
877
-    if($fp)
878
-    {
879
-        clearstatcache();
880
-
881
-        fputs($fp,'<?php'."\n");
882
-        fputs($fp,'//'."\n");
883
-        fputs($fp,'// File generated by Dolibarr installer '.DOL_VERSION.' on '.dol_print_date(dol_now(),'')."\n");
884
-        fputs($fp,'//'."\n");
885
-        fputs($fp,'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.' file'."\n");
886
-        fputs($fp,'// and explanations for all possibles parameters.'."\n");
887
-        fputs($fp,'//'."\n");
888
-
889
-        fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",($main_url)).'\';');
890
-        fputs($fp,"\n");
891
-
892
-        fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",($main_dir)).'\';');
893
-        fputs($fp,"\n");
894
-
895
-        fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",("/".$main_alt_dir_name)).'\';');
896
-        fputs($fp,"\n");
897
-
898
-        fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",($main_dir."/".$main_alt_dir_name)).'\';');
858
+	global $conf,$langs;
859
+	global $main_url,$main_dir,$main_data_dir,$main_force_https,$main_use_alt_dir,$main_alt_dir_name,$main_db_prefix;
860
+	global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
861
+	global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
862
+	global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
863
+	global $db_host,$db_port,$db_name,$db_user,$db_pass,$db_type,$db_character_set,$db_collation;
864
+	global $conffile,$conffiletoshow,$conffiletoshowshort;
865
+	global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
866
+	global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
867
+	global $force_dolibarr_lib_PHPEXCEL_PATH, $force_dolibarr_lib_GEOIP_PATH;
868
+	global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
869
+	global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI, $force_dolibarr_js_JQUERY_FLOT;
870
+	global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
871
+
872
+	$error=0;
873
+
874
+	$key = md5(uniqid(mt_rand(),TRUE)); // Generate random hash
875
+
876
+	$fp = fopen("$conffile", "w");
877
+	if($fp)
878
+	{
879
+		clearstatcache();
880
+
881
+		fputs($fp,'<?php'."\n");
882
+		fputs($fp,'//'."\n");
883
+		fputs($fp,'// File generated by Dolibarr installer '.DOL_VERSION.' on '.dol_print_date(dol_now(),'')."\n");
884
+		fputs($fp,'//'."\n");
885
+		fputs($fp,'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.' file'."\n");
886
+		fputs($fp,'// and explanations for all possibles parameters.'."\n");
887
+		fputs($fp,'//'."\n");
888
+
889
+		fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",($main_url)).'\';');
890
+		fputs($fp,"\n");
891
+
892
+		fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",($main_dir)).'\';');
893
+		fputs($fp,"\n");
894
+
895
+		fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",("/".$main_alt_dir_name)).'\';');
896
+		fputs($fp,"\n");
897
+
898
+		fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",($main_dir."/".$main_alt_dir_name)).'\';');
899 899
 		fputs($fp,"\n");
900 900
 
901 901
 		fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'","\'",($main_data_dir)).'\';');
@@ -929,88 +929,88 @@  discard block
 block discarded – undo
929 929
 
930 930
 		/* Authentication */
931 931
 		fputs($fp, '// Authentication settings');
932
-        fputs($fp,"\n");
932
+		fputs($fp,"\n");
933 933
 
934 934
 		fputs($fp, '$dolibarr_main_authentication=\'dolibarr\';');
935 935
 		fputs($fp,"\n\n");
936 936
 
937
-        fputs($fp, '//$dolibarr_main_demo=\'autologin,autopass\';');
938
-        fputs($fp,"\n");
937
+		fputs($fp, '//$dolibarr_main_demo=\'autologin,autopass\';');
938
+		fputs($fp,"\n");
939 939
 
940 940
 		fputs($fp, '// Security settings');
941
-        fputs($fp,"\n");
941
+		fputs($fp,"\n");
942 942
 
943
-        fputs($fp, '$dolibarr_main_prod=\'0\';');
944
-        fputs($fp,"\n");
943
+		fputs($fp, '$dolibarr_main_prod=\'0\';');
944
+		fputs($fp,"\n");
945 945
 
946
-        fputs($fp, '$dolibarr_main_force_https=\''.$main_force_https.'\';');
946
+		fputs($fp, '$dolibarr_main_force_https=\''.$main_force_https.'\';');
947 947
 		fputs($fp,"\n");
948 948
 
949
-        fputs($fp, '$dolibarr_main_restrict_os_commands=\'mysqldump, mysql, pg_dump, pgrestore\';');
949
+		fputs($fp, '$dolibarr_main_restrict_os_commands=\'mysqldump, mysql, pg_dump, pgrestore\';');
950 950
 		fputs($fp,"\n");
951 951
 
952
-        fputs($fp, '$dolibarr_nocsrfcheck=\'0\';');
953
-        fputs($fp,"\n");
952
+		fputs($fp, '$dolibarr_nocsrfcheck=\'0\';');
953
+		fputs($fp,"\n");
954 954
 
955 955
 		fputs($fp, '$dolibarr_main_cookie_cryptkey=\''.$key.'\';');
956 956
 		fputs($fp,"\n");
957 957
 
958 958
 		fputs($fp, '$dolibarr_mailing_limit_sendbyweb=\'0\';');
959
-        fputs($fp,"\n");
960
-
961
-        // Write params to overwrites default lib path
962
-        fputs($fp,"\n");
963
-        if (empty($force_dolibarr_lib_FPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH=''; }
964
-        fputs($fp, '$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.'\';');
965
-        fputs($fp,"\n");
966
-        if (empty($force_dolibarr_lib_TCPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH=''; }
967
-        fputs($fp, '$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.'\';');
968
-        fputs($fp,"\n");
969
-        if (empty($force_dolibarr_lib_FPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH=''; }
970
-        fputs($fp, '$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.'\';');
971
-        fputs($fp,"\n");
972
-        if (empty($force_dolibarr_lib_TCPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH=''; }
973
-        fputs($fp, '$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.'\';');
974
-        fputs($fp,"\n");
975
-        if (empty($force_dolibarr_lib_ADODB_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH=''; }
976
-        fputs($fp, '$dolibarr_lib_ADODB_PATH=\''.$force_dolibarr_lib_ADODB_PATH.'\';');
977
-        fputs($fp,"\n");
978
-        if (empty($force_dolibarr_lib_GEOIP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH=''; }
979
-        fputs($fp, '$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.'\';');
980
-        fputs($fp,"\n");
981
-        if (empty($force_dolibarr_lib_NUSOAP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH=''; }
982
-        fputs($fp, '$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.'\';');
983
-        fputs($fp,"\n");
984
-        if (empty($force_dolibarr_lib_PHPEXCEL_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_PHPEXCEL_PATH=''; }
985
-        fputs($fp, '$dolibarr_lib_PHPEXCEL_PATH=\''.$force_dolibarr_lib_PHPEXCEL_PATH.'\';');
986
-        fputs($fp,"\n");
987
-        if (empty($force_dolibarr_lib_ODTPHP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH=''; }
988
-        fputs($fp, '$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.'\';');
989
-        fputs($fp,"\n");
990
-        if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP=''; }
991
-        fputs($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.'\';');
992
-        fputs($fp,"\n");
993
-        if (empty($force_dolibarr_js_CKEDITOR)) { fputs($fp, '//'); $force_dolibarr_js_CKEDITOR=''; }
994
-        fputs($fp, '$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.'\';');
995
-        fputs($fp,"\n");
996
-        if (empty($force_dolibarr_js_JQUERY)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY=''; }
997
-        fputs($fp, '$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.'\';');
998
-        fputs($fp,"\n");
999
-        if (empty($force_dolibarr_js_JQUERY_UI)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI=''; }
1000
-        fputs($fp, '$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.'\';');
1001
-        fputs($fp,"\n");
1002
-        if (empty($force_dolibarr_js_JQUERY_FLOT)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY_FLOT=''; }
1003
-        fputs($fp, '$dolibarr_js_JQUERY_FLOT=\''.$force_dolibarr_js_JQUERY_FLOT.'\';');
1004
-        fputs($fp,"\n");
1005
-
1006
-        // Write params to overwrites default font path
1007
-        fputs($fp,"\n");
1008
-        if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF=''; }
959
+		fputs($fp,"\n");
960
+
961
+		// Write params to overwrites default lib path
962
+		fputs($fp,"\n");
963
+		if (empty($force_dolibarr_lib_FPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH=''; }
964
+		fputs($fp, '$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.'\';');
965
+		fputs($fp,"\n");
966
+		if (empty($force_dolibarr_lib_TCPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH=''; }
967
+		fputs($fp, '$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.'\';');
968
+		fputs($fp,"\n");
969
+		if (empty($force_dolibarr_lib_FPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH=''; }
970
+		fputs($fp, '$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.'\';');
971
+		fputs($fp,"\n");
972
+		if (empty($force_dolibarr_lib_TCPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH=''; }
973
+		fputs($fp, '$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.'\';');
974
+		fputs($fp,"\n");
975
+		if (empty($force_dolibarr_lib_ADODB_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH=''; }
976
+		fputs($fp, '$dolibarr_lib_ADODB_PATH=\''.$force_dolibarr_lib_ADODB_PATH.'\';');
977
+		fputs($fp,"\n");
978
+		if (empty($force_dolibarr_lib_GEOIP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH=''; }
979
+		fputs($fp, '$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.'\';');
980
+		fputs($fp,"\n");
981
+		if (empty($force_dolibarr_lib_NUSOAP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH=''; }
982
+		fputs($fp, '$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.'\';');
983
+		fputs($fp,"\n");
984
+		if (empty($force_dolibarr_lib_PHPEXCEL_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_PHPEXCEL_PATH=''; }
985
+		fputs($fp, '$dolibarr_lib_PHPEXCEL_PATH=\''.$force_dolibarr_lib_PHPEXCEL_PATH.'\';');
986
+		fputs($fp,"\n");
987
+		if (empty($force_dolibarr_lib_ODTPHP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH=''; }
988
+		fputs($fp, '$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.'\';');
989
+		fputs($fp,"\n");
990
+		if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP=''; }
991
+		fputs($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.'\';');
992
+		fputs($fp,"\n");
993
+		if (empty($force_dolibarr_js_CKEDITOR)) { fputs($fp, '//'); $force_dolibarr_js_CKEDITOR=''; }
994
+		fputs($fp, '$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.'\';');
995
+		fputs($fp,"\n");
996
+		if (empty($force_dolibarr_js_JQUERY)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY=''; }
997
+		fputs($fp, '$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.'\';');
998
+		fputs($fp,"\n");
999
+		if (empty($force_dolibarr_js_JQUERY_UI)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI=''; }
1000
+		fputs($fp, '$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.'\';');
1001
+		fputs($fp,"\n");
1002
+		if (empty($force_dolibarr_js_JQUERY_FLOT)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY_FLOT=''; }
1003
+		fputs($fp, '$dolibarr_js_JQUERY_FLOT=\''.$force_dolibarr_js_JQUERY_FLOT.'\';');
1004
+		fputs($fp,"\n");
1005
+
1006
+		// Write params to overwrites default font path
1007
+		fputs($fp,"\n");
1008
+		if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF=''; }
1009 1009
    		fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.'\';');
1010
-        fputs($fp,"\n");
1011
-        if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD=''; }
1012
-        fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';');
1013
-        fputs($fp,"\n");
1010
+		fputs($fp,"\n");
1011
+		if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD=''; }
1012
+		fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';');
1013
+		fputs($fp,"\n");
1014 1014
 
1015 1015
 		fclose($fp);
1016 1016
 
Please login to merge, or discard this patch.
htdocs/societe/card.php 1 patch
Indentation   +1858 added lines, -1858 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 $objcanvas=null;
87 87
 if (! empty($canvas))
88 88
 {
89
-    require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
90
-    $objcanvas = new Canvas($db, $action);
91
-    $objcanvas->getCanvas('thirdparty', 'card', $canvas);
89
+	require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
90
+	$objcanvas = new Canvas($db, $action);
91
+	$objcanvas->getCanvas('thirdparty', 'card', $canvas);
92 92
 }
93 93
 
94 94
 // Security check
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 
106 106
 if (empty($reshook))
107 107
 {
108
-    if ($cancel)
109
-    {
110
-        $action='';
111
-        if (! empty($backtopage))
112
-        {
113
-            header("Location: ".$backtopage);
114
-            exit;
115
-        }
116
-    }
108
+	if ($cancel)
109
+	{
110
+		$action='';
111
+		if (! empty($backtopage))
112
+		{
113
+			header("Location: ".$backtopage);
114
+			exit;
115
+		}
116
+	}
117 117
 
118 118
 	if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer)
119 119
 	{
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 			if (!$error)
141 141
 			{
142
-			    // TODO Move the merge function into class of object.
142
+				// TODO Move the merge function into class of object.
143 143
 
144 144
 				$db->begin();
145 145
 
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 
162 162
 				// Concat some data
163 163
 				$listofproperties=array(
164
-				    'note_public', 'note_private'
164
+					'note_public', 'note_private'
165 165
 				);
166 166
 				foreach ($listofproperties as $property)
167 167
 				{
168
-				    $object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
168
+					$object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
169 169
 				}
170 170
 
171 171
 				// Merge extrafields
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				{
174 174
 					foreach ($soc_origin->array_options as $key => $val)
175 175
 					{
176
-					    if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
176
+						if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
177 177
 					}
178 178
 				}
179 179
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 				}
290 290
 				else
291 291
 				{
292
-				    $langs->load("errors");
292
+					$langs->load("errors");
293 293
 					setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors');
294 294
 					$db->rollback();
295 295
 				}
@@ -297,152 +297,152 @@  discard block
 block discarded – undo
297 297
 		}
298 298
 	}
299 299
 
300
-    if (GETPOST('getcustomercode'))
301
-    {
302
-        // We defined value code_client
303
-        $_POST["code_client"]="Acompleter";
304
-    }
305
-
306
-    if (GETPOST('getsuppliercode'))
307
-    {
308
-        // We defined value code_fournisseur
309
-        $_POST["code_fournisseur"]="Acompleter";
310
-    }
311
-
312
-    if($action=='set_localtax1')
313
-    {
314
-    	//obtidre selected del combobox
315
-    	$value=GETPOST('lt1');
316
-    	$object->fetch($socid);
317
-    	$res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
318
-    }
319
-    if($action=='set_localtax2')
320
-    {
321
-    	//obtidre selected del combobox
322
-    	$value=GETPOST('lt2');
323
-    	$object->fetch($socid);
324
-    	$res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
325
-    }
326
-
327
-    if ($action == 'update_extras') {
328
-        $object->fetch($socid);
329
-
330
-        $object->oldcopy = dol_clone($object);
331
-
332
-        // Fill array 'array_options' with data from update form
333
-        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
334
-        $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
335
-        if ($ret < 0) $error++;
336
-
337
-        if (! $error)
338
-        {
339
-            $result = $object->insertExtraFields('COMPANY_MODIFY');
300
+	if (GETPOST('getcustomercode'))
301
+	{
302
+		// We defined value code_client
303
+		$_POST["code_client"]="Acompleter";
304
+	}
305
+
306
+	if (GETPOST('getsuppliercode'))
307
+	{
308
+		// We defined value code_fournisseur
309
+		$_POST["code_fournisseur"]="Acompleter";
310
+	}
311
+
312
+	if($action=='set_localtax1')
313
+	{
314
+		//obtidre selected del combobox
315
+		$value=GETPOST('lt1');
316
+		$object->fetch($socid);
317
+		$res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
318
+	}
319
+	if($action=='set_localtax2')
320
+	{
321
+		//obtidre selected del combobox
322
+		$value=GETPOST('lt2');
323
+		$object->fetch($socid);
324
+		$res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
325
+	}
326
+
327
+	if ($action == 'update_extras') {
328
+		$object->fetch($socid);
329
+
330
+		$object->oldcopy = dol_clone($object);
331
+
332
+		// Fill array 'array_options' with data from update form
333
+		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
334
+		$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
335
+		if ($ret < 0) $error++;
336
+
337
+		if (! $error)
338
+		{
339
+			$result = $object->insertExtraFields('COMPANY_MODIFY');
340 340
    			if ($result < 0)
341 341
 			{
342 342
 				setEventMessages($object->error, $object->errors, 'errors');
343 343
 				$error++;
344 344
 			}
345
-        }
346
-
347
-        if ($error) $action = 'edit_extras';
348
-    }
349
-
350
-    // Add new or update third party
351
-    if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode'))
352
-    && ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
353
-    {
354
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
355
-
356
-        if (! GETPOST('name'))
357
-        {
358
-            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
359
-            $error++;
360
-        }
361
-        if (GETPOST('client') < 0)
362
-        {
363
-            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors');
364
-            $error++;
365
-        }
366
-        if (GETPOST('fournisseur') < 0)
367
-        {
368
-            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
369
-            $error++;
370
-
371
-        }
372
-
373
-        if (! $error)
374
-        {
375
-        		if ($action == 'update')
376
-	        {
377
-	        		$ret=$object->fetch($socid);
345
+		}
346
+
347
+		if ($error) $action = 'edit_extras';
348
+	}
349
+
350
+	// Add new or update third party
351
+	if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode'))
352
+	&& ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
353
+	{
354
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
355
+
356
+		if (! GETPOST('name'))
357
+		{
358
+			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
359
+			$error++;
360
+		}
361
+		if (GETPOST('client') < 0)
362
+		{
363
+			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors');
364
+			$error++;
365
+		}
366
+		if (GETPOST('fournisseur') < 0)
367
+		{
368
+			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
369
+			$error++;
370
+
371
+		}
372
+
373
+		if (! $error)
374
+		{
375
+				if ($action == 'update')
376
+			{
377
+					$ret=$object->fetch($socid);
378 378
 				$object->oldcopy = clone $object;
379
-	        }
379
+			}
380 380
 			else $object->canvas=$canvas;
381 381
 
382
-	        if (GETPOST("private") == 1)	// Ask to create a contact
383
-	        {
384
-	            $object->particulier			= GETPOST("private");
385
-
386
-	            $object->name				= dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha'));
387
-	            $object->civility_id			= GETPOST('civility_id');	// Note: civility id is a code, not an int
388
-	            // Add non official properties
389
-	            $object->name_bis			= GETPOST('name','alpha');
390
-	            $object->firstname			= GETPOST('firstname','alpha');
391
-	        }
392
-	        else
393
-	        {
394
-	            $object->name				= GETPOST('name', 'alpha');
395
-	        }
396
-	        $object->entity					= (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
397
-	        $object->name_alias				= GETPOST('name_alias');
398
-	        $object->address					= GETPOST('address');
399
-	        $object->zip						= GETPOST('zipcode', 'alpha');
400
-	        $object->town					= GETPOST('town', 'alpha');
401
-	        $object->country_id				= GETPOST('country_id', 'int');
402
-	        $object->state_id				= GETPOST('state_id', 'int');
403
-	        $object->skype					= GETPOST('skype', 'alpha');
404
-	        $object->phone					= GETPOST('phone', 'alpha');
405
-	        $object->fax						= GETPOST('fax','alpha');
406
-	        $object->email					= trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
407
-	        $object->url						= trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
408
-	        $object->idprof1					= trim(GETPOST('idprof1', 'alpha'));
409
-	        $object->idprof2					= trim(GETPOST('idprof2', 'alpha'));
410
-	        $object->idprof3					= trim(GETPOST('idprof3', 'alpha'));
411
-	        $object->idprof4					= trim(GETPOST('idprof4', 'alpha'));
412
-	        $object->idprof5					= trim(GETPOST('idprof5', 'alpha'));
413
-	        $object->idprof6					= trim(GETPOST('idprof6', 'alpha'));
414
-	        $object->prefix_comm				= GETPOST('prefix_comm', 'alpha');
415
-	        $object->code_client				= GETPOST('code_client', 'alpha');
416
-	        $object->code_fournisseur		= GETPOST('code_fournisseur', 'alpha');
417
-	        $object->capital					= GETPOST('capital', 'alpha');
418
-	        $object->barcode					= GETPOST('barcode', 'alpha');
419
-
420
-	        $object->tva_intra				= GETPOST('tva_intra', 'alpha');
421
-	        $object->tva_assuj				= GETPOST('assujtva_value', 'alpha');
422
-	        $object->status					= GETPOST('status', 'alpha');
423
-
424
-	        // Local Taxes
425
-	        $object->localtax1_assuj			= GETPOST('localtax1assuj_value', 'alpha');
426
-	        $object->localtax2_assuj			= GETPOST('localtax2assuj_value', 'alpha');
427
-
428
-	        $object->localtax1_value			= GETPOST('lt1', 'alpha');
429
-	        $object->localtax2_value			= GETPOST('lt2', 'alpha');
430
-
431
-	        $object->forme_juridique_code	= GETPOST('forme_juridique_code', 'int');
432
-	        $object->effectif_id				= GETPOST('effectif_id', 'int');
433
-	        $object->typent_id				= GETPOST('typent_id','int');
434
-
435
-	        $object->typent_code				= dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code');	// Force typent_code too so check in verify() will be done on new type
436
-
437
-	        $object->client					= GETPOST('client', 'int');
438
-	        $object->fournisseur				= GETPOST('fournisseur', 'int');
439
-
440
-	        $object->commercial_id			= GETPOST('commercial_id', 'int');
441
-	        $object->default_lang			= GETPOST('default_lang');
442
-
443
-	        // Webservices url/key
444
-	        $object->webservices_url			= GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
445
-	        $object->webservices_key			= GETPOST('webservices_key', 'san_alpha');
382
+			if (GETPOST("private") == 1)	// Ask to create a contact
383
+			{
384
+				$object->particulier			= GETPOST("private");
385
+
386
+				$object->name				= dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha'));
387
+				$object->civility_id			= GETPOST('civility_id');	// Note: civility id is a code, not an int
388
+				// Add non official properties
389
+				$object->name_bis			= GETPOST('name','alpha');
390
+				$object->firstname			= GETPOST('firstname','alpha');
391
+			}
392
+			else
393
+			{
394
+				$object->name				= GETPOST('name', 'alpha');
395
+			}
396
+			$object->entity					= (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
397
+			$object->name_alias				= GETPOST('name_alias');
398
+			$object->address					= GETPOST('address');
399
+			$object->zip						= GETPOST('zipcode', 'alpha');
400
+			$object->town					= GETPOST('town', 'alpha');
401
+			$object->country_id				= GETPOST('country_id', 'int');
402
+			$object->state_id				= GETPOST('state_id', 'int');
403
+			$object->skype					= GETPOST('skype', 'alpha');
404
+			$object->phone					= GETPOST('phone', 'alpha');
405
+			$object->fax						= GETPOST('fax','alpha');
406
+			$object->email					= trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
407
+			$object->url						= trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
408
+			$object->idprof1					= trim(GETPOST('idprof1', 'alpha'));
409
+			$object->idprof2					= trim(GETPOST('idprof2', 'alpha'));
410
+			$object->idprof3					= trim(GETPOST('idprof3', 'alpha'));
411
+			$object->idprof4					= trim(GETPOST('idprof4', 'alpha'));
412
+			$object->idprof5					= trim(GETPOST('idprof5', 'alpha'));
413
+			$object->idprof6					= trim(GETPOST('idprof6', 'alpha'));
414
+			$object->prefix_comm				= GETPOST('prefix_comm', 'alpha');
415
+			$object->code_client				= GETPOST('code_client', 'alpha');
416
+			$object->code_fournisseur		= GETPOST('code_fournisseur', 'alpha');
417
+			$object->capital					= GETPOST('capital', 'alpha');
418
+			$object->barcode					= GETPOST('barcode', 'alpha');
419
+
420
+			$object->tva_intra				= GETPOST('tva_intra', 'alpha');
421
+			$object->tva_assuj				= GETPOST('assujtva_value', 'alpha');
422
+			$object->status					= GETPOST('status', 'alpha');
423
+
424
+			// Local Taxes
425
+			$object->localtax1_assuj			= GETPOST('localtax1assuj_value', 'alpha');
426
+			$object->localtax2_assuj			= GETPOST('localtax2assuj_value', 'alpha');
427
+
428
+			$object->localtax1_value			= GETPOST('lt1', 'alpha');
429
+			$object->localtax2_value			= GETPOST('lt2', 'alpha');
430
+
431
+			$object->forme_juridique_code	= GETPOST('forme_juridique_code', 'int');
432
+			$object->effectif_id				= GETPOST('effectif_id', 'int');
433
+			$object->typent_id				= GETPOST('typent_id','int');
434
+
435
+			$object->typent_code				= dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code');	// Force typent_code too so check in verify() will be done on new type
436
+
437
+			$object->client					= GETPOST('client', 'int');
438
+			$object->fournisseur				= GETPOST('fournisseur', 'int');
439
+
440
+			$object->commercial_id			= GETPOST('commercial_id', 'int');
441
+			$object->default_lang			= GETPOST('default_lang');
442
+
443
+			// Webservices url/key
444
+			$object->webservices_url			= GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
445
+			$object->webservices_key			= GETPOST('webservices_key', 'san_alpha');
446 446
 
447 447
 			// Incoterms
448 448
 			if (!empty($conf->incoterm->enabled))
@@ -457,70 +457,70 @@  discard block
 block discarded – undo
457 457
 				$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
458 458
 			}
459 459
 
460
-	        // Fill array 'array_options' with data from add form
461
-	        $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
460
+			// Fill array 'array_options' with data from add form
461
+			$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
462 462
 			if ($ret < 0)
463 463
 			{
464 464
 				 $error++;
465 465
 			}
466 466
 
467
-	        if (GETPOST('deletephoto')) $object->logo = '';
468
-	        else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
469
-
470
-	        // Check parameters
471
-	        if (! GETPOST('cancel','alpha'))
472
-	        {
473
-	            if (! empty($object->email) && ! isValidEMail($object->email))
474
-	            {
475
-	                $langs->load("errors");
476
-	                $error++;
477
-	                setEventMessages('', $langs->trans("ErrorBadEMail",$object->email), 'errors');
478
-	            }
479
-	            if (! empty($object->url) && ! isValidUrl($object->url))
480
-	            {
481
-	                $langs->load("errors");
482
-	                setEventMessages('', $langs->trans("ErrorBadUrl",$object->url), 'errors');
483
-	            }
484
-	            if ($object->fournisseur && ! $conf->fournisseur->enabled)
485
-	            {
486
-	                $langs->load("errors");
487
-	                setEventMessages('', $langs->trans("ErrorSupplierModuleNotEnabled"), 'errors');
488
-	            }
489
-	            if (! empty($object->webservices_url)) {
490
-	                //Check if has transport, without any the soap client will give error
491
-	                if (strpos($object->webservices_url, "http") === false)
492
-	                {
493
-	                    $object->webservices_url = "http://".$object->webservices_url;
494
-	                }
495
-	                if (! isValidUrl($object->webservices_url)) {
496
-	                    $langs->load("errors");
497
-	                    $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url);
498
-	                }
499
-	            }
500
-
501
-	            // We set country_id, country_code and country for the selected country
502
-	            $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
503
-	            if ($object->country_id)
504
-	            {
505
-	            	$tmparray=getCountry($object->country_id,'all');
506
-	            	$object->country_code=$tmparray['code'];
507
-	            	$object->country=$tmparray['label'];
508
-	            }
509
-	        }
510
-        }
511
-
512
-        if (! $error)
513
-        {
514
-            if ($action == 'add')
515
-            {
516
-            	$error = 0;
517
-
518
-                $db->begin();
519
-
520
-                if (empty($object->client))      $object->code_client='';
521
-                if (empty($object->fournisseur)) $object->code_fournisseur='';
522
-
523
-                $result = $object->create($user);
467
+			if (GETPOST('deletephoto')) $object->logo = '';
468
+			else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
469
+
470
+			// Check parameters
471
+			if (! GETPOST('cancel','alpha'))
472
+			{
473
+				if (! empty($object->email) && ! isValidEMail($object->email))
474
+				{
475
+					$langs->load("errors");
476
+					$error++;
477
+					setEventMessages('', $langs->trans("ErrorBadEMail",$object->email), 'errors');
478
+				}
479
+				if (! empty($object->url) && ! isValidUrl($object->url))
480
+				{
481
+					$langs->load("errors");
482
+					setEventMessages('', $langs->trans("ErrorBadUrl",$object->url), 'errors');
483
+				}
484
+				if ($object->fournisseur && ! $conf->fournisseur->enabled)
485
+				{
486
+					$langs->load("errors");
487
+					setEventMessages('', $langs->trans("ErrorSupplierModuleNotEnabled"), 'errors');
488
+				}
489
+				if (! empty($object->webservices_url)) {
490
+					//Check if has transport, without any the soap client will give error
491
+					if (strpos($object->webservices_url, "http") === false)
492
+					{
493
+						$object->webservices_url = "http://".$object->webservices_url;
494
+					}
495
+					if (! isValidUrl($object->webservices_url)) {
496
+						$langs->load("errors");
497
+						$error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url);
498
+					}
499
+				}
500
+
501
+				// We set country_id, country_code and country for the selected country
502
+				$object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
503
+				if ($object->country_id)
504
+				{
505
+					$tmparray=getCountry($object->country_id,'all');
506
+					$object->country_code=$tmparray['code'];
507
+					$object->country=$tmparray['label'];
508
+				}
509
+			}
510
+		}
511
+
512
+		if (! $error)
513
+		{
514
+			if ($action == 'add')
515
+			{
516
+				$error = 0;
517
+
518
+				$db->begin();
519
+
520
+				if (empty($object->client))      $object->code_client='';
521
+				if (empty($object->fournisseur)) $object->code_fournisseur='';
522
+
523
+				$result = $object->create($user);
524 524
 
525 525
 				if ($result >= 0)
526 526
 				{
@@ -553,116 +553,116 @@  discard block
 block discarded – undo
553 553
 						setEventMessages($object->error, $object->errors, 'errors');
554 554
 					}
555 555
 
556
-                    // Logo/Photo save
557
-                    $dir     = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
558
-                    $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
559
-                    if ($file_OK)
560
-                    {
561
-                        if (image_format_supported($_FILES['photo']['name']))
562
-                        {
563
-                            dol_mkdir($dir);
564
-
565
-                            if (@is_dir($dir))
566
-                            {
567
-                                $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
568
-                                $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
569
-
570
-                                if (! $result > 0)
571
-                                {
572
-                                    $errors[] = "ErrorFailedToSaveFile";
573
-                                }
574
-                                else
575
-                                {
576
-                                    // Create thumbs
577
-                                    $object->addThumbs($newfile);
578
-                                }
579
-                            }
580
-                        }
581
-                    }
582
-                    else
556
+					// Logo/Photo save
557
+					$dir     = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
558
+					$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
559
+					if ($file_OK)
560
+					{
561
+						if (image_format_supported($_FILES['photo']['name']))
562
+						{
563
+							dol_mkdir($dir);
564
+
565
+							if (@is_dir($dir))
566
+							{
567
+								$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
568
+								$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
569
+
570
+								if (! $result > 0)
571
+								{
572
+									$errors[] = "ErrorFailedToSaveFile";
573
+								}
574
+								else
575
+								{
576
+									// Create thumbs
577
+									$object->addThumbs($newfile);
578
+								}
579
+							}
580
+						}
581
+					}
582
+					else
583 583
 					{
584 584
 						switch($_FILES['photo']['error'])
585 585
 						{
586
-						    case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
587
-						    case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
588
-						      $errors[] = "ErrorFileSizeTooLarge";
589
-						      break;
590
-	      					case 3: //uploaded file was only partially uploaded
591
-						      $errors[] = "ErrorFilePartiallyUploaded";
592
-						      break;
586
+							case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
587
+							case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
588
+							  $errors[] = "ErrorFileSizeTooLarge";
589
+							  break;
590
+		  					case 3: //uploaded file was only partially uploaded
591
+							  $errors[] = "ErrorFilePartiallyUploaded";
592
+							  break;
593 593
 						}
594
-	                }
595
-                    // Gestion du logo de la société
596
-                }
597
-                else
594
+					}
595
+					// Gestion du logo de la société
596
+				}
597
+				else
598 598
 				{
599
-				    if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case
599
+					if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case
600 600
 					{
601 601
 						$duplicate_code_error = true;
602 602
 						$object->code_fournisseur = null;
603 603
 						$object->code_client = null;
604 604
 					}
605 605
 
606
-                    setEventMessages($object->error, $object->errors, 'errors');
607
-                   	$error++;
608
-                }
609
-
610
-                if ($result >= 0 && ! $error)
611
-                {
612
-                    $db->commit();
613
-
614
-                	if (! empty($backtopage))
615
-                	{
616
-                	    if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id;
617
-               		    header("Location: ".$backtopage);
618
-                    	exit;
619
-                	}
620
-                	else
621
-                	{
622
-                    	$url=$_SERVER["PHP_SELF"]."?socid=".$object->id;
623
-                    	if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id;
624
-                    	else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id;
625
-
626
-                		header("Location: ".$url);
627
-                    	exit;
628
-                	}
629
-                }
630
-                else
631
-                {
632
-                    $db->rollback();
633
-                    $action='create';
634
-                }
635
-            }
636
-
637
-            if ($action == 'update')
638
-            {
639
-            	$error = 0;
640
-
641
-                if (GETPOST('cancel','alpha'))
642
-                {
643
-                	if (! empty($backtopage))
644
-                	{
645
-               		    header("Location: ".$backtopage);
646
-                    	exit;
647
-                	}
648
-                	else
649
-                	{
650
-               		    header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
651
-                    	exit;
652
-                	}
653
-                }
654
-
655
-                // To not set code if third party is not concerned. But if it had values, we keep them.
656
-                if (empty($object->client) && empty($object->oldcopy->code_client))          $object->code_client='';
657
-                if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur='';
658
-                //var_dump($object);exit;
659
-
660
-                $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0);
661
-                if ($result <=  0)
662
-                {
663
-                    setEventMessages($object->error, $object->errors, 'errors');
664
-                  	$error++;
665
-                }
606
+					setEventMessages($object->error, $object->errors, 'errors');
607
+				   	$error++;
608
+				}
609
+
610
+				if ($result >= 0 && ! $error)
611
+				{
612
+					$db->commit();
613
+
614
+					if (! empty($backtopage))
615
+					{
616
+						if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id;
617
+			   			header("Location: ".$backtopage);
618
+						exit;
619
+					}
620
+					else
621
+					{
622
+						$url=$_SERVER["PHP_SELF"]."?socid=".$object->id;
623
+						if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id;
624
+						else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id;
625
+
626
+						header("Location: ".$url);
627
+						exit;
628
+					}
629
+				}
630
+				else
631
+				{
632
+					$db->rollback();
633
+					$action='create';
634
+				}
635
+			}
636
+
637
+			if ($action == 'update')
638
+			{
639
+				$error = 0;
640
+
641
+				if (GETPOST('cancel','alpha'))
642
+				{
643
+					if (! empty($backtopage))
644
+					{
645
+			   			header("Location: ".$backtopage);
646
+						exit;
647
+					}
648
+					else
649
+					{
650
+			   			header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
651
+						exit;
652
+					}
653
+				}
654
+
655
+				// To not set code if third party is not concerned. But if it had values, we keep them.
656
+				if (empty($object->client) && empty($object->oldcopy->code_client))          $object->code_client='';
657
+				if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur='';
658
+				//var_dump($object);exit;
659
+
660
+				$result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0);
661
+				if ($result <=  0)
662
+				{
663
+					setEventMessages($object->error, $object->errors, 'errors');
664
+				  	$error++;
665
+				}
666 666
 
667 667
 				// Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined)
668 668
 				if (! $error && !empty($user->rights->categorie->lire))
@@ -686,155 +686,155 @@  discard block
 block discarded – undo
686 686
 					}
687 687
 				}
688 688
 
689
-                // Logo/Photo save
690
-                $dir     = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
691
-                $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
692
-                if (GETPOST('deletephoto') && $object->photo)
693
-                {
694
-                    $fileimg=$dir.'/'.$object->logo;
695
-                    $dirthumbs=$dir.'/thumbs';
696
-                    dol_delete_file($fileimg);
697
-                    dol_delete_dir_recursive($dirthumbs);
698
-                }
699
-                if ($file_OK)
700
-                {
701
-                    if (image_format_supported($_FILES['photo']['name']) > 0)
702
-                    {
703
-                        dol_mkdir($dir);
704
-
705
-                        if (@is_dir($dir))
706
-                        {
707
-                            $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
708
-                            $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
709
-
710
-                            if (! $result > 0)
711
-                            {
712
-                                $errors[] = "ErrorFailedToSaveFile";
713
-                            }
714
-                            else
715
-                            {
716
-                            	// Create thumbs
717
-                            	$object->addThumbs($newfile);
718
-
719
-                                // Index file in database
720
-                                if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD))
721
-                                {
722
-                                	require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
723
-                                	// the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir
724
-                                	deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', 'uploaded', 1);
725
-                                	// now we index the uploaded logo file
726
-                                	addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1);
727
-                                }
728
-                            }
729
-                        }
730
-                    }
731
-                    else
689
+				// Logo/Photo save
690
+				$dir     = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
691
+				$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
692
+				if (GETPOST('deletephoto') && $object->photo)
693
+				{
694
+					$fileimg=$dir.'/'.$object->logo;
695
+					$dirthumbs=$dir.'/thumbs';
696
+					dol_delete_file($fileimg);
697
+					dol_delete_dir_recursive($dirthumbs);
698
+				}
699
+				if ($file_OK)
700
+				{
701
+					if (image_format_supported($_FILES['photo']['name']) > 0)
702
+					{
703
+						dol_mkdir($dir);
704
+
705
+						if (@is_dir($dir))
706
+						{
707
+							$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
708
+							$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
709
+
710
+							if (! $result > 0)
711
+							{
712
+								$errors[] = "ErrorFailedToSaveFile";
713
+							}
714
+							else
715
+							{
716
+								// Create thumbs
717
+								$object->addThumbs($newfile);
718
+
719
+								// Index file in database
720
+								if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD))
721
+								{
722
+									require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
723
+									// the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir
724
+									deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', 'uploaded', 1);
725
+									// now we index the uploaded logo file
726
+									addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1);
727
+								}
728
+							}
729
+						}
730
+					}
731
+					else
732 732
 					{
733
-                        $errors[] = "ErrorBadImageFormat";
734
-                    }
735
-                }
736
-                else
737
-                {
733
+						$errors[] = "ErrorBadImageFormat";
734
+					}
735
+				}
736
+				else
737
+				{
738 738
 					switch($_FILES['photo']['error'])
739 739
 					{
740
-					    case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
741
-					    case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
742
-					      $errors[] = "ErrorFileSizeTooLarge";
743
-					      break;
744
-      					case 3: //uploaded file was only partially uploaded
745
-					      $errors[] = "ErrorFilePartiallyUploaded";
746
-					      break;
740
+						case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
741
+						case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
742
+						  $errors[] = "ErrorFileSizeTooLarge";
743
+						  break;
744
+	  					case 3: //uploaded file was only partially uploaded
745
+						  $errors[] = "ErrorFilePartiallyUploaded";
746
+						  break;
747
+					}
748
+				}
749
+				// Gestion du logo de la société
750
+
751
+
752
+				// Update linked member
753
+				if (! $error && $object->fk_soc > 0)
754
+				{
755
+
756
+					$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
757
+					$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
758
+					if (! $object->db->query($sql))
759
+					{
760
+						$error++;
761
+						$object->error .= $object->db->lasterror();
762
+					}
763
+				}
764
+
765
+				if (! $error && ! count($errors))
766
+				{
767
+					if (! empty($backtopage))
768
+					{
769
+			   			header("Location: ".$backtopage);
770
+						exit;
771
+					}
772
+					else
773
+					{
774
+			   			header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
775
+						exit;
747 776
 					}
748
-                }
749
-                // Gestion du logo de la société
750
-
751
-
752
-                // Update linked member
753
-                if (! $error && $object->fk_soc > 0)
754
-                {
755
-
756
-                	$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
757
-                	$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
758
-                	if (! $object->db->query($sql))
759
-                	{
760
-                		$error++;
761
-                		$object->error .= $object->db->lasterror();
762
-                	}
763
-                }
764
-
765
-                if (! $error && ! count($errors))
766
-                {
767
-                	if (! empty($backtopage))
768
-                	{
769
-               		    header("Location: ".$backtopage);
770
-                    	exit;
771
-                	}
772
-                	else
773
-                	{
774
-               		    header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
775
-                    	exit;
776
-                	}
777
-                }
778
-                else
779
-                {
780
-                    $object->id = $socid;
781
-                    $action= "edit";
782
-                }
783
-            }
784
-        }
785
-        else
786
-        {
787
-        	$action = ($action=='add'?'create':'edit');
788
-        }
789
-    }
790
-
791
-    // Delete third party
792
-    if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
793
-    {
794
-        $object->fetch($socid);
795
-        $result = $object->delete($socid, $user);
796
-
797
-        if ($result > 0)
798
-        {
799
-            header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name));
800
-            exit;
801
-        }
802
-        else
803
-        {
804
-            $langs->load("errors");
805
-           	setEventMessages($object->error, $object->errors, 'errors');
806
-           	$error++;
807
-            $action='';
808
-        }
809
-    }
810
-
811
-    // Set parent company
812
-    if ($action == 'set_thirdparty' && $user->rights->societe->creer)
813
-    {
814
-    	$object->fetch($socid);
815
-    	$result = $object->set_parent(GETPOST('editparentcompany','int'));
816
-    }
817
-
818
-    // Set incoterm
819
-    if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
820
-    {
821
-    	$object->fetch($socid);
822
-    	$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
823
-    }
824
-
825
-    // Actions to send emails
826
-    $id=$socid;
827
-    $trigger_name='COMPANY_SENTBYMAIL';
828
-    $paramname='socid';
829
-    $mode='emailfromthirdparty';
830
-    $trackid='thi'.$object->id;
831
-    include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
832
-
833
-    // Actions to build doc
834
-    $id = $socid;
835
-    $upload_dir = $conf->societe->dir_output;
836
-    $permissioncreate=$user->rights->societe->creer;
837
-    include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
777
+				}
778
+				else
779
+				{
780
+					$object->id = $socid;
781
+					$action= "edit";
782
+				}
783
+			}
784
+		}
785
+		else
786
+		{
787
+			$action = ($action=='add'?'create':'edit');
788
+		}
789
+	}
790
+
791
+	// Delete third party
792
+	if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
793
+	{
794
+		$object->fetch($socid);
795
+		$result = $object->delete($socid, $user);
796
+
797
+		if ($result > 0)
798
+		{
799
+			header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name));
800
+			exit;
801
+		}
802
+		else
803
+		{
804
+			$langs->load("errors");
805
+		   	setEventMessages($object->error, $object->errors, 'errors');
806
+		   	$error++;
807
+			$action='';
808
+		}
809
+	}
810
+
811
+	// Set parent company
812
+	if ($action == 'set_thirdparty' && $user->rights->societe->creer)
813
+	{
814
+		$object->fetch($socid);
815
+		$result = $object->set_parent(GETPOST('editparentcompany','int'));
816
+	}
817
+
818
+	// Set incoterm
819
+	if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
820
+	{
821
+		$object->fetch($socid);
822
+		$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
823
+	}
824
+
825
+	// Actions to send emails
826
+	$id=$socid;
827
+	$trigger_name='COMPANY_SENTBYMAIL';
828
+	$paramname='socid';
829
+	$mode='emailfromthirdparty';
830
+	$trackid='thi'.$object->id;
831
+	include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
832
+
833
+	// Actions to build doc
834
+	$id = $socid;
835
+	$upload_dir = $conf->societe->dir_output;
836
+	$permissioncreate=$user->rights->societe->creer;
837
+	include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
838 838
 }
839 839
 
840 840
 
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
 if ($socid > 0 && empty($object->id))
851 851
 {
852
-    $result=$object->fetch($socid);
852
+	$result=$object->fetch($socid);
853 853
 	if ($result <= 0) dol_print_error('',$object->error);
854 854
 }
855 855
 
@@ -862,161 +862,161 @@  discard block
 block discarded – undo
862 862
 
863 863
 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
864 864
 {
865
-    // -----------------------------------------
866
-    // When used with CANVAS
867
-    // -----------------------------------------
865
+	// -----------------------------------------
866
+	// When used with CANVAS
867
+	// -----------------------------------------
868 868
    	$objcanvas->assign_values($action, $object->id, $object->ref);	// Set value for templates
869
-    $objcanvas->display_canvas($action);							// Show template
869
+	$objcanvas->display_canvas($action);							// Show template
870 870
 }
871 871
 else
872 872
 {
873
-    // -----------------------------------------
874
-    // When used in standard mode
875
-    // -----------------------------------------
876
-    if ($action == 'create')
877
-    {
878
-        /*
873
+	// -----------------------------------------
874
+	// When used in standard mode
875
+	// -----------------------------------------
876
+	if ($action == 'create')
877
+	{
878
+		/*
879 879
          *  Creation
880 880
          */
881 881
 		$private=GETPOST("private","int");
882 882
 		if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1;
883
-    	if (empty($private)) $private=0;
884
-
885
-        // Load object modCodeTiers
886
-        $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
887
-        if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
888
-        {
889
-            $module = substr($module, 0, dol_strlen($module)-4);
890
-        }
891
-        $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
892
-        foreach ($dirsociete as $dirroot)
893
-        {
894
-            $res=dol_include_once($dirroot.$module.'.php');
895
-            if ($res) break;
896
-        }
897
-        $modCodeClient = new $module;
898
-        // Load object modCodeFournisseur
899
-        $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
900
-        if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
901
-        {
902
-            $module = substr($module, 0, dol_strlen($module)-4);
903
-        }
904
-        $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
905
-        foreach ($dirsociete as $dirroot)
906
-        {
907
-            $res=dol_include_once($dirroot.$module.'.php');
908
-            if ($res) break;
909
-        }
910
-        $modCodeFournisseur = new $module;
911
-
912
-        // Define if customer/prospect or supplier status is set or not
913
-        if (GETPOST("type")!='f')
914
-        {
915
-            $object->client=-1;
916
-            if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT))  { $object->client=3; }
917
-        }
918
-        if (GETPOST("type")=='c')  { $object->client=3; }   // Prospect / Customer
919
-        if (GETPOST("type")=='p')  { $object->client=2; }
920
-        if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT))))  { $object->fournisseur=1; }
921
-
922
-        $object->name				= GETPOST('name', 'alpha');
923
-        $object->firstname			= GETPOST('firstname', 'alpha');
924
-        $object->particulier		= $private;
925
-        $object->prefix_comm		= GETPOST('prefix_comm');
926
-        $object->client				= GETPOST('client')?GETPOST('client'):$object->client;
927
-
928
-        if(empty($duplicate_code_error)) {
929
-	        $object->code_client		= GETPOST('code_client', 'alpha');
930
-	        $object->fournisseur		= GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur;
931
-        }
883
+		if (empty($private)) $private=0;
884
+
885
+		// Load object modCodeTiers
886
+		$module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
887
+		if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
888
+		{
889
+			$module = substr($module, 0, dol_strlen($module)-4);
890
+		}
891
+		$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
892
+		foreach ($dirsociete as $dirroot)
893
+		{
894
+			$res=dol_include_once($dirroot.$module.'.php');
895
+			if ($res) break;
896
+		}
897
+		$modCodeClient = new $module;
898
+		// Load object modCodeFournisseur
899
+		$module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
900
+		if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
901
+		{
902
+			$module = substr($module, 0, dol_strlen($module)-4);
903
+		}
904
+		$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
905
+		foreach ($dirsociete as $dirroot)
906
+		{
907
+			$res=dol_include_once($dirroot.$module.'.php');
908
+			if ($res) break;
909
+		}
910
+		$modCodeFournisseur = new $module;
911
+
912
+		// Define if customer/prospect or supplier status is set or not
913
+		if (GETPOST("type")!='f')
914
+		{
915
+			$object->client=-1;
916
+			if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT))  { $object->client=3; }
917
+		}
918
+		if (GETPOST("type")=='c')  { $object->client=3; }   // Prospect / Customer
919
+		if (GETPOST("type")=='p')  { $object->client=2; }
920
+		if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT))))  { $object->fournisseur=1; }
921
+
922
+		$object->name				= GETPOST('name', 'alpha');
923
+		$object->firstname			= GETPOST('firstname', 'alpha');
924
+		$object->particulier		= $private;
925
+		$object->prefix_comm		= GETPOST('prefix_comm');
926
+		$object->client				= GETPOST('client')?GETPOST('client'):$object->client;
927
+
928
+		if(empty($duplicate_code_error)) {
929
+			$object->code_client		= GETPOST('code_client', 'alpha');
930
+			$object->fournisseur		= GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur;
931
+		}
932 932
 		else {
933 933
 			setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings');
934 934
 		}
935 935
 
936
-        $object->code_fournisseur	= GETPOST('code_fournisseur', 'alpha');
937
-        $object->address			= GETPOST('address', 'alpha');
938
-        $object->zip				= GETPOST('zipcode', 'alpha');
939
-        $object->town				= GETPOST('town', 'alpha');
940
-        $object->state_id			= GETPOST('state_id', 'int');
941
-        $object->skype				= GETPOST('skype', 'alpha');
942
-        $object->phone				= GETPOST('phone', 'alpha');
943
-        $object->fax				= GETPOST('fax', 'alpha');
944
-        $object->email				= GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
945
-        $object->url				= GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
946
-        $object->capital			= GETPOST('capital', 'alpha');
947
-        $object->barcode			= GETPOST('barcode', 'alpha');
948
-        $object->idprof1			= GETPOST('idprof1', 'alpha');
949
-        $object->idprof2			= GETPOST('idprof2', 'alpha');
950
-        $object->idprof3			= GETPOST('idprof3', 'alpha');
951
-        $object->idprof4			= GETPOST('idprof4', 'alpha');
952
-        $object->idprof5			= GETPOST('idprof5', 'alpha');
953
-        $object->idprof6			= GETPOST('idprof6', 'alpha');
954
-        $object->typent_id			= GETPOST('typent_id', 'int');
955
-        $object->effectif_id		= GETPOST('effectif_id', 'int');
956
-        $object->civility_id		= GETPOST('civility_id', 'int');
957
-
958
-        $object->tva_assuj			= GETPOST('assujtva_value', 'int');
959
-        $object->status				= GETPOST('status', 'int');
960
-
961
-        //Local Taxes
962
-        $object->localtax1_assuj	= GETPOST('localtax1assuj_value', 'int');
963
-        $object->localtax2_assuj	= GETPOST('localtax2assuj_value', 'int');
964
-
965
-        $object->localtax1_value	=GETPOST('lt1', 'int');
966
-        $object->localtax2_value	=GETPOST('lt2', 'int');
967
-
968
-        $object->tva_intra			= GETPOST('tva_intra', 'alpha');
969
-
970
-        $object->commercial_id		= GETPOST('commercial_id', 'int');
971
-        $object->default_lang		= GETPOST('default_lang');
972
-
973
-        $object->logo = (isset($_FILES['photo'])?dol_sanitizeFileName($_FILES['photo']['name']):'');
974
-
975
-        // Gestion du logo de la société
976
-        $dir     = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
977
-        $file_OK = (isset($_FILES['photo'])?is_uploaded_file($_FILES['photo']['tmp_name']):false);
978
-        if ($file_OK)
979
-        {
980
-            if (image_format_supported($_FILES['photo']['name']))
981
-            {
982
-                dol_mkdir($dir);
983
-
984
-                if (@is_dir($dir))
985
-                {
986
-                    $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
987
-                    $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
988
-
989
-                    if (! $result > 0)
990
-                    {
991
-                        $errors[] = "ErrorFailedToSaveFile";
992
-                    }
993
-                    else
994
-                    {
995
-                        // Create thumbs
996
-                        $object->addThumbs($newfile);
997
-                    }
998
-                }
999
-            }
1000
-        }
1001
-
1002
-        // We set country_id, country_code and country for the selected country
1003
-        $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id;
1004
-        if ($object->country_id)
1005
-        {
1006
-            $tmparray=getCountry($object->country_id,'all');
1007
-            $object->country_code=$tmparray['code'];
1008
-            $object->country=$tmparray['label'];
1009
-        }
1010
-        $object->forme_juridique_code=GETPOST('forme_juridique_code');
1011
-        /* Show create form */
1012
-
1013
-        $linkback="";
1014
-        print load_fiche_titre($langs->trans("NewThirdParty"),$linkback,'title_companies.png');
1015
-
1016
-        if (! empty($conf->use_javascript_ajax))
1017
-        {
1018
-            print "\n".'<script type="text/javascript">';
1019
-            print '$(document).ready(function () {
936
+		$object->code_fournisseur	= GETPOST('code_fournisseur', 'alpha');
937
+		$object->address			= GETPOST('address', 'alpha');
938
+		$object->zip				= GETPOST('zipcode', 'alpha');
939
+		$object->town				= GETPOST('town', 'alpha');
940
+		$object->state_id			= GETPOST('state_id', 'int');
941
+		$object->skype				= GETPOST('skype', 'alpha');
942
+		$object->phone				= GETPOST('phone', 'alpha');
943
+		$object->fax				= GETPOST('fax', 'alpha');
944
+		$object->email				= GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
945
+		$object->url				= GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
946
+		$object->capital			= GETPOST('capital', 'alpha');
947
+		$object->barcode			= GETPOST('barcode', 'alpha');
948
+		$object->idprof1			= GETPOST('idprof1', 'alpha');
949
+		$object->idprof2			= GETPOST('idprof2', 'alpha');
950
+		$object->idprof3			= GETPOST('idprof3', 'alpha');
951
+		$object->idprof4			= GETPOST('idprof4', 'alpha');
952
+		$object->idprof5			= GETPOST('idprof5', 'alpha');
953
+		$object->idprof6			= GETPOST('idprof6', 'alpha');
954
+		$object->typent_id			= GETPOST('typent_id', 'int');
955
+		$object->effectif_id		= GETPOST('effectif_id', 'int');
956
+		$object->civility_id		= GETPOST('civility_id', 'int');
957
+
958
+		$object->tva_assuj			= GETPOST('assujtva_value', 'int');
959
+		$object->status				= GETPOST('status', 'int');
960
+
961
+		//Local Taxes
962
+		$object->localtax1_assuj	= GETPOST('localtax1assuj_value', 'int');
963
+		$object->localtax2_assuj	= GETPOST('localtax2assuj_value', 'int');
964
+
965
+		$object->localtax1_value	=GETPOST('lt1', 'int');
966
+		$object->localtax2_value	=GETPOST('lt2', 'int');
967
+
968
+		$object->tva_intra			= GETPOST('tva_intra', 'alpha');
969
+
970
+		$object->commercial_id		= GETPOST('commercial_id', 'int');
971
+		$object->default_lang		= GETPOST('default_lang');
972
+
973
+		$object->logo = (isset($_FILES['photo'])?dol_sanitizeFileName($_FILES['photo']['name']):'');
974
+
975
+		// Gestion du logo de la société
976
+		$dir     = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
977
+		$file_OK = (isset($_FILES['photo'])?is_uploaded_file($_FILES['photo']['tmp_name']):false);
978
+		if ($file_OK)
979
+		{
980
+			if (image_format_supported($_FILES['photo']['name']))
981
+			{
982
+				dol_mkdir($dir);
983
+
984
+				if (@is_dir($dir))
985
+				{
986
+					$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
987
+					$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
988
+
989
+					if (! $result > 0)
990
+					{
991
+						$errors[] = "ErrorFailedToSaveFile";
992
+					}
993
+					else
994
+					{
995
+						// Create thumbs
996
+						$object->addThumbs($newfile);
997
+					}
998
+				}
999
+			}
1000
+		}
1001
+
1002
+		// We set country_id, country_code and country for the selected country
1003
+		$object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id;
1004
+		if ($object->country_id)
1005
+		{
1006
+			$tmparray=getCountry($object->country_id,'all');
1007
+			$object->country_code=$tmparray['code'];
1008
+			$object->country=$tmparray['label'];
1009
+		}
1010
+		$object->forme_juridique_code=GETPOST('forme_juridique_code');
1011
+		/* Show create form */
1012
+
1013
+		$linkback="";
1014
+		print load_fiche_titre($langs->trans("NewThirdParty"),$linkback,'title_companies.png');
1015
+
1016
+		if (! empty($conf->use_javascript_ajax))
1017
+		{
1018
+			print "\n".'<script type="text/javascript">';
1019
+			print '$(document).ready(function () {
1020 1020
 						id_te_private=8;
1021 1021
                         id_ef15=1;
1022 1022
                         is_private='.$private.';
@@ -1044,494 +1044,494 @@  discard block
 block discarded – undo
1044 1044
                         	document.formsoc.submit();
1045 1045
                         });
1046 1046
                      });';
1047
-            print '</script>'."\n";
1048
-
1049
-            print '<div id="selectthirdpartytype">';
1050
-            print '<div class="hideonsmartphone float">';
1051
-            print $langs->trans("ThirdPartyType").': &nbsp; &nbsp; ';
1052
-            print '</div>';
1053
-	        print '<label for="radiocompany" class="radiocompany">';
1054
-            print '<input type="radio" id="radiocompany" class="flat" name="private"  value="0"'.($private?'':' checked').'>';
1055
-	        print '&nbsp;';
1056
-            print $langs->trans("CreateThirdPartyOnly");
1057
-	        print '</label>';
1058
-            print ' &nbsp; &nbsp; ';
1059
-	        print '<label for="radioprivate" class="radioprivate">';
1060
-            $text ='<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private?' checked':'').'>';
1061
-	        $text.='&nbsp;';
1062
-	        $text.= $langs->trans("CreateThirdPartyAndContact");
1063
-	        $htmltext=$langs->trans("ToCreateContactWithSameName");
1064
-	        print $form->textwithpicto($text, $htmltext, 1, 'help', '', 0, 3);
1065
-            print '</label>';
1066
-            print '</div>';
1067
-            print "<br>\n";
1068
-        }
1069
-
1070
-        dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
1071
-
1072
-        print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">';		// Chrome ignor autocomplete
1073
-
1074
-        print '<input type="hidden" name="action" value="add">';
1075
-        print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1076
-        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1077
-        print '<input type="hidden" name="private" value='.$object->particulier.'>';
1078
-        print '<input type="hidden" name="type" value='.GETPOST("type",'alpha').'>';
1079
-        print '<input type="hidden" name="LastName" value="'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName').'">';
1080
-        print '<input type="hidden" name="ThirdPartyName" value="'.$langs->trans('ThirdPartyName').'">';
1081
-        if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1082
-
1083
-        dol_fiche_head(null, 'card', '', 0, '');
1084
-
1085
-        print '<table class="border" width="100%">';
1086
-
1087
-        // Name, firstname
1088
-	    print '<tr><td class="titlefieldcreate">';
1089
-        if ($object->particulier || $private)
1090
-        {
1091
-	        print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').'</span>';
1092
-        }
1093
-        else
1047
+			print '</script>'."\n";
1048
+
1049
+			print '<div id="selectthirdpartytype">';
1050
+			print '<div class="hideonsmartphone float">';
1051
+			print $langs->trans("ThirdPartyType").': &nbsp; &nbsp; ';
1052
+			print '</div>';
1053
+			print '<label for="radiocompany" class="radiocompany">';
1054
+			print '<input type="radio" id="radiocompany" class="flat" name="private"  value="0"'.($private?'':' checked').'>';
1055
+			print '&nbsp;';
1056
+			print $langs->trans("CreateThirdPartyOnly");
1057
+			print '</label>';
1058
+			print ' &nbsp; &nbsp; ';
1059
+			print '<label for="radioprivate" class="radioprivate">';
1060
+			$text ='<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private?' checked':'').'>';
1061
+			$text.='&nbsp;';
1062
+			$text.= $langs->trans("CreateThirdPartyAndContact");
1063
+			$htmltext=$langs->trans("ToCreateContactWithSameName");
1064
+			print $form->textwithpicto($text, $htmltext, 1, 'help', '', 0, 3);
1065
+			print '</label>';
1066
+			print '</div>';
1067
+			print "<br>\n";
1068
+		}
1069
+
1070
+		dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
1071
+
1072
+		print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">';		// Chrome ignor autocomplete
1073
+
1074
+		print '<input type="hidden" name="action" value="add">';
1075
+		print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1076
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1077
+		print '<input type="hidden" name="private" value='.$object->particulier.'>';
1078
+		print '<input type="hidden" name="type" value='.GETPOST("type",'alpha').'>';
1079
+		print '<input type="hidden" name="LastName" value="'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName').'">';
1080
+		print '<input type="hidden" name="ThirdPartyName" value="'.$langs->trans('ThirdPartyName').'">';
1081
+		if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1082
+
1083
+		dol_fiche_head(null, 'card', '', 0, '');
1084
+
1085
+		print '<table class="border" width="100%">';
1086
+
1087
+		// Name, firstname
1088
+		print '<tr><td class="titlefieldcreate">';
1089
+		if ($object->particulier || $private)
1090
+		{
1091
+			print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').'</span>';
1092
+		}
1093
+		else
1094 1094
 		{
1095 1095
 			print '<span id="TypeName" class="fieldrequired">'.fieldLabel('ThirdPartyName','name').'</span>';
1096
-        }
1097
-	    print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>';
1098
-	    print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.$object->name.'" autofocus="autofocus"></td>';
1099
-	    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
1100
-	    {
1101
-		    print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'"></td>';
1102
-	    }
1103
-	    print '</tr>';
1104
-
1105
-        // If javascript on, we show option individual
1106
-        if ($conf->use_javascript_ajax)
1107
-        {
1108
-            print '<tr class="individualline"><td>'.fieldLabel('FirstName','firstname').'</td>';
1109
-	        print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.$object->firstname.'"></td>';
1110
-            print '</tr>';
1111
-            // Title
1112
-            print '<tr class="individualline"><td>'.fieldLabel('UserTitle','civility_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1113
-            print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'</td>';
1114
-            print '</tr>';
1115
-        }
1116
-
1117
-        // Alias names (commercial, trademark or alias names)
1118
-        print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1119
-	    print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.$object->name_alias.'"></td></tr>';
1120
-
1121
-        // Prospect/Customer
1122
-        print '<tr><td class="titlefieldcreate">'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>';
1123
-	    print '<td class="maxwidthonsmartphone">';
1124
-	    $selected=GETPOST('client','int')!=''?GETPOST('client','int'):$object->client;
1125
-        print '<select class="flat" name="client" id="customerprospect">';
1126
-        if (GETPOST("type") == '') print '<option value="-1">&nbsp;</option>';
1127
-        if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1128
-        if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
1129
-        if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
1130
-        print '<option value="0"'.((string) $selected == '0'?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
1131
-        print '</select></td>';
1132
-
1133
-        print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>';
1134
-        print '<table class="nobordernopadding"><tr><td>';
1135
-		$tmpcode=$object->code_client;
1136
-        if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0);
1137
-        print '<input type="text" name="code_client" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1138
-        print '</td><td>';
1139
-        $s=$modCodeClient->getToolTip($langs,$object,0);
1140
-        print $form->textwithpicto('',$s,1);
1141
-        print '</td></tr></table>';
1142
-        print '</td></tr>';
1143
-
1144
-        if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire))
1145
-        {
1146
-            // Supplier
1147
-            print '<tr>';
1148
-            print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td>';
1149
-            $default = -1;
1150
-            if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1;
1151
-            print $form->selectyesno("fournisseur", (GETPOST('fournisseur','int')!=''?GETPOST('fournisseur','int'):(GETPOST("type",'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type",'alpha') == '' ? 1 : 0));
1152
-            print '</td>';
1153
-            print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>';
1154
-            print '<table class="nobordernopadding"><tr><td>';
1155
-            $tmpcode=$object->code_fournisseur;
1156
-            if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1);
1157
-            print '<input type="text" name="code_fournisseur" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1158
-            print '</td><td>';
1159
-            $s=$modCodeFournisseur->getToolTip($langs,$object,1);
1160
-            print $form->textwithpicto('',$s,1);
1161
-            print '</td></tr></table>';
1162
-            print '</td></tr>';
1163
-        }
1164
-
1165
-        // Status
1166
-        print '<tr><td>'.fieldLabel('Status','status').'</td><td colspan="3">';
1167
-        print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),1);
1168
-        print '</td></tr>';
1169
-
1170
-        // Barcode
1171
-        if (! empty($conf->barcode->enabled))
1172
-        {
1173
-            print '<tr><td>'.fieldLabel('Gencod','barcode').'</td>';
1174
-	        print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.$object->barcode.'">';
1175
-            print '</td></tr>';
1176
-        }
1177
-
1178
-        // Address
1179
-        print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
1180
-	    print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="'._ROWS_2.'" wrap="soft">';
1181
-        print $object->address;
1182
-        print '</textarea></td></tr>';
1183
-
1184
-        // Zip / Town
1185
-        print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
1186
-        print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
1187
-        print '</td><td>'.fieldLabel('Town','town').'</td><td>';
1188
-        print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
1189
-        print '</td></tr>';
1190
-
1191
-        // Country
1192
-        print '<tr><td>'.fieldLabel('Country','selectcountry_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1193
-        print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id));
1194
-        if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1195
-        print '</td></tr>';
1196
-
1197
-        // State
1198
-        if (empty($conf->global->SOCIETE_DISABLE_STATE))
1199
-        {
1200
-            if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1201
-            {
1202
-                print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1203
-            }
1204
-            else
1205
-            {
1206
-                print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1207
-            }
1208
-
1209
-            if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code);
1210
-            else print $countrynotdefined;
1211
-            print '</td></tr>';
1212
-        }
1213
-
1214
-        // Email web
1215
-        print '<tr><td>'.fieldLabel('EMail','email',$conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
1216
-	    print '<td colspan="3"><input type="text" name="email" id="email" value="'.$object->email.'"></td></tr>';
1217
-        print '<tr><td>'.fieldLabel('Web','url').'</td>';
1218
-	    print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>';
1219
-
1220
-        // Skype
1221
-        if (! empty($conf->skype->enabled))
1222
-        {
1223
-            print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
1224
-	        print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
1225
-        }
1226
-
1227
-        // Phone / Fax
1228
-        print '<tr><td>'.fieldLabel('Phone','phone').'</td>';
1229
-	    print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->phone.'"></td>';
1230
-        print '<td>'.fieldLabel('Fax','fax').'</td>';
1231
-	    print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->fax.'"></td></tr>';
1232
-
1233
-        // Prof ids
1234
-        $i=1; $j=0;
1235
-        while ($i <= 6)
1236
-        {
1237
-            $idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
1238
-            if ($idprof!='-')
1239
-            {
1240
-	            $key='idprof'.$i;
1241
-
1242
-                if (($j % 2) == 0) print '<tr>';
1243
-
1244
-                $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
1245
-                print '<td>'.fieldLabel($idprof,$key, (empty($conf->global->$idprof_mandatory)?0:1)).'</td><td>';
1246
-
1247
-                print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1248
-                print '</td>';
1249
-                if (($j % 2) == 1) print '</tr>';
1250
-                $j++;
1251
-            }
1252
-            $i++;
1253
-        }
1254
-        if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
1255
-
1256
-        // Vat is used
1257
-        print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td>';
1258
-        print '<td>';
1259
-        print $form->selectyesno('assujtva_value',(isset($conf->global->THIRDPARTY_DEFAULT_USEVAT)?$conf->global->THIRDPARTY_DEFAULT_USEVAT:1),1);     // Assujeti par defaut en creation
1260
-        print '</td>';
1261
-        print '<td class="nowrap">'.fieldLabel('VATIntra','intra_vat').'</td>';
1262
-        print '<td class="nowrap">';
1263
-        $s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1264
-
1265
-        if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
1266
-        {
1267
-            $s.=' ';
1268
-
1269
-            if (! empty($conf->use_javascript_ajax))
1270
-            {
1271
-                print "\n";
1272
-                print '<script language="JavaScript" type="text/javascript">';
1273
-                print "function CheckVAT(a) {\n";
1274
-                print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,300);\n";
1275
-                print "}\n";
1276
-                print '</script>';
1277
-                print "\n";
1278
-                $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1279
-                $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
1280
-            }
1281
-            else
1282
-            {
1283
-                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
1284
-            }
1285
-        }
1286
-        print $s;
1287
-        print '</td>';
1288
-        print '</tr>';
1289
-
1290
-        // Local Taxes
1291
-        //TODO: Place into a function to control showing by country or study better option
1292
-        if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
1293
-        {
1294
-            print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
1295
-            print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1);
1296
-            print '</td><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
1297
-            print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1);
1298
-            print '</td></tr>';
1299
-
1300
-        }
1301
-        elseif($mysoc->localtax1_assuj=="1")
1302
-        {
1303
-            print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
1304
-            print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1);
1305
-            print '</td></tr>';
1306
-        }
1307
-        elseif($mysoc->localtax2_assuj=="1")
1308
-        {
1309
-            print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
1310
-            print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1);
1311
-            print '</td></tr>';
1312
-        }
1313
-
1314
-        // Type - Size
1315
-        print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">'."\n";
1316
-        $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
1317
-        print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam);
1318
-        if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1319
-        print '</td>';
1320
-        print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">';
1321
-        print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id);
1322
-        if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1323
-        print '</td></tr>';
1324
-
1325
-        // Legal Form
1326
-        print '<tr><td>'.fieldLabel('JuridicalStatus','forme_juridique_code').'</td>';
1327
-        print '<td colspan="3" class="maxwidthonsmartphone">';
1328
-        if ($object->country_id)
1329
-        {
1330
-            print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1331
-        }
1332
-        else
1333
-        {
1334
-            print $countrynotdefined;
1335
-        }
1336
-        print '</td></tr>';
1337
-
1338
-        // Capital
1339
-        print '<tr><td>'.fieldLabel('Capital','capital').'</td>';
1340
-	    print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="'.$object->capital.'"> ';
1341
-        print '<span class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
1342
-
1343
-        if (! empty($conf->global->MAIN_MULTILANGS))
1344
-        {
1345
-            print '<tr><td>'.fieldLabel('DefaultLang','default_lang').'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
1346
-            print $formadmin->select_language(($object->default_lang?$object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1,0,0,'maxwidth200onsmartphone');
1347
-            print '</td>';
1348
-            print '</tr>';
1349
-        }
1350
-
1351
-        if ($user->rights->societe->client->voir)
1352
-        {
1353
-            // Assign a Name
1354
-            print '<tr>';
1355
-            print '<td>'.fieldLabel('AllocateCommercial','commercial_id').'</td>';
1356
-            print '<td colspan="3" class="maxwidthonsmartphone">';
1357
-            print $form->select_dolusers((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default
1358
-            print '</td></tr>';
1359
-        }
1096
+		}
1097
+		print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>';
1098
+		print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.$object->name.'" autofocus="autofocus"></td>';
1099
+		if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
1100
+		{
1101
+			print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'"></td>';
1102
+		}
1103
+		print '</tr>';
1360 1104
 
1361
-		// Incoterms
1362
-		if (!empty($conf->incoterm->enabled))
1105
+		// If javascript on, we show option individual
1106
+		if ($conf->use_javascript_ajax)
1107
+		{
1108
+			print '<tr class="individualline"><td>'.fieldLabel('FirstName','firstname').'</td>';
1109
+			print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.$object->firstname.'"></td>';
1110
+			print '</tr>';
1111
+			// Title
1112
+			print '<tr class="individualline"><td>'.fieldLabel('UserTitle','civility_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1113
+			print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'</td>';
1114
+			print '</tr>';
1115
+		}
1116
+
1117
+		// Alias names (commercial, trademark or alias names)
1118
+		print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1119
+		print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.$object->name_alias.'"></td></tr>';
1120
+
1121
+		// Prospect/Customer
1122
+		print '<tr><td class="titlefieldcreate">'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>';
1123
+		print '<td class="maxwidthonsmartphone">';
1124
+		$selected=GETPOST('client','int')!=''?GETPOST('client','int'):$object->client;
1125
+		print '<select class="flat" name="client" id="customerprospect">';
1126
+		if (GETPOST("type") == '') print '<option value="-1">&nbsp;</option>';
1127
+		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1128
+		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
1129
+		if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
1130
+		print '<option value="0"'.((string) $selected == '0'?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
1131
+		print '</select></td>';
1132
+
1133
+		print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>';
1134
+		print '<table class="nobordernopadding"><tr><td>';
1135
+		$tmpcode=$object->code_client;
1136
+		if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0);
1137
+		print '<input type="text" name="code_client" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1138
+		print '</td><td>';
1139
+		$s=$modCodeClient->getToolTip($langs,$object,0);
1140
+		print $form->textwithpicto('',$s,1);
1141
+		print '</td></tr></table>';
1142
+		print '</td></tr>';
1143
+
1144
+		if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire))
1363 1145
 		{
1146
+			// Supplier
1364 1147
 			print '<tr>';
1365
-			print '<td>'.fieldLabel('IncotermLabel','incoterm_id').'</td>';
1366
-	        print '<td colspan="3" class="maxwidthonsmartphone">';
1367
-	        print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
1148
+			print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td>';
1149
+			$default = -1;
1150
+			if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1;
1151
+			print $form->selectyesno("fournisseur", (GETPOST('fournisseur','int')!=''?GETPOST('fournisseur','int'):(GETPOST("type",'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type",'alpha') == '' ? 1 : 0));
1152
+			print '</td>';
1153
+			print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>';
1154
+			print '<table class="nobordernopadding"><tr><td>';
1155
+			$tmpcode=$object->code_fournisseur;
1156
+			if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1);
1157
+			print '<input type="text" name="code_fournisseur" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1158
+			print '</td><td>';
1159
+			$s=$modCodeFournisseur->getToolTip($langs,$object,1);
1160
+			print $form->textwithpicto('',$s,1);
1161
+			print '</td></tr></table>';
1368 1162
 			print '</td></tr>';
1369 1163
 		}
1370 1164
 
1371
-		// Categories
1372
-		if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
1165
+		// Status
1166
+		print '<tr><td>'.fieldLabel('Status','status').'</td><td colspan="3">';
1167
+		print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),1);
1168
+		print '</td></tr>';
1169
+
1170
+		// Barcode
1171
+		if (! empty($conf->barcode->enabled))
1373 1172
 		{
1374
-			$langs->load('categories');
1173
+			print '<tr><td>'.fieldLabel('Gencod','barcode').'</td>';
1174
+			print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.$object->barcode.'">';
1175
+			print '</td></tr>';
1176
+		}
1375 1177
 
1376
-			// Customer
1377
-			if ($object->prospect || $object->client) {
1378
-				print '<tr><td class="toptd">' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td><td colspan="3">';
1379
-				$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
1380
-				print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null,
1381
-					null, "90%");
1382
-				print "</td></tr>";
1178
+		// Address
1179
+		print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
1180
+		print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="'._ROWS_2.'" wrap="soft">';
1181
+		print $object->address;
1182
+		print '</textarea></td></tr>';
1183
+
1184
+		// Zip / Town
1185
+		print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
1186
+		print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
1187
+		print '</td><td>'.fieldLabel('Town','town').'</td><td>';
1188
+		print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
1189
+		print '</td></tr>';
1190
+
1191
+		// Country
1192
+		print '<tr><td>'.fieldLabel('Country','selectcountry_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1193
+		print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id));
1194
+		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1195
+		print '</td></tr>';
1196
+
1197
+		// State
1198
+		if (empty($conf->global->SOCIETE_DISABLE_STATE))
1199
+		{
1200
+			if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1201
+			{
1202
+				print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1383 1203
 			}
1384
-
1385
-			// Supplier
1386
-			if ($object->fournisseur) {
1387
-				print '<tr><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
1388
-				$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1);
1389
-				print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null,
1390
-					null, "90%");
1391
-				print "</td></tr>";
1204
+			else
1205
+			{
1206
+				print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">';
1392 1207
 			}
1393
-		}
1394 1208
 
1395
-		// Multicurrency
1396
-		if (! empty($conf->multicurrency->enabled))
1397
-		{
1398
-			print '<tr>';
1399
-			print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
1400
-	        print '<td colspan="3" class="maxwidthonsmartphone">';
1401
-	        print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
1209
+			if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code);
1210
+			else print $countrynotdefined;
1402 1211
 			print '</td></tr>';
1403 1212
 		}
1404 1213
 
1405
-        // Other attributes
1406
-        $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
1407
-        $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
1408
-        print $hookmanager->resPrint;
1409
-        if (empty($reshook) && ! empty($extrafields->attribute_label))
1410
-        {
1411
-        	print $object->showOptionals($extrafields,'edit');
1412
-        }
1413
-
1414
-        // Ajout du logo
1415
-        print '<tr class="hideonsmartphone">';
1416
-        print '<td>'.fieldLabel('Logo','photoinput').'</td>';
1417
-        print '<td colspan="3">';
1418
-        print '<input class="flat" type="file" name="photo" id="photoinput" />';
1419
-        print '</td>';
1420
-        print '</tr>';
1421
-
1422
-        print '</table>'."\n";
1423
-
1424
-        dol_fiche_end();
1425
-
1426
-        print '<div class="center">';
1427
-        print '<input type="submit" class="button" name="create" value="'.$langs->trans('AddThirdParty').'">';
1428
-        if (! empty($backtopage))
1429
-        {
1430
-            print ' &nbsp; &nbsp; ';
1431
-            print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
1432
-        }
1433
-        else
1434
-        {
1435
-            print ' &nbsp; &nbsp; ';
1436
-            print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1437
-        }
1438
-        print '</div>'."\n";
1439
-
1440
-        print '</form>'."\n";
1441
-    }
1442
-    elseif ($action == 'edit')
1443
-    {
1444
-        /*
1445
-         * Edition
1446
-         */
1214
+		// Email web
1215
+		print '<tr><td>'.fieldLabel('EMail','email',$conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
1216
+		print '<td colspan="3"><input type="text" name="email" id="email" value="'.$object->email.'"></td></tr>';
1217
+		print '<tr><td>'.fieldLabel('Web','url').'</td>';
1218
+		print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>';
1447 1219
 
1220
+		// Skype
1221
+		if (! empty($conf->skype->enabled))
1222
+		{
1223
+			print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
1224
+			print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
1225
+		}
1448 1226
 
1449
-        //print load_fiche_titre($langs->trans("EditCompany"));
1450
-
1451
-        if ($socid)
1452
-        {
1453
-        	$res=$object->fetch_optionals();
1454
-            //if ($res < 0) { dol_print_error($db); exit; }
1455
-
1456
-	        $head = societe_prepare_head($object);
1457
-
1458
-            // Load object modCodeTiers
1459
-            $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
1460
-            if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1461
-            {
1462
-                $module = substr($module, 0, dol_strlen($module)-4);
1463
-            }
1464
-            $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
1465
-            foreach ($dirsociete as $dirroot)
1466
-            {
1467
-                $res=dol_include_once($dirroot.$module.'.php');
1468
-                if ($res) break;
1469
-            }
1470
-            $modCodeClient = new $module($db);
1471
-            // We verified if the tag prefix is used
1472
-            if ($modCodeClient->code_auto)
1473
-            {
1474
-                $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1475
-            }
1476
-            $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
1477
-            if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1478
-            {
1479
-                $module = substr($module, 0, dol_strlen($module)-4);
1480
-            }
1481
-            $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
1482
-            foreach ($dirsociete as $dirroot)
1483
-            {
1484
-                $res=dol_include_once($dirroot.$module.'.php');
1485
-                if ($res) break;
1486
-            }
1487
-            $modCodeFournisseur = new $module($db);
1488
-            // On verifie si la balise prefix est utilisee
1489
-            if ($modCodeFournisseur->code_auto)
1490
-            {
1491
-                $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1492
-            }
1227
+		// Phone / Fax
1228
+		print '<tr><td>'.fieldLabel('Phone','phone').'</td>';
1229
+		print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->phone.'"></td>';
1230
+		print '<td>'.fieldLabel('Fax','fax').'</td>';
1231
+		print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->fax.'"></td></tr>';
1493 1232
 
1494
-			$object->oldcopy = clone $object;
1233
+		// Prof ids
1234
+		$i=1; $j=0;
1235
+		while ($i <= 6)
1236
+		{
1237
+			$idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
1238
+			if ($idprof!='-')
1239
+			{
1240
+				$key='idprof'.$i;
1495 1241
 
1496
-            if (GETPOSTISSET('name'))
1497
-            {
1498
-                // We overwrite with values if posted
1499
-                $object->name					= GETPOST('name', 'alpha');
1500
-                $object->prefix_comm			= GETPOST('prefix_comm', 'alpha');
1501
-                $object->client					= GETPOST('client', 'int');
1502
-                $object->code_client			= GETPOST('code_client', 'alpha');
1503
-                $object->fournisseur			= GETPOST('fournisseur', 'int');
1504
-                $object->code_fournisseur		= GETPOST('code_fournisseur', 'alpha');
1505
-                $object->address				= GETPOST('address', 'alpha');
1506
-                $object->zip					= GETPOST('zipcode', 'alpha');
1507
-                $object->town					= GETPOST('town', 'alpha');
1508
-                $object->country_id				= GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id;
1509
-                $object->state_id				= GETPOST('state_id', 'int');
1510
-                $object->skype					= GETPOST('skype', 'alpha');
1511
-                $object->phone					= GETPOST('phone', 'alpha');
1512
-                $object->fax					= GETPOST('fax', 'alpha');
1513
-                $object->email					= GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
1514
-                $object->url					= GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
1515
-                $object->capital				= GETPOST('capital', 'alpha');
1516
-                $object->idprof1				= GETPOST('idprof1', 'alpha');
1517
-                $object->idprof2				= GETPOST('idprof2', 'alpha');
1518
-                $object->idprof3				= GETPOST('idprof3', 'alpha');
1519
-                $object->idprof4				= GETPOST('idprof4', 'alpha');
1520
-                $object->idprof5				= GETPOST('idprof5', 'alpha');
1521
-                $object->idprof6				= GETPOST('idprof6', 'alpha');
1522
-                $object->typent_id				= GETPOST('typent_id', 'int');
1523
-                $object->effectif_id			= GETPOST('effectif_id', 'int');
1524
-                $object->barcode				= GETPOST('barcode', 'alpha');
1525
-                $object->forme_juridique_code	= GETPOST('forme_juridique_code', 'int');
1526
-                $object->default_lang			= GETPOST('default_lang', 'alpha');
1527
-
1528
-                $object->tva_assuj				= GETPOST('assujtva_value', 'int');
1529
-                $object->tva_intra				= GETPOST('tva_intra', 'alpha');
1530
-                $object->status					= GETPOST('status', 'int');
1531
-
1532
-                // Webservices url/key
1533
-                $object->webservices_url        = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
1534
-                $object->webservices_key        = GETPOST('webservices_key', 'san_alpha');
1242
+				if (($j % 2) == 0) print '<tr>';
1243
+
1244
+				$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
1245
+				print '<td>'.fieldLabel($idprof,$key, (empty($conf->global->$idprof_mandatory)?0:1)).'</td><td>';
1246
+
1247
+				print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1248
+				print '</td>';
1249
+				if (($j % 2) == 1) print '</tr>';
1250
+				$j++;
1251
+			}
1252
+			$i++;
1253
+		}
1254
+		if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
1255
+
1256
+		// Vat is used
1257
+		print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td>';
1258
+		print '<td>';
1259
+		print $form->selectyesno('assujtva_value',(isset($conf->global->THIRDPARTY_DEFAULT_USEVAT)?$conf->global->THIRDPARTY_DEFAULT_USEVAT:1),1);     // Assujeti par defaut en creation
1260
+		print '</td>';
1261
+		print '<td class="nowrap">'.fieldLabel('VATIntra','intra_vat').'</td>';
1262
+		print '<td class="nowrap">';
1263
+		$s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1264
+
1265
+		if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
1266
+		{
1267
+			$s.=' ';
1268
+
1269
+			if (! empty($conf->use_javascript_ajax))
1270
+			{
1271
+				print "\n";
1272
+				print '<script language="JavaScript" type="text/javascript">';
1273
+				print "function CheckVAT(a) {\n";
1274
+				print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,300);\n";
1275
+				print "}\n";
1276
+				print '</script>';
1277
+				print "\n";
1278
+				$s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1279
+				$s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
1280
+			}
1281
+			else
1282
+			{
1283
+				$s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
1284
+			}
1285
+		}
1286
+		print $s;
1287
+		print '</td>';
1288
+		print '</tr>';
1289
+
1290
+		// Local Taxes
1291
+		//TODO: Place into a function to control showing by country or study better option
1292
+		if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
1293
+		{
1294
+			print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
1295
+			print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1);
1296
+			print '</td><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
1297
+			print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1);
1298
+			print '</td></tr>';
1299
+
1300
+		}
1301
+		elseif($mysoc->localtax1_assuj=="1")
1302
+		{
1303
+			print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
1304
+			print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1);
1305
+			print '</td></tr>';
1306
+		}
1307
+		elseif($mysoc->localtax2_assuj=="1")
1308
+		{
1309
+			print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
1310
+			print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1);
1311
+			print '</td></tr>';
1312
+		}
1313
+
1314
+		// Type - Size
1315
+		print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">'."\n";
1316
+		$sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
1317
+		print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam);
1318
+		if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1319
+		print '</td>';
1320
+		print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">';
1321
+		print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id);
1322
+		if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1323
+		print '</td></tr>';
1324
+
1325
+		// Legal Form
1326
+		print '<tr><td>'.fieldLabel('JuridicalStatus','forme_juridique_code').'</td>';
1327
+		print '<td colspan="3" class="maxwidthonsmartphone">';
1328
+		if ($object->country_id)
1329
+		{
1330
+			print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1331
+		}
1332
+		else
1333
+		{
1334
+			print $countrynotdefined;
1335
+		}
1336
+		print '</td></tr>';
1337
+
1338
+		// Capital
1339
+		print '<tr><td>'.fieldLabel('Capital','capital').'</td>';
1340
+		print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="'.$object->capital.'"> ';
1341
+		print '<span class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
1342
+
1343
+		if (! empty($conf->global->MAIN_MULTILANGS))
1344
+		{
1345
+			print '<tr><td>'.fieldLabel('DefaultLang','default_lang').'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
1346
+			print $formadmin->select_language(($object->default_lang?$object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1,0,0,'maxwidth200onsmartphone');
1347
+			print '</td>';
1348
+			print '</tr>';
1349
+		}
1350
+
1351
+		if ($user->rights->societe->client->voir)
1352
+		{
1353
+			// Assign a Name
1354
+			print '<tr>';
1355
+			print '<td>'.fieldLabel('AllocateCommercial','commercial_id').'</td>';
1356
+			print '<td colspan="3" class="maxwidthonsmartphone">';
1357
+			print $form->select_dolusers((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default
1358
+			print '</td></tr>';
1359
+		}
1360
+
1361
+		// Incoterms
1362
+		if (!empty($conf->incoterm->enabled))
1363
+		{
1364
+			print '<tr>';
1365
+			print '<td>'.fieldLabel('IncotermLabel','incoterm_id').'</td>';
1366
+			print '<td colspan="3" class="maxwidthonsmartphone">';
1367
+			print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
1368
+			print '</td></tr>';
1369
+		}
1370
+
1371
+		// Categories
1372
+		if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
1373
+		{
1374
+			$langs->load('categories');
1375
+
1376
+			// Customer
1377
+			if ($object->prospect || $object->client) {
1378
+				print '<tr><td class="toptd">' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td><td colspan="3">';
1379
+				$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
1380
+				print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null,
1381
+					null, "90%");
1382
+				print "</td></tr>";
1383
+			}
1384
+
1385
+			// Supplier
1386
+			if ($object->fournisseur) {
1387
+				print '<tr><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
1388
+				$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1);
1389
+				print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null,
1390
+					null, "90%");
1391
+				print "</td></tr>";
1392
+			}
1393
+		}
1394
+
1395
+		// Multicurrency
1396
+		if (! empty($conf->multicurrency->enabled))
1397
+		{
1398
+			print '<tr>';
1399
+			print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
1400
+			print '<td colspan="3" class="maxwidthonsmartphone">';
1401
+			print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
1402
+			print '</td></tr>';
1403
+		}
1404
+
1405
+		// Other attributes
1406
+		$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
1407
+		$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
1408
+		print $hookmanager->resPrint;
1409
+		if (empty($reshook) && ! empty($extrafields->attribute_label))
1410
+		{
1411
+			print $object->showOptionals($extrafields,'edit');
1412
+		}
1413
+
1414
+		// Ajout du logo
1415
+		print '<tr class="hideonsmartphone">';
1416
+		print '<td>'.fieldLabel('Logo','photoinput').'</td>';
1417
+		print '<td colspan="3">';
1418
+		print '<input class="flat" type="file" name="photo" id="photoinput" />';
1419
+		print '</td>';
1420
+		print '</tr>';
1421
+
1422
+		print '</table>'."\n";
1423
+
1424
+		dol_fiche_end();
1425
+
1426
+		print '<div class="center">';
1427
+		print '<input type="submit" class="button" name="create" value="'.$langs->trans('AddThirdParty').'">';
1428
+		if (! empty($backtopage))
1429
+		{
1430
+			print ' &nbsp; &nbsp; ';
1431
+			print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
1432
+		}
1433
+		else
1434
+		{
1435
+			print ' &nbsp; &nbsp; ';
1436
+			print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1437
+		}
1438
+		print '</div>'."\n";
1439
+
1440
+		print '</form>'."\n";
1441
+	}
1442
+	elseif ($action == 'edit')
1443
+	{
1444
+		/*
1445
+         * Edition
1446
+         */
1447
+
1448
+
1449
+		//print load_fiche_titre($langs->trans("EditCompany"));
1450
+
1451
+		if ($socid)
1452
+		{
1453
+			$res=$object->fetch_optionals();
1454
+			//if ($res < 0) { dol_print_error($db); exit; }
1455
+
1456
+			$head = societe_prepare_head($object);
1457
+
1458
+			// Load object modCodeTiers
1459
+			$module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
1460
+			if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1461
+			{
1462
+				$module = substr($module, 0, dol_strlen($module)-4);
1463
+			}
1464
+			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
1465
+			foreach ($dirsociete as $dirroot)
1466
+			{
1467
+				$res=dol_include_once($dirroot.$module.'.php');
1468
+				if ($res) break;
1469
+			}
1470
+			$modCodeClient = new $module($db);
1471
+			// We verified if the tag prefix is used
1472
+			if ($modCodeClient->code_auto)
1473
+			{
1474
+				$prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1475
+			}
1476
+			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
1477
+			if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1478
+			{
1479
+				$module = substr($module, 0, dol_strlen($module)-4);
1480
+			}
1481
+			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
1482
+			foreach ($dirsociete as $dirroot)
1483
+			{
1484
+				$res=dol_include_once($dirroot.$module.'.php');
1485
+				if ($res) break;
1486
+			}
1487
+			$modCodeFournisseur = new $module($db);
1488
+			// On verifie si la balise prefix est utilisee
1489
+			if ($modCodeFournisseur->code_auto)
1490
+			{
1491
+				$prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1492
+			}
1493
+
1494
+			$object->oldcopy = clone $object;
1495
+
1496
+			if (GETPOSTISSET('name'))
1497
+			{
1498
+				// We overwrite with values if posted
1499
+				$object->name					= GETPOST('name', 'alpha');
1500
+				$object->prefix_comm			= GETPOST('prefix_comm', 'alpha');
1501
+				$object->client					= GETPOST('client', 'int');
1502
+				$object->code_client			= GETPOST('code_client', 'alpha');
1503
+				$object->fournisseur			= GETPOST('fournisseur', 'int');
1504
+				$object->code_fournisseur		= GETPOST('code_fournisseur', 'alpha');
1505
+				$object->address				= GETPOST('address', 'alpha');
1506
+				$object->zip					= GETPOST('zipcode', 'alpha');
1507
+				$object->town					= GETPOST('town', 'alpha');
1508
+				$object->country_id				= GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id;
1509
+				$object->state_id				= GETPOST('state_id', 'int');
1510
+				$object->skype					= GETPOST('skype', 'alpha');
1511
+				$object->phone					= GETPOST('phone', 'alpha');
1512
+				$object->fax					= GETPOST('fax', 'alpha');
1513
+				$object->email					= GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
1514
+				$object->url					= GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
1515
+				$object->capital				= GETPOST('capital', 'alpha');
1516
+				$object->idprof1				= GETPOST('idprof1', 'alpha');
1517
+				$object->idprof2				= GETPOST('idprof2', 'alpha');
1518
+				$object->idprof3				= GETPOST('idprof3', 'alpha');
1519
+				$object->idprof4				= GETPOST('idprof4', 'alpha');
1520
+				$object->idprof5				= GETPOST('idprof5', 'alpha');
1521
+				$object->idprof6				= GETPOST('idprof6', 'alpha');
1522
+				$object->typent_id				= GETPOST('typent_id', 'int');
1523
+				$object->effectif_id			= GETPOST('effectif_id', 'int');
1524
+				$object->barcode				= GETPOST('barcode', 'alpha');
1525
+				$object->forme_juridique_code	= GETPOST('forme_juridique_code', 'int');
1526
+				$object->default_lang			= GETPOST('default_lang', 'alpha');
1527
+
1528
+				$object->tva_assuj				= GETPOST('assujtva_value', 'int');
1529
+				$object->tva_intra				= GETPOST('tva_intra', 'alpha');
1530
+				$object->status					= GETPOST('status', 'int');
1531
+
1532
+				// Webservices url/key
1533
+				$object->webservices_url        = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
1534
+				$object->webservices_key        = GETPOST('webservices_key', 'san_alpha');
1535 1535
 
1536 1536
 				//Incoterms
1537 1537
 				if (!empty($conf->incoterm->enabled))
@@ -1540,31 +1540,31 @@  discard block
 block discarded – undo
1540 1540
 					$object->location_incoterms		= GETPOST('lcoation_incoterms', 'alpha');
1541 1541
 				}
1542 1542
 
1543
-                //Local Taxes
1544
-                $object->localtax1_assuj		= GETPOST('localtax1assuj_value');
1545
-                $object->localtax2_assuj		= GETPOST('localtax2assuj_value');
1543
+				//Local Taxes
1544
+				$object->localtax1_assuj		= GETPOST('localtax1assuj_value');
1545
+				$object->localtax2_assuj		= GETPOST('localtax2assuj_value');
1546 1546
 
1547
-                $object->localtax1_value		=GETPOST('lt1');
1548
-                $object->localtax2_value		=GETPOST('lt2');
1547
+				$object->localtax1_value		=GETPOST('lt1');
1548
+				$object->localtax2_value		=GETPOST('lt2');
1549 1549
 
1550
-                // We set country_id, and country_code label of the chosen country
1551
-                if ($object->country_id > 0)
1552
-                {
1553
-                	$tmparray=getCountry($object->country_id,'all');
1554
-                    $object->country_code	= $tmparray['code'];
1555
-                    $object->country		= $tmparray['label'];
1556
-                }
1557
-            }
1550
+				// We set country_id, and country_code label of the chosen country
1551
+				if ($object->country_id > 0)
1552
+				{
1553
+					$tmparray=getCountry($object->country_id,'all');
1554
+					$object->country_code	= $tmparray['code'];
1555
+					$object->country		= $tmparray['label'];
1556
+				}
1557
+			}
1558 1558
 
1559
-            if($object->localtax1_assuj==0){
1560
-            	$sub=0;
1561
-            }else{$sub=1;}
1562
-            if($object->localtax2_assuj==0){
1563
-            	$sub2=0;
1564
-            }else{$sub2=1;}
1559
+			if($object->localtax1_assuj==0){
1560
+				$sub=0;
1561
+			}else{$sub=1;}
1562
+			if($object->localtax2_assuj==0){
1563
+				$sub2=0;
1564
+			}else{$sub2=1;}
1565 1565
 
1566
-            print "\n".'<script type="text/javascript">';
1567
-            print '$(document).ready(function () {
1566
+			print "\n".'<script type="text/javascript">';
1567
+			print '$(document).ready(function () {
1568 1568
     			var val='.$sub.';
1569 1569
     			var val2='.$sub2.';
1570 1570
     			if("#localtax1assuj_value".value==undefined){
@@ -1599,340 +1599,340 @@  discard block
 block discarded – undo
1599 1599
     			});
1600 1600
 
1601 1601
                });';
1602
-            print '</script>'."\n";
1602
+			print '</script>'."\n";
1603 1603
 
1604 1604
 
1605
-            if ($conf->use_javascript_ajax)
1606
-            {
1607
-                print "\n".'<script type="text/javascript" language="javascript">';
1608
-                print '$(document).ready(function () {
1605
+			if ($conf->use_javascript_ajax)
1606
+			{
1607
+				print "\n".'<script type="text/javascript" language="javascript">';
1608
+				print '$(document).ready(function () {
1609 1609
                 			$("#selectcountry_id").change(function() {
1610 1610
                 				document.formsoc.action.value="edit";
1611 1611
                 				document.formsoc.submit();
1612 1612
                 			});
1613 1613
                        })';
1614
-                print '</script>'."\n";
1615
-            }
1614
+				print '</script>'."\n";
1615
+			}
1616 1616
 
1617
-            print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post" name="formsoc">';
1618
-            print '<input type="hidden" name="action" value="update">';
1619
-            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1620
-            print '<input type="hidden" name="socid" value="'.$object->id.'">';
1621
-            if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1617
+			print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post" name="formsoc">';
1618
+			print '<input type="hidden" name="action" value="update">';
1619
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1620
+			print '<input type="hidden" name="socid" value="'.$object->id.'">';
1621
+			if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1622 1622
 
1623 1623
 
1624
-            dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
1624
+			dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
1625 1625
 
1626
-            print '<div class="fichecenter2">';
1627
-            print '<table class="border" width="100%">';
1626
+			print '<div class="fichecenter2">';
1627
+			print '<table class="border" width="100%">';
1628 1628
 
1629
-            // Ref/ID
1629
+			// Ref/ID
1630 1630
 			if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
1631 1631
 			{
1632
-		        print '<tr><td class="titlefieldcreate">'.$langs->trans("ID").'</td><td colspan="3">';
1633
-            	print $object->ref;
1634
-            	print '</td></tr>';
1635
-			}
1636
-
1637
-            // Name
1638
-            print '<tr><td class="titlefieldcreate">'.fieldLabel('ThirdPartyName','name',1).'</td>';
1639
-	        print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus"></td></tr>';
1640
-
1641
-	        // Alias names (commercial, trademark or alias names)
1642
-	        print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1643
-	        print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag($object->name_alias).'"></td></tr>';
1644
-
1645
-            // Prefix
1646
-            if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
1647
-            {
1648
-                print '<tr><td>'.fieldLabel('Prefix','prefix').'</td><td colspan="3">';
1649
-                // It does not change the prefix mode using the auto numbering prefix
1650
-                if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm)
1651
-                {
1652
-                    print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1653
-                    print $object->prefix_comm;
1654
-                }
1655
-                else
1656
-                {
1657
-                    print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1658
-                }
1659
-                print '</td>';
1660
-            }
1661
-
1662
-            // Prospect/Customer
1663
-            print '<tr><td>'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>';
1664
-	        print '<td class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">';
1665
-            if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($object->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1666
-            if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="3"'.($object->client==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
1667
-            if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($object->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
1668
-            print '<option value="0"'.($object->client==0?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
1669
-            print '</select></td>';
1670
-            print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>';
1671
-
1672
-            print '<table class="nobordernopadding"><tr><td>';
1673
-            if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto)
1674
-            {
1675
-                $tmpcode=$object->code_client;
1676
-                if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1677
-                if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0);
1678
-                print '<input type="text" name="code_client" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1679
-            }
1680
-            else if ($object->codeclient_modifiable())
1681
-            {
1682
-                print '<input type="text" name="code_client" id="customer_code" size="16" value="'.$object->code_client.'" maxlength="15">';
1683
-            }
1684
-            else
1685
-            {
1686
-                print $object->code_client;
1687
-                print '<input type="hidden" name="code_client" value="'.$object->code_client.'">';
1688
-            }
1689
-            print '</td><td>';
1690
-            $s=$modCodeClient->getToolTip($langs,$object,0);
1691
-            print $form->textwithpicto('',$s,1);
1692
-            print '</td></tr></table>';
1693
-
1694
-            print '</td></tr>';
1695
-
1696
-            // Supplier
1697
-            if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire))
1698
-            {
1699
-                print '<tr>';
1700
-                print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td class="maxwidthonsmartphone">';
1701
-                print $form->selectyesno("fournisseur",$object->fournisseur,1);
1702
-                print '</td>';
1703
-                print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>';
1704
-
1705
-                print '<table class="nobordernopadding"><tr><td>';
1706
-                if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto)
1707
-                {
1708
-                    $tmpcode=$object->code_fournisseur;
1709
-                    if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1710
-                    if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1);
1711
-                    print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1712
-                }
1713
-                else if ($object->codefournisseur_modifiable())
1714
-                {
1715
-                    print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.$object->code_fournisseur.'" maxlength="15">';
1716
-                }
1717
-                else
1718
-              {
1719
-                    print $object->code_fournisseur;
1720
-                    print '<input type="hidden" name="code_fournisseur" value="'.$object->code_fournisseur.'">';
1721
-                }
1722
-                print '</td><td>';
1723
-                $s=$modCodeFournisseur->getToolTip($langs,$object,1);
1724
-                print $form->textwithpicto('',$s,1);
1725
-                print '</td></tr></table>';
1726
-
1727
-                print '</td></tr>';
1728
-            }
1729
-
1730
-            // Barcode
1731
-            if (! empty($conf->barcode->enabled))
1732
-            {
1733
-                print '<tr><td class="tdtop">'.fieldLabel('Gencod','barcode').'</td>';
1734
-	            print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.$object->barcode.'">';
1735
-                print '</td></tr>';
1736
-            }
1737
-
1738
-            // Status
1739
-            print '<tr><td>'.fieldLabel('Status','status').'</td><td colspan="3">';
1740
-            print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status);
1741
-            print '</td></tr>';
1742
-
1743
-            // Address
1744
-            print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
1745
-	        print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1746
-            print $object->address;
1747
-            print '</textarea></td></tr>';
1748
-
1749
-            // Zip / Town
1750
-            print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
1751
-            print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth50onsmartphone');
1752
-            print '</td><td>'.fieldLabel('Town','town').'</td><td>';
1753
-            print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1754
-            print '</td></tr>';
1755
-
1756
-            // Country
1757
-            print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td colspan="3">';
1758
-            print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
1759
-            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1760
-            print '</td></tr>';
1761
-
1762
-            // State
1763
-            if (empty($conf->global->SOCIETE_DISABLE_STATE))
1764
-            {
1765
-                if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1766
-                {
1767
-                    print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3">';
1768
-                }
1769
-                else
1770
-                {
1771
-                    print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3">';
1772
-                }
1773
-
1774
-                print $formcompany->select_state($object->state_id,$object->country_code);
1775
-                print '</td></tr>';
1776
-            }
1777
-
1778
-            // EMail / Web
1779
-            print '<tr><td>'.fieldLabel('EMail','email',(! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'</td>';
1780
-	        print '<td colspan="3"><input type="text" name="email" id="email" size="32" value="'.$object->email.'"></td></tr>';
1781
-            print '<tr><td>'.fieldLabel('Web','url').'</td>';
1782
-	        print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="'.$object->url.'"></td></tr>';
1783
-
1784
-            // Skype
1785
-            if (! empty($conf->skype->enabled))
1786
-            {
1787
-                print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
1788
-	            print '<td colspan="3"><input type="text" name="skype" id="skype" size="32" value="'.$object->skype.'"></td></tr>';
1789
-            }
1790
-
1791
-            // Phone / Fax
1792
-            print '<tr><td>'.fieldLabel('Phone','phone').'</td>';
1793
-	        print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->phone.'"></td>';
1794
-            print '<td>'.fieldLabel('Fax','fax').'</td>';
1795
-	        print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->fax.'"></td></tr>';
1796
-
1797
-            // Prof ids
1798
-            $i=1; $j=0;
1799
-            while ($i <= 6)
1800
-            {
1801
-                $idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
1802
-                if ($idprof!='-')
1803
-                {
1804
-	                $key='idprof'.$i;
1805
-
1806
-	                if (($j % 2) == 0) print '<tr>';
1807
-
1808
-	                $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
1809
-	                if (empty($conf->global->$idprof_mandatory) || ! $object->isACompany())
1810
-	                    print '<td>'.fieldLabel($idprof,$key).'</td><td>';
1811
-                    else
1812
-	                    print '<td><span class="fieldrequired">'.fieldLabel($idprof,$key).'</td><td>';
1813
-
1814
-	                print $formcompany->get_input_id_prof($i,$key,$object->$key,$object->country_code);
1815
-                    print '</td>';
1816
-                    if (($j % 2) == 1) print '</tr>';
1817
-                    $j++;
1818
-                }
1819
-                $i++;
1820
-            }
1821
-            if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
1822
-
1823
-            // VAT is used
1824
-            print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td><td colspan="3">';
1825
-            print $form->selectyesno('assujtva_value',$object->tva_assuj,1);
1826
-            print '</td></tr>';
1827
-
1828
-            // Local Taxes
1829
-            //TODO: Place into a function to control showing by country or study better option
1830
-            if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
1831
-            {
1832
-                print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td>';
1833
-                print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
1834
-                if(! isOnlyOneLocalTax(1))
1835
-                {
1836
-                    print '<span class="cblt1">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1837
-                    $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
1838
-                    print '</span>';
1839
-                }
1840
-                print '</td>';
1841
-
1842
-                print '<td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td>';
1843
-                print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
1844
-                if  (! isOnlyOneLocalTax(2))
1845
-                {
1846
-                    print '<span class="cblt2">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1847
-                    $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
1848
-                    print '</span>';
1849
-                }
1850
-                print '</td></tr>';
1851
-
1852
-            }
1853
-            elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
1854
-            {
1855
-                print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td colspan="3">';
1856
-                print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
1857
-                if(! isOnlyOneLocalTax(1))
1858
-                {
1859
-                    print '<span class="cblt1">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1860
-                    $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
1861
-                    print '</span>';
1862
-                }
1863
-                print '</td></tr>';
1864
-
1865
-            }
1866
-            elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
1867
-            {
1868
-                print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td colspan="3">';
1869
-                print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
1870
-                if(! isOnlyOneLocalTax(2))
1871
-                {
1872
-                    print '<span class="cblt2">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1873
-                    $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
1874
-                    print '</span>';
1875
-                }
1876
-                print '</td></tr>';
1877
-            }
1878
-
1879
-            // VAT Code
1880
-            print '<tr><td>'.fieldLabel('VATIntra','intra_vat').'</td>';
1881
-            print '<td colspan="3">';
1882
-            $s ='<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1883
-
1884
-            if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
1885
-            {
1886
-                $s.=' &nbsp; ';
1887
-
1888
-                if ($conf->use_javascript_ajax)
1889
-                {
1890
-                    print "\n";
1891
-                    print '<script language="JavaScript" type="text/javascript">';
1892
-                    print "function CheckVAT(a) {\n";
1893
-                    print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,285);\n";
1894
-                    print "}\n";
1895
-                    print '</script>';
1896
-                    print "\n";
1897
-                    $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1898
-                    $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
1899
-                }
1900
-                else
1901
-                {
1902
-                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
1903
-                }
1904
-            }
1905
-            print $s;
1906
-            print '</td>';
1907
-            print '</tr>';
1908
-
1909
-            // Type - Size
1910
-            print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">';
1911
-            print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
1912
-            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1913
-            print '</td>';
1914
-            print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">';
1915
-            print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $object->effectif_id);
1916
-            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1917
-            print '</td></tr>';
1918
-
1919
-            // Juridical type
1920
-            print '<tr><td>'.fieldLabel('JuridicalStatus','forme_juridique_code').'</td><td class="maxwidthonsmartphone" colspan="3">';
1921
-            print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1922
-            print '</td></tr>';
1923
-
1924
-            // Capital
1925
-            print '<tr><td>'.fieldLabel('Capital','capital').'</td>';
1926
-	        print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="'.$object->capital.'"> <font class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</font></td></tr>';
1927
-
1928
-            // Default language
1929
-            if (! empty($conf->global->MAIN_MULTILANGS))
1930
-            {
1931
-                print '<tr><td>'.fieldLabel('DefaultLang','default_lang').'</td><td colspan="3">'."\n";
1932
-                print $formadmin->select_language($object->default_lang,'default_lang',0,0,1);
1933
-                print '</td>';
1934
-                print '</tr>';
1935
-            }
1632
+				print '<tr><td class="titlefieldcreate">'.$langs->trans("ID").'</td><td colspan="3">';
1633
+				print $object->ref;
1634
+				print '</td></tr>';
1635
+			}
1636
+
1637
+			// Name
1638
+			print '<tr><td class="titlefieldcreate">'.fieldLabel('ThirdPartyName','name',1).'</td>';
1639
+			print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus"></td></tr>';
1640
+
1641
+			// Alias names (commercial, trademark or alias names)
1642
+			print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1643
+			print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag($object->name_alias).'"></td></tr>';
1644
+
1645
+			// Prefix
1646
+			if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
1647
+			{
1648
+				print '<tr><td>'.fieldLabel('Prefix','prefix').'</td><td colspan="3">';
1649
+				// It does not change the prefix mode using the auto numbering prefix
1650
+				if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm)
1651
+				{
1652
+					print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1653
+					print $object->prefix_comm;
1654
+				}
1655
+				else
1656
+				{
1657
+					print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1658
+				}
1659
+				print '</td>';
1660
+			}
1661
+
1662
+			// Prospect/Customer
1663
+			print '<tr><td>'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>';
1664
+			print '<td class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">';
1665
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($object->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1666
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="3"'.($object->client==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
1667
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($object->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
1668
+			print '<option value="0"'.($object->client==0?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
1669
+			print '</select></td>';
1670
+			print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>';
1671
+
1672
+			print '<table class="nobordernopadding"><tr><td>';
1673
+			if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto)
1674
+			{
1675
+				$tmpcode=$object->code_client;
1676
+				if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1677
+				if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0);
1678
+				print '<input type="text" name="code_client" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1679
+			}
1680
+			else if ($object->codeclient_modifiable())
1681
+			{
1682
+				print '<input type="text" name="code_client" id="customer_code" size="16" value="'.$object->code_client.'" maxlength="15">';
1683
+			}
1684
+			else
1685
+			{
1686
+				print $object->code_client;
1687
+				print '<input type="hidden" name="code_client" value="'.$object->code_client.'">';
1688
+			}
1689
+			print '</td><td>';
1690
+			$s=$modCodeClient->getToolTip($langs,$object,0);
1691
+			print $form->textwithpicto('',$s,1);
1692
+			print '</td></tr></table>';
1693
+
1694
+			print '</td></tr>';
1695
+
1696
+			// Supplier
1697
+			if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire))
1698
+			{
1699
+				print '<tr>';
1700
+				print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td class="maxwidthonsmartphone">';
1701
+				print $form->selectyesno("fournisseur",$object->fournisseur,1);
1702
+				print '</td>';
1703
+				print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>';
1704
+
1705
+				print '<table class="nobordernopadding"><tr><td>';
1706
+				if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto)
1707
+				{
1708
+					$tmpcode=$object->code_fournisseur;
1709
+					if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1710
+					if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1);
1711
+					print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">';
1712
+				}
1713
+				else if ($object->codefournisseur_modifiable())
1714
+				{
1715
+					print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.$object->code_fournisseur.'" maxlength="15">';
1716
+				}
1717
+				else
1718
+			  {
1719
+					print $object->code_fournisseur;
1720
+					print '<input type="hidden" name="code_fournisseur" value="'.$object->code_fournisseur.'">';
1721
+				}
1722
+				print '</td><td>';
1723
+				$s=$modCodeFournisseur->getToolTip($langs,$object,1);
1724
+				print $form->textwithpicto('',$s,1);
1725
+				print '</td></tr></table>';
1726
+
1727
+				print '</td></tr>';
1728
+			}
1729
+
1730
+			// Barcode
1731
+			if (! empty($conf->barcode->enabled))
1732
+			{
1733
+				print '<tr><td class="tdtop">'.fieldLabel('Gencod','barcode').'</td>';
1734
+				print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.$object->barcode.'">';
1735
+				print '</td></tr>';
1736
+			}
1737
+
1738
+			// Status
1739
+			print '<tr><td>'.fieldLabel('Status','status').'</td><td colspan="3">';
1740
+			print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status);
1741
+			print '</td></tr>';
1742
+
1743
+			// Address
1744
+			print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
1745
+			print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1746
+			print $object->address;
1747
+			print '</textarea></td></tr>';
1748
+
1749
+			// Zip / Town
1750
+			print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
1751
+			print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth50onsmartphone');
1752
+			print '</td><td>'.fieldLabel('Town','town').'</td><td>';
1753
+			print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1754
+			print '</td></tr>';
1755
+
1756
+			// Country
1757
+			print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td colspan="3">';
1758
+			print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
1759
+			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1760
+			print '</td></tr>';
1761
+
1762
+			// State
1763
+			if (empty($conf->global->SOCIETE_DISABLE_STATE))
1764
+			{
1765
+				if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1766
+				{
1767
+					print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3">';
1768
+				}
1769
+				else
1770
+				{
1771
+					print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3">';
1772
+				}
1773
+
1774
+				print $formcompany->select_state($object->state_id,$object->country_code);
1775
+				print '</td></tr>';
1776
+			}
1777
+
1778
+			// EMail / Web
1779
+			print '<tr><td>'.fieldLabel('EMail','email',(! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'</td>';
1780
+			print '<td colspan="3"><input type="text" name="email" id="email" size="32" value="'.$object->email.'"></td></tr>';
1781
+			print '<tr><td>'.fieldLabel('Web','url').'</td>';
1782
+			print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="'.$object->url.'"></td></tr>';
1783
+
1784
+			// Skype
1785
+			if (! empty($conf->skype->enabled))
1786
+			{
1787
+				print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
1788
+				print '<td colspan="3"><input type="text" name="skype" id="skype" size="32" value="'.$object->skype.'"></td></tr>';
1789
+			}
1790
+
1791
+			// Phone / Fax
1792
+			print '<tr><td>'.fieldLabel('Phone','phone').'</td>';
1793
+			print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->phone.'"></td>';
1794
+			print '<td>'.fieldLabel('Fax','fax').'</td>';
1795
+			print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->fax.'"></td></tr>';
1796
+
1797
+			// Prof ids
1798
+			$i=1; $j=0;
1799
+			while ($i <= 6)
1800
+			{
1801
+				$idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
1802
+				if ($idprof!='-')
1803
+				{
1804
+					$key='idprof'.$i;
1805
+
1806
+					if (($j % 2) == 0) print '<tr>';
1807
+
1808
+					$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
1809
+					if (empty($conf->global->$idprof_mandatory) || ! $object->isACompany())
1810
+						print '<td>'.fieldLabel($idprof,$key).'</td><td>';
1811
+					else
1812
+						print '<td><span class="fieldrequired">'.fieldLabel($idprof,$key).'</td><td>';
1813
+
1814
+					print $formcompany->get_input_id_prof($i,$key,$object->$key,$object->country_code);
1815
+					print '</td>';
1816
+					if (($j % 2) == 1) print '</tr>';
1817
+					$j++;
1818
+				}
1819
+				$i++;
1820
+			}
1821
+			if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
1822
+
1823
+			// VAT is used
1824
+			print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td><td colspan="3">';
1825
+			print $form->selectyesno('assujtva_value',$object->tva_assuj,1);
1826
+			print '</td></tr>';
1827
+
1828
+			// Local Taxes
1829
+			//TODO: Place into a function to control showing by country or study better option
1830
+			if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
1831
+			{
1832
+				print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td>';
1833
+				print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
1834
+				if(! isOnlyOneLocalTax(1))
1835
+				{
1836
+					print '<span class="cblt1">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1837
+					$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
1838
+					print '</span>';
1839
+				}
1840
+				print '</td>';
1841
+
1842
+				print '<td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td>';
1843
+				print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
1844
+				if  (! isOnlyOneLocalTax(2))
1845
+				{
1846
+					print '<span class="cblt2">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1847
+					$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
1848
+					print '</span>';
1849
+				}
1850
+				print '</td></tr>';
1851
+
1852
+			}
1853
+			elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
1854
+			{
1855
+				print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td colspan="3">';
1856
+				print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
1857
+				if(! isOnlyOneLocalTax(1))
1858
+				{
1859
+					print '<span class="cblt1">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1860
+					$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
1861
+					print '</span>';
1862
+				}
1863
+				print '</td></tr>';
1864
+
1865
+			}
1866
+			elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
1867
+			{
1868
+				print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td colspan="3">';
1869
+				print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
1870
+				if(! isOnlyOneLocalTax(2))
1871
+				{
1872
+					print '<span class="cblt2">     '.$langs->transcountry("Type",$mysoc->country_code).': ';
1873
+					$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
1874
+					print '</span>';
1875
+				}
1876
+				print '</td></tr>';
1877
+			}
1878
+
1879
+			// VAT Code
1880
+			print '<tr><td>'.fieldLabel('VATIntra','intra_vat').'</td>';
1881
+			print '<td colspan="3">';
1882
+			$s ='<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1883
+
1884
+			if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
1885
+			{
1886
+				$s.=' &nbsp; ';
1887
+
1888
+				if ($conf->use_javascript_ajax)
1889
+				{
1890
+					print "\n";
1891
+					print '<script language="JavaScript" type="text/javascript">';
1892
+					print "function CheckVAT(a) {\n";
1893
+					print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,285);\n";
1894
+					print "}\n";
1895
+					print '</script>';
1896
+					print "\n";
1897
+					$s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1898
+					$s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
1899
+				}
1900
+				else
1901
+				{
1902
+					$s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
1903
+				}
1904
+			}
1905
+			print $s;
1906
+			print '</td>';
1907
+			print '</tr>';
1908
+
1909
+			// Type - Size
1910
+			print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">';
1911
+			print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
1912
+			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1913
+			print '</td>';
1914
+			print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">';
1915
+			print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $object->effectif_id);
1916
+			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1917
+			print '</td></tr>';
1918
+
1919
+			// Juridical type
1920
+			print '<tr><td>'.fieldLabel('JuridicalStatus','forme_juridique_code').'</td><td class="maxwidthonsmartphone" colspan="3">';
1921
+			print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1922
+			print '</td></tr>';
1923
+
1924
+			// Capital
1925
+			print '<tr><td>'.fieldLabel('Capital','capital').'</td>';
1926
+			print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="'.$object->capital.'"> <font class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</font></td></tr>';
1927
+
1928
+			// Default language
1929
+			if (! empty($conf->global->MAIN_MULTILANGS))
1930
+			{
1931
+				print '<tr><td>'.fieldLabel('DefaultLang','default_lang').'</td><td colspan="3">'."\n";
1932
+				print $formadmin->select_language($object->default_lang,'default_lang',0,0,1);
1933
+				print '</td>';
1934
+				print '</tr>';
1935
+			}
1936 1936
 
1937 1937
 			// Categories
1938 1938
 			if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
@@ -1973,296 +1973,296 @@  discard block
 block discarded – undo
1973 1973
 			{
1974 1974
 				print '<tr>';
1975 1975
 				print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
1976
-		        print '<td colspan="3" class="maxwidthonsmartphone">';
1977
-		        print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
1976
+				print '<td colspan="3" class="maxwidthonsmartphone">';
1977
+				print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
1978 1978
 				print '</td></tr>';
1979 1979
 			}
1980 1980
 
1981
-            // Other attributes
1982
-            $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
1983
-            $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
1984
-            print $hookmanager->resPrint;
1985
-            if (empty($reshook) && ! empty($extrafields->attribute_label))
1986
-            {
1987
-            	print $object->showOptionals($extrafields,'edit');
1988
-            }
1981
+			// Other attributes
1982
+			$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
1983
+			$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
1984
+			print $hookmanager->resPrint;
1985
+			if (empty($reshook) && ! empty($extrafields->attribute_label))
1986
+			{
1987
+				print $object->showOptionals($extrafields,'edit');
1988
+			}
1989 1989
 
1990
-            // Webservices url/key
1991
-            if (!empty($conf->syncsupplierwebservices->enabled)) {
1992
-                print '<tr><td>'.fieldLabel('WebServiceURL','webservices_url').'</td>';
1993
-                print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.'"></td>';
1994
-                print '<td>'.fieldLabel('WebServiceKey','webservices_key').'</td>';
1995
-                print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.'"></td></tr>';
1996
-            }
1990
+			// Webservices url/key
1991
+			if (!empty($conf->syncsupplierwebservices->enabled)) {
1992
+				print '<tr><td>'.fieldLabel('WebServiceURL','webservices_url').'</td>';
1993
+				print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.'"></td>';
1994
+				print '<td>'.fieldLabel('WebServiceKey','webservices_key').'</td>';
1995
+				print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.'"></td></tr>';
1996
+			}
1997 1997
 
1998 1998
 			// Incoterms
1999 1999
 			if (!empty($conf->incoterm->enabled))
2000 2000
 			{
2001 2001
 				print '<tr>';
2002 2002
 				print '<td>'.fieldLabel('IncotermLabel','incoterm_id').'</td>';
2003
-	            print '<td colspan="3" class="maxwidthonsmartphone">';
2004
-	            print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
2003
+				print '<td colspan="3" class="maxwidthonsmartphone">';
2004
+				print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
2005 2005
 				print '</td></tr>';
2006 2006
 			}
2007 2007
 
2008
-            // Logo
2009
-            print '<tr class="hideonsmartphone">';
2010
-            print '<td>'.fieldLabel('Logo','photoinput').'</td>';
2011
-            print '<td colspan="3">';
2012
-            if ($object->logo) print $form->showphoto('societe',$object);
2013
-            $caneditfield=1;
2014
-            if ($caneditfield)
2015
-            {
2016
-                if ($object->logo) print "<br>\n";
2017
-                print '<table class="nobordernopadding">';
2018
-                if ($object->logo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
2019
-                //print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
2020
-                print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
2021
-                print '</table>';
2022
-            }
2023
-            print '</td>';
2024
-            print '</tr>';
2025
-
2026
-            print '</table>';
2027
-            print '</div>';
2028
-
2029
-	        dol_fiche_end();
2030
-
2031
-            print '<div align="center">';
2032
-            print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
2033
-            print ' &nbsp; &nbsp; ';
2034
-            print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
2035
-            print '</div>';
2036
-
2037
-            print '</form>';
2038
-        }
2039
-    }
2040
-    else
2041
-    {
2042
-    	/*
2008
+			// Logo
2009
+			print '<tr class="hideonsmartphone">';
2010
+			print '<td>'.fieldLabel('Logo','photoinput').'</td>';
2011
+			print '<td colspan="3">';
2012
+			if ($object->logo) print $form->showphoto('societe',$object);
2013
+			$caneditfield=1;
2014
+			if ($caneditfield)
2015
+			{
2016
+				if ($object->logo) print "<br>\n";
2017
+				print '<table class="nobordernopadding">';
2018
+				if ($object->logo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
2019
+				//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
2020
+				print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
2021
+				print '</table>';
2022
+			}
2023
+			print '</td>';
2024
+			print '</tr>';
2025
+
2026
+			print '</table>';
2027
+			print '</div>';
2028
+
2029
+			dol_fiche_end();
2030
+
2031
+			print '<div align="center">';
2032
+			print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
2033
+			print ' &nbsp; &nbsp; ';
2034
+			print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
2035
+			print '</div>';
2036
+
2037
+			print '</form>';
2038
+		}
2039
+	}
2040
+	else
2041
+	{
2042
+		/*
2043 2043
          * View
2044 2044
          */
2045 2045
 
2046
-        if (!empty($object->id)) $res=$object->fetch_optionals();
2047
-        //if ($res < 0) { dol_print_error($db); exit; }
2048
-
2049
-
2050
-        $head = societe_prepare_head($object);
2051
-
2052
-        dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company');
2053
-
2054
-        // Confirm delete third party
2055
-        if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
2056
-        {
2057
-            print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
2058
-        }
2059
-
2060
-	    if ($action == 'merge')
2061
-	    {
2062
-		    $formquestion = array(
2063
-			    array(
2064
-				    'name' => 'soc_origin',
2065
-			    	'label' => $langs->trans('MergeOriginThirdparty'),
2066
-				    'type' => 'other',
2067
-				    'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200')
2068
-			    )
2069
-		    );
2070
-
2071
-		    print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
2072
-	    }
2073
-
2074
-        dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
2075
-
2076
-        $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2077
-
2078
-        dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
2079
-
2080
-
2081
-        print '<div class="fichecenter">';
2082
-        print '<div class="fichehalfleft">';
2083
-
2084
-        print '<div class="underbanner clearboth"></div>';
2085
-        print '<table class="border tableforfield" width="100%">';
2086
-
2087
-    	// Prospect/Customer
2088
-    	print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>';
2089
-    	print $object->getLibCustProspStatut();
2090
-    	print '</td></tr>';
2091
-
2092
-    	// Supplier
2093
-    	if (! empty($conf->fournisseur->enabled))
2094
-    	{
2095
-    		print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
2096
-    		print yn($object->fournisseur);
2097
-    		print '</td></tr>';
2098
-    	}
2099
-
2100
-    	// Prefix
2101
-        if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
2102
-        {
2103
-            print '<tr><td>'.$langs->trans('Prefix').'</td><td>'.$object->prefix_comm.'</td>';
2104
-            print $htmllogobar; $htmllogobar='';
2105
-            print '</tr>';
2106
-        }
2107
-
2108
-        // Customer code
2109
-        if ($object->client)
2110
-        {
2111
-            print '<tr><td>';
2112
-            print $langs->trans('CustomerCode').'</td><td>';
2113
-            print $object->code_client;
2114
-            if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
2115
-            print '</td>';
2116
-            print $htmllogobar; $htmllogobar='';
2117
-            print '</tr>';
2118
-        }
2119
-
2120
-        // Supplier code
2121
-        if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire))
2122
-        {
2123
-            print '<tr><td>';
2124
-            print $langs->trans('SupplierCode').'</td><td>';
2125
-            print $object->code_fournisseur;
2126
-            if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
2127
-            print '</td>';
2128
-            print $htmllogobar; $htmllogobar='';
2129
-            print '</tr>';
2130
-        }
2131
-
2132
-        // Barcode
2133
-        if (! empty($conf->barcode->enabled))
2134
-        {
2135
-            print '<tr><td>';
2136
-            print $langs->trans('Gencod').'</td><td>'.$object->barcode;
2137
-            print '</td>';
2046
+		if (!empty($object->id)) $res=$object->fetch_optionals();
2047
+		//if ($res < 0) { dol_print_error($db); exit; }
2048
+
2049
+
2050
+		$head = societe_prepare_head($object);
2051
+
2052
+		dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company');
2053
+
2054
+		// Confirm delete third party
2055
+		if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
2056
+		{
2057
+			print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
2058
+		}
2059
+
2060
+		if ($action == 'merge')
2061
+		{
2062
+			$formquestion = array(
2063
+				array(
2064
+					'name' => 'soc_origin',
2065
+					'label' => $langs->trans('MergeOriginThirdparty'),
2066
+					'type' => 'other',
2067
+					'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200')
2068
+				)
2069
+			);
2070
+
2071
+			print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
2072
+		}
2073
+
2074
+		dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
2075
+
2076
+		$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2077
+
2078
+		dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
2079
+
2080
+
2081
+		print '<div class="fichecenter">';
2082
+		print '<div class="fichehalfleft">';
2083
+
2084
+		print '<div class="underbanner clearboth"></div>';
2085
+		print '<table class="border tableforfield" width="100%">';
2086
+
2087
+		// Prospect/Customer
2088
+		print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>';
2089
+		print $object->getLibCustProspStatut();
2090
+		print '</td></tr>';
2091
+
2092
+		// Supplier
2093
+		if (! empty($conf->fournisseur->enabled))
2094
+		{
2095
+			print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
2096
+			print yn($object->fournisseur);
2097
+			print '</td></tr>';
2098
+		}
2099
+
2100
+		// Prefix
2101
+		if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
2102
+		{
2103
+			print '<tr><td>'.$langs->trans('Prefix').'</td><td>'.$object->prefix_comm.'</td>';
2104
+			print $htmllogobar; $htmllogobar='';
2105
+			print '</tr>';
2106
+		}
2107
+
2108
+		// Customer code
2109
+		if ($object->client)
2110
+		{
2111
+			print '<tr><td>';
2112
+			print $langs->trans('CustomerCode').'</td><td>';
2113
+			print $object->code_client;
2114
+			if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
2115
+			print '</td>';
2116
+			print $htmllogobar; $htmllogobar='';
2117
+			print '</tr>';
2118
+		}
2119
+
2120
+		// Supplier code
2121
+		if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire))
2122
+		{
2123
+			print '<tr><td>';
2124
+			print $langs->trans('SupplierCode').'</td><td>';
2125
+			print $object->code_fournisseur;
2126
+			if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
2127
+			print '</td>';
2128
+			print $htmllogobar; $htmllogobar='';
2129
+			print '</tr>';
2130
+		}
2131
+
2132
+		// Barcode
2133
+		if (! empty($conf->barcode->enabled))
2134
+		{
2135
+			print '<tr><td>';
2136
+			print $langs->trans('Gencod').'</td><td>'.$object->barcode;
2137
+			print '</td>';
2138 2138
 			if ($htmllogobar) $htmllogobar.=$form->showbarcode($object);
2139
-            print $htmllogobar;
2139
+			print $htmllogobar;
2140 2140
 			$htmllogobar='';
2141
-            print '</tr>';
2142
-        }
2143
-
2144
-        // Prof ids
2145
-        $i=1; $j=0;
2146
-        while ($i <= 6)
2147
-        {
2148
-            $idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
2149
-            if ($idprof!='-')
2150
-            {
2151
-                //if (($j % 2) == 0) print '<tr>';
2152
-                print '<tr>';
2153
-            	print '<td>'.$idprof.'</td><td>';
2154
-                $key='idprof'.$i;
2155
-                print $object->$key;
2156
-                if ($object->$key)
2157
-                {
2158
-                    if ($object->id_prof_check($i,$object) > 0) print ' &nbsp; '.$object->id_prof_url($i,$object);
2159
-                    else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
2160
-                }
2161
-                print '</td>';
2162
-                //if (($j % 2) == 1) print '</tr>';
2163
-                print '</tr>';
2164
-                $j++;
2165
-            }
2166
-            $i++;
2167
-        }
2168
-        //if ($j % 2 == 1)  print '<td colspan="2"></td></tr>';
2169
-
2170
-        // VAT is used
2171
-        print '<tr><td>';
2172
-        print $langs->trans('VATIsUsed');
2173
-        print '</td><td>';
2174
-        print yn($object->tva_assuj);
2175
-        print '</td>';
2141
+			print '</tr>';
2142
+		}
2143
+
2144
+		// Prof ids
2145
+		$i=1; $j=0;
2146
+		while ($i <= 6)
2147
+		{
2148
+			$idprof=$langs->transcountry('ProfId'.$i,$object->country_code);
2149
+			if ($idprof!='-')
2150
+			{
2151
+				//if (($j % 2) == 0) print '<tr>';
2152
+				print '<tr>';
2153
+				print '<td>'.$idprof.'</td><td>';
2154
+				$key='idprof'.$i;
2155
+				print $object->$key;
2156
+				if ($object->$key)
2157
+				{
2158
+					if ($object->id_prof_check($i,$object) > 0) print ' &nbsp; '.$object->id_prof_url($i,$object);
2159
+					else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
2160
+				}
2161
+				print '</td>';
2162
+				//if (($j % 2) == 1) print '</tr>';
2163
+				print '</tr>';
2164
+				$j++;
2165
+			}
2166
+			$i++;
2167
+		}
2168
+		//if ($j % 2 == 1)  print '<td colspan="2"></td></tr>';
2169
+
2170
+		// VAT is used
2171
+		print '<tr><td>';
2172
+		print $langs->trans('VATIsUsed');
2173
+		print '</td><td>';
2174
+		print yn($object->tva_assuj);
2175
+		print '</td>';
2176 2176
 		print '</tr>';
2177 2177
 
2178 2178
 		// Local Taxes
2179 2179
 		//TODO: Place into a function to control showing by country or study better option
2180 2180
 		if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
2181 2181
 		{
2182
-		    print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
2183
-		    print yn($object->localtax1_assuj);
2184
-		    print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
2185
-		    print yn($object->localtax2_assuj);
2186
-		    print '</td></tr>';
2187
-
2188
-		    if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
2189
-		    {
2190
-		        print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2191
-		        print '<input type="hidden" name="action" value="set_localtax1">';
2192
-		        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2193
-		        print '<tr><td>'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2194
-		        if($action == 'editRE')
2195
-		        {
2196
-		            print '<td align="left">';
2197
-		            $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
2198
-		            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2199
-		        }
2200
-		        else
2201
-		        {
2202
-		            print '<td>'.$object->localtax1_value.'</td>';
2203
-		        }
2204
-		        print '</tr></form>';
2205
-		    }
2206
-		    if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
2207
-		    {
2208
-		        print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2209
-		        print '<input type="hidden" name="action" value="set_localtax2">';
2210
-		        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2211
-		        print '<tr><td>'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2212
-		        if($action == 'editIRPF'){
2213
-		            print '<td align="left">';
2214
-		            $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
2215
-		            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2216
-		        }else{
2217
-		            print '<td>'.$object->localtax2_value.'</td>';
2218
-		        }
2219
-		        print '</tr></form>';
2220
-		    }
2182
+			print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
2183
+			print yn($object->localtax1_assuj);
2184
+			print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
2185
+			print yn($object->localtax2_assuj);
2186
+			print '</td></tr>';
2187
+
2188
+			if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
2189
+			{
2190
+				print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2191
+				print '<input type="hidden" name="action" value="set_localtax1">';
2192
+				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2193
+				print '<tr><td>'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2194
+				if($action == 'editRE')
2195
+				{
2196
+					print '<td align="left">';
2197
+					$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
2198
+					print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2199
+				}
2200
+				else
2201
+				{
2202
+					print '<td>'.$object->localtax1_value.'</td>';
2203
+				}
2204
+				print '</tr></form>';
2205
+			}
2206
+			if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
2207
+			{
2208
+				print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2209
+				print '<input type="hidden" name="action" value="set_localtax2">';
2210
+				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2211
+				print '<tr><td>'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2212
+				if($action == 'editIRPF'){
2213
+					print '<td align="left">';
2214
+					$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
2215
+					print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2216
+				}else{
2217
+					print '<td>'.$object->localtax2_value.'</td>';
2218
+				}
2219
+				print '</tr></form>';
2220
+			}
2221 2221
 		}
2222 2222
 		elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
2223 2223
 		{
2224
-		    print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
2225
-		    print yn($object->localtax1_assuj);
2226
-		    print '</td></tr>';
2227
-		    if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
2228
-		    {
2229
-		        print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2230
-		        print '<input type="hidden" name="action" value="set_localtax1">';
2231
-		        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2232
-		        print '<tr><td> '.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2233
-		        if($action == 'editRE'){
2234
-		            print '<td align="left">';
2235
-		            $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
2236
-		            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2237
-		        }else{
2238
-		            print '<td>'.$object->localtax1_value.'</td>';
2239
-		        }
2240
-		        print '</tr></form>';
2241
-
2242
-		    }
2224
+			print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
2225
+			print yn($object->localtax1_assuj);
2226
+			print '</td></tr>';
2227
+			if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
2228
+			{
2229
+				print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2230
+				print '<input type="hidden" name="action" value="set_localtax1">';
2231
+				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2232
+				print '<tr><td> '.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2233
+				if($action == 'editRE'){
2234
+					print '<td align="left">';
2235
+					$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
2236
+					print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2237
+				}else{
2238
+					print '<td>'.$object->localtax1_value.'</td>';
2239
+				}
2240
+				print '</tr></form>';
2241
+
2242
+			}
2243 2243
 		}
2244 2244
 		elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
2245 2245
 		{
2246
-		    print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
2247
-		    print yn($object->localtax2_assuj);
2248
-		    print '</td></tr>';
2249
-		    if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
2250
-		    {
2251
-
2252
-		        print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2253
-		        print '<input type="hidden" name="action" value="set_localtax2">';
2254
-		        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2255
-		        print '<tr><td> '.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2256
-		        if($action == 'editIRPF'){
2257
-		            print '<td align="left">';
2258
-		            $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
2259
-		            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2260
-		        }else{
2261
-		            print '<td>'.$object->localtax2_value.'</td>';
2262
-		        }
2263
-		        print '</tr></form>';
2264
-
2265
-		    }
2246
+			print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
2247
+			print yn($object->localtax2_assuj);
2248
+			print '</td></tr>';
2249
+			if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
2250
+			{
2251
+
2252
+				print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2253
+				print '<input type="hidden" name="action" value="set_localtax2">';
2254
+				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2255
+				print '<tr><td> '.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
2256
+				if($action == 'editIRPF'){
2257
+					print '<td align="left">';
2258
+					$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
2259
+					print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2260
+				}else{
2261
+					print '<td>'.$object->localtax2_value.'</td>';
2262
+				}
2263
+				print '</tr></form>';
2264
+
2265
+			}
2266 2266
 		}
2267 2267
 		/*
2268 2268
 		 if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1)
@@ -2273,60 +2273,60 @@  discard block
 block discarded – undo
2273 2273
 		 }
2274 2274
 		 */
2275 2275
 
2276
-        // VAT Code
2277
-        print '<tr>';
2276
+		// VAT Code
2277
+		print '<tr>';
2278 2278
 		print '<td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
2279
-        if ($object->tva_intra)
2280
-        {
2281
-            $s='';
2282
-            $s.=$object->tva_intra;
2283
-            $s.='<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.'">';
2284
-
2285
-            if (empty($conf->global->MAIN_DISABLEVATCHECK))
2286
-            {
2287
-                $s.=' &nbsp; ';
2288
-
2289
-                if ($conf->use_javascript_ajax)
2290
-                {
2291
-                    print "\n";
2292
-                    print '<script language="JavaScript" type="text/javascript">';
2293
-                    print "function CheckVAT(a) {\n";
2294
-                    print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,285);\n";
2295
-                    print "}\n";
2296
-                    print '</script>';
2297
-                    print "\n";
2298
-                    $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>';
2299
-                    $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
2300
-                }
2301
-                else
2302
-                {
2303
-                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
2304
-                }
2305
-            }
2306
-            print $s;
2307
-        }
2308
-        else
2309
-        {
2310
-            print '&nbsp;';
2311
-        }
2312
-        print '</td>';
2313
-        print '</tr>';
2314
-
2315
-        // Type + Staff
2316
-        $arr = $formcompany->typent_array(1);
2317
-        $object->typent= $arr[$object->typent_code];
2318
-        print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'.$object->typent.'</td>';
2319
-        print '<tr><td>'.$langs->trans("Staff").'</td><td>'.$object->effectif.'</td></tr>';
2320
-
2321
-        print '</table>';
2322
-
2323
-        print '</div>';
2324
-        print '<div class="fichehalfright"><div class="ficheaddleft">';
2325
-
2326
-        print '<div class="underbanner clearboth"></div>';
2327
-        print '<table class="border tableforfield" width="100%">';
2328
-
2329
-    	// Tags / categories
2279
+		if ($object->tva_intra)
2280
+		{
2281
+			$s='';
2282
+			$s.=$object->tva_intra;
2283
+			$s.='<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.'">';
2284
+
2285
+			if (empty($conf->global->MAIN_DISABLEVATCHECK))
2286
+			{
2287
+				$s.=' &nbsp; ';
2288
+
2289
+				if ($conf->use_javascript_ajax)
2290
+				{
2291
+					print "\n";
2292
+					print '<script language="JavaScript" type="text/javascript">';
2293
+					print "function CheckVAT(a) {\n";
2294
+					print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,285);\n";
2295
+					print "}\n";
2296
+					print '</script>';
2297
+					print "\n";
2298
+					$s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>';
2299
+					$s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
2300
+				}
2301
+				else
2302
+				{
2303
+					$s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
2304
+				}
2305
+			}
2306
+			print $s;
2307
+		}
2308
+		else
2309
+		{
2310
+			print '&nbsp;';
2311
+		}
2312
+		print '</td>';
2313
+		print '</tr>';
2314
+
2315
+		// Type + Staff
2316
+		$arr = $formcompany->typent_array(1);
2317
+		$object->typent= $arr[$object->typent_code];
2318
+		print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'.$object->typent.'</td>';
2319
+		print '<tr><td>'.$langs->trans("Staff").'</td><td>'.$object->effectif.'</td></tr>';
2320
+
2321
+		print '</table>';
2322
+
2323
+		print '</div>';
2324
+		print '<div class="fichehalfright"><div class="ficheaddleft">';
2325
+
2326
+		print '<div class="underbanner clearboth"></div>';
2327
+		print '<table class="border tableforfield" width="100%">';
2328
+
2329
+		// Tags / categories
2330 2330
 		if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
2331 2331
 		{
2332 2332
 			// Customer
@@ -2346,40 +2346,40 @@  discard block
 block discarded – undo
2346 2346
 			}
2347 2347
 		}
2348 2348
 
2349
-        // Legal
2350
-        print '<tr><td class="titlefield">'.$langs->trans('JuridicalStatus').'</td><td>'.$object->forme_juridique.'</td></tr>';
2349
+		// Legal
2350
+		print '<tr><td class="titlefield">'.$langs->trans('JuridicalStatus').'</td><td>'.$object->forme_juridique.'</td></tr>';
2351 2351
 
2352
-        // Capital
2353
-        print '<tr><td>'.$langs->trans('Capital').'</td><td>';
2354
-        if ($object->capital) print price($object->capital,'',$langs,0,-1,-1, $conf->currency);
2355
-        else print '&nbsp;';
2356
-        print '</td></tr>';
2352
+		// Capital
2353
+		print '<tr><td>'.$langs->trans('Capital').'</td><td>';
2354
+		if ($object->capital) print price($object->capital,'',$langs,0,-1,-1, $conf->currency);
2355
+		else print '&nbsp;';
2356
+		print '</td></tr>';
2357 2357
 
2358
-        // Default language
2359
-        if (! empty($conf->global->MAIN_MULTILANGS))
2360
-        {
2361
-            require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2362
-            print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
2363
-            //$s=picto_from_langcode($object->default_lang);
2364
-            //print ($s?$s.' ':'');
2365
-            $langs->load("languages");
2366
-            $labellang = ($object->default_lang?$langs->trans('Language_'.$object->default_lang):'');
2367
-            print $labellang;
2368
-            print '</td></tr>';
2369
-        }
2358
+		// Default language
2359
+		if (! empty($conf->global->MAIN_MULTILANGS))
2360
+		{
2361
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2362
+			print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
2363
+			//$s=picto_from_langcode($object->default_lang);
2364
+			//print ($s?$s.' ':'');
2365
+			$langs->load("languages");
2366
+			$labellang = ($object->default_lang?$langs->trans('Language_'.$object->default_lang):'');
2367
+			print $labellang;
2368
+			print '</td></tr>';
2369
+		}
2370 2370
 
2371 2371
 		// Incoterms
2372 2372
 		if (!empty($conf->incoterm->enabled))
2373 2373
 		{
2374 2374
 			print '<tr><td>';
2375
-            print '<table width="100%" class="nobordernopadding"><tr><td>';
2376
-            print $langs->trans('IncotermLabel');
2377
-            print '<td><td align="right">';
2378
-            if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$object->id.'&action=editincoterm">'.img_edit('',1).'</a>';
2379
-            else print '&nbsp;';
2380
-            print '</td></tr></table>';
2381
-            print '</td>';
2382
-            print '<td colspan="3">';
2375
+			print '<table width="100%" class="nobordernopadding"><tr><td>';
2376
+			print $langs->trans('IncotermLabel');
2377
+			print '<td><td align="right">';
2378
+			if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$object->id.'&action=editincoterm">'.img_edit('',1).'</a>';
2379
+			else print '&nbsp;';
2380
+			print '</td></tr></table>';
2381
+			print '</td>';
2382
+			print '<td colspan="3">';
2383 2383
 			if ($action != 'editincoterm')
2384 2384
 			{
2385 2385
 				print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 			{
2389 2389
 				print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id);
2390 2390
 			}
2391
-            print '</td></tr>';
2391
+			print '</td></tr>';
2392 2392
 		}
2393 2393
 
2394 2394
 		// Multicurrency
@@ -2396,8 +2396,8 @@  discard block
 block discarded – undo
2396 2396
 		{
2397 2397
 			print '<tr>';
2398 2398
 			print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
2399
-	        print '<td>';
2400
-	        print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : '';
2399
+			print '<td>';
2400
+			print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : '';
2401 2401
 			print '</td></tr>';
2402 2402
 		}
2403 2403
 
@@ -2405,74 +2405,74 @@  discard block
 block discarded – undo
2405 2405
 		$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
2406 2406
 		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
2407 2407
 
2408
-        // Parent company
2409
-        if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
2410
-        {
2411
-        	// Payment term
2412
-        	print '<tr><td>';
2413
-        	print '<table class="nobordernopadding" width="100%"><tr><td>';
2414
-        	print $langs->trans('ParentCompany');
2415
-        	print '</td>';
2416
-        	if ($action != 'editparentcompany') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
2417
-        	print '</tr></table>';
2418
-        	print '</td><td colspan="3">';
2419
-        	if ($action == 'editparentcompany')
2420
-        	{
2421
-        		$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'editparentcompany','s.rowid <> '.$object->id,1);
2422
-        	}
2423
-        	else
2424
-        	{
2425
-        		$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'none','s.rowid <> '.$object->id,1);
2426
-        	}
2427
-        	print '</td>';
2428
-        	print '</tr>';
2429
-        }
2430
-
2431
-        // Sales representative
2432
-        include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
2433
-
2434
-        // Module Adherent
2435
-        if (! empty($conf->adherent->enabled))
2436
-        {
2437
-            $langs->load("members");
2438
-            print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
2439
-            print '<td colspan="3">';
2440
-            $adh=new Adherent($db);
2441
-            $result=$adh->fetch('','',$object->id);
2442
-            if ($result > 0)
2443
-            {
2444
-                $adh->ref=$adh->getFullName($langs);
2445
-                print $adh->getNomUrl(1);
2446
-            }
2447
-            else
2448
-            {
2449
-                print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
2450
-            }
2451
-            print '</td>';
2452
-            print "</tr>\n";
2453
-        }
2454
-
2455
-        // Webservices url/key
2456
-        if (!empty($conf->syncsupplierwebservices->enabled)) {
2457
-            print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';
2458
-            print '<td class="nowrap">'.$langs->trans('WebServiceKey').'</td><td>'.$object->webservices_key.'</td></tr>';
2459
-        }
2460
-
2461
-        print '</table>';
2408
+		// Parent company
2409
+		if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
2410
+		{
2411
+			// Payment term
2412
+			print '<tr><td>';
2413
+			print '<table class="nobordernopadding" width="100%"><tr><td>';
2414
+			print $langs->trans('ParentCompany');
2415
+			print '</td>';
2416
+			if ($action != 'editparentcompany') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
2417
+			print '</tr></table>';
2418
+			print '</td><td colspan="3">';
2419
+			if ($action == 'editparentcompany')
2420
+			{
2421
+				$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'editparentcompany','s.rowid <> '.$object->id,1);
2422
+			}
2423
+			else
2424
+			{
2425
+				$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'none','s.rowid <> '.$object->id,1);
2426
+			}
2427
+			print '</td>';
2428
+			print '</tr>';
2429
+		}
2430
+
2431
+		// Sales representative
2432
+		include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
2433
+
2434
+		// Module Adherent
2435
+		if (! empty($conf->adherent->enabled))
2436
+		{
2437
+			$langs->load("members");
2438
+			print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
2439
+			print '<td colspan="3">';
2440
+			$adh=new Adherent($db);
2441
+			$result=$adh->fetch('','',$object->id);
2442
+			if ($result > 0)
2443
+			{
2444
+				$adh->ref=$adh->getFullName($langs);
2445
+				print $adh->getNomUrl(1);
2446
+			}
2447
+			else
2448
+			{
2449
+				print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
2450
+			}
2451
+			print '</td>';
2452
+			print "</tr>\n";
2453
+		}
2454
+
2455
+		// Webservices url/key
2456
+		if (!empty($conf->syncsupplierwebservices->enabled)) {
2457
+			print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';
2458
+			print '<td class="nowrap">'.$langs->trans('WebServiceKey').'</td><td>'.$object->webservices_key.'</td></tr>';
2459
+		}
2460
+
2461
+		print '</table>';
2462 2462
 		print '</div>';
2463 2463
 
2464
-        print '</div></div>';
2465
-        print '<div style="clear:both"></div>';
2464
+		print '</div></div>';
2465
+		print '<div style="clear:both"></div>';
2466 2466
 
2467
-        dol_fiche_end();
2467
+		dol_fiche_end();
2468 2468
 
2469 2469
 
2470
-        /*
2470
+		/*
2471 2471
          *  Actions
2472 2472
          */
2473
-        if ($action != 'presend')
2474
-        {
2475
-	        print '<div class="tabsAction">'."\n";
2473
+		if ($action != 'presend')
2474
+		{
2475
+			print '<div class="tabsAction">'."\n";
2476 2476
 
2477 2477
 			$parameters=array();
2478 2478
 			$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
@@ -2489,44 +2489,44 @@  discard block
 block discarded – undo
2489 2489
 					}
2490 2490
 				}
2491 2491
 
2492
-		        if (! empty($object->email) || $at_least_one_email_contact)
2493
-		        {
2494
-		        	$langs->load("mails");
2495
-		        	print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&amp;action=presend&amp;mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
2496
-		        }
2497
-		        else
2492
+				if (! empty($object->email) || $at_least_one_email_contact)
2493
+				{
2494
+					$langs->load("mails");
2495
+					print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&amp;action=presend&amp;mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
2496
+				}
2497
+				else
2498
+				{
2499
+					$langs->load("mails");
2500
+			   		print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
2501
+				}
2502
+
2503
+				if ($user->rights->societe->creer)
2504
+				{
2505
+					print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
2506
+				}
2507
+
2508
+				if ($user->rights->societe->supprimer)
2509
+				{
2510
+					print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("MergeThirdparties")).'">'.$langs->trans('Merge').'</a></div>';
2511
+				}
2512
+
2513
+				if ($user->rights->societe->supprimer)
2498 2514
 				{
2499
-		        	$langs->load("mails");
2500
-		       		print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
2501
-		        }
2502
-
2503
-		        if ($user->rights->societe->creer)
2504
-		        {
2505
-		            print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
2506
-		        }
2507
-
2508
-		        if ($user->rights->societe->supprimer)
2509
-		        {
2510
-		        	print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("MergeThirdparties")).'">'.$langs->trans('Merge').'</a></div>';
2511
-		        }
2512
-
2513
-		        if ($user->rights->societe->supprimer)
2514
-		        {
2515
-		            if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))	// We can't use preloaded confirm form with jmobile
2516
-		            {
2517
-		                print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
2518
-		            }
2519
-		            else
2515
+					if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))	// We can't use preloaded confirm form with jmobile
2516
+					{
2517
+						print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
2518
+					}
2519
+					else
2520 2520
 					{
2521
-		                print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
2522
-		            }
2523
-		        }
2521
+						print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
2522
+					}
2523
+				}
2524 2524
 			}
2525 2525
 
2526
-	        print '</div>'."\n";
2527
-        }
2526
+			print '</div>'."\n";
2527
+		}
2528 2528
 
2529
-        //Select mail models is same action as presend
2529
+		//Select mail models is same action as presend
2530 2530
 		if (GETPOST('modelselected')) {
2531 2531
 			$action = 'presend';
2532 2532
 		}
@@ -2535,20 +2535,20 @@  discard block
 block discarded – undo
2535 2535
 		{
2536 2536
 			print '<div class="fichecenter"><div class="fichehalfleft">';
2537 2537
 
2538
-	        if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
2539
-	        {
2538
+			if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
2539
+			{
2540 2540
 				print '<a name="builddoc"></a>'; // ancre
2541 2541
 
2542
-	            /*
2542
+				/*
2543 2543
 	             * Documents generes
2544 2544
 	             */
2545
-	            $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
2546
-	            $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
2547
-	            $genallowed=$user->rights->societe->lire;
2548
-	            $delallowed=$user->rights->societe->creer;
2545
+				$filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
2546
+				$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
2547
+				$genallowed=$user->rights->societe->lire;
2548
+				$delallowed=$user->rights->societe->creer;
2549 2549
 
2550
-	            print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
2551
-	        }
2550
+				print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
2551
+			}
2552 2552
 
2553 2553
 			// Subsidiaries list
2554 2554
 			if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES))
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 
2596 2596
 		include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2597 2597
 
2598
-    }
2598
+	}
2599 2599
 }
2600 2600
 
2601 2601
 
Please login to merge, or discard this patch.