Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/api/index.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
  *  \file       htdocs/api/index.php
25 25
  */
26 26
 
27
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');			// Do not check anti CSRF attack test
28
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');		// Do not check anti POST attack test
29
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');		// If there is no need to load and show top and left menu
30
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');		// If we don't need to load the html.form.class.php
31
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');       // Do not load ajax.lib.php library
32
-if (! defined("NOLOGIN"))        define("NOLOGIN",'1');				// If this page is public (can be called outside logged session)
27
+if (!defined('NOCSRFCHECK'))    define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
28
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
29
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
30
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
31
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
32
+if (!defined("NOLOGIN"))        define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
33 33
 
34 34
 
35 35
 // Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used.
36
-if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']);
36
+if (!empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']);
37 37
 
38 38
 
39
-$res=0;
40
-if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php';
41
-if (! $res) die("Include of main fails");
39
+$res = 0;
40
+if (!$res && file_exists("../main.inc.php")) $res = include '../main.inc.php';
41
+if (!$res) die("Include of main fails");
42 42
 
43 43
 require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php';
44 44
 
45
-call_user_func(function () {
45
+call_user_func(function() {
46 46
     $loader = Luracast\Restler\AutoLoader::instance();
47 47
     spl_autoload_register($loader);
48 48
     return $loader;
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 {
60 60
     $langs->load("admin");
61 61
     dol_syslog("Call Dolibarr API interfaces with module REST disabled");
62
-    print $langs->trans("WarningModuleNotActive",'Api').'.<br><br>';
62
+    print $langs->trans("WarningModuleNotActive", 'Api').'.<br><br>';
63 63
     print $langs->trans("ToActivateModule");
64 64
     exit;
65 65
 }
66 66
 
67 67
 // Test if explorer is not disabled
68
-if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($conf->global->API_EXPLORER_DISABLED))
68
+if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && !empty($conf->global->API_EXPLORER_DISABLED))
69 69
 {
70 70
     $langs->load("admin");
71 71
     dol_syslog("Call Dolibarr API interfaces with module REST disabled");
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 
94 94
 
95 95
 // Set the flag to say to refresh (when we reload the explorer, production must be for API call only)
96
-$refreshcache=false;
97
-if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
96
+$refreshcache = false;
97
+if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
98 98
 {
99
-    $refreshcache=true;
99
+    $refreshcache = true;
100 100
 }
101 101
 
102 102
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 // See https://github.com/Luracast/Restler-API-Explorer for more info.
108 108
 $api->r->addAPIClass('Luracast\\Restler\\Explorer');
109 109
 
110
-$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat');	// 'YamlFormat'
111
-$api->r->addAuthenticationClass('DolibarrApiAccess','');
110
+$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); // 'YamlFormat'
111
+$api->r->addAuthenticationClass('DolibarrApiAccess', '');
112 112
 
113 113
 // Define accepted mime types
114 114
 UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 
118 118
 // Call Explorer file for all APIs definitions
119
-if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
119
+if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
120 120
 {
121 121
     // Scan all API files to load them
122 122
 
@@ -128,25 +128,25 @@  discard block
 block discarded – undo
128 128
         // Search available module
129 129
         dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files");
130 130
 
131
-        $handle=@opendir(dol_osencode($dir));
131
+        $handle = @opendir(dol_osencode($dir));
132 132
         if (is_resource($handle))
133 133
         {
134
-            while (($file = readdir($handle))!==false)
134
+            while (($file = readdir($handle)) !== false)
135 135
             {
136
-                if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$regmod))
136
+                if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod))
137 137
                 {
138 138
                     $module = strtolower($regmod[1]);
139 139
                     $moduledirforclass = getModuleDirForApiClass($module);
140 140
                     $modulenameforenabled = $module;
141
-                    if ($module == 'propale') { $modulenameforenabled='propal'; }
142
-                    if ($module == 'supplierproposal') { $modulenameforenabled='supplier_proposal'; }
143
-                    if ($module == 'ficheinter') { $modulenameforenabled='ficheinter'; }
141
+                    if ($module == 'propale') { $modulenameforenabled = 'propal'; }
142
+                    if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; }
143
+                    if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; }
144 144
 
145 145
                     dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass);
146 146
 
147 147
                     // Defined if module is enabled
148
-                    $enabled=true;
149
-                    if (empty($conf->$modulenameforenabled->enabled)) $enabled=false;
148
+                    $enabled = true;
149
+                    if (empty($conf->$modulenameforenabled->enabled)) $enabled = false;
150 150
 
151 151
                     if ($enabled)
152 152
                     {
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
                         // @todo : use getElementProperties() function ?
156 156
                         $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
157 157
 
158
-                        $handle_part=@opendir(dol_osencode($dir_part));
158
+                        $handle_part = @opendir(dol_osencode($dir_part));
159 159
                         if (is_resource($handle_part))
160 160
                         {
161
-                            while (($file_searched = readdir($handle_part))!==false)
161
+                            while (($file_searched = readdir($handle_part)) !== false)
162 162
                             {
163 163
                                 if ($file_searched == 'api_access.class.php') continue;
164 164
 
165
-                                if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi))
165
+                                if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi))
166 166
                                 {
167 167
                                     $classname = ucwords($regapi[1]);
168 168
                                     $classname = str_replace('_', '', $classname);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 }
202 202
 
203 203
 // Call one APIs or one definition of an API
204
-if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root')))
204
+if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root')))
205 205
 {
206 206
     $module = $reg[1];
207 207
     if ($module == 'explorer')  // If we call page to explore details of a service
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $module = $regbis[2];
210 210
     }
211 211
 
212
-    $module=strtolower($module);
212
+    $module = strtolower($module);
213 213
     $moduledirforclass = getModuleDirForApiClass($module);
214 214
 
215 215
     // Load a dedicated API file
@@ -230,16 +230,16 @@  discard block
 block discarded – undo
230 230
 	if ($module == 'interventions')
231 231
 		$classfile = 'interventions';
232 232
 
233
-	$dir_part_file = dol_buildpath('/' . $moduledirforclass . '/class/api_' . $classfile . '.class.php', 0, 2);
233
+	$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php', 0, 2);
234 234
 
235 235
 	$classname = ucwords($module);
236 236
 
237
-	dol_syslog('Search /' . $moduledirforclass . '/class/api_' . $classfile . '.class.php => dir_part_file=' . $dir_part_file . ' classname=' . $classname);
237
+	dol_syslog('Search /'.$moduledirforclass.'/class/api_'.$classfile.'.class.php => dir_part_file='.$dir_part_file.' classname='.$classname);
238 238
 
239 239
 	$res = false;
240 240
 	if ($dir_part_file)
241 241
 		$res = include_once $dir_part_file;
242
-	if (! $res) {
242
+	if (!$res) {
243 243
 		print 'API not found (failed to include API file)';
244 244
 		header('HTTP/1.1 501 API not found (failed to include API file)');
245 245
 		exit(0);
Please login to merge, or discard this patch.
dolibarr/htdocs/paypal/lib/paypalfunctions.lib.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 // PayPal Express Checkout Module
39 39
 // ==================================
40 40
 
41
-$API_version="56";
41
+$API_version = "56";
42 42
 
43 43
 /*
44 44
  ' Define the PayPal Redirect URLs.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  ' For the sandbox, the URL is       https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
49 49
  ' For the live site, the URL is        https://www.paypal.com/webscr&cmd=_express-checkout&token=
50 50
  */
51
-if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))		// We can force sand box with param 'forcesandbox'
51
+if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha'))		// We can force sand box with param 'forcesandbox'
52 52
 {
53 53
     $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
54 54
     $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 // Clean parameters
63
-$PAYPAL_API_USER="";
64
-if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER;
65
-$PAYPAL_API_PASSWORD="";
66
-if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD;
67
-$PAYPAL_API_SIGNATURE="";
68
-if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE;
69
-$PAYPAL_API_SANDBOX="";
70
-if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX;
63
+$PAYPAL_API_USER = "";
64
+if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
65
+$PAYPAL_API_PASSWORD = "";
66
+if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
67
+$PAYPAL_API_SIGNATURE = "";
68
+if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
69
+$PAYPAL_API_SANDBOX = "";
70
+if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
71 71
 
72 72
 // Proxy
73 73
 $PROXY_HOST = $conf->global->MAIN_PROXY_HOST;
74 74
 $PROXY_PORT = $conf->global->MAIN_PROXY_PORT;
75 75
 $PROXY_USER = $conf->global->MAIN_PROXY_USER;
76 76
 $PROXY_PASS = $conf->global->MAIN_PROXY_PASS;
77
-$USE_PROXY = empty($conf->global->MAIN_PROXY_USE)?false:true;
77
+$USE_PROXY = empty($conf->global->MAIN_PROXY_USE) ?false:true;
78 78
 
Please login to merge, or discard this patch.
dolibarr/htdocs/paypal/lib/paypal.lib.php 1 patch
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 	$head[$h][2] = 'paypalaccount';
41 41
 	$h++;
42 42
 
43
-	$object=new stdClass();
43
+	$object = new stdClass();
44 44
 
45 45
     // Show more tabs from modules
46 46
     // Entries must be declared in modules descriptor with line
47 47
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
48 48
     // $this->tabs = array('entity:-tabname);   												to remove a tab
49
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'paypaladmin');
49
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'paypaladmin');
50 50
 
51
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'paypaladmin','remove');
51
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'paypaladmin', 'remove');
52 52
 
53 53
     return $head;
54 54
 }
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
  * @param	string	$ref		Ref of object
63 63
  * @return	string				Url string
64 64
  */
65
-function showPaypalPaymentUrl($type,$ref)
65
+function showPaypalPaymentUrl($type, $ref)
66 66
 {
67 67
 	global $conf, $langs;
68 68
 
69 69
 	$langs->load("paypal");
70 70
     $langs->load("paybox");
71
-    $servicename='PayPal';
72
-    $out='<br><br>';
73
-    $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
74
-    $url=getPaypalPaymentUrl(0,$type,$ref);
75
-    $out.='<input type="text" id="paypalurl" class="quatrevingtpercent" value="'.$url.'">';
76
-    $out.=ajax_autoselect("paypalurl", 0);
71
+    $servicename = 'PayPal';
72
+    $out = '<br><br>';
73
+    $out .= img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'<br>';
74
+    $url = getPaypalPaymentUrl(0, $type, $ref);
75
+    $out .= '<input type="text" id="paypalurl" class="quatrevingtpercent" value="'.$url.'">';
76
+    $out .= ajax_autoselect("paypalurl", 0);
77 77
     return $out;
78 78
 }
79 79
 
@@ -88,96 +88,96 @@  discard block
 block discarded – undo
88 88
  * @param	string	$freetag	Free tag
89 89
  * @return	string				Url string
90 90
  */
91
-function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag')
91
+function getPaypalPaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag')
92 92
 {
93 93
 	global $conf;
94 94
 
95
-	$ref=str_replace(' ','',$ref);
95
+	$ref = str_replace(' ', '', $ref);
96 96
 
97 97
     if ($type == 'free')
98 98
     {
99
-	    $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
100
-	    if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
99
+	    $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode ? '<font color="#666666">' : '').$amount.($mode ? '</font>' : '').'&tag='.($mode ? '<font color="#666666">' : '').$freetag.($mode ? '</font>' : '');
100
+	    if (!empty($conf->global->PAYPAL_SECURITY_TOKEN))
101 101
 	    {
102
-	    	if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
103
-	    	else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
102
+	    	if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
103
+	    	else $out .= '&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
104 104
 	    }
105 105
     }
106 106
     if ($type == 'order')
107 107
     {
108
-        $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
109
-        if ($mode == 1) $out.='order_ref';
110
-        if ($mode == 0) $out.=urlencode($ref);
111
-	    $out.=($mode?'</font>':'');
112
-        if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
108
+        $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode ? '<font color="#666666">' : '');
109
+        if ($mode == 1) $out .= 'order_ref';
110
+        if ($mode == 0) $out .= urlencode($ref);
111
+	    $out .= ($mode ? '</font>' : '');
112
+        if (!empty($conf->global->PAYPAL_SECURITY_TOKEN))
113 113
         {
114
-    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
114
+    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
115 115
             else
116 116
             {
117
-                $out.='&securekey='.($mode?'<font color="#666666">':'');
118
-                if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)";
119
-                if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2);
120
-                $out.=($mode?'</font>':'');
117
+                $out .= '&securekey='.($mode ? '<font color="#666666">' : '');
118
+                if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)";
119
+                if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2);
120
+                $out .= ($mode ? '</font>' : '');
121 121
             }
122 122
         }
123 123
     }
124 124
     if ($type == 'invoice')
125 125
     {
126
-        $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
127
-        if ($mode == 1) $out.='invoice_ref';
128
-        if ($mode == 0) $out.=urlencode($ref);
129
-	    $out.=($mode?'</font>':'');
130
-        if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
126
+        $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode ? '<font color="#666666">' : '');
127
+        if ($mode == 1) $out .= 'invoice_ref';
128
+        if ($mode == 0) $out .= urlencode($ref);
129
+	    $out .= ($mode ? '</font>' : '');
130
+        if (!empty($conf->global->PAYPAL_SECURITY_TOKEN))
131 131
         {
132
-    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
132
+    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
133 133
             else
134 134
             {
135
-                $out.='&securekey='.($mode?'<font color="#666666">':'');
136
-                if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
137
-                if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2);
138
-                $out.=($mode?'</font>':'');
135
+                $out .= '&securekey='.($mode ? '<font color="#666666">' : '');
136
+                if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
137
+                if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2);
138
+                $out .= ($mode ? '</font>' : '');
139 139
             }
140 140
         }
141 141
     }
142 142
     if ($type == 'contractline')
143 143
     {
144
-        $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
145
-        if ($mode == 1) $out.='contractline_ref';
146
-        if ($mode == 0) $out.=urlencode($ref);
147
-	    $out.=($mode?'</font>':'');
148
-        if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
144
+        $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode ? '<font color="#666666">' : '');
145
+        if ($mode == 1) $out .= 'contractline_ref';
146
+        if ($mode == 0) $out .= urlencode($ref);
147
+	    $out .= ($mode ? '</font>' : '');
148
+        if (!empty($conf->global->PAYPAL_SECURITY_TOKEN))
149 149
         {
150
-    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
150
+    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
151 151
             else
152 152
             {
153
-                $out.='&securekey='.($mode?'<font color="#666666">':'');
154
-                if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
155
-                if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2);
156
-                $out.=($mode?'</font>':'');
153
+                $out .= '&securekey='.($mode ? '<font color="#666666">' : '');
154
+                if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
155
+                if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2);
156
+                $out .= ($mode ? '</font>' : '');
157 157
             }
158 158
         }
159 159
     }
160 160
     if ($type == 'membersubscription')
161 161
     {
162
-        $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
163
-        if ($mode == 1) $out.='member_ref';
164
-        if ($mode == 0) $out.=urlencode($ref);
165
-	    $out.=($mode?'</font>':'');
166
-        if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
162
+        $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode ? '<font color="#666666">' : '');
163
+        if ($mode == 1) $out .= 'member_ref';
164
+        if ($mode == 0) $out .= urlencode($ref);
165
+	    $out .= ($mode ? '</font>' : '');
166
+        if (!empty($conf->global->PAYPAL_SECURITY_TOKEN))
167 167
         {
168
-    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
168
+    	    if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
169 169
             else
170 170
             {
171
-                $out.='&securekey='.($mode?'<font color="#666666">':'');
172
-                if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)";
173
-                if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2);
174
-                $out.=($mode?'</font>':'');
171
+                $out .= '&securekey='.($mode ? '<font color="#666666">' : '');
172
+                if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)";
173
+                if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2);
174
+                $out .= ($mode ? '</font>' : '');
175 175
             }
176 176
         }
177 177
     }
178 178
 
179 179
     // For multicompany
180
-    $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
180
+    $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
181 181
 
182 182
     return $out;
183 183
 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  * @param   string	$tag				Full tag
195 195
  * @return	string						No return (a redirect is done) if OK, or Error message if KO
196 196
  */
197
-function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag)
197
+function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag)
198 198
 {
199 199
     //declaring of global variables
200 200
     global $conf, $langs;
@@ -209,27 +209,27 @@  discard block
 block discarded – undo
209 209
     //'
210 210
     //'-------------------------------------------------
211 211
 
212
-    if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral';
212
+    if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
213 213
 
214
-    $solutionType='Sole';
215
-    $landingPage='Billing';
214
+    $solutionType = 'Sole';
215
+    $landingPage = 'Billing';
216 216
     // For payment with Paypal only
217 217
     if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly')
218 218
     {
219
-        $solutionType='Mark';
220
-        $landingPage='Login';
219
+        $solutionType = 'Mark';
220
+        $landingPage = 'Login';
221 221
     }
222 222
     // For payment with Credit card or Paypal
223 223
     if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
224 224
     {
225
-        $solutionType='Sole';
226
-        $landingPage='Billing';
225
+        $solutionType = 'Sole';
226
+        $landingPage = 'Billing';
227 227
     }
228 228
     // For payment with Credit card
229 229
     if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly')
230 230
     {
231
-        $solutionType='Sole';
232
-        $landingPage='Billing';
231
+        $solutionType = 'Sole';
232
+        $landingPage = 'Billing';
233 233
     }
234 234
 
235 235
     dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
     );
256 256
 
257 257
     $ack = strtoupper($resArray["ACK"]);
258
-    if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
258
+    if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
259 259
     {
260
-        $token=$resArray["TOKEN"];
260
+        $token = $resArray["TOKEN"];
261 261
 
262 262
         // Redirect to paypal.com here
263
-        $payPalURL = $API_Url . $token;
263
+        $payPalURL = $API_Url.$token;
264 264
         header("Location: ".$payPalURL);
265 265
         exit;
266 266
     }
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
 
275 275
         if ($ErrorCode == 10729)
276 276
         {
277
-        	$mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n";
277
+        	$mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n";
278 278
         }
279 279
         else
280 280
         {
281
-        	$mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "<br>\n";
282
-        	$mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."<br>\n";
283
-        	$mesg.= $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."<br>\n";
284
-        	$mesg.= $langs->trans('ErrorCode') . ": " . $ErrorCode."<br>\n";
285
-        	$mesg.= $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."<br>\n";
281
+        	$mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."<br>\n";
282
+        	$mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."<br>\n";
283
+        	$mesg .= $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."<br>\n";
284
+        	$mesg .= $langs->trans('ErrorCode').": ".$ErrorCode."<br>\n";
285
+        	$mesg .= $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."<br>\n";
286 286
         }
287 287
 
288 288
         return $mesg;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
  * @param	string			$desc				Description
331 331
  * @return	array								Array
332 332
  */
333
-function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum, $email='', $desc='')
333
+function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum, $email = '', $desc = '')
334 334
 {
335 335
     //------------------------------------------------------------------------------------------------------------------------------------
336 336
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
@@ -342,92 +342,92 @@  discard block
 block discarded – undo
342 342
 
343 343
     $nvpstr = '';
344 344
     //$nvpstr = $nvpstr . "&VERSION=".$API_version;				// Already added by hash_call
345
-    $nvpstr = $nvpstr . "&RETURNURL=" . urlencode($returnURL);
346
-    $nvpstr = $nvpstr . "&CANCELURL=" . urlencode($cancelURL);
347
-    if (! empty($conf->global->PAYPAL_ALLOW_NOTES))
345
+    $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL);
346
+    $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL);
347
+    if (!empty($conf->global->PAYPAL_ALLOW_NOTES))
348 348
     {
349
-    	$nvpstr = $nvpstr . "&ALLOWNOTE=0";
349
+    	$nvpstr = $nvpstr."&ALLOWNOTE=0";
350 350
     }
351 351
     if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS))
352 352
     {
353
-    	$nvpstr = $nvpstr . "&NOSHIPPING=1";	// An empty or not complete shipping address will be accepted
353
+    	$nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted
354 354
     }
355 355
     else
356 356
     {
357
-    	$nvpstr = $nvpstr . "&NOSHIPPING=0";	// A valid shipping address is required (full required fields mandatory)
357
+    	$nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory)
358 358
     }
359
-    $nvpstr = $nvpstr . "&SOLUTIONTYPE=" . urlencode($solutionType);
360
-    $nvpstr = $nvpstr . "&LANDINGPAGE=" . urlencode($landingPage);
361
-    if (! empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER))
359
+    $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType);
360
+    $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage);
361
+    if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER))
362 362
     {
363
-    	$nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER);    // Hotline phone number
363
+    	$nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number
364 364
     }
365 365
 
366 366
     $paypalprefix = 'PAYMENTREQUEST_0_';
367 367
     //$paypalprefix = '';
368
-	if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale';
369
-
370
-	$nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount);									// Total for all elements
371
-
372
-    $nvpstr = $nvpstr . "&".$paypalprefix."INVNUM=" . urlencode($tag);
373
-    $nvpstr = $nvpstr . "&".$paypalprefix."AMT=". urlencode($paymentAmount);                 // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT
374
-    $nvpstr = $nvpstr . "&".$paypalprefix."ITEMAMT=". urlencode($paymentAmount);             // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT
375
-    $nvpstr = $nvpstr . "&".$paypalprefix."PAYMENTACTION=" . urlencode($paymentType);        // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION
376
-    $nvpstr = $nvpstr . "&".$paypalprefix."CURRENCYCODE=" . urlencode($currencyCodeType);    // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE
377
-
378
-    $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1";
379
-    $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount);
380
-    $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc);
381
-    $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0";
382
-
383
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTONAME=" . urlencode($shipToName);            // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME
384
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET=" . urlencode($shipToStreet);        //
385
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET2=" . urlencode($shipToStreet2);
386
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCITY=" . urlencode($shipToCity);
387
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTATE=" . urlencode($shipToState);
388
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode);
389
-    $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip);
390
-    $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum);
391
-    if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email);      // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL
392
-    if (! empty($desc))  $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc);        // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC
393
-
394
-    if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo)
368
+	if (!empty($paypalprefix) && $paymentType == 'Sole') $paymentType = 'Sale';
369
+
370
+	$nvpstr = $nvpstr."&AMT=".urlencode($paymentAmount); // Total for all elements
371
+
372
+    $nvpstr = $nvpstr."&".$paypalprefix."INVNUM=".urlencode($tag);
373
+    $nvpstr = $nvpstr."&".$paypalprefix."AMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT
374
+    $nvpstr = $nvpstr."&".$paypalprefix."ITEMAMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT
375
+    $nvpstr = $nvpstr."&".$paypalprefix."PAYMENTACTION=".urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION
376
+    $nvpstr = $nvpstr."&".$paypalprefix."CURRENCYCODE=".urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE
377
+
378
+    $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1";
379
+    $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount);
380
+    $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc);
381
+    $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0";
382
+
383
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTONAME=".urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME
384
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET=".urlencode($shipToStreet); //
385
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET2=".urlencode($shipToStreet2);
386
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCITY=".urlencode($shipToCity);
387
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTATE=".urlencode($shipToState);
388
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode);
389
+    $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip);
390
+    $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum);
391
+    if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL
392
+    if (!empty($desc))  $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC
393
+
394
+    if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo)
395 395
     {
396 396
     	global $dolibarr_main_url_root;
397 397
 
398 398
 	    // Define $urlwithroot
399
-	    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
400
-	    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
399
+	    $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
400
+	    $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
401 401
 	    //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
402 402
 
403
-	    $urllogo=$urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo);
404
-	    $nvpstr = $nvpstr . "&LOGOIMG=" . urlencode($urllogo);
403
+	    $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo);
404
+	    $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo);
405 405
     }
406
-    if (! empty($conf->global->PAYPAL_BRANDNAME))
406
+    if (!empty($conf->global->PAYPAL_BRANDNAME))
407 407
     {
408
-    	$nvpstr = $nvpstr . "&BRANDNAME=" . urlencode($conf->global->PAYPAL_BRANDNAME);    // BRANDNAME
408
+    	$nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME
409 409
     }
410
-    if (! empty($conf->global->PAYPAL_NOTETOBUYER))
410
+    if (!empty($conf->global->PAYPAL_NOTETOBUYER))
411 411
     {
412
-    	$nvpstr = $nvpstr . "&NOTETOBUYER=" . urlencode($conf->global->PAYPAL_NOTETOBUYER);  // PAYPAL_NOTETOBUYER
412
+    	$nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER
413 413
     }
414 414
 
415 415
 	$_SESSION["FinalPaymentAmt"] = $paymentAmount;
416 416
     $_SESSION["currencyCodeType"] = $currencyCodeType;
417
-    $_SESSION["PaymentType"] = $paymentType;			// 'Mark', 'Sole'
418
-    $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR'];   // Payer ip
417
+    $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole'
418
+    $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip
419 419
 
420 420
     //'---------------------------------------------------------------------------------------------------------------
421 421
     //' Make the API call to PayPal
422 422
     //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
423 423
     //' If an error occured, show the resulting errors
424 424
     //'---------------------------------------------------------------------------------------------------------------
425
-    $resArray=hash_call("SetExpressCheckout", $nvpstr);
425
+    $resArray = hash_call("SetExpressCheckout", $nvpstr);
426 426
     $ack = strtoupper($resArray["ACK"]);
427
-    if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
427
+    if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
428 428
     {
429 429
         $token = urldecode($resArray["TOKEN"]);
430
-        $_SESSION['TOKEN']=$token;
430
+        $_SESSION['TOKEN'] = $token;
431 431
     }
432 432
 
433 433
     return $resArray;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
     //' Build a second API request to PayPal, using the token as the
460 460
     //'  ID to get the details on the payment authorization
461 461
     //'---------------------------------------------------------------------------
462
-    $nvpstr="&TOKEN=" . $token;
462
+    $nvpstr = "&TOKEN=".$token;
463 463
 
464 464
     //'---------------------------------------------------------------------------
465 465
     //' Make the API call and store the results in an array.
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
     //'     an action to complete the payment.
468 468
     //' If failed, show the error
469 469
     //'---------------------------------------------------------------------------
470
-    $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr);
470
+    $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr);
471 471
     $ack = strtoupper($resArray["ACK"]);
472
-    if($ack == "SUCCESS" || $ack=="SUCCESSWITHWARNING")
472
+    if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
473 473
     {
474 474
         $_SESSION['payer_id'] = $resArray['PAYERID'];
475 475
     }
@@ -502,18 +502,18 @@  discard block
 block discarded – undo
502 502
     global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
503 503
 
504 504
     $nvpstr = '';
505
-    $nvpstr .= '&TOKEN=' . urlencode($token);
506
-    $nvpstr .= '&PAYERID=' . urlencode($payerID);
507
-    $nvpstr .= '&PAYMENTACTION=' . urlencode($paymentType);
508
-    $nvpstr .= '&AMT=' . urlencode($FinalPaymentAmt);
509
-    $nvpstr .= '&CURRENCYCODE=' . urlencode($currencyCodeType);
510
-    $nvpstr .= '&IPADDRESS=' . urlencode($ipaddress);
511
-    $nvpstr .= '&INVNUM=' . urlencode($tag);
505
+    $nvpstr .= '&TOKEN='.urlencode($token);
506
+    $nvpstr .= '&PAYERID='.urlencode($payerID);
507
+    $nvpstr .= '&PAYMENTACTION='.urlencode($paymentType);
508
+    $nvpstr .= '&AMT='.urlencode($FinalPaymentAmt);
509
+    $nvpstr .= '&CURRENCYCODE='.urlencode($currencyCodeType);
510
+    $nvpstr .= '&IPADDRESS='.urlencode($ipaddress);
511
+    $nvpstr .= '&INVNUM='.urlencode($tag);
512 512
 
513 513
     /* Make the call to PayPal to finalize payment
514 514
      If an error occured, show the resulting errors
515 515
      */
516
-    $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr);
516
+    $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
517 517
 
518 518
     /* Display the API response back to the browser.
519 519
      If the response from PayPal was a success, display the response parameters'
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
  * @param	string	$nvpStr 		is nvp string.
584 584
  * @return	array					returns an associtive array containing the response from the server.
585 585
  */
586
-function hash_call($methodName,$nvpStr)
586
+function hash_call($methodName, $nvpStr)
587 587
 {
588 588
     //declaring of global variables
589 589
     global $conf, $langs;
@@ -591,8 +591,8 @@  discard block
 block discarded – undo
591 591
     global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
592 592
 
593 593
     // TODO problem with triggers
594
-    $API_version="98.0";
595
-	if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))		// We can force sand box with param 'forcesandbox'
594
+    $API_version = "98.0";
595
+	if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha'))		// We can force sand box with param 'forcesandbox'
596 596
 	{
597 597
 	    $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
598 598
 	    $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 	}
605 605
 
606 606
 	// Clean parameters
607
-	$PAYPAL_API_USER="";
608
-	if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER;
609
-	$PAYPAL_API_PASSWORD="";
610
-	if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD;
611
-	$PAYPAL_API_SIGNATURE="";
612
-	if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE;
613
-	$PAYPAL_API_SANDBOX="";
614
-	if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX;
607
+	$PAYPAL_API_USER = "";
608
+	if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
609
+	$PAYPAL_API_PASSWORD = "";
610
+	if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
611
+	$PAYPAL_API_SIGNATURE = "";
612
+	if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
613
+	$PAYPAL_API_SANDBOX = "";
614
+	if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
615 615
 	// TODO END problem with triggers
616 616
 
617 617
     dol_syslog("Paypal API endpoint ".$API_Endpoint);
@@ -626,30 +626,30 @@  discard block
 block discarded – undo
626 626
     curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
627 627
     curl_setopt($ch, CURLOPT_VERBOSE, 1);
628 628
     // TLSv1 by default or change to TLSv1.2 in module configuration
629
-    curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION)?1:$conf->global->PAYPAL_SSLVERSION));
629
+    curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION) ? 1 : $conf->global->PAYPAL_SSLVERSION));
630 630
 
631 631
     //turning off the server and peer verification(TrustManager Concept).
632 632
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
633 633
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
634 634
 
635
-    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT);
636
-    curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT);
635
+    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT);
636
+    curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT);
637 637
 
638
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
638
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
639 639
     curl_setopt($ch, CURLOPT_POST, 1);
640 640
 
641 641
     //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled.
642 642
     if ($USE_PROXY)
643 643
     {
644
-        dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);
644
+        dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS);
645 645
         //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
646
-        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
647
-        if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
646
+        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT);
647
+        if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS);
648 648
     }
649 649
 
650 650
     //NVPRequest for submitting to server
651
-    $nvpreq ="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($API_version) . "&PWD=" . urlencode($PAYPAL_API_PASSWORD) . "&USER=" . urlencode($PAYPAL_API_USER) . "&SIGNATURE=" . urlencode($PAYPAL_API_SIGNATURE) . $nvpStr;
652
-    $nvpreq.="&LOCALECODE=".strtoupper($langs->getDefaultLang(1));
651
+    $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($API_version)."&PWD=".urlencode($PAYPAL_API_PASSWORD)."&USER=".urlencode($PAYPAL_API_USER)."&SIGNATURE=".urlencode($PAYPAL_API_SIGNATURE).$nvpStr;
652
+    $nvpreq .= "&LOCALECODE=".strtoupper($langs->getDefaultLang(1));
653 653
     //$nvpreq.="&BRANDNAME=".urlencode();       // Override merchant name
654 654
     //$nvpreq.="&NOTIFYURL=".urlencode();       // For Instant Payment Notification url
655 655
 
@@ -662,18 +662,18 @@  discard block
 block discarded – undo
662 662
     //getting response from server
663 663
     $response = curl_exec($ch);
664 664
 
665
-    $nvpReqArray=deformatNVP($nvpreq);
666
-    $_SESSION['nvpReqArray']=$nvpReqArray;
665
+    $nvpReqArray = deformatNVP($nvpreq);
666
+    $_SESSION['nvpReqArray'] = $nvpReqArray;
667 667
 
668 668
     //convrting NVPResponse to an Associative Array
669 669
     dol_syslog("Paypal API hash_call Response nvpresp=".$response);
670
-    $nvpResArray=deformatNVP($response);
670
+    $nvpResArray = deformatNVP($response);
671 671
 
672 672
     if (curl_errno($ch))
673 673
     {
674 674
         // moving to display page to display curl errors
675
-        $_SESSION['curl_error_no']=curl_errno($ch);
676
-        $_SESSION['curl_error_msg']=curl_error($ch);
675
+        $_SESSION['curl_error_no'] = curl_errno($ch);
676
+        $_SESSION['curl_error_msg'] = curl_error($ch);
677 677
 
678 678
         //Execute the Error handling module to display errors.
679 679
     }
@@ -696,22 +696,22 @@  discard block
 block discarded – undo
696 696
  */
697 697
 function deformatNVP($nvpstr)
698 698
 {
699
-    $intial=0;
699
+    $intial = 0;
700 700
     $nvpArray = array();
701 701
 
702
-    while(strlen($nvpstr))
702
+    while (strlen($nvpstr))
703 703
     {
704 704
         //postion of Key
705
-        $keypos= strpos($nvpstr,'=');
705
+        $keypos = strpos($nvpstr, '=');
706 706
         //position of value
707
-        $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);
707
+        $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr);
708 708
 
709 709
         /*getting the Key and Value values and storing in a Associative Array*/
710
-        $keyval=substr($nvpstr,$intial,$keypos);
711
-        $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
710
+        $keyval = substr($nvpstr, $intial, $keypos);
711
+        $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1);
712 712
         //decoding the respose
713
-        $nvpArray[urldecode($keyval)] =urldecode($valval);
714
-        $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
713
+        $nvpArray[urldecode($keyval)] = urldecode($valval);
714
+        $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr));
715 715
     }
716 716
     return $nvpArray;
717 717
 }
@@ -723,16 +723,16 @@  discard block
 block discarded – undo
723 723
  */
724 724
 function getApiError()
725 725
 {
726
-	$errors=array();
726
+	$errors = array();
727 727
 
728
-	$resArray=$_SESSION['reshash'];
728
+	$resArray = $_SESSION['reshash'];
729 729
 
730
-	if(isset($_SESSION['curl_error_no']))
730
+	if (isset($_SESSION['curl_error_no']))
731 731
 	{
732 732
 		$errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg'];
733 733
 	}
734 734
 
735
-	foreach($resArray as $key => $value)
735
+	foreach ($resArray as $key => $value)
736 736
 	{
737 737
 		$errors[] = $key.'-'.$value;
738 738
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/dav/dav.class.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param	int|boolean	$ouri			Ouri
57 57
 	 * @return string
58 58
 	 */
59
-	public function getSqlCalEvents($calid, $oid=false, $ouri=false)
59
+	public function getSqlCalEvents($calid, $oid = false, $ouri = false)
60 60
 	{
61 61
 		// TODO : replace GROUP_CONCAT by
62 62
 		$sql = 'SELECT
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
 						LEFT OUTER JOIN '.MAIN_DB_PREFIX.'user AS u ON (u.rowid=fk_element)
83 83
 						WHERE ar.element_type=\'user\' AND fk_actioncomm=a.id) AS other_users
84 84
 				FROM '.MAIN_DB_PREFIX.'actioncomm AS a';
85
-		if (! $this->user->rights->societe->client->voir )//FIXME si 'voir' on voit plus de chose ?
85
+		if (!$this->user->rights->societe->client->voir)//FIXME si 'voir' on voit plus de chose ?
86 86
 		{
87
-			$sql.=' LEFT OUTER JOIN '.MAIN_DB_PREFIX.'societe_commerciaux AS sc ON (a.fk_soc = sc.fk_soc AND sc.fk_user='.$this->user->id.')
87
+			$sql .= ' LEFT OUTER JOIN '.MAIN_DB_PREFIX.'societe_commerciaux AS sc ON (a.fk_soc = sc.fk_soc AND sc.fk_user='.$this->user->id.')
88 88
 					LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON (s.rowid = sc.fk_soc)
89 89
 					LEFT JOIN '.MAIN_DB_PREFIX.'socpeople AS sp ON (sp.fk_soc = sc.fk_soc AND sp.rowid = a.fk_contact)
90 90
 					LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
91 91
 		}
92 92
 		else
93 93
 		{
94
-			$sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON (s.rowid = a.fk_soc)
94
+			$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON (s.rowid = a.fk_soc)
95 95
 					LEFT JOIN '.MAIN_DB_PREFIX.'socpeople AS sp ON (sp.rowid = a.fk_contact)
96 96
 					LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
97 97
 		}
98 98
 
99
-		$sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON co.rowid = sp.fk_pays
99
+		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON co.rowid = sp.fk_pays
100 100
 				LEFT JOIN '.MAIN_DB_PREFIX.'c_country as cos ON cos.rowid = s.fk_pays
101 101
 				WHERE 	a.id IN (SELECT ar.fk_actioncomm FROM '.MAIN_DB_PREFIX.'actioncomm_resources ar WHERE ar.element_type=\'user\' AND ar.fk_element='.intval($calid).')
102 102
 						AND a.code IN (SELECT cac.code FROM '.MAIN_DB_PREFIX.'c_actioncomm cac WHERE cac.type<>\'systemauto\')
103 103
 						AND a.entity IN ('.getEntity('societe', 1).')';
104
-		if($oid!==false) {
105
-			if($ouri===false)
104
+		if ($oid !== false) {
105
+			if ($ouri === false)
106 106
 			{
107
-				$sql.=' AND a.id = '.intval($oid);
107
+				$sql .= ' AND a.id = '.intval($oid);
108 108
 			}
109 109
 			else
110 110
 			{
111
-				$sql.=' AND (a.id = '.intval($oid).' OR ac.uuidext = \''.$this->db->escape($ouri).'\')';
111
+				$sql .= ' AND (a.id = '.intval($oid).' OR ac.uuidext = \''.$this->db->escape($ouri).'\')';
112 112
 			}
113 113
 		}
114 114
 
@@ -131,116 +131,116 @@  discard block
 block discarded – undo
131 131
 			$categ[] = $this->langs->transnoentitiesnoconv('Customer');
132 132
 		}*/
133 133
 
134
-		$location=$obj->location;
134
+		$location = $obj->location;
135 135
 
136 136
 		// contact address
137
-		if(empty($location) && !empty($obj->address))
137
+		if (empty($location) && !empty($obj->address))
138 138
 		{
139
-			$location = trim(str_replace(array("\r","\t","\n"),' ', $obj->address));
139
+			$location = trim(str_replace(array("\r", "\t", "\n"), ' ', $obj->address));
140 140
 			$location = trim($location.', '.$obj->zip);
141 141
 			$location = trim($location.' '.$obj->town);
142 142
 			$location = trim($location.', '.$obj->country_label);
143 143
 		}
144 144
 
145 145
 		// contact address
146
-		if(empty($location) && !empty($obj->soc_address))
146
+		if (empty($location) && !empty($obj->soc_address))
147 147
 		{
148
-			$location = trim(str_replace(array("\r","\t","\n"),' ', $obj->soc_address));
148
+			$location = trim(str_replace(array("\r", "\t", "\n"), ' ', $obj->soc_address));
149 149
 			$location = trim($location.', '.$obj->soc_zip);
150 150
 			$location = trim($location.' '.$obj->soc_town);
151 151
 			$location = trim($location.', '.$obj->soc_country_label);
152 152
 		}
153 153
 
154
-		$address=explode("\n",$obj->address,2);
155
-		foreach($address as $kAddr => $vAddr)
154
+		$address = explode("\n", $obj->address, 2);
155
+		foreach ($address as $kAddr => $vAddr)
156 156
 		{
157
-			$address[$kAddr] = trim(str_replace(array("\r","\t"),' ', str_replace("\n",' | ', trim($vAddr))));
157
+			$address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr))));
158 158
 		}
159
-		$address[]='';
160
-		$address[]='';
159
+		$address[] = '';
160
+		$address[] = '';
161 161
 
162
-		if($obj->percent==-1 && trim($obj->datep)!='')
163
-			$type='VEVENT';
162
+		if ($obj->percent == -1 && trim($obj->datep) != '')
163
+			$type = 'VEVENT';
164 164
 		else
165
-			$type='VTODO';
165
+			$type = 'VTODO';
166 166
 
167 167
 		$timezone = date_default_timezone_get();
168 168
 
169
-		$caldata ="BEGIN:VCALENDAR\n";
170
-		$caldata.="VERSION:2.0\n";
171
-		$caldata.="METHOD:PUBLISH\n";
172
-		$caldata.="PRODID:-//Dolibarr CDav//FR\n";
173
-		$caldata.="BEGIN:".$type."\n";
174
-		$caldata.="CREATED:".gmdate('Ymd\THis', strtotime($obj->datec))."Z\n";
175
-		$caldata.="LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
176
-		$caldata.="DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
177
-		if($obj->sourceuid=='')
178
-			$caldata.="UID:".$obj->id.'-ev-'.$calid.'-cal-'.CDAV_URI_KEY."\n";
169
+		$caldata = "BEGIN:VCALENDAR\n";
170
+		$caldata .= "VERSION:2.0\n";
171
+		$caldata .= "METHOD:PUBLISH\n";
172
+		$caldata .= "PRODID:-//Dolibarr CDav//FR\n";
173
+		$caldata .= "BEGIN:".$type."\n";
174
+		$caldata .= "CREATED:".gmdate('Ymd\THis', strtotime($obj->datec))."Z\n";
175
+		$caldata .= "LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
176
+		$caldata .= "DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
177
+		if ($obj->sourceuid == '')
178
+			$caldata .= "UID:".$obj->id.'-ev-'.$calid.'-cal-'.CDAV_URI_KEY."\n";
179 179
 		else
180
-			$caldata.="UID:".$obj->sourceuid."\n";
181
-		$caldata.="SUMMARY:".$obj->label."\n";
182
-		$caldata.="LOCATION:".$location."\n";
183
-		$caldata.="PRIORITY:".$obj->priority."\n";
184
-		if($obj->fulldayevent)
180
+			$caldata .= "UID:".$obj->sourceuid."\n";
181
+		$caldata .= "SUMMARY:".$obj->label."\n";
182
+		$caldata .= "LOCATION:".$location."\n";
183
+		$caldata .= "PRIORITY:".$obj->priority."\n";
184
+		if ($obj->fulldayevent)
185 185
 		{
186
-			$caldata.="DTSTART;VALUE=DATE:".date('Ymd', strtotime($obj->datep))."\n";
187
-			if($type=='VEVENT')
186
+			$caldata .= "DTSTART;VALUE=DATE:".date('Ymd', strtotime($obj->datep))."\n";
187
+			if ($type == 'VEVENT')
188 188
 			{
189
-				if(trim($obj->datep2)!='')
190
-					$caldata.="DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep2)+1)."\n";
189
+				if (trim($obj->datep2) != '')
190
+					$caldata .= "DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep2) + 1)."\n";
191 191
 				else
192
-					$caldata.="DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep)+(25*3600))."\n";
192
+					$caldata .= "DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep) + (25 * 3600))."\n";
193 193
 			}
194
-			elseif(trim($obj->datep2)!='')
195
-				$caldata.="DUE;VALUE=DATE:".date('Ymd', strtotime($obj->datep2)+1)."\n";
194
+			elseif (trim($obj->datep2) != '')
195
+				$caldata .= "DUE;VALUE=DATE:".date('Ymd', strtotime($obj->datep2) + 1)."\n";
196 196
 		}
197 197
 		else
198 198
 		{
199
-			$caldata.="DTSTART;TZID=".$timezone.":".strtr($obj->datep,array(" "=>"T", ":"=>"", "-"=>""))."\n";
200
-			if($type=='VEVENT')
199
+			$caldata .= "DTSTART;TZID=".$timezone.":".strtr($obj->datep, array(" "=>"T", ":"=>"", "-"=>""))."\n";
200
+			if ($type == 'VEVENT')
201 201
 			{
202
-				if(trim($obj->datep2)!='')
203
-					$caldata.="DTEND;TZID=".$timezone.":".strtr($obj->datep2,array(" "=>"T", ":"=>"", "-"=>""))."\n";
202
+				if (trim($obj->datep2) != '')
203
+					$caldata .= "DTEND;TZID=".$timezone.":".strtr($obj->datep2, array(" "=>"T", ":"=>"", "-"=>""))."\n";
204 204
 				else
205
-					$caldata.="DTEND;TZID=".$timezone.":".strtr($obj->datep,array(" "=>"T", ":"=>"", "-"=>""))."\n";
205
+					$caldata .= "DTEND;TZID=".$timezone.":".strtr($obj->datep, array(" "=>"T", ":"=>"", "-"=>""))."\n";
206 206
 			}
207
-			elseif(trim($obj->datep2)!='')
208
-				$caldata.="DUE;TZID=".$timezone.":".strtr($obj->datep2,array(" "=>"T", ":"=>"", "-"=>""))."\n";
207
+			elseif (trim($obj->datep2) != '')
208
+				$caldata .= "DUE;TZID=".$timezone.":".strtr($obj->datep2, array(" "=>"T", ":"=>"", "-"=>""))."\n";
209 209
 		}
210
-		$caldata.="CLASS:PUBLIC\n";
211
-		if($obj->transparency==1)
212
-			$caldata.="TRANSP:TRANSPARENT\n";
210
+		$caldata .= "CLASS:PUBLIC\n";
211
+		if ($obj->transparency == 1)
212
+			$caldata .= "TRANSP:TRANSPARENT\n";
213 213
 		else
214
-			$caldata.="TRANSP:OPAQUE\n";
214
+			$caldata .= "TRANSP:OPAQUE\n";
215 215
 
216
-		if($type=='VEVENT')
217
-			$caldata.="STATUS:CONFIRMED\n";
218
-		elseif($obj->percent==0)
219
-			$caldata.="STATUS:NEEDS-ACTION\n";
220
-		elseif($obj->percent==100)
221
-			$caldata.="STATUS:COMPLETED\n";
216
+		if ($type == 'VEVENT')
217
+			$caldata .= "STATUS:CONFIRMED\n";
218
+		elseif ($obj->percent == 0)
219
+			$caldata .= "STATUS:NEEDS-ACTION\n";
220
+		elseif ($obj->percent == 100)
221
+			$caldata .= "STATUS:COMPLETED\n";
222 222
 		else
223 223
 		{
224
-			$caldata.="STATUS:IN-PROCESS\n";
225
-			$caldata.="PERCENT-COMPLETE:".$obj->percent."\n";
224
+			$caldata .= "STATUS:IN-PROCESS\n";
225
+			$caldata .= "PERCENT-COMPLETE:".$obj->percent."\n";
226 226
 		}
227 227
 
228
-		$caldata.="DESCRIPTION:";
229
-		$caldata.=strtr($obj->note, array("\n"=>"\\n", "\r"=>""));
230
-		if(!empty($obj->soc_nom))
231
-			$caldata.="\\n*DOLIBARR-SOC: ".$obj->soc_nom;
232
-		if(!empty($obj->soc_phone))
233
-			$caldata.="\\n*DOLIBARR-SOC-TEL: ".$obj->soc_phone;
234
-		if(!empty($obj->firstname) || !empty($obj->lastname))
235
-			$caldata.="\\n*DOLIBARR-CTC: ".trim($obj->firstname.' '.$obj->lastname);
236
-		if(!empty($obj->phone) || !empty($obj->phone_perso) || !empty($obj->phone_mobile))
237
-			$caldata.="\\n*DOLIBARR-CTC-TEL: ".trim($obj->phone.' '.$obj->phone_perso.' '.$obj->phone_mobile);
238
-		if(strpos($obj->other_users,',')) // several
239
-			$caldata.="\\n*DOLIBARR-USR: ".$obj->other_users;
240
-		$caldata.="\n";
228
+		$caldata .= "DESCRIPTION:";
229
+		$caldata .= strtr($obj->note, array("\n"=>"\\n", "\r"=>""));
230
+		if (!empty($obj->soc_nom))
231
+			$caldata .= "\\n*DOLIBARR-SOC: ".$obj->soc_nom;
232
+		if (!empty($obj->soc_phone))
233
+			$caldata .= "\\n*DOLIBARR-SOC-TEL: ".$obj->soc_phone;
234
+		if (!empty($obj->firstname) || !empty($obj->lastname))
235
+			$caldata .= "\\n*DOLIBARR-CTC: ".trim($obj->firstname.' '.$obj->lastname);
236
+		if (!empty($obj->phone) || !empty($obj->phone_perso) || !empty($obj->phone_mobile))
237
+			$caldata .= "\\n*DOLIBARR-CTC-TEL: ".trim($obj->phone.' '.$obj->phone_perso.' '.$obj->phone_mobile);
238
+		if (strpos($obj->other_users, ',')) // several
239
+			$caldata .= "\\n*DOLIBARR-USR: ".$obj->other_users;
240
+		$caldata .= "\n";
241 241
 
242
-		$caldata.="END:".$type."\n";
243
-		$caldata.="END:VCALENDAR\n";
242
+		$caldata .= "END:".$type."\n";
243
+		$caldata .= "END:VCALENDAR\n";
244 244
 
245 245
 		return $caldata;
246 246
 	}
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public function getFullCalendarObjects($calendarId, $bCalendarData)
256 256
 	{
257
-		$calid = ($calendarId*1);
257
+		$calid = ($calendarId * 1);
258 258
 		$calevents = array();
259 259
 
260
-		if(! $this->user->rights->agenda->myactions->read)
260
+		if (!$this->user->rights->agenda->myactions->read)
261 261
 			return $calevents;
262 262
 
263
-		if($calid!=$this->user->id && (!isset($this->user->rights->agenda->allactions->read) || !$this->user->rights->agenda->allactions->read))
263
+		if ($calid != $this->user->id && (!isset($this->user->rights->agenda->allactions->read) || !$this->user->rights->agenda->allactions->read))
264 264
 			return $calevents;
265 265
 
266 266
 		$sql = $this->getSqlCalEvents($calid);
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			{
274 274
 				$calendardata = $this->toVCalendar($calid, $obj);
275 275
 
276
-				if($bCalendarData)
276
+				if ($bCalendarData)
277 277
 				{
278 278
 					$calevents[] = array(
279 279
 						'calendardata' => $calendardata,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 						'etag' => '"'.md5($calendardata).'"',
283 283
 						'calendarid'   => $calendarId,
284 284
 						'size' => strlen($calendardata),
285
-						'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo',
285
+						'component' => strpos($calendardata, 'BEGIN:VEVENT') > 0 ? 'vevent' : 'vtodo',
286 286
 					);
287 287
 				}
288 288
 				else
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 						'etag' => '"'.md5($calendardata).'"',
295 295
 						'calendarid'   => $calendarId,
296 296
 						'size' => strlen($calendardata),
297
-						'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo',
297
+						'component' => strpos($calendardata, 'BEGIN:VEVENT') > 0 ? 'vevent' : 'vtodo',
298 298
 					);
299 299
 				}
300 300
 			}
Please login to merge, or discard this patch.
dolibarr/htdocs/dav/dav.lib.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
  */
23 23
 
24 24
 // define CDAV_CONTACT_TAG if not
25
-if(!defined('CDAV_CONTACT_TAG'))
25
+if (!defined('CDAV_CONTACT_TAG'))
26 26
 {
27
-	if(isset($conf->global->CDAV_CONTACT_TAG))
27
+	if (isset($conf->global->CDAV_CONTACT_TAG))
28 28
 		define('CDAV_CONTACT_TAG', $conf->global->CDAV_CONTACT_TAG);
29 29
 		else
30 30
 			define('CDAV_CONTACT_TAG', '');
31 31
 }
32 32
 
33 33
 // define CDAV_URI_KEY if not
34
-if(!defined('CDAV_URI_KEY'))
34
+if (!defined('CDAV_URI_KEY'))
35 35
 {
36
-	if(isset($conf->global->CDAV_URI_KEY))
36
+	if (isset($conf->global->CDAV_URI_KEY))
37 37
 		define('CDAV_URI_KEY', $conf->global->CDAV_URI_KEY);
38 38
 		else
39
-			define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']),0,8));
39
+			define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']), 0, 8));
40 40
 }
41 41
 
42 42
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	// Entries must be declared in modules descriptor with line
64 64
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
65 65
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
66
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav');
66
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'admindav');
67 67
 
68
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav','remove');
68
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'admindav', 'remove');
69 69
 
70 70
 	return $head;
71 71
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/dav/fileserver.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  *      \brief      Server DAV
22 22
  */
23 23
 
24
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
25
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1'); // If there is no menu to show
26
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
27
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
28
-if (! defined('NOLOGIN'))  		 define("NOLOGIN",1);		// This means this output page does not require to be logged.
29
-if (! defined('NOCSRFCHECK'))  	 define("NOCSRFCHECK",1);	// We accept to go on this page from external web site.
24
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
25
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1'); // If there is no menu to show
26
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
27
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
28
+if (!defined('NOLOGIN'))  		 define("NOLOGIN", 1); // This means this output page does not require to be logged.
29
+if (!defined('NOCSRFCHECK'))  	 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
30 30
 
31 31
 require "../main.inc.php";
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 $user = new User($db);
40
-if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
40
+if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] != '')
41 41
 {
42
-	$user->fetch('',$_SERVER['PHP_AUTH_USER']);
42
+	$user->fetch('', $_SERVER['PHP_AUTH_USER']);
43 43
 	$user->getrights();
44 44
 }
45 45
 
46 46
 // Load translation files required by the page
47
-$langs->loadLangs(array("main","other"));
47
+$langs->loadLangs(array("main", "other"));
48 48
 
49 49
 
50
-if(empty($conf->dav->enabled))
50
+if (empty($conf->dav->enabled))
51 51
 	accessforbidden();
52 52
 
53 53
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 //var_dump($tmpDir);exit;
59 59
 
60 60
 // Authentication callback function
61
-$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) {
61
+$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($username, $password) {
62 62
 	global $user;
63 63
 	global $conf;
64 64
 	global $dolibarr_main_authentication;
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Authentication mode
74 74
 	if (empty($dolibarr_main_authentication))
75
-		$dolibarr_main_authentication='http,dolibarr';
76
-	$authmode = explode(',',$dolibarr_main_authentication);
77
-	$entity = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
75
+		$dolibarr_main_authentication = 'http,dolibarr';
76
+	$authmode = explode(',', $dolibarr_main_authentication);
77
+	$entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1));
78 78
 
79
-	if (checkLoginPassEntity($username,$password,$entity,$authmode) != $username)
79
+	if (checkLoginPassEntity($username, $password, $entity, $authmode) != $username)
80 80
 		return false;
81 81
 
82 82
 	return true;
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 // Public dir
101 101
 if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
102 102
 {
103
-	$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/public');
103
+	$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root.'/dav/public');
104 104
 }
105 105
 // Private dir
106
-$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/private');
106
+$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root.'/dav/private');
107 107
 // ECM dir
108
-if (! empty($conf->ecm->enabled) && ! empty($conf->global->DAV_ALLOW_ECM_DIR))
108
+if (!empty($conf->ecm->enabled) && !empty($conf->global->DAV_ALLOW_ECM_DIR))
109 109
 {
110
-	$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/ecm');
110
+	$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root.'/ecm');
111 111
 }
112 112
 
113 113
 
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 
136 136
 // Add authentication function
137 137
 if ((empty($conf->global->DAV_ALLOW_PUBLIC_DIR)
138
-	|| ! preg_match('/'.preg_quote(DOL_URL_ROOT.'/dav/fileserver.php/public','/').'/', $_SERVER["PHP_SELF"]))
139
-	&& ! preg_match('/^sabreAction=asset&assetName=[a-zA-Z0-9%\-\/]+\.(png|css|woff|ico|ttf)$/', $_SERVER["QUERY_STRING"])	// URL for Sabre browser resources
138
+	|| !preg_match('/'.preg_quote(DOL_URL_ROOT.'/dav/fileserver.php/public', '/').'/', $_SERVER["PHP_SELF"]))
139
+	&& !preg_match('/^sabreAction=asset&assetName=[a-zA-Z0-9%\-\/]+\.(png|css|woff|ico|ttf)$/', $_SERVER["QUERY_STRING"])	// URL for Sabre browser resources
140 140
 	)
141 141
 {
142 142
 	//var_dump($_SERVER["QUERY_STRING"]);exit;
143 143
 	$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
144 144
 }
145 145
 // Support for LOCK and UNLOCK
146
-$lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir . '/.locksdb');
146
+$lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir.'/.locksdb');
147 147
 $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend);
148 148
 $server->addPlugin($lockPlugin);
149 149
 
Please login to merge, or discard this patch.
dolibarr/htdocs/exports/class/export.class.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public $db;
37 37
 
38
-	var $array_export_code=array();             // Tableau de "idmodule_numlot"
39
-	var $array_export_module=array();           // Tableau de "nom de modules"
40
-	var $array_export_label=array();            // Tableau de "libelle de lots"
41
-	var $array_export_sql_start=array();        // Tableau des "requetes sql"
42
-	var $array_export_sql_end=array();          // Tableau des "requetes sql"
43
-	var $array_export_sql_order=array();        // Tableau des "requetes sql"
44
-
45
-	var $array_export_fields=array();           // Tableau des listes de champ+libelle a exporter
46
-	var $array_export_TypeFields=array();		// Tableau des listes de champ+Type de filtre
47
-	var $array_export_FilterValue=array();		// Tableau des listes de champ+Valeur a filtrer
48
-	var $array_export_entities=array();         // Tableau des listes de champ+alias a exporter
49
-	var $array_export_dependencies=array();     // array of list of entities that must take care of the DISTINCT if a field is added into export
50
-	var $array_export_special=array();          // Tableau des operations speciales sur champ
51
-    var $array_export_examplevalues=array();    // array with examples
38
+	var $array_export_code = array(); // Tableau de "idmodule_numlot"
39
+	var $array_export_module = array(); // Tableau de "nom de modules"
40
+	var $array_export_label = array(); // Tableau de "libelle de lots"
41
+	var $array_export_sql_start = array(); // Tableau des "requetes sql"
42
+	var $array_export_sql_end = array(); // Tableau des "requetes sql"
43
+	var $array_export_sql_order = array(); // Tableau des "requetes sql"
44
+
45
+	var $array_export_fields = array(); // Tableau des listes de champ+libelle a exporter
46
+	var $array_export_TypeFields = array(); // Tableau des listes de champ+Type de filtre
47
+	var $array_export_FilterValue = array(); // Tableau des listes de champ+Valeur a filtrer
48
+	var $array_export_entities = array(); // Tableau des listes de champ+alias a exporter
49
+	var $array_export_dependencies = array(); // array of list of entities that must take care of the DISTINCT if a field is added into export
50
+	var $array_export_special = array(); // Tableau des operations speciales sur champ
51
+    var $array_export_examplevalues = array(); // array with examples
52 52
 
53 53
 	// To store export modules
54 54
 	var $hexa;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	function __construct($db)
68 68
 	{
69
-		$this->db=$db;
69
+		$this->db = $db;
70 70
 	}
71 71
 
72 72
 
@@ -78,38 +78,38 @@  discard block
 block discarded – undo
78 78
 	 *    @param  	string		$filter    	Load a particular dataset only
79 79
 	 *    @return	int						<0 if KO, >0 if OK
80 80
 	 */
81
-	function load_arrays($user,$filter='')
81
+	function load_arrays($user, $filter = '')
82 82
 	{
83 83
         // phpcs:enable
84
-		global $langs,$conf,$mysoc;
84
+		global $langs, $conf, $mysoc;
85 85
 
86 86
 		dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter);
87 87
 
88
-        $i=0;
88
+        $i = 0;
89 89
 
90 90
         // Define list of modules directories into modulesdir
91 91
         require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
92 92
 
93 93
         $modulesdir = dolGetModulesDirs();
94 94
 
95
-		foreach($modulesdir as $dir)
95
+		foreach ($modulesdir as $dir)
96 96
 		{
97 97
 			// Search available exports
98
-			$handle=@opendir(dol_osencode($dir));
98
+			$handle = @opendir(dol_osencode($dir));
99 99
 			if (is_resource($handle))
100 100
 			{
101 101
                 // Search module files
102
-			    while (($file = readdir($handle))!==false)
102
+			    while (($file = readdir($handle)) !== false)
103 103
 				{
104
-					if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i",$file,$reg))
104
+					if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg))
105 105
 					{
106
-						$modulename=$reg[1];
106
+						$modulename = $reg[1];
107 107
 
108 108
 						// Defined if module is enabled
109
-						$enabled=true;
110
-						$part=strtolower(preg_replace('/^mod/i','',$modulename));
111
-						if ($part == 'propale') $part='propal';
112
-						if (empty($conf->$part->enabled)) $enabled=false;
109
+						$enabled = true;
110
+						$part = strtolower(preg_replace('/^mod/i', '', $modulename));
111
+						if ($part == 'propale') $part = 'propal';
112
+						if (empty($conf->$part->enabled)) $enabled = false;
113 113
 
114 114
 						if ($enabled)
115 115
 						{
@@ -121,32 +121,32 @@  discard block
 block discarded – undo
121 121
 
122 122
 							if (isset($module->export_code) && is_array($module->export_code))
123 123
 							{
124
-							    foreach($module->export_code as $r => $value)
124
+							    foreach ($module->export_code as $r => $value)
125 125
 								{
126 126
                                     //print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).'<br>';
127 127
 								    if ($filter && ($filter != $module->export_code[$r])) continue;
128 128
 
129 129
                                     // Test if condition to show are ok
130
-                                    if (! empty($module->export_enabled[$r]) && ! verifCond($module->export_enabled[$r])) continue;
130
+                                    if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) continue;
131 131
 
132 132
                                     // Test if permissions are ok
133
-									$bool=true;
133
+									$bool = true;
134 134
 									if (isset($module->export_permission))
135 135
 									{
136
-										foreach($module->export_permission[$r] as $val)
136
+										foreach ($module->export_permission[$r] as $val)
137 137
 										{
138
-	    									$perm=$val;
138
+	    									$perm = $val;
139 139
 	    									//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
140
-	    									if (! empty($perm[2]))
140
+	    									if (!empty($perm[2]))
141 141
 	    									{
142
-	    										$bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
142
+	    										$bool = $user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
143 143
 	    									}
144 144
 	    									else
145 145
 	    									{
146
-	    										$bool=$user->rights->{$perm[0]}->{$perm[1]};
146
+	    										$bool = $user->rights->{$perm[0]}->{$perm[1]};
147 147
 	    									}
148
-	    									if ($perm[0]=='user' && $user->admin) $bool=true;
149
-	    									if (! $bool) break;
148
+	    									if ($perm[0] == 'user' && $user->admin) $bool = true;
149
+	    									if (!$bool) break;
150 150
 										}
151 151
 									}
152 152
 									//print $bool." $perm[0]"."<br>";
@@ -155,45 +155,45 @@  discard block
 block discarded – undo
155 155
 									//	          if ($bool)
156 156
 									//	          {
157 157
 									// Charge fichier lang en rapport
158
-									$langtoload=$module->getLangFilesArray();
158
+									$langtoload = $module->getLangFilesArray();
159 159
 									if (is_array($langtoload))
160 160
 									{
161
-										foreach($langtoload as $key)
161
+										foreach ($langtoload as $key)
162 162
 										{
163 163
 											$langs->load($key);
164 164
 										}
165 165
 									}
166 166
 
167 167
 									// Module
168
-									$this->array_export_module[$i]=$module;
168
+									$this->array_export_module[$i] = $module;
169 169
 									// Permission
170
-									$this->array_export_perms[$i]=$bool;
170
+									$this->array_export_perms[$i] = $bool;
171 171
 									// Icon
172
-									$this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
172
+									$this->array_export_icon[$i] = (isset($module->export_icon[$r]) ? $module->export_icon[$r] : $module->picto);
173 173
 									// Code du dataset export
174
-									$this->array_export_code[$i]=$module->export_code[$r];
174
+									$this->array_export_code[$i] = $module->export_code[$r];
175 175
 									// Libelle du dataset export
176
-									$this->array_export_label[$i]=$module->getExportDatasetLabel($r);
176
+									$this->array_export_label[$i] = $module->getExportDatasetLabel($r);
177 177
 									// Tableau des champ a exporter (cle=champ, valeur=libelle)
178
-									$this->array_export_fields[$i]=$module->export_fields_array[$r];
178
+									$this->array_export_fields[$i] = $module->export_fields_array[$r];
179 179
 									// Tableau des champs a filtrer (cle=champ, valeur1=type de donnees) on verifie que le module a des filtres
180
-									$this->array_export_TypeFields[$i]=(isset($module->export_TypeFields_array[$r])?$module->export_TypeFields_array[$r]:'');
180
+									$this->array_export_TypeFields[$i] = (isset($module->export_TypeFields_array[$r]) ? $module->export_TypeFields_array[$r] : '');
181 181
 									// Tableau des entites a exporter (cle=champ, valeur=entite)
182
-									$this->array_export_entities[$i]=$module->export_entities_array[$r];
182
+									$this->array_export_entities[$i] = $module->export_entities_array[$r];
183 183
 									// Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records)
184
-									$this->array_export_dependencies[$i]=(! empty($module->export_dependencies_array[$r])?$module->export_dependencies_array[$r]:'');
184
+									$this->array_export_dependencies[$i] = (!empty($module->export_dependencies_array[$r]) ? $module->export_dependencies_array[$r] : '');
185 185
 									// Tableau des operations speciales sur champ
186
-									$this->array_export_special[$i]=(! empty($module->export_special_array[$r])?$module->export_special_array[$r]:'');
186
+									$this->array_export_special[$i] = (!empty($module->export_special_array[$r]) ? $module->export_special_array[$r] : '');
187 187
             						// Array of examples
188
-            						$this->array_export_examplevalues[$i]=$module->export_examplevalues_array[$r];
188
+            						$this->array_export_examplevalues[$i] = $module->export_examplevalues_array[$r];
189 189
 
190 190
 									// Requete sql du dataset
191
-									$this->array_export_sql_start[$i]=$module->export_sql_start[$r];
192
-									$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
193
-									$this->array_export_sql_order[$i]=$module->export_sql_order[$r];
191
+									$this->array_export_sql_start[$i] = $module->export_sql_start[$r];
192
+									$this->array_export_sql_end[$i] = $module->export_sql_end[$r];
193
+									$this->array_export_sql_order[$i] = $module->export_sql_order[$r];
194 194
 									//$this->array_export_sql[$i]=$module->export_sql[$r];
195 195
 
196
-									dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".(! empty($module->export_fields_code[$r])?count($module->export_fields_code[$r]):''));
196
+									dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".(!empty($module->export_fields_code[$r]) ?count($module->export_fields_code[$r]) : ''));
197 197
 									$i++;
198 198
 									//	          }
199 199
 								}
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
 	{
224 224
         // phpcs:enable
225 225
 		// Build the sql request
226
-		$sql=$this->array_export_sql_start[$indice];
227
-		$i=0;
226
+		$sql = $this->array_export_sql_start[$indice];
227
+		$i = 0;
228 228
 
229 229
 		//print_r($array_selected);
230 230
 		foreach ($this->array_export_fields[$indice] as $key => $value)
231 231
 		{
232
-			if (! array_key_exists($key, $array_selected)) continue;		// Field not selected
233
-            if (preg_match('/^none\./', $key)) continue;                    // A field that must not appears into SQL
234
-			if ($i > 0) $sql.=', ';
232
+			if (!array_key_exists($key, $array_selected)) continue; // Field not selected
233
+            if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL
234
+			if ($i > 0) $sql .= ', ';
235 235
 			else $i++;
236 236
 
237
-			if (strpos($key, ' as ')===false) {
238
-				$newfield=$key.' as '.str_replace(array('.', '-','(',')'),'_',$key);
237
+			if (strpos($key, ' as ') === false) {
238
+				$newfield = $key.' as '.str_replace(array('.', '-', '(', ')'), '_', $key);
239 239
 			} else {
240
-				$newfield=$key;
240
+				$newfield = $key;
241 241
 			}
242 242
 
243
-			$sql.=$newfield;
243
+			$sql .= $newfield;
244 244
 		}
245
-		$sql.=$this->array_export_sql_end[$indice];
245
+		$sql .= $this->array_export_sql_end[$indice];
246 246
 
247 247
 		// Add the WHERE part. Filtering into sql if a filtering array is provided
248 248
 		if (is_array($array_filterValue) && !empty($array_filterValue))
249 249
 		{
250
-			$sqlWhere='';
250
+			$sqlWhere = '';
251 251
 			// Loop on each condition to add
252 252
 			foreach ($array_filterValue as $key => $value)
253 253
 			{
254 254
 			    if (preg_match('/GROUP_CONCAT/i', $key)) continue;
255
-				if ($value != '') $sqlWhere.=" and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
255
+				if ($value != '') $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
256 256
 			}
257
-			$sql.=$sqlWhere;
257
+			$sql .= $sqlWhere;
258 258
 		}
259 259
 
260 260
 		// Add the order
261
-		$sql.=$this->array_export_sql_order[$indice];
261
+		$sql .= $this->array_export_sql_order[$indice];
262 262
 
263 263
 		// Add the HAVING part.
264 264
 		if (is_array($array_filterValue) && !empty($array_filterValue))
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		    // Loop on each condition to add
267 267
 		    foreach ($array_filterValue as $key => $value)
268 268
 		    {
269
-		        if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql.=" HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
269
+		        if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
270 270
 		    }
271 271
 		}
272 272
 
@@ -290,25 +290,25 @@  discard block
 block discarded – undo
290 290
 		// build the input field on depend of the type of file
291 291
 		switch ($InfoFieldList[0]) {
292 292
 			case 'Text':
293
-				if (! (strpos($ValueField, '%') === false))
294
-					$szFilterQuery.=" ".$NameField." LIKE '".$ValueField."'";
293
+				if (!(strpos($ValueField, '%') === false))
294
+					$szFilterQuery .= " ".$NameField." LIKE '".$ValueField."'";
295 295
 				else
296
-					$szFilterQuery.=" ".$NameField." = '".$ValueField."'";
296
+					$szFilterQuery .= " ".$NameField." = '".$ValueField."'";
297 297
 				break;
298 298
 			case 'Date':
299 299
 				if (strpos($ValueField, "+") > 0)
300 300
 				{
301 301
 					// mode plage
302 302
 					$ValueArray = explode("+", $ValueField);
303
-					$szFilterQuery ="(".$this->conditionDate($NameField,trim($ValueArray[0]),">=");
304
-					$szFilterQuery.=" AND ".$this->conditionDate($NameField,trim($ValueArray[1]),"<=").")";
303
+					$szFilterQuery = "(".$this->conditionDate($NameField, trim($ValueArray[0]), ">=");
304
+					$szFilterQuery .= " AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")";
305 305
 				}
306 306
 				else
307 307
 				{
308
-					if (is_numeric(substr($ValueField,0,1)))
309
-						$szFilterQuery=$this->conditionDate($NameField,trim($ValueField),"=");
308
+					if (is_numeric(substr($ValueField, 0, 1)))
309
+						$szFilterQuery = $this->conditionDate($NameField, trim($ValueField), "=");
310 310
 					else
311
-						$szFilterQuery=$this->conditionDate($NameField,trim(substr($ValueField,1)),substr($ValueField,0,1));
311
+						$szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
312 312
 				}
313 313
 				break;
314 314
 			case 'Duree':
@@ -319,29 +319,29 @@  discard block
 block discarded – undo
319 319
 				{
320 320
 					// mode plage
321 321
 					$ValueArray = explode("+", $ValueField);
322
-					$szFilterQuery ="(".$NameField.">=".$ValueArray[0];
323
-					$szFilterQuery.=" AND ".$NameField."<=".$ValueArray[1].")";
322
+					$szFilterQuery = "(".$NameField.">=".$ValueArray[0];
323
+					$szFilterQuery .= " AND ".$NameField."<=".$ValueArray[1].")";
324 324
 				}
325 325
 				else
326 326
 				{
327
-					if (is_numeric(substr($ValueField,0,1)))
328
-						$szFilterQuery=" ".$NameField."=".$ValueField;
327
+					if (is_numeric(substr($ValueField, 0, 1)))
328
+						$szFilterQuery = " ".$NameField."=".$ValueField;
329 329
 					else
330
-						$szFilterQuery=" ".$NameField.substr($ValueField,0,1).substr($ValueField,1);
330
+						$szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
331 331
 				}
332 332
 				break;
333 333
 			case 'Boolean':
334
-				$szFilterQuery=" ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField =='yes' ? 1: 0) );
334
+				$szFilterQuery = " ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField == 'yes' ? 1 : 0));
335 335
 				break;
336 336
 			case 'Status':
337 337
 			case 'List':
338 338
 				if (is_numeric($ValueField))
339
-					$szFilterQuery=" ".$NameField."=".$ValueField;
339
+					$szFilterQuery = " ".$NameField."=".$ValueField;
340 340
 				else {
341
-                    if (! (strpos($ValueField, '%') === false))
342
-                        $szFilterQuery=" ".$NameField." LIKE '".$ValueField."'";
341
+                    if (!(strpos($ValueField, '%') === false))
342
+                        $szFilterQuery = " ".$NameField." LIKE '".$ValueField."'";
343 343
                     else
344
-                        $szFilterQuery=" ".$NameField." = '".$ValueField."'";
344
+                        $szFilterQuery = " ".$NameField." = '".$ValueField."'";
345 345
 				}
346 346
 				break;
347 347
 			default:
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	function conditionDate($Field, $Value, $Sens)
363 363
 	{
364 364
 		// TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN
365
-		if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
366
-		elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
367
-		else  $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
365
+		if (strlen($Value) == 4) $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
366
+		elseif (strlen($Value) == 6) $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
367
+		else  $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
368 368
 		return $Condition;
369 369
 	}
370 370
 
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
 	function build_filterField($TypeField, $NameField, $ValueField)
381 381
 	{
382 382
         // phpcs:enable
383
-		global $conf,$langs;
383
+		global $conf, $langs;
384 384
 
385
-		$szFilterField='';
385
+		$szFilterField = '';
386 386
 		$InfoFieldList = explode(":", $TypeField);
387 387
 
388 388
 		// build the input field on depend of the type of file
@@ -390,52 +390,52 @@  discard block
 block discarded – undo
390 390
 		{
391 391
 			case 'Text':
392 392
 			case 'Date':
393
-				$szFilterField='<input type="text" name="'.$NameField.'" value="'.$ValueField.'">';
393
+				$szFilterField = '<input type="text" name="'.$NameField.'" value="'.$ValueField.'">';
394 394
 				break;
395 395
 			case 'Duree':
396 396
 			case 'Numeric':
397 397
 			case 'Number':
398 398
 				// Must be a string text to allow to use comparison strings like "<= 999"
399
-			    $szFilterField='<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
399
+			    $szFilterField = '<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
400 400
 				break;
401 401
 			case 'Status':
402
-				if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField='<input type="number" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
403
-				else $szFilterField='<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
402
+				if (!empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField = '<input type="number" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
403
+				else $szFilterField = '<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
404 404
 				break;
405 405
 			case 'Boolean':
406
-				$szFilterField='<select name="'.$NameField.'" class="flat">';
407
-				$szFilterField.='<option ';
408
-				if ($ValueField=='') $szFilterField.=' selected ';
409
-				$szFilterField.=' value="">&nbsp;</option>';
410
-
411
-				$szFilterField.='<option ';
412
-				if ($ValueField=='yes' || $ValueField == '1') $szFilterField.=' selected ';
413
-				$szFilterField.=' value="1">'.yn(1).'</option>';
414
-
415
-				$szFilterField.='<option ';
416
-				if ($ValueField=='no' || $ValueField=='0') $szFilterField.=' selected ';
417
-				$szFilterField.=' value="0">'.yn(0).'</option>';
418
-				$szFilterField.="</select>";
406
+				$szFilterField = '<select name="'.$NameField.'" class="flat">';
407
+				$szFilterField .= '<option ';
408
+				if ($ValueField == '') $szFilterField .= ' selected ';
409
+				$szFilterField .= ' value="">&nbsp;</option>';
410
+
411
+				$szFilterField .= '<option ';
412
+				if ($ValueField == 'yes' || $ValueField == '1') $szFilterField .= ' selected ';
413
+				$szFilterField .= ' value="1">'.yn(1).'</option>';
414
+
415
+				$szFilterField .= '<option ';
416
+				if ($ValueField == 'no' || $ValueField == '0') $szFilterField .= ' selected ';
417
+				$szFilterField .= ' value="0">'.yn(0).'</option>';
418
+				$szFilterField .= "</select>";
419 419
 				break;
420 420
 			case 'List':
421 421
 				// 0 : Type du champ
422 422
 				// 1 : Nom de la table
423 423
 				// 2 : Nom du champ contenant le libelle
424 424
 				// 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list.
425
-				if (count($InfoFieldList)==4)
426
-					$keyList=$InfoFieldList[3];
425
+				if (count($InfoFieldList) == 4)
426
+					$keyList = $InfoFieldList[3];
427 427
 				else
428
-					$keyList='rowid';
429
-				$sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3])?'':', '.$InfoFieldList[3].' as code');
430
-				if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3])?'':', '.$InfoFieldList[3].' as code');
428
+					$keyList = 'rowid';
429
+				$sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
430
+				if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
431 431
 				if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
432
-				$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[1];
432
+				$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[1];
433 433
 
434 434
 				$resql = $this->db->query($sql);
435 435
 				if ($resql)
436 436
 				{
437
-					$szFilterField='<select class="flat" name="'.$NameField.'">';
438
-					$szFilterField.='<option value="0">&nbsp;</option>';
437
+					$szFilterField = '<select class="flat" name="'.$NameField.'">';
438
+					$szFilterField .= '<option value="0">&nbsp;</option>';
439 439
 					$num = $this->db->num_rows($resql);
440 440
 
441 441
 					$i = 0;
@@ -451,30 +451,30 @@  discard block
 block discarded – undo
451 451
 								continue;
452 452
 							}
453 453
 							//var_dump($InfoFieldList[1]);
454
-							$labeltoshow=dol_trunc($obj->label,18);
454
+							$labeltoshow = dol_trunc($obj->label, 18);
455 455
 							if ($InfoFieldList[1] == 'c_stcomm')
456 456
 							{
457 457
 								$langs->load("companies");
458
-								$labeltoshow=(($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id)?$langs->trans("StatusProspect".$obj->id):$obj->label);
458
+								$labeltoshow = (($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id) ? $langs->trans("StatusProspect".$obj->id) : $obj->label);
459 459
 							}
460 460
 							if ($InfoFieldList[1] == 'c_country')
461 461
 							{
462 462
 								//var_dump($sql);
463 463
 								$langs->load("dict");
464
-								$labeltoshow=(($langs->trans("Country".$obj->code) != "Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label);
464
+								$labeltoshow = (($langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label);
465 465
 							}
466 466
 							if (!empty($ValueField) && $ValueField == $obj->rowid)
467 467
 							{
468
-								$szFilterField.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
468
+								$szFilterField .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
469 469
 							}
470 470
 							else
471 471
 							{
472
-								$szFilterField.='<option value="'.$obj->rowid.'" >'.$labeltoshow.'</option>';
472
+								$szFilterField .= '<option value="'.$obj->rowid.'" >'.$labeltoshow.'</option>';
473 473
 							}
474 474
 							$i++;
475 475
 						}
476 476
 					}
477
-					$szFilterField.="</select>";
477
+					$szFilterField .= "</select>";
478 478
 
479 479
 					$this->db->free($resql);
480 480
 				}
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 	{
496 496
         global $langs;
497 497
 
498
-		$szMsg='';
498
+		$szMsg = '';
499 499
 		$InfoFieldList = explode(":", $TypeField);
500 500
 		// build the input field on depend of the type of file
501 501
 		switch ($InfoFieldList[0]) {
502 502
 			case 'Text':
503
-				$szMsg= $langs->trans('ExportStringFilter');
503
+				$szMsg = $langs->trans('ExportStringFilter');
504 504
 				break;
505 505
 			case 'Date':
506 506
 				$szMsg = $langs->trans('ExportDateFilter');
@@ -535,37 +535,37 @@  discard block
 block discarded – undo
535 535
 	function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '')
536 536
  	{
537 537
         // phpcs:enable
538
-		global $conf,$langs;
538
+		global $conf, $langs;
539 539
 
540
-		$indice=0;
540
+		$indice = 0;
541 541
 		asort($array_selected);
542 542
 
543 543
 		dol_syslog(get_class($this)."::".__FUNCTION__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected));
544 544
 
545 545
 		// Check parameters or context properties
546
-		if (empty($this->array_export_fields) || ! is_array($this->array_export_fields))
546
+		if (empty($this->array_export_fields) || !is_array($this->array_export_fields))
547 547
 		{
548
-			$this->error="ErrorBadParameter";
548
+			$this->error = "ErrorBadParameter";
549 549
 			return -1;
550 550
 		}
551 551
 
552 552
 		// Creation of class to export using model ExportXXX
553
-		$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
553
+		$dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
554 554
 		$file = "export_".$model.".modules.php";
555 555
 		$classname = "Export".$model;
556 556
 		require_once $dir.$file;
557 557
 		$objmodel = new $classname($this->db);
558 558
 
559
-		if (! empty($sqlquery)) $sql = $sqlquery;
559
+		if (!empty($sqlquery)) $sql = $sqlquery;
560 560
         else
561 561
 		{
562 562
 			// Define value for indice from $datatoexport
563
-			$foundindice=0;
564
-			foreach($this->array_export_code as $key => $dataset)
563
+			$foundindice = 0;
564
+			foreach ($this->array_export_code as $key => $dataset)
565 565
 			{
566 566
 				if ($datatoexport == $dataset)
567 567
 				{
568
-					$indice=$key;
568
+					$indice = $key;
569 569
 					$foundindice++;
570 570
 					//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
571 571
 					break;
@@ -573,31 +573,31 @@  discard block
 block discarded – undo
573 573
 			}
574 574
 			if (empty($foundindice))
575 575
 			{
576
-				$this->error="ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
576
+				$this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
577 577
 				return -1;
578 578
 			}
579
-        	$sql=$this->build_sql($indice, $array_selected, $array_filterValue);
579
+        	$sql = $this->build_sql($indice, $array_selected, $array_filterValue);
580 580
 		}
581 581
 
582 582
 		// Run the sql
583
-		$this->sqlusedforexport=$sql;
583
+		$this->sqlusedforexport = $sql;
584 584
 		dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG);
585 585
 		$resql = $this->db->query($sql);
586 586
 		if ($resql)
587 587
 		{
588 588
 			//$this->array_export_label[$indice]
589 589
 			if ($conf->global->EXPORT_PREFIX_SPEC)
590
-				$filename=$conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
590
+				$filename = $conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
591 591
 			else
592
-				$filename="export_".$datatoexport;
593
-			$filename.='.'.$objmodel->getDriverExtension();
594
-			$dirname=$conf->export->dir_temp.'/'.$user->id;
592
+				$filename = "export_".$datatoexport;
593
+			$filename .= '.'.$objmodel->getDriverExtension();
594
+			$dirname = $conf->export->dir_temp.'/'.$user->id;
595 595
 
596 596
 			$outputlangs = clone $langs; // We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value
597 597
 
598 598
 			// Open file
599 599
 			dol_mkdir($dirname);
600
-			$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
600
+			$result = $objmodel->open_file($dirname."/".$filename, $outputlangs);
601 601
 
602 602
 			if ($result >= 0)
603 603
 			{
@@ -605,64 +605,64 @@  discard block
 block discarded – undo
605 605
 				$objmodel->write_header($outputlangs);
606 606
 
607 607
 				// Genere ligne de titre
608
-				$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs,$this->array_export_TypeFields[$indice]);
608
+				$objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, $this->array_export_TypeFields[$indice]);
609 609
 
610 610
 				while ($obj = $this->db->fetch_object($resql))
611 611
 				{
612 612
 					// Process special operations
613
-					if (! empty($this->array_export_special[$indice]))
613
+					if (!empty($this->array_export_special[$indice]))
614 614
 					{
615 615
 						foreach ($this->array_export_special[$indice] as $key => $value)
616 616
 						{
617
-							if (! array_key_exists($key, $array_selected)) continue;		// Field not selected
617
+							if (!array_key_exists($key, $array_selected)) continue; // Field not selected
618 618
 							// Operation NULLIFNEG
619
-							if ($this->array_export_special[$indice][$key]=='NULLIFNEG')
619
+							if ($this->array_export_special[$indice][$key] == 'NULLIFNEG')
620 620
 							{
621 621
 								//$alias=$this->array_export_alias[$indice][$key];
622
-								$alias=str_replace(array('.', '-','(',')'),'_',$key);
623
-								if ($obj->$alias < 0) $obj->$alias='';
622
+								$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
623
+								if ($obj->$alias < 0) $obj->$alias = '';
624 624
 							}
625 625
 							// Operation ZEROIFNEG
626
-							elseif ($this->array_export_special[$indice][$key]=='ZEROIFNEG')
626
+							elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG')
627 627
 							{
628 628
 								//$alias=$this->array_export_alias[$indice][$key];
629
-								$alias=str_replace(array('.', '-','(',')'),'_',$key);
630
-								if ($obj->$alias < 0) $obj->$alias='0';
629
+								$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
630
+								if ($obj->$alias < 0) $obj->$alias = '0';
631 631
 							}
632 632
 							// Operation INVOICEREMAINTOPAY
633
-							elseif ($this->array_export_special[$indice][$key]=='getRemainToPay')
633
+							elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay')
634 634
 							{
635 635
 								//$alias=$this->array_export_alias[$indice][$key];
636
-								$alias=str_replace(array('.', '-','(',')'),'_',$key);
637
-								$remaintopay='';
636
+								$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
637
+								$remaintopay = '';
638 638
 								if ($obj->f_rowid > 0)
639 639
 								{
640 640
 								    global $tmpobjforcomputecall;
641
-								    if (! is_object($tmpobjforcomputecall))
641
+								    if (!is_object($tmpobjforcomputecall))
642 642
 								    {
643 643
 								        include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
644
-								        $tmpobjforcomputecall=new Facture($this->db);
644
+								        $tmpobjforcomputecall = new Facture($this->db);
645 645
 								    }
646 646
 								    $tmpobjforcomputecall->id = $obj->f_rowid;
647 647
 								    $tmpobjforcomputecall->total_ttc = $obj->f_total_ttc;
648
-								    $remaintopay=$tmpobjforcomputecall->getRemainToPay();
648
+								    $remaintopay = $tmpobjforcomputecall->getRemainToPay();
649 649
 								}
650
-								$obj->$alias=$remaintopay;
650
+								$obj->$alias = $remaintopay;
651 651
 							}
652 652
 							else
653 653
 							{
654 654
 							    // TODO FIXME Export of compute field does not work. $obj containt $obj->alias_field and formulat will contains $obj->field
655
-							    $computestring=$this->array_export_special[$indice][$key];
656
-							    $tmp=dol_eval($computestring, 1, 0);
657
-							    $obj->$alias=$tmp;
655
+							    $computestring = $this->array_export_special[$indice][$key];
656
+							    $tmp = dol_eval($computestring, 1, 0);
657
+							    $obj->$alias = $tmp;
658 658
 
659
-							    $this->error="ERROPNOTSUPPORTED. Operation ".$this->array_export_special[$indice][$key]." not supported. Export of 'computed' extrafields is not yet supported, please remove field.";
659
+							    $this->error = "ERROPNOTSUPPORTED. Operation ".$this->array_export_special[$indice][$key]." not supported. Export of 'computed' extrafields is not yet supported, please remove field.";
660 660
 							    return -1;
661 661
 							}
662 662
 						}
663 663
 					}
664 664
 					// end of special operation processing
665
-					$objmodel->write_record($array_selected,$obj,$outputlangs,$this->array_export_TypeFields[$indice]);
665
+					$objmodel->write_record($array_selected, $obj, $outputlangs, $this->array_export_TypeFields[$indice]);
666 666
 				}
667 667
 
668 668
 				// Genere en-tete
@@ -675,14 +675,14 @@  discard block
 block discarded – undo
675 675
 			}
676 676
 			else
677 677
 			{
678
-				$this->error=$objmodel->error;
678
+				$this->error = $objmodel->error;
679 679
 				dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
680 680
 				return -1;
681 681
 			}
682 682
 		}
683 683
 		else
684 684
 		{
685
-			$this->error=$this->db->error()." - sql=".$sql;
685
+			$this->error = $this->db->error()." - sql=".$sql;
686 686
 			return -1;
687 687
 		}
688 688
 	}
@@ -701,24 +701,24 @@  discard block
 block discarded – undo
701 701
 
702 702
 		$this->db->begin();
703 703
 
704
-		$filter='';
704
+		$filter = '';
705 705
 
706 706
 		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'export_model (';
707
-		$sql.= 'label,';
708
-		$sql.= 'type,';
709
-		$sql.= 'field,';
710
-		$sql.= 'fk_user,';
711
-		$sql.= 'filter';
712
-		$sql.= ') VALUES (';
713
-		$sql.= "'".$this->db->escape($this->model_name)."',";
714
-		$sql.= "'".$this->db->escape($this->datatoexport)."',";
715
-		$sql.= "'".$this->db->escape($this->hexa)."',";
716
-		$sql.= "'".$user->id."',";
717
-		$sql.= "'".$this->db->escape($this->hexafiltervalue)."'";
718
-		$sql.= ")";
707
+		$sql .= 'label,';
708
+		$sql .= 'type,';
709
+		$sql .= 'field,';
710
+		$sql .= 'fk_user,';
711
+		$sql .= 'filter';
712
+		$sql .= ') VALUES (';
713
+		$sql .= "'".$this->db->escape($this->model_name)."',";
714
+		$sql .= "'".$this->db->escape($this->datatoexport)."',";
715
+		$sql .= "'".$this->db->escape($this->hexa)."',";
716
+		$sql .= "'".$user->id."',";
717
+		$sql .= "'".$this->db->escape($this->hexafiltervalue)."'";
718
+		$sql .= ")";
719 719
 
720 720
 		dol_syslog(get_class($this)."::create", LOG_DEBUG);
721
-		$resql=$this->db->query($sql);
721
+		$resql = $this->db->query($sql);
722 722
 		if ($resql)
723 723
 		{
724 724
 			$this->db->commit();
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 		}
727 727
 		else
728 728
 		{
729
-			$this->error=$this->db->lasterror();
730
-			$this->errno=$this->db->lasterrno();
729
+			$this->error = $this->db->lasterror();
730
+			$this->errno = $this->db->lasterrno();
731 731
 			$this->db->rollback();
732 732
 			return -1;
733 733
 		}
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	function fetch($id)
743 743
 	{
744 744
 		$sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter';
745
-		$sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em';
746
-		$sql.= ' WHERE em.rowid = '.$id;
745
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'export_model as em';
746
+		$sql .= ' WHERE em.rowid = '.$id;
747 747
 
748 748
 		dol_syslog("Export::fetch", LOG_DEBUG);
749 749
 		$result = $this->db->query($sql);
@@ -752,18 +752,18 @@  discard block
 block discarded – undo
752 752
 			$obj = $this->db->fetch_object($result);
753 753
 			if ($obj)
754 754
 			{
755
-				$this->id				= $obj->rowid;
756
-				$this->model_name		= $obj->label;
757
-				$this->datatoexport		= $obj->type;
755
+				$this->id = $obj->rowid;
756
+				$this->model_name = $obj->label;
757
+				$this->datatoexport = $obj->type;
758 758
 
759
-				$this->hexa				= $obj->field;
760
-				$this->hexafiltervalue	= $obj->filter;
759
+				$this->hexa = $obj->field;
760
+				$this->hexafiltervalue = $obj->filter;
761 761
 
762 762
 				return 1;
763 763
 			}
764 764
 			else
765 765
 			{
766
-				$this->error="ModelNotFound";
766
+				$this->error = "ModelNotFound";
767 767
 				return -2;
768 768
 			}
769 769
 		}
@@ -782,23 +782,23 @@  discard block
 block discarded – undo
782 782
 	 *  @param      int			$notrigger	    0=launch triggers after, 1=disable triggers
783 783
 	 *	@return		int							<0 if KO, >0 if OK
784 784
 	 */
785
-	function delete($user, $notrigger=0)
785
+	function delete($user, $notrigger = 0)
786 786
 	{
787 787
 		global $conf, $langs;
788
-		$error=0;
788
+		$error = 0;
789 789
 
790 790
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."export_model";
791
-		$sql.= " WHERE rowid=".$this->id;
791
+		$sql .= " WHERE rowid=".$this->id;
792 792
 
793 793
 		$this->db->begin();
794 794
 
795 795
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
796 796
 		$resql = $this->db->query($sql);
797
-		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
797
+		if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
798 798
 
799
-		if (! $error)
799
+		if (!$error)
800 800
 		{
801
-			if (! $notrigger)
801
+			if (!$notrigger)
802 802
 			{
803 803
 				// Uncomment this and change MYOBJECT to your own tag if you
804 804
 				// want this action call a trigger.
@@ -815,13 +815,13 @@  discard block
 block discarded – undo
815 815
 		// Commit or rollback
816 816
 		if ($error)
817 817
 		{
818
-			foreach($this->errors as $errmsg)
818
+			foreach ($this->errors as $errmsg)
819 819
 			{
820 820
 				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
821
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
821
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
822 822
 			}
823 823
 			$this->db->rollback();
824
-			return -1*$error;
824
+			return -1 * $error;
825 825
 		}
826 826
 		else
827 827
 		{
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 		global $conf, $langs;
844 844
 
845 845
 		$sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter";
846
-		$sql.= " FROM ".MAIN_DB_PREFIX."export_model as em";
847
-		$sql.= " ORDER BY rowid";
846
+		$sql .= " FROM ".MAIN_DB_PREFIX."export_model as em";
847
+		$sql .= " ORDER BY rowid";
848 848
 
849 849
 		$result = $this->db->query($sql);
850 850
 		if ($result)
@@ -858,19 +858,19 @@  discard block
 block discarded – undo
858 858
 				print "<tr>";
859 859
 				print '<td><a href=export.php?step=2&action=select_model&exportmodelid='.$obj->rowid.'&datatoexport='.$obj->type.'>'.$obj->label.'</a></td>';
860 860
 				print '<td>';
861
-				print img_object($this->array_export_module[$keyModel]->getName(),$this->array_export_icon[$keyModel]).' ';
861
+				print img_object($this->array_export_module[$keyModel]->getName(), $this->array_export_icon[$keyModel]).' ';
862 862
 				print $this->array_export_module[$keyModel]->getName().' - ';
863 863
 				// recuperation du nom de l'export
864 864
 
865
-				$string=$langs->trans($this->array_export_label[$keyModel]);
866
-				print ($string!=$this->array_export_label[$keyModel]?$string:$this->array_export_label[$keyModel]);
865
+				$string = $langs->trans($this->array_export_label[$keyModel]);
866
+				print ($string != $this->array_export_label[$keyModel] ? $string : $this->array_export_label[$keyModel]);
867 867
 				print '</td>';
868 868
 				//print '<td>'.$obj->type.$keyModel.'</td>';
869
-				print '<td>'.str_replace(',',' , ',$obj->field).'</td>';
870
-				if (! empty($obj->filter)) {
869
+				print '<td>'.str_replace(',', ' , ', $obj->field).'</td>';
870
+				if (!empty($obj->filter)) {
871 871
 					$filter = json_decode($obj->filter, true);
872
-					print '<td>'.str_replace(',',' , ',$filter['field']).'</td>';
873
-					print '<td>'.str_replace(',',' , ',$filter['value']).'</td>';
872
+					print '<td>'.str_replace(',', ' , ', $filter['field']).'</td>';
873
+					print '<td>'.str_replace(',', ' , ', $filter['value']).'</td>';
874 874
 				}
875 875
 				// suppression de l'export
876 876
 				print '<td align="right">';
Please login to merge, or discard this patch.
dolibarr/htdocs/margin/lib/margins.lib.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	// Entries must be declared in modules descriptor with line
45 45
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
46 46
     // $this->tabs = array('entity:-tabname);   												to remove a tab
47
-	complete_head_from_modules($conf,$langs,'',$head,$h,'margesadmin');
47
+	complete_head_from_modules($conf, $langs, '', $head, $h, 'margesadmin');
48 48
 
49
-	complete_head_from_modules($conf,$langs,'',$head,$h,'margesadmin','remove');
49
+	complete_head_from_modules($conf, $langs, '', $head, $h, 'margesadmin', 'remove');
50 50
 
51 51
 	return $head;
52 52
 }
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 {
116 116
 	global $db, $conf;
117 117
 
118
-	$marge_tx_ret='';
119
-	$marque_tx_ret='';
118
+	$marge_tx_ret = '';
119
+	$marque_tx_ret = '';
120 120
 
121 121
 	if ($fk_pa > 0 && empty($paht)) {
122 122
 		require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
Please login to merge, or discard this patch.
dolibarr/htdocs/margin/admin/margin.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
 
32 32
 $langs->loadLangs(array("admin", "bills", "margins", "stocks"));
33 33
 
34
-if (! $user->admin) accessforbidden();
34
+if (!$user->admin) accessforbidden();
35 35
 
36
-$action=GETPOST('action','alpha');
36
+$action = GETPOST('action', 'alpha');
37 37
 
38 38
 
39 39
 /*
40 40
  * Action
41 41
  */
42
-if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
42
+if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
43 43
 {
44
-    $code=$reg[1];
44
+    $code = $reg[1];
45 45
     if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
46 46
     {
47 47
         header("Location: ".$_SERVER["PHP_SELF"]);
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     }
54 54
 }
55 55
 
56
-if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
56
+if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
57 57
 {
58
-    $code=$reg[1];
58
+    $code = $reg[1];
59 59
     if (dolibarr_del_const($db, $code, $conf->entity) > 0)
60 60
     {
61 61
         header("Location: ".$_SERVER["PHP_SELF"]);
@@ -107,18 +107,18 @@  discard block
 block discarded – undo
107 107
  * View
108 108
  */
109 109
 
110
-llxHeader('',$langs->trans("margesSetup"));
110
+llxHeader('', $langs->trans("margesSetup"));
111 111
 
112 112
 
113
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
114
-print load_fiche_titre($langs->trans("margesSetup"),$linkback,'title_setup');
113
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
114
+print load_fiche_titre($langs->trans("margesSetup"), $linkback, 'title_setup');
115 115
 
116 116
 
117 117
 $head = marges_admin_prepare_head();
118 118
 
119 119
 dol_fiche_head($head, 'parameters', $langs->trans("Margins"), -1, 'margin');
120 120
 
121
-print load_fiche_titre($langs->trans("MemberMainOptions"),'','');
121
+print load_fiche_titre($langs->trans("MemberMainOptions"), '', '');
122 122
 print '<table class="noborder" width="100%">';
123 123
 print '<tr class="liste_titre">';
124 124
 print '<td width=300>'.$langs->trans("Description").'</td>';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 print '<tr class="oddeven">';
164 164
 print '<td>'.$langs->trans("DisplayMarginRates").'</td>';
165 165
 print '<td colspan="2" align="center">';
166
-if (! empty($conf->use_javascript_ajax))
166
+if (!empty($conf->use_javascript_ajax))
167 167
 {
168 168
 	print ajax_constantonoff('DISPLAY_MARGIN_RATES');
169 169
 }
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 {
172 172
 	if (empty($conf->global->DISPLAY_MARGIN_RATES))
173 173
 	{
174
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
174
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
175 175
 	}
176 176
 	else
177 177
 	{
178
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
178
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
179 179
 	}
180 180
 }
181 181
 print '</td>';
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 print '<tr class="oddeven">';
187 187
 print '<td>'.$langs->trans("DisplayMarkRates").'</td>';
188 188
 print '<td colspan="2" align="center">';
189
-if (! empty($conf->use_javascript_ajax))
189
+if (!empty($conf->use_javascript_ajax))
190 190
 {
191 191
 	print ajax_constantonoff('DISPLAY_MARK_RATES');
192 192
 }
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 {
195 195
 	if (empty($conf->global->DISPLAY_MARK_RATES))
196 196
 	{
197
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
197
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
198 198
 	}
199 199
 	else
200 200
 	{
201
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
201
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
202 202
 	}
203 203
 }
204 204
 print '</td>';
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 print '<tr class="oddeven">';
210 210
 print '<td>'.$langs->trans("ForceBuyingPriceIfNull").'</td>';
211 211
 print '<td colspan="2" align="center">';
212
-if (! empty($conf->use_javascript_ajax))
212
+if (!empty($conf->use_javascript_ajax))
213 213
 {
214 214
 	print ajax_constantonoff('ForceBuyingPriceIfNull');
215 215
 }
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 {
218 218
 	if (empty($conf->global->ForceBuyingPriceIfNull))
219 219
 	{
220
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>';
220
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
221 221
 	}
222 222
 	else
223 223
 	{
224
-		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>';
224
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
225 225
 	}
226 226
 }
227 227
 print '</td>';
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 print '<td align="left">';
261 261
 $formcompany = new FormCompany($db);
262 262
 $facture = new Facture($db);
263
-print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1);
263
+print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE", "internal", "code", 1);
264 264
 print '</td>';
265 265
 print '<td>';
266 266
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
Please login to merge, or discard this patch.