Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/societe/admin/societe.php 1 patch
Indentation   +475 added lines, -475 removed lines patch added patch discarded remove patch
@@ -46,169 +46,169 @@  discard block
 block discarded – undo
46 46
 
47 47
 if ($action == 'setcodeclient')
48 48
 {
49
-	if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
50
-	{
51
-		header("Location: ".$_SERVER["PHP_SELF"]);
52
-		exit;
53
-	}
54
-	else
55
-	{
56
-		dol_print_error($db);
57
-	}
49
+    if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
50
+    {
51
+        header("Location: ".$_SERVER["PHP_SELF"]);
52
+        exit;
53
+    }
54
+    else
55
+    {
56
+        dol_print_error($db);
57
+    }
58 58
 }
59 59
 
60 60
 if ($action == 'setcodecompta')
61 61
 {
62
-	if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
63
-	{
64
-		header("Location: ".$_SERVER["PHP_SELF"]);
65
-		exit;
66
-	}
67
-	else
68
-	{
69
-		dol_print_error($db);
70
-	}
62
+    if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
63
+    {
64
+        header("Location: ".$_SERVER["PHP_SELF"]);
65
+        exit;
66
+    }
67
+    else
68
+    {
69
+        dol_print_error($db);
70
+    }
71 71
 }
72 72
 
73 73
 if ($action == 'updateoptions')
74 74
 {
75
-	if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT'))
76
-	{
77
-		$companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha');
78
-		$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity);
79
-		if (! $res > 0) $error++;
80
-		if (! $error)
81
-	    {
82
-		    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
83
-	    }
84
-	    else
85
-	    {
86
-		    setEventMessages($langs->trans("Error"), null, 'errors');
87
-		}
88
-	}
89
-
90
-	if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT'))
91
-	{
92
-		$contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha');
93
-		$res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity);
94
-		if (! $res > 0) $error++;
95
-		if (! $error)
96
-		{
97
-			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
98
-		}
99
-		else
100
-		{
101
-			setEventMessages($langs->trans("Error"), null, 'errors');
102
-		}
103
-	}
75
+    if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT'))
76
+    {
77
+        $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha');
78
+        $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity);
79
+        if (! $res > 0) $error++;
80
+        if (! $error)
81
+        {
82
+            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
83
+        }
84
+        else
85
+        {
86
+            setEventMessages($langs->trans("Error"), null, 'errors');
87
+        }
88
+    }
89
+
90
+    if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT'))
91
+    {
92
+        $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha');
93
+        $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity);
94
+        if (! $res > 0) $error++;
95
+        if (! $error)
96
+        {
97
+            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
98
+        }
99
+        else
100
+        {
101
+            setEventMessages($langs->trans("Error"), null, 'errors');
102
+        }
103
+    }
104 104
 }
105 105
 
106 106
 // Activate a document generator module
107 107
 if ($action == 'set')
108 108
 {
109
-	$label = GETPOST('label','alpha');
110
-	$scandir = GETPOST('scan_dir','alpha');
109
+    $label = GETPOST('label','alpha');
110
+    $scandir = GETPOST('scan_dir','alpha');
111 111
 
112
-	$type='company';
113
-	$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
114
-	$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
115
-	$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
116
-	$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
117
-	$sql.= ")";
112
+    $type='company';
113
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
114
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
115
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
116
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
117
+    $sql.= ")";
118 118
 
119
-	$resql=$db->query($sql);
120
-	if (! $resql) dol_print_error($db);
119
+    $resql=$db->query($sql);
120
+    if (! $resql) dol_print_error($db);
121 121
 }
122 122
 
123 123
 // Disable a document generator module
124 124
 if ($action== 'del')
125 125
 {
126
-	$type='company';
127
-	$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
128
-	$sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity;
129
-	$resql=$db->query($sql);
130
-	if (! $resql) dol_print_error($db);
126
+    $type='company';
127
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
128
+    $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity;
129
+    $resql=$db->query($sql);
130
+    if (! $resql) dol_print_error($db);
131 131
 }
132 132
 
133 133
 // Define default generator
134 134
 if ($action == 'setdoc')
135 135
 {
136
-	$label = GETPOST('label','alpha');
137
-	$scandir = GETPOST('scan_dir','alpha');
136
+    $label = GETPOST('label','alpha');
137
+    $scandir = GETPOST('scan_dir','alpha');
138 138
 
139
-	$db->begin();
139
+    $db->begin();
140 140
 
141
-	dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity);
141
+    dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity);
142 142
 
143
-	// On active le modele
144
-	$type='company';
145
-	$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
146
-	$sql_del.= " WHERE nom = '".$db->escape(GETPOST('value','alpha'))."'";
147
-	$sql_del.= " AND type = '".$type."'";
148
-	$sql_del.= " AND entity = ".$conf->entity;
143
+    // On active le modele
144
+    $type='company';
145
+    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
146
+    $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value','alpha'))."'";
147
+    $sql_del.= " AND type = '".$type."'";
148
+    $sql_del.= " AND entity = ".$conf->entity;
149 149
     dol_syslog("societe.php ".$sql);
150
-	$result1=$db->query($sql_del);
150
+    $result1=$db->query($sql_del);
151 151
 
152
-	$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
153
-	$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
154
-	$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
155
-	$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
156
-	$sql.= ")";
152
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
153
+    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
154
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
155
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
156
+    $sql.= ")";
157 157
     dol_syslog("societe.php", LOG_DEBUG);
158
-	$result2=$db->query($sql);
159
-	if ($result1 && $result2)
160
-	{
161
-		$db->commit();
162
-	}
163
-	else
164
-	{
165
-	    $db->rollback();
166
-	}
158
+    $result2=$db->query($sql);
159
+    if ($result1 && $result2)
160
+    {
161
+        $db->commit();
162
+    }
163
+    else
164
+    {
165
+        $db->rollback();
166
+    }
167 167
 }
168 168
 
169 169
 //Activate Set ref in list
170 170
 if ($action=="setaddrefinlist") {
171
-	$setaddrefinlist = GETPOST('value','int');
172
-	$res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity);
173
-	if (! $res > 0) $error++;
174
-	if (! $error)
175
-	{
176
-		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
177
-	}
178
-	else
179
-	{
180
-		setEventMessages($langs->trans("Error"), null, 'errors');
181
-	}
171
+    $setaddrefinlist = GETPOST('value','int');
172
+    $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity);
173
+    if (! $res > 0) $error++;
174
+    if (! $error)
175
+    {
176
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
177
+    }
178
+    else
179
+    {
180
+        setEventMessages($langs->trans("Error"), null, 'errors');
181
+    }
182 182
 }
183 183
 
184 184
 //Activate Set adress in list
185 185
 if ($action=="setaddadressinlist") {
186
-	$val = GETPOST('value','int');
187
-	$res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity);
188
-	if (! $res > 0) $error++;
189
-	if (! $error)
190
-	{
191
-		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
192
-	}
193
-	else
194
-	{
195
-		setEventMessages($langs->trans("Error"), null, 'errors');
196
-	}
186
+    $val = GETPOST('value','int');
187
+    $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity);
188
+    if (! $res > 0) $error++;
189
+    if (! $error)
190
+    {
191
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
192
+    }
193
+    else
194
+    {
195
+        setEventMessages($langs->trans("Error"), null, 'errors');
196
+    }
197 197
 }
198 198
 
199 199
 //Activate Ask For Preferred Shipping Method
200 200
 if ($action=="setaskforshippingmet") {
201
-	$setaskforshippingmet = GETPOST('value','int');
202
-	$res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity);
203
-	if (! $res > 0) $error++;
204
-	if (! $error)
205
-	{
206
-		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
207
-	}
208
-	else
209
-	{
210
-		setEventMessages($langs->trans("Error"), null, 'errors');
211
-	}
201
+    $setaskforshippingmet = GETPOST('value','int');
202
+    $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity);
203
+    if (! $res > 0) $error++;
204
+    if (! $error)
205
+    {
206
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
207
+    }
208
+    else
209
+    {
210
+        setEventMessages($langs->trans("Error"), null, 'errors');
211
+    }
212 212
 }
213 213
 
214 214
 //Activate "Disable prospect/customer type"
@@ -229,81 +229,81 @@  discard block
 block discarded – undo
229 229
 //Activate ProfId unique
230 230
 if ($action == 'setprofid')
231 231
 {
232
-	$status = GETPOST('status','alpha');
232
+    $status = GETPOST('status','alpha');
233 233
 
234
-	$idprof="SOCIETE_".$value."_UNIQUE";
235
-	if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
236
-	{
237
-		//header("Location: ".$_SERVER["PHP_SELF"]);
238
-		//exit;
239
-	}
240
-	else
241
-	{
242
-		dol_print_error($db);
243
-	}
234
+    $idprof="SOCIETE_".$value."_UNIQUE";
235
+    if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
236
+    {
237
+        //header("Location: ".$_SERVER["PHP_SELF"]);
238
+        //exit;
239
+    }
240
+    else
241
+    {
242
+        dol_print_error($db);
243
+    }
244 244
 }
245 245
 
246 246
 //Activate ProfId mandatory
247 247
 if ($action == 'setprofidmandatory')
248 248
 {
249
-	$status = GETPOST('status','alpha');
249
+    $status = GETPOST('status','alpha');
250 250
 
251
-	$idprof="SOCIETE_".$value."_MANDATORY";
252
-	if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
253
-	{
254
-		//header("Location: ".$_SERVER["PHP_SELF"]);
255
-		//exit;
256
-	}
257
-	else
258
-	{
259
-		dol_print_error($db);
260
-	}
251
+    $idprof="SOCIETE_".$value."_MANDATORY";
252
+    if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
253
+    {
254
+        //header("Location: ".$_SERVER["PHP_SELF"]);
255
+        //exit;
256
+    }
257
+    else
258
+    {
259
+        dol_print_error($db);
260
+    }
261 261
 }
262 262
 
263 263
 //Activate ProfId invoice mandatory
264 264
 if ($action == 'setprofidinvoicemandatory')
265 265
 {
266
-	$status = GETPOST('status','alpha');
266
+    $status = GETPOST('status','alpha');
267 267
 
268
-	$idprof="SOCIETE_".$value."_INVOICE_MANDATORY";
269
-	if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
270
-	{
271
-		//header("Location: ".$_SERVER["PHP_SELF"]);
272
-		//exit;
273
-	}
274
-	else
275
-	{
276
-		dol_print_error($db);
277
-	}
268
+    $idprof="SOCIETE_".$value."_INVOICE_MANDATORY";
269
+    if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
270
+    {
271
+        //header("Location: ".$_SERVER["PHP_SELF"]);
272
+        //exit;
273
+    }
274
+    else
275
+    {
276
+        dol_print_error($db);
277
+    }
278 278
 }
279 279
 
280 280
 //Set hide closed customer into combox or select
281 281
 if ($action == 'sethideinactivethirdparty')
282 282
 {
283
-	$status = GETPOST('status','alpha');
283
+    $status = GETPOST('status','alpha');
284 284
 
285
-	if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0)
286
-	{
287
-		header("Location: ".$_SERVER["PHP_SELF"]);
288
-		exit;
289
-	}
290
-	else
291
-	{
292
-		dol_print_error($db);
293
-	}
285
+    if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0)
286
+    {
287
+        header("Location: ".$_SERVER["PHP_SELF"]);
288
+        exit;
289
+    }
290
+    else
291
+    {
292
+        dol_print_error($db);
293
+    }
294 294
 }
295 295
 if($action=='setonsearchandlistgooncustomerorsuppliercard'){
296
-       $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int');
297
-       $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity);
298
-       if (! $res > 0) $error++;
299
-       if (! $error)
300
-       {
301
-               setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
302
-       }
303
-       else
304
-       {
305
-               setEventMessages($langs->trans("Error"), null, 'errors');
306
-       }
296
+        $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int');
297
+        $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity);
298
+        if (! $res > 0) $error++;
299
+        if (! $error)
300
+        {
301
+                setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
302
+        }
303
+        else
304
+        {
305
+                setEventMessages($langs->trans("Error"), null, 'errors');
306
+        }
307 307
 }
308 308
 
309 309
 
@@ -343,63 +343,63 @@  discard block
 block discarded – undo
343 343
 
344 344
 foreach ($dirsociete as $dirroot)
345 345
 {
346
-	$dir = dol_buildpath($dirroot,0);
346
+    $dir = dol_buildpath($dirroot,0);
347 347
 
348 348
     $handle = @opendir($dir);
349 349
     if (is_resource($handle))
350 350
     {
351
-    	// Loop on each module find in opened directory
352
-    	while (($file = readdir($handle))!==false)
353
-    	{
354
-    		if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
355
-    		{
356
-    			$file = substr($file, 0, dol_strlen($file)-4);
357
-
358
-    			try {
359
-        			dol_include_once($dirroot.$file.'.php');
360
-    			}
361
-    			catch(Exception $e)
362
-    			{
363
-    			    dol_syslog($e->getMessage(), LOG_ERR);
364
-    			}
365
-
366
-    			$modCodeTiers = new $file;
367
-
368
-    			// Show modules according to features level
369
-    			if ($modCodeTiers->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
370
-    			if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
371
-
372
-    			print '<tr class="oddeven">'."\n";
373
-    			print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
374
-    			print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
375
-    			print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
376
-
377
-    			if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
378
-    			{
379
-    				print '<td align="center">'."\n";
380
-    				print img_picto($langs->trans("Activated"),'switch_on');
381
-    				print "</td>\n";
382
-    			}
383
-    			else
384
-    			{
385
-    				$disabled = false;
386
-    				if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true);
387
-    				print '<td align="center">';
388
-    				if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
389
-    				print img_picto($langs->trans("Disabled"),'switch_off');
390
-    				if (! $disabled) print '</a>';
391
-    				print '</td>';
392
-    			}
393
-
394
-    			print '<td align="center">';
395
-    			$s=$modCodeTiers->getToolTip($langs,null,-1);
396
-    			print $form->textwithpicto('',$s,1);
397
-    			print '</td>';
398
-
399
-    			print '</tr>';
400
-    		}
401
-    	}
402
-    	closedir($handle);
351
+        // Loop on each module find in opened directory
352
+        while (($file = readdir($handle))!==false)
353
+        {
354
+            if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
355
+            {
356
+                $file = substr($file, 0, dol_strlen($file)-4);
357
+
358
+                try {
359
+                    dol_include_once($dirroot.$file.'.php');
360
+                }
361
+                catch(Exception $e)
362
+                {
363
+                    dol_syslog($e->getMessage(), LOG_ERR);
364
+                }
365
+
366
+                $modCodeTiers = new $file;
367
+
368
+                // Show modules according to features level
369
+                if ($modCodeTiers->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
370
+                if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
371
+
372
+                print '<tr class="oddeven">'."\n";
373
+                print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
374
+                print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
375
+                print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
376
+
377
+                if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
378
+                {
379
+                    print '<td align="center">'."\n";
380
+                    print img_picto($langs->trans("Activated"),'switch_on');
381
+                    print "</td>\n";
382
+                }
383
+                else
384
+                {
385
+                    $disabled = false;
386
+                    if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true);
387
+                    print '<td align="center">';
388
+                    if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
389
+                    print img_picto($langs->trans("Disabled"),'switch_off');
390
+                    if (! $disabled) print '</a>';
391
+                    print '</td>';
392
+                }
393
+
394
+                print '<td align="center">';
395
+                $s=$modCodeTiers->getToolTip($langs,null,-1);
396
+                print $form->textwithpicto('',$s,1);
397
+                print '</td>';
398
+
399
+                print '</tr>';
400
+            }
401
+        }
402
+        closedir($handle);
403 403
     }
404 404
 }
405 405
 print '</table>';
@@ -423,53 +423,53 @@  discard block
 block discarded – undo
423 423
 
424 424
 foreach ($dirsociete as $dirroot)
425 425
 {
426
-	$dir = dol_buildpath($dirroot,0);
426
+    $dir = dol_buildpath($dirroot,0);
427 427
 
428
-	$handle = @opendir($dir);
428
+    $handle = @opendir($dir);
429 429
     if (is_resource($handle))
430 430
     {
431
-    	while (($file = readdir($handle))!==false)
432
-    	{
433
-    		if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
434
-    		{
435
-    			$file = substr($file, 0, dol_strlen($file)-4);
436
-
437
-    		    try {
438
-        			dol_include_once($dirroot.$file.'.php');
439
-    			}
440
-    			catch(Exception $e)
441
-    			{
442
-    			    dol_syslog($e->getMessage(), LOG_ERR);
443
-    			}
444
-
445
-    			$modCodeCompta = new $file;
446
-
447
-    			print '<tr class="oddeven">';
448
-    			print '<td>'.$modCodeCompta->name."</td><td>\n";
449
-    			print $modCodeCompta->info($langs);
450
-    			print '</td>';
451
-    			print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
452
-
453
-    			if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
454
-    			{
455
-    				print '<td align="center">';
456
-    				print img_picto($langs->trans("Activated"),'switch_on');
457
-    				print '</td>';
458
-    			}
459
-    			else
460
-    			{
461
-    				print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">';
462
-    				print img_picto($langs->trans("Disabled"),'switch_off');
463
-    				print '</a></td>';
464
-    			}
465
-    			print '<td align="center">';
466
-    			$s=$modCodeCompta->getToolTip($langs,null,-1);
467
-    			print $form->textwithpicto('',$s,1);
468
-    			print '</td>';
469
-    			print "</tr>\n";
470
-    		}
471
-    	}
472
-    	closedir($handle);
431
+        while (($file = readdir($handle))!==false)
432
+        {
433
+            if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
434
+            {
435
+                $file = substr($file, 0, dol_strlen($file)-4);
436
+
437
+                try {
438
+                    dol_include_once($dirroot.$file.'.php');
439
+                }
440
+                catch(Exception $e)
441
+                {
442
+                    dol_syslog($e->getMessage(), LOG_ERR);
443
+                }
444
+
445
+                $modCodeCompta = new $file;
446
+
447
+                print '<tr class="oddeven">';
448
+                print '<td>'.$modCodeCompta->name."</td><td>\n";
449
+                print $modCodeCompta->info($langs);
450
+                print '</td>';
451
+                print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
452
+
453
+                if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
454
+                {
455
+                    print '<td align="center">';
456
+                    print img_picto($langs->trans("Activated"),'switch_on');
457
+                    print '</td>';
458
+                }
459
+                else
460
+                {
461
+                    print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">';
462
+                    print img_picto($langs->trans("Disabled"),'switch_off');
463
+                    print '</a></td>';
464
+                }
465
+                print '<td align="center">';
466
+                $s=$modCodeCompta->getToolTip($langs,null,-1);
467
+                print $form->textwithpicto('',$s,1);
468
+                print '</td>';
469
+                print "</tr>\n";
470
+            }
471
+        }
472
+        closedir($handle);
473 473
     }
474 474
 }
475 475
 print "</table>\n";
@@ -490,18 +490,18 @@  discard block
 block discarded – undo
490 490
 $resql=$db->query($sql);
491 491
 if ($resql)
492 492
 {
493
-	$i = 0;
494
-	$num_rows=$db->num_rows($resql);
495
-	while ($i < $num_rows)
496
-	{
497
-		$array = $db->fetch_array($resql);
498
-		array_push($def, $array[0]);
499
-		$i++;
500
-	}
493
+    $i = 0;
494
+    $num_rows=$db->num_rows($resql);
495
+    while ($i < $num_rows)
496
+    {
497
+        $array = $db->fetch_array($resql);
498
+        array_push($def, $array[0]);
499
+        $i++;
500
+    }
501 501
 }
502 502
 else
503 503
 {
504
-	dol_print_error($db);
504
+    dol_print_error($db);
505 505
 }
506 506
 
507 507
 print '<table class="noborder" width="100%">';
@@ -515,108 +515,108 @@  discard block
 block discarded – undo
515 515
 
516 516
 foreach ($dirsociete as $dirroot)
517 517
 {
518
-	$dir = dol_buildpath($dirroot.'doc/',0);
519
-
520
-	$handle=@opendir($dir);
521
-	if (is_resource($handle))
522
-	{
523
-		while (($file = readdir($handle))!==false)
524
-		{
525
-			if (preg_match('/\.modules\.php$/i',$file))
526
-			{
527
-				$name = substr($file, 4, dol_strlen($file) -16);
528
-				$classname = substr($file, 0, dol_strlen($file) -12);
529
-
530
-			    try {
531
-        			dol_include_once($dirroot.'doc/'.$file);
532
-    			}
533
-    			catch(Exception $e)
534
-    			{
535
-    			    dol_syslog($e->getMessage(), LOG_ERR);
536
-    			}
537
-
538
-    			$module = new $classname($db);
539
-
540
-				$modulequalified=1;
541
-				if (! empty($module->version)) {
542
-					if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
543
-					else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
544
-				}
545
-
546
-				if ($modulequalified)
547
-				{
548
-					print '<tr class="oddeven"><td width="100">';
549
-					print $module->name;
550
-					print "</td><td>\n";
551
-					if (method_exists($module,'info')) print $module->info($langs);
552
-					else print $module->description;
553
-					print '</td>';
554
-
555
-					// Activate / Disable
556
-					if (in_array($name, $def))
557
-					{
558
-						print "<td align=\"center\">\n";
559
-						//if ($conf->global->COMPANY_ADDON_PDF != "$name")
560
-						//{
561
-							print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
562
-							print img_picto($langs->trans("Enabled"),'switch_on');
563
-							print '</a>';
564
-						//}
565
-						//else
566
-						//{
567
-						//	print img_picto($langs->trans("Enabled"),'on');
568
-						//}
569
-						print "</td>";
570
-					}
571
-					else
572
-					{
573
-						if (versioncompare($module->phpmin,versionphparray()) > 0)
574
-						{
575
-							print "<td align=\"center\">\n";
576
-							print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off');
577
-							print "</td>";
578
-						}
579
-						else
580
-						{
581
-							print "<td align=\"center\">\n";
582
-							print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
583
-							print "</td>";
584
-						}
585
-					}
586
-
587
-					// Info
588
-					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
589
-					$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
590
-					if ($module->type == 'pdf')
591
-					{
592
-						$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
593
-					}
594
-					$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
595
-					$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1);
596
-
597
-					print '<td align="center" class="nowrap">';
598
-					print $form->textwithpicto('',$htmltooltip,1,0);
599
-					print '</td>';
600
-
601
-					// Preview
602
-					print '<td align="center" class="nowrap">';
603
-					if ($module->type == 'pdf')
604
-					{
605
-						$linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
606
-					}
607
-					else
608
-					{
609
-						$linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic');
610
-					}
611
-					print $linkspec;
612
-					print '</td>';
613
-
614
-					print "</tr>\n";
615
-				}
616
-			}
617
-		}
618
-		closedir($handle);
619
-	}
518
+    $dir = dol_buildpath($dirroot.'doc/',0);
519
+
520
+    $handle=@opendir($dir);
521
+    if (is_resource($handle))
522
+    {
523
+        while (($file = readdir($handle))!==false)
524
+        {
525
+            if (preg_match('/\.modules\.php$/i',$file))
526
+            {
527
+                $name = substr($file, 4, dol_strlen($file) -16);
528
+                $classname = substr($file, 0, dol_strlen($file) -12);
529
+
530
+                try {
531
+                    dol_include_once($dirroot.'doc/'.$file);
532
+                }
533
+                catch(Exception $e)
534
+                {
535
+                    dol_syslog($e->getMessage(), LOG_ERR);
536
+                }
537
+
538
+                $module = new $classname($db);
539
+
540
+                $modulequalified=1;
541
+                if (! empty($module->version)) {
542
+                    if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
543
+                    else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
544
+                }
545
+
546
+                if ($modulequalified)
547
+                {
548
+                    print '<tr class="oddeven"><td width="100">';
549
+                    print $module->name;
550
+                    print "</td><td>\n";
551
+                    if (method_exists($module,'info')) print $module->info($langs);
552
+                    else print $module->description;
553
+                    print '</td>';
554
+
555
+                    // Activate / Disable
556
+                    if (in_array($name, $def))
557
+                    {
558
+                        print "<td align=\"center\">\n";
559
+                        //if ($conf->global->COMPANY_ADDON_PDF != "$name")
560
+                        //{
561
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
562
+                            print img_picto($langs->trans("Enabled"),'switch_on');
563
+                            print '</a>';
564
+                        //}
565
+                        //else
566
+                        //{
567
+                        //	print img_picto($langs->trans("Enabled"),'on');
568
+                        //}
569
+                        print "</td>";
570
+                    }
571
+                    else
572
+                    {
573
+                        if (versioncompare($module->phpmin,versionphparray()) > 0)
574
+                        {
575
+                            print "<td align=\"center\">\n";
576
+                            print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off');
577
+                            print "</td>";
578
+                        }
579
+                        else
580
+                        {
581
+                            print "<td align=\"center\">\n";
582
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
583
+                            print "</td>";
584
+                        }
585
+                    }
586
+
587
+                    // Info
588
+                    $htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
589
+                    $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
590
+                    if ($module->type == 'pdf')
591
+                    {
592
+                        $htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
593
+                    }
594
+                    $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
595
+                    $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1);
596
+
597
+                    print '<td align="center" class="nowrap">';
598
+                    print $form->textwithpicto('',$htmltooltip,1,0);
599
+                    print '</td>';
600
+
601
+                    // Preview
602
+                    print '<td align="center" class="nowrap">';
603
+                    if ($module->type == 'pdf')
604
+                    {
605
+                        $linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
606
+                    }
607
+                    else
608
+                    {
609
+                        $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic');
610
+                    }
611
+                    print $linkspec;
612
+                    print '</td>';
613
+
614
+                    print "</tr>\n";
615
+                }
616
+            }
617
+        }
618
+        closedir($handle);
619
+    }
620 620
 }
621 621
 print '</table>';
622 622
 
@@ -652,63 +652,63 @@  discard block
 block discarded – undo
652 652
 $nbofloop=count($profid);
653 653
 foreach($profid as $key => $val)
654 654
 {
655
-	if ($profid[$key][1]!='-')
656
-	{
657
-		print '<tr class="oddeven">';
658
-		print '<td>'.$profid[$key][0]."</td><td>\n";
659
-		print $profid[$key][1];
660
-		print '</td>';
661
-
662
-		$idprof_unique ='SOCIETE_'.$key.'_UNIQUE';
663
-		$idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY';
664
-		$idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY';
665
-
666
-		$verif=(empty($conf->global->$idprof_unique)?false:true);
667
-		$mandatory=(empty($conf->global->$idprof_mandatory)?false:true);
668
-		$invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true);
669
-
670
-		if ($verif)
671
-		{
672
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">';
673
-			print img_picto($langs->trans("Activated"),'switch_on');
674
-			print '</a></td>';
675
-		}
676
-		else
677
-		{
678
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">';
679
-			print img_picto($langs->trans("Disabled"),'switch_off');
680
-			print '</a></td>';
681
-		}
682
-
683
-		if ($mandatory)
684
-		{
685
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">';
686
-			print img_picto($langs->trans("Activated"),'switch_on');
687
-			print '</a></td>';
688
-		}
689
-		else
690
-		{
691
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">';
692
-			print img_picto($langs->trans("Disabled"),'switch_off');
693
-			print '</a></td>';
694
-		}
695
-
696
-		if ($invoice_mandatory)
697
-		{
698
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">';
699
-			print img_picto($langs->trans("Activated"),'switch_on');
700
-			print '</a></td>';
701
-		}
702
-		else
703
-		{
704
-			print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">';
705
-			print img_picto($langs->trans("Disabled"),'switch_off');
706
-			print '</a></td>';
707
-		}
708
-
709
-		print "</tr>\n";
710
-	}
711
-	$i++;
655
+    if ($profid[$key][1]!='-')
656
+    {
657
+        print '<tr class="oddeven">';
658
+        print '<td>'.$profid[$key][0]."</td><td>\n";
659
+        print $profid[$key][1];
660
+        print '</td>';
661
+
662
+        $idprof_unique ='SOCIETE_'.$key.'_UNIQUE';
663
+        $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY';
664
+        $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY';
665
+
666
+        $verif=(empty($conf->global->$idprof_unique)?false:true);
667
+        $mandatory=(empty($conf->global->$idprof_mandatory)?false:true);
668
+        $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true);
669
+
670
+        if ($verif)
671
+        {
672
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">';
673
+            print img_picto($langs->trans("Activated"),'switch_on');
674
+            print '</a></td>';
675
+        }
676
+        else
677
+        {
678
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">';
679
+            print img_picto($langs->trans("Disabled"),'switch_off');
680
+            print '</a></td>';
681
+        }
682
+
683
+        if ($mandatory)
684
+        {
685
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">';
686
+            print img_picto($langs->trans("Activated"),'switch_on');
687
+            print '</a></td>';
688
+        }
689
+        else
690
+        {
691
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">';
692
+            print img_picto($langs->trans("Disabled"),'switch_off');
693
+            print '</a></td>';
694
+        }
695
+
696
+        if ($invoice_mandatory)
697
+        {
698
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">';
699
+            print img_picto($langs->trans("Activated"),'switch_on');
700
+            print '</a></td>';
701
+        }
702
+        else
703
+        {
704
+            print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">';
705
+            print img_picto($langs->trans("Disabled"),'switch_off');
706
+            print '</a></td>';
707
+        }
708
+
709
+        print "</tr>\n";
710
+    }
711
+    $i++;
712 712
 }
713 713
 
714 714
 print "</table><br>\n";
@@ -735,22 +735,22 @@  discard block
 block discarded – undo
735 735
 print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"),$langs->trans('UseSearchToSelectCompanyTooltip'),1).' </td>';
736 736
 if (! $conf->use_javascript_ajax)
737 737
 {
738
-	print '<td class="nowrap" align="right" colspan="2">';
739
-	print $langs->trans("NotAvailableWhenAjaxDisabled");
740
-	print "</td>";
738
+    print '<td class="nowrap" align="right" colspan="2">';
739
+    print $langs->trans("NotAvailableWhenAjaxDisabled");
740
+    print "</td>";
741 741
 }
742 742
 else
743 743
 {
744
-	print '<td width="60" align="right">';
745
-	$arrval=array('0'=>$langs->trans("No"),
746
-	'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
744
+    print '<td width="60" align="right">';
745
+    $arrval=array('0'=>$langs->trans("No"),
746
+    '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
747 747
     '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
748 748
     '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
749
-	);
750
-	print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
751
-	print '</td><td align="right">';
752
-	print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
753
-	print "</td>";
749
+    );
750
+    print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
751
+    print '</td><td align="right">';
752
+    print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
753
+    print "</td>";
754 754
 }
755 755
 print '</tr>';
756 756
 
@@ -759,22 +759,22 @@  discard block
 block discarded – undo
759 759
 print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"),$langs->trans('UseSearchToSelectContactTooltip'),1).'</td>';
760 760
 if (! $conf->use_javascript_ajax)
761 761
 {
762
-	print '<td class="nowrap" align="right" colspan="2">';
763
-	print $langs->trans("NotAvailableWhenAjaxDisabled");
764
-	print "</td>";
762
+    print '<td class="nowrap" align="right" colspan="2">';
763
+    print $langs->trans("NotAvailableWhenAjaxDisabled");
764
+    print "</td>";
765 765
 }
766 766
 else
767 767
 {
768
-	print '<td width="60" align="right">';
769
-	$arrval=array('0'=>$langs->trans("No"),
770
-	'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
771
-	'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
772
-	'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
773
-	);
774
-	print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
775
-	print '</td><td align="right">';
776
-	print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
777
-	print "</td>";
768
+    print '<td width="60" align="right">';
769
+    $arrval=array('0'=>$langs->trans("No"),
770
+    '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
771
+    '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
772
+    '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
773
+    );
774
+    print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
775
+    print '</td><td align="right">';
776
+    print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
777
+    print "</td>";
778 778
 }
779 779
 print '</tr>';
780 780
 
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 print '<td align="center">';
787 787
 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST))
788 788
 {
789
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">';
790
-	print img_picto($langs->trans("Activated"),'switch_on');
789
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">';
790
+    print img_picto($langs->trans("Activated"),'switch_on');
791 791
 }
792 792
 else
793 793
 {
794
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">';
795
-	print img_picto($langs->trans("Disabled"),'switch_off');
794
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">';
795
+    print img_picto($langs->trans("Disabled"),'switch_off');
796 796
 }
797 797
 print '</a></td>';
798 798
 print '</tr>';
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
 print '<td align="center">';
804 804
 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST))
805 805
 {
806
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">';
807
-	print img_picto($langs->trans("Activated"),'switch_on');
806
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">';
807
+    print img_picto($langs->trans("Activated"),'switch_on');
808 808
 }
809 809
 else
810 810
 {
811
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">';
812
-	print img_picto($langs->trans("Disabled"),'switch_off');
811
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">';
812
+    print img_picto($langs->trans("Disabled"),'switch_off');
813 813
 }
814 814
 print '</a></td>';
815 815
 print '</tr>';
@@ -822,13 +822,13 @@  discard block
 block discarded – undo
822 822
 print '<td align="center">';
823 823
 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD))
824 824
 {
825
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">';
826
-	print img_picto($langs->trans("Activated"),'switch_on');
825
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">';
826
+    print img_picto($langs->trans("Activated"),'switch_on');
827 827
 }
828 828
 else
829 829
 {
830
-	print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">';
831
-	print img_picto($langs->trans("Disabled"),'switch_off');
830
+    print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">';
831
+    print img_picto($langs->trans("Disabled"),'switch_off');
832 832
 }
833 833
 print '</a></td>';
834 834
 print '</tr>';
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/admin/contact_extrafields.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,8 +93,8 @@
 block discarded – undo
93 93
 
94 94
 if ($action == 'create')
95 95
 {
96
-	print '<br><div id="newattrib"></div>';
97
-	print load_fiche_titre($langs->trans('NewAttribute'));
96
+    print '<br><div id="newattrib"></div>';
97
+    print load_fiche_titre($langs->trans('NewAttribute'));
98 98
 
99 99
     require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
100 100
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/ajax/company.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,48 +50,48 @@
 block discarded – undo
50 50
 
51 51
 if (! empty($action) && $action == 'fetch' && ! empty($id))
52 52
 {
53
-	require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
53
+    require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
54 54
 
55
-	$outjson=array();
55
+    $outjson=array();
56 56
 
57
-	$object = new Societe($db);
58
-	$ret=$object->fetch($id);
59
-	if ($ret > 0)
60
-	{
61
-		$outname=$object->name;
62
-		$outlabel = '';
63
-		$outdesc = '';
64
-		$outtype = $object->type;
57
+    $object = new Societe($db);
58
+    $ret=$object->fetch($id);
59
+    if ($ret > 0)
60
+    {
61
+        $outname=$object->name;
62
+        $outlabel = '';
63
+        $outdesc = '';
64
+        $outtype = $object->type;
65 65
 
66
-		$outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype);
67
-	}
66
+        $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype);
67
+    }
68 68
 
69
-	echo json_encode($outjson);
69
+    echo json_encode($outjson);
70 70
 }
71 71
 else
72 72
 {
73
-	require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
73
+    require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
74 74
 
75
-	$langs->load("companies");
75
+    $langs->load("companies");
76 76
 
77
-	top_httphead();
77
+    top_httphead();
78 78
 
79
-	if (empty($htmlname)) return;
79
+    if (empty($htmlname)) return;
80 80
 
81
-	$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
82
-	sort($match);
83
-	$id = (! empty($match[0]) ? $match[0] : '');
81
+    $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
82
+    sort($match);
83
+    $id = (! empty($match[0]) ? $match[0] : '');
84 84
 
85
-	// When used from jQuery, the search term is added as GET param "term".
86
-	$searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):''));
85
+    // When used from jQuery, the search term is added as GET param "term".
86
+    $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):''));
87 87
 
88
-	if (! $searchkey) return;
88
+    if (! $searchkey) return;
89 89
 
90
-	if (! is_object($form)) $form = new Form($db);
91
-	$arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
90
+    if (! is_object($form)) $form = new Form($db);
91
+    $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
92 92
 
93
-	$db->close();
93
+    $db->close();
94 94
 
95
-	if ($outjson) print json_encode($arrayresult);
95
+    if ($outjson) print json_encode($arrayresult);
96 96
 }
97 97
 
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/checkvat/checkVatPopup.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -49,117 +49,117 @@  discard block
 block discarded – undo
49 49
 
50 50
 if (! $vatNumber)
51 51
 {
52
-	print '<br>';
53
-	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>';
52
+    print '<br>';
53
+    print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>';
54 54
 }
55 55
 else
56 56
 {
57
-	$vatNumber = preg_replace('/\^\w/', '', $vatNumber);
58
-	$countryCode=substr($vatNumber,0,2);
59
-	$vatNumber=substr($vatNumber,2);
57
+    $vatNumber = preg_replace('/\^\w/', '', $vatNumber);
58
+    $countryCode=substr($vatNumber,0,2);
59
+    $vatNumber=substr($vatNumber,2);
60 60
 
61
-	print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>';
62
-	print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>';
63
-	print '<br>';
61
+    print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>';
62
+    print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>';
63
+    print '<br>';
64 64
 
65
-	// Set the parameters to send to the WebService
66
-	$parameters = array("countryCode" => $countryCode,
67
-						"vatNumber" => $vatNumber);
65
+    // Set the parameters to send to the WebService
66
+    $parameters = array("countryCode" => $countryCode,
67
+                        "vatNumber" => $vatNumber);
68 68
 
69
-	// Set the WebService URL
70
-	dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL);
69
+    // Set the WebService URL
70
+    dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL);
71 71
     require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
72 72
     $params=getSoapParams();
73 73
     //ini_set('default_socket_timeout', $params['response_timeout']);
74 74
     //$soapclient = new SoapClient($WS_DOL_URL_WSDL,$params);
75
-	$soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']);
76
-	$soapclient->soap_defencoding = 'utf-8';
77
-	$soapclient->xml_encoding = 'utf-8';
78
-	$soapclient->decode_utf8 = false;
79
-
80
-	// Check for an error
81
-	$err = $soapclient->getError();
82
-	if ($err)
83
-	{
84
-		dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
85
-	}
86
-
87
-	// Call the WebService and store its result in $result.
88
-	dol_syslog("Call method ".$WS_METHOD);
89
-	$result = $soapclient->call($WS_METHOD,$parameters);
90
-
91
-	//var_dump($parameters);
92
-	//var_dump($soapclient);
93
-	//print "x".is_array($result)."i";
94
-	//var_dump($result);
95
-	//print $soapclient->request.'<br>';
96
-	//print $soapclient->response.'<br>';
97
-
98
-	$messagetoshow='';
99
-	print '<b>'.$langs->trans("Response").'</b>:<br>';
100
-
101
-	// Service indisponible
102
-	if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring']))
103
-	{
104
-		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
105
-		$messagetoshow=$soapclient->response;
106
-	}
107
-	elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
108
-	{
109
-		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
110
-		$messagetoshow=$soapclient->response;
111
-	}
112
-	elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
113
-	{
114
-		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
115
-		$messagetoshow=$soapclient->response;
116
-	}
117
-	elseif ($result['faultstring'])
118
-	{
119
-		print '<font class="error">'.$langs->trans("Error").'</font><br>';
120
-		$messagetoshow=$result['faultstring'];
121
-	}
122
-	// Syntaxe ko
123
-	elseif (preg_match('/INVALID_INPUT/i',$result['faultstring'])
124
-	|| ($result['requestDate'] && ! $result['valid']))
125
-	{
126
-		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
127
-		print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
128
-		print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
129
-		//$messagetoshow=$soapclient->response;
130
-	}
131
-	else
132
-	{
133
-		// Syntaxe ok
134
-		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
135
-		print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
136
-		print $langs->trans("ValueIsValid").': ';
137
-		if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring']))
138
-		{
139
-			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>';
140
-		}
141
-		else
142
-		{
143
-			if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true'))
144
-			{
145
-				print '<font class="ok">'.$langs->trans("Yes").'</font>';
146
-				print '<br>';
147
-				print $langs->trans("Name").': '.$result['name'].'<br>';
148
-				print $langs->trans("Address").': '.$result['address'].'<br>';
149
-			}
150
-			else
151
-			{
152
-				print '<font class="error">'.$langs->trans("No").'</font>';
153
-				print '<br>'."\n";
154
-			}
155
-		}
156
-	}
157
-
158
-	// Show log data into page
159
-	print "\n";
160
-	print '<!-- ';
161
-	var_dump($result);
162
-	print '-->';
75
+    $soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']);
76
+    $soapclient->soap_defencoding = 'utf-8';
77
+    $soapclient->xml_encoding = 'utf-8';
78
+    $soapclient->decode_utf8 = false;
79
+
80
+    // Check for an error
81
+    $err = $soapclient->getError();
82
+    if ($err)
83
+    {
84
+        dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
85
+    }
86
+
87
+    // Call the WebService and store its result in $result.
88
+    dol_syslog("Call method ".$WS_METHOD);
89
+    $result = $soapclient->call($WS_METHOD,$parameters);
90
+
91
+    //var_dump($parameters);
92
+    //var_dump($soapclient);
93
+    //print "x".is_array($result)."i";
94
+    //var_dump($result);
95
+    //print $soapclient->request.'<br>';
96
+    //print $soapclient->response.'<br>';
97
+
98
+    $messagetoshow='';
99
+    print '<b>'.$langs->trans("Response").'</b>:<br>';
100
+
101
+    // Service indisponible
102
+    if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring']))
103
+    {
104
+        print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
105
+        $messagetoshow=$soapclient->response;
106
+    }
107
+    elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
108
+    {
109
+        print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
110
+        $messagetoshow=$soapclient->response;
111
+    }
112
+    elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
113
+    {
114
+        print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
115
+        $messagetoshow=$soapclient->response;
116
+    }
117
+    elseif ($result['faultstring'])
118
+    {
119
+        print '<font class="error">'.$langs->trans("Error").'</font><br>';
120
+        $messagetoshow=$result['faultstring'];
121
+    }
122
+    // Syntaxe ko
123
+    elseif (preg_match('/INVALID_INPUT/i',$result['faultstring'])
124
+    || ($result['requestDate'] && ! $result['valid']))
125
+    {
126
+        if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
127
+        print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
128
+        print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
129
+        //$messagetoshow=$soapclient->response;
130
+    }
131
+    else
132
+    {
133
+        // Syntaxe ok
134
+        if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
135
+        print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
136
+        print $langs->trans("ValueIsValid").': ';
137
+        if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring']))
138
+        {
139
+            print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>';
140
+        }
141
+        else
142
+        {
143
+            if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true'))
144
+            {
145
+                print '<font class="ok">'.$langs->trans("Yes").'</font>';
146
+                print '<br>';
147
+                print $langs->trans("Name").': '.$result['name'].'<br>';
148
+                print $langs->trans("Address").': '.$result['address'].'<br>';
149
+            }
150
+            else
151
+            {
152
+                print '<font class="error">'.$langs->trans("No").'</font>';
153
+                print '<br>'."\n";
154
+            }
155
+        }
156
+    }
157
+
158
+    // Show log data into page
159
+    print "\n";
160
+    print '<!-- ';
161
+    var_dump($result);
162
+    print '-->';
163 163
 }
164 164
 
165 165
 print '<br>';
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 
170 170
 if ($messagetoshow)
171 171
 {
172
-	print '<br><br>';
173
-	print "\n".'Error returned:<br>';
174
-	print nl2br($messagetoshow);
172
+    print '<br><br>';
173
+    print "\n".'Error returned:<br>';
174
+    print nl2br($messagetoshow);
175 175
 }
176 176
 
177 177
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/paymentmodes.php 1 patch
Indentation   +1402 added lines, -1402 removed lines patch added patch discarded remove patch
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 
72 72
 if (! empty($conf->stripe->enabled))
73 73
 {
74
-	$service = 'StripeTest';
75
-	$servicestatus = 0;
76
-	if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
77
-	{
78
-		$service = 'StripeLive';
79
-		$servicestatus = 1;
80
-	}
81
-
82
-	$stripe = new Stripe($db);
83
-	$stripeacc = $stripe->getStripeAccount($service);								// Get Stripe OAuth connect account (no network access here)
84
-	$stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus);		// Get remote Stripe customer 'cus_...' (no network access here)
74
+    $service = 'StripeTest';
75
+    $servicestatus = 0;
76
+    if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
77
+    {
78
+        $service = 'StripeLive';
79
+        $servicestatus = 1;
80
+    }
81
+
82
+    $stripe = new Stripe($db);
83
+    $stripeacc = $stripe->getStripeAccount($service);								// Get Stripe OAuth connect account (no network access here)
84
+    $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus);		// Get remote Stripe customer 'cus_...' (no network access here)
85 85
 }
86 86
 
87 87
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 if ($cancel)
94 94
 {
95
-	$action='';
95
+    $action='';
96 96
 }
97 97
 
98 98
 $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
@@ -101,546 +101,546 @@  discard block
 block discarded – undo
101 101
 
102 102
 if (empty($reshook))
103 103
 {
104
-	if ($cancel)
105
-	{
106
-		$action='';
107
-		if (! empty($backtopage))
108
-		{
109
-			header("Location: ".$backtopage);
110
-			exit;
111
-		}
112
-	}
113
-
114
-	if ($action == 'update')
115
-	{
116
-		// Modification
117
-		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
118
-		{
119
-			if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
120
-			if (! GETPOST('bank','alpha'))  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
121
-			$action='edit';
122
-			$error++;
123
-		}
124
-		if ($companybankaccount->needIBAN() == 1)
125
-		{
126
-			if (! GETPOST('iban'))
127
-			{
128
-				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
129
-				$action='edit';
130
-				$error++;
131
-			}
132
-			if (! GETPOST('bic'))
133
-			{
134
-				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
135
-				$action='edit';
136
-				$error++;
137
-			}
138
-		}
139
-
140
-		$companybankaccount->fetch($id);
141
-		if (! $error)
142
-		{
143
-			$companybankaccount->socid           = $object->id;
144
-
145
-			$companybankaccount->bank            = GETPOST('bank','alpha');
146
-			$companybankaccount->label           = GETPOST('label','alpha');
147
-			$companybankaccount->courant         = GETPOST('courant','alpha');
148
-			$companybankaccount->clos            = GETPOST('clos','alpha');
149
-			$companybankaccount->code_banque     = GETPOST('code_banque','alpha');
150
-			$companybankaccount->code_guichet    = GETPOST('code_guichet','alpha');
151
-			$companybankaccount->number          = GETPOST('number','alpha');
152
-			$companybankaccount->cle_rib         = GETPOST('cle_rib','alpha');
153
-			$companybankaccount->bic             = GETPOST('bic','alpha');
154
-			$companybankaccount->iban            = GETPOST('iban','alpha');
155
-			$companybankaccount->domiciliation   = GETPOST('domiciliation','alpha');
156
-			$companybankaccount->proprio         = GETPOST('proprio','alpha');
157
-			$companybankaccount->owner_address   = GETPOST('owner_address','alpha');
158
-			$companybankaccount->frstrecur       = GETPOST('frstrecur','alpha');
159
-			$companybankaccount->rum             = GETPOST('rum','alpha');
160
-			if (empty($companybankaccount->rum))
161
-			{
162
-				$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
163
-				$companybankaccount->date_rum = dol_now();
164
-			}
165
-
166
-			$result = $companybankaccount->update($user);
167
-			if (! $result)
168
-			{
169
-				setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
170
-			}
171
-			else
172
-			{
173
-				// If this account is the default bank account, we disable others
174
-				if ($companybankaccount->default_rib)
175
-				{
176
-					$companybankaccount->setAsDefault($id);	// This will make sure there is only one default rib
177
-				}
178
-
179
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
180
-				header('Location: '.$url);
181
-				exit;
182
-			}
183
-		}
184
-	}
185
-
186
-	if ($action == 'updatecard')
187
-	{
188
-		// Modification
189
-		if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
190
-		{
191
-			if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
192
-			if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
193
-			if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
194
-			if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
195
-			if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
196
-			$action='createcard';
197
-			$error++;
198
-		}
199
-
200
-		$companypaymentmode->fetch($id);
201
-		if (! $error)
202
-		{
203
-			$companypaymentmode->fk_soc          = $object->id;
204
-
205
-			$companypaymentmode->bank            = GETPOST('bank','alpha');
206
-			$companypaymentmode->label           = GETPOST('label','alpha');
207
-			$companypaymentmode->number          = GETPOST('cardnumber','alpha');
208
-			$companypaymentmode->last_four       = substr(GETPOST('cardnumber','alpha'), -4);
209
-			$companypaymentmode->proprio         = GETPOST('proprio','alpha');
210
-			$companypaymentmode->exp_date_month  = GETPOST('exp_date_month','int');
211
-			$companypaymentmode->exp_date_year   = GETPOST('exp_date_year','int');
212
-			$companypaymentmode->cvn             = GETPOST('cvn','alpha');
213
-			$companypaymentmode->country_code    = $object->country_code;
214
-
215
-			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
216
-
217
-			$result = $companypaymentmode->update($user);
218
-			if (! $result)
219
-			{
220
-				setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
221
-			}
222
-			else
223
-			{
224
-				// If this account is the default bank account, we disable others
225
-				if ($companypaymentmode->default_rib)
226
-				{
227
-					$companypaymentmode->setAsDefault($id);	// This will make sure there is only one default rib
228
-				}
229
-
230
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
231
-				header('Location: '.$url);
232
-				exit;
233
-			}
234
-		}
235
-	}
236
-
237
-	if ($action == 'add')
238
-	{
239
-		$error=0;
240
-
241
-		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
242
-		{
243
-			if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
244
-			if (! GETPOST('bank','alpha'))  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
245
-			$action='create';
246
-			$error++;
247
-		}
248
-
249
-		if (! $error)
250
-		{
251
-			// Ajout
252
-			$companybankaccount = new CompanyBankAccount($db);
253
-
254
-			$companybankaccount->socid           = $object->id;
255
-
256
-			$companybankaccount->bank            = GETPOST('bank','alpha');
257
-			$companybankaccount->label           = GETPOST('label','alpha');
258
-			$companybankaccount->courant         = GETPOST('courant','alpha');
259
-			$companybankaccount->clos            = GETPOST('clos','alpha');
260
-			$companybankaccount->code_banque     = GETPOST('code_banque','alpha');
261
-			$companybankaccount->code_guichet    = GETPOST('code_guichet','alpha');
262
-			$companybankaccount->number          = GETPOST('number','alpha');
263
-			$companybankaccount->cle_rib         = GETPOST('cle_rib','alpha');
264
-			$companybankaccount->bic             = GETPOST('bic','alpha');
265
-			$companybankaccount->iban            = GETPOST('iban','alpha');
266
-			$companybankaccount->domiciliation   = GETPOST('domiciliation','alpha');
267
-			$companybankaccount->proprio         = GETPOST('proprio','alpha');
268
-			$companybankaccount->owner_address   = GETPOST('owner_address','alpha');
269
-			$companybankaccount->frstrecur       = GETPOST('frstrecur');
270
-			$companybankaccount->rum             = GETPOST('rum','alpha');
271
-			$companybankaccount->datec			 = dol_now();
272
-			$companybankaccount->status          = 1;
273
-
274
-			$db->begin();
275
-
276
-			// This test can be done only once properties were set
277
-			if ($companybankaccount->needIBAN() == 1)
278
-			{
279
-				if (! GETPOST('iban'))
280
-				{
281
-					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
282
-					$action='create';
283
-					$error++;
284
-				}
285
-				if (! GETPOST('bic'))
286
-				{
287
-					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
288
-					$action='create';
289
-					$error++;
290
-				}
291
-			}
292
-
293
-			if (! $error)
294
-			{
295
-				$result = $companybankaccount->create($user);
296
-				if ($result < 0)
297
-				{
298
-					$error++;
299
-					setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
300
-					$action='create';     // Force chargement page création
301
-				}
302
-
303
-				if (empty($companybankaccount->rum))
304
-				{
305
-					$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
306
-					$companybankaccount->date_rum = dol_now();
307
-				}
308
-			}
309
-
310
-			if (! $error)
311
-			{
312
-				$result = $companybankaccount->update($user);	// This will set the UMR number.
313
-				if ($result < 0)
314
-				{
315
-					$error++;
316
-					setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
317
-					$action='create';
318
-				}
319
-			}
320
-
321
-			if (! $error)
322
-			{
323
-				$db->commit();
324
-
325
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
326
-				header('Location: '.$url);
327
-				exit;
328
-			}
329
-			else
330
-			{
331
-				$db->rollback();
332
-			}
333
-		}
334
-	}
335
-
336
-	if ($action == 'addcard')
337
-	{
338
-		$error=0;
339
-
340
-		if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
341
-		{
342
-			if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
343
-			if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
344
-			if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
345
-			if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
346
-			if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
347
-			$action='createcard';
348
-			$error++;
349
-		}
350
-
351
-		if (! $error)
352
-		{
353
-			// Ajout
354
-			$companypaymentmode = new CompanyPaymentMode($db);
355
-
356
-			$companypaymentmode->fk_soc          = $object->id;
357
-			$companypaymentmode->bank            = GETPOST('bank','alpha');
358
-			$companypaymentmode->label           = GETPOST('label','alpha');
359
-			$companypaymentmode->number          = GETPOST('cardnumber','alpha');
360
-			$companypaymentmode->last_four       = substr(GETPOST('cardnumber','alpha'), -4);
361
-			$companypaymentmode->proprio         = GETPOST('proprio','alpha');
362
-			$companypaymentmode->exp_date_month  = GETPOST('exp_date_month','int');
363
-			$companypaymentmode->exp_date_year   = GETPOST('exp_date_year','int');
364
-			$companypaymentmode->cvn             = GETPOST('cvn','alpha');
365
-			$companypaymentmode->datec           = dol_now();
366
-			$companypaymentmode->default_rib     = 0;
367
-			$companypaymentmode->type            = 'card';
368
-			$companypaymentmode->country_code    = $object->country_code;
369
-			$companypaymentmode->status          = $servicestatus;
370
-
371
-			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
372
-
373
-			$db->begin();
374
-
375
-			if (! $error)
376
-			{
377
-				$result = $companypaymentmode->create($user);
378
-				if ($result < 0)
379
-				{
380
-					$error++;
381
-					setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
382
-					$action='createcard';     // Force chargement page création
383
-				}
384
-			}
385
-
386
-			if (! $error)
387
-			{
388
-				$db->commit();
389
-
390
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
391
-				header('Location: '.$url);
392
-				exit;
393
-			}
394
-			else
395
-			{
396
-				$db->rollback();
397
-			}
398
-		}
399
-	}
400
-
401
-	if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0)
402
-	{
403
-		$companybankaccount = new CompanyBankAccount($db);
404
-		$res = $companybankaccount->setAsDefault(GETPOST('ribid','int'));
405
-		if ($res)
406
-		{
407
-			$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
408
-			header('Location: '.$url);
409
-			exit;
410
-		}
411
-		else
412
-		{
413
-			setEventMessages($db->lasterror, null, 'errors');
414
-		}
415
-	}
416
-
417
-	if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes')
418
-	{
419
-		$companypaymentmode = new CompanyPaymentMode($db);
420
-		if ($companypaymentmode->fetch($ribid?$ribid:$id))
421
-		{
422
-			$result = $companypaymentmode->delete($user);
423
-			if ($result > 0)
424
-			{
425
-				$url = $_SERVER['PHP_SELF']."?socid=".$object->id;
426
-				header('Location: '.$url);
427
-				exit;
428
-			}
429
-			else
430
-			{
431
-				setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
432
-			}
433
-		}
434
-		else
435
-		{
436
-			setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
437
-		}
438
-	}
439
-	if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes')
440
-	{
441
-		$companybankaccount = new CompanyBankAccount($db);
442
-		if ($companybankaccount->fetch($ribid?$ribid:$id))
443
-		{
444
-			$result = $companybankaccount->delete($user);
445
-			if ($result > 0)
446
-			{
447
-				$url = $_SERVER['PHP_SELF']."?socid=".$object->id;
448
-				header('Location: '.$url);
449
-				exit;
450
-			}
451
-			else
452
-			{
453
-				setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
454
-			}
455
-		}
456
-		else
457
-		{
458
-			setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
459
-		}
460
-	}
461
-
462
-	$savid=$id;
463
-
464
-	// Actions to build doc
465
-	if ($action == 'builddocrib')
466
-	{
467
-		$action = 'builddoc';
468
-		$moreparams = array(
469
-			'use_companybankid'=>GETPOST('companybankid'),
470
-			'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
471
-		);
472
-		$_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha');
473
-		$_POST['model'] =  GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha');
474
-	}
475
-
476
-	$id = $socid;
477
-	$upload_dir = $conf->societe->multidir_output[$object->entity];
478
-	$permissioncreate=$user->rights->societe->creer;
479
-	include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
480
-
481
-	$id = $savid;
482
-
483
-	// Action for stripe
484
-	if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
485
-	{
486
-		if ($action == 'synccustomertostripe')
487
-		{
488
-			if ($object->client == 0)
489
-			{
490
-				$error++;
491
-				setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
492
-			}
493
-			else
494
-			{
495
-				// Creation of Stripe customer + update of societe_account
496
-				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
497
-				if (! $cu)
498
-				{
499
-					$error++;
500
-					setEventMessages($stripe->error, $stripe->errors, 'errors');
501
-				}
502
-				else
503
-				{
504
-					$stripecu = $cu->id;
505
-				}
506
-			}
507
-		}
508
-		if ($action == 'synccardtostripe')
509
-		{
510
-			$companypaymentmode = new CompanyPaymentMode($db);
511
-			$companypaymentmode->fetch($id);
512
-
513
-			if ($companypaymentmode->type != 'card')
514
-			{
515
-				$error++;
516
-				setEventMessages('ThisPaymentModeIsNotACard', null, 'errors');
517
-			}
518
-			else
519
-			{
520
-				// Get the Stripe customer
521
-				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
522
-				if (! $cu)
523
-				{
524
-					$error++;
525
-					setEventMessages($stripe->error, $stripe->errors, 'errors');
526
-				}
527
-
528
-				if (! $error)
529
-				{
530
-					// Creation of Stripe card + update of societe_account
531
-					$card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
532
-					if (! $card)
533
-					{
534
-						$error++;
535
-						setEventMessages($stripe->error, $stripe->errors, 'errors');
536
-					}
537
-					else
538
-					{
539
-						$stripecard = $card->id;
540
-					}
541
-				}
542
-			}
543
-		}
544
-
545
-		if ($action == 'setkey_account')
546
-		{
547
-			$error = 0;
548
-
549
-			$newcu = GETPOST('key_account', 'alpha');
550
-
551
-			$db->begin();
104
+    if ($cancel)
105
+    {
106
+        $action='';
107
+        if (! empty($backtopage))
108
+        {
109
+            header("Location: ".$backtopage);
110
+            exit;
111
+        }
112
+    }
113
+
114
+    if ($action == 'update')
115
+    {
116
+        // Modification
117
+        if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
118
+        {
119
+            if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
120
+            if (! GETPOST('bank','alpha'))  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
121
+            $action='edit';
122
+            $error++;
123
+        }
124
+        if ($companybankaccount->needIBAN() == 1)
125
+        {
126
+            if (! GETPOST('iban'))
127
+            {
128
+                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
129
+                $action='edit';
130
+                $error++;
131
+            }
132
+            if (! GETPOST('bic'))
133
+            {
134
+                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
135
+                $action='edit';
136
+                $error++;
137
+            }
138
+        }
139
+
140
+        $companybankaccount->fetch($id);
141
+        if (! $error)
142
+        {
143
+            $companybankaccount->socid           = $object->id;
144
+
145
+            $companybankaccount->bank            = GETPOST('bank','alpha');
146
+            $companybankaccount->label           = GETPOST('label','alpha');
147
+            $companybankaccount->courant         = GETPOST('courant','alpha');
148
+            $companybankaccount->clos            = GETPOST('clos','alpha');
149
+            $companybankaccount->code_banque     = GETPOST('code_banque','alpha');
150
+            $companybankaccount->code_guichet    = GETPOST('code_guichet','alpha');
151
+            $companybankaccount->number          = GETPOST('number','alpha');
152
+            $companybankaccount->cle_rib         = GETPOST('cle_rib','alpha');
153
+            $companybankaccount->bic             = GETPOST('bic','alpha');
154
+            $companybankaccount->iban            = GETPOST('iban','alpha');
155
+            $companybankaccount->domiciliation   = GETPOST('domiciliation','alpha');
156
+            $companybankaccount->proprio         = GETPOST('proprio','alpha');
157
+            $companybankaccount->owner_address   = GETPOST('owner_address','alpha');
158
+            $companybankaccount->frstrecur       = GETPOST('frstrecur','alpha');
159
+            $companybankaccount->rum             = GETPOST('rum','alpha');
160
+            if (empty($companybankaccount->rum))
161
+            {
162
+                $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
163
+                $companybankaccount->date_rum = dol_now();
164
+            }
165
+
166
+            $result = $companybankaccount->update($user);
167
+            if (! $result)
168
+            {
169
+                setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
170
+            }
171
+            else
172
+            {
173
+                // If this account is the default bank account, we disable others
174
+                if ($companybankaccount->default_rib)
175
+                {
176
+                    $companybankaccount->setAsDefault($id);	// This will make sure there is only one default rib
177
+                }
178
+
179
+                $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
180
+                header('Location: '.$url);
181
+                exit;
182
+            }
183
+        }
184
+    }
185
+
186
+    if ($action == 'updatecard')
187
+    {
188
+        // Modification
189
+        if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
190
+        {
191
+            if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
192
+            if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
193
+            if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
194
+            if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
195
+            if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
196
+            $action='createcard';
197
+            $error++;
198
+        }
199
+
200
+        $companypaymentmode->fetch($id);
201
+        if (! $error)
202
+        {
203
+            $companypaymentmode->fk_soc          = $object->id;
204
+
205
+            $companypaymentmode->bank            = GETPOST('bank','alpha');
206
+            $companypaymentmode->label           = GETPOST('label','alpha');
207
+            $companypaymentmode->number          = GETPOST('cardnumber','alpha');
208
+            $companypaymentmode->last_four       = substr(GETPOST('cardnumber','alpha'), -4);
209
+            $companypaymentmode->proprio         = GETPOST('proprio','alpha');
210
+            $companypaymentmode->exp_date_month  = GETPOST('exp_date_month','int');
211
+            $companypaymentmode->exp_date_year   = GETPOST('exp_date_year','int');
212
+            $companypaymentmode->cvn             = GETPOST('cvn','alpha');
213
+            $companypaymentmode->country_code    = $object->country_code;
214
+
215
+            $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
216
+
217
+            $result = $companypaymentmode->update($user);
218
+            if (! $result)
219
+            {
220
+                setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
221
+            }
222
+            else
223
+            {
224
+                // If this account is the default bank account, we disable others
225
+                if ($companypaymentmode->default_rib)
226
+                {
227
+                    $companypaymentmode->setAsDefault($id);	// This will make sure there is only one default rib
228
+                }
229
+
230
+                $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
231
+                header('Location: '.$url);
232
+                exit;
233
+            }
234
+        }
235
+    }
236
+
237
+    if ($action == 'add')
238
+    {
239
+        $error=0;
240
+
241
+        if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
242
+        {
243
+            if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
244
+            if (! GETPOST('bank','alpha'))  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
245
+            $action='create';
246
+            $error++;
247
+        }
248
+
249
+        if (! $error)
250
+        {
251
+            // Ajout
252
+            $companybankaccount = new CompanyBankAccount($db);
253
+
254
+            $companybankaccount->socid           = $object->id;
255
+
256
+            $companybankaccount->bank            = GETPOST('bank','alpha');
257
+            $companybankaccount->label           = GETPOST('label','alpha');
258
+            $companybankaccount->courant         = GETPOST('courant','alpha');
259
+            $companybankaccount->clos            = GETPOST('clos','alpha');
260
+            $companybankaccount->code_banque     = GETPOST('code_banque','alpha');
261
+            $companybankaccount->code_guichet    = GETPOST('code_guichet','alpha');
262
+            $companybankaccount->number          = GETPOST('number','alpha');
263
+            $companybankaccount->cle_rib         = GETPOST('cle_rib','alpha');
264
+            $companybankaccount->bic             = GETPOST('bic','alpha');
265
+            $companybankaccount->iban            = GETPOST('iban','alpha');
266
+            $companybankaccount->domiciliation   = GETPOST('domiciliation','alpha');
267
+            $companybankaccount->proprio         = GETPOST('proprio','alpha');
268
+            $companybankaccount->owner_address   = GETPOST('owner_address','alpha');
269
+            $companybankaccount->frstrecur       = GETPOST('frstrecur');
270
+            $companybankaccount->rum             = GETPOST('rum','alpha');
271
+            $companybankaccount->datec			 = dol_now();
272
+            $companybankaccount->status          = 1;
273
+
274
+            $db->begin();
275
+
276
+            // This test can be done only once properties were set
277
+            if ($companybankaccount->needIBAN() == 1)
278
+            {
279
+                if (! GETPOST('iban'))
280
+                {
281
+                    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
282
+                    $action='create';
283
+                    $error++;
284
+                }
285
+                if (! GETPOST('bic'))
286
+                {
287
+                    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
288
+                    $action='create';
289
+                    $error++;
290
+                }
291
+            }
292
+
293
+            if (! $error)
294
+            {
295
+                $result = $companybankaccount->create($user);
296
+                if ($result < 0)
297
+                {
298
+                    $error++;
299
+                    setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
300
+                    $action='create';     // Force chargement page création
301
+                }
302
+
303
+                if (empty($companybankaccount->rum))
304
+                {
305
+                    $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
306
+                    $companybankaccount->date_rum = dol_now();
307
+                }
308
+            }
309
+
310
+            if (! $error)
311
+            {
312
+                $result = $companybankaccount->update($user);	// This will set the UMR number.
313
+                if ($result < 0)
314
+                {
315
+                    $error++;
316
+                    setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
317
+                    $action='create';
318
+                }
319
+            }
320
+
321
+            if (! $error)
322
+            {
323
+                $db->commit();
324
+
325
+                $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
326
+                header('Location: '.$url);
327
+                exit;
328
+            }
329
+            else
330
+            {
331
+                $db->rollback();
332
+            }
333
+        }
334
+    }
335
+
336
+    if ($action == 'addcard')
337
+    {
338
+        $error=0;
339
+
340
+        if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
341
+        {
342
+            if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
343
+            if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
344
+            if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
345
+            if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
346
+            if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
347
+            $action='createcard';
348
+            $error++;
349
+        }
350
+
351
+        if (! $error)
352
+        {
353
+            // Ajout
354
+            $companypaymentmode = new CompanyPaymentMode($db);
355
+
356
+            $companypaymentmode->fk_soc          = $object->id;
357
+            $companypaymentmode->bank            = GETPOST('bank','alpha');
358
+            $companypaymentmode->label           = GETPOST('label','alpha');
359
+            $companypaymentmode->number          = GETPOST('cardnumber','alpha');
360
+            $companypaymentmode->last_four       = substr(GETPOST('cardnumber','alpha'), -4);
361
+            $companypaymentmode->proprio         = GETPOST('proprio','alpha');
362
+            $companypaymentmode->exp_date_month  = GETPOST('exp_date_month','int');
363
+            $companypaymentmode->exp_date_year   = GETPOST('exp_date_year','int');
364
+            $companypaymentmode->cvn             = GETPOST('cvn','alpha');
365
+            $companypaymentmode->datec           = dol_now();
366
+            $companypaymentmode->default_rib     = 0;
367
+            $companypaymentmode->type            = 'card';
368
+            $companypaymentmode->country_code    = $object->country_code;
369
+            $companypaymentmode->status          = $servicestatus;
370
+
371
+            $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
372
+
373
+            $db->begin();
374
+
375
+            if (! $error)
376
+            {
377
+                $result = $companypaymentmode->create($user);
378
+                if ($result < 0)
379
+                {
380
+                    $error++;
381
+                    setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
382
+                    $action='createcard';     // Force chargement page création
383
+                }
384
+            }
385
+
386
+            if (! $error)
387
+            {
388
+                $db->commit();
389
+
390
+                $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
391
+                header('Location: '.$url);
392
+                exit;
393
+            }
394
+            else
395
+            {
396
+                $db->rollback();
397
+            }
398
+        }
399
+    }
400
+
401
+    if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0)
402
+    {
403
+        $companybankaccount = new CompanyBankAccount($db);
404
+        $res = $companybankaccount->setAsDefault(GETPOST('ribid','int'));
405
+        if ($res)
406
+        {
407
+            $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
408
+            header('Location: '.$url);
409
+            exit;
410
+        }
411
+        else
412
+        {
413
+            setEventMessages($db->lasterror, null, 'errors');
414
+        }
415
+    }
416
+
417
+    if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes')
418
+    {
419
+        $companypaymentmode = new CompanyPaymentMode($db);
420
+        if ($companypaymentmode->fetch($ribid?$ribid:$id))
421
+        {
422
+            $result = $companypaymentmode->delete($user);
423
+            if ($result > 0)
424
+            {
425
+                $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
426
+                header('Location: '.$url);
427
+                exit;
428
+            }
429
+            else
430
+            {
431
+                setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
432
+            }
433
+        }
434
+        else
435
+        {
436
+            setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
437
+        }
438
+    }
439
+    if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes')
440
+    {
441
+        $companybankaccount = new CompanyBankAccount($db);
442
+        if ($companybankaccount->fetch($ribid?$ribid:$id))
443
+        {
444
+            $result = $companybankaccount->delete($user);
445
+            if ($result > 0)
446
+            {
447
+                $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
448
+                header('Location: '.$url);
449
+                exit;
450
+            }
451
+            else
452
+            {
453
+                setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
454
+            }
455
+        }
456
+        else
457
+        {
458
+            setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
459
+        }
460
+    }
461
+
462
+    $savid=$id;
463
+
464
+    // Actions to build doc
465
+    if ($action == 'builddocrib')
466
+    {
467
+        $action = 'builddoc';
468
+        $moreparams = array(
469
+            'use_companybankid'=>GETPOST('companybankid'),
470
+            'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
471
+        );
472
+        $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha');
473
+        $_POST['model'] =  GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha');
474
+    }
475
+
476
+    $id = $socid;
477
+    $upload_dir = $conf->societe->multidir_output[$object->entity];
478
+    $permissioncreate=$user->rights->societe->creer;
479
+    include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
480
+
481
+    $id = $savid;
482
+
483
+    // Action for stripe
484
+    if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
485
+    {
486
+        if ($action == 'synccustomertostripe')
487
+        {
488
+            if ($object->client == 0)
489
+            {
490
+                $error++;
491
+                setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
492
+            }
493
+            else
494
+            {
495
+                // Creation of Stripe customer + update of societe_account
496
+                $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
497
+                if (! $cu)
498
+                {
499
+                    $error++;
500
+                    setEventMessages($stripe->error, $stripe->errors, 'errors');
501
+                }
502
+                else
503
+                {
504
+                    $stripecu = $cu->id;
505
+                }
506
+            }
507
+        }
508
+        if ($action == 'synccardtostripe')
509
+        {
510
+            $companypaymentmode = new CompanyPaymentMode($db);
511
+            $companypaymentmode->fetch($id);
512
+
513
+            if ($companypaymentmode->type != 'card')
514
+            {
515
+                $error++;
516
+                setEventMessages('ThisPaymentModeIsNotACard', null, 'errors');
517
+            }
518
+            else
519
+            {
520
+                // Get the Stripe customer
521
+                $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
522
+                if (! $cu)
523
+                {
524
+                    $error++;
525
+                    setEventMessages($stripe->error, $stripe->errors, 'errors');
526
+                }
527
+
528
+                if (! $error)
529
+                {
530
+                    // Creation of Stripe card + update of societe_account
531
+                    $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
532
+                    if (! $card)
533
+                    {
534
+                        $error++;
535
+                        setEventMessages($stripe->error, $stripe->errors, 'errors');
536
+                    }
537
+                    else
538
+                    {
539
+                        $stripecard = $card->id;
540
+                    }
541
+                }
542
+            }
543
+        }
544
+
545
+        if ($action == 'setkey_account')
546
+        {
547
+            $error = 0;
548
+
549
+            $newcu = GETPOST('key_account', 'alpha');
550
+
551
+            $db->begin();
552 552
 
553 553
                 if (empty($newcu)) {
554 554
                         $sql  = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
555 555
                 } else {
556
-			$sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
557
-			$sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'";
558
-			$sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
556
+            $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
557
+            $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'";
558
+            $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
559 559
                 }
560 560
 
561
-			$resql = $db->query($sql);
562
-			$num = $db->num_rows($resql);
563
-			if (empty($num) && !empty($newcu))
564
-			{
565
-				$societeaccount = new SocieteAccount($db);
566
-				$societeaccount->fk_soc = $object->id;
567
-				$societeaccount->login = '';
568
-				$societeaccount->pass_encoding = '';
569
-				$societeaccount->site = 'stripe';
570
-				$societeaccount->status = $servicestatus;
571
-				$societeaccount->key_account = $newcu;
572
-				$result = $societeaccount->create($user);
573
-				if ($result < 0)
574
-				{
575
-					$error++;
576
-				}
577
-			}
578
-
579
-			if (! $error)
580
-			{
581
-				$stripecu = $newcu;
582
-				$db->commit();
583
-			}
584
-			else
585
-			{
586
-				$db->rollback();
587
-			}
588
-		}
589
-		if ($action == 'setlocalassourcedefault')
590
-		{
591
-			try {
592
-				$companypaymentmode->setAsDefault($id);
593
-
594
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
595
-				header('Location: '.$url);
596
-				exit;
597
-			}
598
-			catch(Exception $e)
599
-			{
600
-				$error++;
601
-				setEventMessages($e->getMessage(), null, 'errors');
602
-			}
603
-		}
604
-		elseif ($action == 'setassourcedefault')
605
-		{
606
-			try {
607
-				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
608
-				$cu->default_source = (string) $source;
609
-				$result = $cu->save();
610
-
611
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
612
-				header('Location: '.$url);
613
-				exit;
614
-			}
615
-			catch(Exception $e)
616
-			{
617
-				$error++;
618
-				setEventMessages($e->getMessage(), null, 'errors');
619
-			}
620
-		}
621
-		elseif ($action == 'deletecard' && $source)
622
-		{
623
-			try {
624
-				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
625
-				$card=$cu->sources->retrieve("$source");
626
-				if ($card)
627
-				{
628
-					// $card->detach();  Does not work with card_, only with src_
629
-					if (method_exists($card, 'detach')) $card->detach();
630
-					else $card->delete();
631
-				}
632
-
633
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
634
-				header('Location: '.$url);
635
-				exit;
636
-			}
637
-			catch(Exception $e)
638
-			{
639
-				$error++;
640
-				setEventMessages($e->getMessage(), null, 'errors');
641
-			}
642
-		}
643
-	}
561
+            $resql = $db->query($sql);
562
+            $num = $db->num_rows($resql);
563
+            if (empty($num) && !empty($newcu))
564
+            {
565
+                $societeaccount = new SocieteAccount($db);
566
+                $societeaccount->fk_soc = $object->id;
567
+                $societeaccount->login = '';
568
+                $societeaccount->pass_encoding = '';
569
+                $societeaccount->site = 'stripe';
570
+                $societeaccount->status = $servicestatus;
571
+                $societeaccount->key_account = $newcu;
572
+                $result = $societeaccount->create($user);
573
+                if ($result < 0)
574
+                {
575
+                    $error++;
576
+                }
577
+            }
578
+
579
+            if (! $error)
580
+            {
581
+                $stripecu = $newcu;
582
+                $db->commit();
583
+            }
584
+            else
585
+            {
586
+                $db->rollback();
587
+            }
588
+        }
589
+        if ($action == 'setlocalassourcedefault')
590
+        {
591
+            try {
592
+                $companypaymentmode->setAsDefault($id);
593
+
594
+                $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
595
+                header('Location: '.$url);
596
+                exit;
597
+            }
598
+            catch(Exception $e)
599
+            {
600
+                $error++;
601
+                setEventMessages($e->getMessage(), null, 'errors');
602
+            }
603
+        }
604
+        elseif ($action == 'setassourcedefault')
605
+        {
606
+            try {
607
+                $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
608
+                $cu->default_source = (string) $source;
609
+                $result = $cu->save();
610
+
611
+                $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
612
+                header('Location: '.$url);
613
+                exit;
614
+            }
615
+            catch(Exception $e)
616
+            {
617
+                $error++;
618
+                setEventMessages($e->getMessage(), null, 'errors');
619
+            }
620
+        }
621
+        elseif ($action == 'deletecard' && $source)
622
+        {
623
+            try {
624
+                $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
625
+                $card=$cu->sources->retrieve("$source");
626
+                if ($card)
627
+                {
628
+                    // $card->detach();  Does not work with card_, only with src_
629
+                    if (method_exists($card, 'detach')) $card->detach();
630
+                    else $card->delete();
631
+                }
632
+
633
+                $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
634
+                header('Location: '.$url);
635
+                exit;
636
+            }
637
+            catch(Exception $e)
638
+            {
639
+                $error++;
640
+                setEventMessages($e->getMessage(), null, 'errors');
641
+            }
642
+        }
643
+    }
644 644
 }
645 645
 
646 646
 
@@ -664,217 +664,217 @@  discard block
 block discarded – undo
664 664
 }*/
665 665
 if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')))
666 666
 {
667
-	dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
667
+    dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
668 668
 }
669 669
 
670 670
 // Load Bank account
671 671
 if (! $id)
672 672
 {
673
-	$companybankaccount->fetch(0, $object->id);
674
-	$companypaymentmode->fetch(0, null, $object->id, 'card');
673
+    $companybankaccount->fetch(0, $object->id);
674
+    $companypaymentmode->fetch(0, null, $object->id, 'card');
675 675
 }
676 676
 else
677 677
 {
678
-	$companybankaccount->fetch($id);
679
-	$companypaymentmode->fetch($id);
678
+    $companybankaccount->fetch($id);
679
+    $companypaymentmode->fetch($id);
680 680
 }
681 681
 if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id;
682 682
 
683 683
 if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer)
684 684
 {
685
-	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
686
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
687
-	$actionforadd='update';
688
-	if ($action == 'editcard') $actionforadd='updatecard';
689
-	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
690
-	print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
685
+    print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
686
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
687
+    $actionforadd='update';
688
+    if ($action == 'editcard') $actionforadd='updatecard';
689
+    print '<input type="hidden" name="action" value="'.$actionforadd.'">';
690
+    print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
691 691
 }
692 692
 if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer)
693 693
 {
694
-	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
695
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
696
-	$actionforadd='add';
697
-	if ($action == 'createcard') $actionforadd='addcard';
698
-	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
694
+    print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
695
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
696
+    $actionforadd='add';
697
+    if ($action == 'createcard') $actionforadd='addcard';
698
+    print '<input type="hidden" name="action" value="'.$actionforadd.'">';
699 699
 }
700 700
 
701 701
 
702 702
 // View
703 703
 if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard')
704 704
 {
705
-	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
706
-
707
-	// Confirm delete ban
708
-	if ($action == 'delete')
709
-	{
710
-		print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1);
711
-	}
712
-	// Confirm delete card
713
-	if ($action == 'deletecard')
714
-	{
715
-		print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1);
716
-	}
717
-
718
-	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
719
-
720
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
721
-
722
-
723
-	if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
724
-	{
725
-		print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
726
-	}
727
-
728
-	//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
729
-
730
-	print '<div class="fichecenter">';
731
-
732
-	print '<div class="underbanner clearboth"></div>';
733
-	print '<table class="border tableforfield" width="100%">';
734
-
735
-	if ($object->client)
736
-	{
737
-		print '<tr><td class="titlefield">';
738
-		print $langs->trans('CustomerCode').'</td><td colspan="2">';
739
-		print $object->code_client;
740
-		if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
741
-		print '</td></tr>';
742
-		$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
743
-		$resql=$db->query($sql);
744
-		if (!$resql) dol_print_error($db);
745
-
746
-		$obj = $db->fetch_object($resql);
747
-		$nbFactsClient = $obj->nb;
748
-		$thirdTypeArray['customer']=$langs->trans("customer");
749
-		if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals');
750
-		if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders');
751
-		if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices');
752
-		if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts');
753
-	}
754
-
755
-	if (! empty($conf->stripe->enabled))
756
-	{
757
-		$permissiontowrite = $user->rights->societe->creer;
758
-		// Stripe customer key 'cu_....' stored into llx_societe_account
759
-		print '<tr><td class="titlefield">';
760
-		//print $langs->trans('StripeCustomerId');
761
-		print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid');
762
-		print '</td><td>';
763
-		//print $stripecu;
764
-		print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
765
-		if ($stripecu && $action != 'editkey_account')
766
-		{
767
-			if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
768
-			$url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
769
-			if ($servicestatus)
770
-			{
771
-				$url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
772
-			}
773
-			print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
774
-		}
775
-		print '</td><td align="right">';
776
-		if (empty($stripecu))
777
-		{
778
-			print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
779
-			print '<input type="hidden" name="action" value="synccustomertostripe">';
780
-			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
781
-			print '<input type="hidden" name="socid" value="'.$object->id.'">';
782
-			print '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
783
-			print '<input type="submit" class="button" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">';
784
-			print '</form>';
785
-		}
786
-		print '</td></tr>';
787
-	}
788
-
789
-	print '</table>';
790
-	print '</div>';
791
-
792
-	dol_fiche_end();
793
-
794
-	print '<br>';
795
-
796
-	// List of Stripe payment modes
797
-	if (! (empty($conf->stripe->enabled)))
798
-	{
799
-		$morehtmlright='';
800
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
801
-		{
802
-			$morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
803
-		}
804
-		print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, '');
805
-
806
-		$listofsources = array();
807
-		if (is_object($stripe))
808
-		{
809
-			try {
810
-				$customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus);
811
-				if ($customerstripe->id) {
812
-					$listofsources=$customerstripe->sources->data;
813
-				}
814
-			}
815
-			catch(Exception $e)
816
-			{
817
-				dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
818
-			}
819
-		}
820
-
821
-		print '<div class="div-table-responsive-no-min">';		// You can use div-table-responsive-no-min if you dont need reserved height for your table
822
-		print '<table class="liste" width="100%">'."\n";
823
-		print '<tr class="liste_titre">';
824
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
825
-		{
826
-			print '<td>'.$langs->trans('LocalID').'</td>';
827
-		}
828
-		print '<td>'.$langs->trans('StripeID').'</td>';
829
-		print '<td>'.$langs->trans('Type').'</td>';
830
-		print '<td>'.$langs->trans('Informations').'</td>';
831
-		print '<td></td>';
832
-		print '<td align="center">'.$langs->trans('Default').'</td>';
833
-		print '<td>'.$langs->trans('Note').'</td>';
834
-		print '<td>'.$langs->trans('DateModification').'</td>';
835
-		print "<td></td>";
836
-		print "</tr>\n";
837
-
838
-		$nbremote = 0;
839
-		$nblocal = 0;
840
-		$arrayofstripecard = array();
841
-
842
-		// Show local sources
843
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
844
-		{
845
-			//$societeaccount = new SocieteAccount($db);
846
-			$companypaymentmodetemp = new CompanyPaymentMode($db);
847
-
848
-			$sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib";
849
-			$sql.=" WHERE type in ('card', 'paypal')";
850
-			$sql.=" AND fk_soc = ".$object->id;
851
-			$sql.=" AND status = ".$servicestatus;
852
-
853
-			$resql = $db->query($sql);
854
-			if ($resql)
855
-			{
856
-				$num_rows = $db->num_rows($resql);
857
-				if ($num_rows)
858
-				{
859
-					$i=0;
860
-					while ($i < $num_rows)
861
-					{
862
-						$nblocal++;
863
-
864
-						$obj = $db->fetch_object($resql);
865
-						if ($obj)
866
-						{
867
-							$companypaymentmodetemp->fetch($obj->rowid);
868
-
869
-							$arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref;
870
-
871
-							print '<tr>';
872
-							print '<td>';
873
-							print $companypaymentmodetemp->id;
874
-							print '</td>';
875
-							print '<td>';
876
-							print $companypaymentmodetemp->stripe_card_ref;
877
-							/*if ($companypaymentmodetemp->stripe_card_ref)
705
+    dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
706
+
707
+    // Confirm delete ban
708
+    if ($action == 'delete')
709
+    {
710
+        print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1);
711
+    }
712
+    // Confirm delete card
713
+    if ($action == 'deletecard')
714
+    {
715
+        print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1);
716
+    }
717
+
718
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
719
+
720
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
721
+
722
+
723
+    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
724
+    {
725
+        print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
726
+    }
727
+
728
+    //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
729
+
730
+    print '<div class="fichecenter">';
731
+
732
+    print '<div class="underbanner clearboth"></div>';
733
+    print '<table class="border tableforfield" width="100%">';
734
+
735
+    if ($object->client)
736
+    {
737
+        print '<tr><td class="titlefield">';
738
+        print $langs->trans('CustomerCode').'</td><td colspan="2">';
739
+        print $object->code_client;
740
+        if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
741
+        print '</td></tr>';
742
+        $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
743
+        $resql=$db->query($sql);
744
+        if (!$resql) dol_print_error($db);
745
+
746
+        $obj = $db->fetch_object($resql);
747
+        $nbFactsClient = $obj->nb;
748
+        $thirdTypeArray['customer']=$langs->trans("customer");
749
+        if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals');
750
+        if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders');
751
+        if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices');
752
+        if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts');
753
+    }
754
+
755
+    if (! empty($conf->stripe->enabled))
756
+    {
757
+        $permissiontowrite = $user->rights->societe->creer;
758
+        // Stripe customer key 'cu_....' stored into llx_societe_account
759
+        print '<tr><td class="titlefield">';
760
+        //print $langs->trans('StripeCustomerId');
761
+        print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid');
762
+        print '</td><td>';
763
+        //print $stripecu;
764
+        print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
765
+        if ($stripecu && $action != 'editkey_account')
766
+        {
767
+            if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
768
+            $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
769
+            if ($servicestatus)
770
+            {
771
+                $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
772
+            }
773
+            print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
774
+        }
775
+        print '</td><td align="right">';
776
+        if (empty($stripecu))
777
+        {
778
+            print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
779
+            print '<input type="hidden" name="action" value="synccustomertostripe">';
780
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
781
+            print '<input type="hidden" name="socid" value="'.$object->id.'">';
782
+            print '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
783
+            print '<input type="submit" class="button" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">';
784
+            print '</form>';
785
+        }
786
+        print '</td></tr>';
787
+    }
788
+
789
+    print '</table>';
790
+    print '</div>';
791
+
792
+    dol_fiche_end();
793
+
794
+    print '<br>';
795
+
796
+    // List of Stripe payment modes
797
+    if (! (empty($conf->stripe->enabled)))
798
+    {
799
+        $morehtmlright='';
800
+        if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
801
+        {
802
+            $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
803
+        }
804
+        print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, '');
805
+
806
+        $listofsources = array();
807
+        if (is_object($stripe))
808
+        {
809
+            try {
810
+                $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus);
811
+                if ($customerstripe->id) {
812
+                    $listofsources=$customerstripe->sources->data;
813
+                }
814
+            }
815
+            catch(Exception $e)
816
+            {
817
+                dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
818
+            }
819
+        }
820
+
821
+        print '<div class="div-table-responsive-no-min">';		// You can use div-table-responsive-no-min if you dont need reserved height for your table
822
+        print '<table class="liste" width="100%">'."\n";
823
+        print '<tr class="liste_titre">';
824
+        if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
825
+        {
826
+            print '<td>'.$langs->trans('LocalID').'</td>';
827
+        }
828
+        print '<td>'.$langs->trans('StripeID').'</td>';
829
+        print '<td>'.$langs->trans('Type').'</td>';
830
+        print '<td>'.$langs->trans('Informations').'</td>';
831
+        print '<td></td>';
832
+        print '<td align="center">'.$langs->trans('Default').'</td>';
833
+        print '<td>'.$langs->trans('Note').'</td>';
834
+        print '<td>'.$langs->trans('DateModification').'</td>';
835
+        print "<td></td>";
836
+        print "</tr>\n";
837
+
838
+        $nbremote = 0;
839
+        $nblocal = 0;
840
+        $arrayofstripecard = array();
841
+
842
+        // Show local sources
843
+        if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
844
+        {
845
+            //$societeaccount = new SocieteAccount($db);
846
+            $companypaymentmodetemp = new CompanyPaymentMode($db);
847
+
848
+            $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib";
849
+            $sql.=" WHERE type in ('card', 'paypal')";
850
+            $sql.=" AND fk_soc = ".$object->id;
851
+            $sql.=" AND status = ".$servicestatus;
852
+
853
+            $resql = $db->query($sql);
854
+            if ($resql)
855
+            {
856
+                $num_rows = $db->num_rows($resql);
857
+                if ($num_rows)
858
+                {
859
+                    $i=0;
860
+                    while ($i < $num_rows)
861
+                    {
862
+                        $nblocal++;
863
+
864
+                        $obj = $db->fetch_object($resql);
865
+                        if ($obj)
866
+                        {
867
+                            $companypaymentmodetemp->fetch($obj->rowid);
868
+
869
+                            $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref;
870
+
871
+                            print '<tr>';
872
+                            print '<td>';
873
+                            print $companypaymentmodetemp->id;
874
+                            print '</td>';
875
+                            print '<td>';
876
+                            print $companypaymentmodetemp->stripe_card_ref;
877
+                            /*if ($companypaymentmodetemp->stripe_card_ref)
878 878
 							{
879 879
 								$url='https://dashboard.stripe.com/test/card/'.$companypaymentmodetemp->stripe_card_ref;
880 880
 								if ($servicestatus)
@@ -883,427 +883,427 @@  discard block
 block discarded – undo
883 883
 								}
884 884
 								print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
885 885
 							}*/
886
-							print '</td>';
887
-							print '<td>';
888
-							print img_credit_card($companypaymentmodetemp->type);
889
-							print '</td>';
890
-							print '<td>';
891
-							if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four;
892
-							if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.'';
893
-							print '</td><td>';
894
-							if ($companypaymentmodetemp->country_code)
895
-							{
896
-								$img=picto_from_langcode($companypaymentmodetemp->country_code);
897
-								print $img?$img.' ':'';
898
-								print getCountry($companypaymentmodetemp->country_code,1);
899
-							}
900
-							else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
901
-							print '</td>';
902
-							// Default
903
-							print '<td align="center">';
904
-							if (empty($companypaymentmodetemp->default_rib))
905
-							{
906
-								print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">';
907
-								print img_picto($langs->trans("Default"),'off');
908
-								print '</a>';
909
-							} else {
910
-								print img_picto($langs->trans("Default"),'on');
911
-							}
912
-							print '</td>';
913
-							print '<td>';
914
-							if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local");
915
-							else print $langs->trans("LocalAndRemote");
916
-							print '</td>';
917
-							print '<td>';
918
-							print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
919
-							print '</td>';
920
-							print '<td align="right" class="nowraponall">';
921
-							if ($user->rights->societe->creer)
922
-							{
923
-								if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref))
924
-								{
925
-									print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>';
926
-								}
886
+                            print '</td>';
887
+                            print '<td>';
888
+                            print img_credit_card($companypaymentmodetemp->type);
889
+                            print '</td>';
890
+                            print '<td>';
891
+                            if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four;
892
+                            if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.'';
893
+                            print '</td><td>';
894
+                            if ($companypaymentmodetemp->country_code)
895
+                            {
896
+                                $img=picto_from_langcode($companypaymentmodetemp->country_code);
897
+                                print $img?$img.' ':'';
898
+                                print getCountry($companypaymentmodetemp->country_code,1);
899
+                            }
900
+                            else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
901
+                            print '</td>';
902
+                            // Default
903
+                            print '<td align="center">';
904
+                            if (empty($companypaymentmodetemp->default_rib))
905
+                            {
906
+                                print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">';
907
+                                print img_picto($langs->trans("Default"),'off');
908
+                                print '</a>';
909
+                            } else {
910
+                                print img_picto($langs->trans("Default"),'on');
911
+                            }
912
+                            print '</td>';
913
+                            print '<td>';
914
+                            if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local");
915
+                            else print $langs->trans("LocalAndRemote");
916
+                            print '</td>';
917
+                            print '<td>';
918
+                            print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
919
+                            print '</td>';
920
+                            print '<td align="right" class="nowraponall">';
921
+                            if ($user->rights->societe->creer)
922
+                            {
923
+                                if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref))
924
+                                {
925
+                                    print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>';
926
+                                }
927
+
928
+                                print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">';
929
+                                print img_picto($langs->trans("Modify"),'edit');
930
+                                print '</a>';
931
+                                print '&nbsp;';
932
+                                print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">';	// source='.$companypaymentmodetemp->stripe_card_ref.'&
933
+                                print img_picto($langs->trans("Delete"), 'delete');
934
+                                print '</a>';
935
+                            }
936
+                            print '</td>';
937
+                            print '</tr>';
938
+                        }
939
+                        $i++;
940
+                    }
941
+                }
942
+            }
943
+            else dol_print_error($db);
944
+        }
945
+
946
+        // Show remote sources (not already shown as local source)
947
+        if (is_array($listofsources) && count($listofsources))
948
+        {
949
+            foreach ($listofsources as $src)
950
+            {
951
+                if (! empty($arrayofstripecard[$src->id])) continue;	// Already in previous list
952
+
953
+                $nbremote++;
954
+
955
+                print '<tr class="oddeven">';
956
+                // Local ID
957
+                if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
958
+                {
959
+                    print '<td>';
960
+                    print '</td>';
961
+                }
962
+                // Src ID
963
+                print '<td>';
964
+                if (!empty($stripeacc)) $connect=$stripeacc.'/';
965
+                $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
966
+                if ($servicestatus)
967
+                {
968
+                    $url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
969
+                }
970
+                print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>";
971
+                print '</td>';
972
+                // Img of credit card
973
+                print '<td>';
974
+                if ($src->object=='card')
975
+                {
976
+                    print img_credit_card($src->brand);
977
+                }
978
+                elseif ($src->object=='source' && $src->type=='card')
979
+                {
980
+                    print img_credit_card($src->card->brand);
981
+                }
982
+                elseif ($src->object=='source' && $src->type=='sepa_debit')
983
+                {
984
+                    print '<span class="fa fa-university fa-2x fa-fw"></span>';
985
+                }
986
+                print'</td>';
987
+                print '<td valign="middle">';
988
+                if ($src->object=='card')
989
+                {
990
+                    print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
991
+                    print '</td><td>';
992
+                    if ($src->country)
993
+                    {
994
+                        $img=picto_from_langcode($src->country);
995
+                        print $img?$img.' ':'';
996
+                        print getCountry($src->country,1);
997
+                    }
998
+                    else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
999
+                }
1000
+                elseif ($src->object=='source' && $src->type=='card')
1001
+                {
1002
+                    print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1003
+                    print '</td><td>';
1004
+
1005
+                        if ($src->card->country)
1006
+                    {
1007
+                        $img=picto_from_langcode($src->card->country);
1008
+                        print $img?$img.' ':'';
1009
+                        print getCountry($src->card->country,1);
1010
+                    }
1011
+                    else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1012
+                }
1013
+                elseif ($src->object=='source' && $src->type=='sepa_debit')
1014
+                {
1015
+                    print 'info sepa';
1016
+                    print '</td><td>';
1017
+                    if ($src->sepa_debit->country)
1018
+                    {
1019
+                            $img=picto_from_langcode($src->sepa_debit->country);
1020
+                            print $img?$img.' ':'';
1021
+                            print getCountry($src->sepa_debit->country,1);
1022
+                    }
1023
+                    else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1024
+                }
1025
+                print '</td>';
1026
+                // Default
1027
+                print '<td align="center" width="50">';
1028
+                if (($customerstripe->default_source != $src->id))
1029
+                {
1030
+                    print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">';
1031
+                    print img_picto($langs->trans("Default"),'off');
1032
+                    print '</a>';
1033
+                } else {
1034
+                    print img_picto($langs->trans("Default"),'on');
1035
+                }
1036
+                print '</td>';
1037
+                print '<td>';
1038
+                print $langs->trans("Remote");
1039
+                //if ($src->cvc_check == 'fail') print ' - CVC check fail';
1040
+                print '</td>';
1041
+                print '<td>';
1042
+                //var_dump($src);
1043
+                print '';
1044
+                print '</td>';
1045
+                print '<td align="right" class="nowraponall">';
1046
+                if ($user->rights->societe->creer)
1047
+                {
1048
+                    print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">';
1049
+                    print img_picto($langs->trans("Delete"), 'delete');
1050
+                    print '</a>';
1051
+                }
1052
+                print '</td>';
1053
+
1054
+                print '</tr>';
1055
+            }
1056
+        }
1057
+
1058
+        if ($nbremote == 0 && $nblocal == 0)
1059
+        {
1060
+            print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
1061
+        }
1062
+        print "</table>";
1063
+        print "</div>";
1064
+    }
1065
+
927 1066
 
928
-								print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">';
929
-								print img_picto($langs->trans("Modify"),'edit');
930
-								print '</a>';
931
-								print '&nbsp;';
932
-								print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">';	// source='.$companypaymentmodetemp->stripe_card_ref.'&
933
-								print img_picto($langs->trans("Delete"), 'delete');
934
-								print '</a>';
935
-							}
936
-							print '</td>';
937
-							print '</tr>';
938
-						}
939
-						$i++;
940
-					}
941
-				}
942
-			}
943
-			else dol_print_error($db);
944
-		}
945
-
946
-		// Show remote sources (not already shown as local source)
947
-		if (is_array($listofsources) && count($listofsources))
948
-		{
949
-			foreach ($listofsources as $src)
950
-			{
951
-				if (! empty($arrayofstripecard[$src->id])) continue;	// Already in previous list
952
-
953
-				$nbremote++;
954
-
955
-				print '<tr class="oddeven">';
956
-				// Local ID
957
-				if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
958
-				{
959
-					print '<td>';
960
-					print '</td>';
961
-				}
962
-				// Src ID
963
-				print '<td>';
964
-				if (!empty($stripeacc)) $connect=$stripeacc.'/';
965
-				$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
966
-				if ($servicestatus)
967
-				{
968
-					$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
969
-				}
970
-				print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>";
971
-				print '</td>';
972
-				// Img of credit card
973
-				print '<td>';
974
-				if ($src->object=='card')
975
-				{
976
-					print img_credit_card($src->brand);
977
-				}
978
-				elseif ($src->object=='source' && $src->type=='card')
979
-				{
980
-					print img_credit_card($src->card->brand);
981
-				}
982
-				elseif ($src->object=='source' && $src->type=='sepa_debit')
983
-				{
984
-					print '<span class="fa fa-university fa-2x fa-fw"></span>';
985
-				}
986
-				print'</td>';
987
-				print '<td valign="middle">';
988
-				if ($src->object=='card')
989
-				{
990
-					print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
991
-					print '</td><td>';
992
-					if ($src->country)
993
-					{
994
-						$img=picto_from_langcode($src->country);
995
-						print $img?$img.' ':'';
996
-						print getCountry($src->country,1);
997
-					}
998
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
999
-				}
1000
-				elseif ($src->object=='source' && $src->type=='card')
1001
-				{
1002
-					print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1003
-					print '</td><td>';
1004
-
1005
-				 	if ($src->card->country)
1006
-					{
1007
-						$img=picto_from_langcode($src->card->country);
1008
-						print $img?$img.' ':'';
1009
-						print getCountry($src->card->country,1);
1010
-					}
1011
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1012
-				}
1013
-				elseif ($src->object=='source' && $src->type=='sepa_debit')
1014
-				{
1015
-					print 'info sepa';
1016
-					print '</td><td>';
1017
-					if ($src->sepa_debit->country)
1018
-					{
1019
-							$img=picto_from_langcode($src->sepa_debit->country);
1020
-							print $img?$img.' ':'';
1021
-							print getCountry($src->sepa_debit->country,1);
1022
-					}
1023
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1024
-				}
1025
-				print '</td>';
1026
-				// Default
1027
-				print '<td align="center" width="50">';
1028
-				if (($customerstripe->default_source != $src->id))
1029
-				{
1030
-					print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">';
1031
-					print img_picto($langs->trans("Default"),'off');
1032
-					print '</a>';
1033
-				} else {
1034
-					print img_picto($langs->trans("Default"),'on');
1035
-				}
1036
-				print '</td>';
1037
-				print '<td>';
1038
-				print $langs->trans("Remote");
1039
-				//if ($src->cvc_check == 'fail') print ' - CVC check fail';
1040
-				print '</td>';
1041
-				print '<td>';
1042
-				//var_dump($src);
1043
-				print '';
1044
-				print '</td>';
1045
-				print '<td align="right" class="nowraponall">';
1046
-				if ($user->rights->societe->creer)
1047
-				{
1048
-					print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">';
1049
-					print img_picto($langs->trans("Delete"), 'delete');
1050
-					print '</a>';
1051
-				}
1052
-				print '</td>';
1053
-
1054
-				print '</tr>';
1055
-			}
1056
-		}
1057
-
1058
-		if ($nbremote == 0 && $nblocal == 0)
1059
-		{
1060
-			print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
1061
-		}
1062
-		print "</table>";
1063
-		print "</div>";
1064
-	}
1065
-
1066
-
1067
-	// List of bank accounts
1068
-	print '<br>';
1069
-
1070
-	$morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
1071
-
1072
-	print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, '');
1073
-
1074
-	$rib_list = $object->get_all_rib();
1075
-	if (is_array($rib_list))
1076
-	{
1077
-		print '<div class="div-table-responsive-no-min">';		// You can use div-table-responsive-no-min if you dont need reserved height for your table
1078
-		print '<table class="liste" width="100%">';
1079
-
1080
-		print '<tr class="liste_titre">';
1081
-		print_liste_field_titre("LabelRIB");
1082
-		print_liste_field_titre("Bank");
1083
-		print_liste_field_titre("RIB");
1084
-		print_liste_field_titre("IBAN");
1085
-		print_liste_field_titre("BIC");
1086
-		if (! empty($conf->prelevement->enabled))
1087
-		{
1088
-			print print_liste_field_titre("RUM");
1089
-			print print_liste_field_titre("WithdrawMode");
1090
-		}
1091
-		print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"');
1092
-		print_liste_field_titre('', '', '', '', '', 'align="center"');
1093
-		print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
1094
-		print "</tr>\n";
1095
-
1096
-		foreach ($rib_list as $rib)
1097
-		{
1098
-			print '<tr class="oddeven">';
1099
-			// Label
1100
-			print '<td>'.$rib->label.'</td>';
1101
-			// Bank name
1102
-			print '<td>'.$rib->bank.'</td>';
1103
-			// Account number
1104
-			print '<td>';
1105
-			$string='';
1106
-			foreach ($rib->getFieldsToShow() as $val) {
1107
-
1108
-				if ($val == 'BankCode') {
1109
-					$string .= $rib->code_banque.' ';
1110
-				} elseif ($val == 'BankAccountNumber') {
1111
-					$string .= $rib->number.' ';
1112
-				} elseif ($val == 'DeskCode') {
1113
-					$string .= $rib->code_guichet.' ';
1114
-				} elseif ($val == 'BankAccountNumberKey') {
1115
-					$string .= $rib->cle_rib.' ';
1116
-				/* Already output after
1067
+    // List of bank accounts
1068
+    print '<br>';
1069
+
1070
+    $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
1071
+
1072
+    print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, '');
1073
+
1074
+    $rib_list = $object->get_all_rib();
1075
+    if (is_array($rib_list))
1076
+    {
1077
+        print '<div class="div-table-responsive-no-min">';		// You can use div-table-responsive-no-min if you dont need reserved height for your table
1078
+        print '<table class="liste" width="100%">';
1079
+
1080
+        print '<tr class="liste_titre">';
1081
+        print_liste_field_titre("LabelRIB");
1082
+        print_liste_field_titre("Bank");
1083
+        print_liste_field_titre("RIB");
1084
+        print_liste_field_titre("IBAN");
1085
+        print_liste_field_titre("BIC");
1086
+        if (! empty($conf->prelevement->enabled))
1087
+        {
1088
+            print print_liste_field_titre("RUM");
1089
+            print print_liste_field_titre("WithdrawMode");
1090
+        }
1091
+        print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"');
1092
+        print_liste_field_titre('', '', '', '', '', 'align="center"');
1093
+        print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
1094
+        print "</tr>\n";
1095
+
1096
+        foreach ($rib_list as $rib)
1097
+        {
1098
+            print '<tr class="oddeven">';
1099
+            // Label
1100
+            print '<td>'.$rib->label.'</td>';
1101
+            // Bank name
1102
+            print '<td>'.$rib->bank.'</td>';
1103
+            // Account number
1104
+            print '<td>';
1105
+            $string='';
1106
+            foreach ($rib->getFieldsToShow() as $val) {
1107
+
1108
+                if ($val == 'BankCode') {
1109
+                    $string .= $rib->code_banque.' ';
1110
+                } elseif ($val == 'BankAccountNumber') {
1111
+                    $string .= $rib->number.' ';
1112
+                } elseif ($val == 'DeskCode') {
1113
+                    $string .= $rib->code_guichet.' ';
1114
+                } elseif ($val == 'BankAccountNumberKey') {
1115
+                    $string .= $rib->cle_rib.' ';
1116
+                /* Already output after
1117 1117
                 }elseif ($val == 'BIC') {
1118 1118
                     $string .= $rib->bic.' ';
1119 1119
                 }elseif ($val == 'IBAN') {
1120 1120
                     $string .= $rib->iban.' ';*/
1121
-				}
1122
-			}
1123
-			if (! empty($rib->label) && $rib->number) {
1124
-				if (! checkBanForAccount($rib)) {
1125
-					$string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning');
1126
-				} else {
1127
-					$string.= ' '.img_picto($langs->trans("ValueIsValid"),'info');
1128
-				}
1129
-			}
1130
-
1131
-			print $string;
1132
-			print '</td>';
1133
-			// IBAN
1134
-			print '<td>'.$rib->iban;
1135
-   			if (! empty($rib->iban)) {
1136
-				if (! checkIbanForAccount($rib)) {
1137
-					print ' '.img_picto($langs->trans("IbanNotValid"),'warning');
1138
-				} else {
1139
-					print ' '.img_picto($langs->trans("IbanValid"),'info');
1140
-				}
1141
-			}
1142
-			print '</td>';
1143
-			// BIC
1144
-			print '<td>'.$rib->bic;
1145
-			if (! empty($rib->bic)) {
1146
-				if (! checkSwiftForAccount($rib)) {
1147
-					print ' '.img_picto($langs->trans("SwiftNotValid"),'warning');
1148
-				} else {
1149
-					print ' '.img_picto($langs->trans("SwiftValid"),'info');
1150
-				}
1151
-			}
1152
-			print '</td>';
1153
-
1154
-			if (! empty($conf->prelevement->enabled))
1155
-			{
1156
-				// RUM
1157
-				//print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
1158
-				print '<td>'.$rib->rum.'</td>';
1159
-
1160
-				// FRSTRECUR
1161
-				print '<td>'.$rib->frstrecur.'</td>';
1162
-			}
1163
-
1164
-			// Default
1165
-			print '<td align="center" width="70">';
1166
-			if (!$rib->default_rib) {
1167
-				print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
1168
-				print img_picto($langs->trans("Disabled"),'off');
1169
-				print '</a>';
1170
-			} else {
1171
-				print img_picto($langs->trans("Enabled"),'on');
1172
-			}
1173
-			print '</td>';
1174
-
1175
-			// Generate doc
1176
-			print '<td align="center">';
1177
-
1178
-			$buttonlabel = $langs->trans("BuildDoc");
1179
-			$forname='builddocrib'.$rib->id;
1180
-
1181
-			include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1182
-			$modellist=ModeleBankAccountDoc::liste_modeles($db);
1183
-
1184
-			$out = '';
1185
-			if (is_array($modellist) && count($modellist))
1186
-			{
1187
-				$out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
1188
-				$out.= '<input type="hidden" name="action" value="builddocrib">';
1189
-				$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1190
-				$out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
1191
-				$out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
1192
-
1193
-				if (is_array($modellist) && count($modellist) == 1)    // If there is only one element
1194
-				{
1195
-					$arraykeys=array_keys($modellist);
1196
-					$modelselected=$arraykeys[0];
1197
-				}
1198
-				if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1199
-
1200
-				$out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1201
-				$out.= ajax_combobox('modelrib'.$rib->id);
1202
-
1203
-				// Language code (if multilang)
1204
-				if ($conf->global->MAIN_MULTILANGS)
1205
-				{
1206
-					include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
1207
-					$formadmin=new FormAdmin($db);
1208
-					$defaultlang=$codelang?$codelang:$langs->getDefaultLang();
1209
-					$morecss='maxwidth150';
1210
-					if ($conf->browser->layout == 'phone') $morecss='maxwidth100';
1211
-					$out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1212
-				}
1213
-				// Button
1214
-				$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
1215
-				$genbutton.= ' type="submit" value="'.$buttonlabel.'"';
1216
-				if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
1217
-				$genbutton.= '>';
1218
-				if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
1219
-				{
1220
-					$langs->load("errors");
1221
-					$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1222
-				}
1223
-				if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
1224
-				if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
1225
-				$out.= $genbutton;
1226
-				$out.= '</form>';
1227
-			}
1228
-			print $out;
1229
-			print '</td>';
1230
-
1231
-			// Edit/Delete
1232
-			print '<td align="right" class="nowraponall">';
1233
-			if ($user->rights->societe->creer)
1234
-			{
1235
-				print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
1236
-				print img_picto($langs->trans("Modify"),'edit');
1237
-				print '</a>';
1238
-
1239
-		   		print '&nbsp;';
1240
-
1241
-		   		print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
1242
-		   		print img_picto($langs->trans("Delete"),'delete');
1243
-		   		print '</a>';
1244
-			}
1245
-			print '</td>';
1246
-
1247
-			print '</tr>';
1248
-		}
1249
-
1250
-		if (count($rib_list) == 0)
1251
-		{
1252
-			$colspan=8;
1253
-			if (! empty($conf->prelevement->enabled)) $colspan+=2;
1254
-			print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
1255
-		}
1256
-
1257
-		print '</table>';
1258
-		print '</div>';
1259
-	} else {
1260
-		dol_print_error($db);
1261
-	}
1262
-
1263
-
1264
-	if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
1265
-	{
1266
-		print '<br>';
1267
-
1268
-		print '<div class="fichecenter"><div class="fichehalfleft">';
1269
-		print '<a name="builddoc"></a>'; // ancre
1270
-
1271
-		/*
1121
+                }
1122
+            }
1123
+            if (! empty($rib->label) && $rib->number) {
1124
+                if (! checkBanForAccount($rib)) {
1125
+                    $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning');
1126
+                } else {
1127
+                    $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info');
1128
+                }
1129
+            }
1130
+
1131
+            print $string;
1132
+            print '</td>';
1133
+            // IBAN
1134
+            print '<td>'.$rib->iban;
1135
+                if (! empty($rib->iban)) {
1136
+                if (! checkIbanForAccount($rib)) {
1137
+                    print ' '.img_picto($langs->trans("IbanNotValid"),'warning');
1138
+                } else {
1139
+                    print ' '.img_picto($langs->trans("IbanValid"),'info');
1140
+                }
1141
+            }
1142
+            print '</td>';
1143
+            // BIC
1144
+            print '<td>'.$rib->bic;
1145
+            if (! empty($rib->bic)) {
1146
+                if (! checkSwiftForAccount($rib)) {
1147
+                    print ' '.img_picto($langs->trans("SwiftNotValid"),'warning');
1148
+                } else {
1149
+                    print ' '.img_picto($langs->trans("SwiftValid"),'info');
1150
+                }
1151
+            }
1152
+            print '</td>';
1153
+
1154
+            if (! empty($conf->prelevement->enabled))
1155
+            {
1156
+                // RUM
1157
+                //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
1158
+                print '<td>'.$rib->rum.'</td>';
1159
+
1160
+                // FRSTRECUR
1161
+                print '<td>'.$rib->frstrecur.'</td>';
1162
+            }
1163
+
1164
+            // Default
1165
+            print '<td align="center" width="70">';
1166
+            if (!$rib->default_rib) {
1167
+                print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
1168
+                print img_picto($langs->trans("Disabled"),'off');
1169
+                print '</a>';
1170
+            } else {
1171
+                print img_picto($langs->trans("Enabled"),'on');
1172
+            }
1173
+            print '</td>';
1174
+
1175
+            // Generate doc
1176
+            print '<td align="center">';
1177
+
1178
+            $buttonlabel = $langs->trans("BuildDoc");
1179
+            $forname='builddocrib'.$rib->id;
1180
+
1181
+            include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1182
+            $modellist=ModeleBankAccountDoc::liste_modeles($db);
1183
+
1184
+            $out = '';
1185
+            if (is_array($modellist) && count($modellist))
1186
+            {
1187
+                $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
1188
+                $out.= '<input type="hidden" name="action" value="builddocrib">';
1189
+                $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1190
+                $out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
1191
+                $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
1192
+
1193
+                if (is_array($modellist) && count($modellist) == 1)    // If there is only one element
1194
+                {
1195
+                    $arraykeys=array_keys($modellist);
1196
+                    $modelselected=$arraykeys[0];
1197
+                }
1198
+                if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1199
+
1200
+                $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1201
+                $out.= ajax_combobox('modelrib'.$rib->id);
1202
+
1203
+                // Language code (if multilang)
1204
+                if ($conf->global->MAIN_MULTILANGS)
1205
+                {
1206
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
1207
+                    $formadmin=new FormAdmin($db);
1208
+                    $defaultlang=$codelang?$codelang:$langs->getDefaultLang();
1209
+                    $morecss='maxwidth150';
1210
+                    if ($conf->browser->layout == 'phone') $morecss='maxwidth100';
1211
+                    $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1212
+                }
1213
+                // Button
1214
+                $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
1215
+                $genbutton.= ' type="submit" value="'.$buttonlabel.'"';
1216
+                if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
1217
+                $genbutton.= '>';
1218
+                if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
1219
+                {
1220
+                    $langs->load("errors");
1221
+                    $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1222
+                }
1223
+                if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
1224
+                if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
1225
+                $out.= $genbutton;
1226
+                $out.= '</form>';
1227
+            }
1228
+            print $out;
1229
+            print '</td>';
1230
+
1231
+            // Edit/Delete
1232
+            print '<td align="right" class="nowraponall">';
1233
+            if ($user->rights->societe->creer)
1234
+            {
1235
+                print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
1236
+                print img_picto($langs->trans("Modify"),'edit');
1237
+                print '</a>';
1238
+
1239
+                    print '&nbsp;';
1240
+
1241
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
1242
+                    print img_picto($langs->trans("Delete"),'delete');
1243
+                    print '</a>';
1244
+            }
1245
+            print '</td>';
1246
+
1247
+            print '</tr>';
1248
+        }
1249
+
1250
+        if (count($rib_list) == 0)
1251
+        {
1252
+            $colspan=8;
1253
+            if (! empty($conf->prelevement->enabled)) $colspan+=2;
1254
+            print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
1255
+        }
1256
+
1257
+        print '</table>';
1258
+        print '</div>';
1259
+    } else {
1260
+        dol_print_error($db);
1261
+    }
1262
+
1263
+
1264
+    if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
1265
+    {
1266
+        print '<br>';
1267
+
1268
+        print '<div class="fichecenter"><div class="fichehalfleft">';
1269
+        print '<a name="builddoc"></a>'; // ancre
1270
+
1271
+        /*
1272 1272
          * Documents generes
1273 1273
          */
1274
-		$filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
1275
-		$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
1276
-		$genallowed=$user->rights->societe->lire;
1277
-		$delallowed=$user->rights->societe->creer;
1278
-
1279
-		print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
1280
-
1281
-		// Show direct download link
1282
-		if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
1283
-		{
1284
-			$companybankaccounttemp = new CompanyBankAccount($db);
1285
-			$companypaymentmodetemp = new CompanyPaymentMode($db);
1286
-			$result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban');
1287
-
1288
-			include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1289
-			$ecmfile = new EcmFiles($db);
1290
-			$result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1291
-			if ($result > 0)
1292
-			{
1293
-				$companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
1294
-				print '<br><!-- Link to download main doc -->'."\n";
1295
-				print showDirectDownloadLink($companybankaccounttemp).'<br>';
1296
-			}
1297
-		}
1298
-
1299
-		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
1300
-
1301
-
1302
-		print '</div></div></div>';
1303
-
1304
-		print '<br>';
1305
-	}
1306
-	/*
1274
+        $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
1275
+        $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
1276
+        $genallowed=$user->rights->societe->lire;
1277
+        $delallowed=$user->rights->societe->creer;
1278
+
1279
+        print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
1280
+
1281
+        // Show direct download link
1282
+        if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
1283
+        {
1284
+            $companybankaccounttemp = new CompanyBankAccount($db);
1285
+            $companypaymentmodetemp = new CompanyPaymentMode($db);
1286
+            $result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban');
1287
+
1288
+            include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1289
+            $ecmfile = new EcmFiles($db);
1290
+            $result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1291
+            if ($result > 0)
1292
+            {
1293
+                $companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
1294
+                print '<br><!-- Link to download main doc -->'."\n";
1295
+                print showDirectDownloadLink($companybankaccounttemp).'<br>';
1296
+            }
1297
+        }
1298
+
1299
+        print '</div><div class="fichehalfright"><div class="ficheaddleft">';
1300
+
1301
+
1302
+        print '</div></div></div>';
1303
+
1304
+        print '<br>';
1305
+    }
1306
+    /*
1307 1307
     include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1308 1308
     $modellist=ModeleBankAccountDoc::liste_modeles($db);
1309 1309
     //print '<td>';
@@ -1327,310 +1327,310 @@  discard block
 block discarded – undo
1327 1327
 // Edit BAN
1328 1328
 if ($socid && $action == 'edit' && $user->rights->societe->creer)
1329 1329
 {
1330
-	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1331
-
1332
-	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1333
-
1334
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1335
-
1336
-	print '<div class="fichecenter">';
1337
-
1338
-	print '<div class="underbanner clearboth"></div>';
1339
-	print '<table class="border centpercent">';
1340
-
1341
-	print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1342
-	print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>';
1343
-
1344
-	print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
1345
-	print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>';
1346
-
1347
-	// Show fields of bank account
1348
-	foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1349
-
1350
-		$require=false;
1351
-		if ($val == 'BankCode') {
1352
-			$name = 'code_banque';
1353
-			$size = 8;
1354
-			$content = $companybankaccount->code_banque;
1355
-		} elseif ($val == 'DeskCode') {
1356
-			$name = 'code_guichet';
1357
-			$size = 8;
1358
-			$content = $companybankaccount->code_guichet;
1359
-		} elseif ($val == 'BankAccountNumber') {
1360
-			$name = 'number';
1361
-			$size = 18;
1362
-			$content = $companybankaccount->number;
1363
-		} elseif ($val == 'BankAccountNumberKey') {
1364
-			$name = 'cle_rib';
1365
-			$size = 3;
1366
-			$content = $companybankaccount->cle_rib;
1367
-		} elseif ($val == 'IBAN') {
1368
-			$name = 'iban';
1369
-			$size = 30;
1370
-			$content = $companybankaccount->iban;
1371
-			if ($companybankaccount->needIBAN()) $require=true;
1372
-		} elseif ($val == 'BIC') {
1373
-			$name = 'bic';
1374
-			$size = 12;
1375
-			$content = $companybankaccount->bic;
1376
-			if ($companybankaccount->needIBAN()) $require=true;
1377
-		}
1378
-
1379
-		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1380
-		print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
1381
-		print '</tr>';
1382
-	}
1383
-
1384
-	print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1385
-	print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1386
-	print $companybankaccount->domiciliation;
1387
-	print "</textarea></td></tr>";
1388
-
1389
-	print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1390
-	print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>';
1391
-	print "</td></tr>\n";
1392
-
1393
-	print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1394
-	print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">';
1395
-	print $companybankaccount->owner_address;
1396
-	print "</textarea></td></tr>";
1397
-
1398
-	print '</table>';
1399
-
1400
-	if ($conf->prelevement->enabled)
1401
-	{
1402
-		print '<br>';
1403
-
1404
-		print '<table class="border" width="100%">';
1405
-
1406
-		if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1407
-
1408
-		// RUM
1409
-		print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
1410
-		print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';
1411
-
1412
-		print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1413
-		$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1414
-		print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0);
1415
-		print '</td></tr>';
1416
-
1417
-		print '</table>';
1418
-	}
1419
-
1420
-	print '</div>';
1421
-
1422
-	dol_fiche_end();
1423
-
1424
-	print '<div align="center">';
1425
-	print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
1426
-	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1427
-	print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
1428
-	print '</div>';
1330
+    dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1331
+
1332
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1333
+
1334
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1335
+
1336
+    print '<div class="fichecenter">';
1337
+
1338
+    print '<div class="underbanner clearboth"></div>';
1339
+    print '<table class="border centpercent">';
1340
+
1341
+    print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1342
+    print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>';
1343
+
1344
+    print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
1345
+    print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>';
1346
+
1347
+    // Show fields of bank account
1348
+    foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1349
+
1350
+        $require=false;
1351
+        if ($val == 'BankCode') {
1352
+            $name = 'code_banque';
1353
+            $size = 8;
1354
+            $content = $companybankaccount->code_banque;
1355
+        } elseif ($val == 'DeskCode') {
1356
+            $name = 'code_guichet';
1357
+            $size = 8;
1358
+            $content = $companybankaccount->code_guichet;
1359
+        } elseif ($val == 'BankAccountNumber') {
1360
+            $name = 'number';
1361
+            $size = 18;
1362
+            $content = $companybankaccount->number;
1363
+        } elseif ($val == 'BankAccountNumberKey') {
1364
+            $name = 'cle_rib';
1365
+            $size = 3;
1366
+            $content = $companybankaccount->cle_rib;
1367
+        } elseif ($val == 'IBAN') {
1368
+            $name = 'iban';
1369
+            $size = 30;
1370
+            $content = $companybankaccount->iban;
1371
+            if ($companybankaccount->needIBAN()) $require=true;
1372
+        } elseif ($val == 'BIC') {
1373
+            $name = 'bic';
1374
+            $size = 12;
1375
+            $content = $companybankaccount->bic;
1376
+            if ($companybankaccount->needIBAN()) $require=true;
1377
+        }
1378
+
1379
+        print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1380
+        print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
1381
+        print '</tr>';
1382
+    }
1383
+
1384
+    print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1385
+    print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1386
+    print $companybankaccount->domiciliation;
1387
+    print "</textarea></td></tr>";
1388
+
1389
+    print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1390
+    print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>';
1391
+    print "</td></tr>\n";
1392
+
1393
+    print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1394
+    print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">';
1395
+    print $companybankaccount->owner_address;
1396
+    print "</textarea></td></tr>";
1397
+
1398
+    print '</table>';
1399
+
1400
+    if ($conf->prelevement->enabled)
1401
+    {
1402
+        print '<br>';
1403
+
1404
+        print '<table class="border" width="100%">';
1405
+
1406
+        if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1407
+
1408
+        // RUM
1409
+        print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
1410
+        print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';
1411
+
1412
+        print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1413
+        $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1414
+        print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0);
1415
+        print '</td></tr>';
1416
+
1417
+        print '</table>';
1418
+    }
1419
+
1420
+    print '</div>';
1421
+
1422
+    dol_fiche_end();
1423
+
1424
+    print '<div align="center">';
1425
+    print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
1426
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1427
+    print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
1428
+    print '</div>';
1429 1429
 }
1430 1430
 
1431 1431
 // Edit Card
1432 1432
 if ($socid && $action == 'editcard' && $user->rights->societe->creer)
1433 1433
 {
1434
-	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1434
+    dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1435 1435
 
1436
-	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1436
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1437 1437
 
1438
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1438
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1439 1439
 
1440
-	print '<div class="fichecenter">';
1440
+    print '<div class="fichecenter">';
1441 1441
 
1442
-	print '<div class="underbanner clearboth"></div>';
1443
-	print '<table class="border centpercent">';
1442
+    print '<div class="underbanner clearboth"></div>';
1443
+    print '<table class="border centpercent">';
1444 1444
 
1445
-	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1446
-	print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>';
1445
+    print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1446
+    print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>';
1447 1447
 
1448
-	print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1449
-	print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
1448
+    print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1449
+    print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
1450 1450
 
1451
-	print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
1452
-	print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
1451
+    print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
1452
+    print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
1453 1453
 
1454
-	print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1455
-	print '<td>';
1456
-	print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1);
1457
-	print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1458
-	print '</td></tr>';
1454
+    print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1455
+    print '<td>';
1456
+    print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1);
1457
+    print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1458
+    print '</td></tr>';
1459 1459
 
1460
-	print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
1461
-	print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
1460
+    print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
1461
+    print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
1462 1462
 
1463
-	print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1464
-	print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>';
1463
+    print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1464
+    print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>';
1465 1465
 
1466
-	print '</table>';
1467
-	print '</div>';
1466
+    print '</table>';
1467
+    print '</div>';
1468 1468
 
1469
-	dol_fiche_end();
1469
+    dol_fiche_end();
1470 1470
 
1471
-	print '<div align="center">';
1472
-	print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
1473
-	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1474
-	print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
1475
-	print '</div>';
1471
+    print '<div align="center">';
1472
+    print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
1473
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1474
+    print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
1475
+    print '</div>';
1476 1476
 }
1477 1477
 
1478 1478
 
1479 1479
 // Create BAN
1480 1480
 if ($socid && $action == 'create' && $user->rights->societe->creer)
1481 1481
 {
1482
-	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1483
-
1484
-	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1485
-
1486
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1487
-
1488
-	print '<div class="nofichecenter">';
1489
-
1490
-	print '<div class="underbanner clearboth"></div>';
1491
-	print '<table class="border centpercent">';
1492
-
1493
-	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1494
-	print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>';
1495
-
1496
-	print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
1497
-	print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
1498
-
1499
-	// Show fields of bank account
1500
-	foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1501
-
1502
-		$require=false;
1503
-		if ($val == 'BankCode') {
1504
-			$name = 'code_banque';
1505
-			$size = 8;
1506
-		} elseif ($val == 'DeskCode') {
1507
-			$name = 'code_guichet';
1508
-			$size = 8;
1509
-		} elseif ($val == 'BankAccountNumber') {
1510
-			$name = 'number';
1511
-			$size = 18;
1512
-		} elseif ($val == 'BankAccountNumberKey') {
1513
-			$name = 'cle_rib';
1514
-			$size = 3;
1515
-		} elseif ($val == 'IBAN') {
1516
-			$name = 'iban';
1517
-			$size = 30;
1518
-			if ($companybankaccount->needIBAN()) $require=true;
1519
-		} elseif ($val == 'BIC') {
1520
-			$name = 'bic';
1521
-			$size = 12;
1522
-			if ($companybankaccount->needIBAN()) $require=true;
1523
-		}
1524
-
1525
-		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1526
-		print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
1527
-		print '</tr>';
1528
-	}
1529
-
1530
-	print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1531
-	print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1532
-	print GETPOST('domiciliation');
1533
-	print "</textarea></td></tr>";
1534
-
1535
-	print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1536
-	print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>';
1537
-	print "</td></tr>\n";
1538
-
1539
-	print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1540
-	print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1541
-	print GETPOST('owner_address');
1542
-	print "</textarea></td></tr>";
1543
-
1544
-	print '</table>';
1545
-
1546
-	if ($conf->prelevement->enabled)
1547
-	{
1548
-		print '<br>';
1549
-
1550
-		print '<table class="border" width="100%">';
1551
-
1552
-		// RUM
1553
-		print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
1554
-		print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
1555
-
1556
-		print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1557
-		$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1558
-		print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
1559
-		print '</td></tr>';
1560
-
1561
-		print '</table>';
1562
-	}
1563
-
1564
-	print '</div>';
1565
-
1566
-	dol_fiche_end();
1567
-
1568
-	dol_set_focus('#label');
1569
-
1570
-	print '<div class="center">';
1571
-	print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
1572
-	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1573
-	print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
1574
-	print '</div>';
1482
+    dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1483
+
1484
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1485
+
1486
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1487
+
1488
+    print '<div class="nofichecenter">';
1489
+
1490
+    print '<div class="underbanner clearboth"></div>';
1491
+    print '<table class="border centpercent">';
1492
+
1493
+    print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1494
+    print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>';
1495
+
1496
+    print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
1497
+    print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
1498
+
1499
+    // Show fields of bank account
1500
+    foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1501
+
1502
+        $require=false;
1503
+        if ($val == 'BankCode') {
1504
+            $name = 'code_banque';
1505
+            $size = 8;
1506
+        } elseif ($val == 'DeskCode') {
1507
+            $name = 'code_guichet';
1508
+            $size = 8;
1509
+        } elseif ($val == 'BankAccountNumber') {
1510
+            $name = 'number';
1511
+            $size = 18;
1512
+        } elseif ($val == 'BankAccountNumberKey') {
1513
+            $name = 'cle_rib';
1514
+            $size = 3;
1515
+        } elseif ($val == 'IBAN') {
1516
+            $name = 'iban';
1517
+            $size = 30;
1518
+            if ($companybankaccount->needIBAN()) $require=true;
1519
+        } elseif ($val == 'BIC') {
1520
+            $name = 'bic';
1521
+            $size = 12;
1522
+            if ($companybankaccount->needIBAN()) $require=true;
1523
+        }
1524
+
1525
+        print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1526
+        print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
1527
+        print '</tr>';
1528
+    }
1529
+
1530
+    print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1531
+    print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1532
+    print GETPOST('domiciliation');
1533
+    print "</textarea></td></tr>";
1534
+
1535
+    print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1536
+    print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>';
1537
+    print "</td></tr>\n";
1538
+
1539
+    print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1540
+    print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1541
+    print GETPOST('owner_address');
1542
+    print "</textarea></td></tr>";
1543
+
1544
+    print '</table>';
1545
+
1546
+    if ($conf->prelevement->enabled)
1547
+    {
1548
+        print '<br>';
1549
+
1550
+        print '<table class="border" width="100%">';
1551
+
1552
+        // RUM
1553
+        print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
1554
+        print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
1555
+
1556
+        print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1557
+        $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1558
+        print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
1559
+        print '</td></tr>';
1560
+
1561
+        print '</table>';
1562
+    }
1563
+
1564
+    print '</div>';
1565
+
1566
+    dol_fiche_end();
1567
+
1568
+    dol_set_focus('#label');
1569
+
1570
+    print '<div class="center">';
1571
+    print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
1572
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1573
+    print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
1574
+    print '</div>';
1575 1575
 }
1576 1576
 
1577 1577
 // Create Card
1578 1578
 if ($socid && $action == 'createcard' && $user->rights->societe->creer)
1579 1579
 {
1580
-	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1580
+    dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
1581 1581
 
1582
-	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1582
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1583 1583
 
1584
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1584
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1585 1585
 
1586
-	print '<div class="nofichecenter">';
1586
+    print '<div class="nofichecenter">';
1587 1587
 
1588
-	print '<div class="underbanner clearboth"></div>';
1589
-	print '<table class="border centpercent">';
1588
+    print '<div class="underbanner clearboth"></div>';
1589
+    print '<table class="border centpercent">';
1590 1590
 
1591
-	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1592
-	print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>';
1591
+    print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1592
+    print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>';
1593 1593
 
1594
-	print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1595
-	print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>';
1594
+    print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1595
+    print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>';
1596 1596
 
1597
-	print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
1598
-	print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>';
1597
+    print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
1598
+    print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>';
1599 1599
 
1600
-	print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1601
-	print '<td>';
1602
-	print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1);
1603
-	print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1604
-	print '</td></tr>';
1600
+    print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1601
+    print '<td>';
1602
+    print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1);
1603
+    print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1604
+    print '</td></tr>';
1605 1605
 
1606
-	print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
1607
-	print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>';
1606
+    print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
1607
+    print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>';
1608 1608
 
1609
-	print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1610
-	print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>';
1609
+    print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1610
+    print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>';
1611 1611
 
1612
-	print '</table>';
1612
+    print '</table>';
1613 1613
 
1614
-	print '</div>';
1614
+    print '</div>';
1615 1615
 
1616
-	dol_fiche_end();
1616
+    dol_fiche_end();
1617 1617
 
1618
-	dol_set_focus('#label');
1618
+    dol_set_focus('#label');
1619 1619
 
1620
-	print '<div class="center">';
1621
-	print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
1622
-	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1623
-	print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
1624
-	print '</div>';
1620
+    print '<div class="center">';
1621
+    print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
1622
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1623
+    print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
1624
+    print '</div>';
1625 1625
 }
1626 1626
 
1627 1627
 if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer)
1628 1628
 {
1629
-	print '</form>';
1629
+    print '</form>';
1630 1630
 }
1631 1631
 if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer)
1632 1632
 {
1633
-	print '</form>';
1633
+    print '</form>';
1634 1634
 }
1635 1635
 
1636 1636
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/note.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
 }
126 126
 else
127 127
 {
128
-	$langs->load("errors");
129
-	print $langs->trans("ErrorRecordNotFound");
128
+    $langs->load("errors");
129
+    print $langs->trans("ErrorRecordNotFound");
130 130
 }
131 131
 
132 132
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/price.php 1 patch
Indentation   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
34 34
 
35 35
 if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
36
-	require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
36
+    require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
37 37
 
38
-	$prodcustprice = new Productcustomerprice($db);
38
+    $prodcustprice = new Productcustomerprice($db);
39 39
 }
40 40
 
41 41
 $langs->loadLangs(array("products", "companies", "bills"));
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 // Security check
48 48
 $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
49 49
 if ($user->societe_id)
50
-	$socid = $user->societe_id;
50
+    $socid = $user->societe_id;
51 51
 $result = restrictedArea($user, 'societe', $socid, '&societe');
52 52
 
53 53
 $object = new Societe($db);
@@ -74,98 +74,98 @@  discard block
 block discarded – undo
74 74
 
75 75
     if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
76 76
 
77
-    	$update_child_soc = GETPOST('updatechildprice');
78
-
79
-    	// add price by customer
80
-    	$prodcustprice->fk_soc = $socid;
81
-    	$prodcustprice->fk_product = GETPOST('prodid', 'int');
82
-    	$prodcustprice->price = price2num(GETPOST("price"), 'MU');
83
-    	$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
84
-    	$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
85
-
86
-    	$tva_tx_txt = GETPOST('tva_tx', 'alpha');           // tva_tx can be '8.5'  or  '8.5*'  or  '8.5 (XXX)' or '8.5* (XXX)'
87
-
88
-    	// We must define tva_tx, npr and local taxes
89
-    	$vatratecode = '';
90
-    	$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
91
-    	$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
92
-    	$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
93
-    	// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
94
-    	if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
95
-    	{
96
-    	    // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
97
-    	    $vatratecode=$reg[1];
98
-    	    // Get record from code
99
-    	    $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
100
-    	    $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
101
-    	    $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'";
102
-    	    $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
103
-    	    $sql.= " AND t.code ='".$vatratecode."'";
104
-    	    $resql=$db->query($sql);
105
-    	    if ($resql)
106
-    	    {
107
-    	        $obj = $db->fetch_object($resql);
108
-    	        $npr = $obj->recuperableonly;
109
-    	        $localtax1 = $obj->localtax1;
110
-    	        $localtax2 = $obj->localtax2;
111
-    	        $localtax1_type = $obj->localtax1_type;
112
-    	        $localtax2_type = $obj->localtax2_type;
113
-    	    }
114
-    	}
115
-
116
-    	$prodcustprice->default_vat_code = $vatratecode;
117
-    	$prodcustprice->tva_tx = $tva_tx;
118
-    	$prodcustprice->recuperableonly = $npr;
119
-    	$prodcustprice->localtax1_tx = $localtax1;
120
-    	$prodcustprice->localtax2_tx = $localtax2;
121
-    	$prodcustprice->localtax1_type = $localtax1_type;
122
-    	$prodcustprice->localtax2_type = $localtax2_type;
123
-
124
-    	$result = $prodcustprice->create($user, 0, $update_child_soc);
125
-
126
-    	if ($result < 0) {
127
-    		setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
128
-    	} else {
129
-    		setEventMessages($langs->trans('Save'), null, 'mesgs');
130
-    	}
131
-
132
-    	$action = '';
77
+        $update_child_soc = GETPOST('updatechildprice');
78
+
79
+        // add price by customer
80
+        $prodcustprice->fk_soc = $socid;
81
+        $prodcustprice->fk_product = GETPOST('prodid', 'int');
82
+        $prodcustprice->price = price2num(GETPOST("price"), 'MU');
83
+        $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
84
+        $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
85
+
86
+        $tva_tx_txt = GETPOST('tva_tx', 'alpha');           // tva_tx can be '8.5'  or  '8.5*'  or  '8.5 (XXX)' or '8.5* (XXX)'
87
+
88
+        // We must define tva_tx, npr and local taxes
89
+        $vatratecode = '';
90
+        $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
91
+        $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
92
+        $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
93
+        // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
94
+        if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
95
+        {
96
+            // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
97
+            $vatratecode=$reg[1];
98
+            // Get record from code
99
+            $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
100
+            $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
101
+            $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'";
102
+            $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
103
+            $sql.= " AND t.code ='".$vatratecode."'";
104
+            $resql=$db->query($sql);
105
+            if ($resql)
106
+            {
107
+                $obj = $db->fetch_object($resql);
108
+                $npr = $obj->recuperableonly;
109
+                $localtax1 = $obj->localtax1;
110
+                $localtax2 = $obj->localtax2;
111
+                $localtax1_type = $obj->localtax1_type;
112
+                $localtax2_type = $obj->localtax2_type;
113
+            }
114
+        }
115
+
116
+        $prodcustprice->default_vat_code = $vatratecode;
117
+        $prodcustprice->tva_tx = $tva_tx;
118
+        $prodcustprice->recuperableonly = $npr;
119
+        $prodcustprice->localtax1_tx = $localtax1;
120
+        $prodcustprice->localtax2_tx = $localtax2;
121
+        $prodcustprice->localtax1_type = $localtax1_type;
122
+        $prodcustprice->localtax2_type = $localtax2_type;
123
+
124
+        $result = $prodcustprice->create($user, 0, $update_child_soc);
125
+
126
+        if ($result < 0) {
127
+            setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
128
+        } else {
129
+            setEventMessages($langs->trans('Save'), null, 'mesgs');
130
+        }
131
+
132
+        $action = '';
133 133
     }
134 134
 
135 135
     if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
136
-    	// Delete price by customer
137
-    	$prodcustprice->id = GETPOST('lineid');
138
-    	$result = $prodcustprice->delete($user);
139
-
140
-    	if ($result < 0) {
141
-    		setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
142
-    	} else {
143
-    		setEventMessages($langs->trans('Delete'), null, 'errors');
144
-    	}
145
-    	$action = '';
136
+        // Delete price by customer
137
+        $prodcustprice->id = GETPOST('lineid');
138
+        $result = $prodcustprice->delete($user);
139
+
140
+        if ($result < 0) {
141
+            setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
142
+        } else {
143
+            setEventMessages($langs->trans('Delete'), null, 'errors');
144
+        }
145
+        $action = '';
146 146
     }
147 147
 
148 148
     if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
149 149
 
150
-    	$prodcustprice->fetch(GETPOST('lineid', 'int'));
150
+        $prodcustprice->fetch(GETPOST('lineid', 'int'));
151 151
 
152
-    	$update_child_soc = GETPOST('updatechildprice');
152
+        $update_child_soc = GETPOST('updatechildprice');
153 153
 
154
-    	// update price by customer
155
-    	$prodcustprice->price = price2num(GETPOST("price"), 'MU');
156
-    	$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
157
-    	$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
158
-    	$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
159
-    	$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
154
+        // update price by customer
155
+        $prodcustprice->price = price2num(GETPOST("price"), 'MU');
156
+        $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
157
+        $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
158
+        $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
159
+        $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
160 160
 
161
-    	$result = $prodcustprice->update($user, 0, $update_child_soc);
162
-    	if ($result < 0) {
163
-    		setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
164
-    	} else {
165
-    		setEventMessages($langs->trans('Save'), null, 'mesgs');
166
-    	}
161
+        $result = $prodcustprice->update($user, 0, $update_child_soc);
162
+        if ($result < 0) {
163
+            setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
164
+        } else {
165
+            setEventMessages($langs->trans('Save'), null, 'mesgs');
166
+        }
167 167
 
168
-    	$action = '';
168
+        $action = '';
169 169
     }
170 170
 }
171 171
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer'));
183 183
 
184 184
 if (! empty($conf->notification->enabled))
185
-	$langs->load("mails");
185
+    $langs->load("mails");
186 186
 $head = societe_prepare_head($object);
187 187
 
188 188
 dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
@@ -198,25 +198,25 @@  discard block
 block discarded – undo
198 198
 
199 199
 if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
200 200
 {
201
-	print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>';
201
+    print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>';
202 202
 }
203 203
 
204 204
 if ($object->client) {
205
-	print '<tr><td class="titlefield">';
206
-	print $langs->trans('CustomerCode') . '</td><td colspan="3">';
207
-	print $object->code_client;
208
-	if ($object->check_codeclient() != 0)
209
-		print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
210
-	print '</td></tr>';
205
+    print '<tr><td class="titlefield">';
206
+    print $langs->trans('CustomerCode') . '</td><td colspan="3">';
207
+    print $object->code_client;
208
+    if ($object->check_codeclient() != 0)
209
+        print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
210
+    print '</td></tr>';
211 211
 }
212 212
 
213 213
 if ($object->fournisseur) {
214
-	print '<tr><td class="titlefield">';
215
-	print $langs->trans('SupplierCode') . '</td><td colspan="3">';
216
-	print $object->code_fournisseur;
217
-	if ($object->check_codefournisseur() != 0)
218
-		print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
219
-	print '</td></tr>';
214
+    print '<tr><td class="titlefield">';
215
+    print $langs->trans('SupplierCode') . '</td><td colspan="3">';
216
+    print $object->code_fournisseur;
217
+    if ($object->check_codefournisseur() != 0)
218
+        print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
219
+    print '</td></tr>';
220 220
 }
221 221
 
222 222
 print '</table>';
@@ -229,277 +229,277 @@  discard block
 block discarded – undo
229 229
 
230 230
 if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
231 231
 
232
-	$prodcustprice = new Productcustomerprice($db);
232
+    $prodcustprice = new Productcustomerprice($db);
233 233
 
234
-	$sortfield = GETPOST("sortfield", 'alpha');
235
-	$sortorder = GETPOST("sortorder", 'alpha');
234
+    $sortfield = GETPOST("sortfield", 'alpha');
235
+    $sortorder = GETPOST("sortorder", 'alpha');
236 236
     $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
237
-	$page = GETPOST("page", 'int');
238
-	if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
239
-	$offset = $limit * $page;
240
-	$pageprev = $page - 1;
241
-	$pagenext = $page + 1;
242
-	if (! $sortorder)
243
-		$sortorder = "ASC";
244
-	if (! $sortfield)
245
-		$sortfield = "soc.nom";
246
-
247
-		// Build filter to diplay only concerned lines
248
-	$filter = array (
249
-		't.fk_soc' => $object->id
250
-	);
251
-
252
-	if (! empty($search_prod)) {
253
-		$filter ['prod.ref'] = $search_prod;
254
-	}
255
-
256
-	if ($action == 'add_customer_price') {
257
-
258
-		// Create mode
259
-
260
-		print load_fiche_titre($langs->trans('PriceByCustomer'));
261
-
262
-		print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
263
-		print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
264
-		print '<input type="hidden" name="action" value="add_customer_price_confirm">';
265
-		print '<input type="hidden" name="socid" value="' . $object->id . '">';
266
-		print '<table class="border" width="100%">';
267
-		print '<tr>';
268
-		print '<td>' . $langs->trans('Product') . '</td>';
269
-		print '<td>';
270
-		print $form->select_produits('', 'prodid', '', 0);
271
-		print '</td>';
272
-		print '</tr>';
273
-
274
-		// VAT
275
-		print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
276
-		print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
277
-		print '</td></tr>';
278
-
279
-		// Price base
280
-		print '<tr><td width="15%">';
281
-		print $langs->trans('PriceBase');
282
-		print '</td>';
283
-		print '<td>';
284
-		print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
285
-		print '</td>';
286
-		print '</tr>';
287
-
288
-		// Price
289
-		print '<tr><td width="20%">';
290
-		$text = $langs->trans('SellingPrice');
291
-		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
292
-		print '</td><td>';
293
-		if ($object->price_base_type == 'TTC') {
294
-			print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
295
-		} else {
296
-			print '<input name="price" size="10" value="' . price($object->price) . '">';
297
-		}
298
-		print '</td></tr>';
299
-
300
-		// Price minimum
301
-		print '<tr><td>';
302
-		$text = $langs->trans('MinPrice');
303
-		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
304
-		if ($object->price_base_type == 'TTC') {
305
-			print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
306
-		} else {
307
-			print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
308
-		}
309
-		print '</td></tr>';
310
-
311
-		// Update all child soc
312
-		print '<tr><td width="15%">';
313
-		print $langs->trans('ForceUpdateChildPriceSoc');
314
-		print '</td>';
315
-		print '<td>';
316
-		print '<input type="checkbox" name="updatechildprice" value="1"/>';
317
-		print '</td>';
318
-		print '</tr>';
319
-
320
-		print '</table>';
321
-
322
-		print '<br><div align="center">';
323
-		print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
324
-		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
325
-		print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
326
-		print '</div>';
327
-
328
-		print '<br></form>';
329
-	} elseif ($action == 'edit_customer_price') {
330
-
331
-		// Edit mode
332
-
333
-		print load_fiche_titre($langs->trans('PriceByCustomer'));
334
-
335
-		$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
336
-		if ($result < 0)
337
-		{
338
-			setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
339
-		}
340
-
341
-		print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
342
-		print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
343
-		print '<input type="hidden" name="action" value="update_customer_price_confirm">';
344
-		print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
345
-		print '<table class="border" width="100%">';
346
-		print '<tr>';
347
-		print '<td>' . $langs->trans('Product') . '</td>';
348
-		$staticprod = new Product($db);
349
-		$staticprod->fetch($prodcustprice->fk_product);
350
-		print "<td>" . $staticprod->getNomUrl(1) . "</td>";
351
-		print '</tr>';
352
-
353
-		// VAT
354
-		print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
355
-		print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
356
-		print '</td></tr>';
357
-
358
-		// Price base
359
-		print '<tr><td width="15%">';
360
-		print $langs->trans('PriceBase');
361
-		print '</td>';
362
-		print '<td>';
363
-		print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
364
-		print '</td>';
365
-		print '</tr>';
366
-
367
-		// Price
368
-		print '<tr><td width="20%">';
369
-		$text = $langs->trans('SellingPrice');
370
-		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
371
-		print '</td><td>';
372
-		if ($prodcustprice->price_base_type == 'TTC') {
373
-			print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">';
374
-		} else {
375
-			print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
376
-		}
377
-		print '</td></tr>';
378
-
379
-		// Price minimum
380
-		print '<tr><td>';
381
-		$text = $langs->trans('MinPrice');
382
-		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
383
-		print '</td><td>';
384
-		if ($prodcustprice->price_base_type == 'TTC') {
385
-			print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
386
-		} else {
387
-			print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
388
-		}
389
-		print '</td></tr>';
390
-
391
-		// Update all child soc
392
-		print '<tr><td width="15%">';
393
-		print $langs->trans('ForceUpdateChildPriceSoc');
394
-		print '</td>';
395
-		print '<td>';
396
-		print '<input type="checkbox" name="updatechildprice" value="1">';
397
-		print '</td>';
398
-		print '</tr>';
399
-
400
-		print '</table>';
401
-
402
-		print '<br><div class="center">';
403
-		print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
404
-		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
405
-		print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
406
-		print '</div>';
407
-
408
-		print '<br></form>';
409
-	} elseif ($action == 'showlog_customer_price') {
410
-
411
-	    print '<!-- showlog_customer_price -->'."\n";
412
-
413
-		$filter = array (
414
-			't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
415
-		);
416
-
417
-		// Count total nb of records
418
-		$nbtotalofrecords = '';
419
-		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
420
-			$nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
421
-		}
422
-
423
-		$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
424
-		if ($result < 0)
425
-		{
426
-			setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
427
-		}
428
-
429
-		$option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
430
-
431
-		print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
432
-
433
-		if (count($prodcustprice->lines) > 0) {
434
-
435
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
436
-			print '<input type="hidden" name="id" value="' . $object->id . '">';
437
-
438
-			print '<table class="noborder" width="100%">';
439
-
440
-			print '<tr class="liste_titre">';
441
-			print '<td>' . $langs->trans("Product") . '</td>';
442
-			print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
443
-			print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
444
-			print '<td align="right">' . $langs->trans("VAT") . '</td>';
445
-			print '<td align="right">' . $langs->trans("HT") . '</td>';
446
-			print '<td align="right">' . $langs->trans("TTC") . '</td>';
447
-			print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
448
-			print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
449
-			print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
450
-			print '<td>&nbsp;</td>';
451
-			print '</tr>';
452
-
453
-			foreach ( $prodcustprice->lines as $line ) {
454
-
455
-				print '<tr class="oddeven">';
456
-				$staticprod = new Product($db);
457
-				$staticprod->fetch($line->fk_product);
458
-
459
-				print "<td>" . $staticprod->getNomUrl(1) . "</td>";
460
-				print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
461
-
462
-				print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
463
-				print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
464
-				print '<td align="right">' . price($line->price) . "</td>";
465
-				print '<td align="right">' . price($line->price_ttc) . "</td>";
466
-				print '<td align="right">' . price($line->price_min) . '</td>';
467
-				print '<td align="right">' . price($line->price_min_ttc) . '</td>';
468
-
469
-				// User
470
-				$userstatic = new User($db);
471
-				$userstatic->fetch($line->fk_user);
472
-				print '<td align="right">';
473
-				print $userstatic->getLoginUrl(1);
474
-				print '</td>';
475
-			}
476
-			print "</table>";
477
-		}
478
-		else
479
-		{
480
-			print $langs->trans('None');
481
-		}
482
-
483
-		print "\n" . '<div class="tabsAction">' . "\n";
484
-		print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
485
-		print "\n</div><br>\n";
486
-	}
487
-	else
488
-	{
237
+    $page = GETPOST("page", 'int');
238
+    if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
239
+    $offset = $limit * $page;
240
+    $pageprev = $page - 1;
241
+    $pagenext = $page + 1;
242
+    if (! $sortorder)
243
+        $sortorder = "ASC";
244
+    if (! $sortfield)
245
+        $sortfield = "soc.nom";
246
+
247
+        // Build filter to diplay only concerned lines
248
+    $filter = array (
249
+        't.fk_soc' => $object->id
250
+    );
251
+
252
+    if (! empty($search_prod)) {
253
+        $filter ['prod.ref'] = $search_prod;
254
+    }
255
+
256
+    if ($action == 'add_customer_price') {
257
+
258
+        // Create mode
259
+
260
+        print load_fiche_titre($langs->trans('PriceByCustomer'));
261
+
262
+        print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
263
+        print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
264
+        print '<input type="hidden" name="action" value="add_customer_price_confirm">';
265
+        print '<input type="hidden" name="socid" value="' . $object->id . '">';
266
+        print '<table class="border" width="100%">';
267
+        print '<tr>';
268
+        print '<td>' . $langs->trans('Product') . '</td>';
269
+        print '<td>';
270
+        print $form->select_produits('', 'prodid', '', 0);
271
+        print '</td>';
272
+        print '</tr>';
273
+
274
+        // VAT
275
+        print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
276
+        print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
277
+        print '</td></tr>';
278
+
279
+        // Price base
280
+        print '<tr><td width="15%">';
281
+        print $langs->trans('PriceBase');
282
+        print '</td>';
283
+        print '<td>';
284
+        print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
285
+        print '</td>';
286
+        print '</tr>';
287
+
288
+        // Price
289
+        print '<tr><td width="20%">';
290
+        $text = $langs->trans('SellingPrice');
291
+        print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
292
+        print '</td><td>';
293
+        if ($object->price_base_type == 'TTC') {
294
+            print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
295
+        } else {
296
+            print '<input name="price" size="10" value="' . price($object->price) . '">';
297
+        }
298
+        print '</td></tr>';
299
+
300
+        // Price minimum
301
+        print '<tr><td>';
302
+        $text = $langs->trans('MinPrice');
303
+        print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
304
+        if ($object->price_base_type == 'TTC') {
305
+            print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
306
+        } else {
307
+            print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
308
+        }
309
+        print '</td></tr>';
310
+
311
+        // Update all child soc
312
+        print '<tr><td width="15%">';
313
+        print $langs->trans('ForceUpdateChildPriceSoc');
314
+        print '</td>';
315
+        print '<td>';
316
+        print '<input type="checkbox" name="updatechildprice" value="1"/>';
317
+        print '</td>';
318
+        print '</tr>';
319
+
320
+        print '</table>';
321
+
322
+        print '<br><div align="center">';
323
+        print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
324
+        print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
325
+        print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
326
+        print '</div>';
327
+
328
+        print '<br></form>';
329
+    } elseif ($action == 'edit_customer_price') {
330
+
331
+        // Edit mode
332
+
333
+        print load_fiche_titre($langs->trans('PriceByCustomer'));
334
+
335
+        $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
336
+        if ($result < 0)
337
+        {
338
+            setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
339
+        }
340
+
341
+        print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
342
+        print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
343
+        print '<input type="hidden" name="action" value="update_customer_price_confirm">';
344
+        print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
345
+        print '<table class="border" width="100%">';
346
+        print '<tr>';
347
+        print '<td>' . $langs->trans('Product') . '</td>';
348
+        $staticprod = new Product($db);
349
+        $staticprod->fetch($prodcustprice->fk_product);
350
+        print "<td>" . $staticprod->getNomUrl(1) . "</td>";
351
+        print '</tr>';
352
+
353
+        // VAT
354
+        print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
355
+        print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
356
+        print '</td></tr>';
357
+
358
+        // Price base
359
+        print '<tr><td width="15%">';
360
+        print $langs->trans('PriceBase');
361
+        print '</td>';
362
+        print '<td>';
363
+        print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
364
+        print '</td>';
365
+        print '</tr>';
366
+
367
+        // Price
368
+        print '<tr><td width="20%">';
369
+        $text = $langs->trans('SellingPrice');
370
+        print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
371
+        print '</td><td>';
372
+        if ($prodcustprice->price_base_type == 'TTC') {
373
+            print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">';
374
+        } else {
375
+            print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
376
+        }
377
+        print '</td></tr>';
378
+
379
+        // Price minimum
380
+        print '<tr><td>';
381
+        $text = $langs->trans('MinPrice');
382
+        print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
383
+        print '</td><td>';
384
+        if ($prodcustprice->price_base_type == 'TTC') {
385
+            print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
386
+        } else {
387
+            print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
388
+        }
389
+        print '</td></tr>';
390
+
391
+        // Update all child soc
392
+        print '<tr><td width="15%">';
393
+        print $langs->trans('ForceUpdateChildPriceSoc');
394
+        print '</td>';
395
+        print '<td>';
396
+        print '<input type="checkbox" name="updatechildprice" value="1">';
397
+        print '</td>';
398
+        print '</tr>';
399
+
400
+        print '</table>';
401
+
402
+        print '<br><div class="center">';
403
+        print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
404
+        print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
405
+        print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
406
+        print '</div>';
407
+
408
+        print '<br></form>';
409
+    } elseif ($action == 'showlog_customer_price') {
410
+
411
+        print '<!-- showlog_customer_price -->'."\n";
412
+
413
+        $filter = array (
414
+            't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
415
+        );
416
+
417
+        // Count total nb of records
418
+        $nbtotalofrecords = '';
419
+        if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
420
+            $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
421
+        }
422
+
423
+        $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
424
+        if ($result < 0)
425
+        {
426
+            setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
427
+        }
428
+
429
+        $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
430
+
431
+        print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
432
+
433
+        if (count($prodcustprice->lines) > 0) {
434
+
435
+            print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
436
+            print '<input type="hidden" name="id" value="' . $object->id . '">';
437
+
438
+            print '<table class="noborder" width="100%">';
439
+
440
+            print '<tr class="liste_titre">';
441
+            print '<td>' . $langs->trans("Product") . '</td>';
442
+            print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
443
+            print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
444
+            print '<td align="right">' . $langs->trans("VAT") . '</td>';
445
+            print '<td align="right">' . $langs->trans("HT") . '</td>';
446
+            print '<td align="right">' . $langs->trans("TTC") . '</td>';
447
+            print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
448
+            print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
449
+            print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
450
+            print '<td>&nbsp;</td>';
451
+            print '</tr>';
452
+
453
+            foreach ( $prodcustprice->lines as $line ) {
454
+
455
+                print '<tr class="oddeven">';
456
+                $staticprod = new Product($db);
457
+                $staticprod->fetch($line->fk_product);
458
+
459
+                print "<td>" . $staticprod->getNomUrl(1) . "</td>";
460
+                print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
461
+
462
+                print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
463
+                print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
464
+                print '<td align="right">' . price($line->price) . "</td>";
465
+                print '<td align="right">' . price($line->price_ttc) . "</td>";
466
+                print '<td align="right">' . price($line->price_min) . '</td>';
467
+                print '<td align="right">' . price($line->price_min_ttc) . '</td>';
468
+
469
+                // User
470
+                $userstatic = new User($db);
471
+                $userstatic->fetch($line->fk_user);
472
+                print '<td align="right">';
473
+                print $userstatic->getLoginUrl(1);
474
+                print '</td>';
475
+            }
476
+            print "</table>";
477
+        }
478
+        else
479
+        {
480
+            print $langs->trans('None');
481
+        }
482
+
483
+        print "\n" . '<div class="tabsAction">' . "\n";
484
+        print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
485
+        print "\n</div><br>\n";
486
+    }
487
+    else
488
+    {
489 489
         // View mode
490 490
 
491
-		/* ************************************************************************** */
492
-		/*                                                                            */
493
-		/* Barre d'action                                                             */
494
-		/*                                                                            */
495
-		/* ************************************************************************** */
491
+        /* ************************************************************************** */
492
+        /*                                                                            */
493
+        /* Barre d'action                                                             */
494
+        /*                                                                            */
495
+        /* ************************************************************************** */
496 496
 
497
-		print "\n" . '<div class="tabsAction">' . "\n";
497
+        print "\n" . '<div class="tabsAction">' . "\n";
498 498
 
499
-		if ($user->rights->produit->creer || $user->rights->service->creer) {
500
-			print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
501
-		}
502
-		print "\n</div>\n";
499
+        if ($user->rights->produit->creer || $user->rights->service->creer) {
500
+            print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
501
+        }
502
+        print "\n</div>\n";
503 503
 
504 504
 
505 505
         // Count total nb of records
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 
518 518
         $option = '&search_prod=' . $search_prod . '&id=' . $object->id;
519 519
 
520
-	    print '<!-- view specific price for each product -->'."\n";
520
+        print '<!-- view specific price for each product -->'."\n";
521 521
 
522
-	    print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
522
+        print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
523 523
 
524 524
         print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
525 525
         print '<input type="hidden" name="id" value="' . $object->id . '">';
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         if (count($prodcustprice->lines) > 0 || $search_prod)
543 543
         {
544 544
             print '<tr class="liste_titre">';
545
-			print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
545
+            print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
546 546
             print '<td class="liste_titre" colspan="8">&nbsp;</td>';
547 547
             // Print the search button
548 548
             print '<td class="liste_titre" align="right">';
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         print "</table>";
610 610
 
611 611
         print "</form>";
612
-	}
612
+    }
613 613
 }
614 614
 
615 615
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/contact.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 
71 71
 if ($action == 'view' && $object->fetch($socid)<=0)
72 72
 {
73
-	$langs->load("errors");
74
-	print($langs->trans('ErrorRecordNotFound'));
75
-	exit;
73
+    $langs->load("errors");
74
+    print($langs->trans('ErrorRecordNotFound'));
75
+    exit;
76 76
 }
77 77
 
78 78
 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
 if (empty($reshook))
104 104
 {
105
-	if ($cancel)
105
+    if ($cancel)
106 106
     {
107 107
         $action='';
108 108
         if (! empty($backtopage))
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 if ($socid > 0 && empty($object->id))
130 130
 {
131 131
     $result=$object->fetch($socid);
132
-	if ($result <= 0) dol_print_error('',$object->error);
132
+    if ($result <= 0) dol_print_error('',$object->error);
133 133
 }
134 134
 
135 135
 $title=$langs->trans("ThirdParty");
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 
159 159
 if ($action != 'presend')
160 160
 {
161
-	// Contacts list
162
-	if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
163
-	{
164
-		$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
165
-	}
166
-
167
-	// Addresses list
168
-	if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
169
-	{
170
-		$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
171
-	}
161
+    // Contacts list
162
+    if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
163
+    {
164
+        $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
165
+    }
166
+
167
+    // Addresses list
168
+    if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
169
+    {
170
+        $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
171
+    }
172 172
 }
173 173
 
174 174
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_login.class.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -31,110 +31,110 @@
 block discarded – undo
31 31
      */
32 32
     function __construct()
33 33
     {
34
-		global $db;
35
-		$this->db = $db;
36
-	}
37
-
38
-	/**
39
-	 * Login
40
-	 *
41
-	 * Request the API token for a couple username / password.
42
-	 * Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file).
43
-	 * Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "DOLAPIKEY" into field at the top right of page. Note: The API key (DOLAPIKEY) can be found/set on the user page.
44
-	 *
45
-	 * @param   string  $login			User login
46
-	 * @param   string  $password		User password
47
-	 * @param   string  $entity			Entity (when multicompany module is used). '' means 1=first company.
48
-	 * @param   int     $reset          Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
34
+        global $db;
35
+        $this->db = $db;
36
+    }
37
+
38
+    /**
39
+     * Login
40
+     *
41
+     * Request the API token for a couple username / password.
42
+     * Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file).
43
+     * Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "DOLAPIKEY" into field at the top right of page. Note: The API key (DOLAPIKEY) can be found/set on the user page.
44
+     *
45
+     * @param   string  $login			User login
46
+     * @param   string  $password		User password
47
+     * @param   string  $entity			Entity (when multicompany module is used). '' means 1=first company.
48
+     * @param   int     $reset          Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
49 49
      * @return  array                   Response status and user token
50 50
      *
51
-	 * @throws 200
52
-	 * @throws 403
53
-	 * @throws 500
54
-	 *
55
-	 * @url GET /
56
-	 * @url POST /
57
-	 */
51
+     * @throws 200
52
+     * @throws 403
53
+     * @throws 500
54
+     *
55
+     * @url GET /
56
+     * @url POST /
57
+     */
58 58
     public function index($login, $password, $entity='', $reset=0)
59 59
     {
60 60
 
61
-	    global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
62
-
63
-		// Authentication mode
64
-		if (empty($dolibarr_main_authentication))
65
-			$dolibarr_main_authentication = 'http,dolibarr';
66
-		// Authentication mode: forceuser
67
-		if ($dolibarr_main_authentication == 'forceuser')
68
-		{
69
-			if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
70
-			if ($dolibarr_auto_user != $login)
71
-			{
72
-				dol_syslog("Warning: your instance is set to use the automatic forced login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
73
-				throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
74
-			}
75
-		}
76
-		// Set authmode
77
-		$authmode = explode(',', $dolibarr_main_authentication);
78
-
79
-		if ($entity != '' && ! is_numeric($entity))
80
-		{
81
-			throw new RestException(403, "Bad value for entity, must be the numeric ID of company.");
82
-		}
83
-		if ($entity == '') $entity=1;
84
-
85
-		include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
86
-		$login = checkLoginPassEntity($login, $password, $entity, $authmode);
87
-		if (empty($login))
88
-		{
89
-			throw new RestException(403, 'Access denied');
90
-		}
91
-
92
-		$token = 'failedtogenerateorgettoken';
93
-
94
-		$tmpuser=new User($this->db);
95
-		$tmpuser->fetch(0, $login, 0, 0, $entity);
96
-		if (empty($tmpuser->id))
97
-		{
98
-			throw new RestException(500, 'Failed to load user');
99
-		}
100
-
101
-		// Renew the hash
102
-		if (empty($tmpuser->api_key) || $reset)
103
-		{
104
-			$tmpuser->getrights();
105
-			if (empty($tmpuser->rights->user->self->creer))
106
-			{
107
-				throw new RestException(403, 'User need write permission on itself to reset its API token');
108
-			}
109
-
110
-    		// Generate token for user
111
-    		$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
112
-
113
-    		// We store API token into database
114
-    		$sql = "UPDATE ".MAIN_DB_PREFIX."user";
115
-    		$sql.= " SET api_key = '".$this->db->escape($token)."'";
116
-    		$sql.= " WHERE login = '".$this->db->escape($login)."'";
117
-
118
-    		dol_syslog(get_class($this)."::login", LOG_DEBUG);	// No log
119
-    		$result = $this->db->query($sql);
120
-    		if (!$result)
121
-    		{
122
-    			throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror());
123
-    		}
124
-		}
125
-		else
126
-		{
61
+        global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
62
+
63
+        // Authentication mode
64
+        if (empty($dolibarr_main_authentication))
65
+            $dolibarr_main_authentication = 'http,dolibarr';
66
+        // Authentication mode: forceuser
67
+        if ($dolibarr_main_authentication == 'forceuser')
68
+        {
69
+            if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
70
+            if ($dolibarr_auto_user != $login)
71
+            {
72
+                dol_syslog("Warning: your instance is set to use the automatic forced login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
73
+                throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
74
+            }
75
+        }
76
+        // Set authmode
77
+        $authmode = explode(',', $dolibarr_main_authentication);
78
+
79
+        if ($entity != '' && ! is_numeric($entity))
80
+        {
81
+            throw new RestException(403, "Bad value for entity, must be the numeric ID of company.");
82
+        }
83
+        if ($entity == '') $entity=1;
84
+
85
+        include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
86
+        $login = checkLoginPassEntity($login, $password, $entity, $authmode);
87
+        if (empty($login))
88
+        {
89
+            throw new RestException(403, 'Access denied');
90
+        }
91
+
92
+        $token = 'failedtogenerateorgettoken';
93
+
94
+        $tmpuser=new User($this->db);
95
+        $tmpuser->fetch(0, $login, 0, 0, $entity);
96
+        if (empty($tmpuser->id))
97
+        {
98
+            throw new RestException(500, 'Failed to load user');
99
+        }
100
+
101
+        // Renew the hash
102
+        if (empty($tmpuser->api_key) || $reset)
103
+        {
104
+            $tmpuser->getrights();
105
+            if (empty($tmpuser->rights->user->self->creer))
106
+            {
107
+                throw new RestException(403, 'User need write permission on itself to reset its API token');
108
+            }
109
+
110
+            // Generate token for user
111
+            $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
112
+
113
+            // We store API token into database
114
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user";
115
+            $sql.= " SET api_key = '".$this->db->escape($token)."'";
116
+            $sql.= " WHERE login = '".$this->db->escape($login)."'";
117
+
118
+            dol_syslog(get_class($this)."::login", LOG_DEBUG);	// No log
119
+            $result = $this->db->query($sql);
120
+            if (!$result)
121
+            {
122
+                throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror());
123
+            }
124
+        }
125
+        else
126
+        {
127 127
             $token = $tmpuser->api_key;
128
-		}
129
-
130
-		//return token
131
-		return array(
132
-			'success' => array(
133
-				'code' => 200,
134
-				'token' => $token,
135
-			    'entity' => $tmpuser->entity,
136
-			    'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
137
-			)
138
-		);
139
-	}
128
+        }
129
+
130
+        //return token
131
+        return array(
132
+            'success' => array(
133
+                'code' => 200,
134
+                'token' => $token,
135
+                'entity' => $tmpuser->entity,
136
+                'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
137
+            )
138
+        );
139
+    }
140 140
 }
Please login to merge, or discard this patch.