Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/dev/initdata/import-thirdparties.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 // Test si mode batch
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
33 33
     echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
34 34
     exit;
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/import-thirdparties.php/i','',$_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/import-thirdparties.php/i', '', $_SERVER["PHP_SELF"]);
39 39
 require $path."../../htdocs/master.inc.php";
40 40
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42 42
 
43
-$delimiter=',';
44
-$enclosure='"';
45
-$linelength=10000;
46
-$escape='/';
43
+$delimiter = ',';
44
+$enclosure = '"';
45
+$linelength = 10000;
46
+$escape = '/';
47 47
 
48 48
 // Global variables
49
-$version=DOL_VERSION;
50
-$confirmed=1;
51
-$error=0;
49
+$version = DOL_VERSION;
50
+$confirmed = 1;
51
+$error = 0;
52 52
 
53 53
 
54 54
 /*
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 
58 58
 @set_time_limit(0);
59 59
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
60
-dol_syslog($script_file." launched with arg ".implode(',',$argv));
60
+dol_syslog($script_file." launched with arg ".implode(',', $argv));
61 61
 
62 62
 $mode = $argv[1];
63 63
 $filepath = $argv[2];
64 64
 $filepatherr = $filepath.'.err';
65 65
 //$defaultlang = empty($argv[3])?'en_US':$argv[3];
66
-$startlinenb = empty($argv[3])?1:$argv[3];
67
-$endlinenb = empty($argv[4])?0:$argv[4];
66
+$startlinenb = empty($argv[3]) ? 1 : $argv[3];
67
+$endlinenb = empty($argv[4]) ? 0 : $argv[4];
68 68
 
69
-if (empty($mode) || ! in_array($mode,array('test','confirm','confirmforced')) || empty($filepath)) {
69
+if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) {
70 70
     print "Usage:  $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
71 71
     print "Usage:  $script_file test myfilepath.csv 2 1002\n";
72 72
     print "\n";
73 73
     exit(-1);
74 74
 }
75
-if (! file_exists($filepath)) {
75
+if (!file_exists($filepath)) {
76 76
     print "Error: File ".$filepath." not found.\n";
77 77
     print "\n";
78 78
     exit(-1);
79 79
 }
80 80
 
81
-$ret=$user->fetch('','admin');
82
-if (! $ret > 0)
81
+$ret = $user->fetch('', 'admin');
82
+if (!$ret > 0)
83 83
 {
84 84
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
85 85
 	exit;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 $user->getrights();
88 88
 
89 89
 // Ask confirmation
90
-if (! $confirmed)
90
+if (!$confirmed)
91 91
 {
92 92
     print "Hit Enter to continue or CTRL+C to stop...\n";
93 93
     $input = trim(fgets(STDIN));
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
 // Open input and ouput files
97 97
 $fhandle = fopen($filepath, 'r');
98
-if (! $fhandle)
98
+if (!$fhandle)
99 99
 {
100 100
     print 'Error: Failed to open file '.$filepath."\n";
101 101
     exit(1);
102 102
 }
103 103
 $fhandleerr = fopen($filepatherr, 'w');
104
-if (! $fhandleerr)
104
+if (!$fhandleerr)
105 105
 {
106 106
     print 'Error: Failed to open file '.$filepatherr."\n";
107 107
     exit(1);
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
 $db->begin();
114 114
 
115
-$i=0;
116
-$nboflines=0;
117
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
115
+$i = 0;
116
+$nboflines = 0;
117
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
118 118
 {
119 119
     $i++;
120
-    $errorrecord=0;
120
+    $errorrecord = 0;
121 121
 
122 122
     if ($startlinenb && $i < $startlinenb) continue;
123 123
     if ($endlinenb && $i > $endlinenb) continue;
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
     $object->client = $fields[7];
130 130
     $object->fournisseur = $fields[8];
131 131
 
132
-    $object->name = $fields[13]?trim($fields[13]):$fields[0];
133
-    $object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
132
+    $object->name = $fields[13] ?trim($fields[13]) : $fields[0];
133
+    $object->name_alias = $fields[0] != $fields[13] ?trim($fields[0]) : '';
134 134
 
135 135
     $object->address = trim($fields[14]);
136 136
     $object->zip = trim($fields[15]);
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 
172 172
 
173 173
     // Extrafields
174
-    $object->array_options['options_anastate']=price2num($fields[20]);
175
-    $object->array_options['options_anaregion']=price2num($fields[17]);
174
+    $object->array_options['options_anastate'] = price2num($fields[20]);
175
+    $object->array_options['options_anaregion'] = price2num($fields[17]);
176 176
 
177
-    if (! $errorrecord)
177
+    if (!$errorrecord)
178 178
     {
179
-        $ret=$object->create($user);
179
+        $ret = $object->create($user);
180 180
         if ($ret < 0)
181 181
         {
182 182
             print " - Error in create result code = ".$ret." - ".$object->errorsToString();
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
     	}
189 189
     }
190 190
 
191
-    if (! $errorrecord)
191
+    if (!$errorrecord)
192 192
     {
193 193
         dol_syslog("Set price level");
194 194
 	    $object->set_price_level($object->price_level, $user);
195 195
     }
196 196
 
197 197
 	// Assign sales representative
198
-	if (! $errorrecord && $fields[3])
198
+	if (!$errorrecord && $fields[3])
199 199
 	{
200
-    	$salesrep=new User($db);
200
+    	$salesrep = new User($db);
201 201
 
202
-    	$tmp=explode(' ',$fields[3],2);
202
+    	$tmp = explode(' ', $fields[3], 2);
203 203
     	$salesrep->firstname = trim($tmp[0]);
204 204
     	$salesrep->lastname = trim($tmp[1]);
205
-    	if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
206
-    	else $salesrep->login=strtolower($salesrep->firstname);
207
-    	$salesrep->login=preg_replace('/ /','',$salesrep->login);
208
-    	$salesrep->fetch(0,$salesrep->login);
205
+    	if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)).strtolower(substr($salesrep->lastname, 0));
206
+    	else $salesrep->login = strtolower($salesrep->firstname);
207
+    	$salesrep->login = preg_replace('/ /', '', $salesrep->login);
208
+    	$salesrep->fetch(0, $salesrep->login);
209 209
 
210 210
     	$result = $object->add_commercial($user, $salesrep->id);
211 211
     	if ($result < 0)
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 
222 222
 	dol_syslog("Add invoice contacts");
223 223
 	// Insert an invoice contact if there is an invoice email != standard email
224
-	if (! $errorrecord && $fields[27] && $fields[26] != $fields[27])
224
+	if (!$errorrecord && $fields[27] && $fields[26] != $fields[27])
225 225
 	{
226
-	    $ret1=$ret2=0;
226
+	    $ret1 = $ret2 = 0;
227 227
 
228 228
 	    $contact = new Contact($db);
229 229
 	    $contact->lastname = $object->name;
230
-	    $contact->address=$object->address;
231
-	    $contact->zip=$object->zip;
232
-	    $contact->town=$object->town;
233
-	    $contact->country_id=$object->country_id;
234
-	    $contact->email=$fields[27];
235
-	    $contact->socid=$object->id;
236
-
237
-	    $ret1=$contact->create($user);
230
+	    $contact->address = $object->address;
231
+	    $contact->zip = $object->zip;
232
+	    $contact->town = $object->town;
233
+	    $contact->country_id = $object->country_id;
234
+	    $contact->email = $fields[27];
235
+	    $contact->socid = $object->id;
236
+
237
+	    $ret1 = $contact->create($user);
238 238
 	    if ($ret1 > 0)
239 239
 	    {
240 240
 	        //$ret2=$contact->add_contact($object->id, 'BILLING');
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
 
253 253
 	dol_syslog("Add delivery contacts");
254 254
 	// Insert a delivery contact
255
-	if (! $errorrecord && $fields[47])
255
+	if (!$errorrecord && $fields[47])
256 256
 	{
257
-	    $ret1=$ret2=0;
257
+	    $ret1 = $ret2 = 0;
258 258
 
259 259
 	    $contact2 = new Contact($db);
260 260
 	    $contact2->lastname = 'Service livraison - '.$fields[47];
261 261
 	    $contact2->address = $fields[48];
262 262
 	    $contact2->zip = $fields[50];
263 263
 	    $contact2->town = $fields[51];
264
-	    $contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
265
-	    $contact2->note_public=$fields[54];
266
-	    $contact2->socid=$object->id;
264
+	    $contact2->country_id = dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
265
+	    $contact2->note_public = $fields[54];
266
+	    $contact2->socid = $object->id;
267 267
 
268 268
 	    // Extrafields
269
-	    $contact2->array_options['options_anazoneliv']=price2num($fields[53]);
269
+	    $contact2->array_options['options_anazoneliv'] = price2num($fields[53]);
270 270
 
271
-	    $ret1=$contact2->create($user);
271
+	    $ret1 = $contact2->create($user);
272 272
 	    if ($ret1 > 0)
273 273
 	    {
274 274
 	        //$ret2=$contact2->add_contact($object->id, 'SHIPPING');
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	if ($errorrecord)
291 291
 	{
292 292
 	    fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
293
-	    $error++;    // $errorrecord will be reset
293
+	    $error++; // $errorrecord will be reset
294 294
 	}
295 295
 }
296 296
 
Please login to merge, or discard this patch.
dolibarr/dev/initdata/import-users.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 // Test si mode batch
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
33 33
     echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
34 34
     exit;
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/import-users.php/i','',$_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/import-users.php/i', '', $_SERVER["PHP_SELF"]);
39 39
 require $path."../../htdocs/master.inc.php";
40 40
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42 42
 
43
-$delimiter=',';
44
-$enclosure='"';
45
-$linelength=10000;
46
-$escape='/';
43
+$delimiter = ',';
44
+$enclosure = '"';
45
+$linelength = 10000;
46
+$escape = '/';
47 47
 
48 48
 // Global variables
49
-$version=DOL_VERSION;
50
-$confirmed=1;
51
-$error=0;
49
+$version = DOL_VERSION;
50
+$confirmed = 1;
51
+$error = 0;
52 52
 
53 53
 
54 54
 /*
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 
58 58
 @set_time_limit(0);
59 59
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
60
-dol_syslog($script_file." launched with arg ".implode(',',$argv));
60
+dol_syslog($script_file." launched with arg ".implode(',', $argv));
61 61
 
62 62
 $mode = $argv[1];
63 63
 $filepath = $argv[2];
64 64
 $filepatherr = $filepath.'.err';
65 65
 //$defaultlang = empty($argv[3])?'en_US':$argv[3];
66
-$startlinenb = empty($argv[3])?1:$argv[3];
67
-$endlinenb = empty($argv[4])?0:$argv[4];
66
+$startlinenb = empty($argv[3]) ? 1 : $argv[3];
67
+$endlinenb = empty($argv[4]) ? 0 : $argv[4];
68 68
 
69
-if (empty($mode) || ! in_array($mode,array('test','confirm','confirmforced')) || empty($filepath)) {
69
+if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) {
70 70
     print "Usage:  $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
71 71
     print "Usage:  $script_file test myfilepath.csv 2 1002\n";
72 72
     print "\n";
73 73
     exit(-1);
74 74
 }
75
-if (! file_exists($filepath)) {
75
+if (!file_exists($filepath)) {
76 76
     print "Error: File ".$filepath." not found.\n";
77 77
     print "\n";
78 78
     exit(-1);
79 79
 }
80 80
 
81
-$ret=$user->fetch('','admin');
82
-if (! $ret > 0)
81
+$ret = $user->fetch('', 'admin');
82
+if (!$ret > 0)
83 83
 {
84 84
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
85 85
 	exit;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 $user->getrights();
88 88
 
89 89
 // Ask confirmation
90
-if (! $confirmed)
90
+if (!$confirmed)
91 91
 {
92 92
     print "Hit Enter to continue or CTRL+C to stop...\n";
93 93
     $input = trim(fgets(STDIN));
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
 // Open input and ouput files
97 97
 $fhandle = fopen($filepath, 'r');
98
-if (! $fhandle)
98
+if (!$fhandle)
99 99
 {
100 100
     print 'Error: Failed to open file '.$filepath."\n";
101 101
     exit(1);
102 102
 }
103 103
 $fhandleerr = fopen($filepatherr, 'w');
104
-if (! $fhandleerr)
104
+if (!$fhandleerr)
105 105
 {
106 106
     print 'Error: Failed to open file '.$filepatherr."\n";
107 107
     exit(1);
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
 $db->begin();
114 114
 
115
-$i=0;
116
-$nboflines=0;
117
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
115
+$i = 0;
116
+$nboflines = 0;
117
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
118 118
 {
119 119
     $i++;
120
-    $errorrecord=0;
120
+    $errorrecord = 0;
121 121
 
122 122
     if ($startlinenb && $i < $startlinenb) continue;
123 123
     if ($endlinenb && $i > $endlinenb) continue;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
     $object = new User($db);
128 128
     $object->statut = 1;
129 129
 
130
-    $tmp=explode(' ',$fields[3],2);
130
+    $tmp = explode(' ', $fields[3], 2);
131 131
     $object->firstname = trim($tmp[0]);
132 132
     $object->lastname = trim($tmp[1]);
133
-    if ($object->lastname) $object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
134
-    else $object->login=strtolower($object->firstname);
135
-    $object->login=preg_replace('/ /','',$object->login);
133
+    if ($object->lastname) $object->login = strtolower(substr($object->firstname, 0, 1)).strtolower(substr($object->lastname, 0));
134
+    else $object->login = strtolower($object->firstname);
135
+    $object->login = preg_replace('/ /', '', $object->login);
136 136
     $object->password = 'init';
137 137
 
138 138
     print "Process line nb ".$i.", login ".$object->login;
139 139
 
140
-    $ret=$object->create($user);
140
+    $ret = $object->create($user);
141 141
     if ($ret < 0)
142 142
     {
143 143
         print " - Error in create result code = ".$ret." - ".$object->errorsToString();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	if ($errorrecord)
154 154
 	{
155 155
 	    fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
156
-	    $error++;    // $errorrecord will be reset
156
+	    $error++; // $errorrecord will be reset
157 157
 	}
158 158
 }
159 159
 
Please login to merge, or discard this patch.
dolibarr/dev/initdata/import-products.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 // Test si mode batch
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
33 33
     echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
34 34
     exit;
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/import-products.php/i','',$_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/import-products.php/i', '', $_SERVER["PHP_SELF"]);
39 39
 require $path."../../htdocs/master.inc.php";
40 40
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42 42
 
43
-$delimiter=',';
44
-$enclosure='"';
45
-$linelength=10000;
46
-$escape='/';
43
+$delimiter = ',';
44
+$enclosure = '"';
45
+$linelength = 10000;
46
+$escape = '/';
47 47
 
48 48
 // Global variables
49
-$version=DOL_VERSION;
50
-$confirmed=1;
51
-$error=0;
49
+$version = DOL_VERSION;
50
+$confirmed = 1;
51
+$error = 0;
52 52
 
53 53
 
54 54
 /*
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 
58 58
 @set_time_limit(0);
59 59
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
60
-dol_syslog($script_file." launched with arg ".implode(',',$argv));
60
+dol_syslog($script_file." launched with arg ".implode(',', $argv));
61 61
 
62 62
 $mode = $argv[1];
63 63
 $filepath = $argv[2];
64 64
 $filepatherr = $filepath.'.err';
65
-$defaultlang = empty($argv[3])?'en_US':$argv[3];
66
-$startlinenb = empty($argv[4])?1:$argv[4];
67
-$endlinenb = empty($argv[5])?0:$argv[5];
65
+$defaultlang = empty($argv[3]) ? 'en_US' : $argv[3];
66
+$startlinenb = empty($argv[4]) ? 1 : $argv[4];
67
+$endlinenb = empty($argv[5]) ? 0 : $argv[5];
68 68
 
69
-if (empty($mode) || ! in_array($mode,array('test','confirm','confirmforced')) || empty($filepath)) {
69
+if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) {
70 70
     print "Usage:  $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
71 71
     print "Usage:  $script_file test myfilepath.csv fr_FR 2 1002\n";
72 72
     print "\n";
73 73
     exit(-1);
74 74
 }
75
-if (! file_exists($filepath)) {
75
+if (!file_exists($filepath)) {
76 76
     print "Error: File ".$filepath." not found.\n";
77 77
     print "\n";
78 78
     exit(-1);
79 79
 }
80 80
 
81
-$ret=$user->fetch('','admin');
82
-if (! $ret > 0)
81
+$ret = $user->fetch('', 'admin');
82
+if (!$ret > 0)
83 83
 {
84 84
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
85 85
 	exit;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 $user->getrights();
88 88
 
89 89
 // Ask confirmation
90
-if (! $confirmed)
90
+if (!$confirmed)
91 91
 {
92 92
     print "Hit Enter to continue or CTRL+C to stop...\n";
93 93
     $input = trim(fgets(STDIN));
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
 // Open input and ouput files
97 97
 $fhandle = fopen($filepath, 'r');
98
-if (! $fhandle)
98
+if (!$fhandle)
99 99
 {
100 100
     print 'Error: Failed to open file '.$filepath."\n";
101 101
     exit(1);
102 102
 }
103 103
 $fhandleerr = fopen($filepatherr, 'w');
104
-if (! $fhandleerr)
104
+if (!$fhandleerr)
105 105
 {
106 106
     print 'Error: Failed to open file '.$filepatherr."\n";
107 107
     exit(1);
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
 $db->begin();
114 114
 
115
-$i=0;
115
+$i = 0;
116 116
 $nboflines++;
117
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
117
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
118 118
 {
119 119
     $i++;
120
-    $errorrecord=0;
120
+    $errorrecord = 0;
121 121
 
122 122
     if ($startlinenb && $i < $startlinenb) continue;
123 123
     if ($endlinenb && $i > $endlinenb) continue;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     $produit->volume = price2num($fields[8]);
136 136
     $produit->volume_unit = 0;
137 137
     $produit->weight = price2num($fields[9]);
138
-    $produit->weight_units = 0;          // -3 = g
138
+    $produit->weight_units = 0; // -3 = g
139 139
 
140 140
     $produit->customcode = $fields[10];
141 141
     $produit->barcode = $fields[1];
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
     $produit->cost_price = price2num($fields[16]);
157 157
 
158 158
     // Extrafields
159
-    $produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
159
+    $produit->array_options['options_ecotaxdeee'] = price2num($fields[17]);
160 160
 
161
-    $ret=$produit->create($user);
161
+    $ret = $produit->create($user);
162 162
     if ($ret < 0)
163 163
     {
164 164
         print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	dol_syslog("Add prices");
173 173
 
174 174
     // If we use price level, insert price for each level
175
-	if (! $errorrecord && 1)
175
+	if (!$errorrecord && 1)
176 176
 	{
177
-	    $ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
178
-	    $ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
177
+	    $ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
178
+	    $ret2 = $produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
179 179
 	    if ($ret1 < 0 || $ret2 < 0)
180 180
         {
181 181
             print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 	dol_syslog("Add multilangs");
191 191
 
192 192
 	// Add alternative languages
193
-	if (! $errorrecord && 1)
193
+	if (!$errorrecord && 1)
194 194
 	{
195
-    	$produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
196
-	    $produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
195
+    	$produit->multilangs['fr_FR'] = array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
196
+	    $produit->multilangs['en_US'] = array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
197 197
 
198
-    	$ret=$produit->setMultiLangs($user);
198
+    	$ret = $produit->setMultiLangs($user);
199 199
         if ($ret < 0)
200 200
         {
201 201
             print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	if ($errorrecord)
213 213
 	{
214 214
 	    fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
215
-	    $error++;    // $errorrecord will be reset
215
+	    $error++; // $errorrecord will be reset
216 216
 	}
217 217
 }
218 218
 
Please login to merge, or discard this patch.
dolibarr/dev/initdata/generate-product.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // Recupere root dolibarr
35 35
 //$path=preg_replace('/generate-produit.php/i','',$_SERVER["PHP_SELF"]);
36
-require __DIR__. '/../../htdocs/master.inc.php';
36
+require __DIR__.'/../../htdocs/master.inc.php';
37 37
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
38 38
 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
39 39
 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 define(GEN_NUMBER_PRODUIT, 100000);
50 50
 
51 51
 
52
-$ret=$user->fetch('','admin');
53
-if (! $ret > 0)
52
+$ret = $user->fetch('', 'admin');
53
+if (!$ret > 0)
54 54
 {
55 55
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
56 56
 	exit;
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
62
-$resql=$db->query($sql);
62
+$resql = $db->query($sql);
63 63
 if ($resql) {
64 64
   $num = $db->num_rows($resql); $i = 0;
65
-  while ($i < $num) {      $row = $db->fetch_row($resql);      $productsid[$i] = $row[0];      $i++; }
65
+  while ($i < $num) {      $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; }
66 66
 }
67 67
 
68 68
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
69
-$resql=$db->query($sql);
69
+$resql = $db->query($sql);
70 70
 if ($resql) {
71 71
 	$num = $db->num_rows($resql); $i = 0;
72
-    while ($i < $num) { $row = $db->fetch_row($resql);      $societesid[$i] = $row[0];      $i++; }
72
+    while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; }
73 73
 } else { print "err"; }
74 74
 
75 75
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
76
-$resql=$db->query($sql);
76
+$resql = $db->query($sql);
77 77
 if ($resql) {
78 78
 	$num = $db->num_rows($resql); $i = 0;
79
-    while ($i < $num) { $row = $db->fetch_row($resql);      $commandesid[$i] = $row[0];      $i++; }
79
+    while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; }
80 80
 } else { print "err"; }
81 81
 
82 82
 
83 83
 print "Generates ".GEN_NUMBER_PRODUIT." products\n";
84
-for ($s = 0 ; $s < GEN_NUMBER_PRODUIT ; $s++)
84
+for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++)
85 85
 {
86 86
     print "Product ".$s;
87 87
     $produit = new Product($db);
88
-    $produit->type = mt_rand(0,1);
88
+    $produit->type = mt_rand(0, 1);
89 89
     $produit->status = 1;
90
-    $produit->ref = ($produit->type?'S':'P').time().$s;
90
+    $produit->ref = ($produit->type ? 'S' : 'P').time().$s;
91 91
     $produit->label = 'Label '.time().$s;
92 92
     $produit->description = 'Description '.time().$s;
93
-    $produit->price = mt_rand(1,1000);
93
+    $produit->price = mt_rand(1, 1000);
94 94
     $produit->tva_tx = "19.6";
95
-    $ret=$produit->create($user);
95
+    $ret = $produit->create($user);
96 96
     if ($ret < 0) print "Error $ret - ".$produit->error."\n";
97 97
 	else print " OK with ref ".$produit->ref."\n";
98 98
 }
Please login to merge, or discard this patch.
dolibarr/dev/initdata/generate-proposal.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // Recupere root dolibarr
35 35
 //$path=preg_replace('/generate-propale.php/i','',$_SERVER["PHP_SELF"]);
36
-require __DIR__. '/../../htdocs/master.inc.php';
36
+require __DIR__.'/../../htdocs/master.inc.php';
37 37
 require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
38 38
 require_once DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php";
39 39
 require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
@@ -45,60 +45,60 @@  discard block
 block discarded – undo
45 45
 
46 46
 define(GEN_NUMBER_PROPAL, 10);
47 47
 $year = 2016;
48
-$dates = array (mktime(12,0,0,1,3,$year),
49
-    mktime(12,0,0,1,9,$year),
50
-    mktime(12,0,0,2,13,$year),
51
-    mktime(12,0,0,2,23,$year),
52
-    mktime(12,0,0,3,30,$year),
53
-    mktime(12,0,0,4,3,$year),
54
-    mktime(12,0,0,4,3,$year),
55
-    mktime(12,0,0,5,9,$year),
56
-    mktime(12,0,0,5,1,$year),
57
-    mktime(12,0,0,5,13,$year),
58
-    mktime(12,0,0,5,19,$year),
59
-    mktime(12,0,0,5,23,$year),
60
-    mktime(12,0,0,6,3,$year),
61
-    mktime(12,0,0,6,19,$year),
62
-    mktime(12,0,0,6,24,$year),
63
-    mktime(12,0,0,7,3,$year),
64
-    mktime(12,0,0,7,9,$year),
65
-    mktime(12,0,0,7,23,$year),
66
-    mktime(12,0,0,7,30,$year),
67
-    mktime(12,0,0,8,9,$year),
68
-    mktime(12,0,0,9,23,$year),
69
-    mktime(12,0,0,10,3,$year),
70
-    mktime(12,0,0,11,12,$year),
71
-    mktime(12,0,0,11,13,$year),
72
-    mktime(12,0,0,1,3,($year - 1)),
73
-    mktime(12,0,0,1,9,($year - 1)),
74
-    mktime(12,0,0,2,13,($year - 1)),
75
-    mktime(12,0,0,2,23,($year - 1)),
76
-    mktime(12,0,0,3,30,($year - 1)),
77
-    mktime(12,0,0,4,3,($year - 1)),
78
-    mktime(12,0,0,4,3,($year - 1)),
79
-    mktime(12,0,0,5,9,($year - 1)),
80
-    mktime(12,0,0,5,1,($year - 1)),
81
-    mktime(12,0,0,5,13,($year - 1)),
82
-    mktime(12,0,0,5,19,($year - 1)),
83
-    mktime(12,0,0,5,23,($year - 1)),
84
-    mktime(12,0,0,6,3,($year - 1)),
85
-    mktime(12,0,0,6,19,($year - 1)),
86
-    mktime(12,0,0,6,24,($year - 1)),
87
-    mktime(12,0,0,7,3,($year - 1)),
88
-    mktime(12,0,0,7,9,($year - 1)),
89
-    mktime(12,0,0,7,23,($year - 1)),
90
-    mktime(12,0,0,7,30,($year - 1)),
91
-    mktime(12,0,0,8,9,($year - 1)),
92
-    mktime(12,0,0,9,23,($year - 1)),
93
-    mktime(12,0,0,10,3,($year - 1)),
94
-    mktime(12,0,0,11,12,$year),
95
-    mktime(12,0,0,11,13,$year),
96
-    mktime(12,0,0,12,12,$year),
97
-    mktime(12,0,0,12,13,$year),
48
+$dates = array(mktime(12, 0, 0, 1, 3, $year),
49
+    mktime(12, 0, 0, 1, 9, $year),
50
+    mktime(12, 0, 0, 2, 13, $year),
51
+    mktime(12, 0, 0, 2, 23, $year),
52
+    mktime(12, 0, 0, 3, 30, $year),
53
+    mktime(12, 0, 0, 4, 3, $year),
54
+    mktime(12, 0, 0, 4, 3, $year),
55
+    mktime(12, 0, 0, 5, 9, $year),
56
+    mktime(12, 0, 0, 5, 1, $year),
57
+    mktime(12, 0, 0, 5, 13, $year),
58
+    mktime(12, 0, 0, 5, 19, $year),
59
+    mktime(12, 0, 0, 5, 23, $year),
60
+    mktime(12, 0, 0, 6, 3, $year),
61
+    mktime(12, 0, 0, 6, 19, $year),
62
+    mktime(12, 0, 0, 6, 24, $year),
63
+    mktime(12, 0, 0, 7, 3, $year),
64
+    mktime(12, 0, 0, 7, 9, $year),
65
+    mktime(12, 0, 0, 7, 23, $year),
66
+    mktime(12, 0, 0, 7, 30, $year),
67
+    mktime(12, 0, 0, 8, 9, $year),
68
+    mktime(12, 0, 0, 9, 23, $year),
69
+    mktime(12, 0, 0, 10, 3, $year),
70
+    mktime(12, 0, 0, 11, 12, $year),
71
+    mktime(12, 0, 0, 11, 13, $year),
72
+    mktime(12, 0, 0, 1, 3, ($year - 1)),
73
+    mktime(12, 0, 0, 1, 9, ($year - 1)),
74
+    mktime(12, 0, 0, 2, 13, ($year - 1)),
75
+    mktime(12, 0, 0, 2, 23, ($year - 1)),
76
+    mktime(12, 0, 0, 3, 30, ($year - 1)),
77
+    mktime(12, 0, 0, 4, 3, ($year - 1)),
78
+    mktime(12, 0, 0, 4, 3, ($year - 1)),
79
+    mktime(12, 0, 0, 5, 9, ($year - 1)),
80
+    mktime(12, 0, 0, 5, 1, ($year - 1)),
81
+    mktime(12, 0, 0, 5, 13, ($year - 1)),
82
+    mktime(12, 0, 0, 5, 19, ($year - 1)),
83
+    mktime(12, 0, 0, 5, 23, ($year - 1)),
84
+    mktime(12, 0, 0, 6, 3, ($year - 1)),
85
+    mktime(12, 0, 0, 6, 19, ($year - 1)),
86
+    mktime(12, 0, 0, 6, 24, ($year - 1)),
87
+    mktime(12, 0, 0, 7, 3, ($year - 1)),
88
+    mktime(12, 0, 0, 7, 9, ($year - 1)),
89
+    mktime(12, 0, 0, 7, 23, ($year - 1)),
90
+    mktime(12, 0, 0, 7, 30, ($year - 1)),
91
+    mktime(12, 0, 0, 8, 9, ($year - 1)),
92
+    mktime(12, 0, 0, 9, 23, ($year - 1)),
93
+    mktime(12, 0, 0, 10, 3, ($year - 1)),
94
+    mktime(12, 0, 0, 11, 12, $year),
95
+    mktime(12, 0, 0, 11, 13, $year),
96
+    mktime(12, 0, 0, 12, 12, $year),
97
+    mktime(12, 0, 0, 12, 13, $year),
98 98
 );
99 99
 
100
-$ret=$user->fetch('','admin');
101
-if (! $ret > 0)
100
+$ret = $user->fetch('', 'admin');
101
+if (!$ret > 0)
102 102
 {
103 103
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
104 104
 	exit;
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 }
153 153
 
154
-$user->rights->propal->creer=1;
155
-$user->rights->propal->propal_advance->validate=1;
154
+$user->rights->propal->creer = 1;
155
+$user->rights->propal->propal_advance->validate = 1;
156 156
 
157 157
 
158
-if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
158
+if (!empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
159 159
 {
160
-	require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php";
160
+	require_once DOL_DOCUMENT_ROOT."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php";
161 161
 }
162 162
 
163
-$i=0;
164
-$result=0;
163
+$i = 0;
164
+$result = 0;
165 165
 while ($i < GEN_NUMBER_PROPAL && $result >= 0)
166 166
 {
167 167
 	$i++;
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 	$object = new Propal($db);
175 175
 
176 176
     $fuser = new User($db);
177
-    $fuser->fetch(mt_rand(1,2));
177
+    $fuser->fetch(mt_rand(1, 2));
178 178
     $fuser->getRights();
179 179
     
180 180
 	$object->contactid = $contids[$socids[$socid]][0];
181 181
 	$object->socid = $socids[$socid];
182
-	$object->datep = $dates[mt_rand(1, count($dates)-1)];
182
+	$object->datep = $dates[mt_rand(1, count($dates) - 1)];
183 183
 	$object->cond_reglement_id = 3;
184 184
 	$object->mode_reglement_id = 3;
185 185
 
186
-	$result=$object->create($fuser);
186
+	$result = $object->create($fuser);
187 187
 	if ($result >= 0)
188 188
 	{
189 189
 		$nbp = mt_rand(2, 5);
@@ -191,17 +191,17 @@  discard block
 block discarded – undo
191 191
 		while ($xnbp < $nbp)
192 192
 		{
193 193
 			$prodid = mt_rand(1, $num_prods);
194
-			$product=new Product($db);
195
-			$result=$product->fetch($prodids[$prodid]);
196
-			$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
194
+			$product = new Product($db);
195
+			$result = $product->fetch($prodids[$prodid]);
196
+			$result = $object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0);
197 197
 			if ($result < 0)
198 198
 			{
199
-				dol_print_error($db,$object->error);
199
+				dol_print_error($db, $object->error);
200 200
 			}
201 201
 			$xnbp++;
202 202
 		}
203 203
 		
204
-		$result=$object->valid($fuser);
204
+		$result = $object->valid($fuser);
205 205
 		if ($result > 0)
206 206
 		{
207 207
 		    $db->commit();
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 		{
212 212
 		    print " KO\n";
213 213
 		    $db->rollback();
214
-		    dol_print_error($db,$object->error);
214
+		    dol_print_error($db, $object->error);
215 215
 		}
216 216
 	}
217 217
 	else
218 218
 	{
219
-		dol_print_error($db,$object->error);
219
+		dol_print_error($db, $object->error);
220 220
 	}
221 221
 }
Please login to merge, or discard this patch.
dolibarr/scripts/emailings/mailing-send.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 
33 33
 // Test if batch mode
34 34
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	exit(-1);
37 37
 }
38 38
 
39
-if (! isset($argv[1]) || ! $argv[1]) {
39
+if (!isset($argv[1]) || !$argv[1]) {
40 40
 	print "Usage: ".$script_file." (ID_MAILING|all)\n";
41 41
 	exit(-1);
42 42
 }
43
-$id=$argv[1];
43
+$id = $argv[1];
44 44
 if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2];
45 45
 else $login = '';
46 46
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
 // Global variables
53
-$version=DOL_VERSION;
54
-$error=0;
53
+$version = DOL_VERSION;
54
+$error = 0;
55 55
 
56 56
 
57 57
 
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 
69 69
 $user = new User($db);
70 70
 // for signature, we use user send as parameter
71
-if (! empty($login)) $user->fetch('',$login);
71
+if (!empty($login)) $user->fetch('', $login);
72 72
 
73 73
 // We get list of emailing id to process
74 74
 $sql = "SELECT m.rowid";
75
-$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
76
-$sql.= " WHERE m.statut IN (1,2)";
75
+$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
76
+$sql .= " WHERE m.statut IN (1,2)";
77 77
 if ($id != 'all')
78 78
 {
79
-	$sql.= " AND m.rowid= ".$id;
80
-	$sql.= " LIMIT 1";
79
+	$sql .= " AND m.rowid= ".$id;
80
+	$sql .= " LIMIT 1";
81 81
 }
82 82
 
83
-$resql=$db->query($sql);
83
+$resql = $db->query($sql);
84 84
 if ($resql)
85 85
 {
86 86
 	$num = $db->num_rows($resql);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
 	if ($num)
90 90
 	{
91
-		for ($j=0; $j<$num; $j++)
91
+		for ($j = 0; $j < $num; $j++)
92 92
 		{
93 93
 			$obj = $db->fetch_object($resql);
94 94
 
@@ -105,22 +105,22 @@  discard block
 block discarded – undo
105 105
 			$replyto  = $emailing->email_replyto;
106 106
 			$errorsto = $emailing->email_errorsto;
107 107
 			// Le message est-il en html
108
-			$msgishtml=-1;  // Unknown by default
109
-			if (preg_match('/[\s\t]*<html>/i',$message)) $msgishtml=1;
108
+			$msgishtml = -1; // Unknown by default
109
+			if (preg_match('/[\s\t]*<html>/i', $message)) $msgishtml = 1;
110 110
 
111
-			$nbok=0; $nbko=0;
111
+			$nbok = 0; $nbko = 0;
112 112
 
113 113
 			// On choisit les mails non deja envoyes pour ce mailing (statut=0)
114 114
 			// ou envoyes en erreur (statut=-1)
115 115
 			$sql2 = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
116
-			$sql2.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
117
-			$sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
116
+			$sql2 .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
117
+			$sql2 .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
118 118
 			if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0)
119 119
 			{
120
-				$sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
120
+				$sql2 .= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
121 121
 			}
122 122
 
123
-			$resql2=$db->query($sql2);
123
+			$resql2 = $db->query($sql2);
124 124
 			if ($resql2)
125 125
 			{
126 126
 				$num2 = $db->num_rows($resql2);
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 
130 130
 				if ($num2)
131 131
 				{
132
-					$now=dol_now();
132
+					$now = dol_now();
133 133
 
134 134
 					// Positionne date debut envoi
135
-					$sqlstartdate="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$id;
136
-					$resqlstartdate=$db->query($sqlstartdate);
137
-					if (! $resqlstartdate)
135
+					$sqlstartdate = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$id;
136
+					$resqlstartdate = $db->query($sqlstartdate);
137
+					if (!$resqlstartdate)
138 138
 					{
139 139
 						dol_print_error($db);
140 140
 						$error++;
@@ -145,26 +145,26 @@  discard block
 block discarded – undo
145 145
 					while ($i < $num2)
146 146
 					{
147 147
 						// Here code is common with same loop ino card.php
148
-						$res=1;
149
-						$now=dol_now();
148
+						$res = 1;
149
+						$now = dol_now();
150 150
 
151 151
 						$obj = $db->fetch_object($resql2);
152 152
 
153 153
 						// sendto en RFC2822
154
-						$sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname) ." <".$obj->email.">");
154
+						$sendto = str_replace(',', ' ', dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">");
155 155
 
156 156
 						// Make subtsitutions on topic and body
157
-						$other=explode(';',$obj->other);
158
-						$tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
159
-						$tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
160
-						$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
161
-						$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
162
-						$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
163
-						$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
164
-
165
-						$object = null;		// Not defined with mass emailing
166
-						$parameters=array('mode'=>'emailing');
167
-						$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object);			// Note: On mass emailing, this is null because we don't know object
157
+						$other = explode(';', $obj->other);
158
+						$tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
159
+						$tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
160
+						$tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
161
+						$tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
162
+						$tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
163
+						$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : '');
164
+
165
+						$object = null; // Not defined with mass emailing
166
+						$parameters = array('mode'=>'emailing');
167
+						$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $object); // Note: On mass emailing, this is null because we don't know object
168 168
 
169 169
 						// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
170 170
 						$substitutionarray['__ID__'] = $obj->source_id;
@@ -177,59 +177,59 @@  discard block
 block discarded – undo
177 177
 						$substitutionarray['__OTHER3__'] = $other3;
178 178
 						$substitutionarray['__OTHER4__'] = $other4;
179 179
 						$substitutionarray['__OTHER5__'] = $other5;
180
-						$substitutionarray['__USER_SIGNATURE__'] = $signature;	// Signature is empty when ran from command line or taken from user in parameter)
181
-						$substitutionarray['__SIGNATURE__'] = $signature;	// For backward compatibility
180
+						$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
181
+						$substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility
182 182
 						$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
183 183
 						$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
184 184
 
185 185
 						$onlinepaymentenabled = 0;
186
-						if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
187
-						if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
188
-						if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
189
-						if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
186
+						if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++;
187
+						if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++;
188
+						if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++;
189
+						if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN))
190 190
 						{
191
-							$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
191
+							$substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
192 192
 							if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
193 193
 							{
194
-								$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
195
-								$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
196
-								$substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
197
-								$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
194
+								$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
195
+								$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
196
+								$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
197
+								$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
198 198
 							}
199 199
 							else
200 200
 							{
201
-								$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
202
-								$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
203
-								$substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
204
-								$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
201
+								$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
202
+								$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2);
203
+								$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
204
+								$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
205 205
 							}
206 206
 						}
207 207
 						/* For backward compatibility */
208
-						if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
208
+						if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN))
209 209
 						{
210
-							$substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
210
+							$substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
211 211
 
212
-							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
213
-							else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
212
+							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
213
+							else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
214 214
 
215
-							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
216
-							else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
215
+							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
216
+							else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2);
217 217
 
218
-							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
219
-							else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
218
+							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
219
+							else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
220 220
 
221
-							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
222
-							else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
221
+							if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
222
+							else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
223 223
 						}
224 224
 
225
-						complete_substitutions_array($substitutionarray,$langs);
226
-						$newsubject=make_substitutions($subject,$substitutionarray);
227
-						$newmessage=make_substitutions($message,$substitutionarray);
225
+						complete_substitutions_array($substitutionarray, $langs);
226
+						$newsubject = make_substitutions($subject, $substitutionarray);
227
+						$newmessage = make_substitutions($message, $substitutionarray);
228 228
 
229
-						$substitutionisok=true;
229
+						$substitutionisok = true;
230 230
 
231 231
 						// Fabrication du mail
232
-						$trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid;
232
+						$trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid;
233 233
 						$mail = new CMailFile(
234 234
 							$newsubject,
235 235
 							$sendto,
@@ -251,18 +251,18 @@  discard block
 block discarded – undo
251 251
 
252 252
 						if ($mail->error)
253 253
 						{
254
-							$res=0;
254
+							$res = 0;
255 255
 						}
256
-						if (! $substitutionisok)
256
+						if (!$substitutionisok)
257 257
 						{
258
-							$mail->error='Some substitution failed';
259
-							$res=0;
258
+							$mail->error = 'Some substitution failed';
259
+							$res = 0;
260 260
 						}
261 261
 
262 262
 						// Send Email
263 263
 						if ($res)
264 264
 						{
265
-							$res=$mail->sendfile();
265
+							$res = $mail->sendfile();
266 266
 						}
267 267
 
268 268
 						if ($res)
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 							// Mail successful
271 271
 							$nbok++;
272 272
 
273
-							dol_syslog("ok for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
273
+							dol_syslog("ok for emailing id ".$id." #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG);
274 274
 
275 275
 							// Note: If emailing is 100 000 targets, 100 000 entries are added, so we don't enter events for each target here
276 276
 							// We must union table llx_mailing_taget for event tab OR enter 1 event with a special table link (id of email in event)
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
                             // End call triggers
291 291
 						    */
292 292
 
293
-							$sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
294
-							$sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
295
-							$resqlok=$db->query($sqlok);
296
-							if (! $resqlok)
293
+							$sqlok = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
294
+							$sqlok .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
295
+							$resqlok = $db->query($sqlok);
296
+							if (!$resqlok)
297 297
 							{
298 298
 								dol_print_error($db);
299 299
 								$error++;
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 									//Update status communication of thirdparty prospect
307 307
 									$sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")";
308 308
 									dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG);
309
-									$resqlx=$db->query($sqlx);
310
-									if (! $resqlx)
309
+									$resqlx = $db->query($sqlx);
310
+									if (!$resqlx)
311 311
 									{
312 312
 										dol_print_error($db);
313 313
 										$error++;
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 									$sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
318 318
 									dol_syslog("card.php: set prospect contact status", LOG_DEBUG);
319 319
 
320
-									$resqlx=$db->query($sqlx);
321
-									if (! $resqlx)
320
+									$resqlx = $db->query($sqlx);
321
+									if (!$resqlx)
322 322
 									{
323 323
 										dol_print_error($db);
324 324
 										$error++;
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
 							// Mail failed
336 336
 							$nbko++;
337 337
 
338
-							dol_syslog("error for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
338
+							dol_syslog("error for emailing id ".$id." #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG);
339 339
 
340
-							$sqlerror="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
341
-							$sqlerror.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
342
-							$resqlerror=$db->query($sqlerror);
343
-							if (! $resqlerror)
340
+							$sqlerror = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
341
+							$sqlerror .= " SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
342
+							$resqlerror = $db->query($sqlerror);
343
+							if (!$resqlerror)
344 344
 							{
345 345
 								dol_print_error($db);
346 346
 								$error++;
@@ -352,21 +352,21 @@  discard block
 block discarded – undo
352 352
 				}
353 353
 				else
354 354
 				{
355
-					$mesg="Emailing id ".$id." has no recipient to target";
355
+					$mesg = "Emailing id ".$id." has no recipient to target";
356 356
 					print $mesg."\n";
357
-					dol_syslog($mesg,LOG_ERR);
357
+					dol_syslog($mesg, LOG_ERR);
358 358
 				}
359 359
 
360 360
 				// Loop finished, set global statut of mail
361
-				$statut=2;
362
-				if (! $nbko) $statut=3;
361
+				$statut = 2;
362
+				if (!$nbko) $statut = 3;
363 363
 
364
-				$sqlenddate="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
364
+				$sqlenddate = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
365 365
 
366 366
 				dol_syslog("update global status", LOG_DEBUG);
367 367
 				print "Update status of emailing id ".$id." to ".$statut."\n";
368
-				$resqlenddate=$db->query($sqlenddate);
369
-				if (! $resqlenddate)
368
+				$resqlenddate = $db->query($sqlenddate);
369
+				if (!$resqlenddate)
370 370
 				{
371 371
 					dol_print_error($db);
372 372
 					$error++;
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 	}
382 382
 	else
383 383
 	{
384
-		$mesg="No validated emailing id to send found.";
384
+		$mesg = "No validated emailing id to send found.";
385 385
 		print $mesg."\n";
386
-		dol_syslog($mesg,LOG_ERR);
386
+		dol_syslog($mesg, LOG_ERR);
387 387
 		$error++;
388 388
 	}
389 389
 }
Please login to merge, or discard this patch.
dolibarr/scripts/accountancy/export-thirdpartyaccount.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 		// We define date_start and date_end
58 58
 		$year_end = $year_start;
59 59
 		$month_start = GETPOST("month") ? GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
60
-		if (! GETPOST('month')) {
61
-			if (! GETPOST("year") && $month_start > $month_current) {
62
-				$year_start --;
63
-				$year_end --;
60
+		if (!GETPOST('month')) {
61
+			if (!GETPOST("year") && $month_start > $month_current) {
62
+				$year_start--;
63
+				$year_end--;
64 64
 			}
65 65
 			$month_end = $month_start - 1;
66 66
 			if ($month_end < 1)
67 67
 				$month_end = 12;
68 68
 			else
69
-				$year_end ++;
69
+				$year_end++;
70 70
 		} else
71 71
 			$month_end = $month_start;
72 72
 		$date_start = dol_get_first_day($year_start, $month_start, false);
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 $exportlink = '';
101 101
 
102 102
 $nom = $langs->trans("ReportThirdParty");
103
-$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
103
+$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
104 104
 $description = $langs->trans("DescThirdPartyReport");
105
-$builddate=dol_now();
105
+$builddate = dol_now();
106 106
 
107
-$moreparam=array('action' => '');
107
+$moreparam = array('action' => '');
108 108
 report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam);
109 109
 
110 110
 print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
@@ -121,58 +121,58 @@  discard block
 block discarded – undo
121 121
 
122 122
 $sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta as compta , ";
123 123
 $sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax ,   f.datec , f.fk_soc , cp.label as country ";
124
-$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
125
-$sql .= ", " . MAIN_DB_PREFIX . "facture as f";
126
-$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp";
124
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
125
+$sql .= ", ".MAIN_DB_PREFIX."facture as f";
126
+$sql .= ", ".MAIN_DB_PREFIX."c_country as cp";
127 127
 $sql .= " WHERE f.fk_soc = s.rowid";
128 128
 $sql .= " AND s.fk_pays = cp.rowid";
129
-if (! empty($date_start) && ! empty($date_end))
130
-	$sql .= " AND f.datec >= '" . $db->idate($date_start) . "' AND f.datec <= '" . $db->idate($date_end) . "'";
131
-$sql .= " AND f.entity = " . $conf->entity;
129
+if (!empty($date_start) && !empty($date_end))
130
+	$sql .= " AND f.datec >= '".$db->idate($date_start)."' AND f.datec <= '".$db->idate($date_end)."'";
131
+$sql .= " AND f.entity = ".$conf->entity;
132 132
 if ($socid)
133
-	$sql .= " AND f.fk_soc = " . $socid;
133
+	$sql .= " AND f.fk_soc = ".$socid;
134 134
 $sql .= " GROUP BY name";
135 135
 $sql .= ")";
136 136
 $sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta_fournisseur as compta , ";
137 137
 $sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax ,   ff.datec , ff.fk_soc , cp.label as country ";
138
-$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
139
-$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as ff";
140
-$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp";
138
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
139
+$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as ff";
140
+$sql .= ", ".MAIN_DB_PREFIX."c_country as cp";
141 141
 $sql .= " WHERE ff.fk_soc = s.rowid";
142 142
 $sql .= " AND s.fk_pays = cp.rowid";
143
-if (! empty($date_start) && ! empty($date_end))
144
-	$sql .= " AND ff.datec >= '" . $db->idate($date_start) . "' AND ff.datec <= '" . $db->idate($date_end) . "'";
145
-$sql .= " AND ff.entity = " . $conf->entity;
143
+if (!empty($date_start) && !empty($date_end))
144
+	$sql .= " AND ff.datec >= '".$db->idate($date_start)."' AND ff.datec <= '".$db->idate($date_end)."'";
145
+$sql .= " AND ff.entity = ".$conf->entity;
146 146
 if ($socid)
147
-	$sql .= " AND f.fk_soc = " . $socid;
147
+	$sql .= " AND f.fk_soc = ".$socid;
148 148
 $sql .= " GROUP BY name";
149 149
 $sql .= ")";
150 150
 
151 151
 $sql .= "ORDER BY name ASC";
152 152
 
153
-dol_syslog('accountancy/admin/thirdpartyaccount.php:: $sql=' . $sql);
153
+dol_syslog('accountancy/admin/thirdpartyaccount.php:: $sql='.$sql);
154 154
 $resql = $db->query($sql);
155 155
 if ($resql) {
156 156
 	$num = $db->num_rows($resql);
157 157
 	$i = 0;
158 158
 
159 159
 	// export csv
160
-	if (GETPOST('action','aZ09') == 'export_csv') {
160
+	if (GETPOST('action', 'aZ09') == 'export_csv') {
161 161
 
162 162
 		header('Content-Type: text/csv');
163 163
 		header('Content-Disposition: attachment;filename=export_csv.csv');
164 164
 
165 165
 		$obj = $db->fetch_object($resql);
166 166
 
167
-		print '"' . $obj->compta . '",';
168
-		print '"' . $obj->address . '",';
169
-		print '"' . $obj->zip . '",';
170
-		print '"' . $obj->town . '",';
171
-		print '"' . $obj->country . '",';
172
-		print '"' . $obj->phone . '",';
173
-		print '"' . $obj->fax . '",';
167
+		print '"'.$obj->compta.'",';
168
+		print '"'.$obj->address.'",';
169
+		print '"'.$obj->zip.'",';
170
+		print '"'.$obj->town.'",';
171
+		print '"'.$obj->country.'",';
172
+		print '"'.$obj->phone.'",';
173
+		print '"'.$obj->fax.'",';
174 174
 		print "\n";
175
-		$i ++;
175
+		$i++;
176 176
 	}
177 177
 
178 178
 	/*
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 	print '</td><td valign="top" width="70%" class="notopnoleftnoright"></td>';
189 189
 	print '</tr><tr><td colspan=2>';
190 190
 	print '<table class="noborder" width="100%">';
191
-	print '<tr class="liste_titre"><td align="left">' . $langs->trans("ThirdParties") . '</td>';
192
-	print '<td align="left">' . $langs->trans("AccountNumber") . '</td>';
193
-	print '<td align="left">' . $langs->trans("RaisonSociale") . '</td>';
194
-	print '<td align="left">' . $langs->trans("Address") . '</td>';
195
-	print '<td align="left">' . $langs->trans("Zip") . '</td>';
196
-	print '<td align="left">' . $langs->trans("Town") . '</td>';
197
-	print '<td align="left">' . $langs->trans("Country") . '</td>';
198
-	print '<td align="left">' . $langs->trans("Contact") . '</td>';
199
-	print '<td align="left">' . $langs->trans("Phone") . '</td>';
200
-	print '<td align="left">' . $langs->trans("Fax") . '</td></tr>';
191
+	print '<tr class="liste_titre"><td align="left">'.$langs->trans("ThirdParties").'</td>';
192
+	print '<td align="left">'.$langs->trans("AccountNumber").'</td>';
193
+	print '<td align="left">'.$langs->trans("RaisonSociale").'</td>';
194
+	print '<td align="left">'.$langs->trans("Address").'</td>';
195
+	print '<td align="left">'.$langs->trans("Zip").'</td>';
196
+	print '<td align="left">'.$langs->trans("Town").'</td>';
197
+	print '<td align="left">'.$langs->trans("Country").'</td>';
198
+	print '<td align="left">'.$langs->trans("Contact").'</td>';
199
+	print '<td align="left">'.$langs->trans("Phone").'</td>';
200
+	print '<td align="left">'.$langs->trans("Fax").'</td></tr>';
201 201
 
202 202
 	while ($obj = $db->fetch_object($resql))
203 203
 	{
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 		$thirdpartystatic->status = $obj->status;
211 211
 		print $thirdpartystatic->getNomUrl(1);
212 212
 		print '</td>';
213
-		print '<td align="left">' . $obj->compta . '</td>' . "\n";
213
+		print '<td align="left">'.$obj->compta.'</td>'."\n";
214 214
 		print '<td align="left"></td>';
215
-		print '<td align="left">' . $obj->address . '</td>';
216
-		print '<td align="left">' . $obj->zip . '</td>';
217
-		print '<td align="left">' . $obj->town . '</td>';
218
-		print '<td align="left">' . $obj->country . '</td>';
215
+		print '<td align="left">'.$obj->address.'</td>';
216
+		print '<td align="left">'.$obj->zip.'</td>';
217
+		print '<td align="left">'.$obj->town.'</td>';
218
+		print '<td align="left">'.$obj->country.'</td>';
219 219
 		print '<td align="left"></td>';
220
-		print '<td align="left">' . $obj->phone . '</td>';
221
-		print '<td align="left">' . $obj->fax . '</td>';
220
+		print '<td align="left">'.$obj->phone.'</td>';
221
+		print '<td align="left">'.$obj->fax.'</td>';
222 222
 		print "</tr>\n";
223 223
 
224
-		$i ++;
224
+		$i++;
225 225
 	}
226 226
 
227 227
 	print "</table>";
Please login to merge, or discard this patch.
dolibarr/scripts/withdrawals/build_withdrawal_file.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 $sapi_type = php_sapi_name();
28 28
 $script_file = basename(__FILE__);
29
-$path=dirname(__FILE__).'/';
29
+$path = dirname(__FILE__).'/';
30 30
 
31 31
 // Test if batch mode
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php";
42 42
 
43 43
 // Global variables
44
-$version=DOL_VERSION;
45
-$error=0;
44
+$version = DOL_VERSION;
45
+$error = 0;
46 46
 
47 47
 
48 48
 /*
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 @set_time_limit(0);
53 53
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
54
-dol_syslog($script_file." launched with arg ".join(',',$argv));
54
+dol_syslog($script_file." launched with arg ".join(',', $argv));
55 55
 
56 56
 $datetimeprev = dol_now();
57 57
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 $user = new user($db);
62 62
 $user->fetch($conf->global->PRELEVEMENT_USER);
63 63
 
64
-if (! isset($argv[1])) {	// Check parameters
64
+if (!isset($argv[1])) {	// Check parameters
65 65
     print "This script check invoices with a withdrawal request and\n";
66 66
     print "then create payment and build a withdraw file.\n";
67 67
 	print "Usage: ".$script_file." simu|real\n";
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 
72
-$withdrawreceipt=new BonPrelevement($db);
72
+$withdrawreceipt = new BonPrelevement($db);
73 73
 // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
74
-$result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->global->PRELEVEMENT_CODE_GUICHET,$argv[1]);
74
+$result = $withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $argv[1]);
75 75
 
76 76
 
77 77
 $db->close();
Please login to merge, or discard this patch.
dolibarr/scripts/cron/cron_run_jobs.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    cron
24 24
  *  \brief      Execute pendings jobs
25 25
  */
26
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
27
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
28
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
29
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
30
-if (! defined('NOLOGIN'))        define('NOLOGIN','1');
26
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
27
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
28
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
29
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
30
+if (!defined('NOLOGIN'))        define('NOLOGIN', '1');
31 31
 //if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
32 32
 
33 33
 
34 34
 $sapi_type = php_sapi_name();
35 35
 $script_file = basename(__FILE__);
36
-$path=dirname(__FILE__).'/';
36
+$path = dirname(__FILE__).'/';
37 37
 
38 38
 // Test if batch mode
39 39
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
47 47
 
48 48
 // Check parameters
49
-if (! isset($argv[1]) || ! $argv[1]) {
50
-	usage($path,$script_file);
49
+if (!isset($argv[1]) || !$argv[1]) {
50
+	usage($path, $script_file);
51 51
 	exit(-1);
52 52
 }
53
-$key=$argv[1];
53
+$key = $argv[1];
54 54
 
55
-if (! isset($argv[2]) || ! $argv[2]) {
56
-	usage($path,$script_file);
55
+if (!isset($argv[2]) || !$argv[2]) {
56
+	usage($path, $script_file);
57 57
 	exit(-1);
58 58
 }
59 59
 
60
-$userlogin=$argv[2];
60
+$userlogin = $argv[2];
61 61
 
62 62
 
63 63
 // Global variables
64
-$version=DOL_VERSION;
65
-$error=0;
64
+$version = DOL_VERSION;
65
+$error = 0;
66 66
 
67 67
 
68 68
 /*
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
  */
71 71
 
72 72
 // current date
73
-$now=dol_now();
73
+$now = dol_now();
74 74
 
75 75
 @set_time_limit(0);
76
-print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . dol_print_date($now, 'dayhourrfc') . " *****\n";
76
+print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=".$userlogin." ***** ".dol_print_date($now, 'dayhourrfc')." *****\n";
77 77
 
78 78
 // Check module cron is activated
79 79
 if (empty($conf->cron->enabled))
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 // If param userlogin is reserved word 'firstadmin'
100 100
 if ($userlogin == 'firstadmin')
101 101
 {
102
-    $sql='SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1';
103
-    $resql=$db->query($sql);
102
+    $sql = 'SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1';
103
+    $resql = $db->query($sql);
104 104
     if ($resql)
105 105
     {
106
-        $obj=$db->fetch_object($resql);
106
+        $obj = $db->fetch_object($resql);
107 107
         if ($obj)
108 108
         {
109 109
             $userlogin = $obj->login;
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 }
115 115
 
116 116
 // Check user login
117
-$user=new User($db);
118
-$result=$user->fetch('',$userlogin);
117
+$user = new User($db);
118
+$result = $user->fetch('', $userlogin);
119 119
 if ($result < 0)
120 120
 {
121 121
 	echo "User Error: ".$user->error;
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 // create a jobs object
142 142
 $object = new Cronjob($db);
143 143
 
144
-$filter=array();
145
-if (! empty($id)) {
146
-	if (! is_numeric($id))
144
+$filter = array();
145
+if (!empty($id)) {
146
+	if (!is_numeric($id))
147 147
 	{
148 148
 		echo "Error: Bad value for parameter job id";
149 149
 		dol_syslog("cron_run_jobs.php Bad value for parameter job id", LOG_WARNING);
150 150
 		exit;
151 151
 	}
152
-	$filter['t.rowid']=$id;
152
+	$filter['t.rowid'] = $id;
153 153
 }
154 154
 
155
-$result = $object->fetch_all('ASC,ASC,ASC','t.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0);
156
-if ($result<0)
155
+$result = $object->fetch_all('ASC,ASC,ASC', 't.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0);
156
+if ($result < 0)
157 157
 {
158 158
 	echo "Error: ".$object->error;
159 159
 	dol_syslog("cron_run_jobs.php:: fetch Error ".$object->error, LOG_ERR);
@@ -162,22 +162,22 @@  discard block
 block discarded – undo
162 162
 
163 163
 
164 164
 $qualifiedjobs = array();
165
-foreach($object->lines as $val)
165
+foreach ($object->lines as $val)
166 166
 {
167
-	if (! verifCond($val->test)) continue;
167
+	if (!verifCond($val->test)) continue;
168 168
 	$qualifiedjobs[] = $val;
169 169
 }
170 170
 
171 171
 // TODO Duplicate. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
172 172
 
173
-$nbofjobs=count($qualifiedjobs);
174
-$nbofjobslaunchedok=0;
175
-$nbofjobslaunchedko=0;
173
+$nbofjobs = count($qualifiedjobs);
174
+$nbofjobslaunchedok = 0;
175
+$nbofjobslaunchedko = 0;
176 176
 
177
-if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0))
177
+if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0))
178 178
 {
179 179
 	// Loop over job
180
-	foreach($qualifiedjobs as $line)
180
+	foreach ($qualifiedjobs as $line)
181 181
 	{
182 182
 		dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG);
183 183
 
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			echo " - qualified";
190 190
 
191
-			dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc'));
191
+			dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
192 192
 
193
-			$cronjob=new Cronjob($db);
194
-			$result=$cronjob->fetch($line->id);
193
+			$cronjob = new Cronjob($db);
194
+			$result = $cronjob->fetch($line->id);
195 195
 			if ($result < 0)
196 196
 			{
197 197
 				echo "Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n";
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 				exit(-1);
201 201
 			}
202 202
 			// Execute job
203
-			$result=$cronjob->run_jobs($userlogin);
203
+			$result = $cronjob->run_jobs($userlogin);
204 204
 			if ($result < 0)
205 205
 			{
206 206
 				echo "Error cronjobid: ".$line->id." cronjob->run_job: ".$cronjob->error."\n";
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 			echo " - result of run_jobs = ".$result;
218 218
 
219 219
 			// we re-program the next execution and stores the last execution time for this job
220
-			$result=$cronjob->reprogram_jobs($userlogin, $now);
221
-			if ($result<0)
220
+			$result = $cronjob->reprogram_jobs($userlogin, $now);
221
+			if ($result < 0)
222 222
 			{
223 223
 				echo "Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n";
224 224
 				echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n";
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		{
233 233
 			echo " - not qualified\n";
234 234
 
235
-			dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc'));
235
+			dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
236 236
 		}
237 237
 	}
238 238
 }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
  * @param string $script_file   filename
256 256
  * @return void
257 257
  */
258
-function usage($path,$script_file)
258
+function usage($path, $script_file)
259 259
 {
260 260
 	global $conf;
261 261
 
Please login to merge, or discard this patch.