Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/htdocs/societe/checkvat/checkVatPopup.php 3 patches
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.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@  discard block
 block discarded – undo
28 28
 $langs->load("companies");
29 29
 
30 30
 //http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
31
-$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
31
+$WS_DOL_URL = 'http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
32 32
 //$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl';
33
-$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
34
-$WS_METHOD ='checkVat';
33
+$WS_DOL_URL_WSDL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
34
+$WS_METHOD = 'checkVat';
35 35
 
36 36
 
37 37
 
38
-$conf->dol_hide_topmenu=1;
39
-$conf->dol_hide_leftmenu=1;
38
+$conf->dol_hide_topmenu = 1;
39
+$conf->dol_hide_leftmenu = 1;
40 40
 
41 41
 llxHeader('', $langs->trans("VATIntraCheckableOnEUSite"));
42 42
 
43 43
 print '<div>';
44 44
 print '<div>';
45 45
 
46
-print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"),'','title_setup');
46
+print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup');
47 47
 
48
-$vatNumber = GETPOST("vatNumber",'alpha');
48
+$vatNumber = GETPOST("vatNumber", 'alpha');
49 49
 
50
-if (! $vatNumber)
50
+if (!$vatNumber)
51 51
 {
52 52
 	print '<br>';
53
-	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>';
53
+	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>';
54 54
 }
55 55
 else
56 56
 {
57 57
 	$vatNumber = preg_replace('/\^\w/', '', $vatNumber);
58
-	$countryCode=substr($vatNumber,0,2);
59
-	$vatNumber=substr($vatNumber,2);
58
+	$countryCode = substr($vatNumber, 0, 2);
59
+	$vatNumber = substr($vatNumber, 2);
60 60
 
61 61
 	print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>';
62 62
 	print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>';
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	// Set the WebService URL
70 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
-    $params=getSoapParams();
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']);
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 76
 	$soapclient->soap_defencoding = 'utf-8';
77 77
 	$soapclient->xml_encoding = 'utf-8';
78 78
 	$soapclient->decode_utf8 = false;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 	// Call the WebService and store its result in $result.
88 88
 	dol_syslog("Call method ".$WS_METHOD);
89
-	$result = $soapclient->call($WS_METHOD,$parameters);
89
+	$result = $soapclient->call($WS_METHOD, $parameters);
90 90
 
91 91
 	//var_dump($parameters);
92 92
 	//var_dump($soapclient);
@@ -95,33 +95,33 @@  discard block
 block discarded – undo
95 95
 	//print $soapclient->request.'<br>';
96 96
 	//print $soapclient->response.'<br>';
97 97
 
98
-	$messagetoshow='';
98
+	$messagetoshow = '';
99 99
 	print '<b>'.$langs->trans("Response").'</b>:<br>';
100 100
 
101 101
 	// Service indisponible
102
-	if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring']))
102
+	if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring']))
103 103
 	{
104 104
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
105
-		$messagetoshow=$soapclient->response;
105
+		$messagetoshow = $soapclient->response;
106 106
 	}
107
-	elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
107
+	elseif (preg_match('/TIMEOUT/i', $result['faultstring']))
108 108
 	{
109 109
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
110
-		$messagetoshow=$soapclient->response;
110
+		$messagetoshow = $soapclient->response;
111 111
 	}
112
-	elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
112
+	elseif (preg_match('/SERVER_BUSY/i', $result['faultstring']))
113 113
 	{
114 114
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
115
-		$messagetoshow=$soapclient->response;
115
+		$messagetoshow = $soapclient->response;
116 116
 	}
117 117
 	elseif ($result['faultstring'])
118 118
 	{
119 119
 		print '<font class="error">'.$langs->trans("Error").'</font><br>';
120
-		$messagetoshow=$result['faultstring'];
120
+		$messagetoshow = $result['faultstring'];
121 121
 	}
122 122
 	// Syntaxe ko
123
-	elseif (preg_match('/INVALID_INPUT/i',$result['faultstring'])
124
-	|| ($result['requestDate'] && ! $result['valid']))
123
+	elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
124
+	|| ($result['requestDate'] && !$result['valid']))
125 125
 	{
126 126
 		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
127 127
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
135 135
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
136 136
 		print $langs->trans("ValueIsValid").': ';
137
-		if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring']))
137
+		if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring']))
138 138
 		{
139
-			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>';
139
+			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>';
140 140
 		}
141 141
 		else
142 142
 		{
143
-			if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true'))
143
+			if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true'))
144 144
 			{
145 145
 				print '<font class="ok">'.$langs->trans("Yes").'</font>';
146 146
 				print '<br>';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 }
164 164
 
165 165
 print '<br>';
166
-print $langs->trans("VATIntraManualCheck",$langs->trans("VATIntraCheckURL"),$langs->trans("VATIntraCheckURL")).'<br>';
166
+print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $langs->trans("VATIntraCheckURL")).'<br>';
167 167
 print '<br>';
168 168
 print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>';
169 169
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -16 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@  discard block
 block discarded – undo
51 51
 {
52 52
 	print '<br>';
53 53
 	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>';
54
-}
55
-else
54
+} else
56 55
 {
57 56
 	$vatNumber = preg_replace('/\^\w/', '', $vatNumber);
58 57
 	$countryCode=substr($vatNumber,0,2);
@@ -103,18 +102,15 @@  discard block
 block discarded – undo
103 102
 	{
104 103
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
105 104
 		$messagetoshow=$soapclient->response;
106
-	}
107
-	elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
105
+	} elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
108 106
 	{
109 107
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
110 108
 		$messagetoshow=$soapclient->response;
111
-	}
112
-	elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
109
+	} elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
113 110
 	{
114 111
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
115 112
 		$messagetoshow=$soapclient->response;
116
-	}
117
-	elseif ($result['faultstring'])
113
+	} elseif ($result['faultstring'])
118 114
 	{
119 115
 		print '<font class="error">'.$langs->trans("Error").'</font><br>';
120 116
 		$messagetoshow=$result['faultstring'];
@@ -123,22 +119,24 @@  discard block
 block discarded – undo
123 119
 	elseif (preg_match('/INVALID_INPUT/i',$result['faultstring'])
124 120
 	|| ($result['requestDate'] && ! $result['valid']))
125 121
 	{
126
-		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
122
+		if ($result['requestDate']) {
123
+		    print $langs->trans("Date").': '.$result['requestDate'].'<br>';
124
+		}
127 125
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
128 126
 		print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
129 127
 		//$messagetoshow=$soapclient->response;
130
-	}
131
-	else
128
+	} else
132 129
 	{
133 130
 		// Syntaxe ok
134
-		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
131
+		if ($result['requestDate']) {
132
+		    print $langs->trans("Date").': '.$result['requestDate'].'<br>';
133
+		}
135 134
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
136 135
 		print $langs->trans("ValueIsValid").': ';
137 136
 		if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring']))
138 137
 		{
139 138
 			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>';
140
-		}
141
-		else
139
+		} else
142 140
 		{
143 141
 			if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true'))
144 142
 			{
@@ -146,8 +144,7 @@  discard block
 block discarded – undo
146 144
 				print '<br>';
147 145
 				print $langs->trans("Name").': '.$result['name'].'<br>';
148 146
 				print $langs->trans("Address").': '.$result['address'].'<br>';
149
-			}
150
-			else
147
+			} else
151 148
 			{
152 149
 				print '<font class="error">'.$langs->trans("No").'</font>';
153 150
 				print '<br>'."\n";
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/paymentmodes.php 3 patches
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.
Spacing   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
40 40
 require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
41 41
 
42
-$langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe','withdrawals'));
42
+$langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals'));
43 43
 
44 44
 
45 45
 // Security check
46
-$socid = GETPOST("socid","int");
47
-if ($user->societe_id) $socid=$user->societe_id;
48
-$result = restrictedArea($user, 'societe','','');
46
+$socid = GETPOST("socid", "int");
47
+if ($user->societe_id) $socid = $user->societe_id;
48
+$result = restrictedArea($user, 'societe', '', '');
49 49
 
50
-$id=GETPOST("id","int");
51
-$source=GETPOST("source","alpha");
52
-$ribid=GETPOST("ribid","int");
53
-$action=GETPOST("action", 'alpha', 3);
54
-$cancel=GETPOST('cancel', 'alpha');
50
+$id = GETPOST("id", "int");
51
+$source = GETPOST("source", "alpha");
52
+$ribid = GETPOST("ribid", "int");
53
+$action = GETPOST("action", 'alpha', 3);
54
+$cancel = GETPOST('cancel', 'alpha');
55 55
 
56 56
 $object = new Societe($db);
57 57
 $object->fetch($socid);
@@ -63,25 +63,25 @@  discard block
 block discarded – undo
63 63
 $extrafields = new ExtraFields($db);
64 64
 
65 65
 // fetch optionals attributes and labels
66
-$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
66
+$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
67 67
 
68 68
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
69
-$hookmanager->initHooks(array('thirdpartybancard','globalcard'));
69
+$hookmanager->initHooks(array('thirdpartybancard', 'globalcard'));
70 70
 
71 71
 
72
-if (! empty($conf->stripe->enabled))
72
+if (!empty($conf->stripe->enabled))
73 73
 {
74 74
 	$service = 'StripeTest';
75 75
 	$servicestatus = 0;
76
-	if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
76
+	if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha'))
77 77
 	{
78 78
 		$service = 'StripeLive';
79 79
 		$servicestatus = 1;
80 80
 	}
81 81
 
82 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)
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,19 +92,19 @@  discard block
 block discarded – undo
92 92
 
93 93
 if ($cancel)
94 94
 {
95
-	$action='';
95
+	$action = '';
96 96
 }
97 97
 
98
-$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
99
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
98
+$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
99
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
100 100
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
101 101
 
102 102
 if (empty($reshook))
103 103
 {
104 104
 	if ($cancel)
105 105
 	{
106
-		$action='';
107
-		if (! empty($backtopage))
106
+		$action = '';
107
+		if (!empty($backtopage))
108 108
 		{
109 109
 			header("Location: ".$backtopage);
110 110
 			exit;
@@ -114,49 +114,49 @@  discard block
 block discarded – undo
114 114
 	if ($action == 'update')
115 115
 	{
116 116
 		// Modification
117
-		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
117
+		if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha'))
118 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';
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 122
 			$error++;
123 123
 		}
124 124
 		if ($companybankaccount->needIBAN() == 1)
125 125
 		{
126
-			if (! GETPOST('iban'))
126
+			if (!GETPOST('iban'))
127 127
 			{
128 128
 				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
129
-				$action='edit';
129
+				$action = 'edit';
130 130
 				$error++;
131 131
 			}
132
-			if (! GETPOST('bic'))
132
+			if (!GETPOST('bic'))
133 133
 			{
134 134
 				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
135
-				$action='edit';
135
+				$action = 'edit';
136 136
 				$error++;
137 137
 			}
138 138
 		}
139 139
 
140 140
 		$companybankaccount->fetch($id);
141
-		if (! $error)
141
+		if (!$error)
142 142
 		{
143 143
 			$companybankaccount->socid           = $object->id;
144 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');
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 160
 			if (empty($companybankaccount->rum))
161 161
 			{
162 162
 				$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			}
165 165
 
166 166
 			$result = $companybankaccount->update($user);
167
-			if (! $result)
167
+			if (!$result)
168 168
 			{
169 169
 				setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
170 170
 			}
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 				// If this account is the default bank account, we disable others
174 174
 				if ($companybankaccount->default_rib)
175 175
 				{
176
-					$companybankaccount->setAsDefault($id);	// This will make sure there is only one default rib
176
+					$companybankaccount->setAsDefault($id); // This will make sure there is only one default rib
177 177
 				}
178 178
 
179
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
179
+				$url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
180 180
 				header('Location: '.$url);
181 181
 				exit;
182 182
 			}
@@ -186,36 +186,36 @@  discard block
 block discarded – undo
186 186
 	if ($action == 'updatecard')
187 187
 	{
188 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'))
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 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';
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 197
 			$error++;
198 198
 		}
199 199
 
200 200
 		$companypaymentmode->fetch($id);
201
-		if (! $error)
201
+		if (!$error)
202 202
 		{
203 203
 			$companypaymentmode->fk_soc          = $object->id;
204 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');
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 213
 			$companypaymentmode->country_code    = $object->country_code;
214 214
 
215
-			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
215
+			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
216 216
 
217 217
 			$result = $companypaymentmode->update($user);
218
-			if (! $result)
218
+			if (!$result)
219 219
 			{
220 220
 				setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
221 221
 			}
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 				// If this account is the default bank account, we disable others
225 225
 				if ($companypaymentmode->default_rib)
226 226
 				{
227
-					$companypaymentmode->setAsDefault($id);	// This will make sure there is only one default rib
227
+					$companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib
228 228
 				}
229 229
 
230
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
230
+				$url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
231 231
 				header('Location: '.$url);
232 232
 				exit;
233 233
 			}
@@ -236,39 +236,39 @@  discard block
 block discarded – undo
236 236
 
237 237
 	if ($action == 'add')
238 238
 	{
239
-		$error=0;
239
+		$error = 0;
240 240
 
241
-		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
241
+		if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha'))
242 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';
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 246
 			$error++;
247 247
 		}
248 248
 
249
-		if (! $error)
249
+		if (!$error)
250 250
 		{
251 251
 			// Ajout
252 252
 			$companybankaccount = new CompanyBankAccount($db);
253 253
 
254 254
 			$companybankaccount->socid           = $object->id;
255 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');
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 269
 			$companybankaccount->frstrecur       = GETPOST('frstrecur');
270
-			$companybankaccount->rum             = GETPOST('rum','alpha');
271
-			$companybankaccount->datec			 = dol_now();
270
+			$companybankaccount->rum             = GETPOST('rum', 'alpha');
271
+			$companybankaccount->datec = dol_now();
272 272
 			$companybankaccount->status          = 1;
273 273
 
274 274
 			$db->begin();
@@ -276,28 +276,28 @@  discard block
 block discarded – undo
276 276
 			// This test can be done only once properties were set
277 277
 			if ($companybankaccount->needIBAN() == 1)
278 278
 			{
279
-				if (! GETPOST('iban'))
279
+				if (!GETPOST('iban'))
280 280
 				{
281 281
 					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
282
-					$action='create';
282
+					$action = 'create';
283 283
 					$error++;
284 284
 				}
285
-				if (! GETPOST('bic'))
285
+				if (!GETPOST('bic'))
286 286
 				{
287 287
 					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
288
-					$action='create';
288
+					$action = 'create';
289 289
 					$error++;
290 290
 				}
291 291
 			}
292 292
 
293
-			if (! $error)
293
+			if (!$error)
294 294
 			{
295 295
 				$result = $companybankaccount->create($user);
296 296
 				if ($result < 0)
297 297
 				{
298 298
 					$error++;
299 299
 					setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
300
-					$action='create';     // Force chargement page création
300
+					$action = 'create'; // Force chargement page création
301 301
 				}
302 302
 
303 303
 				if (empty($companybankaccount->rum))
@@ -307,22 +307,22 @@  discard block
 block discarded – undo
307 307
 				}
308 308
 			}
309 309
 
310
-			if (! $error)
310
+			if (!$error)
311 311
 			{
312
-				$result = $companybankaccount->update($user);	// This will set the UMR number.
312
+				$result = $companybankaccount->update($user); // This will set the UMR number.
313 313
 				if ($result < 0)
314 314
 				{
315 315
 					$error++;
316 316
 					setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
317
-					$action='create';
317
+					$action = 'create';
318 318
 				}
319 319
 			}
320 320
 
321
-			if (! $error)
321
+			if (!$error)
322 322
 			{
323 323
 				$db->commit();
324 324
 
325
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
325
+				$url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
326 326
 				header('Location: '.$url);
327 327
 				exit;
328 328
 			}
@@ -335,59 +335,59 @@  discard block
 block discarded – undo
335 335
 
336 336
 	if ($action == 'addcard')
337 337
 	{
338
-		$error=0;
338
+		$error = 0;
339 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'))
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 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';
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 348
 			$error++;
349 349
 		}
350 350
 
351
-		if (! $error)
351
+		if (!$error)
352 352
 		{
353 353
 			// Ajout
354 354
 			$companypaymentmode = new CompanyPaymentMode($db);
355 355
 
356 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');
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 365
 			$companypaymentmode->datec           = dol_now();
366 366
 			$companypaymentmode->default_rib     = 0;
367 367
 			$companypaymentmode->type            = 'card';
368 368
 			$companypaymentmode->country_code    = $object->country_code;
369 369
 			$companypaymentmode->status          = $servicestatus;
370 370
 
371
-			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
371
+			$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
372 372
 
373 373
 			$db->begin();
374 374
 
375
-			if (! $error)
375
+			if (!$error)
376 376
 			{
377 377
 				$result = $companypaymentmode->create($user);
378 378
 				if ($result < 0)
379 379
 				{
380 380
 					$error++;
381 381
 					setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
382
-					$action='createcard';     // Force chargement page création
382
+					$action = 'createcard'; // Force chargement page création
383 383
 				}
384 384
 			}
385 385
 
386
-			if (! $error)
386
+			if (!$error)
387 387
 			{
388 388
 				$db->commit();
389 389
 
390
-				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
390
+				$url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
391 391
 				header('Location: '.$url);
392 392
 				exit;
393 393
 			}
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 		}
399 399
 	}
400 400
 
401
-	if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0)
401
+	if ($action == 'setasbankdefault' && GETPOST('ribid', 'int') > 0)
402 402
 	{
403 403
 		$companybankaccount = new CompanyBankAccount($db);
404
-		$res = $companybankaccount->setAsDefault(GETPOST('ribid','int'));
404
+		$res = $companybankaccount->setAsDefault(GETPOST('ribid', 'int'));
405 405
 		if ($res)
406 406
 		{
407
-			$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
407
+			$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
408 408
 			header('Location: '.$url);
409 409
 			exit;
410 410
 		}
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
 		}
415 415
 	}
416 416
 
417
-	if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes')
417
+	if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes')
418 418
 	{
419 419
 		$companypaymentmode = new CompanyPaymentMode($db);
420
-		if ($companypaymentmode->fetch($ribid?$ribid:$id))
420
+		if ($companypaymentmode->fetch($ribid ? $ribid : $id))
421 421
 		{
422 422
 			$result = $companypaymentmode->delete($user);
423 423
 			if ($result > 0)
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
 			setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
437 437
 		}
438 438
 	}
439
-	if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes')
439
+	if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes')
440 440
 	{
441 441
 		$companybankaccount = new CompanyBankAccount($db);
442
-		if ($companybankaccount->fetch($ribid?$ribid:$id))
442
+		if ($companybankaccount->fetch($ribid ? $ribid : $id))
443 443
 		{
444 444
 			$result = $companybankaccount->delete($user);
445 445
 			if ($result > 0)
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 		}
460 460
 	}
461 461
 
462
-	$savid=$id;
462
+	$savid = $id;
463 463
 
464 464
 	// Actions to build doc
465 465
 	if ($action == 'builddocrib')
@@ -469,19 +469,19 @@  discard block
 block discarded – undo
469 469
 			'use_companybankid'=>GETPOST('companybankid'),
470 470
 			'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
471 471
 		);
472
-		$_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha');
473
-		$_POST['model'] =  GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha');
472
+		$_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha');
473
+		$_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha');
474 474
 	}
475 475
 
476 476
 	$id = $socid;
477 477
 	$upload_dir = $conf->societe->multidir_output[$object->entity];
478
-	$permissioncreate=$user->rights->societe->creer;
478
+	$permissioncreate = $user->rights->societe->creer;
479 479
 	include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
480 480
 
481 481
 	$id = $savid;
482 482
 
483 483
 	// Action for stripe
484
-	if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
484
+	if (!empty($conf->stripe->enabled) && class_exists('Stripe'))
485 485
 	{
486 486
 		if ($action == 'synccustomertostripe')
487 487
 		{
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 			{
495 495
 				// Creation of Stripe customer + update of societe_account
496 496
 				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
497
-				if (! $cu)
497
+				if (!$cu)
498 498
 				{
499 499
 					$error++;
500 500
 					setEventMessages($stripe->error, $stripe->errors, 'errors');
@@ -519,17 +519,17 @@  discard block
 block discarded – undo
519 519
 			{
520 520
 				// Get the Stripe customer
521 521
 				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
522
-				if (! $cu)
522
+				if (!$cu)
523 523
 				{
524 524
 					$error++;
525 525
 					setEventMessages($stripe->error, $stripe->errors, 'errors');
526 526
 				}
527 527
 
528
-				if (! $error)
528
+				if (!$error)
529 529
 				{
530 530
 					// Creation of Stripe card + update of societe_account
531 531
 					$card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
532
-					if (! $card)
532
+					if (!$card)
533 533
 					{
534 534
 						$error++;
535 535
 						setEventMessages($stripe->error, $stripe->errors, 'errors');
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 			$db->begin();
552 552
 
553 553
                 if (empty($newcu)) {
554
-                        $sql  = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
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 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 !
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 561
 			$resql = $db->query($sql);
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 				}
577 577
 			}
578 578
 
579
-			if (! $error)
579
+			if (!$error)
580 580
 			{
581 581
 				$stripecu = $newcu;
582 582
 				$db->commit();
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
 			try {
592 592
 				$companypaymentmode->setAsDefault($id);
593 593
 
594
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
594
+				$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
595 595
 				header('Location: '.$url);
596 596
 				exit;
597 597
 			}
598
-			catch(Exception $e)
598
+			catch (Exception $e)
599 599
 			{
600 600
 				$error++;
601 601
 				setEventMessages($e->getMessage(), null, 'errors');
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 		elseif ($action == 'setassourcedefault')
605 605
 		{
606 606
 			try {
607
-				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
607
+				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
608 608
 				$cu->default_source = (string) $source;
609 609
 				$result = $cu->save();
610 610
 
611
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
611
+				$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
612 612
 				header('Location: '.$url);
613 613
 				exit;
614 614
 			}
615
-			catch(Exception $e)
615
+			catch (Exception $e)
616 616
 			{
617 617
 				$error++;
618 618
 				setEventMessages($e->getMessage(), null, 'errors');
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
 		elseif ($action == 'deletecard' && $source)
622 622
 		{
623 623
 			try {
624
-				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
625
-				$card=$cu->sources->retrieve("$source");
624
+				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
625
+				$card = $cu->sources->retrieve("$source");
626 626
 				if ($card)
627 627
 				{
628 628
 					// $card->detach();  Does not work with card_, only with src_
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
 					else $card->delete();
631 631
 				}
632 632
 
633
-				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
633
+				$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
634 634
 				header('Location: '.$url);
635 635
 				exit;
636 636
 			}
637
-			catch(Exception $e)
637
+			catch (Exception $e)
638 638
 			{
639 639
 				$error++;
640 640
 				setEventMessages($e->getMessage(), null, 'errors');
@@ -655,20 +655,20 @@  discard block
 block discarded – undo
655 655
 
656 656
 llxHeader();
657 657
 
658
-$head=societe_prepare_head($object);
658
+$head = societe_prepare_head($object);
659 659
 
660 660
 // Show sandbox warning
661 661
 /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')))		// We can force sand box with param 'forcesandbox'
662 662
 {
663 663
 	dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning');
664 664
 }*/
665
-if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')))
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
-if (! $id)
671
+if (!$id)
672 672
 {
673 673
 	$companybankaccount->fetch(0, $object->id);
674 674
 	$companypaymentmode->fetch(0, null, $object->id, 'card');
@@ -678,23 +678,23 @@  discard block
 block discarded – undo
678 678
 	$companybankaccount->fetch($id);
679 679
 	$companypaymentmode->fetch($id);
680 680
 }
681
-if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id;
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 685
 	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
686 686
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
687
-	$actionforadd='update';
688
-	if ($action == 'editcard') $actionforadd='updatecard';
687
+	$actionforadd = 'update';
688
+	if ($action == 'editcard') $actionforadd = 'updatecard';
689 689
 	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
690
-	print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
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 694
 	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
695 695
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
696
-	$actionforadd='add';
697
-	if ($action == 'createcard') $actionforadd='addcard';
696
+	$actionforadd = 'add';
697
+	if ($action == 'createcard') $actionforadd = 'addcard';
698 698
 	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
699 699
 }
700 700
 
@@ -707,20 +707,20 @@  discard block
 block discarded – undo
707 707
 	// Confirm delete ban
708 708
 	if ($action == 'delete')
709 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);
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 711
 	}
712 712
 	// Confirm delete card
713 713
 	if ($action == 'deletecard')
714 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);
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 716
 	}
717 717
 
718 718
 	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
719 719
 
720
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
720
+	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
721 721
 
722 722
 
723
-	if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
723
+	if (!empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
724 724
 	{
725 725
 		print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
726 726
 	}
@@ -740,19 +740,19 @@  discard block
 block discarded – undo
740 740
 		if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
741 741
 		print '</td></tr>';
742 742
 		$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
743
-		$resql=$db->query($sql);
743
+		$resql = $db->query($sql);
744 744
 		if (!$resql) dol_print_error($db);
745 745
 
746 746
 		$obj = $db->fetch_object($resql);
747 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');
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 753
 	}
754 754
 
755
-	if (! empty($conf->stripe->enabled))
755
+	if (!empty($conf->stripe->enabled))
756 756
 	{
757 757
 		$permissiontowrite = $user->rights->societe->creer;
758 758
 		// Stripe customer key 'cu_....' stored into llx_societe_account
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
 		print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
765 765
 		if ($stripecu && $action != 'editkey_account')
766 766
 		{
767
-			if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
768
-			$url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
767
+			if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/';
768
+			$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
769 769
 			if ($servicestatus)
770 770
 			{
771
-				$url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
771
+				$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
772 772
 			}
773 773
 			print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
774 774
 		}
@@ -794,34 +794,34 @@  discard block
 block discarded – undo
794 794
 	print '<br>';
795 795
 
796 796
 	// List of Stripe payment modes
797
-	if (! (empty($conf->stripe->enabled)))
797
+	if (!(empty($conf->stripe->enabled)))
798 798
 	{
799
-		$morehtmlright='';
800
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
799
+		$morehtmlright = '';
800
+		if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
801 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>';
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 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, '');
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 805
 
806 806
 		$listofsources = array();
807 807
 		if (is_object($stripe))
808 808
 		{
809 809
 			try {
810
-				$customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus);
810
+				$customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
811 811
 				if ($customerstripe->id) {
812
-					$listofsources=$customerstripe->sources->data;
812
+					$listofsources = $customerstripe->sources->data;
813 813
 				}
814 814
 			}
815
-			catch(Exception $e)
815
+			catch (Exception $e)
816 816
 			{
817 817
 				dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
818 818
 			}
819 819
 		}
820 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
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 822
 		print '<table class="liste" width="100%">'."\n";
823 823
 		print '<tr class="liste_titre">';
824
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
824
+		if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
825 825
 		{
826 826
 			print '<td>'.$langs->trans('LocalID').'</td>';
827 827
 		}
@@ -840,15 +840,15 @@  discard block
 block discarded – undo
840 840
 		$arrayofstripecard = array();
841 841
 
842 842
 		// Show local sources
843
-		if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
843
+		if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
844 844
 		{
845 845
 			//$societeaccount = new SocieteAccount($db);
846 846
 			$companypaymentmodetemp = new CompanyPaymentMode($db);
847 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;
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 852
 
853 853
 			$resql = $db->query($sql);
854 854
 			if ($resql)
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 				$num_rows = $db->num_rows($resql);
857 857
 				if ($num_rows)
858 858
 				{
859
-					$i=0;
859
+					$i = 0;
860 860
 					while ($i < $num_rows)
861 861
 					{
862 862
 						$nblocal++;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 						{
867 867
 							$companypaymentmodetemp->fetch($obj->rowid);
868 868
 
869
-							$arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref;
869
+							$arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
870 870
 
871 871
 							print '<tr>';
872 872
 							print '<td>';
@@ -893,21 +893,21 @@  discard block
 block discarded – undo
893 893
 							print '</td><td>';
894 894
 							if ($companypaymentmodetemp->country_code)
895 895
 							{
896
-								$img=picto_from_langcode($companypaymentmodetemp->country_code);
897
-								print $img?$img.' ':'';
898
-								print getCountry($companypaymentmodetemp->country_code,1);
896
+								$img = picto_from_langcode($companypaymentmodetemp->country_code);
897
+								print $img ? $img.' ' : '';
898
+								print getCountry($companypaymentmodetemp->country_code, 1);
899 899
 							}
900
-							else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
900
+							else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
901 901
 							print '</td>';
902 902
 							// Default
903 903
 							print '<td align="center">';
904 904
 							if (empty($companypaymentmodetemp->default_rib))
905 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');
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 908
 								print '</a>';
909 909
 							} else {
910
-								print img_picto($langs->trans("Default"),'on');
910
+								print img_picto($langs->trans("Default"), 'on');
911 911
 							}
912 912
 							print '</td>';
913 913
 							print '<td>';
@@ -925,11 +925,11 @@  discard block
 block discarded – undo
925 925
 									print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>';
926 926
 								}
927 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');
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 930
 								print '</a>';
931 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.'&
932
+								print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'&
933 933
 								print img_picto($langs->trans("Delete"), 'delete');
934 934
 								print '</a>';
935 935
 							}
@@ -948,90 +948,90 @@  discard block
 block discarded – undo
948 948
 		{
949 949
 			foreach ($listofsources as $src)
950 950
 			{
951
-				if (! empty($arrayofstripecard[$src->id])) continue;	// Already in previous list
951
+				if (!empty($arrayofstripecard[$src->id])) continue; // Already in previous list
952 952
 
953 953
 				$nbremote++;
954 954
 
955 955
 				print '<tr class="oddeven">';
956 956
 				// Local ID
957
-				if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
957
+				if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
958 958
 				{
959 959
 					print '<td>';
960 960
 					print '</td>';
961 961
 				}
962 962
 				// Src ID
963 963
 				print '<td>';
964
-				if (!empty($stripeacc)) $connect=$stripeacc.'/';
965
-				$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
964
+				if (!empty($stripeacc)) $connect = $stripeacc.'/';
965
+				$url = 'https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
966 966
 				if ($servicestatus)
967 967
 				{
968
-					$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
968
+					$url = 'https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
969 969
 				}
970 970
 				print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>";
971 971
 				print '</td>';
972 972
 				// Img of credit card
973 973
 				print '<td>';
974
-				if ($src->object=='card')
974
+				if ($src->object == 'card')
975 975
 				{
976 976
 					print img_credit_card($src->brand);
977 977
 				}
978
-				elseif ($src->object=='source' && $src->type=='card')
978
+				elseif ($src->object == 'source' && $src->type == 'card')
979 979
 				{
980 980
 					print img_credit_card($src->card->brand);
981 981
 				}
982
-				elseif ($src->object=='source' && $src->type=='sepa_debit')
982
+				elseif ($src->object == 'source' && $src->type == 'sepa_debit')
983 983
 				{
984 984
 					print '<span class="fa fa-university fa-2x fa-fw"></span>';
985 985
 				}
986 986
 				print'</td>';
987 987
 				print '<td valign="middle">';
988
-				if ($src->object=='card')
988
+				if ($src->object == 'card')
989 989
 				{
990 990
 					print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
991 991
 					print '</td><td>';
992 992
 					if ($src->country)
993 993
 					{
994
-						$img=picto_from_langcode($src->country);
995
-						print $img?$img.' ':'';
996
-						print getCountry($src->country,1);
994
+						$img = picto_from_langcode($src->country);
995
+						print $img ? $img.' ' : '';
996
+						print getCountry($src->country, 1);
997 997
 					}
998
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
998
+					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
999 999
 				}
1000
-				elseif ($src->object=='source' && $src->type=='card')
1000
+				elseif ($src->object == 'source' && $src->type == 'card')
1001 1001
 				{
1002 1002
 					print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1003 1003
 					print '</td><td>';
1004 1004
 
1005 1005
 				 	if ($src->card->country)
1006 1006
 					{
1007
-						$img=picto_from_langcode($src->card->country);
1008
-						print $img?$img.' ':'';
1009
-						print getCountry($src->card->country,1);
1007
+						$img = picto_from_langcode($src->card->country);
1008
+						print $img ? $img.' ' : '';
1009
+						print getCountry($src->card->country, 1);
1010 1010
 					}
1011
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1011
+					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1012 1012
 				}
1013
-				elseif ($src->object=='source' && $src->type=='sepa_debit')
1013
+				elseif ($src->object == 'source' && $src->type == 'sepa_debit')
1014 1014
 				{
1015 1015
 					print 'info sepa';
1016 1016
 					print '</td><td>';
1017 1017
 					if ($src->sepa_debit->country)
1018 1018
 					{
1019
-							$img=picto_from_langcode($src->sepa_debit->country);
1020
-							print $img?$img.' ':'';
1021
-							print getCountry($src->sepa_debit->country,1);
1019
+							$img = picto_from_langcode($src->sepa_debit->country);
1020
+							print $img ? $img.' ' : '';
1021
+							print getCountry($src->sepa_debit->country, 1);
1022 1022
 					}
1023
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1023
+					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1024 1024
 				}
1025 1025
 				print '</td>';
1026 1026
 				// Default
1027 1027
 				print '<td align="center" width="50">';
1028 1028
 				if (($customerstripe->default_source != $src->id))
1029 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');
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 1032
 					print '</a>';
1033 1033
 				} else {
1034
-					print img_picto($langs->trans("Default"),'on');
1034
+					print img_picto($langs->trans("Default"), 'on');
1035 1035
 				}
1036 1036
 				print '</td>';
1037 1037
 				print '<td>';
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 				print '<td align="right" class="nowraponall">';
1046 1046
 				if ($user->rights->societe->creer)
1047 1047
 				{
1048
-					print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">';
1048
+					print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">';
1049 1049
 					print img_picto($langs->trans("Delete"), 'delete');
1050 1050
 					print '</a>';
1051 1051
 				}
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
 	// List of bank accounts
1068 1068
 	print '<br>';
1069 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>';
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 1071
 
1072 1072
 	print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, '');
1073 1073
 
1074 1074
 	$rib_list = $object->get_all_rib();
1075 1075
 	if (is_array($rib_list))
1076 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
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 1078
 		print '<table class="liste" width="100%">';
1079 1079
 
1080 1080
 		print '<tr class="liste_titre">';
@@ -1083,14 +1083,14 @@  discard block
 block discarded – undo
1083 1083
 		print_liste_field_titre("RIB");
1084 1084
 		print_liste_field_titre("IBAN");
1085 1085
 		print_liste_field_titre("BIC");
1086
-		if (! empty($conf->prelevement->enabled))
1086
+		if (!empty($conf->prelevement->enabled))
1087 1087
 		{
1088 1088
 			print print_liste_field_titre("RUM");
1089 1089
 			print print_liste_field_titre("WithdrawMode");
1090 1090
 		}
1091 1091
 		print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"');
1092 1092
 		print_liste_field_titre('', '', '', '', '', 'align="center"');
1093
-		print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
1093
+		print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
1094 1094
 		print "</tr>\n";
1095 1095
 
1096 1096
 		foreach ($rib_list as $rib)
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 			print '<td>'.$rib->bank.'</td>';
1103 1103
 			// Account number
1104 1104
 			print '<td>';
1105
-			$string='';
1105
+			$string = '';
1106 1106
 			foreach ($rib->getFieldsToShow() as $val) {
1107 1107
 
1108 1108
 				if ($val == 'BankCode') {
@@ -1120,11 +1120,11 @@  discard block
 block discarded – undo
1120 1120
                     $string .= $rib->iban.' ';*/
1121 1121
 				}
1122 1122
 			}
1123
-			if (! empty($rib->label) && $rib->number) {
1124
-				if (! checkBanForAccount($rib)) {
1125
-					$string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning');
1123
+			if (!empty($rib->label) && $rib->number) {
1124
+				if (!checkBanForAccount($rib)) {
1125
+					$string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning');
1126 1126
 				} else {
1127
-					$string.= ' '.img_picto($langs->trans("ValueIsValid"),'info');
1127
+					$string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info');
1128 1128
 				}
1129 1129
 			}
1130 1130
 
@@ -1132,26 +1132,26 @@  discard block
 block discarded – undo
1132 1132
 			print '</td>';
1133 1133
 			// IBAN
1134 1134
 			print '<td>'.$rib->iban;
1135
-   			if (! empty($rib->iban)) {
1136
-				if (! checkIbanForAccount($rib)) {
1137
-					print ' '.img_picto($langs->trans("IbanNotValid"),'warning');
1135
+   			if (!empty($rib->iban)) {
1136
+				if (!checkIbanForAccount($rib)) {
1137
+					print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
1138 1138
 				} else {
1139
-					print ' '.img_picto($langs->trans("IbanValid"),'info');
1139
+					print ' '.img_picto($langs->trans("IbanValid"), 'info');
1140 1140
 				}
1141 1141
 			}
1142 1142
 			print '</td>';
1143 1143
 			// BIC
1144 1144
 			print '<td>'.$rib->bic;
1145
-			if (! empty($rib->bic)) {
1146
-				if (! checkSwiftForAccount($rib)) {
1147
-					print ' '.img_picto($langs->trans("SwiftNotValid"),'warning');
1145
+			if (!empty($rib->bic)) {
1146
+				if (!checkSwiftForAccount($rib)) {
1147
+					print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning');
1148 1148
 				} else {
1149
-					print ' '.img_picto($langs->trans("SwiftValid"),'info');
1149
+					print ' '.img_picto($langs->trans("SwiftValid"), 'info');
1150 1150
 				}
1151 1151
 			}
1152 1152
 			print '</td>';
1153 1153
 
1154
-			if (! empty($conf->prelevement->enabled))
1154
+			if (!empty($conf->prelevement->enabled))
1155 1155
 			{
1156 1156
 				// RUM
1157 1157
 				//print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
@@ -1165,10 +1165,10 @@  discard block
 block discarded – undo
1165 1165
 			print '<td align="center" width="70">';
1166 1166
 			if (!$rib->default_rib) {
1167 1167
 				print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
1168
-				print img_picto($langs->trans("Disabled"),'off');
1168
+				print img_picto($langs->trans("Disabled"), 'off');
1169 1169
 				print '</a>';
1170 1170
 			} else {
1171
-				print img_picto($langs->trans("Enabled"),'on');
1171
+				print img_picto($langs->trans("Enabled"), 'on');
1172 1172
 			}
1173 1173
 			print '</td>';
1174 1174
 
@@ -1176,54 +1176,54 @@  discard block
 block discarded – undo
1176 1176
 			print '<td align="center">';
1177 1177
 
1178 1178
 			$buttonlabel = $langs->trans("BuildDoc");
1179
-			$forname='builddocrib'.$rib->id;
1179
+			$forname = 'builddocrib'.$rib->id;
1180 1180
 
1181 1181
 			include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1182
-			$modellist=ModeleBankAccountDoc::liste_modeles($db);
1182
+			$modellist = ModeleBankAccountDoc::liste_modeles($db);
1183 1183
 
1184 1184
 			$out = '';
1185 1185
 			if (is_array($modellist) && count($modellist))
1186 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.'">';
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 1192
 
1193 1193
 				if (is_array($modellist) && count($modellist) == 1)    // If there is only one element
1194 1194
 				{
1195
-					$arraykeys=array_keys($modellist);
1196
-					$modelselected=$arraykeys[0];
1195
+					$arraykeys = array_keys($modellist);
1196
+					$modelselected = $arraykeys[0];
1197 1197
 				}
1198
-				if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1198
+				if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1199 1199
 
1200
-				$out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1201
-				$out.= ajax_combobox('modelrib'.$rib->id);
1200
+				$out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1201
+				$out .= ajax_combobox('modelrib'.$rib->id);
1202 1202
 
1203 1203
 				// Language code (if multilang)
1204 1204
 				if ($conf->global->MAIN_MULTILANGS)
1205 1205
 				{
1206 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);
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 1212
 				}
1213 1213
 				// Button
1214 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')
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 1219
 				{
1220 1220
 					$langs->load("errors");
1221
-					$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1221
+					$genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1222 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>';
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 1227
 			}
1228 1228
 			print $out;
1229 1229
 			print '</td>';
@@ -1233,13 +1233,13 @@  discard block
 block discarded – undo
1233 1233
 			if ($user->rights->societe->creer)
1234 1234
 			{
1235 1235
 				print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
1236
-				print img_picto($langs->trans("Modify"),'edit');
1236
+				print img_picto($langs->trans("Modify"), 'edit');
1237 1237
 				print '</a>';
1238 1238
 
1239 1239
 		   		print '&nbsp;';
1240 1240
 
1241 1241
 		   		print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
1242
-		   		print img_picto($langs->trans("Delete"),'delete');
1242
+		   		print img_picto($langs->trans("Delete"), 'delete');
1243 1243
 		   		print '</a>';
1244 1244
 			}
1245 1245
 			print '</td>';
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		if (count($rib_list) == 0)
1251 1251
 		{
1252
-			$colspan=8;
1253
-			if (! empty($conf->prelevement->enabled)) $colspan+=2;
1252
+			$colspan = 8;
1253
+			if (!empty($conf->prelevement->enabled)) $colspan += 2;
1254 1254
 			print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
1255 1255
 		}
1256 1256
 
@@ -1271,15 +1271,15 @@  discard block
 block discarded – undo
1271 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;
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 1278
 
1279 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 1280
 
1281 1281
 		// Show direct download link
1282
-		if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
1282
+		if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
1283 1283
 		{
1284 1284
 			$companybankaccounttemp = new CompanyBankAccount($db);
1285 1285
 			$companypaymentmodetemp = new CompanyPaymentMode($db);
@@ -1327,11 +1327,11 @@  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');
1330
+	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1331 1331
 
1332 1332
 	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1333 1333
 
1334
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1334
+	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
1335 1335
 
1336 1336
 	print '<div class="fichecenter">';
1337 1337
 
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 	// Show fields of bank account
1348 1348
 	foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1349 1349
 
1350
-		$require=false;
1350
+		$require = false;
1351 1351
 		if ($val == 'BankCode') {
1352 1352
 			$name = 'code_banque';
1353 1353
 			$size = 8;
@@ -1368,15 +1368,15 @@  discard block
 block discarded – undo
1368 1368
 			$name = 'iban';
1369 1369
 			$size = 30;
1370 1370
 			$content = $companybankaccount->iban;
1371
-			if ($companybankaccount->needIBAN()) $require=true;
1371
+			if ($companybankaccount->needIBAN()) $require = true;
1372 1372
 		} elseif ($val == 'BIC') {
1373 1373
 			$name = 'bic';
1374 1374
 			$size = 12;
1375 1375
 			$content = $companybankaccount->bic;
1376
-			if ($companybankaccount->needIBAN()) $require=true;
1376
+			if ($companybankaccount->needIBAN()) $require = true;
1377 1377
 		}
1378 1378
 
1379
-		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1379
+		print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>'.$langs->trans($val).'</td>';
1380 1380
 		print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
1381 1381
 		print '</tr>';
1382 1382
 	}
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 
1412 1412
 		print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1413 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);
1414
+		print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0);
1415 1415
 		print '</td></tr>';
1416 1416
 
1417 1417
 		print '</table>';
@@ -1431,11 +1431,11 @@  discard block
 block discarded – undo
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 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 1440
 	print '<div class="fichecenter">';
1441 1441
 
@@ -1479,11 +1479,11 @@  discard block
 block discarded – undo
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');
1482
+	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1483 1483
 
1484 1484
 	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
1485 1485
 
1486
-	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
1486
+	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
1487 1487
 
1488 1488
 	print '<div class="nofichecenter">';
1489 1489
 
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 	// Show fields of bank account
1500 1500
 	foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1501 1501
 
1502
-		$require=false;
1502
+		$require = false;
1503 1503
 		if ($val == 'BankCode') {
1504 1504
 			$name = 'code_banque';
1505 1505
 			$size = 8;
@@ -1515,14 +1515,14 @@  discard block
 block discarded – undo
1515 1515
 		} elseif ($val == 'IBAN') {
1516 1516
 			$name = 'iban';
1517 1517
 			$size = 30;
1518
-			if ($companybankaccount->needIBAN()) $require=true;
1518
+			if ($companybankaccount->needIBAN()) $require = true;
1519 1519
 		} elseif ($val == 'BIC') {
1520 1520
 			$name = 'bic';
1521 1521
 			$size = 12;
1522
-			if ($companybankaccount->needIBAN()) $require=true;
1522
+			if ($companybankaccount->needIBAN()) $require = true;
1523 1523
 		}
1524 1524
 
1525
-		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
1525
+		print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>'.$langs->trans($val).'</td>';
1526 1526
 		print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
1527 1527
 		print '</tr>';
1528 1528
 	}
@@ -1551,11 +1551,11 @@  discard block
 block discarded – undo
1551 1551
 
1552 1552
 		// RUM
1553 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>';
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 1555
 
1556 1556
 		print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1557 1557
 		$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1558
-		print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
1558
+		print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur']) ?GETPOST('frstrecur') : 'FRST'), 0);
1559 1559
 		print '</td></tr>';
1560 1560
 
1561 1561
 		print '</table>';
@@ -1577,11 +1577,11 @@  discard block
 block discarded – undo
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 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 1586
 	print '<div class="nofichecenter">';
1587 1587
 
@@ -1589,25 +1589,25 @@  discard block
 block discarded – undo
1589 1589
 	print '<table class="border centpercent">';
1590 1590
 
1591 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>';
1592
+	print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label', 'alpha').'"></td></tr>';
1593 1593
 
1594 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>';
1595
+	print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio', 'alpha').'"></td></tr>';
1596 1596
 
1597 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>';
1598
+	print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber', 'alpha').'"></td></tr>';
1599 1599
 
1600 1600
 	print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1601 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');
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 1604
 	print '</td></tr>';
1605 1605
 
1606 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>';
1607
+	print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn', 'alpha').'"></td></tr>';
1608 1608
 
1609 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>';
1610
+	print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref', 'alpha').'"></td></tr>';
1611 1611
 
1612 1612
 	print '</table>';
1613 1613
 
Please login to merge, or discard this patch.
Braces   +175 added lines, -102 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
 // Security check
46 46
 $socid = GETPOST("socid","int");
47
-if ($user->societe_id) $socid=$user->societe_id;
47
+if ($user->societe_id) {
48
+    $socid=$user->societe_id;
49
+}
48 50
 $result = restrictedArea($user, 'societe','','');
49 51
 
50 52
 $id=GETPOST("id","int");
@@ -97,7 +99,9 @@  discard block
 block discarded – undo
97 99
 
98 100
 $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
99 101
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
100
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
102
+if ($reshook < 0) {
103
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
104
+}
101 105
 
102 106
 if (empty($reshook))
103 107
 {
@@ -116,8 +120,12 @@  discard block
 block discarded – undo
116 120
 		// Modification
117 121
 		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
118 122
 		{
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');
123
+			if (! GETPOST('label','alpha')) {
124
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
125
+			}
126
+			if (! GETPOST('bank','alpha')) {
127
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
128
+			}
121 129
 			$action='edit';
122 130
 			$error++;
123 131
 		}
@@ -167,8 +175,7 @@  discard block
 block discarded – undo
167 175
 			if (! $result)
168 176
 			{
169 177
 				setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
170
-			}
171
-			else
178
+			} else
172 179
 			{
173 180
 				// If this account is the default bank account, we disable others
174 181
 				if ($companybankaccount->default_rib)
@@ -188,11 +195,21 @@  discard block
 block discarded – undo
188 195
 		// Modification
189 196
 		if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
190 197
 		{
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');
198
+			if (! GETPOST('label','alpha')) {
199
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
200
+			}
201
+			if (! GETPOST('proprio','alpha')) {
202
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
203
+			}
204
+			if (! GETPOST('cardnumber','alpha')) {
205
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
206
+			}
207
+			if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) {
208
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
209
+			}
210
+			if (! GETPOST('cvn','alpha')) {
211
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
212
+			}
196 213
 			$action='createcard';
197 214
 			$error++;
198 215
 		}
@@ -218,8 +235,7 @@  discard block
 block discarded – undo
218 235
 			if (! $result)
219 236
 			{
220 237
 				setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
221
-			}
222
-			else
238
+			} else
223 239
 			{
224 240
 				// If this account is the default bank account, we disable others
225 241
 				if ($companypaymentmode->default_rib)
@@ -240,8 +256,12 @@  discard block
 block discarded – undo
240 256
 
241 257
 		if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
242 258
 		{
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');
259
+			if (! GETPOST('label','alpha')) {
260
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
261
+			}
262
+			if (! GETPOST('bank','alpha')) {
263
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
264
+			}
245 265
 			$action='create';
246 266
 			$error++;
247 267
 		}
@@ -325,8 +345,7 @@  discard block
 block discarded – undo
325 345
 				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
326 346
 				header('Location: '.$url);
327 347
 				exit;
328
-			}
329
-			else
348
+			} else
330 349
 			{
331 350
 				$db->rollback();
332 351
 			}
@@ -339,11 +358,21 @@  discard block
 block discarded – undo
339 358
 
340 359
 		if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
341 360
 		{
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');
361
+			if (! GETPOST('label','alpha')) {
362
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
363
+			}
364
+			if (! GETPOST('proprio','alpha')) {
365
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
366
+			}
367
+			if (! GETPOST('cardnumber','alpha')) {
368
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
369
+			}
370
+			if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) {
371
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
372
+			}
373
+			if (! GETPOST('cvn','alpha')) {
374
+			    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
375
+			}
347 376
 			$action='createcard';
348 377
 			$error++;
349 378
 		}
@@ -390,8 +419,7 @@  discard block
 block discarded – undo
390 419
 				$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
391 420
 				header('Location: '.$url);
392 421
 				exit;
393
-			}
394
-			else
422
+			} else
395 423
 			{
396 424
 				$db->rollback();
397 425
 			}
@@ -407,8 +435,7 @@  discard block
 block discarded – undo
407 435
 			$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
408 436
 			header('Location: '.$url);
409 437
 			exit;
410
-		}
411
-		else
438
+		} else
412 439
 		{
413 440
 			setEventMessages($db->lasterror, null, 'errors');
414 441
 		}
@@ -425,13 +452,11 @@  discard block
 block discarded – undo
425 452
 				$url = $_SERVER['PHP_SELF']."?socid=".$object->id;
426 453
 				header('Location: '.$url);
427 454
 				exit;
428
-			}
429
-			else
455
+			} else
430 456
 			{
431 457
 				setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
432 458
 			}
433
-		}
434
-		else
459
+		} else
435 460
 		{
436 461
 			setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
437 462
 		}
@@ -447,13 +472,11 @@  discard block
 block discarded – undo
447 472
 				$url = $_SERVER['PHP_SELF']."?socid=".$object->id;
448 473
 				header('Location: '.$url);
449 474
 				exit;
450
-			}
451
-			else
475
+			} else
452 476
 			{
453 477
 				setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
454 478
 			}
455
-		}
456
-		else
479
+		} else
457 480
 		{
458 481
 			setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
459 482
 		}
@@ -489,8 +512,7 @@  discard block
 block discarded – undo
489 512
 			{
490 513
 				$error++;
491 514
 				setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
492
-			}
493
-			else
515
+			} else
494 516
 			{
495 517
 				// Creation of Stripe customer + update of societe_account
496 518
 				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
@@ -498,8 +520,7 @@  discard block
 block discarded – undo
498 520
 				{
499 521
 					$error++;
500 522
 					setEventMessages($stripe->error, $stripe->errors, 'errors');
501
-				}
502
-				else
523
+				} else
503 524
 				{
504 525
 					$stripecu = $cu->id;
505 526
 				}
@@ -514,8 +535,7 @@  discard block
 block discarded – undo
514 535
 			{
515 536
 				$error++;
516 537
 				setEventMessages('ThisPaymentModeIsNotACard', null, 'errors');
517
-			}
518
-			else
538
+			} else
519 539
 			{
520 540
 				// Get the Stripe customer
521 541
 				$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
@@ -533,8 +553,7 @@  discard block
 block discarded – undo
533 553
 					{
534 554
 						$error++;
535 555
 						setEventMessages($stripe->error, $stripe->errors, 'errors');
536
-					}
537
-					else
556
+					} else
538 557
 					{
539 558
 						$stripecard = $card->id;
540 559
 					}
@@ -580,8 +599,7 @@  discard block
 block discarded – undo
580 599
 			{
581 600
 				$stripecu = $newcu;
582 601
 				$db->commit();
583
-			}
584
-			else
602
+			} else
585 603
 			{
586 604
 				$db->rollback();
587 605
 			}
@@ -594,14 +612,12 @@  discard block
 block discarded – undo
594 612
 				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
595 613
 				header('Location: '.$url);
596 614
 				exit;
597
-			}
598
-			catch(Exception $e)
615
+			} catch(Exception $e)
599 616
 			{
600 617
 				$error++;
601 618
 				setEventMessages($e->getMessage(), null, 'errors');
602 619
 			}
603
-		}
604
-		elseif ($action == 'setassourcedefault')
620
+		} elseif ($action == 'setassourcedefault')
605 621
 		{
606 622
 			try {
607 623
 				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
@@ -611,14 +627,12 @@  discard block
 block discarded – undo
611 627
 				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
612 628
 				header('Location: '.$url);
613 629
 				exit;
614
-			}
615
-			catch(Exception $e)
630
+			} catch(Exception $e)
616 631
 			{
617 632
 				$error++;
618 633
 				setEventMessages($e->getMessage(), null, 'errors');
619 634
 			}
620
-		}
621
-		elseif ($action == 'deletecard' && $source)
635
+		} elseif ($action == 'deletecard' && $source)
622 636
 		{
623 637
 			try {
624 638
 				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
@@ -626,15 +640,17 @@  discard block
 block discarded – undo
626 640
 				if ($card)
627 641
 				{
628 642
 					// $card->detach();  Does not work with card_, only with src_
629
-					if (method_exists($card, 'detach')) $card->detach();
630
-					else $card->delete();
643
+					if (method_exists($card, 'detach')) {
644
+					    $card->detach();
645
+					} else {
646
+					    $card->delete();
647
+					}
631 648
 				}
632 649
 
633 650
 				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
634 651
 				header('Location: '.$url);
635 652
 				exit;
636
-			}
637
-			catch(Exception $e)
653
+			} catch(Exception $e)
638 654
 			{
639 655
 				$error++;
640 656
 				setEventMessages($e->getMessage(), null, 'errors');
@@ -672,20 +688,23 @@  discard block
 block discarded – undo
672 688
 {
673 689
 	$companybankaccount->fetch(0, $object->id);
674 690
 	$companypaymentmode->fetch(0, null, $object->id, 'card');
675
-}
676
-else
691
+} else
677 692
 {
678 693
 	$companybankaccount->fetch($id);
679 694
 	$companypaymentmode->fetch($id);
680 695
 }
681
-if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id;
696
+if (empty($companybankaccount->socid)) {
697
+    $companybankaccount->socid=$object->id;
698
+}
682 699
 
683 700
 if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer)
684 701
 {
685 702
 	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
686 703
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
687 704
 	$actionforadd='update';
688
-	if ($action == 'editcard') $actionforadd='updatecard';
705
+	if ($action == 'editcard') {
706
+	    $actionforadd='updatecard';
707
+	}
689 708
 	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
690 709
 	print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
691 710
 }
@@ -694,7 +713,9 @@  discard block
 block discarded – undo
694 713
 	print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
695 714
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
696 715
 	$actionforadd='add';
697
-	if ($action == 'createcard') $actionforadd='addcard';
716
+	if ($action == 'createcard') {
717
+	    $actionforadd='addcard';
718
+	}
698 719
 	print '<input type="hidden" name="action" value="'.$actionforadd.'">';
699 720
 }
700 721
 
@@ -720,10 +741,12 @@  discard block
 block discarded – undo
720 741
 	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
721 742
 
722 743
 
723
-	if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
744
+	if (! empty($conf->global->SOCIETE_USEPREFIX)) {
745
+	    // Old not used prefix field
724 746
 	{
725 747
 		print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
726 748
 	}
749
+	}
727 750
 
728 751
 	//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
729 752
 
@@ -737,19 +760,31 @@  discard block
 block discarded – undo
737 760
 		print '<tr><td class="titlefield">';
738 761
 		print $langs->trans('CustomerCode').'</td><td colspan="2">';
739 762
 		print $object->code_client;
740
-		if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
763
+		if ($object->check_codeclient() <> 0) {
764
+		    print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
765
+		}
741 766
 		print '</td></tr>';
742 767
 		$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
743 768
 		$resql=$db->query($sql);
744
-		if (!$resql) dol_print_error($db);
769
+		if (!$resql) {
770
+		    dol_print_error($db);
771
+		}
745 772
 
746 773
 		$obj = $db->fetch_object($resql);
747 774
 		$nbFactsClient = $obj->nb;
748 775
 		$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');
776
+		if ($conf->propal->enabled && $user->rights->propal->lire) {
777
+		    $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals');
778
+		}
779
+		if ($conf->commande->enabled && $user->rights->commande->lire) {
780
+		    $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders');
781
+		}
782
+		if ($conf->facture->enabled && $user->rights->facture->lire) {
783
+		    $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices');
784
+		}
785
+		if ($conf->contrat->enabled && $user->rights->contrat->lire) {
786
+		    $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts');
787
+		}
753 788
 	}
754 789
 
755 790
 	if (! empty($conf->stripe->enabled))
@@ -764,7 +799,9 @@  discard block
 block discarded – undo
764 799
 		print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
765 800
 		if ($stripecu && $action != 'editkey_account')
766 801
 		{
767
-			if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
802
+			if (! empty($conf->stripe->enabled) && !empty($stripeacc)) {
803
+			    $connect=$stripeacc.'/';
804
+			}
768 805
 			$url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
769 806
 			if ($servicestatus)
770 807
 			{
@@ -811,8 +848,7 @@  discard block
 block discarded – undo
811 848
 				if ($customerstripe->id) {
812 849
 					$listofsources=$customerstripe->sources->data;
813 850
 				}
814
-			}
815
-			catch(Exception $e)
851
+			} catch(Exception $e)
816 852
 			{
817 853
 				dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
818 854
 			}
@@ -888,16 +924,21 @@  discard block
 block discarded – undo
888 924
 							print img_credit_card($companypaymentmodetemp->type);
889 925
 							print '</td>';
890 926
 							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.'';
927
+							if ($companypaymentmodetemp->last_four) {
928
+							    print '....'.$companypaymentmodetemp->last_four;
929
+							}
930
+							if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
931
+							    print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.'';
932
+							}
893 933
 							print '</td><td>';
894 934
 							if ($companypaymentmodetemp->country_code)
895 935
 							{
896 936
 								$img=picto_from_langcode($companypaymentmodetemp->country_code);
897 937
 								print $img?$img.' ':'';
898 938
 								print getCountry($companypaymentmodetemp->country_code,1);
939
+							} else {
940
+							    print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
899 941
 							}
900
-							else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
901 942
 							print '</td>';
902 943
 							// Default
903 944
 							print '<td align="center">';
@@ -911,8 +952,11 @@  discard block
 block discarded – undo
911 952
 							}
912 953
 							print '</td>';
913 954
 							print '<td>';
914
-							if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local");
915
-							else print $langs->trans("LocalAndRemote");
955
+							if (empty($companypaymentmodetemp->stripe_card_ref)) {
956
+							    print $langs->trans("Local");
957
+							} else {
958
+							    print $langs->trans("LocalAndRemote");
959
+							}
916 960
 							print '</td>';
917 961
 							print '<td>';
918 962
 							print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
@@ -939,8 +983,9 @@  discard block
 block discarded – undo
939 983
 						$i++;
940 984
 					}
941 985
 				}
986
+			} else {
987
+			    dol_print_error($db);
942 988
 			}
943
-			else dol_print_error($db);
944 989
 		}
945 990
 
946 991
 		// Show remote sources (not already shown as local source)
@@ -948,7 +993,10 @@  discard block
 block discarded – undo
948 993
 		{
949 994
 			foreach ($listofsources as $src)
950 995
 			{
951
-				if (! empty($arrayofstripecard[$src->id])) continue;	// Already in previous list
996
+				if (! empty($arrayofstripecard[$src->id])) {
997
+				    continue;
998
+				}
999
+				// Already in previous list
952 1000
 
953 1001
 				$nbremote++;
954 1002
 
@@ -961,7 +1009,9 @@  discard block
 block discarded – undo
961 1009
 				}
962 1010
 				// Src ID
963 1011
 				print '<td>';
964
-				if (!empty($stripeacc)) $connect=$stripeacc.'/';
1012
+				if (!empty($stripeacc)) {
1013
+				    $connect=$stripeacc.'/';
1014
+				}
965 1015
 				$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
966 1016
 				if ($servicestatus)
967 1017
 				{
@@ -974,12 +1024,10 @@  discard block
 block discarded – undo
974 1024
 				if ($src->object=='card')
975 1025
 				{
976 1026
 					print img_credit_card($src->brand);
977
-				}
978
-				elseif ($src->object=='source' && $src->type=='card')
1027
+				} elseif ($src->object=='source' && $src->type=='card')
979 1028
 				{
980 1029
 					print img_credit_card($src->card->brand);
981
-				}
982
-				elseif ($src->object=='source' && $src->type=='sepa_debit')
1030
+				} elseif ($src->object=='source' && $src->type=='sepa_debit')
983 1031
 				{
984 1032
 					print '<span class="fa fa-university fa-2x fa-fw"></span>';
985 1033
 				}
@@ -994,10 +1042,10 @@  discard block
 block discarded – undo
994 1042
 						$img=picto_from_langcode($src->country);
995 1043
 						print $img?$img.' ':'';
996 1044
 						print getCountry($src->country,1);
1045
+					} else {
1046
+					    print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
997 1047
 					}
998
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
999
-				}
1000
-				elseif ($src->object=='source' && $src->type=='card')
1048
+				} elseif ($src->object=='source' && $src->type=='card')
1001 1049
 				{
1002 1050
 					print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1003 1051
 					print '</td><td>';
@@ -1007,10 +1055,10 @@  discard block
 block discarded – undo
1007 1055
 						$img=picto_from_langcode($src->card->country);
1008 1056
 						print $img?$img.' ':'';
1009 1057
 						print getCountry($src->card->country,1);
1058
+					} else {
1059
+					    print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1010 1060
 					}
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')
1061
+				} elseif ($src->object=='source' && $src->type=='sepa_debit')
1014 1062
 				{
1015 1063
 					print 'info sepa';
1016 1064
 					print '</td><td>';
@@ -1019,8 +1067,9 @@  discard block
 block discarded – undo
1019 1067
 							$img=picto_from_langcode($src->sepa_debit->country);
1020 1068
 							print $img?$img.' ':'';
1021 1069
 							print getCountry($src->sepa_debit->country,1);
1070
+					} else {
1071
+					    print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1022 1072
 					}
1023
-					else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
1024 1073
 				}
1025 1074
 				print '</td>';
1026 1075
 				// Default
@@ -1190,12 +1239,16 @@  discard block
 block discarded – undo
1190 1239
 				$out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
1191 1240
 				$out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
1192 1241
 
1193
-				if (is_array($modellist) && count($modellist) == 1)    // If there is only one element
1242
+				if (is_array($modellist) && count($modellist) == 1) {
1243
+				    // If there is only one element
1194 1244
 				{
1195 1245
 					$arraykeys=array_keys($modellist);
1246
+				}
1196 1247
 					$modelselected=$arraykeys[0];
1197 1248
 				}
1198
-				if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1249
+				if (! empty($conf->global->BANKADDON_PDF)) {
1250
+				    $modelselected = $conf->global->BANKADDON_PDF;
1251
+				}
1199 1252
 
1200 1253
 				$out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1201 1254
 				$out.= ajax_combobox('modelrib'.$rib->id);
@@ -1207,21 +1260,29 @@  discard block
 block discarded – undo
1207 1260
 					$formadmin=new FormAdmin($db);
1208 1261
 					$defaultlang=$codelang?$codelang:$langs->getDefaultLang();
1209 1262
 					$morecss='maxwidth150';
1210
-					if ($conf->browser->layout == 'phone') $morecss='maxwidth100';
1263
+					if ($conf->browser->layout == 'phone') {
1264
+					    $morecss='maxwidth100';
1265
+					}
1211 1266
 					$out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1212 1267
 				}
1213 1268
 				// Button
1214 1269
 				$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
1215 1270
 				$genbutton.= ' type="submit" value="'.$buttonlabel.'"';
1216
-				if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
1271
+				if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) {
1272
+				    $genbutton.= ' disabled';
1273
+				}
1217 1274
 				$genbutton.= '>';
1218 1275
 				if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
1219 1276
 				{
1220 1277
 					$langs->load("errors");
1221 1278
 					$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1222 1279
 				}
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='';
1280
+				if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') {
1281
+				    $genbutton='';
1282
+				}
1283
+				if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') {
1284
+				    $genbutton='';
1285
+				}
1225 1286
 				$out.= $genbutton;
1226 1287
 				$out.= '</form>';
1227 1288
 			}
@@ -1250,7 +1311,9 @@  discard block
 block discarded – undo
1250 1311
 		if (count($rib_list) == 0)
1251 1312
 		{
1252 1313
 			$colspan=8;
1253
-			if (! empty($conf->prelevement->enabled)) $colspan+=2;
1314
+			if (! empty($conf->prelevement->enabled)) {
1315
+			    $colspan+=2;
1316
+			}
1254 1317
 			print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
1255 1318
 		}
1256 1319
 
@@ -1368,12 +1431,16 @@  discard block
 block discarded – undo
1368 1431
 			$name = 'iban';
1369 1432
 			$size = 30;
1370 1433
 			$content = $companybankaccount->iban;
1371
-			if ($companybankaccount->needIBAN()) $require=true;
1434
+			if ($companybankaccount->needIBAN()) {
1435
+			    $require=true;
1436
+			}
1372 1437
 		} elseif ($val == 'BIC') {
1373 1438
 			$name = 'bic';
1374 1439
 			$size = 12;
1375 1440
 			$content = $companybankaccount->bic;
1376
-			if ($companybankaccount->needIBAN()) $require=true;
1441
+			if ($companybankaccount->needIBAN()) {
1442
+			    $require=true;
1443
+			}
1377 1444
 		}
1378 1445
 
1379 1446
 		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
@@ -1403,7 +1470,9 @@  discard block
 block discarded – undo
1403 1470
 
1404 1471
 		print '<table class="border" width="100%">';
1405 1472
 
1406
-		if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1473
+		if (empty($companybankaccount->rum)) {
1474
+		    $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1475
+		}
1407 1476
 
1408 1477
 		// RUM
1409 1478
 		print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
@@ -1515,11 +1584,15 @@  discard block
 block discarded – undo
1515 1584
 		} elseif ($val == 'IBAN') {
1516 1585
 			$name = 'iban';
1517 1586
 			$size = 30;
1518
-			if ($companybankaccount->needIBAN()) $require=true;
1587
+			if ($companybankaccount->needIBAN()) {
1588
+			    $require=true;
1589
+			}
1519 1590
 		} elseif ($val == 'BIC') {
1520 1591
 			$name = 'bic';
1521 1592
 			$size = 12;
1522
-			if ($companybankaccount->needIBAN()) $require=true;
1593
+			if ($companybankaccount->needIBAN()) {
1594
+			    $require=true;
1595
+			}
1523 1596
 		}
1524 1597
 
1525 1598
 		print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/note.php 3 patches
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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
 require '../main.inc.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 31
 
32
-$action = GETPOST('action','aZ09');
32
+$action = GETPOST('action', 'aZ09');
33 33
 
34 34
 $langs->load("companies");
35 35
 
36 36
 // Security check
37
-$id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int');
38
-if ($user->societe_id) $id=$user->societe_id;
37
+$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
38
+if ($user->societe_id) $id = $user->societe_id;
39 39
 $result = restrictedArea($user, 'societe', $id, '&societe');
40 40
 
41 41
 $object = new Societe($db);
42 42
 if ($id > 0) $object->fetch($id);
43 43
 
44
-$permissionnote=$user->rights->societe->creer;	// Used by the include of actions_setnotes.inc.php
44
+$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
45 45
 
46 46
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
47
-$hookmanager->initHooks(array('thirdpartynote','globalcard'));
47
+$hookmanager->initHooks(array('thirdpartynote', 'globalcard'));
48 48
 
49 49
 
50 50
 /*
51 51
  * Actions
52 52
  */
53 53
 
54
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';	// Must be include, not includ_once
54
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
55 55
 
56 56
 
57 57
 /*
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 
61 61
 $form = new Form($db);
62 62
 
63
-$title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes");
64
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes");
65
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
66
-llxHeader('',$title,$help_url);
63
+$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes");
64
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes");
65
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
66
+llxHeader('', $title, $help_url);
67 67
 
68 68
 if ($object->id > 0)
69 69
 {
70 70
     /*
71 71
      * Affichage onglets
72 72
      */
73
-    if (! empty($conf->notification->enabled)) $langs->load("mails");
73
+    if (!empty($conf->notification->enabled)) $langs->load("mails");
74 74
 
75 75
     $head = societe_prepare_head($object);
76 76
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 
79 79
     $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
80 80
 
81
-    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
81
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
82 82
 
83
-    $cssclass='titlefield';
83
+    $cssclass = 'titlefield';
84 84
     //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
85 85
     //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     print '<div class="underbanner clearboth"></div>';
90 90
     print '<table class="border centpercent">';
91 91
 
92
-    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
92
+    if (!empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
93 93
     {
94 94
         print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
95 95
     }
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,11 +35,15 @@  discard block
 block discarded – undo
35 35
 
36 36
 // Security check
37 37
 $id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int');
38
-if ($user->societe_id) $id=$user->societe_id;
38
+if ($user->societe_id) {
39
+    $id=$user->societe_id;
40
+}
39 41
 $result = restrictedArea($user, 'societe', $id, '&societe');
40 42
 
41 43
 $object = new Societe($db);
42
-if ($id > 0) $object->fetch($id);
44
+if ($id > 0) {
45
+    $object->fetch($id);
46
+}
43 47
 
44 48
 $permissionnote=$user->rights->societe->creer;	// Used by the include of actions_setnotes.inc.php
45 49
 
@@ -61,7 +65,9 @@  discard block
 block discarded – undo
61 65
 $form = new Form($db);
62 66
 
63 67
 $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes");
64
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes");
68
+if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) {
69
+    $title=$object->name.' - '.$langs->trans("Notes");
70
+}
65 71
 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
66 72
 llxHeader('',$title,$help_url);
67 73
 
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
     /*
71 77
      * Affichage onglets
72 78
      */
73
-    if (! empty($conf->notification->enabled)) $langs->load("mails");
79
+    if (! empty($conf->notification->enabled)) {
80
+        $langs->load("mails");
81
+    }
74 82
 
75 83
     $head = societe_prepare_head($object);
76 84
 
@@ -89,17 +97,21 @@  discard block
 block discarded – undo
89 97
     print '<div class="underbanner clearboth"></div>';
90 98
     print '<table class="border centpercent">';
91 99
 
92
-    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
100
+    if (! empty($conf->global->SOCIETE_USEPREFIX)) {
101
+        // Old not used prefix field
93 102
     {
94 103
         print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
95 104
     }
105
+    }
96 106
 
97 107
     if ($object->client)
98 108
     {
99 109
         print '<tr><td class="'.$cssclass.'">';
100 110
         print $langs->trans('CustomerCode').'</td><td colspan="3">';
101 111
         print $object->code_client;
102
-        if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
112
+        if ($object->check_codeclient() <> 0) {
113
+            print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
114
+        }
103 115
         print '</td></tr>';
104 116
     }
105 117
 
@@ -108,7 +120,9 @@  discard block
 block discarded – undo
108 120
         print '<tr><td class="'.$cssclass.'">';
109 121
         print $langs->trans('SupplierCode').'</td><td colspan="3">';
110 122
         print $object->code_fournisseur;
111
-        if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
123
+        if ($object->check_codefournisseur() <> 0) {
124
+            print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
125
+        }
112 126
         print '</td></tr>';
113 127
     }
114 128
 
@@ -122,8 +136,7 @@  discard block
 block discarded – undo
122 136
     include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
123 137
 
124 138
     dol_fiche_end();
125
-}
126
-else
139
+} else
127 140
 {
128 141
 	$langs->load("errors");
129 142
 	print $langs->trans("ErrorRecordNotFound");
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/index.php 3 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -62,32 +62,32 @@  discard block
 block discarded – undo
62 62
     // Search thirdparty
63 63
     if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
64 64
     {
65
-    	$listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty');
65
+        $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty');
66 66
     }
67 67
     // Search contact/address
68 68
     if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
69 69
     {
70
-    	$listofsearchfields['search_contact']=array('text'=>'Contact');
70
+        $listofsearchfields['search_contact']=array('text'=>'Contact');
71 71
     }
72 72
 
73 73
     if (count($listofsearchfields))
74 74
     {
75
-    	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
76
-    	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
77
-    	print '<table class="noborder nohover centpercent">';
78
-    	$i=0;
79
-    	foreach($listofsearchfields as $key => $value)
80
-    	{
81
-    		if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>';
82
-    		print '<tr '.$bc[false].'>';
83
-    		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
84
-    		if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
85
-    		print '</tr>';
86
-    		$i++;
87
-    	}
88
-    	print '</table>';
89
-    	print '</form>';
90
-    	print '<br>';
75
+        print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
76
+        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
77
+        print '<table class="noborder nohover centpercent">';
78
+        $i=0;
79
+        foreach($listofsearchfields as $key => $value)
80
+        {
81
+            if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>';
82
+            print '<tr '.$bc[false].'>';
83
+            print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
84
+            if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
85
+            print '</tr>';
86
+            $i++;
87
+        }
88
+        print '</table>';
89
+        print '</form>';
90
+        print '<br>';
91 91
     }
92 92
 }
93 93
 
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
  */
98 98
 
99 99
 $third = array(
100
-		'customer' => 0,
101
-		'prospect' => 0,
102
-		'supplier' => 0,
103
-		'other' =>0
100
+        'customer' => 0,
101
+        'prospect' => 0,
102
+        'supplier' => 0,
103
+        'other' =>0
104 104
 );
105 105
 $total=0;
106 106
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
     if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other']));
141 141
     include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
142 142
     $dolgraph = new DolGraph();
143
-	$dolgraph->SetData($dataseries);
144
-	$dolgraph->setShowLegend(1);
145
-	$dolgraph->setShowPercent(1);
146
-	$dolgraph->SetType(array('pie'));
147
-	$dolgraph->setWidth('100%');
148
-	$dolgraph->draw('idgraphthirdparties');
149
-	print $dolgraph->show();
143
+    $dolgraph->SetData($dataseries);
144
+    $dolgraph->setShowLegend(1);
145
+    $dolgraph->setShowPercent(1);
146
+    $dolgraph->SetType(array('pie'));
147
+    $dolgraph->setWidth('100%');
148
+    $dolgraph->draw('idgraphthirdparties');
149
+    print $dolgraph->show();
150 150
     print '</td></tr>'."\n";
151 151
 }
152 152
 else
@@ -180,80 +180,80 @@  discard block
 block discarded – undo
180 180
 
181 181
 if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
182 182
 {
183
-	require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
184
-	$elementtype = 'societe';
185
-
186
-	print '<br>';
187
-
188
-	print '<div class="div-table-responsive-no-min">';
189
-	print '<table class="noborder nohover" width="100%">';
190
-	print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
191
-	print '<tr '.$bc[0].'><td align="center" colspan="2">';
192
-	$sql = "SELECT c.label, count(*) as nb";
193
-	$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
194
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
195
-	$sql.= " WHERE c.type = 2";
196
-	if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
197
-	$sql.= " AND c.entity IN (".getEntity('category').")";
198
-	$sql.= " GROUP BY c.label";
199
-	$total=0;
200
-	$result = $db->query($sql);
201
-	if ($result)
202
-	{
203
-		$num = $db->num_rows($result);
204
-		$i=0;
205
-		if (! empty($conf->use_javascript_ajax) )
206
-		{
207
-			$dataseries=array();
208
-			$rest=0;
209
-			$nbmax=10;
210
-
211
-			while ($i < $num)
212
-			{
213
-				$obj = $db->fetch_object($result);
214
-				if ($i < $nbmax)
215
-				{
216
-					$dataseries[]=array($obj->label, round($obj->nb));
217
-				}
218
-				else
219
-				{
220
-					$rest+=$obj->nb;
221
-				}
222
-				$total+=$obj->nb;
223
-				$i++;
224
-			}
225
-			if ($i > $nbmax)
226
-			{
227
-				$dataseries[]=array($langs->trans("Other"), round($rest));
228
-			}
229
-			include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
230
-			$dolgraph = new DolGraph();
231
-			$dolgraph->SetData($dataseries);
232
-			$dolgraph->setShowLegend(1);
233
-			$dolgraph->setShowPercent(1);
234
-			$dolgraph->SetType(array('pie'));
235
-			$dolgraph->setWidth('100%');
236
-			$dolgraph->draw('idgraphcateg');
237
-			print $dolgraph->show();
238
-		}
239
-		else
240
-		{
241
-			while ($i < $num)
242
-			{
243
-				$obj = $db->fetch_object($result);
244
-
245
-				print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
246
-				$total+=$obj->nb;
247
-				$i++;
248
-			}
249
-		}
250
-	}
251
-	print '</td></tr>';
252
-	print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
253
-	print $total;
254
-	print '</td></tr>';
255
-	print '</table>';
256
-	print '</div>';
183
+    require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
184
+    $elementtype = 'societe';
185
+
186
+    print '<br>';
187
+
188
+    print '<div class="div-table-responsive-no-min">';
189
+    print '<table class="noborder nohover" width="100%">';
190
+    print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
191
+    print '<tr '.$bc[0].'><td align="center" colspan="2">';
192
+    $sql = "SELECT c.label, count(*) as nb";
193
+    $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
194
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
195
+    $sql.= " WHERE c.type = 2";
196
+    if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
197
+    $sql.= " AND c.entity IN (".getEntity('category').")";
198
+    $sql.= " GROUP BY c.label";
199
+    $total=0;
200
+    $result = $db->query($sql);
201
+    if ($result)
202
+    {
203
+        $num = $db->num_rows($result);
204
+        $i=0;
205
+        if (! empty($conf->use_javascript_ajax) )
206
+        {
207
+            $dataseries=array();
208
+            $rest=0;
209
+            $nbmax=10;
210
+
211
+            while ($i < $num)
212
+            {
213
+                $obj = $db->fetch_object($result);
214
+                if ($i < $nbmax)
215
+                {
216
+                    $dataseries[]=array($obj->label, round($obj->nb));
217
+                }
218
+                else
219
+                {
220
+                    $rest+=$obj->nb;
221
+                }
222
+                $total+=$obj->nb;
223
+                $i++;
224
+            }
225
+            if ($i > $nbmax)
226
+            {
227
+                $dataseries[]=array($langs->trans("Other"), round($rest));
228
+            }
229
+            include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
230
+            $dolgraph = new DolGraph();
231
+            $dolgraph->SetData($dataseries);
232
+            $dolgraph->setShowLegend(1);
233
+            $dolgraph->setShowPercent(1);
234
+            $dolgraph->SetType(array('pie'));
235
+            $dolgraph->setWidth('100%');
236
+            $dolgraph->draw('idgraphcateg');
237
+            print $dolgraph->show();
238
+        }
239
+        else
240
+        {
241
+            while ($i < $num)
242
+            {
243
+                $obj = $db->fetch_object($result);
244
+
245
+                print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
246
+                $total+=$obj->nb;
247
+                $i++;
248
+            }
249
+        }
250
+    }
251
+    print '</td></tr>';
252
+    print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
253
+    print $total;
254
+    print '</td></tr>';
255
+    print '</table>';
256
+    print '</div>';
257 257
 }
258 258
 
259 259
 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
@@ -324,20 +324,20 @@  discard block
 block discarded – undo
324 324
             print '<td align="center">';
325 325
             if ($thirdparty_static->client==1 || $thirdparty_static->client==3)
326 326
             {
327
-            	$thirdparty_static->name=$langs->trans("Customer");
328
-            	print $thirdparty_static->getNomUrl(0,'customer',0,1);
327
+                $thirdparty_static->name=$langs->trans("Customer");
328
+                print $thirdparty_static->getNomUrl(0,'customer',0,1);
329 329
             }
330 330
             if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
331 331
             if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
332 332
             {
333
-            	$thirdparty_static->name=$langs->trans("Prospect");
334
-            	print $thirdparty_static->getNomUrl(0,'prospect',0,1);
333
+                $thirdparty_static->name=$langs->trans("Prospect");
334
+                print $thirdparty_static->getNomUrl(0,'prospect',0,1);
335 335
             }
336 336
             if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
337 337
             {
338 338
                 if ($thirdparty_static->client) print " / ";
339
-            	$thirdparty_static->name=$langs->trans("Supplier");
340
-            	print $thirdparty_static->getNomUrl(0,'supplier',0,1);
339
+                $thirdparty_static->name=$langs->trans("Supplier");
340
+                print $thirdparty_static->getNomUrl(0,'supplier',0,1);
341 341
             }
342 342
             print '</td>';
343 343
             // Last modified date
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
 $langs->load("companies");
33 33
 
34
-$socid = GETPOST('socid','int');
35
-if ($user->societe_id) $socid=$user->societe_id;
34
+$socid = GETPOST('socid', 'int');
35
+if ($user->societe_id) $socid = $user->societe_id;
36 36
 
37 37
 // Security check
38
-$result=restrictedArea($user,'societe',0,'','','','');
38
+$result = restrictedArea($user, 'societe', 0, '', '', '', '');
39 39
 
40 40
 $thirdparty_static = new Societe($db);
41 41
 
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
  */
46 46
 
47 47
 $transAreaType = $langs->trans("ThirdPartiesArea");
48
-$helpurl='EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Terceros';
48
+$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Terceros';
49 49
 
50
-llxHeader("",$langs->trans("ThirdParties"),$helpurl);
51
-$linkback='';
52
-print load_fiche_titre($transAreaType,$linkback,'title_companies.png');
50
+llxHeader("", $langs->trans("ThirdParties"), $helpurl);
51
+$linkback = '';
52
+print load_fiche_titre($transAreaType, $linkback, 'title_companies.png');
53 53
 
54 54
 
55 55
 //print '<table border="0" width="100%" class="notopnoleftnoright">';
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 print '<div class="fichecenter"><div class="fichethirdleft">';
58 58
 
59 59
 
60
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
60
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
61 61
 {
62 62
     // Search thirdparty
63
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
63
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire)
64 64
     {
65
-    	$listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty');
65
+    	$listofsearchfields['search_thirdparty'] = array('text'=>'ThirdParty');
66 66
     }
67 67
     // Search contact/address
68
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
68
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire)
69 69
     {
70
-    	$listofsearchfields['search_contact']=array('text'=>'Contact');
70
+    	$listofsearchfields['search_contact'] = array('text'=>'Contact');
71 71
     }
72 72
 
73 73
     if (count($listofsearchfields))
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
     	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
76 76
     	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
77 77
     	print '<table class="noborder nohover centpercent">';
78
-    	$i=0;
79
-    	foreach($listofsearchfields as $key => $value)
78
+    	$i = 0;
79
+    	foreach ($listofsearchfields as $key => $value)
80 80
     	{
81 81
     		if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>';
82 82
     		print '<tr '.$bc[false].'>';
@@ -102,26 +102,26 @@  discard block
 block discarded – undo
102 102
 		'supplier' => 0,
103 103
 		'other' =>0
104 104
 );
105
-$total=0;
105
+$total = 0;
106 106
 
107 107
 $sql = "SELECT s.rowid, s.client, s.fournisseur";
108
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
109
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
110
-$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
111
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
112
-if ($socid)	$sql.= " AND s.rowid = ".$socid;
113
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";    // client=0, fournisseur=0 must be visible
108
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
109
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
110
+$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
111
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
112
+if ($socid)	$sql .= " AND s.rowid = ".$socid;
113
+if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
114 114
 //print $sql;
115 115
 $result = $db->query($sql);
116 116
 if ($result)
117 117
 {
118 118
     while ($objp = $db->fetch_object($result))
119 119
     {
120
-        $found=0;
121
-        if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; }
122
-        if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; }
123
-        if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; }
124
-        if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; }
120
+        $found = 0;
121
+        if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; }
122
+        if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; }
123
+        if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
124
+        if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
125 125
         if ($found) $total++;
126 126
     }
127 127
 }
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 print '<div class="div-table-responsive-no-min">';
131 131
 print '<table class="noborder nohover" width="100%">'."\n";
132 132
 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
133
-if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2))
133
+if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2))
134 134
 {
135 135
     print '<tr><td align="center" colspan="2">';
136
-    $dataseries=array();
137
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))     $dataseries[]=array($langs->trans("Prospects"), round($third['prospect']));
138
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))     $dataseries[]=array($langs->trans("Customers"), round($third['customer']));
139
-    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier']));
140
-    if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other']));
136
+    $dataseries = array();
137
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))     $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
138
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))     $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
139
+    if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
140
+    if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other']));
141 141
     include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
142 142
     $dolgraph = new DolGraph();
143 143
 	$dolgraph->SetData($dataseries);
@@ -151,23 +151,23 @@  discard block
 block discarded – undo
151 151
 }
152 152
 else
153 153
 {
154
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
154
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
155 155
     {
156 156
         $statstring = "<tr>";
157
-        $statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
158
-        $statstring.= "</tr>";
157
+        $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
158
+        $statstring .= "</tr>";
159 159
     }
160
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
160
+    if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
161 161
     {
162
-        $statstring.= "<tr>";
163
-        $statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
164
-        $statstring.= "</tr>";
162
+        $statstring .= "<tr>";
163
+        $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
164
+        $statstring .= "</tr>";
165 165
     }
166
-    if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
166
+    if (!empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
167 167
     {
168 168
         $statstring2 = "<tr>";
169
-        $statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>';
170
-        $statstring2.= "</tr>";
169
+        $statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>';
170
+        $statstring2 .= "</tr>";
171 171
     }
172 172
     print $statstring;
173 173
     print $statstring2;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 print '</table>';
179 179
 print '</div>';
180 180
 
181
-if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
181
+if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
182 182
 {
183 183
 	require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
184 184
 	$elementtype = 'societe';
@@ -190,41 +190,41 @@  discard block
 block discarded – undo
190 190
 	print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
191 191
 	print '<tr '.$bc[0].'><td align="center" colspan="2">';
192 192
 	$sql = "SELECT c.label, count(*) as nb";
193
-	$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
194
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
195
-	$sql.= " WHERE c.type = 2";
196
-	if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
197
-	$sql.= " AND c.entity IN (".getEntity('category').")";
198
-	$sql.= " GROUP BY c.label";
199
-	$total=0;
193
+	$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
194
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
195
+	$sql .= " WHERE c.type = 2";
196
+	if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
197
+	$sql .= " AND c.entity IN (".getEntity('category').")";
198
+	$sql .= " GROUP BY c.label";
199
+	$total = 0;
200 200
 	$result = $db->query($sql);
201 201
 	if ($result)
202 202
 	{
203 203
 		$num = $db->num_rows($result);
204
-		$i=0;
205
-		if (! empty($conf->use_javascript_ajax) )
204
+		$i = 0;
205
+		if (!empty($conf->use_javascript_ajax))
206 206
 		{
207
-			$dataseries=array();
208
-			$rest=0;
209
-			$nbmax=10;
207
+			$dataseries = array();
208
+			$rest = 0;
209
+			$nbmax = 10;
210 210
 
211 211
 			while ($i < $num)
212 212
 			{
213 213
 				$obj = $db->fetch_object($result);
214 214
 				if ($i < $nbmax)
215 215
 				{
216
-					$dataseries[]=array($obj->label, round($obj->nb));
216
+					$dataseries[] = array($obj->label, round($obj->nb));
217 217
 				}
218 218
 				else
219 219
 				{
220
-					$rest+=$obj->nb;
220
+					$rest += $obj->nb;
221 221
 				}
222
-				$total+=$obj->nb;
222
+				$total += $obj->nb;
223 223
 				$i++;
224 224
 			}
225 225
 			if ($i > $nbmax)
226 226
 			{
227
-				$dataseries[]=array($langs->trans("Other"), round($rest));
227
+				$dataseries[] = array($langs->trans("Other"), round($rest));
228 228
 			}
229 229
 			include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
230 230
 			$dolgraph = new DolGraph();
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				$obj = $db->fetch_object($result);
244 244
 
245 245
 				print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
246
-				$total+=$obj->nb;
246
+				$total += $obj->nb;
247 247
 				$i++;
248 248
 			}
249 249
 		}
@@ -263,20 +263,20 @@  discard block
 block discarded – undo
263 263
 /*
264 264
  * Last third parties modified
265 265
  */
266
-$max=15;
266
+$max = 15;
267 267
 $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
268
-$sql.= ", s.code_client";
269
-$sql.= ", s.code_fournisseur";
270
-$sql.= ", s.logo";
271
-$sql.= ", s.canvas, s.tms as datem, s.status as status";
272
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
273
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
274
-$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
275
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
276
-if ($socid)	$sql.= " AND s.rowid = ".$socid;
277
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)";
278
-$sql.= $db->order("s.tms","DESC");
279
-$sql.= $db->plimit($max,0);
268
+$sql .= ", s.code_client";
269
+$sql .= ", s.code_fournisseur";
270
+$sql .= ", s.logo";
271
+$sql .= ", s.canvas, s.tms as datem, s.status as status";
272
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
273
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
274
+$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
275
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
276
+if ($socid)	$sql .= " AND s.rowid = ".$socid;
277
+if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
278
+$sql .= $db->order("s.tms", "DESC");
279
+$sql .= $db->plimit($max, 0);
280 280
 
281 281
 //print $sql;
282 282
 $result = $db->query($sql);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
     if ($num > 0)
290 290
     {
291
-        $transRecordedType = $langs->trans("LastModifiedThirdParties",$max);
291
+        $transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
292 292
 
293 293
         print "\n<!-- last thirdparties modified -->\n";
294 294
         print '<div class="div-table-responsive-no-min">';
@@ -303,16 +303,16 @@  discard block
 block discarded – undo
303 303
         {
304 304
             $objp = $db->fetch_object($result);
305 305
 
306
-            $thirdparty_static->id=$objp->rowid;
307
-            $thirdparty_static->name=$objp->name;
308
-            $thirdparty_static->client=$objp->client;
309
-            $thirdparty_static->fournisseur=$objp->fournisseur;
306
+            $thirdparty_static->id = $objp->rowid;
307
+            $thirdparty_static->name = $objp->name;
308
+            $thirdparty_static->client = $objp->client;
309
+            $thirdparty_static->fournisseur = $objp->fournisseur;
310 310
             $thirdparty_static->logo = $objp->logo;
311
-            $thirdparty_static->datem=$db->jdate($objp->datem);
312
-            $thirdparty_static->status=$objp->status;
311
+            $thirdparty_static->datem = $db->jdate($objp->datem);
312
+            $thirdparty_static->status = $objp->status;
313 313
             $thirdparty_static->code_client = $objp->code_client;
314 314
             $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
315
-            $thirdparty_static->canvas=$objp->canvas;
315
+            $thirdparty_static->canvas = $objp->canvas;
316 316
             $thirdparty_static->email = $objp->email;
317 317
 
318 318
             print '<tr class="oddeven">';
@@ -322,27 +322,27 @@  discard block
 block discarded – undo
322 322
             print "</td>\n";
323 323
             // Type
324 324
             print '<td align="center">';
325
-            if ($thirdparty_static->client==1 || $thirdparty_static->client==3)
325
+            if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3)
326 326
             {
327
-            	$thirdparty_static->name=$langs->trans("Customer");
328
-            	print $thirdparty_static->getNomUrl(0,'customer',0,1);
327
+            	$thirdparty_static->name = $langs->trans("Customer");
328
+            	print $thirdparty_static->getNomUrl(0, 'customer', 0, 1);
329 329
             }
330 330
             if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
331
-            if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
331
+            if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
332 332
             {
333
-            	$thirdparty_static->name=$langs->trans("Prospect");
334
-            	print $thirdparty_static->getNomUrl(0,'prospect',0,1);
333
+            	$thirdparty_static->name = $langs->trans("Prospect");
334
+            	print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1);
335 335
             }
336
-            if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
336
+            if (!empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
337 337
             {
338 338
                 if ($thirdparty_static->client) print " / ";
339
-            	$thirdparty_static->name=$langs->trans("Supplier");
340
-            	print $thirdparty_static->getNomUrl(0,'supplier',0,1);
339
+            	$thirdparty_static->name = $langs->trans("Supplier");
340
+            	print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1);
341 341
             }
342 342
             print '</td>';
343 343
             // Last modified date
344 344
             print '<td align="right">';
345
-            print dol_print_date($thirdparty_static->datem,'day');
345
+            print dol_print_date($thirdparty_static->datem, 'day');
346 346
             print "</td>";
347 347
             print '<td align="right" class="nowrap">';
348 348
             print $thirdparty_static->getLibStatut(3);
Please login to merge, or discard this patch.
Braces   +67 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@  discard block
 block discarded – undo
32 32
 $langs->load("companies");
33 33
 
34 34
 $socid = GETPOST('socid','int');
35
-if ($user->societe_id) $socid=$user->societe_id;
35
+if ($user->societe_id) {
36
+    $socid=$user->societe_id;
37
+}
36 38
 
37 39
 // Security check
38 40
 $result=restrictedArea($user,'societe',0,'','','','');
@@ -57,12 +59,14 @@  discard block
 block discarded – undo
57 59
 print '<div class="fichecenter"><div class="fichethirdleft">';
58 60
 
59 61
 
60
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
62
+if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) {
63
+    // This is useless due to the global search combo
61 64
 {
62 65
     // Search thirdparty
63 66
     if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
64 67
     {
65 68
     	$listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty');
69
+}
66 70
     }
67 71
     // Search contact/address
68 72
     if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
@@ -78,10 +82,14 @@  discard block
 block discarded – undo
78 82
     	$i=0;
79 83
     	foreach($listofsearchfields as $key => $value)
80 84
     	{
81
-    		if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>';
85
+    		if ($i == 0) {
86
+    		    print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>';
87
+    		}
82 88
     		print '<tr '.$bc[false].'>';
83 89
     		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
84
-    		if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
90
+    		if ($i == 0) {
91
+    		    print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
92
+    		}
85 93
     		print '</tr>';
86 94
     		$i++;
87 95
     	}
@@ -106,11 +114,20 @@  discard block
 block discarded – undo
106 114
 
107 115
 $sql = "SELECT s.rowid, s.client, s.fournisseur";
108 116
 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
109
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
117
+if (! $user->rights->societe->client->voir && ! $socid) {
118
+    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
119
+}
110 120
 $sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
111
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
112
-if ($socid)	$sql.= " AND s.rowid = ".$socid;
113
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";    // client=0, fournisseur=0 must be visible
121
+if (! $user->rights->societe->client->voir && ! $socid) {
122
+    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
123
+}
124
+if ($socid) {
125
+    $sql.= " AND s.rowid = ".$socid;
126
+}
127
+if (! $user->rights->fournisseur->lire) {
128
+    $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";
129
+}
130
+// client=0, fournisseur=0 must be visible
114 131
 //print $sql;
115 132
 $result = $db->query($sql);
116 133
 if ($result)
@@ -122,10 +139,13 @@  discard block
 block discarded – undo
122 139
         if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; }
123 140
         if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; }
124 141
         if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; }
125
-        if ($found) $total++;
142
+        if ($found) {
143
+            $total++;
144
+        }
126 145
     }
146
+} else {
147
+    dol_print_error($db);
127 148
 }
128
-else dol_print_error($db);
129 149
 
130 150
 print '<div class="div-table-responsive-no-min">';
131 151
 print '<table class="noborder nohover" width="100%">'."\n";
@@ -134,10 +154,18 @@  discard block
 block discarded – undo
134 154
 {
135 155
     print '<tr><td align="center" colspan="2">';
136 156
     $dataseries=array();
137
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))     $dataseries[]=array($langs->trans("Prospects"), round($third['prospect']));
138
-    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))     $dataseries[]=array($langs->trans("Customers"), round($third['customer']));
139
-    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier']));
140
-    if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other']));
157
+    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
158
+        $dataseries[]=array($langs->trans("Prospects"), round($third['prospect']));
159
+    }
160
+    if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
161
+        $dataseries[]=array($langs->trans("Customers"), round($third['customer']));
162
+    }
163
+    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
164
+        $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier']));
165
+    }
166
+    if (! empty($conf->societe->enabled)) {
167
+        $dataseries[]=array($langs->trans("Others"), round($third['other']));
168
+    }
141 169
     include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
142 170
     $dolgraph = new DolGraph();
143 171
 	$dolgraph->SetData($dataseries);
@@ -148,8 +176,7 @@  discard block
 block discarded – undo
148 176
 	$dolgraph->draw('idgraphthirdparties');
149 177
 	print $dolgraph->show();
150 178
     print '</td></tr>'."\n";
151
-}
152
-else
179
+} else
153 180
 {
154 181
     if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
155 182
     {
@@ -193,7 +220,9 @@  discard block
 block discarded – undo
193 220
 	$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
194 221
 	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
195 222
 	$sql.= " WHERE c.type = 2";
196
-	if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
223
+	if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
224
+	    $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
225
+	}
197 226
 	$sql.= " AND c.entity IN (".getEntity('category').")";
198 227
 	$sql.= " GROUP BY c.label";
199 228
 	$total=0;
@@ -214,8 +243,7 @@  discard block
 block discarded – undo
214 243
 				if ($i < $nbmax)
215 244
 				{
216 245
 					$dataseries[]=array($obj->label, round($obj->nb));
217
-				}
218
-				else
246
+				} else
219 247
 				{
220 248
 					$rest+=$obj->nb;
221 249
 				}
@@ -235,8 +263,7 @@  discard block
 block discarded – undo
235 263
 			$dolgraph->setWidth('100%');
236 264
 			$dolgraph->draw('idgraphcateg');
237 265
 			print $dolgraph->show();
238
-		}
239
-		else
266
+		} else
240 267
 		{
241 268
 			while ($i < $num)
242 269
 			{
@@ -270,11 +297,19 @@  discard block
 block discarded – undo
270 297
 $sql.= ", s.logo";
271 298
 $sql.= ", s.canvas, s.tms as datem, s.status as status";
272 299
 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
273
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
300
+if (! $user->rights->societe->client->voir && ! $socid) {
301
+    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
302
+}
274 303
 $sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
275
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
276
-if ($socid)	$sql.= " AND s.rowid = ".$socid;
277
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)";
304
+if (! $user->rights->societe->client->voir && ! $socid) {
305
+    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
306
+}
307
+if ($socid) {
308
+    $sql.= " AND s.rowid = ".$socid;
309
+}
310
+if (! $user->rights->fournisseur->lire) {
311
+    $sql.=" AND (s.fournisseur != 1 OR s.client != 0)";
312
+}
278 313
 $sql.= $db->order("s.tms","DESC");
279 314
 $sql.= $db->plimit($max,0);
280 315
 
@@ -327,7 +362,9 @@  discard block
 block discarded – undo
327 362
             	$thirdparty_static->name=$langs->trans("Customer");
328 363
             	print $thirdparty_static->getNomUrl(0,'customer',0,1);
329 364
             }
330
-            if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
365
+            if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
366
+                print " / ";
367
+            }
331 368
             if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
332 369
             {
333 370
             	$thirdparty_static->name=$langs->trans("Prospect");
@@ -335,7 +372,9 @@  discard block
 block discarded – undo
335 372
             }
336 373
             if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
337 374
             {
338
-                if ($thirdparty_static->client) print " / ";
375
+                if ($thirdparty_static->client) {
376
+                    print " / ";
377
+                }
339 378
             	$thirdparty_static->name=$langs->trans("Supplier");
340 379
             	print $thirdparty_static->getNomUrl(0,'supplier',0,1);
341 380
             }
@@ -357,8 +396,7 @@  discard block
 block discarded – undo
357 396
         print '</div>';
358 397
         print "<!-- End last thirdparties modified -->\n";
359 398
     }
360
-}
361
-else
399
+} else
362 400
 {
363 401
     dol_print_error($db);
364 402
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/price.php 3 patches
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.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
  */
28 28
 
29 29
 require '../main.inc.php';
30
-require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
31
-require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
33
-require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
30
+require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
31
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
32
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
34 34
 
35
-if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
36
-	require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
35
+if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
36
+	require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
37 37
 
38 38
 	$prodcustprice = new Productcustomerprice($db);
39 39
 }
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 $langs->loadLangs(array("products", "companies", "bills"));
42 42
 
43 43
 $action = GETPOST('action', 'alpha');
44
-$search_prod = GETPOST('search_prod','alpha');
45
-$cancel = GETPOST('cancel','alpha');
44
+$search_prod = GETPOST('search_prod', 'alpha');
45
+$cancel = GETPOST('cancel', 'alpha');
46 46
 
47 47
 // Security check
48
-$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
48
+$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
49 49
 if ($user->societe_id)
50 50
 	$socid = $user->societe_id;
51 51
 $result = restrictedArea($user, 'societe', $socid, '&societe');
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 $object = new Societe($db);
54 54
 
55 55
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
56
-$hookmanager->initHooks(array('thirdpartycustomerprice','globalcard'));
56
+$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard'));
57 57
 
58 58
 
59 59
 
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
  * Actions
62 62
  */
63 63
 
64
-$parameters=array('id'=>$socid);
65
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
64
+$parameters = array('id'=>$socid);
65
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
66 66
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
67 67
 
68 68
 if (empty($reshook))
69 69
 {
70
-    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers
70
+    if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
71 71
     {
72 72
         $search_prod = '';
73 73
     }
74 74
 
75
-    if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
75
+    if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
76 76
 
77 77
     	$update_child_soc = GETPOST('updatechildprice');
78 78
 
@@ -83,25 +83,25 @@  discard block
 block discarded – undo
83 83
     	$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
84 84
     	$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
85 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)'
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 87
 
88 88
     	// We must define tva_tx, npr and local taxes
89 89
     	$vatratecode = '';
90
-    	$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
90
+    	$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
91 91
     	$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
92 92
     	$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
93 93
     	// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
94 94
     	if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
95 95
     	{
96 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];
97
+    	    $vatratecode = $reg[1];
98 98
     	    // Get record from code
99 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);
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 105
     	    if ($resql)
106 106
     	    {
107 107
     	        $obj = $db->fetch_object($resql);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     	$action = '';
146 146
     }
147 147
 
148
-    if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
148
+    if ($action == 'update_customer_price_confirm' && !$_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
149 149
 
150 150
     	$prodcustprice->fetch(GETPOST('lineid', 'int'));
151 151
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 $object = new Societe($db);
180 180
 
181 181
 $result = $object->fetch($socid);
182
-llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer'));
182
+llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
183 183
 
184
-if (! empty($conf->notification->enabled))
184
+if (!empty($conf->notification->enabled))
185 185
 	$langs->load("mails");
186 186
 $head = societe_prepare_head($object);
187 187
 
@@ -189,33 +189,33 @@  discard block
 block discarded – undo
189 189
 
190 190
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
191 191
 
192
-dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
192
+dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
193 193
 
194 194
 print '<div class="fichecenter">';
195 195
 
196 196
 print '<div class="underbanner clearboth"></div>';
197 197
 print '<table class="border centpercent">';
198 198
 
199
-if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
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 205
 	print '<tr><td class="titlefield">';
206
-	print $langs->trans('CustomerCode') . '</td><td colspan="3">';
206
+	print $langs->trans('CustomerCode').'</td><td colspan="3">';
207 207
 	print $object->code_client;
208 208
 	if ($object->check_codeclient() != 0)
209
-		print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
209
+		print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
210 210
 	print '</td></tr>';
211 211
 }
212 212
 
213 213
 if ($object->fournisseur) {
214 214
 	print '<tr><td class="titlefield">';
215
-	print $langs->trans('SupplierCode') . '</td><td colspan="3">';
215
+	print $langs->trans('SupplierCode').'</td><td colspan="3">';
216 216
 	print $object->code_fournisseur;
217 217
 	if ($object->check_codefournisseur() != 0)
218
-		print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
218
+		print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
219 219
 	print '</td></tr>';
220 220
 }
221 221
 
@@ -227,29 +227,29 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
 
230
-if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
230
+if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
231 231
 
232 232
 	$prodcustprice = new Productcustomerprice($db);
233 233
 
234 234
 	$sortfield = GETPOST("sortfield", 'alpha');
235 235
 	$sortorder = GETPOST("sortorder", 'alpha');
236
-    $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
236
+    $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
237 237
 	$page = GETPOST("page", 'int');
238 238
 	if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
239 239
 	$offset = $limit * $page;
240 240
 	$pageprev = $page - 1;
241 241
 	$pagenext = $page + 1;
242
-	if (! $sortorder)
242
+	if (!$sortorder)
243 243
 		$sortorder = "ASC";
244
-	if (! $sortfield)
244
+	if (!$sortfield)
245 245
 		$sortfield = "soc.nom";
246 246
 
247 247
 		// Build filter to diplay only concerned lines
248
-	$filter = array (
248
+	$filter = array(
249 249
 		't.fk_soc' => $object->id
250 250
 	);
251 251
 
252
-	if (! empty($search_prod)) {
252
+	if (!empty($search_prod)) {
253 253
 		$filter ['prod.ref'] = $search_prod;
254 254
 	}
255 255
 
@@ -259,20 +259,20 @@  discard block
 block discarded – undo
259 259
 
260 260
 		print load_fiche_titre($langs->trans('PriceByCustomer'));
261 261
 
262
-		print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
263
-		print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
262
+		print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
263
+		print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">';
264 264
 		print '<input type="hidden" name="action" value="add_customer_price_confirm">';
265
-		print '<input type="hidden" name="socid" value="' . $object->id . '">';
265
+		print '<input type="hidden" name="socid" value="'.$object->id.'">';
266 266
 		print '<table class="border" width="100%">';
267 267
 		print '<tr>';
268
-		print '<td>' . $langs->trans('Product') . '</td>';
268
+		print '<td>'.$langs->trans('Product').'</td>';
269 269
 		print '<td>';
270 270
 		print $form->select_produits('', 'prodid', '', 0);
271 271
 		print '</td>';
272 272
 		print '</tr>';
273 273
 
274 274
 		// VAT
275
-		print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
275
+		print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
276 276
 		print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
277 277
 		print '</td></tr>';
278 278
 
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
292 292
 		print '</td><td>';
293 293
 		if ($object->price_base_type == 'TTC') {
294
-			print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
294
+			print '<input name="price" size="10" value="'.price($object->price_ttc).'">';
295 295
 		} else {
296
-			print '<input name="price" size="10" value="' . price($object->price) . '">';
296
+			print '<input name="price" size="10" value="'.price($object->price).'">';
297 297
 		}
298 298
 		print '</td></tr>';
299 299
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 		$text = $langs->trans('MinPrice');
303 303
 		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
304 304
 		if ($object->price_base_type == 'TTC') {
305
-			print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
305
+			print '<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).'">';
306 306
 		} else {
307
-			print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
307
+			print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">';
308 308
 		}
309 309
 		print '</td></tr>';
310 310
 
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 		print '</table>';
321 321
 
322 322
 		print '<br><div align="center">';
323
-		print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
323
+		print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
324 324
 		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
325
-		print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
325
+		print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
326 326
 		print '</div>';
327 327
 
328 328
 		print '<br></form>';
@@ -338,20 +338,20 @@  discard block
 block discarded – undo
338 338
 			setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
339 339
 		}
340 340
 
341
-		print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
342
-		print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
341
+		print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
342
+		print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">';
343 343
 		print '<input type="hidden" name="action" value="update_customer_price_confirm">';
344
-		print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
344
+		print '<input type="hidden" name="lineid" value="'.$prodcustprice->id.'">';
345 345
 		print '<table class="border" width="100%">';
346 346
 		print '<tr>';
347
-		print '<td>' . $langs->trans('Product') . '</td>';
347
+		print '<td>'.$langs->trans('Product').'</td>';
348 348
 		$staticprod = new Product($db);
349 349
 		$staticprod->fetch($prodcustprice->fk_product);
350
-		print "<td>" . $staticprod->getNomUrl(1) . "</td>";
350
+		print "<td>".$staticprod->getNomUrl(1)."</td>";
351 351
 		print '</tr>';
352 352
 
353 353
 		// VAT
354
-		print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
354
+		print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
355 355
 		print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
356 356
 		print '</td></tr>';
357 357
 
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
371 371
 		print '</td><td>';
372 372
 		if ($prodcustprice->price_base_type == 'TTC') {
373
-			print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">';
373
+			print '<input name="price" size="10" value="'.price($prodcustprice->price_ttc).'">';
374 374
 		} else {
375
-			print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
375
+			print '<input name="price" size="10" value="'.price($prodcustprice->price).'">';
376 376
 		}
377 377
 		print '</td></tr>';
378 378
 
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 		print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
383 383
 		print '</td><td>';
384 384
 		if ($prodcustprice->price_base_type == 'TTC') {
385
-			print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
385
+			print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).'">';
386 386
 		} else {
387
-			print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
387
+			print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min).'">';
388 388
 		}
389 389
 		print '</td></tr>';
390 390
 
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 		print '</table>';
401 401
 
402 402
 		print '<br><div class="center">';
403
-		print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
403
+		print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
404 404
 		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
405
-		print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
405
+		print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
406 406
 		print '</div>';
407 407
 
408 408
 		print '<br></form>';
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 
411 411
 	    print '<!-- showlog_customer_price -->'."\n";
412 412
 
413
-		$filter = array (
414
-			't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
413
+		$filter = array(
414
+			't.fk_product' => GETPOST('prodid', 'int'), 't.fk_soc' => $socid
415 415
 		);
416 416
 
417 417
 		// Count total nb of records
@@ -426,45 +426,45 @@  discard block
 block discarded – undo
426 426
 			setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
427 427
 		}
428 428
 
429
-		$option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
429
+		$option = '&socid='.GETPOST('socid', 'int').'&prodid='.GETPOST('prodid', 'int');
430 430
 
431 431
 		print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
432 432
 
433 433
 		if (count($prodcustprice->lines) > 0) {
434 434
 
435
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
436
-			print '<input type="hidden" name="id" value="' . $object->id . '">';
435
+			print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
436
+			print '<input type="hidden" name="id" value="'.$object->id.'">';
437 437
 
438 438
 			print '<table class="noborder" width="100%">';
439 439
 
440 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>';
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 450
 			print '<td>&nbsp;</td>';
451 451
 			print '</tr>';
452 452
 
453
-			foreach ( $prodcustprice->lines as $line ) {
453
+			foreach ($prodcustprice->lines as $line) {
454 454
 
455 455
 				print '<tr class="oddeven">';
456 456
 				$staticprod = new Product($db);
457 457
 				$staticprod->fetch($line->fk_product);
458 458
 
459
-				print "<td>" . $staticprod->getNomUrl(1) . "</td>";
460
-				print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
459
+				print "<td>".$staticprod->getNomUrl(1)."</td>";
460
+				print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
461 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>';
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 468
 
469 469
 				// User
470 470
 				$userstatic = new User($db);
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 			print $langs->trans('None');
481 481
 		}
482 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>';
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 485
 		print "\n</div><br>\n";
486 486
 	}
487 487
 	else
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
 		/*                                                                            */
495 495
 		/* ************************************************************************** */
496 496
 
497
-		print "\n" . '<div class="tabsAction">' . "\n";
497
+		print "\n".'<div class="tabsAction">'."\n";
498 498
 
499 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>';
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 501
 		}
502 502
 		print "\n</div>\n";
503 503
 
@@ -515,38 +515,38 @@  discard block
 block discarded – undo
515 515
             setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
516 516
         }
517 517
 
518
-        $option = '&search_prod=' . $search_prod . '&id=' . $object->id;
518
+        $option = '&search_prod='.$search_prod.'&id='.$object->id;
519 519
 
520 520
 	    print '<!-- view specific price for each product -->'."\n";
521 521
 
522 522
 	    print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
523 523
 
524
-        print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
525
-        print '<input type="hidden" name="id" value="' . $object->id . '">';
524
+        print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
525
+        print '<input type="hidden" name="id" value="'.$object->id.'">';
526 526
 
527 527
         print '<table class="noborder" width="100%">';
528 528
 
529 529
         print '<tr class="liste_titre">';
530
-        print '<td>' . $langs->trans("Product") . '</td>';
531
-        print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
532
-        print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
533
-        print '<td align="right">' . $langs->trans("VAT") . '</td>';
534
-        print '<td align="right">' . $langs->trans("HT") . '</td>';
535
-        print '<td align="right">' . $langs->trans("TTC") . '</td>';
536
-        print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
537
-        print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
538
-        print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
530
+        print '<td>'.$langs->trans("Product").'</td>';
531
+        print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
532
+        print '<td align="center">'.$langs->trans("PriceBase").'</td>';
533
+        print '<td align="right">'.$langs->trans("VAT").'</td>';
534
+        print '<td align="right">'.$langs->trans("HT").'</td>';
535
+        print '<td align="right">'.$langs->trans("TTC").'</td>';
536
+        print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
537
+        print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
538
+        print '<td align="right">'.$langs->trans("ChangedBy").'</td>';
539 539
         print '<td>&nbsp;</td>';
540 540
         print '</tr>';
541 541
 
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">';
549
-            $searchpicto=$form->showFilterAndCheckAddButtons(0);
549
+            $searchpicto = $form->showFilterAndCheckAddButtons(0);
550 550
             print $searchpicto;
551 551
             print '</td>';
552 552
             print '</tr>';
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
                 $staticprod = new Product($db);
562 562
                 $staticprod->fetch($line->fk_product);
563 563
 
564
-                print "<td>" . $staticprod->getNomUrl(1) . "</td>";
565
-                print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
564
+                print "<td>".$staticprod->getNomUrl(1)."</td>";
565
+                print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
566 566
 
567
-                print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
568
-                print '<td align="right">' . vatrate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), true, $line->recuperableonly) . "</td>";
569
-                print '<td align="right">' . price($line->price) . "</td>";
570
-                print '<td align="right">' . price($line->price_ttc) . "</td>";
571
-                print '<td align="right">' . price($line->price_min) . '</td>';
572
-                print '<td align="right">' . price($line->price_min_ttc) . '</td>';
567
+                print '<td align="center">'.$langs->trans($line->price_base_type)."</td>";
568
+                print '<td align="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
569
+                print '<td align="right">'.price($line->price)."</td>";
570
+                print '<td align="right">'.price($line->price_ttc)."</td>";
571
+                print '<td align="right">'.price($line->price_min).'</td>';
572
+                print '<td align="right">'.price($line->price_min_ttc).'</td>';
573 573
 
574 574
                 // User
575 575
                 $userstatic = new User($db);
@@ -582,15 +582,15 @@  discard block
 block discarded – undo
582 582
                 if ($user->rights->produit->creer || $user->rights->service->creer)
583 583
                 {
584 584
                     print '<td align="right">';
585
-                    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $object->id . '&amp;prodid=' . $line->fk_product . '">';
585
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">';
586 586
                     print img_info();
587 587
                     print '</a>';
588 588
                     print ' ';
589
-                    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
589
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
590 590
                     print img_edit('default', 0, 'style="vertical-align: middle;"');
591 591
                     print '</a>';
592 592
                     print ' ';
593
-                    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
593
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
594 594
                     print img_delete('default', 'style="vertical-align: middle;"');
595 595
                     print '</a>';
596 596
                     print '</td>';
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
         }
602 602
         else
603 603
         {
604
-            $colspan=9;
605
-            if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1;
606
-            print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>';
604
+            $colspan = 9;
605
+            if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1;
606
+            print '<tr '.$bc[false].'><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
607 607
         }
608 608
 
609 609
         print "</table>";
Please login to merge, or discard this patch.
Braces   +31 added lines, -20 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 
47 47
 // Security check
48 48
 $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
49
-if ($user->societe_id)
49
+if ($user->societe_id) {
50 50
 	$socid = $user->societe_id;
51
+}
51 52
 $result = restrictedArea($user, 'societe', $socid, '&societe');
52 53
 
53 54
 $object = new Societe($db);
@@ -63,14 +64,18 @@  discard block
 block discarded – undo
63 64
 
64 65
 $parameters=array('id'=>$socid);
65 66
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
66
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
67
+if ($reshook < 0) {
68
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
69
+}
67 70
 
68 71
 if (empty($reshook))
69 72
 {
70
-    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers
73
+    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) {
74
+        // Both test are required to be compatible with all browsers
71 75
     {
72 76
         $search_prod = '';
73 77
     }
78
+    }
74 79
 
75 80
     if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
76 81
 
@@ -181,8 +186,9 @@  discard block
 block discarded – undo
181 186
 $result = $object->fetch($socid);
182 187
 llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer'));
183 188
 
184
-if (! empty($conf->notification->enabled))
189
+if (! empty($conf->notification->enabled)) {
185 190
 	$langs->load("mails");
191
+}
186 192
 $head = societe_prepare_head($object);
187 193
 
188 194
 dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
@@ -196,17 +202,20 @@  discard block
 block discarded – undo
196 202
 print '<div class="underbanner clearboth"></div>';
197 203
 print '<table class="border centpercent">';
198 204
 
199
-if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
205
+if (! empty($conf->global->SOCIETE_USEPREFIX)) {
206
+    // Old not used prefix field
200 207
 {
201 208
 	print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>';
202 209
 }
210
+}
203 211
 
204 212
 if ($object->client) {
205 213
 	print '<tr><td class="titlefield">';
206 214
 	print $langs->trans('CustomerCode') . '</td><td colspan="3">';
207 215
 	print $object->code_client;
208
-	if ($object->check_codeclient() != 0)
209
-		print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
216
+	if ($object->check_codeclient() != 0) {
217
+			print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
218
+	}
210 219
 	print '</td></tr>';
211 220
 }
212 221
 
@@ -214,8 +223,9 @@  discard block
 block discarded – undo
214 223
 	print '<tr><td class="titlefield">';
215 224
 	print $langs->trans('SupplierCode') . '</td><td colspan="3">';
216 225
 	print $object->code_fournisseur;
217
-	if ($object->check_codefournisseur() != 0)
218
-		print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
226
+	if ($object->check_codefournisseur() != 0) {
227
+			print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
228
+	}
219 229
 	print '</td></tr>';
220 230
 }
221 231
 
@@ -239,10 +249,12 @@  discard block
 block discarded – undo
239 249
 	$offset = $limit * $page;
240 250
 	$pageprev = $page - 1;
241 251
 	$pagenext = $page + 1;
242
-	if (! $sortorder)
243
-		$sortorder = "ASC";
244
-	if (! $sortfield)
245
-		$sortfield = "soc.nom";
252
+	if (! $sortorder) {
253
+			$sortorder = "ASC";
254
+	}
255
+	if (! $sortfield) {
256
+			$sortfield = "soc.nom";
257
+	}
246 258
 
247 259
 		// Build filter to diplay only concerned lines
248 260
 	$filter = array (
@@ -474,8 +486,7 @@  discard block
 block discarded – undo
474 486
 				print '</td>';
475 487
 			}
476 488
 			print "</table>";
477
-		}
478
-		else
489
+		} else
479 490
 		{
480 491
 			print $langs->trans('None');
481 492
 		}
@@ -483,8 +494,7 @@  discard block
 block discarded – undo
483 494
 		print "\n" . '<div class="tabsAction">' . "\n";
484 495
 		print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
485 496
 		print "\n</div><br>\n";
486
-	}
487
-	else
497
+	} else
488 498
 	{
489 499
         // View mode
490 500
 
@@ -598,11 +608,12 @@  discard block
 block discarded – undo
598 608
 
599 609
                 print "</tr>\n";
600 610
             }
601
-        }
602
-        else
611
+        } else
603 612
         {
604 613
             $colspan=9;
605
-            if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1;
614
+            if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
615
+                $colspan+=1;
616
+            }
606 617
             print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>';
607 618
         }
608 619
 
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/contact.php 3 patches
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.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43 43
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
44 44
 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45
-if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
45
+if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
46 46
 
47
-$langs->loadLangs(array("companies","commercial","bills","banks","users"));
48
-if (! empty($conf->categorie->enabled)) $langs->load("categories");
49
-if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
50
-if (! empty($conf->notification->enabled)) $langs->load("mails");
47
+$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
48
+if (!empty($conf->categorie->enabled)) $langs->load("categories");
49
+if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
50
+if (!empty($conf->notification->enabled)) $langs->load("mails");
51 51
 
52
-$mesg=''; $error=0; $errors=array();
52
+$mesg = ''; $error = 0; $errors = array();
53 53
 
54
-$action		= (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view');
55
-$cancel     = GETPOST('cancel','alpha');
56
-$backtopage = GETPOST('backtopage','alpha');
54
+$action		= (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view');
55
+$cancel     = GETPOST('cancel', 'alpha');
56
+$backtopage = GETPOST('backtopage', 'alpha');
57 57
 $confirm	= GETPOST('confirm');
58
-$socid		= GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int');
59
-if ($user->societe_id) $socid=$user->societe_id;
60
-if (empty($socid) && $action == 'view') $action='create';
58
+$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
59
+if ($user->societe_id) $socid = $user->societe_id;
60
+if (empty($socid) && $action == 'view') $action = 'create';
61 61
 
62 62
 $object = new Societe($db);
63 63
 $extrafields = new ExtraFields($db);
64 64
 
65 65
 // fetch optionals attributes and labels
66
-$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
66
+$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
67 67
 
68 68
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
69
-$hookmanager->initHooks(array('thirdpartycontact','globalcard'));
69
+$hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
70 70
 
71
-if ($action == 'view' && $object->fetch($socid)<=0)
71
+if ($action == 'view' && $object->fetch($socid) <= 0)
72 72
 {
73 73
 	$langs->load("errors");
74 74
 	print($langs->trans('ErrorRecordNotFound'));
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 
78 78
 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
79 79
 $object->getCanvas($socid);
80
-$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
81
-$objcanvas=null;
82
-if (! empty($canvas))
80
+$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
81
+$objcanvas = null;
82
+if (!empty($canvas))
83 83
 {
84 84
     require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
85 85
     $objcanvas = new Canvas($db, $action);
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
  * Actions
97 97
  */
98 98
 
99
-$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
100
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
99
+$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
100
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
101 101
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
102 102
 
103 103
 if (empty($reshook))
104 104
 {
105 105
 	if ($cancel)
106 106
     {
107
-        $action='';
108
-        if (! empty($backtopage))
107
+        $action = '';
108
+        if (!empty($backtopage))
109 109
         {
110 110
             header("Location: ".$backtopage);
111 111
             exit;
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 
129 129
 if ($socid > 0 && empty($object->id))
130 130
 {
131
-    $result=$object->fetch($socid);
132
-	if ($result <= 0) dol_print_error('',$object->error);
131
+    $result = $object->fetch($socid);
132
+	if ($result <= 0) dol_print_error('', $object->error);
133 133
 }
134 134
 
135
-$title=$langs->trans("ThirdParty");
136
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card');
137
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
138
-llxHeader('',$title,$help_url);
135
+$title = $langs->trans("ThirdParty");
136
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card');
137
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
138
+llxHeader('', $title, $help_url);
139 139
 
140
-$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
140
+$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
141 141
 
142 142
 
143
-if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels);
143
+if (!empty($object->id)) $res = $object->fetch_optionals($object->id, $extralabels);
144 144
 //if ($res < 0) { dol_print_error($db); exit; }
145 145
 
146 146
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
152 152
 
153
-dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
153
+dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
154 154
 
155 155
 dol_fiche_end();
156 156
 
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 	// Contacts list
162 162
 	if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
163 163
 	{
164
-		$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
164
+		$result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
165 165
 	}
166 166
 
167 167
 	// Addresses list
168
-	if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
168
+	if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
169 169
 	{
170
-		$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
170
+		$result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
171 171
 	}
172 172
 }
173 173
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,12 +42,20 @@  discard block
 block discarded – undo
42 42
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43 43
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
44 44
 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45
-if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
45
+if (! empty($conf->adherent->enabled)) {
46
+    require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
47
+}
46 48
 
47 49
 $langs->loadLangs(array("companies","commercial","bills","banks","users"));
48
-if (! empty($conf->categorie->enabled)) $langs->load("categories");
49
-if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
50
-if (! empty($conf->notification->enabled)) $langs->load("mails");
50
+if (! empty($conf->categorie->enabled)) {
51
+    $langs->load("categories");
52
+}
53
+if (! empty($conf->incoterm->enabled)) {
54
+    $langs->load("incoterm");
55
+}
56
+if (! empty($conf->notification->enabled)) {
57
+    $langs->load("mails");
58
+}
51 59
 
52 60
 $mesg=''; $error=0; $errors=array();
53 61
 
@@ -56,8 +64,12 @@  discard block
 block discarded – undo
56 64
 $backtopage = GETPOST('backtopage','alpha');
57 65
 $confirm	= GETPOST('confirm');
58 66
 $socid		= GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int');
59
-if ($user->societe_id) $socid=$user->societe_id;
60
-if (empty($socid) && $action == 'view') $action='create';
67
+if ($user->societe_id) {
68
+    $socid=$user->societe_id;
69
+}
70
+if (empty($socid) && $action == 'view') {
71
+    $action='create';
72
+}
61 73
 
62 74
 $object = new Societe($db);
63 75
 $extrafields = new ExtraFields($db);
@@ -98,7 +110,9 @@  discard block
 block discarded – undo
98 110
 
99 111
 $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
100 112
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
101
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113
+if ($reshook < 0) {
114
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
115
+}
102 116
 
103 117
 if (empty($reshook))
104 118
 {
@@ -129,18 +143,24 @@  discard block
 block discarded – undo
129 143
 if ($socid > 0 && empty($object->id))
130 144
 {
131 145
     $result=$object->fetch($socid);
132
-	if ($result <= 0) dol_print_error('',$object->error);
133
-}
146
+	if ($result <= 0) {
147
+	    dol_print_error('',$object->error);
148
+	}
149
+	}
134 150
 
135 151
 $title=$langs->trans("ThirdParty");
136
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card');
152
+if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) {
153
+    $title=$object->name." - ".$langs->trans('Card');
154
+}
137 155
 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
138 156
 llxHeader('',$title,$help_url);
139 157
 
140 158
 $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
141 159
 
142 160
 
143
-if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels);
161
+if (!empty($object->id)) {
162
+    $res=$object->fetch_optionals($object->id,$extralabels);
163
+}
144 164
 //if ($res < 0) { dol_print_error($db); exit; }
145 165
 
146 166
 
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/list.php 3 patches
Indentation   +597 added lines, -597 removed lines patch added patch discarded remove patch
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
 
126 126
 // List of fields to search into when doing a "search in all"
127 127
 $fieldstosearchall = array(
128
-	's.nom'=>"ThirdPartyName",
129
-	's.name_alias'=>"AliasNameShort",
130
-	's.code_client'=>"CustomerCode",
131
-	's.code_fournisseur'=>"SupplierCode",
132
-	's.code_compta'=>"CustomerAccountancyCodeShort",
133
-	's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort",
134
-	's.email'=>"EMail",
135
-	's.url'=>"URL",
136
-	's.tva_intra'=>"VATIntra",
137
-	's.siren'=>"ProfId1",
138
-	's.siret'=>"ProfId2",
139
-	's.ape'=>"ProfId3",
140
-	's.phone'=>"Phone",
141
-	's.fax'=>"Fax",
128
+    's.nom'=>"ThirdPartyName",
129
+    's.name_alias'=>"AliasNameShort",
130
+    's.code_client'=>"CustomerCode",
131
+    's.code_fournisseur'=>"SupplierCode",
132
+    's.code_compta'=>"CustomerAccountancyCodeShort",
133
+    's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort",
134
+    's.email'=>"EMail",
135
+    's.url'=>"URL",
136
+    's.tva_intra'=>"VATIntra",
137
+    's.siren'=>"ProfId1",
138
+    's.siret'=>"ProfId2",
139
+    's.ape'=>"ProfId3",
140
+    's.phone'=>"Phone",
141
+    's.fax'=>"Fax",
142 142
 );
143 143
 if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4';
144 144
 if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5';
@@ -166,47 +166,47 @@  discard block
 block discarded – undo
166 166
 $checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
167 167
 $checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
168 168
 $arrayfields=array(
169
-	's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
170
-	's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
171
-	's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
172
-	's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
173
-	's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode),
174
-	's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
175
-	's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode),
176
-	's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
177
-	's.town'=>array('label'=>"Town", 'checked'=>1),
178
-	's.zip'=>array('label'=>"Zip", 'checked'=>1),
179
-	'state.nom'=>array('label'=>"State", 'checked'=>0),
180
-	'region.nom'=>array('label'=>"Region", 'checked'=>0),
181
-	'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
182
-	's.email'=>array('label'=>"Email", 'checked'=>0),
183
-	's.url'=>array('label'=>"Url", 'checked'=>0),
184
-	's.phone'=>array('label'=>"Phone", 'checked'=>1),
185
-	's.fax'=>array('label'=>"Fax", 'checked'=>0),
186
-	'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
187
-	'staff.code'=>array('label'=>"Staff", 'checked'=>0),
188
-	's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1),
189
-	's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2),
190
-	's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3),
191
-	's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4),
192
-	's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5),
193
-	's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6),
194
-	's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0),
195
-	'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1),
196
-	's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel),
197
-	's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm),
198
-	's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
199
-	's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
200
-	's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
201
-	's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
169
+    's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
170
+    's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
171
+    's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
172
+    's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
173
+    's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode),
174
+    's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
175
+    's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode),
176
+    's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
177
+    's.town'=>array('label'=>"Town", 'checked'=>1),
178
+    's.zip'=>array('label'=>"Zip", 'checked'=>1),
179
+    'state.nom'=>array('label'=>"State", 'checked'=>0),
180
+    'region.nom'=>array('label'=>"Region", 'checked'=>0),
181
+    'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
182
+    's.email'=>array('label'=>"Email", 'checked'=>0),
183
+    's.url'=>array('label'=>"Url", 'checked'=>0),
184
+    's.phone'=>array('label'=>"Phone", 'checked'=>1),
185
+    's.fax'=>array('label'=>"Fax", 'checked'=>0),
186
+    'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
187
+    'staff.code'=>array('label'=>"Staff", 'checked'=>0),
188
+    's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1),
189
+    's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2),
190
+    's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3),
191
+    's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4),
192
+    's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5),
193
+    's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6),
194
+    's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0),
195
+    'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1),
196
+    's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel),
197
+    's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm),
198
+    's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
199
+    's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
200
+    's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
201
+    's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
202 202
 );
203 203
 // Extra fields
204 204
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
205 205
 {
206
-   foreach($extrafields->attribute_label as $key => $val)
207
-   {
208
-		if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
209
-   }
206
+    foreach($extrafields->attribute_label as $key => $val)
207
+    {
208
+        if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
209
+    }
210 210
 }
211 211
 
212 212
 $object = new Societe($db);
@@ -225,67 +225,67 @@  discard block
 block discarded – undo
225 225
 
226 226
 if (empty($reshook))
227 227
 {
228
-	// Selection of new fields
229
-	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
230
-
231
-	// Did we click on purge search criteria ?
232
-	if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
233
-	{
234
-		$search_id='';
235
-		$search_nom='';
236
-		$search_alias='';
237
-		$search_categ_cus=0;
238
-		$search_categ_sup=0;
239
-		$search_sale='';
240
-		$search_barcode="";
241
-		$search_customer_code='';
242
-		$search_supplier_code='';
243
-		$search_account_customer_code='';
244
-		$search_account_supplier_code='';
245
-		$search_town="";
246
-		$search_zip="";
247
-		$search_state="";
248
-		$search_country='';
249
-		$search_email='';
250
-		$search_phone='';
251
-		$search_fax='';
252
-		$search_url='';
253
-		$search_idprof1='';
254
-		$search_idprof2='';
255
-		$search_idprof3='';
256
-		$search_idprof4='';
257
-		$search_idprof5='';
258
-		$search_idprof6='';
259
-		$search_vat='';
260
-		$search_type='';
261
-		$search_type_thirdparty='';
262
-		$search_staff='';
263
-		$search_status=-1;
264
-		$search_stcomm='';
265
-	 	$search_level='';
266
-	 	$search_import_key='';
267
-	 	$toselect='';
268
-		$search_array_options=array();
269
-	}
270
-
271
-	// Mass actions
272
-	$objectclass='Societe';
273
-	$objectlabel='ThirdParty';
274
-	$permtoread = $user->rights->societe->lire;
275
-	$permtodelete = $user->rights->societe->supprimer;
276
-	$uploaddir = $conf->societe->dir_output;
277
-	include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
278
-
279
-	if ($action == 'setstcomm')
280
-	{
281
-		$object = new Client($db);
282
-		$result=$object->fetch(GETPOST('stcommsocid'));
283
-		$object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
284
-		$result=$object->update($object->id, $user);
285
-		if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
286
-
287
-		$action='';
288
-	}
228
+    // Selection of new fields
229
+    include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
230
+
231
+    // Did we click on purge search criteria ?
232
+    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
233
+    {
234
+        $search_id='';
235
+        $search_nom='';
236
+        $search_alias='';
237
+        $search_categ_cus=0;
238
+        $search_categ_sup=0;
239
+        $search_sale='';
240
+        $search_barcode="";
241
+        $search_customer_code='';
242
+        $search_supplier_code='';
243
+        $search_account_customer_code='';
244
+        $search_account_supplier_code='';
245
+        $search_town="";
246
+        $search_zip="";
247
+        $search_state="";
248
+        $search_country='';
249
+        $search_email='';
250
+        $search_phone='';
251
+        $search_fax='';
252
+        $search_url='';
253
+        $search_idprof1='';
254
+        $search_idprof2='';
255
+        $search_idprof3='';
256
+        $search_idprof4='';
257
+        $search_idprof5='';
258
+        $search_idprof6='';
259
+        $search_vat='';
260
+        $search_type='';
261
+        $search_type_thirdparty='';
262
+        $search_staff='';
263
+        $search_status=-1;
264
+        $search_stcomm='';
265
+            $search_level='';
266
+            $search_import_key='';
267
+            $toselect='';
268
+        $search_array_options=array();
269
+    }
270
+
271
+    // Mass actions
272
+    $objectclass='Societe';
273
+    $objectlabel='ThirdParty';
274
+    $permtoread = $user->rights->societe->lire;
275
+    $permtodelete = $user->rights->societe->supprimer;
276
+    $uploaddir = $conf->societe->dir_output;
277
+    include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
278
+
279
+    if ($action == 'setstcomm')
280
+    {
281
+        $object = new Client($db);
282
+        $result=$object->fetch(GETPOST('stcommsocid'));
283
+        $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
284
+        $result=$object->update($object->id, $user);
285
+        if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
286
+
287
+        $action='';
288
+    }
289 289
 }
290 290
 
291 291
 if ($search_status=='') $search_status=1; // always display active thirdparty first
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 $resql = $db->query($sql);
329 329
 if ($resql)
330 330
 {
331
-	while ($obj = $db->fetch_object($resql))
332
-	{
333
-		// Compute level text
334
-		$level=$langs->trans($obj->code);
335
-		if ($level == $obj->code) $level=$langs->trans($obj->label);
336
-		$tab_level[$obj->code] = $level;
337
-	}
331
+    while ($obj = $db->fetch_object($resql))
332
+    {
333
+        // Compute level text
334
+        $level=$langs->trans($obj->code);
335
+        if ($level == $obj->code) $level=$langs->trans($obj->label);
336
+        $tab_level[$obj->code] = $level;
337
+    }
338 338
 }
339 339
 else dol_print_error($db);
340 340
 
@@ -435,13 +435,13 @@  discard block
 block discarded – undo
435 435
 $nbtotalofrecords = '';
436 436
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
437 437
 {
438
-	$result = $db->query($sql);
439
-	$nbtotalofrecords = $db->num_rows($result);
440
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
441
-	{
442
-		$page = 0;
443
-		$offset = 0;
444
-	}
438
+    $result = $db->query($sql);
439
+    $nbtotalofrecords = $db->num_rows($result);
440
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
441
+    {
442
+        $page = 0;
443
+        $offset = 0;
444
+    }
445 445
 }
446 446
 
447 447
 $sql.= $db->plimit($limit+1, $offset);
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 $resql = $db->query($sql);
450 450
 if (! $resql)
451 451
 {
452
-	dol_print_error($db);
453
-	exit;
452
+    dol_print_error($db);
453
+    exit;
454 454
 }
455 455
 
456 456
 $num = $db->num_rows($resql);
@@ -459,21 +459,21 @@  discard block
 block discarded – undo
459 459
 
460 460
 if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list')
461 461
 {
462
-	$obj = $db->fetch_object($resql);
463
-	$id = $obj->rowid;
464
-	if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
465
-              if( $obj->client > 0) {
466
-                       header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
467
-                       exit;
468
-               }
469
-               if( $obj->fournisseur > 0){
470
-                       header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
471
-                       exit;
472
-               }
473
-       }
474
-
475
-	header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
476
-	exit;
462
+    $obj = $db->fetch_object($resql);
463
+    $id = $obj->rowid;
464
+    if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
465
+                if( $obj->client > 0) {
466
+                        header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
467
+                        exit;
468
+                }
469
+                if( $obj->fournisseur > 0){
470
+                        header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
471
+                        exit;
472
+                }
473
+        }
474
+
475
+    header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
476
+    exit;
477 477
 }
478 478
 
479 479
 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
 // Show delete result message
525 525
 if (GETPOST('delsoc'))
526 526
 {
527
-	setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
527
+    setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
528 528
 }
529 529
 
530 530
 // List of mass actions available
531 531
 $arrayofmassactions =  array(
532
-	'presend'=>$langs->trans("SendByMail"),
532
+    'presend'=>$langs->trans("SendByMail"),
533 533
 //    'builddoc'=>$langs->trans("PDFMerge"),
534 534
 );
535 535
 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
@@ -540,20 +540,20 @@  discard block
 block discarded – undo
540 540
 $newcardbutton='';
541 541
 if ($user->rights->societe->creer)
542 542
 {
543
-	$typefilter='';
544
-	$label='MenuNewThirdParty';
545
-
546
-	if(! empty($type))
547
-	{
548
-		$typefilter = '&amp;type='.$type;
549
-		if($type == 'p') $label='MenuNewProspect';
550
-		if($type == 'c') $label='MenuNewCustomer';
551
-		if($type == 'f') $label='NewSupplier';
552
-	}
553
-
554
-	$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter.'"><span class="valignmiddle">'.$langs->trans($label).'</span>';
555
-	$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
556
-	$newcardbutton.= '</a>';
543
+    $typefilter='';
544
+    $label='MenuNewThirdParty';
545
+
546
+    if(! empty($type))
547
+    {
548
+        $typefilter = '&amp;type='.$type;
549
+        if($type == 'p') $label='MenuNewProspect';
550
+        if($type == 'c') $label='MenuNewCustomer';
551
+        if($type == 'f') $label='NewSupplier';
552
+    }
553
+
554
+    $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter.'"><span class="valignmiddle">'.$langs->trans($label).'</span>';
555
+    $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
556
+    $newcardbutton.= '</a>';
557 557
 }
558 558
 
559 559
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 $textprofid=array();
571 571
 foreach(array(1,2,3,4,5,6) as $key)
572 572
 {
573
-	$label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
574
-	$textprofid[$key]='';
575
-	if ($label != "ProfId".$key.$mysoc->country_code)
576
-	{	// Get only text between ()
577
-		if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
578
-		$textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
579
-	}
573
+    $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
574
+    $textprofid[$key]='';
575
+    if ($label != "ProfId".$key.$mysoc->country_code)
576
+    {	// Get only text between ()
577
+        if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
578
+        $textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
579
+    }
580 580
 }
581 581
 
582 582
 $topicmail="Information";
@@ -587,51 +587,51 @@  discard block
 block discarded – undo
587 587
 
588 588
 if ($search_all)
589 589
 {
590
-	foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
591
-	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall).'</div>';
590
+    foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
591
+    print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall).'</div>';
592 592
 }
593 593
 
594 594
 // Filter on categories
595 595
 $moreforfilter='';
596 596
 if (empty($type) || $type == 'c' || $type == 'p')
597 597
 {
598
-	if (! empty($conf->categorie->enabled))
599
-	{
600
-		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
601
-		$moreforfilter.='<div class="divsearchfield">';
602
-	 	$moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
603
-		$moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
604
-	 	$moreforfilter.='</div>';
605
-	}
598
+    if (! empty($conf->categorie->enabled))
599
+    {
600
+        require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
601
+        $moreforfilter.='<div class="divsearchfield">';
602
+            $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
603
+        $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
604
+            $moreforfilter.='</div>';
605
+    }
606 606
 }
607 607
 if (empty($type) || $type == 'f')
608 608
 {
609
-	if (! empty($conf->categorie->enabled))
610
-	{
611
-		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
612
-		$moreforfilter.='<div class="divsearchfield">';
613
-		$moreforfilter.=$langs->trans('SuppliersCategoriesShort').': ';
614
-		$moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1);
615
-		$moreforfilter.='</div>';
616
-	}
609
+    if (! empty($conf->categorie->enabled))
610
+    {
611
+        require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
612
+        $moreforfilter.='<div class="divsearchfield">';
613
+        $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': ';
614
+        $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1);
615
+        $moreforfilter.='</div>';
616
+    }
617 617
 }
618 618
 
619 619
 // If the user can view prospects other than his'
620 620
 if ($user->rights->societe->client->voir || $socid)
621 621
 {
622
- 	$moreforfilter.='<div class="divsearchfield">';
623
- 	$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
624
-	$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
625
-	$moreforfilter.='</div>';
622
+        $moreforfilter.='<div class="divsearchfield">';
623
+        $moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
624
+    $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
625
+    $moreforfilter.='</div>';
626 626
 }
627 627
 if ($moreforfilter)
628 628
 {
629
-	print '<div class="liste_titre liste_titre_bydiv centpercent">';
630
-	print $moreforfilter;
631
-	$parameters=array('type'=>$type);
632
-	$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
633
-	print $hookmanager->resPrint;
634
-	print '</div>';
629
+    print '<div class="liste_titre liste_titre_bydiv centpercent">';
630
+    print $moreforfilter;
631
+    $parameters=array('type'=>$type);
632
+    $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
633
+    print $hookmanager->resPrint;
634
+    print '</div>';
635 635
 }
636 636
 
637 637
 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
@@ -647,217 +647,217 @@  discard block
 block discarded – undo
647 647
 print '<tr class="liste_titre_filter">';
648 648
 if (! empty($arrayfields['s.rowid']['checked']))
649 649
 {
650
-	print '<td class="liste_titre">';
651
-	print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
652
-	print '</td>';
650
+    print '<td class="liste_titre">';
651
+    print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
652
+    print '</td>';
653 653
 }
654 654
 if (! empty($arrayfields['s.nom']['checked']))
655 655
 {
656
-	print '<td class="liste_titre">';
657
-	if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
658
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
659
-	print '</td>';
656
+    print '<td class="liste_titre">';
657
+    if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
658
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
659
+    print '</td>';
660 660
 }
661 661
 if (! empty($arrayfields['s.name_alias']['checked']))
662 662
 {
663
-	print '<td class="liste_titre">';
664
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
665
-	print '</td>';
663
+    print '<td class="liste_titre">';
664
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
665
+    print '</td>';
666 666
 }
667 667
 // Barcode
668 668
 if (! empty($arrayfields['s.barcode']['checked']))
669 669
 {
670
-	print '<td class="liste_titre">';
671
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
672
-	print '</td>';
670
+    print '<td class="liste_titre">';
671
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
672
+    print '</td>';
673 673
 }
674 674
 // Customer code
675 675
 if (! empty($arrayfields['s.code_client']['checked']))
676 676
 {
677
-	print '<td class="liste_titre">';
678
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
679
-	print '</td>';
677
+    print '<td class="liste_titre">';
678
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
679
+    print '</td>';
680 680
 }
681 681
 // Supplier code
682 682
 if (! empty($arrayfields['s.code_fournisseur']['checked']))
683 683
 {
684
-	print '<td class="liste_titre">';
685
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
686
-	print '</td>';
684
+    print '<td class="liste_titre">';
685
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
686
+    print '</td>';
687 687
 }
688 688
 // Account Customer code
689 689
 if (! empty($arrayfields['s.code_compta']['checked']))
690 690
 {
691
-	print '<td class="liste_titre">';
692
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
693
-	print '</td>';
691
+    print '<td class="liste_titre">';
692
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
693
+    print '</td>';
694 694
 }
695 695
 // Account Supplier code
696 696
 if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
697 697
 {
698
-	print '<td class="liste_titre">';
699
-	print '<input class="flat maxwidth50" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
700
-	print '</td>';
698
+    print '<td class="liste_titre">';
699
+    print '<input class="flat maxwidth50" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
700
+    print '</td>';
701 701
 }
702 702
 // Town
703 703
 if (! empty($arrayfields['s.town']['checked']))
704 704
 {
705
-	print '<td class="liste_titre">';
706
-	print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
707
-	print '</td>';
705
+    print '<td class="liste_titre">';
706
+    print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
707
+    print '</td>';
708 708
 }
709 709
 // Zip
710 710
 if (! empty($arrayfields['s.zip']['checked']))
711 711
 {
712
-	print '<td class="liste_titre">';
713
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
714
-	print '</td>';
712
+    print '<td class="liste_titre">';
713
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
714
+    print '</td>';
715 715
 }
716 716
 // State
717 717
 if (! empty($arrayfields['state.nom']['checked']))
718 718
 {
719
-	print '<td class="liste_titre">';
720
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
721
-	print '</td>';
719
+    print '<td class="liste_titre">';
720
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
721
+    print '</td>';
722 722
 }
723 723
 // Region
724 724
 if (! empty($arrayfields['region.nom']['checked']))
725 725
 {
726
-	print '<td class="liste_titre">';
727
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
728
-	print '</td>';
726
+    print '<td class="liste_titre">';
727
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
728
+    print '</td>';
729 729
 }
730 730
 // Country
731 731
 if (! empty($arrayfields['country.code_iso']['checked']))
732 732
 {
733
-	print '<td class="liste_titre" align="center">';
734
-	print $form->select_country($search_country,'search_country','',0,'maxwidth100');
735
-	print '</td>';
733
+    print '<td class="liste_titre" align="center">';
734
+    print $form->select_country($search_country,'search_country','',0,'maxwidth100');
735
+    print '</td>';
736 736
 }
737 737
 // Company type
738 738
 if (! empty($arrayfields['typent.code']['checked']))
739 739
 {
740
-	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
741
-	print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
742
-	print '</td>';
740
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
741
+    print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
742
+    print '</td>';
743 743
 }
744 744
 // Staff
745 745
 if (! empty($arrayfields['staff.code']['checked']))
746 746
 {
747
-	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
748
-	print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100');
749
-	print '</td>';
747
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
748
+    print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100');
749
+    print '</td>';
750 750
 }
751 751
 if (! empty($arrayfields['s.email']['checked']))
752 752
 {
753
-	// Email
754
-	print '<td class="liste_titre">';
755
-	print '<input class="flat searchemail maxwidth50" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
756
-	print '</td>';
753
+    // Email
754
+    print '<td class="liste_titre">';
755
+    print '<input class="flat searchemail maxwidth50" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
756
+    print '</td>';
757 757
 }
758 758
 if (! empty($arrayfields['s.phone']['checked']))
759 759
 {
760
-	// Phone
761
-	print '<td class="liste_titre">';
762
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
763
-	print '</td>';
760
+    // Phone
761
+    print '<td class="liste_titre">';
762
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
763
+    print '</td>';
764 764
 }
765 765
 if (! empty($arrayfields['s.fax']['checked']))
766 766
 {
767
-	// Fax
768
-	print '<td class="liste_titre">';
769
-	print '<input class="flat searchstring" size="4" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
770
-	print '</td>';
767
+    // Fax
768
+    print '<td class="liste_titre">';
769
+    print '<input class="flat searchstring" size="4" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
770
+    print '</td>';
771 771
 }
772 772
 if (! empty($arrayfields['s.url']['checked']))
773 773
 {
774
-	// Url
775
-	print '<td class="liste_titre">';
776
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
777
-	print '</td>';
774
+    // Url
775
+    print '<td class="liste_titre">';
776
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
777
+    print '</td>';
778 778
 }
779 779
 if (! empty($arrayfields['s.siren']['checked']))
780 780
 {
781
-	// IdProf1
782
-	print '<td class="liste_titre">';
783
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
784
-	print '</td>';
781
+    // IdProf1
782
+    print '<td class="liste_titre">';
783
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
784
+    print '</td>';
785 785
 }
786 786
 if (! empty($arrayfields['s.siret']['checked']))
787 787
 {
788
-	// IdProf2
789
-	print '<td class="liste_titre">';
790
-	print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
791
-	print '</td>';
788
+    // IdProf2
789
+    print '<td class="liste_titre">';
790
+    print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
791
+    print '</td>';
792 792
 }
793 793
 if (! empty($arrayfields['s.ape']['checked']))
794 794
 {
795
-	// IdProf3
796
-	print '<td class="liste_titre">';
797
-	print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
798
-	print '</td>';
795
+    // IdProf3
796
+    print '<td class="liste_titre">';
797
+    print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
798
+    print '</td>';
799 799
 }
800 800
 if (! empty($arrayfields['s.idprof4']['checked']))
801 801
 {
802
-	// IdProf4
803
-	print '<td class="liste_titre">';
804
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
805
-	print '</td>';
802
+    // IdProf4
803
+    print '<td class="liste_titre">';
804
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
805
+    print '</td>';
806 806
 }
807 807
 if (! empty($arrayfields['s.idprof5']['checked']))
808 808
 {
809
-	// IdProf5
810
-	print '<td class="liste_titre">';
811
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
812
-	print '</td>';
809
+    // IdProf5
810
+    print '<td class="liste_titre">';
811
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
812
+    print '</td>';
813 813
 }
814 814
 if (! empty($arrayfields['s.idprof6']['checked']))
815 815
 {
816
-	// IdProf6
817
-	print '<td class="liste_titre">';
818
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
819
-	print '</td>';
816
+    // IdProf6
817
+    print '<td class="liste_titre">';
818
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
819
+    print '</td>';
820 820
 }
821 821
 if (! empty($arrayfields['s.tva_intra']['checked']))
822 822
 {
823
-	// Vat number
824
-	print '<td class="liste_titre">';
825
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
826
-	print '</td>';
823
+    // Vat number
824
+    print '<td class="liste_titre">';
825
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
826
+    print '</td>';
827 827
 }
828 828
 
829 829
 // Type (customer/prospect/supplier)
830 830
 if (! empty($arrayfields['customerorsupplier']['checked']))
831 831
 {
832
-	print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
833
-	if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
834
-	print '<select class="flat" name="search_type">';
835
-	print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
836
-	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
837
-	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
838
-	//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
839
-	print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
840
-	print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
841
-	print '</select></td>';
832
+    print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
833
+    if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
834
+    print '<select class="flat" name="search_type">';
835
+    print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
836
+    if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
837
+    if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
838
+    //if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
839
+    print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
840
+    print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
841
+    print '</select></td>';
842 842
 }
843 843
 // Prospect level
844 844
 if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
845 845
 {
846
- 	print '<td class="liste_titre" align="center">';
847
- 	print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
848
-	print '</td>';
846
+        print '<td class="liste_titre" align="center">';
847
+        print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
848
+    print '</td>';
849 849
 }
850 850
 // Prospect status
851 851
 if (! empty($arrayfields['s.fk_stcomm']['checked']))
852 852
 {
853
-	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
854
-	$arraystcomm=array();
855
-	foreach($prospectstatic->cacheprospectstatus as $key => $val)
856
-	{
857
-		$arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
858
-	}
859
-	print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
860
-	print '</td>';
853
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
854
+    $arraystcomm=array();
855
+    foreach($prospectstatic->cacheprospectstatus as $key => $val)
856
+    {
857
+        $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
858
+    }
859
+    print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
860
+    print '</td>';
861 861
 }
862 862
 // Extra fields
863 863
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -869,27 +869,27 @@  discard block
 block discarded – undo
869 869
 // Date creation
870 870
 if (! empty($arrayfields['s.datec']['checked']))
871 871
 {
872
-	print '<td class="liste_titre">';
873
-	print '</td>';
872
+    print '<td class="liste_titre">';
873
+    print '</td>';
874 874
 }
875 875
 // Date modification
876 876
 if (! empty($arrayfields['s.tms']['checked']))
877 877
 {
878
-	print '<td class="liste_titre">';
879
-	print '</td>';
878
+    print '<td class="liste_titre">';
879
+    print '</td>';
880 880
 }
881 881
 // Status
882 882
 if (! empty($arrayfields['s.status']['checked']))
883 883
 {
884
-	print '<td class="liste_titre center minwidth75imp">';
885
-	print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1);
886
-	print '</td>';
884
+    print '<td class="liste_titre center minwidth75imp">';
885
+    print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1);
886
+    print '</td>';
887 887
 }
888 888
 if (! empty($arrayfields['s.import_key']['checked']))
889 889
 {
890
-	print '<td class="liste_titre center">';
891
-	print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
892
-	print '</td>';
890
+    print '<td class="liste_titre center">';
891
+    print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
892
+    print '</td>';
893 893
 }
894 894
 // Action column
895 895
 print '<td class="liste_titre" align="right">';
@@ -947,289 +947,289 @@  discard block
 block discarded – undo
947 947
 $totalarray=array();
948 948
 while ($i < min($num, $limit))
949 949
 {
950
-	$obj = $db->fetch_object($resql);
951
-
952
-	$companystatic->id=$obj->rowid;
953
-	$companystatic->name=$obj->name;
954
-	$companystatic->name_alias=$obj->name_alias;
955
-	$companystatic->logo=$obj->logo;
956
-	$companystatic->canvas=$obj->canvas;
957
-	$companystatic->client=$obj->client;
958
-	$companystatic->status=$obj->status;
959
-	$companystatic->email=$obj->email;
960
-	$companystatic->fournisseur=$obj->fournisseur;
961
-	$companystatic->code_client=$obj->code_client;
962
-	$companystatic->code_fournisseur=$obj->code_fournisseur;
963
-
964
-	$companystatic->code_compta_client=$obj->code_compta;
965
-	$companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
966
-
967
-   	$companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
968
-
969
-	print '<tr class="oddeven">';
970
-	if (! empty($arrayfields['s.rowid']['checked']))
971
-	{
972
-		print '<td class="tdoverflowmax50">';
973
-		print $obj->rowid;
974
-		print "</td>\n";
975
-		if (! $i) $totalarray['nbfield']++;
976
-	}
977
-	if (! empty($arrayfields['s.nom']['checked']))
978
-	{
979
-		$savalias = $obj->name_alias;
980
-		if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
981
-		print '<td class="tdoverflowmax200">';
982
-		print $companystatic->getNomUrl(1, '', 100, 0, 1);
983
-		print "</td>\n";
984
-		$companystatic->name_alias = $savalias;
950
+    $obj = $db->fetch_object($resql);
951
+
952
+    $companystatic->id=$obj->rowid;
953
+    $companystatic->name=$obj->name;
954
+    $companystatic->name_alias=$obj->name_alias;
955
+    $companystatic->logo=$obj->logo;
956
+    $companystatic->canvas=$obj->canvas;
957
+    $companystatic->client=$obj->client;
958
+    $companystatic->status=$obj->status;
959
+    $companystatic->email=$obj->email;
960
+    $companystatic->fournisseur=$obj->fournisseur;
961
+    $companystatic->code_client=$obj->code_client;
962
+    $companystatic->code_fournisseur=$obj->code_fournisseur;
963
+
964
+    $companystatic->code_compta_client=$obj->code_compta;
965
+    $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
966
+
967
+        $companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
968
+
969
+    print '<tr class="oddeven">';
970
+    if (! empty($arrayfields['s.rowid']['checked']))
971
+    {
972
+        print '<td class="tdoverflowmax50">';
973
+        print $obj->rowid;
974
+        print "</td>\n";
985 975
         if (! $i) $totalarray['nbfield']++;
986
-	}
987
-	if (! empty($arrayfields['s.name_alias']['checked']))
988
-	{
989
-		print '<td class="tdoverflowmax200">';
990
-		print $companystatic->name_alias;
991
-		print "</td>\n";
992
-		if (! $i) $totalarray['nbfield']++;
993
-	}
994
-	// Barcode
995
-	if (! empty($arrayfields['s.barcode']['checked']))
996
-	{
997
-		print '<td>'.$obj->barcode.'</td>';
998
-		if (! $i) $totalarray['nbfield']++;
999
-	}
1000
-	// Customer code
1001
-	if (! empty($arrayfields['s.code_client']['checked']))
1002
-	{
1003
-		print '<td class="nowraponall">'.$obj->code_client.'</td>';
1004
-		if (! $i) $totalarray['nbfield']++;
1005
-	}
1006
-	// Supplier code
1007
-	if (! empty($arrayfields['s.code_fournisseur']['checked']))
1008
-	{
1009
-		print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>';
1010
-		if (! $i) $totalarray['nbfield']++;
1011
-	}
1012
-	// Account customer code
1013
-	if (! empty($arrayfields['s.code_compta']['checked']))
1014
-	{
1015
-		print '<td>'.$obj->code_compta.'</td>';
1016
-		if (! $i) $totalarray['nbfield']++;
1017
-	}
1018
-	// Account supplier code
1019
-	if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
1020
-	{
1021
-		print '<td>'.$obj->code_compta_fournisseur.'</td>';
1022
-		if (! $i) $totalarray['nbfield']++;
1023
-	}
1024
-	// Town
1025
-	if (! empty($arrayfields['s.town']['checked']))
1026
-	{
1027
-		print "<td>".$obj->town."</td>\n";
1028
-		if (! $i) $totalarray['nbfield']++;
1029
-	}
1030
-	// Zip
1031
-	if (! empty($arrayfields['s.zip']['checked']))
1032
-	{
1033
-		print "<td>".$obj->zip."</td>\n";
1034
-		if (! $i) $totalarray['nbfield']++;
1035
-	}
1036
-	// State
1037
-	if (! empty($arrayfields['state.nom']['checked']))
1038
-	{
1039
-		print "<td>".$obj->state_name."</td>\n";
1040
-		if (! $i) $totalarray['nbfield']++;
1041
-	}
1042
-	// Region
1043
-	if (! empty($arrayfields['region.nom']['checked']))
1044
-	{
1045
-		print "<td>".$obj->region_name."</td>\n";
1046
-		if (! $i) $totalarray['nbfield']++;
1047
-	}
1048
-	// Country
1049
-	if (! empty($arrayfields['country.code_iso']['checked']))
1050
-	{
1051
-		print '<td align="center">';
1052
-		$tmparray=getCountry($obj->fk_pays,'all');
1053
-		print $tmparray['label'];
1054
-		print '</td>';
1055
-		if (! $i) $totalarray['nbfield']++;
1056
-	}
1057
-	// Type ent
1058
-	if (! empty($arrayfields['typent.code']['checked']))
1059
-	{
1060
-		print '<td align="center">';
1061
-		if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
1062
-		print $typenArray[$obj->typent_code];
1063
-		print '</td>';
1064
-		if (! $i) $totalarray['nbfield']++;
1065
-	}
1066
-	// Staff
1067
-	if (! empty($arrayfields['staff.code']['checked']))
1068
-	{
1069
-		print '<td align="center">';
1070
-		if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
1071
-		print $staffArray[$obj->staff_code];
1072
-		print '</td>';
1073
-		if (! $i) $totalarray['nbfield']++;
1074
-	}
1075
-	if (! empty($arrayfields['s.email']['checked']))
1076
-	{
1077
-		print "<td>".$obj->email."</td>\n";
1078
-		if (! $i) $totalarray['nbfield']++;
1079
-	}
1080
-	if (! empty($arrayfields['s.phone']['checked']))
1081
-	{
1082
-		print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid)."</td>\n";
1083
-		if (! $i) $totalarray['nbfield']++;
1084
-	}
1085
-	if (! empty($arrayfields['s.fax']['checked']))
1086
-	{
1087
-		print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid)."</td>\n";
1088
-		if (! $i) $totalarray['nbfield']++;
1089
-	}
1090
-	if (! empty($arrayfields['s.url']['checked']))
1091
-	{
1092
-		print "<td>".$obj->url."</td>\n";
1093
-		if (! $i) $totalarray['nbfield']++;
1094
-	}
1095
-	if (! empty($arrayfields['s.siren']['checked']))
1096
-	{
1097
-		print "<td>".$obj->idprof1."</td>\n";
1098
-		if (! $i) $totalarray['nbfield']++;
1099
-	}
1100
-	if (! empty($arrayfields['s.siret']['checked']))
1101
-	{
1102
-		print "<td>".$obj->idprof2."</td>\n";
1103
-		if (! $i) $totalarray['nbfield']++;
1104
-	}
1105
-	if (! empty($arrayfields['s.ape']['checked']))
1106
-	{
1107
-		print "<td>".$obj->idprof3."</td>\n";
1108
-		if (! $i) $totalarray['nbfield']++;
1109
-	}
1110
-	if (! empty($arrayfields['s.idprof4']['checked']))
1111
-	{
1112
-		print "<td>".$obj->idprof4."</td>\n";
1113
-		if (! $i) $totalarray['nbfield']++;
1114
-	}
1115
-	if (! empty($arrayfields['s.idprof5']['checked']))
1116
-	{
1117
-		print "<td>".$obj->idprof5."</td>\n";
1118
-		if (! $i) $totalarray['nbfield']++;
1119
-	}
1120
-	if (! empty($arrayfields['s.idprof6']['checked']))
1121
-	{
1122
-		print "<td>".$obj->idprof6."</td>\n";
1123
-		if (! $i) $totalarray['nbfield']++;
1124
-	}
1125
-	if (! empty($arrayfields['s.tva_intra']['checked']))
1126
-	{
1127
-		print "<td>".$obj->tva_intra."</td>\n";
1128
-		if (! $i) $totalarray['nbfield']++;
1129
-	}
1130
-	// Type
1131
-	if (! empty($arrayfields['customerorsupplier']['checked']))
1132
-	{
1133
-		print '<td align="center">';
1134
-		$s='';
1135
-		if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
1136
-		{
1137
-	  		$companystatic->name=$langs->trans("Customer");
1138
-	  		$companystatic->name_alias='';
1139
-			$s.=$companystatic->getNomUrl(0,'customer',0,1);
1140
-		}
1141
-		if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1142
-		{
1143
-			if ($s) $s.=" / ";
1144
-			$companystatic->name=$langs->trans("Prospect");
1145
-	  		$companystatic->name_alias='';
1146
-			$s.=$companystatic->getNomUrl(0,'prospect',0,1);
1147
-		}
1148
-		if ((! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) && $obj->fournisseur)
1149
-		{
1150
-			if ($s) $s.=" / ";
1151
-			$companystatic->name=$langs->trans("Supplier");
1152
-	  		$companystatic->name_alias='';
1153
-			$s.=$companystatic->getNomUrl(0,'supplier',0,1);
1154
-		}
1155
-		print $s;
1156
-		print '</td>';
1157
-		if (! $i) $totalarray['nbfield']++;
1158
-	}
1159
-
1160
-	if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
1161
-	{
1162
-		// Prospect level
1163
-		print '<td align="center">';
1164
-		print $companystatic->getLibProspLevel();
1165
-		print "</td>";
1166
-		if (! $i) $totalarray['nbfield']++;
1167
-	}
1168
-
1169
-	if (! empty($arrayfields['s.fk_stcomm']['checked']))
1170
-	{
1171
-		// Prospect status
1172
-		print '<td align="center" class="nowrap"><div class="nowrap">';
1173
-		print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
1174
-		print '</div> - <div class="inline-block">';
1175
-		foreach($prospectstatic->cacheprospectstatus as $key => $val)
1176
-		{
1177
-			$titlealt='default';
1178
-			if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
1179
-			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
1180
-		}
1181
-		print '</div></div></td>';
1182
-		if (! $i) $totalarray['nbfield']++;
1183
-	}
1184
-	// Extra fields
1185
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1186
-	// Fields from hook
1187
-	$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1188
-	$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
1189
-	print $hookmanager->resPrint;
1190
-	// Date creation
1191
-	if (! empty($arrayfields['s.datec']['checked']))
1192
-	{
1193
-		print '<td align="center" class="nowrap">';
1194
-		print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1195
-		print '</td>';
1196
-		if (! $i) $totalarray['nbfield']++;
1197
-	}
1198
-	// Date modification
1199
-	if (! empty($arrayfields['s.tms']['checked']))
1200
-	{
1201
-		print '<td align="center" class="nowrap">';
1202
-		print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1203
-		print '</td>';
1204
-		if (! $i) $totalarray['nbfield']++;
1205
-	}
1206
-	// Status
1207
-	if (! empty($arrayfields['s.status']['checked']))
1208
-	{
1209
-		print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
1210
-		if (! $i) $totalarray['nbfield']++;
1211
-	}
1212
-	if (! empty($arrayfields['s.import_key']['checked']))
1213
-	{
1214
-		print '<td class="tdoverflowmax100">';
1215
-		print $obj->import_key;
1216
-		print "</td>\n";
1217
-		if (! $i) $totalarray['nbfield']++;
1218
-	}
1219
-
1220
-	// Action column
1221
-	print '<td class="nowrap" align="center">';
1222
-	if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1223
-	{
1224
-		$selected=0;
1225
-		if (in_array($obj->rowid, $arrayofselected)) $selected=1;
1226
-		print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
1227
-	}
1228
-	print '</td>';
1229
-	if (! $i) $totalarray['nbfield']++;
1230
-
1231
-	print '</tr>'."\n";
1232
-	$i++;
976
+    }
977
+    if (! empty($arrayfields['s.nom']['checked']))
978
+    {
979
+        $savalias = $obj->name_alias;
980
+        if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
981
+        print '<td class="tdoverflowmax200">';
982
+        print $companystatic->getNomUrl(1, '', 100, 0, 1);
983
+        print "</td>\n";
984
+        $companystatic->name_alias = $savalias;
985
+        if (! $i) $totalarray['nbfield']++;
986
+    }
987
+    if (! empty($arrayfields['s.name_alias']['checked']))
988
+    {
989
+        print '<td class="tdoverflowmax200">';
990
+        print $companystatic->name_alias;
991
+        print "</td>\n";
992
+        if (! $i) $totalarray['nbfield']++;
993
+    }
994
+    // Barcode
995
+    if (! empty($arrayfields['s.barcode']['checked']))
996
+    {
997
+        print '<td>'.$obj->barcode.'</td>';
998
+        if (! $i) $totalarray['nbfield']++;
999
+    }
1000
+    // Customer code
1001
+    if (! empty($arrayfields['s.code_client']['checked']))
1002
+    {
1003
+        print '<td class="nowraponall">'.$obj->code_client.'</td>';
1004
+        if (! $i) $totalarray['nbfield']++;
1005
+    }
1006
+    // Supplier code
1007
+    if (! empty($arrayfields['s.code_fournisseur']['checked']))
1008
+    {
1009
+        print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>';
1010
+        if (! $i) $totalarray['nbfield']++;
1011
+    }
1012
+    // Account customer code
1013
+    if (! empty($arrayfields['s.code_compta']['checked']))
1014
+    {
1015
+        print '<td>'.$obj->code_compta.'</td>';
1016
+        if (! $i) $totalarray['nbfield']++;
1017
+    }
1018
+    // Account supplier code
1019
+    if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
1020
+    {
1021
+        print '<td>'.$obj->code_compta_fournisseur.'</td>';
1022
+        if (! $i) $totalarray['nbfield']++;
1023
+    }
1024
+    // Town
1025
+    if (! empty($arrayfields['s.town']['checked']))
1026
+    {
1027
+        print "<td>".$obj->town."</td>\n";
1028
+        if (! $i) $totalarray['nbfield']++;
1029
+    }
1030
+    // Zip
1031
+    if (! empty($arrayfields['s.zip']['checked']))
1032
+    {
1033
+        print "<td>".$obj->zip."</td>\n";
1034
+        if (! $i) $totalarray['nbfield']++;
1035
+    }
1036
+    // State
1037
+    if (! empty($arrayfields['state.nom']['checked']))
1038
+    {
1039
+        print "<td>".$obj->state_name."</td>\n";
1040
+        if (! $i) $totalarray['nbfield']++;
1041
+    }
1042
+    // Region
1043
+    if (! empty($arrayfields['region.nom']['checked']))
1044
+    {
1045
+        print "<td>".$obj->region_name."</td>\n";
1046
+        if (! $i) $totalarray['nbfield']++;
1047
+    }
1048
+    // Country
1049
+    if (! empty($arrayfields['country.code_iso']['checked']))
1050
+    {
1051
+        print '<td align="center">';
1052
+        $tmparray=getCountry($obj->fk_pays,'all');
1053
+        print $tmparray['label'];
1054
+        print '</td>';
1055
+        if (! $i) $totalarray['nbfield']++;
1056
+    }
1057
+    // Type ent
1058
+    if (! empty($arrayfields['typent.code']['checked']))
1059
+    {
1060
+        print '<td align="center">';
1061
+        if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
1062
+        print $typenArray[$obj->typent_code];
1063
+        print '</td>';
1064
+        if (! $i) $totalarray['nbfield']++;
1065
+    }
1066
+    // Staff
1067
+    if (! empty($arrayfields['staff.code']['checked']))
1068
+    {
1069
+        print '<td align="center">';
1070
+        if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
1071
+        print $staffArray[$obj->staff_code];
1072
+        print '</td>';
1073
+        if (! $i) $totalarray['nbfield']++;
1074
+    }
1075
+    if (! empty($arrayfields['s.email']['checked']))
1076
+    {
1077
+        print "<td>".$obj->email."</td>\n";
1078
+        if (! $i) $totalarray['nbfield']++;
1079
+    }
1080
+    if (! empty($arrayfields['s.phone']['checked']))
1081
+    {
1082
+        print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid)."</td>\n";
1083
+        if (! $i) $totalarray['nbfield']++;
1084
+    }
1085
+    if (! empty($arrayfields['s.fax']['checked']))
1086
+    {
1087
+        print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid)."</td>\n";
1088
+        if (! $i) $totalarray['nbfield']++;
1089
+    }
1090
+    if (! empty($arrayfields['s.url']['checked']))
1091
+    {
1092
+        print "<td>".$obj->url."</td>\n";
1093
+        if (! $i) $totalarray['nbfield']++;
1094
+    }
1095
+    if (! empty($arrayfields['s.siren']['checked']))
1096
+    {
1097
+        print "<td>".$obj->idprof1."</td>\n";
1098
+        if (! $i) $totalarray['nbfield']++;
1099
+    }
1100
+    if (! empty($arrayfields['s.siret']['checked']))
1101
+    {
1102
+        print "<td>".$obj->idprof2."</td>\n";
1103
+        if (! $i) $totalarray['nbfield']++;
1104
+    }
1105
+    if (! empty($arrayfields['s.ape']['checked']))
1106
+    {
1107
+        print "<td>".$obj->idprof3."</td>\n";
1108
+        if (! $i) $totalarray['nbfield']++;
1109
+    }
1110
+    if (! empty($arrayfields['s.idprof4']['checked']))
1111
+    {
1112
+        print "<td>".$obj->idprof4."</td>\n";
1113
+        if (! $i) $totalarray['nbfield']++;
1114
+    }
1115
+    if (! empty($arrayfields['s.idprof5']['checked']))
1116
+    {
1117
+        print "<td>".$obj->idprof5."</td>\n";
1118
+        if (! $i) $totalarray['nbfield']++;
1119
+    }
1120
+    if (! empty($arrayfields['s.idprof6']['checked']))
1121
+    {
1122
+        print "<td>".$obj->idprof6."</td>\n";
1123
+        if (! $i) $totalarray['nbfield']++;
1124
+    }
1125
+    if (! empty($arrayfields['s.tva_intra']['checked']))
1126
+    {
1127
+        print "<td>".$obj->tva_intra."</td>\n";
1128
+        if (! $i) $totalarray['nbfield']++;
1129
+    }
1130
+    // Type
1131
+    if (! empty($arrayfields['customerorsupplier']['checked']))
1132
+    {
1133
+        print '<td align="center">';
1134
+        $s='';
1135
+        if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
1136
+        {
1137
+                $companystatic->name=$langs->trans("Customer");
1138
+                $companystatic->name_alias='';
1139
+            $s.=$companystatic->getNomUrl(0,'customer',0,1);
1140
+        }
1141
+        if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1142
+        {
1143
+            if ($s) $s.=" / ";
1144
+            $companystatic->name=$langs->trans("Prospect");
1145
+                $companystatic->name_alias='';
1146
+            $s.=$companystatic->getNomUrl(0,'prospect',0,1);
1147
+        }
1148
+        if ((! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) && $obj->fournisseur)
1149
+        {
1150
+            if ($s) $s.=" / ";
1151
+            $companystatic->name=$langs->trans("Supplier");
1152
+                $companystatic->name_alias='';
1153
+            $s.=$companystatic->getNomUrl(0,'supplier',0,1);
1154
+        }
1155
+        print $s;
1156
+        print '</td>';
1157
+        if (! $i) $totalarray['nbfield']++;
1158
+    }
1159
+
1160
+    if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
1161
+    {
1162
+        // Prospect level
1163
+        print '<td align="center">';
1164
+        print $companystatic->getLibProspLevel();
1165
+        print "</td>";
1166
+        if (! $i) $totalarray['nbfield']++;
1167
+    }
1168
+
1169
+    if (! empty($arrayfields['s.fk_stcomm']['checked']))
1170
+    {
1171
+        // Prospect status
1172
+        print '<td align="center" class="nowrap"><div class="nowrap">';
1173
+        print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
1174
+        print '</div> - <div class="inline-block">';
1175
+        foreach($prospectstatic->cacheprospectstatus as $key => $val)
1176
+        {
1177
+            $titlealt='default';
1178
+            if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
1179
+            if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
1180
+        }
1181
+        print '</div></div></td>';
1182
+        if (! $i) $totalarray['nbfield']++;
1183
+    }
1184
+    // Extra fields
1185
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1186
+    // Fields from hook
1187
+    $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1188
+    $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
1189
+    print $hookmanager->resPrint;
1190
+    // Date creation
1191
+    if (! empty($arrayfields['s.datec']['checked']))
1192
+    {
1193
+        print '<td align="center" class="nowrap">';
1194
+        print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1195
+        print '</td>';
1196
+        if (! $i) $totalarray['nbfield']++;
1197
+    }
1198
+    // Date modification
1199
+    if (! empty($arrayfields['s.tms']['checked']))
1200
+    {
1201
+        print '<td align="center" class="nowrap">';
1202
+        print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1203
+        print '</td>';
1204
+        if (! $i) $totalarray['nbfield']++;
1205
+    }
1206
+    // Status
1207
+    if (! empty($arrayfields['s.status']['checked']))
1208
+    {
1209
+        print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
1210
+        if (! $i) $totalarray['nbfield']++;
1211
+    }
1212
+    if (! empty($arrayfields['s.import_key']['checked']))
1213
+    {
1214
+        print '<td class="tdoverflowmax100">';
1215
+        print $obj->import_key;
1216
+        print "</td>\n";
1217
+        if (! $i) $totalarray['nbfield']++;
1218
+    }
1219
+
1220
+    // Action column
1221
+    print '<td class="nowrap" align="center">';
1222
+    if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1223
+    {
1224
+        $selected=0;
1225
+        if (in_array($obj->rowid, $arrayofselected)) $selected=1;
1226
+        print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
1227
+    }
1228
+    print '</td>';
1229
+    if (! $i) $totalarray['nbfield']++;
1230
+
1231
+    print '</tr>'."\n";
1232
+    $i++;
1233 1233
 }
1234 1234
 
1235 1235
 $db->free($resql);
Please login to merge, or discard this patch.
Spacing   +520 added lines, -520 removed lines patch added patch discarded remove patch
@@ -40,79 +40,79 @@  discard block
 block discarded – undo
40 40
 
41 41
 $langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories"));
42 42
 
43
-$action=GETPOST('action','alpha');
44
-$massaction=GETPOST('massaction','alpha');
45
-$show_files=GETPOST('show_files','int');
46
-$confirm=GETPOST('confirm','alpha');
43
+$action = GETPOST('action', 'alpha');
44
+$massaction = GETPOST('massaction', 'alpha');
45
+$show_files = GETPOST('show_files', 'int');
46
+$confirm = GETPOST('confirm', 'alpha');
47 47
 $toselect = GETPOST('toselect', 'array');
48
-$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'thirdpartylist';
48
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist';
49 49
 
50 50
 // Security check
51
-$socid = GETPOST('socid','int');
52
-if ($user->societe_id) $socid=$user->societe_id;
53
-$result = restrictedArea($user,'societe',$socid,'');
54
-
55
-$search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
56
-$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml')));	// Phone number without any special chars
57
-
58
-$search_id=trim(GETPOST("search_id","int"));
59
-$search_nom=trim(GETPOST("search_nom"));
60
-$search_alias=trim(GETPOST("search_alias"));
61
-$search_nom_only=trim(GETPOST("search_nom_only"));
62
-$search_barcode=trim(GETPOST("search_barcode"));
63
-$search_customer_code=trim(GETPOST('search_customer_code'));
64
-$search_supplier_code=trim(GETPOST('search_supplier_code'));
65
-$search_account_customer_code=trim(GETPOST('search_account_customer_code'));
66
-$search_account_supplier_code=trim(GETPOST('search_account_supplier_code'));
67
-$search_town=trim(GETPOST("search_town"));
68
-$search_zip=trim(GETPOST("search_zip"));
69
-$search_state=trim(GETPOST("search_state"));
70
-$search_region=trim(GETPOST("search_region"));
71
-$search_email=trim(GETPOST('search_email'));
72
-$search_phone=trim(GETPOST('search_phone'));
73
-$search_fax=trim(GETPOST('search_fax'));
74
-$search_url=trim(GETPOST('search_url'));
75
-$search_idprof1=trim(GETPOST('search_idprof1'));
76
-$search_idprof2=trim(GETPOST('search_idprof2'));
77
-$search_idprof3=trim(GETPOST('search_idprof3'));
78
-$search_idprof4=trim(GETPOST('search_idprof4'));
79
-$search_idprof5=trim(GETPOST('search_idprof5'));
80
-$search_idprof6=trim(GETPOST('search_idprof6'));
81
-$search_vat=trim(GETPOST('search_vat'));
82
-$search_sale=trim(GETPOST("search_sale",'int'));
83
-$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
84
-$search_categ_sup=trim(GETPOST("search_categ_sup",'int'));
85
-$search_country=GETPOST("search_country",'intcomma');
86
-$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
87
-$search_staff=GETPOST("search_staff",'int');
88
-$search_status=GETPOST("search_status",'int');
89
-$search_type=GETPOST('search_type','alpha');
90
-$search_level      = GETPOST("search_level", "array");
91
-$search_stcomm=GETPOST('search_stcomm','int');
92
-$search_import_key  = GETPOST("search_import_key","alpha");
93
-$search_btn=GETPOST('button_search','alpha');
94
-$search_remove_btn=GETPOST('button_removefilter','alpha');
95
-
96
-$type=GETPOST('type','alpha');
97
-$optioncss=GETPOST('optioncss','alpha');
98
-$mode=GETPOST("mode",'');
99
-
100
-$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id;
101
-
102
-$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
103
-$sortfield=GETPOST("sortfield",'alpha');
104
-$sortorder=GETPOST("sortorder",'alpha');
105
-$page=GETPOST("page",'int');
106
-if (! $sortorder) $sortorder="ASC";
107
-if (! $sortfield) $sortfield="s.nom";
51
+$socid = GETPOST('socid', 'int');
52
+if ($user->societe_id) $socid = $user->societe_id;
53
+$result = restrictedArea($user, 'societe', $socid, '');
54
+
55
+$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
56
+$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
57
+
58
+$search_id = trim(GETPOST("search_id", "int"));
59
+$search_nom = trim(GETPOST("search_nom"));
60
+$search_alias = trim(GETPOST("search_alias"));
61
+$search_nom_only = trim(GETPOST("search_nom_only"));
62
+$search_barcode = trim(GETPOST("search_barcode"));
63
+$search_customer_code = trim(GETPOST('search_customer_code'));
64
+$search_supplier_code = trim(GETPOST('search_supplier_code'));
65
+$search_account_customer_code = trim(GETPOST('search_account_customer_code'));
66
+$search_account_supplier_code = trim(GETPOST('search_account_supplier_code'));
67
+$search_town = trim(GETPOST("search_town"));
68
+$search_zip = trim(GETPOST("search_zip"));
69
+$search_state = trim(GETPOST("search_state"));
70
+$search_region = trim(GETPOST("search_region"));
71
+$search_email = trim(GETPOST('search_email'));
72
+$search_phone = trim(GETPOST('search_phone'));
73
+$search_fax = trim(GETPOST('search_fax'));
74
+$search_url = trim(GETPOST('search_url'));
75
+$search_idprof1 = trim(GETPOST('search_idprof1'));
76
+$search_idprof2 = trim(GETPOST('search_idprof2'));
77
+$search_idprof3 = trim(GETPOST('search_idprof3'));
78
+$search_idprof4 = trim(GETPOST('search_idprof4'));
79
+$search_idprof5 = trim(GETPOST('search_idprof5'));
80
+$search_idprof6 = trim(GETPOST('search_idprof6'));
81
+$search_vat = trim(GETPOST('search_vat'));
82
+$search_sale = trim(GETPOST("search_sale", 'int'));
83
+$search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
84
+$search_categ_sup = trim(GETPOST("search_categ_sup", 'int'));
85
+$search_country = GETPOST("search_country", 'intcomma');
86
+$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
87
+$search_staff = GETPOST("search_staff", 'int');
88
+$search_status = GETPOST("search_status", 'int');
89
+$search_type = GETPOST('search_type', 'alpha');
90
+$search_level = GETPOST("search_level", "array");
91
+$search_stcomm = GETPOST('search_stcomm', 'int');
92
+$search_import_key = GETPOST("search_import_key", "alpha");
93
+$search_btn = GETPOST('button_search', 'alpha');
94
+$search_remove_btn = GETPOST('button_removefilter', 'alpha');
95
+
96
+$type = GETPOST('type', 'alpha');
97
+$optioncss = GETPOST('optioncss', 'alpha');
98
+$mode = GETPOST("mode", '');
99
+
100
+$diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id;
101
+
102
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
103
+$sortfield = GETPOST("sortfield", 'alpha');
104
+$sortorder = GETPOST("sortorder", 'alpha');
105
+$page = GETPOST("page", 'int');
106
+if (!$sortorder) $sortorder = "ASC";
107
+if (!$sortfield) $sortfield = "s.nom";
108 108
 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; }
109 109
 $offset = $limit * $page;
110 110
 $pageprev = $page - 1;
111 111
 $pagenext = $page + 1;
112 112
 
113
-if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; }
114
-if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; }
115
-if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; }
113
+if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; }
114
+if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; }
115
+if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; }
116 116
 
117 117
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
118 118
 $object = new Societe($db);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 // fetch optionals attributes and labels
123 123
 $extralabels = $extrafields->fetch_name_optionals_label('societe');
124
-$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
124
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
125 125
 
126 126
 // List of fields to search into when doing a "search in all"
127 127
 $fieldstosearchall = array(
@@ -140,40 +140,40 @@  discard block
 block discarded – undo
140 140
 	's.phone'=>"Phone",
141 141
 	's.fax'=>"Fax",
142 142
 );
143
-if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4';
144
-if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5';
145
-if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6';
146
-if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod';
143
+if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4';
144
+if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5';
145
+if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6';
146
+if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod';
147 147
 // Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode'
148
-if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
148
+if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
149 149
 
150 150
 
151 151
 // Define list of fields to show into list
152
-$checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0);
153
-$checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0);
154
-$checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0);
155
-$checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0);
156
-$checkedtypetiers=1;
157
-$checkedprofid1=0;
158
-$checkedprofid2=0;
159
-$checkedprofid3=0;
160
-$checkedprofid4=0;
161
-$checkedprofid5=0;
162
-$checkedprofid6=0;
152
+$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0);
153
+$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
154
+$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0);
155
+$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
156
+$checkedtypetiers = 1;
157
+$checkedprofid1 = 0;
158
+$checkedprofid2 = 0;
159
+$checkedprofid3 = 0;
160
+$checkedprofid4 = 0;
161
+$checkedprofid5 = 0;
162
+$checkedprofid6 = 0;
163 163
 //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0);
164 164
 //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0);
165 165
 //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0);
166
-$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
167
-$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
168
-$arrayfields=array(
169
-	's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
166
+$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
167
+$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
168
+$arrayfields = array(
169
+	's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)),
170 170
 	's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
171 171
 	's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
172
-	's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
172
+	's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))),
173 173
 	's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode),
174
-	's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
174
+	's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled))),
175 175
 	's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode),
176
-	's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
176
+	's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled))),
177 177
 	's.town'=>array('label'=>"Town", 'checked'=>1),
178 178
 	's.zip'=>array('label'=>"Zip", 'checked'=>1),
179 179
 	'state.nom'=>array('label'=>"State", 'checked'=>0),
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 // Extra fields
204 204
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
205 205
 {
206
-   foreach($extrafields->attribute_label as $key => $val)
206
+   foreach ($extrafields->attribute_label as $key => $val)
207 207
    {
208
-		if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
208
+		if (!empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key]) != 3 && $extrafields->attribute_perms[$key]));
209 209
    }
210 210
 }
211 211
 
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
  * Actions
217 217
  */
218 218
 
219
-if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
220
-if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
219
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
220
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
221 221
 
222
-$parameters=array();
223
-$reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
222
+$parameters = array();
223
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
224 224
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
225 225
 
226 226
 if (empty($reshook))
@@ -229,48 +229,48 @@  discard block
 block discarded – undo
229 229
 	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
230 230
 
231 231
 	// Did we click on purge search criteria ?
232
-	if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
232
+	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
233 233
 	{
234
-		$search_id='';
235
-		$search_nom='';
236
-		$search_alias='';
237
-		$search_categ_cus=0;
238
-		$search_categ_sup=0;
239
-		$search_sale='';
240
-		$search_barcode="";
241
-		$search_customer_code='';
242
-		$search_supplier_code='';
243
-		$search_account_customer_code='';
244
-		$search_account_supplier_code='';
245
-		$search_town="";
246
-		$search_zip="";
247
-		$search_state="";
248
-		$search_country='';
249
-		$search_email='';
250
-		$search_phone='';
251
-		$search_fax='';
252
-		$search_url='';
253
-		$search_idprof1='';
254
-		$search_idprof2='';
255
-		$search_idprof3='';
256
-		$search_idprof4='';
257
-		$search_idprof5='';
258
-		$search_idprof6='';
259
-		$search_vat='';
260
-		$search_type='';
261
-		$search_type_thirdparty='';
262
-		$search_staff='';
263
-		$search_status=-1;
264
-		$search_stcomm='';
265
-	 	$search_level='';
266
-	 	$search_import_key='';
267
-	 	$toselect='';
268
-		$search_array_options=array();
234
+		$search_id = '';
235
+		$search_nom = '';
236
+		$search_alias = '';
237
+		$search_categ_cus = 0;
238
+		$search_categ_sup = 0;
239
+		$search_sale = '';
240
+		$search_barcode = "";
241
+		$search_customer_code = '';
242
+		$search_supplier_code = '';
243
+		$search_account_customer_code = '';
244
+		$search_account_supplier_code = '';
245
+		$search_town = "";
246
+		$search_zip = "";
247
+		$search_state = "";
248
+		$search_country = '';
249
+		$search_email = '';
250
+		$search_phone = '';
251
+		$search_fax = '';
252
+		$search_url = '';
253
+		$search_idprof1 = '';
254
+		$search_idprof2 = '';
255
+		$search_idprof3 = '';
256
+		$search_idprof4 = '';
257
+		$search_idprof5 = '';
258
+		$search_idprof6 = '';
259
+		$search_vat = '';
260
+		$search_type = '';
261
+		$search_type_thirdparty = '';
262
+		$search_staff = '';
263
+		$search_status = -1;
264
+		$search_stcomm = '';
265
+	 	$search_level = '';
266
+	 	$search_import_key = '';
267
+	 	$toselect = '';
268
+		$search_array_options = array();
269 269
 	}
270 270
 
271 271
 	// Mass actions
272
-	$objectclass='Societe';
273
-	$objectlabel='ThirdParty';
272
+	$objectclass = 'Societe';
273
+	$objectlabel = 'ThirdParty';
274 274
 	$permtoread = $user->rights->societe->lire;
275 275
 	$permtodelete = $user->rights->societe->supprimer;
276 276
 	$uploaddir = $conf->societe->dir_output;
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	if ($action == 'setstcomm')
280 280
 	{
281 281
 		$object = new Client($db);
282
-		$result=$object->fetch(GETPOST('stcommsocid'));
283
-		$object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
284
-		$result=$object->update($object->id, $user);
285
-		if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
282
+		$result = $object->fetch(GETPOST('stcommsocid'));
283
+		$object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
284
+		$result = $object->update($object->id, $user);
285
+		if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
286 286
 
287
-		$action='';
287
+		$action = '';
288 288
 	}
289 289
 }
290 290
 
291
-if ($search_status=='') $search_status=1; // always display active thirdparty first
291
+if ($search_status == '') $search_status = 1; // always display active thirdparty first
292 292
 
293 293
 
294 294
 
@@ -305,131 +305,131 @@  discard block
 block discarded – undo
305 305
  External user socid=x + No permission to see ALL customers => Can see only himself
306 306
  */
307 307
 
308
-$form=new Form($db);
309
-$formother=new FormOther($db);
310
-$companystatic=new Societe($db);
311
-$formcompany=new FormCompany($db);
312
-$prospectstatic=new Client($db);
313
-$prospectstatic->client=2;
308
+$form = new Form($db);
309
+$formother = new FormOther($db);
310
+$companystatic = new Societe($db);
311
+$formcompany = new FormCompany($db);
312
+$prospectstatic = new Client($db);
313
+$prospectstatic->client = 2;
314 314
 $prospectstatic->loadCacheOfProspStatus();
315 315
 
316 316
 
317
-$title=$langs->trans("ListOfThirdParties");
318
-if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers");
319
-if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects");
320
-if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers");
317
+$title = $langs->trans("ListOfThirdParties");
318
+if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title = $langs->trans("ListOfCustomers");
319
+if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title = $langs->trans("ListOfProspects");
320
+if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title = $langs->trans("ListOfSuppliers");
321 321
 
322 322
 // Select every potentiels, and note each potentiels which fit in search parameters
323 323
 $tab_level = array();
324 324
 $sql = "SELECT code, label, sortorder";
325
-$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
326
-$sql.= " WHERE active > 0";
327
-$sql.= " ORDER BY sortorder";
325
+$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
326
+$sql .= " WHERE active > 0";
327
+$sql .= " ORDER BY sortorder";
328 328
 $resql = $db->query($sql);
329 329
 if ($resql)
330 330
 {
331 331
 	while ($obj = $db->fetch_object($resql))
332 332
 	{
333 333
 		// Compute level text
334
-		$level=$langs->trans($obj->code);
335
-		if ($level == $obj->code) $level=$langs->trans($obj->label);
334
+		$level = $langs->trans($obj->code);
335
+		if ($level == $obj->code) $level = $langs->trans($obj->label);
336 336
 		$tab_level[$obj->code] = $level;
337 337
 	}
338 338
 }
339 339
 else dol_print_error($db);
340 340
 
341 341
 $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
342
-$sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
343
-$sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,";
344
-$sql.= " s.tms as date_update, s.datec as date_creation,";
345
-$sql.= " s.code_compta,s.code_compta_fournisseur,";
346
-$sql.= " typent.code as typent_code,";
347
-$sql.= " staff.code as staff_code,";
348
-$sql.= " country.code as country_code,";
349
-$sql.= " state.code_departement as state_code, state.nom as state_name,";
350
-$sql.= " region.code_region as region_code, region.nom as region_name";
342
+$sql .= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
343
+$sql .= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,";
344
+$sql .= " s.tms as date_update, s.datec as date_creation,";
345
+$sql .= " s.code_compta,s.code_compta_fournisseur,";
346
+$sql .= " typent.code as typent_code,";
347
+$sql .= " staff.code as staff_code,";
348
+$sql .= " country.code as country_code,";
349
+$sql .= " state.code_departement as state_code, state.nom as state_name,";
350
+$sql .= " region.code_region as region_code, region.nom as region_name";
351 351
 // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
352 352
 if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
353 353
 // We'll need these fields in order to filter by categ
354 354
 if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
355 355
 if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc";
356 356
 // Add fields from extrafields
357
-foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
357
+foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
358 358
 // Add fields from hooks
359
-$parameters=array();
360
-$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
361
-$sql.=$hookmanager->resPrint;
362
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
363
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
364
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
365
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
366
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
367
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
368
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.	code_region = state.fk_region)";
359
+$parameters = array();
360
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
361
+$sql .= $hookmanager->resPrint;
362
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
363
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
364
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
365
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
366
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
367
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
368
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.	code_region = state.fk_region)";
369 369
 // We'll need this table joined to the select in order to filter by categ
370
-if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
371
-if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
372
-$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
370
+if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
371
+if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
372
+$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
373 373
 // We'll need this table joined to the select in order to filter by sale
374
-if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
375
-$sql.= " WHERE s.entity IN (".getEntity('societe').")";
376
-if (! $user->rights->societe->client->voir && ! $socid)	$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
377
-if ($socid)                $sql.= " AND s.rowid = ".$socid;
378
-if ($search_sale)          $sql.= " AND s.rowid = sc.fk_soc";        // Join for the needed table to filter by sale
379
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";    // client=0, fournisseur=0 must be visible
380
-if ($search_sale)          $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
381
-if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
382
-if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
383
-if ($search_categ_cus == -2)   $sql.= " AND cc.fk_categorie IS NULL";
384
-if ($search_categ_sup == -2)   $sql.= " AND cs.fk_categorie IS NULL";
385
-
386
-if ($search_all)           $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
387
-if (strlen($search_cti))   $sql.= natural_search('s.phone', $search_cti);
388
-
389
-if ($search_id > 0)        $sql.= natural_search("s.rowid",$search_id,1);
390
-if ($search_nom)           $sql.= natural_search("s.nom",$search_nom);
391
-if ($search_alias)         $sql.= natural_search("s.name_alias",$search_alias);
392
-if ($search_nom_only)      $sql.= natural_search("s.nom",$search_nom_only);
393
-if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code);
394
-if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code);
395
-if ($search_account_customer_code) $sql.= natural_search("s.code_compta",$search_account_customer_code);
396
-if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code);
397
-if ($search_town)          $sql.= natural_search("s.town",$search_town);
398
-if (strlen($search_zip))   $sql.= natural_search("s.zip",$search_zip);
399
-if ($search_state)         $sql.= natural_search("state.nom",$search_state);
400
-if ($search_region)        $sql.= natural_search("region.nom",$search_region);
374
+if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
375
+$sql .= " WHERE s.entity IN (".getEntity('societe').")";
376
+if (!$user->rights->societe->client->voir && !$socid)	$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
377
+if ($socid)                $sql .= " AND s.rowid = ".$socid;
378
+if ($search_sale)          $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
379
+if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
380
+if ($search_sale)          $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
381
+if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
382
+if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
383
+if ($search_categ_cus == -2)   $sql .= " AND cc.fk_categorie IS NULL";
384
+if ($search_categ_sup == -2)   $sql .= " AND cs.fk_categorie IS NULL";
385
+
386
+if ($search_all)           $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
387
+if (strlen($search_cti))   $sql .= natural_search('s.phone', $search_cti);
388
+
389
+if ($search_id > 0)        $sql .= natural_search("s.rowid", $search_id, 1);
390
+if ($search_nom)           $sql .= natural_search("s.nom", $search_nom);
391
+if ($search_alias)         $sql .= natural_search("s.name_alias", $search_alias);
392
+if ($search_nom_only)      $sql .= natural_search("s.nom", $search_nom_only);
393
+if ($search_customer_code) $sql .= natural_search("s.code_client", $search_customer_code);
394
+if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
395
+if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code);
396
+if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
397
+if ($search_town)          $sql .= natural_search("s.town", $search_town);
398
+if (strlen($search_zip))   $sql .= natural_search("s.zip", $search_zip);
399
+if ($search_state)         $sql .= natural_search("state.nom", $search_state);
400
+if ($search_region)        $sql .= natural_search("region.nom", $search_region);
401 401
 if ($search_country && $search_country != '-1')       $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
402
-if ($search_email)         $sql.= natural_search("s.email",$search_email);
403
-if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone);
404
-if (strlen($search_fax)) $sql.= natural_search("s.phone", $search_fax);
405
-if ($search_url)           $sql.= natural_search("s.url",$search_url);
406
-if (strlen($search_idprof1)) $sql.= natural_search("s.siren",$search_idprof1);
407
-if (strlen($search_idprof2)) $sql.= natural_search("s.siret",$search_idprof2);
408
-if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3);
409
-if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4);
410
-if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5);
411
-if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6);
412
-if (strlen($search_vat))     $sql.= natural_search("s.tva_intra",$search_vat);
402
+if ($search_email)         $sql .= natural_search("s.email", $search_email);
403
+if (strlen($search_phone)) $sql .= natural_search("s.phone", $search_phone);
404
+if (strlen($search_fax)) $sql .= natural_search("s.phone", $search_fax);
405
+if ($search_url)           $sql .= natural_search("s.url", $search_url);
406
+if (strlen($search_idprof1)) $sql .= natural_search("s.siren", $search_idprof1);
407
+if (strlen($search_idprof2)) $sql .= natural_search("s.siret", $search_idprof2);
408
+if (strlen($search_idprof3)) $sql .= natural_search("s.ape", $search_idprof3);
409
+if (strlen($search_idprof4)) $sql .= natural_search("s.idprof4", $search_idprof4);
410
+if (strlen($search_idprof5)) $sql .= natural_search("s.idprof5", $search_idprof5);
411
+if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6);
412
+if (strlen($search_vat))     $sql .= natural_search("s.tva_intra", $search_vat);
413 413
 // Filter on type of thirdparty
414
-if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")";
415
-if ($search_type > 0 && in_array($search_type,array('4')))         $sql .= " AND s.fournisseur = 1";
414
+if ($search_type > 0 && in_array($search_type, array('1,3', '2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")";
415
+if ($search_type > 0 && in_array($search_type, array('4')))         $sql .= " AND s.fournisseur = 1";
416 416
 if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
417
-if ($search_status!='' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
418
-if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode);
419
-if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2);
420
-if (! empty($search_staff) && $search_staff != '-1')            $sql.= natural_search("s.fk_effectif", $search_staff, 2);
417
+if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
418
+if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode);
419
+if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
420
+if (!empty($search_staff) && $search_staff != '-1')            $sql .= natural_search("s.fk_effectif", $search_staff, 2);
421 421
 if ($search_level)  $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
422
-if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2);
423
-if ($search_import_key)    $sql.= natural_search("s.import_key",$search_import_key);
422
+if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2);
423
+if ($search_import_key)    $sql .= natural_search("s.import_key", $search_import_key);
424 424
 // Add where from extra fields
425 425
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
426 426
 
427 427
 // Add where from hooks
428
-$parameters=array();
429
-$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
430
-$sql.=$hookmanager->resPrint;
428
+$parameters = array();
429
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
430
+$sql .= $hookmanager->resPrint;
431 431
 
432
-$sql.= $db->order($sortfield,$sortorder);
432
+$sql .= $db->order($sortfield, $sortorder);
433 433
 
434 434
 // Count total nb of records
435 435
 $nbtotalofrecords = '';
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 }
446 446
 
447
-$sql.= $db->plimit($limit+1, $offset);
447
+$sql .= $db->plimit($limit + 1, $offset);
448 448
 
449 449
 $resql = $db->query($sql);
450
-if (! $resql)
450
+if (!$resql)
451 451
 {
452 452
 	dol_print_error($db);
453 453
 	exit;
@@ -455,18 +455,18 @@  discard block
 block discarded – undo
455 455
 
456 456
 $num = $db->num_rows($resql);
457 457
 
458
-$arrayofselected=is_array($toselect)?$toselect:array();
458
+$arrayofselected = is_array($toselect) ? $toselect : array();
459 459
 
460
-if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list')
460
+if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list')
461 461
 {
462 462
 	$obj = $db->fetch_object($resql);
463 463
 	$id = $obj->rowid;
464
-	if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
465
-              if( $obj->client > 0) {
464
+	if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) {
465
+              if ($obj->client > 0) {
466 466
                        header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
467 467
                        exit;
468 468
                }
469
-               if( $obj->fournisseur > 0){
469
+               if ($obj->fournisseur > 0) {
470 470
                        header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
471 471
                        exit;
472 472
                }
@@ -476,84 +476,84 @@  discard block
 block discarded – undo
476 476
 	exit;
477 477
 }
478 478
 
479
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
480
-llxHeader('',$langs->trans("ThirdParty"),$help_url);
479
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
480
+llxHeader('', $langs->trans("ThirdParty"), $help_url);
481 481
 
482
-$param='';
483
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
484
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
482
+$param = '';
483
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
484
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
485 485
 if ($search_all != '')     $param = "&sall=".urlencode($search_all);
486
-if ($sall != '')           $param.= "&sall=".urlencode($sall);
487
-if ($search_categ_cus > 0) $param.= '&search_categ_cus='.urlencode($search_categ_cus);
488
-if ($search_categ_sup > 0) $param.= '&search_categ_sup='.urlencode($search_categ_sup);
489
-if ($search_sale > 0)	   $param.= '&search_sale='.urlencode($search_sale);
490
-if ($search_id > 0)        $param.= "&search_id=".urlencode($search_id);
491
-if ($search_nom != '')     $param.= "&search_nom=".urlencode($search_nom);
492
-if ($search_alias != '')   $param.= "&search_alias=".urlencode($search_alias);
493
-if ($search_town != '')    $param.= "&search_town=".urlencode($search_town);
494
-if ($search_zip != '')     $param.= "&search_zip=".urlencode($search_zip);
495
-if ($search_phone != '')   $param.= "&search_phone=".urlencode($search_phone);
496
-if ($search_fax != '')     $param.= "&search_fax=".urlencode($search_fax);
497
-if ($search_email != '')   $param.= "&search_email=".urlencode($search_email);
498
-if ($search_url != '')     $param.= "&search_url=".urlencode($search_url);
499
-if ($search_state != '')   $param.= "&search_state=".urlencode($search_state);
500
-if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
501
-if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
502
-if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
503
-if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
504
-if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
505
-if ($search_barcode != '') $param.= "&search_barcode=".urlencode($search_barcode);
506
-if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
507
-if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
508
-if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
509
-if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
510
-if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
511
-if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
512
-if ($search_vat != '')     $param.= '&search_vat='.urlencode($search_vat);
513
-if ($search_type_thirdparty != '')    $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
514
-if ($search_type != '')    $param.='&search_type='.urlencode($search_type);
515
-if (is_array($search_level) && count($search_level)) foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel);
516
-if ($search_status != '')  $param.='&search_status='.urlencode($search_status);
517
-if ($search_stcomm != '')  $param.='&search_stcomm='.urlencode($search_stcomm);
518
-if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
519
-if ($type != '') $param.='&type='.urlencode($type);
520
-if ($optioncss != '')      $param.='&optioncss='.urlencode($optioncss);
486
+if ($sall != '')           $param .= "&sall=".urlencode($sall);
487
+if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
488
+if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup);
489
+if ($search_sale > 0)	   $param .= '&search_sale='.urlencode($search_sale);
490
+if ($search_id > 0)        $param .= "&search_id=".urlencode($search_id);
491
+if ($search_nom != '')     $param .= "&search_nom=".urlencode($search_nom);
492
+if ($search_alias != '')   $param .= "&search_alias=".urlencode($search_alias);
493
+if ($search_town != '')    $param .= "&search_town=".urlencode($search_town);
494
+if ($search_zip != '')     $param .= "&search_zip=".urlencode($search_zip);
495
+if ($search_phone != '')   $param .= "&search_phone=".urlencode($search_phone);
496
+if ($search_fax != '')     $param .= "&search_fax=".urlencode($search_fax);
497
+if ($search_email != '')   $param .= "&search_email=".urlencode($search_email);
498
+if ($search_url != '')     $param .= "&search_url=".urlencode($search_url);
499
+if ($search_state != '')   $param .= "&search_state=".urlencode($search_state);
500
+if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
501
+if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code);
502
+if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code);
503
+if ($search_account_customer_code != '') $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
504
+if ($search_account_supplier_code != '') $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
505
+if ($search_barcode != '') $param .= "&search_barcode=".urlencode($search_barcode);
506
+if ($search_idprof1 != '') $param .= '&search_idprof1='.urlencode($search_idprof1);
507
+if ($search_idprof2 != '') $param .= '&search_idprof2='.urlencode($search_idprof2);
508
+if ($search_idprof3 != '') $param .= '&search_idprof3='.urlencode($search_idprof3);
509
+if ($search_idprof4 != '') $param .= '&search_idprof4='.urlencode($search_idprof4);
510
+if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof5);
511
+if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6);
512
+if ($search_vat != '')     $param .= '&search_vat='.urlencode($search_vat);
513
+if ($search_type_thirdparty != '')    $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
514
+if ($search_type != '')    $param .= '&search_type='.urlencode($search_type);
515
+if (is_array($search_level) && count($search_level)) foreach ($search_level as $slevel) $param .= '&search_level[]='.urlencode($slevel);
516
+if ($search_status != '')  $param .= '&search_status='.urlencode($search_status);
517
+if ($search_stcomm != '')  $param .= '&search_stcomm='.urlencode($search_stcomm);
518
+if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key);
519
+if ($type != '') $param .= '&type='.urlencode($type);
520
+if ($optioncss != '')      $param .= '&optioncss='.urlencode($optioncss);
521 521
 // Add $param from extra fields
522 522
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
523 523
 
524 524
 // Show delete result message
525 525
 if (GETPOST('delsoc'))
526 526
 {
527
-	setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
527
+	setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
528 528
 }
529 529
 
530 530
 // List of mass actions available
531
-$arrayofmassactions =  array(
531
+$arrayofmassactions = array(
532 532
 	'presend'=>$langs->trans("SendByMail"),
533 533
 //    'builddoc'=>$langs->trans("PDFMerge"),
534 534
 );
535 535
 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
536
-if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
537
-if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
538
-$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
536
+if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = $langs->trans("Delete");
537
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
538
+$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
539 539
 
540
-$newcardbutton='';
540
+$newcardbutton = '';
541 541
 if ($user->rights->societe->creer)
542 542
 {
543
-	$typefilter='';
544
-	$label='MenuNewThirdParty';
543
+	$typefilter = '';
544
+	$label = 'MenuNewThirdParty';
545 545
 
546
-	if(! empty($type))
546
+	if (!empty($type))
547 547
 	{
548 548
 		$typefilter = '&amp;type='.$type;
549
-		if($type == 'p') $label='MenuNewProspect';
550
-		if($type == 'c') $label='MenuNewCustomer';
551
-		if($type == 'f') $label='NewSupplier';
549
+		if ($type == 'p') $label = 'MenuNewProspect';
550
+		if ($type == 'c') $label = 'MenuNewCustomer';
551
+		if ($type == 'f') $label = 'NewSupplier';
552 552
 	}
553 553
 
554 554
 	$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter.'"><span class="valignmiddle">'.$langs->trans($label).'</span>';
555
-	$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
556
-	$newcardbutton.= '</a>';
555
+	$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
556
+	$newcardbutton .= '</a>';
557 557
 }
558 558
 
559 559
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
@@ -567,258 +567,258 @@  discard block
 block discarded – undo
567 567
 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
568 568
 
569 569
 $langs->load("other");
570
-$textprofid=array();
571
-foreach(array(1,2,3,4,5,6) as $key)
570
+$textprofid = array();
571
+foreach (array(1, 2, 3, 4, 5, 6) as $key)
572 572
 {
573
-	$label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
574
-	$textprofid[$key]='';
573
+	$label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
574
+	$textprofid[$key] = '';
575 575
 	if ($label != "ProfId".$key.$mysoc->country_code)
576 576
 	{	// Get only text between ()
577
-		if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
578
-		$textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
577
+		if (preg_match('/\((.*)\)/i', $label, $reg)) $label = $reg[1];
578
+		$textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
579 579
 	}
580 580
 }
581 581
 
582
-$topicmail="Information";
583
-$modelmail="thirdparty";
584
-$objecttmp=new Societe($db);
585
-$trackid='thi'.$object->id;
582
+$topicmail = "Information";
583
+$modelmail = "thirdparty";
584
+$objecttmp = new Societe($db);
585
+$trackid = 'thi'.$object->id;
586 586
 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
587 587
 
588 588
 if ($search_all)
589 589
 {
590
-	foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
591
-	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall).'</div>';
590
+	foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
591
+	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
592 592
 }
593 593
 
594 594
 // Filter on categories
595
-$moreforfilter='';
595
+$moreforfilter = '';
596 596
 if (empty($type) || $type == 'c' || $type == 'p')
597 597
 {
598
-	if (! empty($conf->categorie->enabled))
598
+	if (!empty($conf->categorie->enabled))
599 599
 	{
600
-		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
601
-		$moreforfilter.='<div class="divsearchfield">';
602
-	 	$moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
603
-		$moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
604
-	 	$moreforfilter.='</div>';
600
+		require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
601
+		$moreforfilter .= '<div class="divsearchfield">';
602
+	 	$moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
603
+		$moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
604
+	 	$moreforfilter .= '</div>';
605 605
 	}
606 606
 }
607 607
 if (empty($type) || $type == 'f')
608 608
 {
609
-	if (! empty($conf->categorie->enabled))
609
+	if (!empty($conf->categorie->enabled))
610 610
 	{
611
-		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
612
-		$moreforfilter.='<div class="divsearchfield">';
613
-		$moreforfilter.=$langs->trans('SuppliersCategoriesShort').': ';
614
-		$moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1);
615
-		$moreforfilter.='</div>';
611
+		require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
612
+		$moreforfilter .= '<div class="divsearchfield">';
613
+		$moreforfilter .= $langs->trans('SuppliersCategoriesShort').': ';
614
+		$moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1);
615
+		$moreforfilter .= '</div>';
616 616
 	}
617 617
 }
618 618
 
619 619
 // If the user can view prospects other than his'
620 620
 if ($user->rights->societe->client->voir || $socid)
621 621
 {
622
- 	$moreforfilter.='<div class="divsearchfield">';
623
- 	$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
624
-	$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
625
-	$moreforfilter.='</div>';
622
+ 	$moreforfilter .= '<div class="divsearchfield">';
623
+ 	$moreforfilter .= $langs->trans('SalesRepresentatives').': ';
624
+	$moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
625
+	$moreforfilter .= '</div>';
626 626
 }
627 627
 if ($moreforfilter)
628 628
 {
629 629
 	print '<div class="liste_titre liste_titre_bydiv centpercent">';
630 630
 	print $moreforfilter;
631
-	$parameters=array('type'=>$type);
632
-	$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
631
+	$parameters = array('type'=>$type);
632
+	$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
633 633
 	print $hookmanager->resPrint;
634 634
 	print '</div>';
635 635
 }
636 636
 
637
-$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
638
-$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
639
-if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
637
+$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
638
+$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
639
+if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
640 640
 
641 641
 if (empty($arrayfields['customerorsupplier']['checked'])) print '<input type="hidden" name="type" value="'.$type.'">';
642 642
 
643 643
 print '<div class="div-table-responsive">';
644
-print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
644
+print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
645 645
 
646 646
 // Fields title search
647 647
 print '<tr class="liste_titre_filter">';
648
-if (! empty($arrayfields['s.rowid']['checked']))
648
+if (!empty($arrayfields['s.rowid']['checked']))
649 649
 {
650 650
 	print '<td class="liste_titre">';
651 651
 	print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
652 652
 	print '</td>';
653 653
 }
654
-if (! empty($arrayfields['s.nom']['checked']))
654
+if (!empty($arrayfields['s.nom']['checked']))
655 655
 {
656 656
 	print '<td class="liste_titre">';
657
-	if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
657
+	if (!empty($search_nom_only) && empty($search_nom)) $search_nom = $search_nom_only;
658 658
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
659 659
 	print '</td>';
660 660
 }
661
-if (! empty($arrayfields['s.name_alias']['checked']))
661
+if (!empty($arrayfields['s.name_alias']['checked']))
662 662
 {
663 663
 	print '<td class="liste_titre">';
664 664
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
665 665
 	print '</td>';
666 666
 }
667 667
 // Barcode
668
-if (! empty($arrayfields['s.barcode']['checked']))
668
+if (!empty($arrayfields['s.barcode']['checked']))
669 669
 {
670 670
 	print '<td class="liste_titre">';
671 671
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
672 672
 	print '</td>';
673 673
 }
674 674
 // Customer code
675
-if (! empty($arrayfields['s.code_client']['checked']))
675
+if (!empty($arrayfields['s.code_client']['checked']))
676 676
 {
677 677
 	print '<td class="liste_titre">';
678 678
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
679 679
 	print '</td>';
680 680
 }
681 681
 // Supplier code
682
-if (! empty($arrayfields['s.code_fournisseur']['checked']))
682
+if (!empty($arrayfields['s.code_fournisseur']['checked']))
683 683
 {
684 684
 	print '<td class="liste_titre">';
685 685
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
686 686
 	print '</td>';
687 687
 }
688 688
 // Account Customer code
689
-if (! empty($arrayfields['s.code_compta']['checked']))
689
+if (!empty($arrayfields['s.code_compta']['checked']))
690 690
 {
691 691
 	print '<td class="liste_titre">';
692 692
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
693 693
 	print '</td>';
694 694
 }
695 695
 // Account Supplier code
696
-if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
696
+if (!empty($arrayfields['s.code_compta_fournisseur']['checked']))
697 697
 {
698 698
 	print '<td class="liste_titre">';
699 699
 	print '<input class="flat maxwidth50" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
700 700
 	print '</td>';
701 701
 }
702 702
 // Town
703
-if (! empty($arrayfields['s.town']['checked']))
703
+if (!empty($arrayfields['s.town']['checked']))
704 704
 {
705 705
 	print '<td class="liste_titre">';
706 706
 	print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
707 707
 	print '</td>';
708 708
 }
709 709
 // Zip
710
-if (! empty($arrayfields['s.zip']['checked']))
710
+if (!empty($arrayfields['s.zip']['checked']))
711 711
 {
712 712
 	print '<td class="liste_titre">';
713 713
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
714 714
 	print '</td>';
715 715
 }
716 716
 // State
717
-if (! empty($arrayfields['state.nom']['checked']))
717
+if (!empty($arrayfields['state.nom']['checked']))
718 718
 {
719 719
 	print '<td class="liste_titre">';
720 720
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
721 721
 	print '</td>';
722 722
 }
723 723
 // Region
724
-if (! empty($arrayfields['region.nom']['checked']))
724
+if (!empty($arrayfields['region.nom']['checked']))
725 725
 {
726 726
 	print '<td class="liste_titre">';
727 727
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
728 728
 	print '</td>';
729 729
 }
730 730
 // Country
731
-if (! empty($arrayfields['country.code_iso']['checked']))
731
+if (!empty($arrayfields['country.code_iso']['checked']))
732 732
 {
733 733
 	print '<td class="liste_titre" align="center">';
734
-	print $form->select_country($search_country,'search_country','',0,'maxwidth100');
734
+	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100');
735 735
 	print '</td>';
736 736
 }
737 737
 // Company type
738
-if (! empty($arrayfields['typent.code']['checked']))
738
+if (!empty($arrayfields['typent.code']['checked']))
739 739
 {
740 740
 	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
741
-	print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
741
+	print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
742 742
 	print '</td>';
743 743
 }
744 744
 // Staff
745
-if (! empty($arrayfields['staff.code']['checked']))
745
+if (!empty($arrayfields['staff.code']['checked']))
746 746
 {
747 747
 	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
748 748
 	print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100');
749 749
 	print '</td>';
750 750
 }
751
-if (! empty($arrayfields['s.email']['checked']))
751
+if (!empty($arrayfields['s.email']['checked']))
752 752
 {
753 753
 	// Email
754 754
 	print '<td class="liste_titre">';
755 755
 	print '<input class="flat searchemail maxwidth50" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
756 756
 	print '</td>';
757 757
 }
758
-if (! empty($arrayfields['s.phone']['checked']))
758
+if (!empty($arrayfields['s.phone']['checked']))
759 759
 {
760 760
 	// Phone
761 761
 	print '<td class="liste_titre">';
762 762
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
763 763
 	print '</td>';
764 764
 }
765
-if (! empty($arrayfields['s.fax']['checked']))
765
+if (!empty($arrayfields['s.fax']['checked']))
766 766
 {
767 767
 	// Fax
768 768
 	print '<td class="liste_titre">';
769 769
 	print '<input class="flat searchstring" size="4" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
770 770
 	print '</td>';
771 771
 }
772
-if (! empty($arrayfields['s.url']['checked']))
772
+if (!empty($arrayfields['s.url']['checked']))
773 773
 {
774 774
 	// Url
775 775
 	print '<td class="liste_titre">';
776 776
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
777 777
 	print '</td>';
778 778
 }
779
-if (! empty($arrayfields['s.siren']['checked']))
779
+if (!empty($arrayfields['s.siren']['checked']))
780 780
 {
781 781
 	// IdProf1
782 782
 	print '<td class="liste_titre">';
783 783
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
784 784
 	print '</td>';
785 785
 }
786
-if (! empty($arrayfields['s.siret']['checked']))
786
+if (!empty($arrayfields['s.siret']['checked']))
787 787
 {
788 788
 	// IdProf2
789 789
 	print '<td class="liste_titre">';
790 790
 	print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
791 791
 	print '</td>';
792 792
 }
793
-if (! empty($arrayfields['s.ape']['checked']))
793
+if (!empty($arrayfields['s.ape']['checked']))
794 794
 {
795 795
 	// IdProf3
796 796
 	print '<td class="liste_titre">';
797 797
 	print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
798 798
 	print '</td>';
799 799
 }
800
-if (! empty($arrayfields['s.idprof4']['checked']))
800
+if (!empty($arrayfields['s.idprof4']['checked']))
801 801
 {
802 802
 	// IdProf4
803 803
 	print '<td class="liste_titre">';
804 804
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
805 805
 	print '</td>';
806 806
 }
807
-if (! empty($arrayfields['s.idprof5']['checked']))
807
+if (!empty($arrayfields['s.idprof5']['checked']))
808 808
 {
809 809
 	// IdProf5
810 810
 	print '<td class="liste_titre">';
811 811
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
812 812
 	print '</td>';
813 813
 }
814
-if (! empty($arrayfields['s.idprof6']['checked']))
814
+if (!empty($arrayfields['s.idprof6']['checked']))
815 815
 {
816 816
 	// IdProf6
817 817
 	print '<td class="liste_titre">';
818 818
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
819 819
 	print '</td>';
820 820
 }
821
-if (! empty($arrayfields['s.tva_intra']['checked']))
821
+if (!empty($arrayfields['s.tva_intra']['checked']))
822 822
 {
823 823
 	// Vat number
824 824
 	print '<td class="liste_titre">';
@@ -827,34 +827,34 @@  discard block
 block discarded – undo
827 827
 }
828 828
 
829 829
 // Type (customer/prospect/supplier)
830
-if (! empty($arrayfields['customerorsupplier']['checked']))
830
+if (!empty($arrayfields['customerorsupplier']['checked']))
831 831
 {
832 832
 	print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
833 833
 	if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
834 834
 	print '<select class="flat" name="search_type">';
835
-	print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
836
-	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
837
-	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
835
+	print '<option value="-1"'.($search_type == '' ? ' selected' : '').'>&nbsp;</option>';
836
+	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
837
+	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
838 838
 	//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
839
-	print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
840
-	print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
839
+	print '<option value="4"'.($search_type == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
840
+	print '<option value="0"'.($search_type == '0' ? ' selected' : '').'>'.$langs->trans('Others').'</option>';
841 841
 	print '</select></td>';
842 842
 }
843 843
 // Prospect level
844
-if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
844
+if (!empty($arrayfields['s.fk_prospectlevel']['checked']))
845 845
 {
846 846
  	print '<td class="liste_titre" align="center">';
847 847
  	print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
848 848
 	print '</td>';
849 849
 }
850 850
 // Prospect status
851
-if (! empty($arrayfields['s.fk_stcomm']['checked']))
851
+if (!empty($arrayfields['s.fk_stcomm']['checked']))
852 852
 {
853 853
 	print '<td class="liste_titre maxwidthonsmartphone" align="center">';
854
-	$arraystcomm=array();
855
-	foreach($prospectstatic->cacheprospectstatus as $key => $val)
854
+	$arraystcomm = array();
855
+	foreach ($prospectstatic->cacheprospectstatus as $key => $val)
856 856
 	{
857
-		$arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
857
+		$arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
858 858
 	}
859 859
 	print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
860 860
 	print '</td>';
@@ -863,29 +863,29 @@  discard block
 block discarded – undo
863 863
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
864 864
 
865 865
 // Fields from hook
866
-$parameters=array('arrayfields'=>$arrayfields);
867
-$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
866
+$parameters = array('arrayfields'=>$arrayfields);
867
+$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
868 868
 print $hookmanager->resPrint;
869 869
 // Date creation
870
-if (! empty($arrayfields['s.datec']['checked']))
870
+if (!empty($arrayfields['s.datec']['checked']))
871 871
 {
872 872
 	print '<td class="liste_titre">';
873 873
 	print '</td>';
874 874
 }
875 875
 // Date modification
876
-if (! empty($arrayfields['s.tms']['checked']))
876
+if (!empty($arrayfields['s.tms']['checked']))
877 877
 {
878 878
 	print '<td class="liste_titre">';
879 879
 	print '</td>';
880 880
 }
881 881
 // Status
882
-if (! empty($arrayfields['s.status']['checked']))
882
+if (!empty($arrayfields['s.status']['checked']))
883 883
 {
884 884
 	print '<td class="liste_titre center minwidth75imp">';
885
-	print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1);
885
+	print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1);
886 886
 	print '</td>';
887 887
 }
888
-if (! empty($arrayfields['s.import_key']['checked']))
888
+if (!empty($arrayfields['s.import_key']['checked']))
889 889
 {
890 890
 	print '<td class="liste_titre center">';
891 891
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
@@ -893,340 +893,340 @@  discard block
 block discarded – undo
893 893
 }
894 894
 // Action column
895 895
 print '<td class="liste_titre" align="right">';
896
-$searchpicto=$form->showFilterButtons();
896
+$searchpicto = $form->showFilterButtons();
897 897
 print $searchpicto;
898 898
 print '</td>';
899 899
 
900 900
 print "</tr>\n";
901 901
 
902 902
 print '<tr class="liste_titre">';
903
-if (! empty($arrayfields['s.rowid']['checked']))                   print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
904
-if (! empty($arrayfields['s.nom']['checked']))                     print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
905
-if (! empty($arrayfields['s.name_alias']['checked']))              print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
906
-if (! empty($arrayfields['s.barcode']['checked']))                 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
907
-if (! empty($arrayfields['s.code_client']['checked']))             print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
908
-if (! empty($arrayfields['s.code_fournisseur']['checked']))        print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
909
-if (! empty($arrayfields['s.code_compta']['checked']))             print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
910
-if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
911
-if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
912
-if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
913
-if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
914
-if (! empty($arrayfields['region.nom']['checked']))       print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
915
-if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
916
-if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
917
-if (! empty($arrayfields['staff.code']['checked']))       print_liste_field_titre($arrayfields['staff.code']['label'],$_SERVER["PHP_SELF"],"staff.code","",$param,'align="center"',$sortfield,$sortorder);
918
-if (! empty($arrayfields['s.email']['checked']))          print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
919
-if (! empty($arrayfields['s.phone']['checked']))          print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder);
920
-if (! empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'],$_SERVER["PHP_SELF"],"s.fax","",$param,'',$sortfield,$sortorder);
921
-if (! empty($arrayfields['s.url']['checked']))            print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder);
922
-if (! empty($arrayfields['s.siren']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
923
-if (! empty($arrayfields['s.siret']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
924
-if (! empty($arrayfields['s.ape']['checked']))            print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
925
-if (! empty($arrayfields['s.idprof4']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
926
-if (! empty($arrayfields['s.idprof5']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
927
-if (! empty($arrayfields['s.idprof6']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
928
-if (! empty($arrayfields['s.tva_intra']['checked']))      print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder);
929
-if (! empty($arrayfields['customerorsupplier']['checked']))        print_liste_field_titre('');   // type of customer
930
-if (! empty($arrayfields['s.fk_prospectlevel']['checked']))        print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
931
-if (! empty($arrayfields['s.fk_stcomm']['checked']))               print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
903
+if (!empty($arrayfields['s.rowid']['checked']))                   print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
904
+if (!empty($arrayfields['s.nom']['checked']))                     print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
905
+if (!empty($arrayfields['s.name_alias']['checked']))              print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
906
+if (!empty($arrayfields['s.barcode']['checked']))                 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
907
+if (!empty($arrayfields['s.code_client']['checked']))             print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
908
+if (!empty($arrayfields['s.code_fournisseur']['checked']))        print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
909
+if (!empty($arrayfields['s.code_compta']['checked']))             print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
910
+if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
911
+if (!empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
912
+if (!empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
913
+if (!empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
914
+if (!empty($arrayfields['region.nom']['checked']))       print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
915
+if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
916
+if (!empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
917
+if (!empty($arrayfields['staff.code']['checked']))       print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, 'align="center"', $sortfield, $sortorder);
918
+if (!empty($arrayfields['s.email']['checked']))          print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
919
+if (!empty($arrayfields['s.phone']['checked']))          print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
920
+if (!empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
921
+if (!empty($arrayfields['s.url']['checked']))            print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
922
+if (!empty($arrayfields['s.siren']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, 'class="nowrap"', $sortfield, $sortorder);
923
+if (!empty($arrayfields['s.siret']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, 'class="nowrap"', $sortfield, $sortorder);
924
+if (!empty($arrayfields['s.ape']['checked']))            print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, 'class="nowrap"', $sortfield, $sortorder);
925
+if (!empty($arrayfields['s.idprof4']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, 'class="nowrap"', $sortfield, $sortorder);
926
+if (!empty($arrayfields['s.idprof5']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, 'class="nowrap"', $sortfield, $sortorder);
927
+if (!empty($arrayfields['s.idprof6']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, 'class="nowrap"', $sortfield, $sortorder);
928
+if (!empty($arrayfields['s.tva_intra']['checked']))      print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'class="nowrap"', $sortfield, $sortorder);
929
+if (!empty($arrayfields['customerorsupplier']['checked']))        print_liste_field_titre(''); // type of customer
930
+if (!empty($arrayfields['s.fk_prospectlevel']['checked']))        print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, 'align="center"', $sortfield, $sortorder);
931
+if (!empty($arrayfields['s.fk_stcomm']['checked']))               print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, 'align="center"', $sortfield, $sortorder);
932 932
 // Extra fields
933 933
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
934 934
 // Hook fields
935
-$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
936
-$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
935
+$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
936
+$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
937 937
 print $hookmanager->resPrint;
938
-if (! empty($arrayfields['s.datec']['checked']))      print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
939
-if (! empty($arrayfields['s.tms']['checked']))        print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
940
-if (! empty($arrayfields['s.status']['checked']))     print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
941
-if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder);
942
-print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
938
+if (!empty($arrayfields['s.datec']['checked']))      print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
939
+if (!empty($arrayfields['s.tms']['checked']))        print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
940
+if (!empty($arrayfields['s.status']['checked']))     print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, 'align="center"', $sortfield, $sortorder);
941
+if (!empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, 'align="center"', $sortfield, $sortorder);
942
+print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
943 943
 print "</tr>\n";
944 944
 
945 945
 
946 946
 $i = 0;
947
-$totalarray=array();
947
+$totalarray = array();
948 948
 while ($i < min($num, $limit))
949 949
 {
950 950
 	$obj = $db->fetch_object($resql);
951 951
 
952
-	$companystatic->id=$obj->rowid;
953
-	$companystatic->name=$obj->name;
954
-	$companystatic->name_alias=$obj->name_alias;
955
-	$companystatic->logo=$obj->logo;
956
-	$companystatic->canvas=$obj->canvas;
957
-	$companystatic->client=$obj->client;
958
-	$companystatic->status=$obj->status;
959
-	$companystatic->email=$obj->email;
960
-	$companystatic->fournisseur=$obj->fournisseur;
961
-	$companystatic->code_client=$obj->code_client;
962
-	$companystatic->code_fournisseur=$obj->code_fournisseur;
952
+	$companystatic->id = $obj->rowid;
953
+	$companystatic->name = $obj->name;
954
+	$companystatic->name_alias = $obj->name_alias;
955
+	$companystatic->logo = $obj->logo;
956
+	$companystatic->canvas = $obj->canvas;
957
+	$companystatic->client = $obj->client;
958
+	$companystatic->status = $obj->status;
959
+	$companystatic->email = $obj->email;
960
+	$companystatic->fournisseur = $obj->fournisseur;
961
+	$companystatic->code_client = $obj->code_client;
962
+	$companystatic->code_fournisseur = $obj->code_fournisseur;
963 963
 
964
-	$companystatic->code_compta_client=$obj->code_compta;
965
-	$companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
964
+	$companystatic->code_compta_client = $obj->code_compta;
965
+	$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
966 966
 
967
-   	$companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
967
+   	$companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
968 968
 
969 969
 	print '<tr class="oddeven">';
970
-	if (! empty($arrayfields['s.rowid']['checked']))
970
+	if (!empty($arrayfields['s.rowid']['checked']))
971 971
 	{
972 972
 		print '<td class="tdoverflowmax50">';
973 973
 		print $obj->rowid;
974 974
 		print "</td>\n";
975
-		if (! $i) $totalarray['nbfield']++;
975
+		if (!$i) $totalarray['nbfield']++;
976 976
 	}
977
-	if (! empty($arrayfields['s.nom']['checked']))
977
+	if (!empty($arrayfields['s.nom']['checked']))
978 978
 	{
979 979
 		$savalias = $obj->name_alias;
980
-		if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
980
+		if (!empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias = '';
981 981
 		print '<td class="tdoverflowmax200">';
982 982
 		print $companystatic->getNomUrl(1, '', 100, 0, 1);
983 983
 		print "</td>\n";
984 984
 		$companystatic->name_alias = $savalias;
985
-        if (! $i) $totalarray['nbfield']++;
985
+        if (!$i) $totalarray['nbfield']++;
986 986
 	}
987
-	if (! empty($arrayfields['s.name_alias']['checked']))
987
+	if (!empty($arrayfields['s.name_alias']['checked']))
988 988
 	{
989 989
 		print '<td class="tdoverflowmax200">';
990 990
 		print $companystatic->name_alias;
991 991
 		print "</td>\n";
992
-		if (! $i) $totalarray['nbfield']++;
992
+		if (!$i) $totalarray['nbfield']++;
993 993
 	}
994 994
 	// Barcode
995
-	if (! empty($arrayfields['s.barcode']['checked']))
995
+	if (!empty($arrayfields['s.barcode']['checked']))
996 996
 	{
997 997
 		print '<td>'.$obj->barcode.'</td>';
998
-		if (! $i) $totalarray['nbfield']++;
998
+		if (!$i) $totalarray['nbfield']++;
999 999
 	}
1000 1000
 	// Customer code
1001
-	if (! empty($arrayfields['s.code_client']['checked']))
1001
+	if (!empty($arrayfields['s.code_client']['checked']))
1002 1002
 	{
1003 1003
 		print '<td class="nowraponall">'.$obj->code_client.'</td>';
1004
-		if (! $i) $totalarray['nbfield']++;
1004
+		if (!$i) $totalarray['nbfield']++;
1005 1005
 	}
1006 1006
 	// Supplier code
1007
-	if (! empty($arrayfields['s.code_fournisseur']['checked']))
1007
+	if (!empty($arrayfields['s.code_fournisseur']['checked']))
1008 1008
 	{
1009 1009
 		print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>';
1010
-		if (! $i) $totalarray['nbfield']++;
1010
+		if (!$i) $totalarray['nbfield']++;
1011 1011
 	}
1012 1012
 	// Account customer code
1013
-	if (! empty($arrayfields['s.code_compta']['checked']))
1013
+	if (!empty($arrayfields['s.code_compta']['checked']))
1014 1014
 	{
1015 1015
 		print '<td>'.$obj->code_compta.'</td>';
1016
-		if (! $i) $totalarray['nbfield']++;
1016
+		if (!$i) $totalarray['nbfield']++;
1017 1017
 	}
1018 1018
 	// Account supplier code
1019
-	if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
1019
+	if (!empty($arrayfields['s.code_compta_fournisseur']['checked']))
1020 1020
 	{
1021 1021
 		print '<td>'.$obj->code_compta_fournisseur.'</td>';
1022
-		if (! $i) $totalarray['nbfield']++;
1022
+		if (!$i) $totalarray['nbfield']++;
1023 1023
 	}
1024 1024
 	// Town
1025
-	if (! empty($arrayfields['s.town']['checked']))
1025
+	if (!empty($arrayfields['s.town']['checked']))
1026 1026
 	{
1027 1027
 		print "<td>".$obj->town."</td>\n";
1028
-		if (! $i) $totalarray['nbfield']++;
1028
+		if (!$i) $totalarray['nbfield']++;
1029 1029
 	}
1030 1030
 	// Zip
1031
-	if (! empty($arrayfields['s.zip']['checked']))
1031
+	if (!empty($arrayfields['s.zip']['checked']))
1032 1032
 	{
1033 1033
 		print "<td>".$obj->zip."</td>\n";
1034
-		if (! $i) $totalarray['nbfield']++;
1034
+		if (!$i) $totalarray['nbfield']++;
1035 1035
 	}
1036 1036
 	// State
1037
-	if (! empty($arrayfields['state.nom']['checked']))
1037
+	if (!empty($arrayfields['state.nom']['checked']))
1038 1038
 	{
1039 1039
 		print "<td>".$obj->state_name."</td>\n";
1040
-		if (! $i) $totalarray['nbfield']++;
1040
+		if (!$i) $totalarray['nbfield']++;
1041 1041
 	}
1042 1042
 	// Region
1043
-	if (! empty($arrayfields['region.nom']['checked']))
1043
+	if (!empty($arrayfields['region.nom']['checked']))
1044 1044
 	{
1045 1045
 		print "<td>".$obj->region_name."</td>\n";
1046
-		if (! $i) $totalarray['nbfield']++;
1046
+		if (!$i) $totalarray['nbfield']++;
1047 1047
 	}
1048 1048
 	// Country
1049
-	if (! empty($arrayfields['country.code_iso']['checked']))
1049
+	if (!empty($arrayfields['country.code_iso']['checked']))
1050 1050
 	{
1051 1051
 		print '<td align="center">';
1052
-		$tmparray=getCountry($obj->fk_pays,'all');
1052
+		$tmparray = getCountry($obj->fk_pays, 'all');
1053 1053
 		print $tmparray['label'];
1054 1054
 		print '</td>';
1055
-		if (! $i) $totalarray['nbfield']++;
1055
+		if (!$i) $totalarray['nbfield']++;
1056 1056
 	}
1057 1057
 	// Type ent
1058
-	if (! empty($arrayfields['typent.code']['checked']))
1058
+	if (!empty($arrayfields['typent.code']['checked']))
1059 1059
 	{
1060 1060
 		print '<td align="center">';
1061
-		if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
1061
+		if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
1062 1062
 		print $typenArray[$obj->typent_code];
1063 1063
 		print '</td>';
1064
-		if (! $i) $totalarray['nbfield']++;
1064
+		if (!$i) $totalarray['nbfield']++;
1065 1065
 	}
1066 1066
 	// Staff
1067
-	if (! empty($arrayfields['staff.code']['checked']))
1067
+	if (!empty($arrayfields['staff.code']['checked']))
1068 1068
 	{
1069 1069
 		print '<td align="center">';
1070
-		if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
1070
+		if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1);
1071 1071
 		print $staffArray[$obj->staff_code];
1072 1072
 		print '</td>';
1073
-		if (! $i) $totalarray['nbfield']++;
1073
+		if (!$i) $totalarray['nbfield']++;
1074 1074
 	}
1075
-	if (! empty($arrayfields['s.email']['checked']))
1075
+	if (!empty($arrayfields['s.email']['checked']))
1076 1076
 	{
1077 1077
 		print "<td>".$obj->email."</td>\n";
1078
-		if (! $i) $totalarray['nbfield']++;
1078
+		if (!$i) $totalarray['nbfield']++;
1079 1079
 	}
1080
-	if (! empty($arrayfields['s.phone']['checked']))
1080
+	if (!empty($arrayfields['s.phone']['checked']))
1081 1081
 	{
1082 1082
 		print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid)."</td>\n";
1083
-		if (! $i) $totalarray['nbfield']++;
1083
+		if (!$i) $totalarray['nbfield']++;
1084 1084
 	}
1085
-	if (! empty($arrayfields['s.fax']['checked']))
1085
+	if (!empty($arrayfields['s.fax']['checked']))
1086 1086
 	{
1087 1087
 		print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid)."</td>\n";
1088
-		if (! $i) $totalarray['nbfield']++;
1088
+		if (!$i) $totalarray['nbfield']++;
1089 1089
 	}
1090
-	if (! empty($arrayfields['s.url']['checked']))
1090
+	if (!empty($arrayfields['s.url']['checked']))
1091 1091
 	{
1092 1092
 		print "<td>".$obj->url."</td>\n";
1093
-		if (! $i) $totalarray['nbfield']++;
1093
+		if (!$i) $totalarray['nbfield']++;
1094 1094
 	}
1095
-	if (! empty($arrayfields['s.siren']['checked']))
1095
+	if (!empty($arrayfields['s.siren']['checked']))
1096 1096
 	{
1097 1097
 		print "<td>".$obj->idprof1."</td>\n";
1098
-		if (! $i) $totalarray['nbfield']++;
1098
+		if (!$i) $totalarray['nbfield']++;
1099 1099
 	}
1100
-	if (! empty($arrayfields['s.siret']['checked']))
1100
+	if (!empty($arrayfields['s.siret']['checked']))
1101 1101
 	{
1102 1102
 		print "<td>".$obj->idprof2."</td>\n";
1103
-		if (! $i) $totalarray['nbfield']++;
1103
+		if (!$i) $totalarray['nbfield']++;
1104 1104
 	}
1105
-	if (! empty($arrayfields['s.ape']['checked']))
1105
+	if (!empty($arrayfields['s.ape']['checked']))
1106 1106
 	{
1107 1107
 		print "<td>".$obj->idprof3."</td>\n";
1108
-		if (! $i) $totalarray['nbfield']++;
1108
+		if (!$i) $totalarray['nbfield']++;
1109 1109
 	}
1110
-	if (! empty($arrayfields['s.idprof4']['checked']))
1110
+	if (!empty($arrayfields['s.idprof4']['checked']))
1111 1111
 	{
1112 1112
 		print "<td>".$obj->idprof4."</td>\n";
1113
-		if (! $i) $totalarray['nbfield']++;
1113
+		if (!$i) $totalarray['nbfield']++;
1114 1114
 	}
1115
-	if (! empty($arrayfields['s.idprof5']['checked']))
1115
+	if (!empty($arrayfields['s.idprof5']['checked']))
1116 1116
 	{
1117 1117
 		print "<td>".$obj->idprof5."</td>\n";
1118
-		if (! $i) $totalarray['nbfield']++;
1118
+		if (!$i) $totalarray['nbfield']++;
1119 1119
 	}
1120
-	if (! empty($arrayfields['s.idprof6']['checked']))
1120
+	if (!empty($arrayfields['s.idprof6']['checked']))
1121 1121
 	{
1122 1122
 		print "<td>".$obj->idprof6."</td>\n";
1123
-		if (! $i) $totalarray['nbfield']++;
1123
+		if (!$i) $totalarray['nbfield']++;
1124 1124
 	}
1125
-	if (! empty($arrayfields['s.tva_intra']['checked']))
1125
+	if (!empty($arrayfields['s.tva_intra']['checked']))
1126 1126
 	{
1127 1127
 		print "<td>".$obj->tva_intra."</td>\n";
1128
-		if (! $i) $totalarray['nbfield']++;
1128
+		if (!$i) $totalarray['nbfield']++;
1129 1129
 	}
1130 1130
 	// Type
1131
-	if (! empty($arrayfields['customerorsupplier']['checked']))
1131
+	if (!empty($arrayfields['customerorsupplier']['checked']))
1132 1132
 	{
1133 1133
 		print '<td align="center">';
1134
-		$s='';
1135
-		if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
1134
+		$s = '';
1135
+		if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
1136 1136
 		{
1137
-	  		$companystatic->name=$langs->trans("Customer");
1138
-	  		$companystatic->name_alias='';
1139
-			$s.=$companystatic->getNomUrl(0,'customer',0,1);
1137
+	  		$companystatic->name = $langs->trans("Customer");
1138
+	  		$companystatic->name_alias = '';
1139
+			$s .= $companystatic->getNomUrl(0, 'customer', 0, 1);
1140 1140
 		}
1141
-		if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1141
+		if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1142 1142
 		{
1143
-			if ($s) $s.=" / ";
1144
-			$companystatic->name=$langs->trans("Prospect");
1145
-	  		$companystatic->name_alias='';
1146
-			$s.=$companystatic->getNomUrl(0,'prospect',0,1);
1143
+			if ($s) $s .= " / ";
1144
+			$companystatic->name = $langs->trans("Prospect");
1145
+	  		$companystatic->name_alias = '';
1146
+			$s .= $companystatic->getNomUrl(0, 'prospect', 0, 1);
1147 1147
 		}
1148
-		if ((! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) && $obj->fournisseur)
1148
+		if ((!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) && $obj->fournisseur)
1149 1149
 		{
1150
-			if ($s) $s.=" / ";
1151
-			$companystatic->name=$langs->trans("Supplier");
1152
-	  		$companystatic->name_alias='';
1153
-			$s.=$companystatic->getNomUrl(0,'supplier',0,1);
1150
+			if ($s) $s .= " / ";
1151
+			$companystatic->name = $langs->trans("Supplier");
1152
+	  		$companystatic->name_alias = '';
1153
+			$s .= $companystatic->getNomUrl(0, 'supplier', 0, 1);
1154 1154
 		}
1155 1155
 		print $s;
1156 1156
 		print '</td>';
1157
-		if (! $i) $totalarray['nbfield']++;
1157
+		if (!$i) $totalarray['nbfield']++;
1158 1158
 	}
1159 1159
 
1160
-	if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
1160
+	if (!empty($arrayfields['s.fk_prospectlevel']['checked']))
1161 1161
 	{
1162 1162
 		// Prospect level
1163 1163
 		print '<td align="center">';
1164 1164
 		print $companystatic->getLibProspLevel();
1165 1165
 		print "</td>";
1166
-		if (! $i) $totalarray['nbfield']++;
1166
+		if (!$i) $totalarray['nbfield']++;
1167 1167
 	}
1168 1168
 
1169
-	if (! empty($arrayfields['s.fk_stcomm']['checked']))
1169
+	if (!empty($arrayfields['s.fk_stcomm']['checked']))
1170 1170
 	{
1171 1171
 		// Prospect status
1172 1172
 		print '<td align="center" class="nowrap"><div class="nowrap">';
1173
-		print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
1173
+		print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
1174 1174
 		print '</div> - <div class="inline-block">';
1175
-		foreach($prospectstatic->cacheprospectstatus as $key => $val)
1175
+		foreach ($prospectstatic->cacheprospectstatus as $key => $val)
1176 1176
 		{
1177
-			$titlealt='default';
1178
-			if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
1179
-			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
1177
+			$titlealt = 'default';
1178
+			if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
1179
+			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code']).'</a>';
1180 1180
 		}
1181 1181
 		print '</div></div></td>';
1182
-		if (! $i) $totalarray['nbfield']++;
1182
+		if (!$i) $totalarray['nbfield']++;
1183 1183
 	}
1184 1184
 	// Extra fields
1185 1185
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1186 1186
 	// Fields from hook
1187
-	$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1188
-	$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
1187
+	$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1188
+	$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1189 1189
 	print $hookmanager->resPrint;
1190 1190
 	// Date creation
1191
-	if (! empty($arrayfields['s.datec']['checked']))
1191
+	if (!empty($arrayfields['s.datec']['checked']))
1192 1192
 	{
1193 1193
 		print '<td align="center" class="nowrap">';
1194 1194
 		print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1195 1195
 		print '</td>';
1196
-		if (! $i) $totalarray['nbfield']++;
1196
+		if (!$i) $totalarray['nbfield']++;
1197 1197
 	}
1198 1198
 	// Date modification
1199
-	if (! empty($arrayfields['s.tms']['checked']))
1199
+	if (!empty($arrayfields['s.tms']['checked']))
1200 1200
 	{
1201 1201
 		print '<td align="center" class="nowrap">';
1202 1202
 		print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1203 1203
 		print '</td>';
1204
-		if (! $i) $totalarray['nbfield']++;
1204
+		if (!$i) $totalarray['nbfield']++;
1205 1205
 	}
1206 1206
 	// Status
1207
-	if (! empty($arrayfields['s.status']['checked']))
1207
+	if (!empty($arrayfields['s.status']['checked']))
1208 1208
 	{
1209 1209
 		print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
1210
-		if (! $i) $totalarray['nbfield']++;
1210
+		if (!$i) $totalarray['nbfield']++;
1211 1211
 	}
1212
-	if (! empty($arrayfields['s.import_key']['checked']))
1212
+	if (!empty($arrayfields['s.import_key']['checked']))
1213 1213
 	{
1214 1214
 		print '<td class="tdoverflowmax100">';
1215 1215
 		print $obj->import_key;
1216 1216
 		print "</td>\n";
1217
-		if (! $i) $totalarray['nbfield']++;
1217
+		if (!$i) $totalarray['nbfield']++;
1218 1218
 	}
1219 1219
 
1220 1220
 	// Action column
1221 1221
 	print '<td class="nowrap" align="center">';
1222 1222
 	if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1223 1223
 	{
1224
-		$selected=0;
1225
-		if (in_array($obj->rowid, $arrayofselected)) $selected=1;
1226
-		print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
1224
+		$selected = 0;
1225
+		if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1226
+		print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1227 1227
 	}
1228 1228
 	print '</td>';
1229
-	if (! $i) $totalarray['nbfield']++;
1229
+	if (!$i) $totalarray['nbfield']++;
1230 1230
 
1231 1231
 	print '</tr>'."\n";
1232 1232
 	$i++;
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 
1235 1235
 $db->free($resql);
1236 1236
 
1237
-$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1238
-$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters);    // Note that $action and $object may have been modified by hook
1237
+$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1238
+$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1239 1239
 print $hookmanager->resPrint;
1240 1240
 
1241 1241
 print "</table>";
Please login to merge, or discard this patch.
Braces   +628 added lines, -205 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
 // Security check
51 51
 $socid = GETPOST('socid','int');
52
-if ($user->societe_id) $socid=$user->societe_id;
52
+if ($user->societe_id) {
53
+    $socid=$user->societe_id;
54
+}
53 55
 $result = restrictedArea($user,'societe',$socid,'');
54 56
 
55 57
 $search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
@@ -103,16 +105,38 @@  discard block
 block discarded – undo
103 105
 $sortfield=GETPOST("sortfield",'alpha');
104 106
 $sortorder=GETPOST("sortorder",'alpha');
105 107
 $page=GETPOST("page",'int');
106
-if (! $sortorder) $sortorder="ASC";
107
-if (! $sortfield) $sortfield="s.nom";
108
+if (! $sortorder) {
109
+    $sortorder="ASC";
110
+}
111
+if (! $sortfield) {
112
+    $sortfield="s.nom";
113
+}
108 114
 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; }
109 115
 $offset = $limit * $page;
110 116
 $pageprev = $page - 1;
111 117
 $pagenext = $page + 1;
112 118
 
113
-if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; }
114
-if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; }
115
-if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; }
119
+if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') {
120
+    $contextpage='customerlist';
121
+}
122
+if ($search_type=='') {
123
+    $search_type='1,3';
124
+}
125
+}
126
+if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') {
127
+    $contextpage='prospectlist';
128
+}
129
+if ($search_type=='') {
130
+    $search_type='2,3';
131
+}
132
+}
133
+if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') {
134
+    $contextpage='supplierlist';
135
+}
136
+if ($search_type=='') {
137
+    $search_type='4';
138
+}
139
+}
116 140
 
117 141
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
118 142
 $object = new Societe($db);
@@ -140,12 +164,22 @@  discard block
 block discarded – undo
140 164
 	's.phone'=>"Phone",
141 165
 	's.fax'=>"Fax",
142 166
 );
143
-if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4';
144
-if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5';
145
-if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6';
146
-if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod';
167
+if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') {
168
+    $fieldstosearchall['s.idprof4']='ProfId4';
169
+}
170
+if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') {
171
+    $fieldstosearchall['s.idprof5']='ProfId5';
172
+}
173
+if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') {
174
+    $fieldstosearchall['s.idprof6']='ProfId6';
175
+}
176
+if (!empty($conf->barcode->enabled)) {
177
+    $fieldstosearchall['s.barcode']='Gencod';
178
+}
147 179
 // Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode'
148
-if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
180
+if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) {
181
+    $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
182
+}
149 183
 
150 184
 
151 185
 // Define list of fields to show into list
@@ -205,7 +239,9 @@  discard block
 block discarded – undo
205 239
 {
206 240
    foreach($extrafields->attribute_label as $key => $val)
207 241
    {
208
-		if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
242
+		if (! empty($extrafields->attribute_list[$key])) {
243
+		    $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
244
+		}
209 245
    }
210 246
 }
211 247
 
@@ -221,7 +257,9 @@  discard block
 block discarded – undo
221 257
 
222 258
 $parameters=array();
223 259
 $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
224
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
260
+if ($reshook < 0) {
261
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
262
+}
225 263
 
226 264
 if (empty($reshook))
227 265
 {
@@ -229,9 +267,11 @@  discard block
 block discarded – undo
229 267
 	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
230 268
 
231 269
 	// Did we click on purge search criteria ?
232
-	if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
270
+	if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) {
271
+	    // All tests are required to be compatible with all browsers
233 272
 	{
234 273
 		$search_id='';
274
+	}
235 275
 		$search_nom='';
236 276
 		$search_alias='';
237 277
 		$search_categ_cus=0;
@@ -282,13 +322,18 @@  discard block
 block discarded – undo
282 322
 		$result=$object->fetch(GETPOST('stcommsocid'));
283 323
 		$object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
284 324
 		$result=$object->update($object->id, $user);
285
-		if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
325
+		if ($result < 0) {
326
+		    setEventMessages($object->error,$object->errors,'errors');
327
+		}
286 328
 
287 329
 		$action='';
288 330
 	}
289 331
 }
290 332
 
291
-if ($search_status=='') $search_status=1; // always display active thirdparty first
333
+if ($search_status=='') {
334
+    $search_status=1;
335
+}
336
+// always display active thirdparty first
292 337
 
293 338
 
294 339
 
@@ -315,9 +360,15 @@  discard block
 block discarded – undo
315 360
 
316 361
 
317 362
 $title=$langs->trans("ListOfThirdParties");
318
-if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers");
319
-if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects");
320
-if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers");
363
+if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) {
364
+    $title=$langs->trans("ListOfCustomers");
365
+}
366
+if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) {
367
+    $title=$langs->trans("ListOfProspects");
368
+}
369
+if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) {
370
+    $title=$langs->trans("ListOfSuppliers");
371
+}
321 372
 
322 373
 // Select every potentiels, and note each potentiels which fit in search parameters
323 374
 $tab_level = array();
@@ -332,11 +383,14 @@  discard block
 block discarded – undo
332 383
 	{
333 384
 		// Compute level text
334 385
 		$level=$langs->trans($obj->code);
335
-		if ($level == $obj->code) $level=$langs->trans($obj->label);
386
+		if ($level == $obj->code) {
387
+		    $level=$langs->trans($obj->label);
388
+		}
336 389
 		$tab_level[$obj->code] = $level;
337 390
 	}
391
+} else {
392
+    dol_print_error($db);
338 393
 }
339
-else dol_print_error($db);
340 394
 
341 395
 $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
342 396
 $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
@@ -349,78 +403,188 @@  discard block
 block discarded – undo
349 403
 $sql.= " state.code_departement as state_code, state.nom as state_name,";
350 404
 $sql.= " region.code_region as region_code, region.nom as region_name";
351 405
 // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
352
-if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
406
+if ($search_sale) {
407
+    $sql .= ", sc.fk_soc, sc.fk_user";
408
+}
353 409
 // We'll need these fields in order to filter by categ
354
-if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
355
-if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc";
410
+if ($search_categ_cus) {
411
+    $sql .= ", cc.fk_categorie, cc.fk_soc";
412
+}
413
+if ($search_categ_sup) {
414
+    $sql .= ", cs.fk_categorie, cs.fk_soc";
415
+}
356 416
 // Add fields from extrafields
357
-foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
417
+foreach ($extrafields->attribute_label as $key => $val) {
418
+    $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
419
+}
358 420
 // Add fields from hooks
359 421
 $parameters=array();
360 422
 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
361 423
 $sql.=$hookmanager->resPrint;
362 424
 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
363
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
425
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
426
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
427
+}
364 428
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
365 429
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
366 430
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
367 431
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
368 432
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.	code_region = state.fk_region)";
369 433
 // We'll need this table joined to the select in order to filter by categ
370
-if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
371
-if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
434
+if (! empty($search_categ_cus)) {
435
+    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc";
436
+}
437
+// We'll need this table joined to the select in order to filter by categ
438
+if (! empty($search_categ_sup)) {
439
+    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
440
+}
441
+// We'll need this table joined to the select in order to filter by categ
372 442
 $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
373 443
 // We'll need this table joined to the select in order to filter by sale
374
-if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
444
+if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) {
445
+    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
446
+}
375 447
 $sql.= " WHERE s.entity IN (".getEntity('societe').")";
376
-if (! $user->rights->societe->client->voir && ! $socid)	$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
377
-if ($socid)                $sql.= " AND s.rowid = ".$socid;
378
-if ($search_sale)          $sql.= " AND s.rowid = sc.fk_soc";        // Join for the needed table to filter by sale
379
-if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";    // client=0, fournisseur=0 must be visible
380
-if ($search_sale)          $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
381
-if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
382
-if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
383
-if ($search_categ_cus == -2)   $sql.= " AND cc.fk_categorie IS NULL";
384
-if ($search_categ_sup == -2)   $sql.= " AND cs.fk_categorie IS NULL";
385
-
386
-if ($search_all)           $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
387
-if (strlen($search_cti))   $sql.= natural_search('s.phone', $search_cti);
388
-
389
-if ($search_id > 0)        $sql.= natural_search("s.rowid",$search_id,1);
390
-if ($search_nom)           $sql.= natural_search("s.nom",$search_nom);
391
-if ($search_alias)         $sql.= natural_search("s.name_alias",$search_alias);
392
-if ($search_nom_only)      $sql.= natural_search("s.nom",$search_nom_only);
393
-if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code);
394
-if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code);
395
-if ($search_account_customer_code) $sql.= natural_search("s.code_compta",$search_account_customer_code);
396
-if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code);
397
-if ($search_town)          $sql.= natural_search("s.town",$search_town);
398
-if (strlen($search_zip))   $sql.= natural_search("s.zip",$search_zip);
399
-if ($search_state)         $sql.= natural_search("state.nom",$search_state);
400
-if ($search_region)        $sql.= natural_search("region.nom",$search_region);
401
-if ($search_country && $search_country != '-1')       $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
402
-if ($search_email)         $sql.= natural_search("s.email",$search_email);
403
-if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone);
404
-if (strlen($search_fax)) $sql.= natural_search("s.phone", $search_fax);
405
-if ($search_url)           $sql.= natural_search("s.url",$search_url);
406
-if (strlen($search_idprof1)) $sql.= natural_search("s.siren",$search_idprof1);
407
-if (strlen($search_idprof2)) $sql.= natural_search("s.siret",$search_idprof2);
408
-if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3);
409
-if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4);
410
-if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5);
411
-if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6);
412
-if (strlen($search_vat))     $sql.= natural_search("s.tva_intra",$search_vat);
448
+if (! $user->rights->societe->client->voir && ! $socid) {
449
+    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
450
+}
451
+if ($socid) {
452
+    $sql.= " AND s.rowid = ".$socid;
453
+}
454
+if ($search_sale) {
455
+    $sql.= " AND s.rowid = sc.fk_soc";
456
+}
457
+// Join for the needed table to filter by sale
458
+if (! $user->rights->fournisseur->lire) {
459
+    $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)";
460
+}
461
+// client=0, fournisseur=0 must be visible
462
+if ($search_sale) {
463
+    $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
464
+}
465
+if ($search_categ_cus > 0) {
466
+    $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
467
+}
468
+if ($search_categ_sup > 0) {
469
+    $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
470
+}
471
+if ($search_categ_cus == -2) {
472
+    $sql.= " AND cc.fk_categorie IS NULL";
473
+}
474
+if ($search_categ_sup == -2) {
475
+    $sql.= " AND cs.fk_categorie IS NULL";
476
+}
477
+
478
+if ($search_all) {
479
+    $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
480
+}
481
+if (strlen($search_cti)) {
482
+    $sql.= natural_search('s.phone', $search_cti);
483
+}
484
+
485
+if ($search_id > 0) {
486
+    $sql.= natural_search("s.rowid",$search_id,1);
487
+}
488
+if ($search_nom) {
489
+    $sql.= natural_search("s.nom",$search_nom);
490
+}
491
+if ($search_alias) {
492
+    $sql.= natural_search("s.name_alias",$search_alias);
493
+}
494
+if ($search_nom_only) {
495
+    $sql.= natural_search("s.nom",$search_nom_only);
496
+}
497
+if ($search_customer_code) {
498
+    $sql.= natural_search("s.code_client",$search_customer_code);
499
+}
500
+if ($search_supplier_code) {
501
+    $sql.= natural_search("s.code_fournisseur",$search_supplier_code);
502
+}
503
+if ($search_account_customer_code) {
504
+    $sql.= natural_search("s.code_compta",$search_account_customer_code);
505
+}
506
+if ($search_account_supplier_code) {
507
+    $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code);
508
+}
509
+if ($search_town) {
510
+    $sql.= natural_search("s.town",$search_town);
511
+}
512
+if (strlen($search_zip)) {
513
+    $sql.= natural_search("s.zip",$search_zip);
514
+}
515
+if ($search_state) {
516
+    $sql.= natural_search("state.nom",$search_state);
517
+}
518
+if ($search_region) {
519
+    $sql.= natural_search("region.nom",$search_region);
520
+}
521
+if ($search_country && $search_country != '-1') {
522
+    $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
523
+}
524
+if ($search_email) {
525
+    $sql.= natural_search("s.email",$search_email);
526
+}
527
+if (strlen($search_phone)) {
528
+    $sql.= natural_search("s.phone", $search_phone);
529
+}
530
+if (strlen($search_fax)) {
531
+    $sql.= natural_search("s.phone", $search_fax);
532
+}
533
+if ($search_url) {
534
+    $sql.= natural_search("s.url",$search_url);
535
+}
536
+if (strlen($search_idprof1)) {
537
+    $sql.= natural_search("s.siren",$search_idprof1);
538
+}
539
+if (strlen($search_idprof2)) {
540
+    $sql.= natural_search("s.siret",$search_idprof2);
541
+}
542
+if (strlen($search_idprof3)) {
543
+    $sql.= natural_search("s.ape",$search_idprof3);
544
+}
545
+if (strlen($search_idprof4)) {
546
+    $sql.= natural_search("s.idprof4",$search_idprof4);
547
+}
548
+if (strlen($search_idprof5)) {
549
+    $sql.= natural_search("s.idprof5",$search_idprof5);
550
+}
551
+if (strlen($search_idprof6)) {
552
+    $sql.= natural_search("s.idprof6",$search_idprof6);
553
+}
554
+if (strlen($search_vat)) {
555
+    $sql.= natural_search("s.tva_intra",$search_vat);
556
+}
413 557
 // Filter on type of thirdparty
414
-if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")";
415
-if ($search_type > 0 && in_array($search_type,array('4')))         $sql .= " AND s.fournisseur = 1";
416
-if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
417
-if ($search_status!='' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
418
-if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode);
419
-if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2);
420
-if (! empty($search_staff) && $search_staff != '-1')            $sql.= natural_search("s.fk_effectif", $search_staff, 2);
421
-if ($search_level)  $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
422
-if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2);
423
-if ($search_import_key)    $sql.= natural_search("s.import_key",$search_import_key);
558
+if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) {
559
+    $sql .= " AND s.client IN (".$db->escape($search_type).")";
560
+}
561
+if ($search_type > 0 && in_array($search_type,array('4'))) {
562
+    $sql .= " AND s.fournisseur = 1";
563
+}
564
+if ($search_type == '0') {
565
+    $sql .= " AND s.client = 0 AND s.fournisseur = 0";
566
+}
567
+if ($search_status!='' && $search_status >= 0) {
568
+    $sql .= natural_search("s.status", $search_status, 2);
569
+}
570
+if (!empty($conf->barcode->enabled) && $search_barcode) {
571
+    $sql.= natural_search("s.barcode", $search_barcode);
572
+}
573
+if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
574
+    $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2);
575
+}
576
+if (! empty($search_staff) && $search_staff != '-1') {
577
+    $sql.= natural_search("s.fk_effectif", $search_staff, 2);
578
+}
579
+if ($search_level) {
580
+    $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
581
+}
582
+if ($search_stcomm != '' && $search_stcomm != -2) {
583
+    $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2);
584
+}
585
+if ($search_import_key) {
586
+    $sql.= natural_search("s.import_key",$search_import_key);
587
+}
424 588
 // Add where from extra fields
425 589
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
426 590
 
@@ -437,9 +601,11 @@  discard block
 block discarded – undo
437 601
 {
438 602
 	$result = $db->query($sql);
439 603
 	$nbtotalofrecords = $db->num_rows($result);
440
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
604
+	if (($page * $limit) > $nbtotalofrecords) {
605
+	    // if total resultset is smaller then paging size (filtering), goto and load page 0
441 606
 	{
442 607
 		$page = 0;
608
+	}
443 609
 		$offset = 0;
444 610
 	}
445 611
 }
@@ -480,44 +646,120 @@  discard block
 block discarded – undo
480 646
 llxHeader('',$langs->trans("ThirdParty"),$help_url);
481 647
 
482 648
 $param='';
483
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
484
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
485
-if ($search_all != '')     $param = "&sall=".urlencode($search_all);
486
-if ($sall != '')           $param.= "&sall=".urlencode($sall);
487
-if ($search_categ_cus > 0) $param.= '&search_categ_cus='.urlencode($search_categ_cus);
488
-if ($search_categ_sup > 0) $param.= '&search_categ_sup='.urlencode($search_categ_sup);
489
-if ($search_sale > 0)	   $param.= '&search_sale='.urlencode($search_sale);
490
-if ($search_id > 0)        $param.= "&search_id=".urlencode($search_id);
491
-if ($search_nom != '')     $param.= "&search_nom=".urlencode($search_nom);
492
-if ($search_alias != '')   $param.= "&search_alias=".urlencode($search_alias);
493
-if ($search_town != '')    $param.= "&search_town=".urlencode($search_town);
494
-if ($search_zip != '')     $param.= "&search_zip=".urlencode($search_zip);
495
-if ($search_phone != '')   $param.= "&search_phone=".urlencode($search_phone);
496
-if ($search_fax != '')     $param.= "&search_fax=".urlencode($search_fax);
497
-if ($search_email != '')   $param.= "&search_email=".urlencode($search_email);
498
-if ($search_url != '')     $param.= "&search_url=".urlencode($search_url);
499
-if ($search_state != '')   $param.= "&search_state=".urlencode($search_state);
500
-if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
501
-if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
502
-if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
503
-if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
504
-if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
505
-if ($search_barcode != '') $param.= "&search_barcode=".urlencode($search_barcode);
506
-if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
507
-if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
508
-if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
509
-if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
510
-if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
511
-if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
512
-if ($search_vat != '')     $param.= '&search_vat='.urlencode($search_vat);
513
-if ($search_type_thirdparty != '')    $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
514
-if ($search_type != '')    $param.='&search_type='.urlencode($search_type);
515
-if (is_array($search_level) && count($search_level)) foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel);
516
-if ($search_status != '')  $param.='&search_status='.urlencode($search_status);
517
-if ($search_stcomm != '')  $param.='&search_stcomm='.urlencode($search_stcomm);
518
-if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
519
-if ($type != '') $param.='&type='.urlencode($type);
520
-if ($optioncss != '')      $param.='&optioncss='.urlencode($optioncss);
649
+if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
650
+    $param.='&contextpage='.urlencode($contextpage);
651
+}
652
+if ($limit > 0 && $limit != $conf->liste_limit) {
653
+    $param.='&limit='.urlencode($limit);
654
+}
655
+if ($search_all != '') {
656
+    $param = "&sall=".urlencode($search_all);
657
+}
658
+if ($sall != '') {
659
+    $param.= "&sall=".urlencode($sall);
660
+}
661
+if ($search_categ_cus > 0) {
662
+    $param.= '&search_categ_cus='.urlencode($search_categ_cus);
663
+}
664
+if ($search_categ_sup > 0) {
665
+    $param.= '&search_categ_sup='.urlencode($search_categ_sup);
666
+}
667
+if ($search_sale > 0) {
668
+    $param.= '&search_sale='.urlencode($search_sale);
669
+}
670
+if ($search_id > 0) {
671
+    $param.= "&search_id=".urlencode($search_id);
672
+}
673
+if ($search_nom != '') {
674
+    $param.= "&search_nom=".urlencode($search_nom);
675
+}
676
+if ($search_alias != '') {
677
+    $param.= "&search_alias=".urlencode($search_alias);
678
+}
679
+if ($search_town != '') {
680
+    $param.= "&search_town=".urlencode($search_town);
681
+}
682
+if ($search_zip != '') {
683
+    $param.= "&search_zip=".urlencode($search_zip);
684
+}
685
+if ($search_phone != '') {
686
+    $param.= "&search_phone=".urlencode($search_phone);
687
+}
688
+if ($search_fax != '') {
689
+    $param.= "&search_fax=".urlencode($search_fax);
690
+}
691
+if ($search_email != '') {
692
+    $param.= "&search_email=".urlencode($search_email);
693
+}
694
+if ($search_url != '') {
695
+    $param.= "&search_url=".urlencode($search_url);
696
+}
697
+if ($search_state != '') {
698
+    $param.= "&search_state=".urlencode($search_state);
699
+}
700
+if ($search_country != '') {
701
+    $param.= "&search_country=".urlencode($search_country);
702
+}
703
+if ($search_customer_code != '') {
704
+    $param.= "&search_customer_code=".urlencode($search_customer_code);
705
+}
706
+if ($search_supplier_code != '') {
707
+    $param.= "&search_supplier_code=".urlencode($search_supplier_code);
708
+}
709
+if ($search_account_customer_code != '') {
710
+    $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
711
+}
712
+if ($search_account_supplier_code != '') {
713
+    $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
714
+}
715
+if ($search_barcode != '') {
716
+    $param.= "&search_barcode=".urlencode($search_barcode);
717
+}
718
+if ($search_idprof1 != '') {
719
+    $param.= '&search_idprof1='.urlencode($search_idprof1);
720
+}
721
+if ($search_idprof2 != '') {
722
+    $param.= '&search_idprof2='.urlencode($search_idprof2);
723
+}
724
+if ($search_idprof3 != '') {
725
+    $param.= '&search_idprof3='.urlencode($search_idprof3);
726
+}
727
+if ($search_idprof4 != '') {
728
+    $param.= '&search_idprof4='.urlencode($search_idprof4);
729
+}
730
+if ($search_idprof5 != '') {
731
+    $param.= '&search_idprof5='.urlencode($search_idprof5);
732
+}
733
+if ($search_idprof6 != '') {
734
+    $param.= '&search_idprof6='.urlencode($search_idprof6);
735
+}
736
+if ($search_vat != '') {
737
+    $param.= '&search_vat='.urlencode($search_vat);
738
+}
739
+if ($search_type_thirdparty != '') {
740
+    $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
741
+}
742
+if ($search_type != '') {
743
+    $param.='&search_type='.urlencode($search_type);
744
+}
745
+if (is_array($search_level) && count($search_level)) {
746
+    foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel);
747
+}
748
+if ($search_status != '') {
749
+    $param.='&search_status='.urlencode($search_status);
750
+}
751
+if ($search_stcomm != '') {
752
+    $param.='&search_stcomm='.urlencode($search_stcomm);
753
+}
754
+if ($search_import_key != '') {
755
+    $param.='&search_import_key='.urlencode($search_import_key);
756
+}
757
+if ($type != '') {
758
+    $param.='&type='.urlencode($type);
759
+}
760
+if ($optioncss != '') {
761
+    $param.='&optioncss='.urlencode($optioncss);
762
+}
521 763
 // Add $param from extra fields
522 764
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
523 765
 
@@ -533,8 +775,12 @@  discard block
 block discarded – undo
533 775
 //    'builddoc'=>$langs->trans("PDFMerge"),
534 776
 );
535 777
 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
536
-if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
537
-if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
778
+if ($user->rights->societe->supprimer) {
779
+    $arrayofmassactions['predelete']=$langs->trans("Delete");
780
+}
781
+if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) {
782
+    $arrayofmassactions=array();
783
+}
538 784
 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
539 785
 
540 786
 $newcardbutton='';
@@ -546,9 +792,15 @@  discard block
 block discarded – undo
546 792
 	if(! empty($type))
547 793
 	{
548 794
 		$typefilter = '&amp;type='.$type;
549
-		if($type == 'p') $label='MenuNewProspect';
550
-		if($type == 'c') $label='MenuNewCustomer';
551
-		if($type == 'f') $label='NewSupplier';
795
+		if($type == 'p') {
796
+		    $label='MenuNewProspect';
797
+		}
798
+		if($type == 'c') {
799
+		    $label='MenuNewCustomer';
800
+		}
801
+		if($type == 'f') {
802
+		    $label='NewSupplier';
803
+		}
552 804
 	}
553 805
 
554 806
 	$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter.'"><span class="valignmiddle">'.$langs->trans($label).'</span>';
@@ -557,7 +809,9 @@  discard block
 block discarded – undo
557 809
 }
558 810
 
559 811
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
560
-if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
812
+if ($optioncss != '') {
813
+    print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
814
+}
561 815
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
562 816
 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
563 817
 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -574,7 +828,9 @@  discard block
 block discarded – undo
574 828
 	$textprofid[$key]='';
575 829
 	if ($label != "ProfId".$key.$mysoc->country_code)
576 830
 	{	// Get only text between ()
577
-		if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
831
+		if (preg_match('/\((.*)\)/i',$label,$reg)) {
832
+		    $label=$reg[1];
833
+		}
578 834
 		$textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
579 835
 	}
580 836
 }
@@ -587,7 +843,9 @@  discard block
 block discarded – undo
587 843
 
588 844
 if ($search_all)
589 845
 {
590
-	foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
846
+	foreach($fieldstosearchall as $key => $val) {
847
+	    $fieldstosearchall[$key]=$langs->trans($val);
848
+	}
591 849
 	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall).'</div>';
592 850
 }
593 851
 
@@ -636,9 +894,13 @@  discard block
 block discarded – undo
636 894
 
637 895
 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
638 896
 $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
639
-if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
897
+if ($massactionbutton) {
898
+    $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
899
+}
640 900
 
641
-if (empty($arrayfields['customerorsupplier']['checked'])) print '<input type="hidden" name="type" value="'.$type.'">';
901
+if (empty($arrayfields['customerorsupplier']['checked'])) {
902
+    print '<input type="hidden" name="type" value="'.$type.'">';
903
+}
642 904
 
643 905
 print '<div class="div-table-responsive">';
644 906
 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@@ -654,7 +916,9 @@  discard block
 block discarded – undo
654 916
 if (! empty($arrayfields['s.nom']['checked']))
655 917
 {
656 918
 	print '<td class="liste_titre">';
657
-	if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
919
+	if (! empty($search_nom_only) && empty($search_nom)) {
920
+	    $search_nom=$search_nom_only;
921
+	}
658 922
 	print '<input class="flat searchstring maxwidth50" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
659 923
 	print '</td>';
660 924
 }
@@ -830,11 +1094,17 @@  discard block
 block discarded – undo
830 1094
 if (! empty($arrayfields['customerorsupplier']['checked']))
831 1095
 {
832 1096
 	print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
833
-	if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
1097
+	if ($type != '') {
1098
+	    print '<input type="hidden" name="type" value="'.$type.'">';
1099
+	}
834 1100
 	print '<select class="flat" name="search_type">';
835 1101
 	print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
836
-	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
837
-	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1102
+	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1103
+	    print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
1104
+	}
1105
+	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
1106
+	    print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
1107
+	}
838 1108
 	//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
839 1109
 	print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
840 1110
 	print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
@@ -900,45 +1170,112 @@  discard block
 block discarded – undo
900 1170
 print "</tr>\n";
901 1171
 
902 1172
 print '<tr class="liste_titre">';
903
-if (! empty($arrayfields['s.rowid']['checked']))                   print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
904
-if (! empty($arrayfields['s.nom']['checked']))                     print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
905
-if (! empty($arrayfields['s.name_alias']['checked']))              print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
906
-if (! empty($arrayfields['s.barcode']['checked']))                 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
907
-if (! empty($arrayfields['s.code_client']['checked']))             print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
908
-if (! empty($arrayfields['s.code_fournisseur']['checked']))        print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
909
-if (! empty($arrayfields['s.code_compta']['checked']))             print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
910
-if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
911
-if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
912
-if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
913
-if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
914
-if (! empty($arrayfields['region.nom']['checked']))       print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
915
-if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
916
-if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
917
-if (! empty($arrayfields['staff.code']['checked']))       print_liste_field_titre($arrayfields['staff.code']['label'],$_SERVER["PHP_SELF"],"staff.code","",$param,'align="center"',$sortfield,$sortorder);
918
-if (! empty($arrayfields['s.email']['checked']))          print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
919
-if (! empty($arrayfields['s.phone']['checked']))          print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder);
920
-if (! empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'],$_SERVER["PHP_SELF"],"s.fax","",$param,'',$sortfield,$sortorder);
921
-if (! empty($arrayfields['s.url']['checked']))            print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder);
922
-if (! empty($arrayfields['s.siren']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
923
-if (! empty($arrayfields['s.siret']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
924
-if (! empty($arrayfields['s.ape']['checked']))            print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
925
-if (! empty($arrayfields['s.idprof4']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
926
-if (! empty($arrayfields['s.idprof5']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
927
-if (! empty($arrayfields['s.idprof6']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
928
-if (! empty($arrayfields['s.tva_intra']['checked']))      print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder);
929
-if (! empty($arrayfields['customerorsupplier']['checked']))        print_liste_field_titre('');   // type of customer
930
-if (! empty($arrayfields['s.fk_prospectlevel']['checked']))        print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
931
-if (! empty($arrayfields['s.fk_stcomm']['checked']))               print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
1173
+if (! empty($arrayfields['s.rowid']['checked'])) {
1174
+    print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
1175
+}
1176
+if (! empty($arrayfields['s.nom']['checked'])) {
1177
+    print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
1178
+}
1179
+if (! empty($arrayfields['s.name_alias']['checked'])) {
1180
+    print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
1181
+}
1182
+if (! empty($arrayfields['s.barcode']['checked'])) {
1183
+    print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
1184
+}
1185
+if (! empty($arrayfields['s.code_client']['checked'])) {
1186
+    print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
1187
+}
1188
+if (! empty($arrayfields['s.code_fournisseur']['checked'])) {
1189
+    print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
1190
+}
1191
+if (! empty($arrayfields['s.code_compta']['checked'])) {
1192
+    print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
1193
+}
1194
+if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1195
+    print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
1196
+}
1197
+if (! empty($arrayfields['s.town']['checked'])) {
1198
+    print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
1199
+}
1200
+if (! empty($arrayfields['s.zip']['checked'])) {
1201
+    print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
1202
+}
1203
+if (! empty($arrayfields['state.nom']['checked'])) {
1204
+    print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
1205
+}
1206
+if (! empty($arrayfields['region.nom']['checked'])) {
1207
+    print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
1208
+}
1209
+if (! empty($arrayfields['country.code_iso']['checked'])) {
1210
+    print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
1211
+}
1212
+if (! empty($arrayfields['typent.code']['checked'])) {
1213
+    print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
1214
+}
1215
+if (! empty($arrayfields['staff.code']['checked'])) {
1216
+    print_liste_field_titre($arrayfields['staff.code']['label'],$_SERVER["PHP_SELF"],"staff.code","",$param,'align="center"',$sortfield,$sortorder);
1217
+}
1218
+if (! empty($arrayfields['s.email']['checked'])) {
1219
+    print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
1220
+}
1221
+if (! empty($arrayfields['s.phone']['checked'])) {
1222
+    print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder);
1223
+}
1224
+if (! empty($arrayfields['s.fax']['checked'])) {
1225
+    print_liste_field_titre($arrayfields['s.fax']['label'],$_SERVER["PHP_SELF"],"s.fax","",$param,'',$sortfield,$sortorder);
1226
+}
1227
+if (! empty($arrayfields['s.url']['checked'])) {
1228
+    print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder);
1229
+}
1230
+if (! empty($arrayfields['s.siren']['checked'])) {
1231
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
1232
+}
1233
+if (! empty($arrayfields['s.siret']['checked'])) {
1234
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
1235
+}
1236
+if (! empty($arrayfields['s.ape']['checked'])) {
1237
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
1238
+}
1239
+if (! empty($arrayfields['s.idprof4']['checked'])) {
1240
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
1241
+}
1242
+if (! empty($arrayfields['s.idprof5']['checked'])) {
1243
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
1244
+}
1245
+if (! empty($arrayfields['s.idprof6']['checked'])) {
1246
+    print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
1247
+}
1248
+if (! empty($arrayfields['s.tva_intra']['checked'])) {
1249
+    print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder);
1250
+}
1251
+if (! empty($arrayfields['customerorsupplier']['checked'])) {
1252
+    print_liste_field_titre('');
1253
+}
1254
+// type of customer
1255
+if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1256
+    print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
1257
+}
1258
+if (! empty($arrayfields['s.fk_stcomm']['checked'])) {
1259
+    print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
1260
+}
932 1261
 // Extra fields
933 1262
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
934 1263
 // Hook fields
935 1264
 $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
936 1265
 $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
937 1266
 print $hookmanager->resPrint;
938
-if (! empty($arrayfields['s.datec']['checked']))      print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
939
-if (! empty($arrayfields['s.tms']['checked']))        print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
940
-if (! empty($arrayfields['s.status']['checked']))     print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
941
-if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder);
1267
+if (! empty($arrayfields['s.datec']['checked'])) {
1268
+    print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
1269
+}
1270
+if (! empty($arrayfields['s.tms']['checked'])) {
1271
+    print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
1272
+}
1273
+if (! empty($arrayfields['s.status']['checked'])) {
1274
+    print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
1275
+}
1276
+if (! empty($arrayfields['s.import_key']['checked'])) {
1277
+    print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder);
1278
+}
942 1279
 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
943 1280
 print "</tr>\n";
944 1281
 
@@ -972,78 +1309,104 @@  discard block
 block discarded – undo
972 1309
 		print '<td class="tdoverflowmax50">';
973 1310
 		print $obj->rowid;
974 1311
 		print "</td>\n";
975
-		if (! $i) $totalarray['nbfield']++;
1312
+		if (! $i) {
1313
+		    $totalarray['nbfield']++;
1314
+		}
976 1315
 	}
977 1316
 	if (! empty($arrayfields['s.nom']['checked']))
978 1317
 	{
979 1318
 		$savalias = $obj->name_alias;
980
-		if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
1319
+		if (! empty($arrayfields['s.name_alias']['checked'])) {
1320
+		    $companystatic->name_alias='';
1321
+		}
981 1322
 		print '<td class="tdoverflowmax200">';
982 1323
 		print $companystatic->getNomUrl(1, '', 100, 0, 1);
983 1324
 		print "</td>\n";
984 1325
 		$companystatic->name_alias = $savalias;
985
-        if (! $i) $totalarray['nbfield']++;
1326
+        if (! $i) {
1327
+            $totalarray['nbfield']++;
1328
+        }
986 1329
 	}
987 1330
 	if (! empty($arrayfields['s.name_alias']['checked']))
988 1331
 	{
989 1332
 		print '<td class="tdoverflowmax200">';
990 1333
 		print $companystatic->name_alias;
991 1334
 		print "</td>\n";
992
-		if (! $i) $totalarray['nbfield']++;
1335
+		if (! $i) {
1336
+		    $totalarray['nbfield']++;
1337
+		}
993 1338
 	}
994 1339
 	// Barcode
995 1340
 	if (! empty($arrayfields['s.barcode']['checked']))
996 1341
 	{
997 1342
 		print '<td>'.$obj->barcode.'</td>';
998
-		if (! $i) $totalarray['nbfield']++;
1343
+		if (! $i) {
1344
+		    $totalarray['nbfield']++;
1345
+		}
999 1346
 	}
1000 1347
 	// Customer code
1001 1348
 	if (! empty($arrayfields['s.code_client']['checked']))
1002 1349
 	{
1003 1350
 		print '<td class="nowraponall">'.$obj->code_client.'</td>';
1004
-		if (! $i) $totalarray['nbfield']++;
1351
+		if (! $i) {
1352
+		    $totalarray['nbfield']++;
1353
+		}
1005 1354
 	}
1006 1355
 	// Supplier code
1007 1356
 	if (! empty($arrayfields['s.code_fournisseur']['checked']))
1008 1357
 	{
1009 1358
 		print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>';
1010
-		if (! $i) $totalarray['nbfield']++;
1359
+		if (! $i) {
1360
+		    $totalarray['nbfield']++;
1361
+		}
1011 1362
 	}
1012 1363
 	// Account customer code
1013 1364
 	if (! empty($arrayfields['s.code_compta']['checked']))
1014 1365
 	{
1015 1366
 		print '<td>'.$obj->code_compta.'</td>';
1016
-		if (! $i) $totalarray['nbfield']++;
1367
+		if (! $i) {
1368
+		    $totalarray['nbfield']++;
1369
+		}
1017 1370
 	}
1018 1371
 	// Account supplier code
1019 1372
 	if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
1020 1373
 	{
1021 1374
 		print '<td>'.$obj->code_compta_fournisseur.'</td>';
1022
-		if (! $i) $totalarray['nbfield']++;
1375
+		if (! $i) {
1376
+		    $totalarray['nbfield']++;
1377
+		}
1023 1378
 	}
1024 1379
 	// Town
1025 1380
 	if (! empty($arrayfields['s.town']['checked']))
1026 1381
 	{
1027 1382
 		print "<td>".$obj->town."</td>\n";
1028
-		if (! $i) $totalarray['nbfield']++;
1383
+		if (! $i) {
1384
+		    $totalarray['nbfield']++;
1385
+		}
1029 1386
 	}
1030 1387
 	// Zip
1031 1388
 	if (! empty($arrayfields['s.zip']['checked']))
1032 1389
 	{
1033 1390
 		print "<td>".$obj->zip."</td>\n";
1034
-		if (! $i) $totalarray['nbfield']++;
1391
+		if (! $i) {
1392
+		    $totalarray['nbfield']++;
1393
+		}
1035 1394
 	}
1036 1395
 	// State
1037 1396
 	if (! empty($arrayfields['state.nom']['checked']))
1038 1397
 	{
1039 1398
 		print "<td>".$obj->state_name."</td>\n";
1040
-		if (! $i) $totalarray['nbfield']++;
1399
+		if (! $i) {
1400
+		    $totalarray['nbfield']++;
1401
+		}
1041 1402
 	}
1042 1403
 	// Region
1043 1404
 	if (! empty($arrayfields['region.nom']['checked']))
1044 1405
 	{
1045 1406
 		print "<td>".$obj->region_name."</td>\n";
1046
-		if (! $i) $totalarray['nbfield']++;
1407
+		if (! $i) {
1408
+		    $totalarray['nbfield']++;
1409
+		}
1047 1410
 	}
1048 1411
 	// Country
1049 1412
 	if (! empty($arrayfields['country.code_iso']['checked']))
@@ -1052,80 +1415,112 @@  discard block
 block discarded – undo
1052 1415
 		$tmparray=getCountry($obj->fk_pays,'all');
1053 1416
 		print $tmparray['label'];
1054 1417
 		print '</td>';
1055
-		if (! $i) $totalarray['nbfield']++;
1418
+		if (! $i) {
1419
+		    $totalarray['nbfield']++;
1420
+		}
1056 1421
 	}
1057 1422
 	// Type ent
1058 1423
 	if (! empty($arrayfields['typent.code']['checked']))
1059 1424
 	{
1060 1425
 		print '<td align="center">';
1061
-		if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
1426
+		if (! is_array($typenArray) || count($typenArray)==0) {
1427
+		    $typenArray = $formcompany->typent_array(1);
1428
+		}
1062 1429
 		print $typenArray[$obj->typent_code];
1063 1430
 		print '</td>';
1064
-		if (! $i) $totalarray['nbfield']++;
1431
+		if (! $i) {
1432
+		    $totalarray['nbfield']++;
1433
+		}
1065 1434
 	}
1066 1435
 	// Staff
1067 1436
 	if (! empty($arrayfields['staff.code']['checked']))
1068 1437
 	{
1069 1438
 		print '<td align="center">';
1070
-		if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
1439
+		if (! is_array($staffArray) || count($staffArray)==0) {
1440
+		    $staffArray = $formcompany->effectif_array(1);
1441
+		}
1071 1442
 		print $staffArray[$obj->staff_code];
1072 1443
 		print '</td>';
1073
-		if (! $i) $totalarray['nbfield']++;
1444
+		if (! $i) {
1445
+		    $totalarray['nbfield']++;
1446
+		}
1074 1447
 	}
1075 1448
 	if (! empty($arrayfields['s.email']['checked']))
1076 1449
 	{
1077 1450
 		print "<td>".$obj->email."</td>\n";
1078
-		if (! $i) $totalarray['nbfield']++;
1451
+		if (! $i) {
1452
+		    $totalarray['nbfield']++;
1453
+		}
1079 1454
 	}
1080 1455
 	if (! empty($arrayfields['s.phone']['checked']))
1081 1456
 	{
1082 1457
 		print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid)."</td>\n";
1083
-		if (! $i) $totalarray['nbfield']++;
1458
+		if (! $i) {
1459
+		    $totalarray['nbfield']++;
1460
+		}
1084 1461
 	}
1085 1462
 	if (! empty($arrayfields['s.fax']['checked']))
1086 1463
 	{
1087 1464
 		print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid)."</td>\n";
1088
-		if (! $i) $totalarray['nbfield']++;
1465
+		if (! $i) {
1466
+		    $totalarray['nbfield']++;
1467
+		}
1089 1468
 	}
1090 1469
 	if (! empty($arrayfields['s.url']['checked']))
1091 1470
 	{
1092 1471
 		print "<td>".$obj->url."</td>\n";
1093
-		if (! $i) $totalarray['nbfield']++;
1472
+		if (! $i) {
1473
+		    $totalarray['nbfield']++;
1474
+		}
1094 1475
 	}
1095 1476
 	if (! empty($arrayfields['s.siren']['checked']))
1096 1477
 	{
1097 1478
 		print "<td>".$obj->idprof1."</td>\n";
1098
-		if (! $i) $totalarray['nbfield']++;
1479
+		if (! $i) {
1480
+		    $totalarray['nbfield']++;
1481
+		}
1099 1482
 	}
1100 1483
 	if (! empty($arrayfields['s.siret']['checked']))
1101 1484
 	{
1102 1485
 		print "<td>".$obj->idprof2."</td>\n";
1103
-		if (! $i) $totalarray['nbfield']++;
1486
+		if (! $i) {
1487
+		    $totalarray['nbfield']++;
1488
+		}
1104 1489
 	}
1105 1490
 	if (! empty($arrayfields['s.ape']['checked']))
1106 1491
 	{
1107 1492
 		print "<td>".$obj->idprof3."</td>\n";
1108
-		if (! $i) $totalarray['nbfield']++;
1493
+		if (! $i) {
1494
+		    $totalarray['nbfield']++;
1495
+		}
1109 1496
 	}
1110 1497
 	if (! empty($arrayfields['s.idprof4']['checked']))
1111 1498
 	{
1112 1499
 		print "<td>".$obj->idprof4."</td>\n";
1113
-		if (! $i) $totalarray['nbfield']++;
1500
+		if (! $i) {
1501
+		    $totalarray['nbfield']++;
1502
+		}
1114 1503
 	}
1115 1504
 	if (! empty($arrayfields['s.idprof5']['checked']))
1116 1505
 	{
1117 1506
 		print "<td>".$obj->idprof5."</td>\n";
1118
-		if (! $i) $totalarray['nbfield']++;
1507
+		if (! $i) {
1508
+		    $totalarray['nbfield']++;
1509
+		}
1119 1510
 	}
1120 1511
 	if (! empty($arrayfields['s.idprof6']['checked']))
1121 1512
 	{
1122 1513
 		print "<td>".$obj->idprof6."</td>\n";
1123
-		if (! $i) $totalarray['nbfield']++;
1514
+		if (! $i) {
1515
+		    $totalarray['nbfield']++;
1516
+		}
1124 1517
 	}
1125 1518
 	if (! empty($arrayfields['s.tva_intra']['checked']))
1126 1519
 	{
1127 1520
 		print "<td>".$obj->tva_intra."</td>\n";
1128
-		if (! $i) $totalarray['nbfield']++;
1521
+		if (! $i) {
1522
+		    $totalarray['nbfield']++;
1523
+		}
1129 1524
 	}
1130 1525
 	// Type
1131 1526
 	if (! empty($arrayfields['customerorsupplier']['checked']))
@@ -1140,21 +1535,27 @@  discard block
 block discarded – undo
1140 1535
 		}
1141 1536
 		if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1142 1537
 		{
1143
-			if ($s) $s.=" / ";
1538
+			if ($s) {
1539
+			    $s.=" / ";
1540
+			}
1144 1541
 			$companystatic->name=$langs->trans("Prospect");
1145 1542
 	  		$companystatic->name_alias='';
1146 1543
 			$s.=$companystatic->getNomUrl(0,'prospect',0,1);
1147 1544
 		}
1148 1545
 		if ((! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) && $obj->fournisseur)
1149 1546
 		{
1150
-			if ($s) $s.=" / ";
1547
+			if ($s) {
1548
+			    $s.=" / ";
1549
+			}
1151 1550
 			$companystatic->name=$langs->trans("Supplier");
1152 1551
 	  		$companystatic->name_alias='';
1153 1552
 			$s.=$companystatic->getNomUrl(0,'supplier',0,1);
1154 1553
 		}
1155 1554
 		print $s;
1156 1555
 		print '</td>';
1157
-		if (! $i) $totalarray['nbfield']++;
1556
+		if (! $i) {
1557
+		    $totalarray['nbfield']++;
1558
+		}
1158 1559
 	}
1159 1560
 
1160 1561
 	if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
@@ -1163,7 +1564,9 @@  discard block
 block discarded – undo
1163 1564
 		print '<td align="center">';
1164 1565
 		print $companystatic->getLibProspLevel();
1165 1566
 		print "</td>";
1166
-		if (! $i) $totalarray['nbfield']++;
1567
+		if (! $i) {
1568
+		    $totalarray['nbfield']++;
1569
+		}
1167 1570
 	}
1168 1571
 
1169 1572
 	if (! empty($arrayfields['s.fk_stcomm']['checked']))
@@ -1175,11 +1578,17 @@  discard block
 block discarded – undo
1175 1578
 		foreach($prospectstatic->cacheprospectstatus as $key => $val)
1176 1579
 		{
1177 1580
 			$titlealt='default';
1178
-			if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
1179
-			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
1581
+			if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1582
+			    $titlealt=$val['label'];
1583
+			}
1584
+			if ($obj->stcomm_id != $val['id']) {
1585
+			    print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
1586
+			}
1180 1587
 		}
1181 1588
 		print '</div></div></td>';
1182
-		if (! $i) $totalarray['nbfield']++;
1589
+		if (! $i) {
1590
+		    $totalarray['nbfield']++;
1591
+		}
1183 1592
 	}
1184 1593
 	// Extra fields
1185 1594
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
@@ -1193,7 +1602,9 @@  discard block
 block discarded – undo
1193 1602
 		print '<td align="center" class="nowrap">';
1194 1603
 		print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1195 1604
 		print '</td>';
1196
-		if (! $i) $totalarray['nbfield']++;
1605
+		if (! $i) {
1606
+		    $totalarray['nbfield']++;
1607
+		}
1197 1608
 	}
1198 1609
 	// Date modification
1199 1610
 	if (! empty($arrayfields['s.tms']['checked']))
@@ -1201,32 +1612,44 @@  discard block
 block discarded – undo
1201 1612
 		print '<td align="center" class="nowrap">';
1202 1613
 		print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1203 1614
 		print '</td>';
1204
-		if (! $i) $totalarray['nbfield']++;
1615
+		if (! $i) {
1616
+		    $totalarray['nbfield']++;
1617
+		}
1205 1618
 	}
1206 1619
 	// Status
1207 1620
 	if (! empty($arrayfields['s.status']['checked']))
1208 1621
 	{
1209 1622
 		print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
1210
-		if (! $i) $totalarray['nbfield']++;
1623
+		if (! $i) {
1624
+		    $totalarray['nbfield']++;
1625
+		}
1211 1626
 	}
1212 1627
 	if (! empty($arrayfields['s.import_key']['checked']))
1213 1628
 	{
1214 1629
 		print '<td class="tdoverflowmax100">';
1215 1630
 		print $obj->import_key;
1216 1631
 		print "</td>\n";
1217
-		if (! $i) $totalarray['nbfield']++;
1632
+		if (! $i) {
1633
+		    $totalarray['nbfield']++;
1634
+		}
1218 1635
 	}
1219 1636
 
1220 1637
 	// Action column
1221 1638
 	print '<td class="nowrap" align="center">';
1222
-	if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1639
+	if ($massactionbutton || $massaction) {
1640
+	    // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1223 1641
 	{
1224 1642
 		$selected=0;
1225
-		if (in_array($obj->rowid, $arrayofselected)) $selected=1;
1643
+	}
1644
+		if (in_array($obj->rowid, $arrayofselected)) {
1645
+		    $selected=1;
1646
+		}
1226 1647
 		print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
1227 1648
 	}
1228 1649
 	print '</td>';
1229
-	if (! $i) $totalarray['nbfield']++;
1650
+	if (! $i) {
1651
+	    $totalarray['nbfield']++;
1652
+	}
1230 1653
 
1231 1654
 	print '</tr>'."\n";
1232 1655
 	$i++;
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_login.class.php 3 patches
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.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @url GET /
56 56
 	 * @url POST /
57 57
 	 */
58
-    public function index($login, $password, $entity='', $reset=0)
58
+    public function index($login, $password, $entity = '', $reset = 0)
59 59
     {
60 60
 
61 61
 	    global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		// Authentication mode: forceuser
67 67
 		if ($dolibarr_main_authentication == 'forceuser')
68 68
 		{
69
-			if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
69
+			if (empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto';
70 70
 			if ($dolibarr_auto_user != $login)
71 71
 			{
72 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.");
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 		// Set authmode
77 77
 		$authmode = explode(',', $dolibarr_main_authentication);
78 78
 
79
-		if ($entity != '' && ! is_numeric($entity))
79
+		if ($entity != '' && !is_numeric($entity))
80 80
 		{
81 81
 			throw new RestException(403, "Bad value for entity, must be the numeric ID of company.");
82 82
 		}
83
-		if ($entity == '') $entity=1;
83
+		if ($entity == '') $entity = 1;
84 84
 
85
-		include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
85
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
86 86
 		$login = checkLoginPassEntity($login, $password, $entity, $authmode);
87 87
 		if (empty($login))
88 88
 		{
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$token = 'failedtogenerateorgettoken';
93 93
 
94
-		$tmpuser=new User($this->db);
94
+		$tmpuser = new User($this->db);
95 95
 		$tmpuser->fetch(0, $login, 0, 0, $entity);
96 96
 		if (empty($tmpuser->id))
97 97
 		{
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 			}
109 109
 
110 110
     		// Generate token for user
111
-    		$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
111
+    		$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1);
112 112
 
113 113
     		// We store API token into database
114 114
     		$sql = "UPDATE ".MAIN_DB_PREFIX."user";
115
-    		$sql.= " SET api_key = '".$this->db->escape($token)."'";
116
-    		$sql.= " WHERE login = '".$this->db->escape($login)."'";
115
+    		$sql .= " SET api_key = '".$this->db->escape($token)."'";
116
+    		$sql .= " WHERE login = '".$this->db->escape($login)."'";
117 117
 
118
-    		dol_syslog(get_class($this)."::login", LOG_DEBUG);	// No log
118
+    		dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log
119 119
     		$result = $this->db->query($sql);
120 120
     		if (!$result)
121 121
     		{
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 				'code' => 200,
134 134
 				'token' => $token,
135 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.')
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 137
 			)
138 138
 		);
139 139
 	}
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,12 +61,15 @@  discard block
 block discarded – undo
61 61
 	    global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
62 62
 
63 63
 		// Authentication mode
64
-		if (empty($dolibarr_main_authentication))
65
-			$dolibarr_main_authentication = 'http,dolibarr';
64
+		if (empty($dolibarr_main_authentication)) {
65
+					$dolibarr_main_authentication = 'http,dolibarr';
66
+		}
66 67
 		// Authentication mode: forceuser
67 68
 		if ($dolibarr_main_authentication == 'forceuser')
68 69
 		{
69
-			if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
70
+			if (empty($dolibarr_auto_user)) {
71
+			    $dolibarr_auto_user='auto';
72
+			}
70 73
 			if ($dolibarr_auto_user != $login)
71 74
 			{
72 75
 				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.");
@@ -80,7 +83,9 @@  discard block
 block discarded – undo
80 83
 		{
81 84
 			throw new RestException(403, "Bad value for entity, must be the numeric ID of company.");
82 85
 		}
83
-		if ($entity == '') $entity=1;
86
+		if ($entity == '') {
87
+		    $entity=1;
88
+		}
84 89
 
85 90
 		include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
86 91
 		$login = checkLoginPassEntity($login, $password, $entity, $authmode);
@@ -121,8 +126,7 @@  discard block
 block discarded – undo
121 126
     		{
122 127
     			throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror());
123 128
     		}
124
-		}
125
-		else
129
+		} else
126 130
 		{
127 131
             $token = $tmpuser->api_key;
128 132
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api.class.php 3 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
         // Remove $db object property for object
101 101
         unset($object->db);
102 102
         unset($object->isextrafieldmanaged);
103
-		unset($object->ismultientitymanaged);
104
-		unset($object->restrictiononfksoc);
103
+        unset($object->ismultientitymanaged);
104
+        unset($object->restrictiononfksoc);
105 105
 
106 106
         // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses
107 107
         unset($object->linkedObjects);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         unset($object->picto);
146 146
 
147 147
         unset($object->fieldsforcombobox);
148
-		unset($object->comments);
148
+        unset($object->comments);
149 149
 
150 150
         unset($object->skip_update_total);
151 151
         unset($object->context);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         // If object has lines, remove $db property
165 165
         if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0)  {
166 166
             $nboflines = count($object->lines);
167
-        	for ($i=0; $i < $nboflines; $i++)
167
+            for ($i=0; $i < $nboflines; $i++)
168 168
             {
169 169
                 $this->_cleanObjectDatas($object->lines[$i]);
170 170
 
@@ -202,101 +202,101 @@  discard block
 block discarded – undo
202 202
 
203 203
         if (! empty($object->thirdparty) && is_object($object->thirdparty))
204 204
         {
205
-        	$this->_cleanObjectDatas($object->thirdparty);
205
+            $this->_cleanObjectDatas($object->thirdparty);
206 206
         }
207 207
 
208
-		return $object;
208
+        return $object;
209 209
     }
210 210
 
211
-	/**
212
-	 * Check user access to a resource
213
-	 *
214
-	 * Check access by user to a given resource
215
-	 *
216
-	 * @param string	$resource		element to check
217
-	 * @param int		$resource_id	Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
218
-	 * @param type		$dbtablename	'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
219
-	 * @param string	$feature2		Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
220
-	 * @param string	$dbt_keyfield   Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
221
-	 * @param string	$dbt_select     Field name for select if not rowid. Not used if objectid is null (optional)
211
+    /**
212
+     * Check user access to a resource
213
+     *
214
+     * Check access by user to a given resource
215
+     *
216
+     * @param string	$resource		element to check
217
+     * @param int		$resource_id	Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
218
+     * @param type		$dbtablename	'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
219
+     * @param string	$feature2		Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
220
+     * @param string	$dbt_keyfield   Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
221
+     * @param string	$dbt_select     Field name for select if not rowid. Not used if objectid is null (optional)
222 222
      * @return bool
223
-	 * @throws RestException
224
-	 */
223
+     * @throws RestException
224
+     */
225 225
     static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
226 226
     {
227 227
 
228
-		// Features/modules to check
229
-		$featuresarray = array($resource);
230
-		if (preg_match('/&/', $resource)) {
231
-			$featuresarray = explode("&", $resource);
232
-		}
233
-		else if (preg_match('/\|/', $resource)) {
234
-			$featuresarray = explode("|", $resource);
235
-		}
236
-
237
-		// More subfeatures to check
238
-		if (! empty($feature2)) {
239
-			$feature2 = explode("|", $feature2);
240
-		}
241
-
242
-		return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
243
-	}
244
-
245
-	/**
246
-	 * Return if a $sqlfilters parameter is valid
247
-	 *
248
-	 * @param  string   $sqlfilters     sqlfilter string
249
-	 * @return boolean                  True if valid, False if not valid
250
-	 */
251
-	function _checkFilters($sqlfilters)
252
-	{
253
-	    //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
254
-	    //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
255
-	    $tmp=$sqlfilters;
256
-	    $ok=0;
257
-	    $i=0; $nb=strlen($tmp);
258
-	    $counter=0;
259
-	    while ($i < $nb)
260
-	    {
261
-	        if ($tmp[$i]=='(') $counter++;
262
-	        if ($tmp[$i]==')') $counter--;
228
+        // Features/modules to check
229
+        $featuresarray = array($resource);
230
+        if (preg_match('/&/', $resource)) {
231
+            $featuresarray = explode("&", $resource);
232
+        }
233
+        else if (preg_match('/\|/', $resource)) {
234
+            $featuresarray = explode("|", $resource);
235
+        }
236
+
237
+        // More subfeatures to check
238
+        if (! empty($feature2)) {
239
+            $feature2 = explode("|", $feature2);
240
+        }
241
+
242
+        return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
243
+    }
244
+
245
+    /**
246
+     * Return if a $sqlfilters parameter is valid
247
+     *
248
+     * @param  string   $sqlfilters     sqlfilter string
249
+     * @return boolean                  True if valid, False if not valid
250
+     */
251
+    function _checkFilters($sqlfilters)
252
+    {
253
+        //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
254
+        //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
255
+        $tmp=$sqlfilters;
256
+        $ok=0;
257
+        $i=0; $nb=strlen($tmp);
258
+        $counter=0;
259
+        while ($i < $nb)
260
+        {
261
+            if ($tmp[$i]=='(') $counter++;
262
+            if ($tmp[$i]==')') $counter--;
263 263
             if ($counter < 0)
264 264
             {
265
-	           $error="Bad sqlfilters=".$sqlfilters;
266
-	           dol_syslog($error, LOG_WARNING);
267
-	           return false;
265
+                $error="Bad sqlfilters=".$sqlfilters;
266
+                dol_syslog($error, LOG_WARNING);
267
+                return false;
268 268
             }
269 269
             $i++;
270
-	    }
271
-	    return true;
272
-	}
270
+        }
271
+        return true;
272
+    }
273 273
 
274 274
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
275
-	/**
276
-	 * Function to forge a SQL criteria
277
-	 *
278
-	 * @param  array    $matches       Array of found string by regex search
279
-	 * @return string                  Forged criteria. Example: "t.field like 'abc%'"
280
-	 */
281
-	static function _forge_criteria_callback($matches)
282
-	{
275
+    /**
276
+     * Function to forge a SQL criteria
277
+     *
278
+     * @param  array    $matches       Array of found string by regex search
279
+     * @return string                  Forged criteria. Example: "t.field like 'abc%'"
280
+     */
281
+    static function _forge_criteria_callback($matches)
282
+    {
283 283
         // phpcs:enable
284
-	    global $db;
284
+        global $db;
285 285
 
286
-	    //dol_syslog("Convert matches ".$matches[1]);
287
-	    if (empty($matches[1])) return '';
288
-	    $tmp=explode(':',$matches[1]);
286
+        //dol_syslog("Convert matches ".$matches[1]);
287
+        if (empty($matches[1])) return '';
288
+        $tmp=explode(':',$matches[1]);
289 289
         if (count($tmp) < 3) return '';
290 290
 
291
-	    $tmpescaped=$tmp[2];
292
-	    if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
293
-	    {
294
-	        $tmpescaped = "'".$db->escape($regbis[1])."'";
295
-	    }
296
-	    else
297
-	    {
298
-	        $tmpescaped = $db->escape($tmpescaped);
299
-	    }
300
-	    return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
301
-	}
291
+        $tmpescaped=$tmp[2];
292
+        if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
293
+        {
294
+            $tmpescaped = "'".$db->escape($regbis[1])."'";
295
+        }
296
+        else
297
+        {
298
+            $tmpescaped = $db->escape($tmpescaped);
299
+        }
300
+        return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
301
+    }
302 302
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param   string  $cachedir       Cache dir
47 47
      * @param   boolean $refreshCache   Update cache
48 48
      */
49
-    function __construct($db, $cachedir='', $refreshCache=false)
49
+    function __construct($db, $cachedir = '', $refreshCache = false)
50 50
     {
51 51
         global $conf, $dolibarr_main_url_root;
52 52
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
         Defaults::$cacheDirectory = $cachedir;
55 55
 
56 56
         $this->db = $db;
57
-        $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
57
+        $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true);
58 58
         $this->r = new Restler($production_mode, $refreshCache);
59 59
 
60
-        $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
61
-        $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
60
+        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
61
+        $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
62 62
 
63
-        $urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT));
64
-        $urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
63
+        $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT));
64
+        $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
65 65
 
66 66
         $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
67 67
         $this->r->setAPIVersion(1);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
         unset($object->ref_next);
119 119
         unset($object->ref_int);
120 120
 
121
-        unset($object->projet);     // Should be fk_project
122
-        unset($object->project);    // Should be fk_project
123
-        unset($object->author);     // Should be fk_user_author
121
+        unset($object->projet); // Should be fk_project
122
+        unset($object->project); // Should be fk_project
123
+        unset($object->author); // Should be fk_user_author
124 124
         unset($object->timespent_old_duration);
125 125
         unset($object->timespent_id);
126 126
         unset($object->timespent_duration);
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
         unset($object->oldcopy);
163 163
 
164 164
         // If object has lines, remove $db property
165
-        if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0)  {
165
+        if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
166 166
             $nboflines = count($object->lines);
167
-        	for ($i=0; $i < $nboflines; $i++)
167
+        	for ($i = 0; $i < $nboflines; $i++)
168 168
             {
169 169
                 $this->_cleanObjectDatas($object->lines[$i]);
170 170
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             }
201 201
         }
202 202
 
203
-        if (! empty($object->thirdparty) && is_object($object->thirdparty))
203
+        if (!empty($object->thirdparty) && is_object($object->thirdparty))
204 204
         {
205 205
         	$this->_cleanObjectDatas($object->thirdparty);
206 206
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @return bool
223 223
 	 * @throws RestException
224 224
 	 */
225
-    static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
225
+    static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
226 226
     {
227 227
 
228 228
 		// Features/modules to check
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 		}
236 236
 
237 237
 		// More subfeatures to check
238
-		if (! empty($feature2)) {
238
+		if (!empty($feature2)) {
239 239
 			$feature2 = explode("|", $feature2);
240 240
 		}
241 241
 
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
 	{
253 253
 	    //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
254 254
 	    //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
255
-	    $tmp=$sqlfilters;
256
-	    $ok=0;
257
-	    $i=0; $nb=strlen($tmp);
258
-	    $counter=0;
255
+	    $tmp = $sqlfilters;
256
+	    $ok = 0;
257
+	    $i = 0; $nb = strlen($tmp);
258
+	    $counter = 0;
259 259
 	    while ($i < $nb)
260 260
 	    {
261
-	        if ($tmp[$i]=='(') $counter++;
262
-	        if ($tmp[$i]==')') $counter--;
261
+	        if ($tmp[$i] == '(') $counter++;
262
+	        if ($tmp[$i] == ')') $counter--;
263 263
             if ($counter < 0)
264 264
             {
265
-	           $error="Bad sqlfilters=".$sqlfilters;
265
+	           $error = "Bad sqlfilters=".$sqlfilters;
266 266
 	           dol_syslog($error, LOG_WARNING);
267 267
 	           return false;
268 268
             }
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 
286 286
 	    //dol_syslog("Convert matches ".$matches[1]);
287 287
 	    if (empty($matches[1])) return '';
288
-	    $tmp=explode(':',$matches[1]);
288
+	    $tmp = explode(':', $matches[1]);
289 289
         if (count($tmp) < 3) return '';
290 290
 
291
-	    $tmpescaped=$tmp[2];
291
+	    $tmpescaped = $tmp[2];
292 292
 	    if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
293 293
 	    {
294 294
 	        $tmpescaped = "'".$db->escape($regbis[1])."'";
Please login to merge, or discard this patch.
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,9 @@  discard block
 block discarded – undo
50 50
     {
51 51
         global $conf, $dolibarr_main_url_root;
52 52
 
53
-        if (empty($cachedir)) $cachedir = $conf->api->dir_temp;
53
+        if (empty($cachedir)) {
54
+            $cachedir = $conf->api->dir_temp;
55
+        }
54 56
         Defaults::$cacheDirectory = $cachedir;
55 57
 
56 58
         $this->db = $db;
@@ -229,8 +231,7 @@  discard block
 block discarded – undo
229 231
 		$featuresarray = array($resource);
230 232
 		if (preg_match('/&/', $resource)) {
231 233
 			$featuresarray = explode("&", $resource);
232
-		}
233
-		else if (preg_match('/\|/', $resource)) {
234
+		} else if (preg_match('/\|/', $resource)) {
234 235
 			$featuresarray = explode("|", $resource);
235 236
 		}
236 237
 
@@ -258,8 +259,12 @@  discard block
 block discarded – undo
258 259
 	    $counter=0;
259 260
 	    while ($i < $nb)
260 261
 	    {
261
-	        if ($tmp[$i]=='(') $counter++;
262
-	        if ($tmp[$i]==')') $counter--;
262
+	        if ($tmp[$i]=='(') {
263
+	            $counter++;
264
+	        }
265
+	        if ($tmp[$i]==')') {
266
+	            $counter--;
267
+	        }
263 268
             if ($counter < 0)
264 269
             {
265 270
 	           $error="Bad sqlfilters=".$sqlfilters;
@@ -284,16 +289,19 @@  discard block
 block discarded – undo
284 289
 	    global $db;
285 290
 
286 291
 	    //dol_syslog("Convert matches ".$matches[1]);
287
-	    if (empty($matches[1])) return '';
292
+	    if (empty($matches[1])) {
293
+	        return '';
294
+	    }
288 295
 	    $tmp=explode(':',$matches[1]);
289
-        if (count($tmp) < 3) return '';
296
+        if (count($tmp) < 3) {
297
+            return '';
298
+        }
290 299
 
291 300
 	    $tmpescaped=$tmp[2];
292 301
 	    if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
293 302
 	    {
294 303
 	        $tmpescaped = "'".$db->escape($regbis[1])."'";
295
-	    }
296
-	    else
304
+	    } else
297 305
 	    {
298 306
 	        $tmpescaped = $db->escape($tmpescaped);
299 307
 	    }
Please login to merge, or discard this patch.