@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * \brief File of class to build ODT documents for assets |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/asset/modules_asset.php'; |
|
| 31 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/asset/modules_asset.php'; |
|
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
| 85 | 85 | |
| 86 | 86 | if ($mysoc === null) { |
| 87 | - dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); |
|
| 87 | + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'.getCallerInfoString(), LOG_ERR); |
|
| 88 | 88 | return; |
| 89 | 89 | } |
| 90 | 90 | // Get source company |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | dol_mkdir($conf->asset->dir_temp); |
| 283 | 283 | if (!is_writable($conf->asset->dir_temp)) { |
| 284 | 284 | $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->asset->dir_temp); |
| 285 | - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); |
|
| 285 | + dol_syslog('Error in write_file: '.$this->error, LOG_ERR); |
|
| 286 | 286 | return -1; |
| 287 | 287 | } |
| 288 | 288 | |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | // Test si mode batch |
| 30 | 30 | $sapi_type = php_sapi_name(); |
| 31 | 31 | $script_file = basename(__FILE__); |
| 32 | -$path=dirname(__FILE__).'/'; |
|
| 32 | +$path = dirname(__FILE__).'/'; |
|
| 33 | 33 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 34 | 34 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
| 35 | 35 | exit; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Recupere root dolibarr |
| 39 | -$path=preg_replace('/import-products.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 39 | +$path = preg_replace('/import-products.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 40 | 40 | require $path."../../htdocs/master.inc.php"; |
| 41 | 41 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 42 | 42 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 43 | 43 | |
| 44 | -$delimiter=','; |
|
| 45 | -$enclosure='"'; |
|
| 46 | -$linelength=10000; |
|
| 47 | -$escape='/'; |
|
| 44 | +$delimiter = ','; |
|
| 45 | +$enclosure = '"'; |
|
| 46 | +$linelength = 10000; |
|
| 47 | +$escape = '/'; |
|
| 48 | 48 | |
| 49 | 49 | // Global variables |
| 50 | -$version=DOL_VERSION; |
|
| 51 | -$confirmed=1; |
|
| 52 | -$error=0; |
|
| 50 | +$version = DOL_VERSION; |
|
| 51 | +$confirmed = 1; |
|
| 52 | +$error = 0; |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* |
@@ -67,39 +67,39 @@ discard block |
||
| 67 | 67 | $startlinenb = empty($argv[4]) ? 1 : $argv[4]; |
| 68 | 68 | $endlinenb = empty($argv[5]) ? 0 : $argv[5]; |
| 69 | 69 | |
| 70 | -if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) { |
|
| 70 | +if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) { |
|
| 71 | 71 | print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n"; |
| 72 | 72 | print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n"; |
| 73 | 73 | print "\n"; |
| 74 | 74 | exit(-1); |
| 75 | 75 | } |
| 76 | -if (! file_exists($filepath)) { |
|
| 76 | +if (!file_exists($filepath)) { |
|
| 77 | 77 | print "Error: File ".$filepath." not found.\n"; |
| 78 | 78 | print "\n"; |
| 79 | 79 | exit(-1); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -$ret=$user->fetch('', 'admin'); |
|
| 83 | -if (! $ret > 0) { |
|
| 82 | +$ret = $user->fetch('', 'admin'); |
|
| 83 | +if (!$ret > 0) { |
|
| 84 | 84 | print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
| 85 | 85 | exit; |
| 86 | 86 | } |
| 87 | 87 | $user->loadRights(); |
| 88 | 88 | |
| 89 | 89 | // Ask confirmation |
| 90 | -if (! $confirmed) { |
|
| 90 | +if (!$confirmed) { |
|
| 91 | 91 | print "Hit Enter to continue or CTRL+C to stop...\n"; |
| 92 | 92 | $input = trim(fgets(STDIN)); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Open input and output files |
| 96 | 96 | $fhandle = fopen($filepath, 'r'); |
| 97 | -if (! $fhandle) { |
|
| 97 | +if (!$fhandle) { |
|
| 98 | 98 | print 'Error: Failed to open file '.$filepath."\n"; |
| 99 | 99 | exit(1); |
| 100 | 100 | } |
| 101 | 101 | $fhandleerr = fopen($filepatherr, 'w'); |
| 102 | -if (! $fhandleerr) { |
|
| 102 | +if (!$fhandleerr) { |
|
| 103 | 103 | print 'Error: Failed to open file '.$filepatherr."\n"; |
| 104 | 104 | exit(1); |
| 105 | 105 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $db->begin(); |
| 111 | 111 | |
| 112 | -$i=0; |
|
| 112 | +$i = 0; |
|
| 113 | 113 | $nboflines++; |
| 114 | -while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 114 | +while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 115 | 115 | $i++; |
| 116 | - $errorrecord=0; |
|
| 116 | + $errorrecord = 0; |
|
| 117 | 117 | |
| 118 | 118 | if ($startlinenb && $i < $startlinenb) { |
| 119 | 119 | continue; |
@@ -135,7 +135,7 @@ discard block |
||
| 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 |
||
| 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 | print " - Error in create result code = ".$ret." - ".$produit->errorsToString(); |
| 164 | 164 | $errorrecord++; |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | dol_syslog("Add prices"); |
| 170 | 170 | |
| 171 | 171 | // If we use price level, insert price for each level |
| 172 | - if (! $errorrecord && 1) { |
|
| 173 | - $ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array()); |
|
| 174 | - $ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array()); |
|
| 172 | + if (!$errorrecord && 1) { |
|
| 173 | + $ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array()); |
|
| 174 | + $ret2 = $produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array()); |
|
| 175 | 175 | if ($ret1 < 0 || $ret2 < 0) { |
| 176 | 176 | print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString(); |
| 177 | 177 | $errorrecord++; |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | dol_syslog("Add multilangs"); |
| 184 | 184 | |
| 185 | 185 | // Add alternative languages |
| 186 | - if (! $errorrecord && 1) { |
|
| 187 | - $produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
| 188 | - $produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
| 186 | + if (!$errorrecord && 1) { |
|
| 187 | + $produit->multilangs['fr_FR'] = array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
| 188 | + $produit->multilangs['en_US'] = array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private); |
|
| 189 | 189 | |
| 190 | - $ret=$produit->setMultiLangs($user); |
|
| 190 | + $ret = $produit->setMultiLangs($user); |
|
| 191 | 191 | if ($ret < 0) { |
| 192 | 192 | print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString(); |
| 193 | 193 | $errorrecord++; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | if ($errorrecord) { |
| 202 | 202 | fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n"); |
| 203 | - $error++; // $errorrecord will be reset |
|
| 203 | + $error++; // $errorrecord will be reset |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | // Test si mode batch |
| 30 | 30 | $sapi_type = php_sapi_name(); |
| 31 | 31 | $script_file = basename(__FILE__); |
| 32 | -$path=dirname(__FILE__).'/'; |
|
| 32 | +$path = dirname(__FILE__).'/'; |
|
| 33 | 33 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 34 | 34 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
| 35 | 35 | exit; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Recupere root dolibarr |
| 39 | -$path=preg_replace('/import-thirdparties.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 39 | +$path = preg_replace('/import-thirdparties.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 40 | 40 | require $path."../../htdocs/master.inc.php"; |
| 41 | 41 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 42 | 42 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 43 | 43 | |
| 44 | -$delimiter=','; |
|
| 45 | -$enclosure='"'; |
|
| 46 | -$linelength=10000; |
|
| 47 | -$escape='/'; |
|
| 44 | +$delimiter = ','; |
|
| 45 | +$enclosure = '"'; |
|
| 46 | +$linelength = 10000; |
|
| 47 | +$escape = '/'; |
|
| 48 | 48 | |
| 49 | 49 | // Global variables |
| 50 | -$version=DOL_VERSION; |
|
| 51 | -$confirmed=1; |
|
| 52 | -$error=0; |
|
| 50 | +$version = DOL_VERSION; |
|
| 51 | +$confirmed = 1; |
|
| 52 | +$error = 0; |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* |
@@ -67,39 +67,39 @@ discard block |
||
| 67 | 67 | $startlinenb = empty($argv[3]) ? 1 : $argv[3]; |
| 68 | 68 | $endlinenb = empty($argv[4]) ? 0 : $argv[4]; |
| 69 | 69 | |
| 70 | -if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) { |
|
| 70 | +if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) { |
|
| 71 | 71 | print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n"; |
| 72 | 72 | print "Usage: $script_file test myfilepath.csv 2 1002\n"; |
| 73 | 73 | print "\n"; |
| 74 | 74 | exit(-1); |
| 75 | 75 | } |
| 76 | -if (! file_exists($filepath)) { |
|
| 76 | +if (!file_exists($filepath)) { |
|
| 77 | 77 | print "Error: File ".$filepath." not found.\n"; |
| 78 | 78 | print "\n"; |
| 79 | 79 | exit(-1); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -$ret=$user->fetch('', 'admin'); |
|
| 83 | -if (! $ret > 0) { |
|
| 82 | +$ret = $user->fetch('', 'admin'); |
|
| 83 | +if (!$ret > 0) { |
|
| 84 | 84 | print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
| 85 | 85 | exit; |
| 86 | 86 | } |
| 87 | 87 | $user->loadRights(); |
| 88 | 88 | |
| 89 | 89 | // Ask confirmation |
| 90 | -if (! $confirmed) { |
|
| 90 | +if (!$confirmed) { |
|
| 91 | 91 | print "Hit Enter to continue or CTRL+C to stop...\n"; |
| 92 | 92 | $input = trim(fgets(STDIN)); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Open input and output files |
| 96 | 96 | $fhandle = fopen($filepath, 'r'); |
| 97 | -if (! $fhandle) { |
|
| 97 | +if (!$fhandle) { |
|
| 98 | 98 | print 'Error: Failed to open file '.$filepath."\n"; |
| 99 | 99 | exit(1); |
| 100 | 100 | } |
| 101 | 101 | $fhandleerr = fopen($filepatherr, 'w'); |
| 102 | -if (! $fhandleerr) { |
|
| 102 | +if (!$fhandleerr) { |
|
| 103 | 103 | print 'Error: Failed to open file '.$filepatherr."\n"; |
| 104 | 104 | exit(1); |
| 105 | 105 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $db->begin(); |
| 111 | 111 | |
| 112 | -$i=0; |
|
| 113 | -$nboflines=0; |
|
| 114 | -while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 112 | +$i = 0; |
|
| 113 | +$nboflines = 0; |
|
| 114 | +while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 115 | 115 | $i++; |
| 116 | - $errorrecord=0; |
|
| 116 | + $errorrecord = 0; |
|
| 117 | 117 | |
| 118 | 118 | if ($startlinenb && $i < $startlinenb) { |
| 119 | 119 | continue; |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | // Extrafields |
| 178 | - $object->array_options['options_anastate']=price2num($fields[20]); |
|
| 179 | - $object->array_options['options_anaregion']=price2num($fields[17]); |
|
| 178 | + $object->array_options['options_anastate'] = price2num($fields[20]); |
|
| 179 | + $object->array_options['options_anaregion'] = price2num($fields[17]); |
|
| 180 | 180 | |
| 181 | - if (! $errorrecord) { |
|
| 182 | - $ret=$object->create($user); |
|
| 181 | + if (!$errorrecord) { |
|
| 182 | + $ret = $object->create($user); |
|
| 183 | 183 | if ($ret < 0) { |
| 184 | 184 | print " - Error in create result code = ".$ret." - ".$object->errorsToString(); |
| 185 | 185 | $errorrecord++; |
@@ -188,24 +188,24 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if (! $errorrecord) { |
|
| 191 | + if (!$errorrecord) { |
|
| 192 | 192 | dol_syslog("Set price level"); |
| 193 | 193 | $object->set_price_level($object->price_level, $user); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Assign sales representative |
| 197 | - if (! $errorrecord && $fields[3]) { |
|
| 198 | - $salesrep=new User($db); |
|
| 197 | + if (!$errorrecord && $fields[3]) { |
|
| 198 | + $salesrep = new User($db); |
|
| 199 | 199 | |
| 200 | - $tmp=explode(' ', $fields[3], 2); |
|
| 200 | + $tmp = explode(' ', $fields[3], 2); |
|
| 201 | 201 | $salesrep->firstname = trim($tmp[0]); |
| 202 | 202 | $salesrep->lastname = trim($tmp[1]); |
| 203 | 203 | if ($salesrep->lastname) { |
| 204 | - $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0)); |
|
| 204 | + $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)).strtolower(substr($salesrep->lastname, 0)); |
|
| 205 | 205 | } else { |
| 206 | - $salesrep->login=strtolower($salesrep->firstname); |
|
| 206 | + $salesrep->login = strtolower($salesrep->firstname); |
|
| 207 | 207 | } |
| 208 | - $salesrep->login=preg_replace('/ /', '', $salesrep->login); |
|
| 208 | + $salesrep->login = preg_replace('/ /', '', $salesrep->login); |
|
| 209 | 209 | $salesrep->fetch(0, $salesrep->login); |
| 210 | 210 | |
| 211 | 211 | $result = $object->add_commercial($user, $salesrep->id); |
@@ -219,19 +219,19 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | dol_syslog("Add invoice contacts"); |
| 221 | 221 | // Insert an invoice contact if there is an invoice email != standard email |
| 222 | - if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) { |
|
| 223 | - $ret1=$ret2=0; |
|
| 222 | + if (!$errorrecord && $fields[27] && $fields[26] != $fields[27]) { |
|
| 223 | + $ret1 = $ret2 = 0; |
|
| 224 | 224 | |
| 225 | 225 | $contact = new Contact($db); |
| 226 | 226 | $contact->lastname = $object->name; |
| 227 | - $contact->address=$object->address; |
|
| 228 | - $contact->zip=$object->zip; |
|
| 229 | - $contact->town=$object->town; |
|
| 230 | - $contact->country_id=$object->country_id; |
|
| 231 | - $contact->email=$fields[27]; |
|
| 232 | - $contact->socid=$object->id; |
|
| 233 | - |
|
| 234 | - $ret1=$contact->create($user); |
|
| 227 | + $contact->address = $object->address; |
|
| 228 | + $contact->zip = $object->zip; |
|
| 229 | + $contact->town = $object->town; |
|
| 230 | + $contact->country_id = $object->country_id; |
|
| 231 | + $contact->email = $fields[27]; |
|
| 232 | + $contact->socid = $object->id; |
|
| 233 | + |
|
| 234 | + $ret1 = $contact->create($user); |
|
| 235 | 235 | if ($ret1 > 0) { |
| 236 | 236 | //$ret2=$contact->add_contact($object->id, 'BILLING'); |
| 237 | 237 | } |
@@ -245,22 +245,22 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | dol_syslog("Add delivery contacts"); |
| 247 | 247 | // Insert a delivery contact |
| 248 | - if (! $errorrecord && $fields[47]) { |
|
| 249 | - $ret1=$ret2=0; |
|
| 248 | + if (!$errorrecord && $fields[47]) { |
|
| 249 | + $ret1 = $ret2 = 0; |
|
| 250 | 250 | |
| 251 | 251 | $contact2 = new Contact($db); |
| 252 | 252 | $contact2->lastname = 'Service livraison - '.$fields[47]; |
| 253 | 253 | $contact2->address = $fields[48]; |
| 254 | 254 | $contact2->zip = $fields[50]; |
| 255 | 255 | $contact2->town = $fields[51]; |
| 256 | - $contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid'); |
|
| 257 | - $contact2->note_public=$fields[54]; |
|
| 258 | - $contact2->socid=$object->id; |
|
| 256 | + $contact2->country_id = dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid'); |
|
| 257 | + $contact2->note_public = $fields[54]; |
|
| 258 | + $contact2->socid = $object->id; |
|
| 259 | 259 | |
| 260 | 260 | // Extrafields |
| 261 | - $contact2->array_options['options_anazoneliv']=price2num($fields[53]); |
|
| 261 | + $contact2->array_options['options_anazoneliv'] = price2num($fields[53]); |
|
| 262 | 262 | |
| 263 | - $ret1=$contact2->create($user); |
|
| 263 | + $ret1 = $contact2->create($user); |
|
| 264 | 264 | if ($ret1 > 0) { |
| 265 | 265 | //$ret2=$contact2->add_contact($object->id, 'SHIPPING'); |
| 266 | 266 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | if ($errorrecord) { |
| 279 | 279 | fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
| 280 | - $error++; // $errorrecord will be reset |
|
| 280 | + $error++; // $errorrecord will be reset |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | // Test si mode batch |
| 30 | 30 | $sapi_type = php_sapi_name(); |
| 31 | 31 | $script_file = basename(__FILE__); |
| 32 | -$path=dirname(__FILE__).'/'; |
|
| 32 | +$path = dirname(__FILE__).'/'; |
|
| 33 | 33 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 34 | 34 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
| 35 | 35 | exit; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Recupere root dolibarr |
| 39 | -$path=preg_replace('/import-users.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 39 | +$path = preg_replace('/import-users.php/i', '', $_SERVER["PHP_SELF"]); |
|
| 40 | 40 | require $path."../../htdocs/master.inc.php"; |
| 41 | 41 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 42 | 42 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 43 | 43 | |
| 44 | -$delimiter=','; |
|
| 45 | -$enclosure='"'; |
|
| 46 | -$linelength=10000; |
|
| 47 | -$escape='/'; |
|
| 44 | +$delimiter = ','; |
|
| 45 | +$enclosure = '"'; |
|
| 46 | +$linelength = 10000; |
|
| 47 | +$escape = '/'; |
|
| 48 | 48 | |
| 49 | 49 | // Global variables |
| 50 | -$version=DOL_VERSION; |
|
| 51 | -$confirmed=1; |
|
| 52 | -$error=0; |
|
| 50 | +$version = DOL_VERSION; |
|
| 51 | +$confirmed = 1; |
|
| 52 | +$error = 0; |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* |
@@ -67,39 +67,39 @@ discard block |
||
| 67 | 67 | $startlinenb = empty($argv[3]) ? 1 : $argv[3]; |
| 68 | 68 | $endlinenb = empty($argv[4]) ? 0 : $argv[4]; |
| 69 | 69 | |
| 70 | -if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) { |
|
| 70 | +if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) { |
|
| 71 | 71 | print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n"; |
| 72 | 72 | print "Usage: $script_file test myfilepath.csv 2 1002\n"; |
| 73 | 73 | print "\n"; |
| 74 | 74 | exit(-1); |
| 75 | 75 | } |
| 76 | -if (! file_exists($filepath)) { |
|
| 76 | +if (!file_exists($filepath)) { |
|
| 77 | 77 | print "Error: File ".$filepath." not found.\n"; |
| 78 | 78 | print "\n"; |
| 79 | 79 | exit(-1); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -$ret=$user->fetch('', 'admin'); |
|
| 83 | -if (! $ret > 0) { |
|
| 82 | +$ret = $user->fetch('', 'admin'); |
|
| 83 | +if (!$ret > 0) { |
|
| 84 | 84 | print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
| 85 | 85 | exit; |
| 86 | 86 | } |
| 87 | 87 | $user->loadRights(); |
| 88 | 88 | |
| 89 | 89 | // Ask confirmation |
| 90 | -if (! $confirmed) { |
|
| 90 | +if (!$confirmed) { |
|
| 91 | 91 | print "Hit Enter to continue or CTRL+C to stop...\n"; |
| 92 | 92 | $input = trim(fgets(STDIN)); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Open input and output files |
| 96 | 96 | $fhandle = fopen($filepath, 'r'); |
| 97 | -if (! $fhandle) { |
|
| 97 | +if (!$fhandle) { |
|
| 98 | 98 | print 'Error: Failed to open file '.$filepath."\n"; |
| 99 | 99 | exit(1); |
| 100 | 100 | } |
| 101 | 101 | $fhandleerr = fopen($filepatherr, 'w'); |
| 102 | -if (! $fhandleerr) { |
|
| 102 | +if (!$fhandleerr) { |
|
| 103 | 103 | print 'Error: Failed to open file '.$filepatherr."\n"; |
| 104 | 104 | exit(1); |
| 105 | 105 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $db->begin(); |
| 111 | 111 | |
| 112 | -$i=0; |
|
| 113 | -$nboflines=0; |
|
| 114 | -while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 112 | +$i = 0; |
|
| 113 | +$nboflines = 0; |
|
| 114 | +while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { |
|
| 115 | 115 | $i++; |
| 116 | - $errorrecord=0; |
|
| 116 | + $errorrecord = 0; |
|
| 117 | 117 | |
| 118 | 118 | if ($startlinenb && $i < $startlinenb) { |
| 119 | 119 | continue; |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | $object = new User($db); |
| 128 | 128 | $object->status = 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 | 133 | if ($object->lastname) { |
| 134 | - $object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0)); |
|
| 134 | + $object->login = strtolower(substr($object->firstname, 0, 1)).strtolower(substr($object->lastname, 0)); |
|
| 135 | 135 | } else { |
| 136 | - $object->login=strtolower($object->firstname); |
|
| 136 | + $object->login = strtolower($object->firstname); |
|
| 137 | 137 | } |
| 138 | - $object->login=preg_replace('/ /', '', $object->login); |
|
| 138 | + $object->login = preg_replace('/ /', '', $object->login); |
|
| 139 | 139 | $object->password = 'init'; |
| 140 | 140 | |
| 141 | 141 | print "Process line nb ".$i.", login ".$object->login; |
| 142 | 142 | |
| 143 | - $ret=$object->create($user); |
|
| 143 | + $ret = $object->create($user); |
|
| 144 | 144 | if ($ret < 0) { |
| 145 | 145 | print " - Error in create result code = ".$ret." - ".$object->errorsToString(); |
| 146 | 146 | $errorrecord++; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | if ($errorrecord) { |
| 154 | 154 | fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); |
| 155 | - $error++; // $errorrecord will be reset |
|
| 155 | + $error++; // $errorrecord will be reset |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
@@ -17,15 +17,15 @@ discard block |
||
| 17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>. |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -$res=0; |
|
| 21 | -if (! $res && file_exists("../../main.inc.php")) { |
|
| 22 | - $res=@include '../../main.inc.php'; |
|
| 20 | +$res = 0; |
|
| 21 | +if (!$res && file_exists("../../main.inc.php")) { |
|
| 22 | + $res = @include '../../main.inc.php'; |
|
| 23 | 23 | } |
| 24 | -if (! $res && file_exists("../../../main.inc.php")) { |
|
| 25 | - $res=@include '../../../main.inc.php'; |
|
| 24 | +if (!$res && file_exists("../../../main.inc.php")) { |
|
| 25 | + $res = @include '../../../main.inc.php'; |
|
| 26 | 26 | } |
| 27 | -if (! $res && file_exists("../../../../main.inc.php")) { |
|
| 28 | - $res=@include '../../../../main.inc.php'; |
|
| 27 | +if (!$res && file_exists("../../../../main.inc.php")) { |
|
| 28 | + $res = @include '../../../../main.inc.php'; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Protection if external user |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // Set view for menu and breadcrumb |
| 52 | 52 | // Menu must be set in constructor of documentation class |
| 53 | -$documentation->view = array('Content','Tables'); |
|
| 53 | +$documentation->view = array('Content', 'Tables'); |
|
| 54 | 54 | |
| 55 | 55 | // Output sidebar |
| 56 | 56 | $documentation->showSidebar(); ?> |
@@ -195,7 +195,7 @@ |
||
| 195 | 195 | |
| 196 | 196 | $arrayofcss[] = 'admin/tools/ui/css/documentation.css'; |
| 197 | 197 | |
| 198 | - top_htmlhead('', $title, 0, 0, $arrayofjs, $arrayofcss); |
|
| 198 | + top_htmlhead('', $title, 0, 0, $arrayofjs, $arrayofcss); |
|
| 199 | 199 | |
| 200 | 200 | print '<body class="dolibarr-doc">'; |
| 201 | 201 | } |
@@ -17,12 +17,12 @@ |
||
| 17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>. |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -$res=0; |
|
| 21 | -if (! $res && file_exists("../main.inc.php")) : $res=@include '../main.inc.php'; |
|
| 20 | +$res = 0; |
|
| 21 | +if (!$res && file_exists("../main.inc.php")) : $res = @include '../main.inc.php'; |
|
| 22 | 22 | endif; |
| 23 | -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; |
|
| 23 | +if (!$res && file_exists("../../main.inc.php")) : $res = @include '../../main.inc.php'; |
|
| 24 | 24 | endif; |
| 25 | -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; |
|
| 25 | +if (!$res && file_exists("../../../main.inc.php")) : $res = @include '../../../main.inc.php'; |
|
| 26 | 26 | endif; |
| 27 | 27 | |
| 28 | 28 | // Protection if external user |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>. |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -$res=0; |
|
| 21 | -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; |
|
| 20 | +$res = 0; |
|
| 21 | +if (!$res && file_exists("../../main.inc.php")) : $res = @include '../../main.inc.php'; |
|
| 22 | 22 | endif; |
| 23 | -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; |
|
| 23 | +if (!$res && file_exists("../../../main.inc.php")) : $res = @include '../../../main.inc.php'; |
|
| 24 | 24 | endif; |
| 25 | -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; |
|
| 25 | +if (!$res && file_exists("../../../../main.inc.php")) : $res = @include '../../../../main.inc.php'; |
|
| 26 | 26 | endif; |
| 27 | 27 | |
| 28 | 28 | // Protection if external user |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | // Set view for menu and breadcrumb |
| 45 | 45 | // Menu must be set in constructor of documentation class |
| 46 | -$documentation->view = array('Components','Progress'); |
|
| 46 | +$documentation->view = array('Components', 'Progress'); |
|
| 47 | 47 | |
| 48 | 48 | // Output sidebar |
| 49 | 49 | $documentation->showSidebar(); ?> |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>. |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -$res=0; |
|
| 21 | -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; |
|
| 20 | +$res = 0; |
|
| 21 | +if (!$res && file_exists("../../main.inc.php")) : $res = @include '../../main.inc.php'; |
|
| 22 | 22 | endif; |
| 23 | -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; |
|
| 23 | +if (!$res && file_exists("../../../main.inc.php")) : $res = @include '../../../main.inc.php'; |
|
| 24 | 24 | endif; |
| 25 | -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; |
|
| 25 | +if (!$res && file_exists("../../../../main.inc.php")) : $res = @include '../../../../main.inc.php'; |
|
| 26 | 26 | endif; |
| 27 | 27 | |
| 28 | 28 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | // Set view for menu and breadcrumb |
| 63 | 63 | // Menu must be set in constructor of documentation class |
| 64 | -$documentation->view = array('Components','Event Message'); |
|
| 64 | +$documentation->view = array('Components', 'Event Message'); |
|
| 65 | 65 | |
| 66 | 66 | // Output sidebar |
| 67 | 67 | $documentation->showSidebar(); ?> |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $label = 'My action label used for accessibility visually for impaired people'; |
| 96 | 96 | $user_right = 1; |
| 97 | 97 | |
| 98 | - $html = '<span class="fa fa-comments paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayMessages');; |
|
| 98 | + $html = '<span class="fa fa-comments paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayMessages'); ; |
|
| 99 | 99 | $action_type = 'displayeventmessages'; |
| 100 | 100 | $url = $_SERVER["PHP_SELF"].'?action=displayeventmessages'; |
| 101 | 101 | print dolGetButtonAction($label, $html, $action_type, $url, '', $user_right); ?> |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | <?php |
| 133 | 133 | $label = 'My action label used for accessibility visually for impaired people'; |
| 134 | 134 | $user_right = 1; |
| 135 | - $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayOKMessage');; |
|
| 135 | + $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayOKMessage'); ; |
|
| 136 | 136 | $action_type = 'displayeventmessageok'; |
| 137 | 137 | $url = $_SERVER["PHP_SELF"].'?action=displayeventmessageok#seteventmessagesection-contextvariations'; |
| 138 | 138 | $params['attr']['style'] = 'background: #446548'; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $label = 'My action label used for accessibility visually for impaired people'; |
| 142 | 142 | $user_right = 1; |
| 143 | - $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayWarningMessage');; |
|
| 143 | + $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayWarningMessage'); ; |
|
| 144 | 144 | $action_type = 'displayeventmessagewarning'; |
| 145 | 145 | $url = $_SERVER["PHP_SELF"].'?action=displayeventmessagewarning#seteventmessagesection-contextvariations'; |
| 146 | 146 | $params['attr']['style'] = 'background: #a28918'; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $label = 'My action label used for accessibility visually for impaired people'; |
| 150 | 150 | $user_right = 1; |
| 151 | - $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayErrorMessage');; |
|
| 151 | + $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayErrorMessage'); ; |
|
| 152 | 152 | $action_type = 'displayeventmessageerror'; |
| 153 | 153 | $url = $_SERVER["PHP_SELF"].'?action=displayeventmessageerror#seteventmessagesection-contextvariations'; |
| 154 | 154 | $params['attr']['style'] = 'background: #a72947'; |