Completed
Branch develop (b5f2d2)
by
unknown
20:52
created
dev/initdata/generate-thirdparty.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 
106 106
 print "Generates ".GEN_NUMBER_SOCIETE." companies\n";
107 107
 for ($s = 0; $s < GEN_NUMBER_SOCIETE; $s++) {
108
-	print "Company $s\n";
108
+	print "company $s\n";
109 109
 	$soc = new Societe($db);
110 110
 	$soc->name = "Company num ".time()."$s";
111 111
 	$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 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 si mode batch
32 32
 $sapi_type = php_sapi_name();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 // Recupere root dolibarr
39 39
 //$path=preg_replace('/generate-societe.php/i','',$_SERVER["PHP_SELF"]);
40
-require __DIR__. '/../../htdocs/master.inc.php';
40
+require __DIR__.'/../../htdocs/master.inc.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
42 42
 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
43 43
 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
46 46
 include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47 47
 
48
-$listoftown = array("Auray","Baden","Vannes","Pirouville","Haguenau","Souffelweiersheim","Illkirch-Graffenstaden","Lauterbourg","Picauville","Sainte-Mère Eglise","Le Bono");
49
-$listoflastname = array("Joe","Marc","Steve","Laurent","Nico","Isabelle","Dorothee","Saby","Brigitte","Karine","Jose-Anne","Celine","Virginie");
48
+$listoftown = array("Auray", "Baden", "Vannes", "Pirouville", "Haguenau", "Souffelweiersheim", "Illkirch-Graffenstaden", "Lauterbourg", "Picauville", "Sainte-Mère Eglise", "Le Bono");
49
+$listoflastname = array("Joe", "Marc", "Steve", "Laurent", "Nico", "Isabelle", "Dorothee", "Saby", "Brigitte", "Karine", "Jose-Anne", "Celine", "Virginie");
50 50
 
51 51
 
52 52
 /*
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 define('GEN_NUMBER_SOCIETE', $argv[1] ?? 10);
57 57
 
58 58
 
59
-$ret=$user->fetch('', 'admin');
60
-if (! $ret > 0) {
59
+$ret = $user->fetch('', 'admin');
60
+if (!$ret > 0) {
61 61
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
62 62
 	exit;
63 63
 }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
68
-$resql=$db->query($sql);
68
+$resql = $db->query($sql);
69 69
 if ($resql) {
70 70
 	$num = $db->num_rows($resql); $i = 0;
71 71
 	while ($i < $num) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 }
77 77
 
78 78
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
79
-$resql=$db->query($sql);
79
+$resql = $db->query($sql);
80 80
 if ($resql) {
81 81
 	$num = $db->num_rows($resql); $i = 0;
82 82
 	while ($i < $num) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 }
90 90
 
91 91
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
92
-$resql=$db->query($sql);
92
+$resql = $db->query($sql);
93 93
 if ($resql) {
94 94
 	$num = $db->num_rows($resql); $i = 0;
95 95
 	while ($i < $num) {
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	print "Company $s\n";
109 109
 	$soc = new Societe($db);
110 110
 	$soc->name = "Company num ".time()."$s";
111
-	$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
112
-	$soc->client = mt_rand(1, 2);		// Une societe sur 2 est prospect, l'autre client
113
-	$soc->fournisseur = mt_rand(0, 1);	// Une societe sur 2 est fournisseur
114
-	$soc->code_client='CU'.time()."$s";
115
-	$soc->code_fournisseur='SU'.time()."$s";
116
-	$soc->tva_assuj=1;
117
-	$soc->country_id=1;
118
-	$soc->country_code='FR';
111
+	$soc->town = $listoftown[mt_rand(0, count($listoftown) - 1)];
112
+	$soc->client = mt_rand(1, 2); // Une societe sur 2 est prospect, l'autre client
113
+	$soc->fournisseur = mt_rand(0, 1); // Une societe sur 2 est fournisseur
114
+	$soc->code_client = 'CU'.time()."$s";
115
+	$soc->code_fournisseur = 'SU'.time()."$s";
116
+	$soc->tva_assuj = 1;
117
+	$soc->country_id = 1;
118
+	$soc->country_code = 'FR';
119 119
 	// Un client sur 3 a une remise de 5%
120
-	$user_remise=mt_rand(1, 3); if ($user_remise==3) {
121
-		$soc->remise_percent=5;
120
+	$user_remise = mt_rand(1, 3); if ($user_remise == 3) {
121
+		$soc->remise_percent = 5;
122 122
 	}
123 123
 	print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n";
124 124
 	$soc->note_private = 'Company created by the script generate-societe.php';
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 			$contact = new Contact($db);
132 132
 			$contact->socid = $soc->id;
133 133
 			$contact->lastname = "Lastname".$c;
134
-			$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)];
134
+			$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname) - 1)];
135 135
 			if ($contact->create($user)) {
136 136
 			}
137 137
 		}
Please login to merge, or discard this patch.
dev/initdata/purge-data.php 1 patch
Spacing   +21 added lines, -21 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=__DIR__.'/';
29
+$path = __DIR__.'/';
30 30
 
31 31
 // Test si mode batch
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/purge-data.php/i', '', $_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/purge-data.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.'/contact/class/contact.class.php';
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 $langs->loadLangs(array("main", "errors"));
48 48
 
49 49
 // Global variables
50
-$version=DOL_VERSION;
51
-$error=0;
50
+$version = DOL_VERSION;
51
+$error = 0;
52 52
 
53 53
 // List of sql to execute
54
-$sqls=array(
54
+$sqls = array(
55 55
 	'user'=>array(
56 56
 		"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
57 57
 		"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 $option = $argv[2];
183 183
 $date = $argv[3];
184 184
 
185
-if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
185
+if (empty($mode) || !in_array($mode, array('test', 'confirm'))) {
186 186
 	print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
187 187
 	print "\n";
188 188
 	print "option can be ".implode(',', array_keys($sqls))."\n";
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	exit(-1);
196 196
 }
197 197
 if ($option != 'all') {
198
-	$listofoptions=explode(',', $option);
198
+	$listofoptions = explode(',', $option);
199 199
 	foreach ($listofoptions as $cursoroption) {
200
-		if (! in_array($cursoroption, array_keys($sqls))) {
200
+		if (!in_array($cursoroption, array_keys($sqls))) {
201 201
 			print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
202 202
 			print "\n";
203 203
 			print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 }
208 208
 
209
-if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
209
+if (empty($date) || (!preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
210 210
 	print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
211 211
 	print "\n";
212 212
 	print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 if (!empty($argv[4])) {
222 222
 	$db->close();
223 223
 	unset($db);
224
-	$db=getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
225
-	$user=new User($db);
224
+	$db = getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
225
+	$user = new User($db);
226 226
 }
227 227
 
228 228
 //var_dump($user->db->database_name);
229
-$ret=$user->fetch('', 'admin');
230
-if (! $ret > 0) {
229
+$ret = $user->fetch('', 'admin');
230
+if (!$ret > 0) {
231 231
 	print 'An admin user with login "admin" must exists to use this script.'."\n";
232 232
 	exit;
233 233
 }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 print "User = ".$db->database_user."\n";
243 243
 print "\n";
244 244
 
245
-if (! $confirmed) {
245
+if (!$confirmed) {
246 246
 	print "Hit Enter to continue or CTRL+C to stop...\n";
247 247
 	$input = trim(fgets(STDIN));
248 248
 }
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 {
260 260
 	global $db, $sqls;
261 261
 
262
-	$error=0;
262
+	$error = 0;
263 263
 	foreach ($sqls[$family] as $sql) {
264 264
 		if (preg_match('/^@/', $sql)) {
265
-			$newfamily=preg_replace('/@/', '', $sql);
265
+			$newfamily = preg_replace('/@/', '', $sql);
266 266
 			processfamily($newfamily, $date);
267 267
 			continue;
268 268
 		}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 
272 272
 		print "Run sql: ".$sql."\n";
273 273
 
274
-		$resql=$db->query($sql);
275
-		if (! $resql) {
274
+		$resql = $db->query($sql);
275
+		if (!$resql) {
276 276
 			if ($db->errno() != 'DB_ERROR_NOSUCHTABLE') {
277 277
 				$error++;
278 278
 			}
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 
296 296
 $db->begin();
297 297
 
298
-$listofoptions=explode(',', $option);
298
+$listofoptions = explode(',', $option);
299 299
 foreach ($listofoptions as $cursoroption) {
300
-	$oldfamily='';
300
+	$oldfamily = '';
301 301
 	foreach ($sqls as $family => $familysql) {
302 302
 		if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) {
303 303
 			continue;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		}
309 309
 		$oldfamily = $family;
310 310
 
311
-		$result=processfamily($family, $date);
311
+		$result = processfamily($family, $date);
312 312
 		if ($result < 0) {
313 313
 			$error++;
314 314
 			break;
Please login to merge, or discard this patch.
dev/initdata/generate-product.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 	$produit->tva_tx = "20.0";
107 107
 	$ret=$produit->create($user);
108 108
 	if ($ret < 0) {
109
-		print "Error $ret - ".$produit->error."\n";
109
+		print "error $ret - ".$produit->error."\n";
110 110
 	} else {
111 111
 		print " OK with ref ".$produit->ref."\n";
112 112
 	}
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 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 si mode batch
32 32
 $sapi_type = php_sapi_name();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 // Recupere root dolibarr
39 39
 //$path=preg_replace('/generate-produit.php/i','',$_SERVER["PHP_SELF"]);
40
-require __DIR__. '/../../htdocs/master.inc.php';
40
+require __DIR__.'/../../htdocs/master.inc.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
42 42
 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
43 43
 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 define('GEN_NUMBER_PRODUIT', $argv[1] ?? 100);
54 54
 
55 55
 
56
-$ret=$user->fetch('', 'admin');
57
-if (! $ret > 0) {
56
+$ret = $user->fetch('', 'admin');
57
+if (!$ret > 0) {
58 58
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
59 59
 	exit;
60 60
 }
@@ -62,31 +62,31 @@  discard block
 block discarded – undo
62 62
 
63 63
 
64 64
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
65
-$resql=$db->query($sql);
65
+$resql = $db->query($sql);
66 66
 if ($resql) {
67 67
 	$num = $db->num_rows($resql); $i = 0;
68 68
 	while ($i < $num) {
69
-		$row = $db->fetch_row($resql);      $productsid[$i] = $row[0];      $i++;
69
+		$row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++;
70 70
 	}
71 71
 }
72 72
 
73 73
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
74
-$resql=$db->query($sql);
74
+$resql = $db->query($sql);
75 75
 if ($resql) {
76 76
 	$num = $db->num_rows($resql); $i = 0;
77 77
 	while ($i < $num) {
78
-		$row = $db->fetch_row($resql);      $societesid[$i] = $row[0];      $i++;
78
+		$row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++;
79 79
 	}
80 80
 } else {
81 81
 	print "err";
82 82
 }
83 83
 
84 84
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
85
-$resql=$db->query($sql);
85
+$resql = $db->query($sql);
86 86
 if ($resql) {
87 87
 	$num = $db->num_rows($resql); $i = 0;
88 88
 	while ($i < $num) {
89
-		$row = $db->fetch_row($resql);      $commandesid[$i] = $row[0];      $i++;
89
+		$row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++;
90 90
 	}
91 91
 } else {
92 92
 	print "err";
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	$produit = new Product($db);
100 100
 	$produit->type = mt_rand(0, 1);
101 101
 	$produit->status = 1;
102
-	$produit->ref = ($produit->type?'S':'P').time().$s;
102
+	$produit->ref = ($produit->type ? 'S' : 'P').time().$s;
103 103
 	$produit->label = 'Label '.time().$s;
104 104
 	$produit->description = 'Description '.time().$s;
105 105
 	$produit->price = mt_rand(1, 999.99);
106 106
 	$produit->tva_tx = "20.0";
107
-	$ret=$produit->create($user);
107
+	$ret = $produit->create($user);
108 108
 	if ($ret < 0) {
109 109
 		print "Error $ret - ".$produit->error."\n";
110 110
 	} else {
Please login to merge, or discard this patch.
dev/initdata/import-users.php 1 patch
Spacing   +28 added lines, -28 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 "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\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
 /*
@@ -63,42 +63,42 @@  discard block
 block discarded – undo
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
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
84 84
 	exit;
85 85
 }
86 86
 $user->getrights();
87 87
 
88 88
 // Ask confirmation
89
-if (! $confirmed) {
89
+if (!$confirmed) {
90 90
 	print "Hit Enter to continue or CTRL+C to stop...\n";
91 91
 	$input = trim(fgets(STDIN));
92 92
 }
93 93
 
94 94
 // Open input and output files
95 95
 $fhandle = fopen($filepath, 'r');
96
-if (! $fhandle) {
96
+if (!$fhandle) {
97 97
 	print 'Error: Failed to open file '.$filepath."\n";
98 98
 	exit(1);
99 99
 }
100 100
 $fhandleerr = fopen($filepatherr, 'w');
101
-if (! $fhandleerr) {
101
+if (!$fhandleerr) {
102 102
 	print 'Error: Failed to open file '.$filepatherr."\n";
103 103
 	exit(1);
104 104
 }
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 
109 109
 $db->begin();
110 110
 
111
-$i=0;
112
-$nboflines=0;
113
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
111
+$i = 0;
112
+$nboflines = 0;
113
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
114 114
 	$i++;
115
-	$errorrecord=0;
115
+	$errorrecord = 0;
116 116
 
117 117
 	if ($startlinenb && $i < $startlinenb) {
118 118
 		continue;
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 	$object = new User($db);
127 127
 	$object->statut = 1;
128 128
 
129
-	$tmp=explode(' ', $fields[3], 2);
129
+	$tmp = explode(' ', $fields[3], 2);
130 130
 	$object->firstname = trim($tmp[0]);
131 131
 	$object->lastname = trim($tmp[1]);
132 132
 	if ($object->lastname) {
133
-		$object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
133
+		$object->login = strtolower(substr($object->firstname, 0, 1)).strtolower(substr($object->lastname, 0));
134 134
 	} else {
135
-		$object->login=strtolower($object->firstname);
135
+		$object->login = strtolower($object->firstname);
136 136
 	}
137
-	$object->login=preg_replace('/ /', '', $object->login);
137
+	$object->login = preg_replace('/ /', '', $object->login);
138 138
 	$object->password = 'init';
139 139
 
140 140
 	print "Process line nb ".$i.", login ".$object->login;
141 141
 
142
-	$ret=$object->create($user);
142
+	$ret = $object->create($user);
143 143
 	if ($ret < 0) {
144 144
 		print " - Error in create result code = ".$ret." - ".$object->errorsToString();
145 145
 		$errorrecord++;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 	if ($errorrecord) {
153 153
 		fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
154
-		$error++;    // $errorrecord will be reset
154
+		$error++; // $errorrecord will be reset
155 155
 	}
156 156
 }
157 157
 
Please login to merge, or discard this patch.
dev/initdata/import-products.php 1 patch
Spacing   +33 added lines, -33 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 "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\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
 /*
@@ -62,43 +62,43 @@  discard block
 block discarded – undo
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
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
84 84
 	exit;
85 85
 }
86 86
 $user->getrights();
87 87
 
88 88
 // Ask confirmation
89
-if (! $confirmed) {
89
+if (!$confirmed) {
90 90
 	print "Hit Enter to continue or CTRL+C to stop...\n";
91 91
 	$input = trim(fgets(STDIN));
92 92
 }
93 93
 
94 94
 // Open input and output files
95 95
 $fhandle = fopen($filepath, 'r');
96
-if (! $fhandle) {
96
+if (!$fhandle) {
97 97
 	print 'Error: Failed to open file '.$filepath."\n";
98 98
 	exit(1);
99 99
 }
100 100
 $fhandleerr = fopen($filepatherr, 'w');
101
-if (! $fhandleerr) {
101
+if (!$fhandleerr) {
102 102
 	print 'Error: Failed to open file '.$filepatherr."\n";
103 103
 	exit(1);
104 104
 }
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 
109 109
 $db->begin();
110 110
 
111
-$i=0;
111
+$i = 0;
112 112
 $nboflines++;
113
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
113
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
114 114
 	$i++;
115
-	$errorrecord=0;
115
+	$errorrecord = 0;
116 116
 
117 117
 	if ($startlinenb && $i < $startlinenb) {
118 118
 		continue;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	$produit->volume = price2num($fields[8]);
135 135
 	$produit->volume_unit = 0;
136 136
 	$produit->weight = price2num($fields[9]);
137
-	$produit->weight_units = 0;          // -3 = g
137
+	$produit->weight_units = 0; // -3 = g
138 138
 
139 139
 	$produit->customcode = $fields[10];
140 140
 	$produit->barcode = $fields[1];
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	$produit->cost_price = price2num($fields[16]);
156 156
 
157 157
 	// Extrafields
158
-	$produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
158
+	$produit->array_options['options_ecotaxdeee'] = price2num($fields[17]);
159 159
 
160
-	$ret=$produit->create($user);
160
+	$ret = $produit->create($user);
161 161
 	if ($ret < 0) {
162 162
 		print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
163 163
 		$errorrecord++;
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	dol_syslog("Add prices");
169 169
 
170 170
 	// If we use price level, insert price for each level
171
-	if (! $errorrecord && 1) {
172
-		$ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
173
-		$ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
171
+	if (!$errorrecord && 1) {
172
+		$ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
173
+		$ret2 = $produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
174 174
 		if ($ret1 < 0 || $ret2 < 0) {
175 175
 			print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
176 176
 			$errorrecord++;
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	dol_syslog("Add multilangs");
183 183
 
184 184
 	// Add alternative languages
185
-	if (! $errorrecord && 1) {
186
-		$produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
187
-		$produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
185
+	if (!$errorrecord && 1) {
186
+		$produit->multilangs['fr_FR'] = array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
187
+		$produit->multilangs['en_US'] = array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
188 188
 
189
-		$ret=$produit->setMultiLangs($user);
189
+		$ret = $produit->setMultiLangs($user);
190 190
 		if ($ret < 0) {
191 191
 			print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
192 192
 			$errorrecord++;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
 	if ($errorrecord) {
201 201
 		fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
202
-		$error++;    // $errorrecord will be reset
202
+		$error++; // $errorrecord will be reset
203 203
 	}
204 204
 }
205 205
 
Please login to merge, or discard this patch.
htdocs/ticket/document.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 	accessforbidden();
92 92
 }
93 93
 
94
-$permissiontoadd = $user->rights->ticket->write;	// Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
94
+$permissiontoadd = $user->rights->ticket->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
95 95
 
96 96
 
97 97
 /*
Please login to merge, or discard this patch.
htdocs/salaries/class/salary.class.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		}
447 447
 	}
448 448
 
449
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
449
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
450 450
 	/**
451 451
 	 *  Update link between payment salary and line generate into llx_bank
452 452
 	 *
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	 */
456 456
 	public function update_fk_bank($id_bank)
457 457
 	{
458
-        // phpcs:enable
458
+		// phpcs:enable
459 459
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.((int) $id_bank);
460 460
 		$sql .= " WHERE rowid = ".((int) $this->id);
461 461
 		$result = $this->db->query($sql);
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 		return $this->LibStatut($this->paye, $mode, $alreadypaid);
693 693
 	}
694 694
 
695
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
695
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
696 696
 	/**
697 697
 	 *  Return label of a given status
698 698
 	 *
Please login to merge, or discard this patch.
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -201,7 +201,9 @@  discard block
 block discarded – undo
201 201
 		if (!$notrigger) {
202 202
 			// Call trigger
203 203
 			$result = $this->call_trigger('SALARY_MODIFY', $user);
204
-			if ($result < 0) $error++;
204
+			if ($result < 0) {
205
+				$error++;
206
+			}
205 207
 			// End call triggers
206 208
 		}
207 209
 
@@ -382,7 +384,9 @@  discard block
 block discarded – undo
382 384
 		$sql .= ", salary";
383 385
 		$sql .= ", fk_typepayment";
384 386
 		$sql .= ", fk_account";
385
-		if ($this->note) $sql .= ", note";
387
+		if ($this->note) {
388
+			$sql .= ", note";
389
+		}
386 390
 		$sql .= ", label";
387 391
 		$sql .= ", datesp";
388 392
 		$sql .= ", dateep";
@@ -400,7 +404,9 @@  discard block
 block discarded – undo
400 404
 		$sql .= ", ".($this->salary > 0 ? ((double) $this->salary) : "null");
401 405
 		$sql .= ", ".($this->type_payment > 0 ? ((int) $this->type_payment) : 0);
402 406
 		$sql .= ", ".($this->accountid > 0 ? ((int) $this->accountid) : "null");
403
-		if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
407
+		if ($this->note) {
408
+			$sql .= ", '".$this->db->escape($this->note)."'";
409
+		}
404 410
 		$sql .= ", '".$this->db->escape($this->label)."'";
405 411
 		$sql .= ", '".$this->db->idate($this->datesp)."'";
406 412
 		$sql .= ", '".$this->db->idate($this->dateep)."'";
@@ -428,9 +434,13 @@  discard block
 block discarded – undo
428 434
 
429 435
 				// Call trigger
430 436
 				$result = $this->call_trigger('SALARY_CREATE', $user);
431
-				if ($result < 0) $error++;
437
+				if ($result < 0) {
438
+					$error++;
439
+				}
432 440
 				// End call triggers
433
-			} else $error++;
441
+			} else {
442
+				$error++;
443
+			}
434 444
 
435 445
 			if (!$error) {
436 446
 				$this->db->commit();
@@ -503,7 +513,10 @@  discard block
 block discarded – undo
503 513
 		global $dolibarr_main_authentication, $dolibarr_main_demo;
504 514
 		global $menumanager;
505 515
 
506
-		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
516
+		if (!empty($conf->dol_no_mouse_hover)) {
517
+			$notooltip = 1;
518
+		}
519
+		// Force disable tooltips
507 520
 
508 521
 		$result = '';
509 522
 		$params = [
@@ -564,8 +577,11 @@  discard block
 block discarded – undo
564 577
 		$hookmanager->initHooks(array('salarypayment'));
565 578
 		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
566 579
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
567
-		if ($reshook > 0) $result = $hookmanager->resPrint;
568
-		else $result .= $hookmanager->resPrint;
580
+		if ($reshook > 0) {
581
+			$result = $hookmanager->resPrint;
582
+		} else {
583
+			$result .= $hookmanager->resPrint;
584
+		}
569 585
 
570 586
 		return $result;
571 587
 	}
@@ -591,7 +607,9 @@  discard block
 block discarded – undo
591 607
 			$amount = 0;
592 608
 
593 609
 			$obj = $this->db->fetch_object($resql);
594
-			if ($obj) $amount = $obj->amount ? $obj->amount : 0;
610
+			if ($obj) {
611
+				$amount = $obj->amount ? $obj->amount : 0;
612
+			}
595 613
 
596 614
 			$this->db->free($resql);
597 615
 			return $amount;
@@ -718,15 +736,23 @@  discard block
 block discarded – undo
718 736
 			//$langs->load("mymodule");
719 737
 			$this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
720 738
 			$this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
721
-			if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
739
+			if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) {
740
+				$this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
741
+			}
722 742
 			$this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
723 743
 			$this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
724
-			if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
744
+			if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) {
745
+				$this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
746
+			}
725 747
 		}
726 748
 
727 749
 		$statusType = 'status1';
728
-		if ($status == 0 && $alreadypaid <> 0) $statusType = 'status3';
729
-		if ($status == 1) $statusType = 'status6';
750
+		if ($status == 0 && $alreadypaid <> 0) {
751
+			$statusType = 'status3';
752
+		}
753
+		if ($status == 1) {
754
+			$statusType = 'status6';
755
+		}
730 756
 
731 757
 		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
732 758
 	}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -497,7 +497,7 @@
 block discarded – undo
497 497
 				$label = $langs->trans("ShowMyObject");
498 498
 				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
499 499
 			}
500
-			$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' :  ' title="tocomplete"');
500
+			$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
501 501
 			$linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
502 502
 		} else {
503 503
 			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
Please login to merge, or discard this patch.
htdocs/salaries/list.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 // Output page
350 350
 // --------------------------------------------------------------------
351 351
 
352
-llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');	// Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
352
+llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
353 353
 
354 354
 $arrayofselected = is_array($toselect) ? $toselect : array();
355 355
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	$userstatic->login = $obj->login;
638 638
 	$userstatic->email = $obj->email;
639 639
 	$userstatic->socid = $obj->fk_soc;
640
-	$userstatic->statut = $obj->status;		// deprecated
640
+	$userstatic->statut = $obj->status; // deprecated
641 641
 	$userstatic->status = $obj->status;
642 642
 	$userstatic->photo = $obj->photo;
643 643
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -719,7 +719,9 @@
 block discarded – undo
719 719
 
720 720
 		// Payment mode
721 721
 		print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
722
-		if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
722
+		if (!empty($obj->payment_code)) {
723
+			print $langs->trans("PaymentTypeShort".$obj->payment_code);
724
+		}
723 725
 		print '</td>';
724 726
 		if (!$i) {
725 727
 			$totalarray['nbfield']++;
Please login to merge, or discard this patch.
htdocs/holiday/view_log.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 $action             = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
41 41
 $massaction         = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
42
-$mode      = GETPOST('mode', 'alpha');
42
+$mode = GETPOST('mode', 'alpha');
43 43
 $show_files         = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
44 44
 $confirm            = GETPOST('confirm', 'alpha'); // Result of a confirmation
45 45
 $cancel             = GETPOST('cancel', 'alpha'); // We click on a Cancel button
Please login to merge, or discard this patch.