diff --git a/.travis.yml b/.travis.yml index 0aaa07158c1..d38b4cda4ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -254,6 +254,7 @@ before_script: fi - sudo a2enmod rewrite actions fastcgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - echo "extension = libzip.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars - sudo chown -R travis:travis /var/lib/apache2/fastcgi - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm @@ -285,7 +286,7 @@ script: # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . + parallel-lint --exclude dev/namespacemig --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . set +e echo diff --git a/build/debian/conf.php.install b/build/debian/conf.php.install index 3fe41b98086..6741d7ea544 100644 --- a/build/debian/conf.php.install +++ b/build/debian/conf.php.install @@ -231,3 +231,8 @@ $dolibarr_main_prod='0'; # Default value: 0 (use database value if exist) # Examples: # $dolibarr_mailing_limit_sendbycli='0'; + +# dolibarr_distrib +# A key to identify the distribution used for first installation +$dolibarr_distrib = 'deb'; + diff --git a/build/debian/source/include-binaries b/build/debian/source/include-binaries index 401eae93712..021641d5c04 100644 --- a/build/debian/source/include-binaries +++ b/build/debian/source/include-binaries @@ -1 +1,2 @@ -htdocs/install/doctemplates/websites/website_template-corporate.zip \ No newline at end of file +htdocs/install/doctemplates/websites/website_template-corporate.zip +htdocs/install/doctemplates/websites/website_template-stellar.zip \ No newline at end of file diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 93f515d3440..994beb95eff 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -110,7 +110,7 @@ Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\m ; Mysql data files (does not overwrite if exists) Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db" ; Dolibarr -Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php" +Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,sabre\sabre\*\tests,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php" Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,initdemo\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,vagrant\*,xdebug\*" Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png" Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php" diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 59a39416b28..976f2cb6ba3 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -146,7 +146,7 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1); $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i'); */ $regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; -$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs +$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname'); $dir=''; $needtoclose=0; diff --git a/dev/initdata/dbf/import-dbf.php b/dev/initdata/dbf/import-dbf.php new file mode 100644 index 00000000000..0718a472cd6 --- /dev/null +++ b/dev/initdata/dbf/import-dbf.php @@ -0,0 +1,231 @@ +#!/usr/bin/env php + + * Copyright (C) 2016 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE + */ + +/** + * \file dev/initdata/import-dbf.php + * \brief Script example to create a table from a large DBF file (openoffice) + * To purge data, you can have a look at purge-data.php + */ +// Test si mode batch +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); + +$path = dirname(__FILE__) . '/'; +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit; +} + +// Recupere root dolibarr +$path = dirname($_SERVER["PHP_SELF"]); +require $path . "./../htdocs/master.inc.php"; +require $path . "/includes/dbase.class.php"; + +// Global variables +$version = DOL_VERSION; +$confirmed = 1; +$error = 0; + + +/* + * Main + */ + +@set_time_limit(0); +print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; +dol_syslog($script_file . " launched with arg " . implode(',', $argv)); + + +$filepath = $argv[1]; +$filepatherr = $filepath . '.err'; +$startchar = empty($argv[2]) ? 0 : (int) $argv[2]; +$deleteTable = empty($argv[3]) ? 1 : 0; +$startlinenb = empty($argv[3]) ? 1 : (int) $argv[3]; +$endlinenb = empty($argv[4]) ? 0 : (int) $argv[4]; + +if (empty($filepath)) { + print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n"; + print "Example: php $script_file myfilepath.dbf 0 2 1002\n"; + print "\n"; + exit(-1); +} +if (!file_exists($filepath)) { + print "Error: File " . $filepath . " not found.\n"; + print "\n"; + exit(-1); +} + +$ret = $user->fetch('', 'admin'); +if (!$ret > 0) { + print 'A user with login "admin" and all permissions must be created to use this script.' . "\n"; + exit; +} +$user->getrights(); + +// Ask confirmation +if (!$confirmed) { + print "Hit Enter to continue or CTRL+C to stop...\n"; + $input = trim(fgets(STDIN)); +} + +// Open input and output files +$fhandle = dbase_open($filepath, 0); +if (!$fhandle) { + print 'Error: Failed to open file ' . $filepath . "\n"; + exit(1); +} +$fhandleerr = fopen($filepatherr, 'w'); +if (!$fhandleerr) { + print 'Error: Failed to open file ' . $filepatherr . "\n"; + exit(1); +} + +$langs->setDefaultLang($defaultlang); + +$record_numbers = dbase_numrecords($fhandle); +$table_name = substr(basename($filepath), 0, strpos(basename($filepath), '.')); +print 'Info: ' . $record_numbers . " lines in file \n"; +$header = dbase_get_header_info($fhandle); +if ($deleteTable) { + $db->query("DROP TABLE IF EXISTS `$table_name`"); +} +$sqlCreate = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` INT(11) NOT NULL AUTO_INCREMENT "; +$fieldArray = array("`id`"); +foreach ($header as $value) { + $fieldName = substr(str_replace('_', '', $value['name']), $startchar); + $fieldArray[] = "`$fieldName`"; + $sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL "; +} +$sqlCreate .= ", PRIMARY KEY (`id`)) ENGINE = InnoDB"; +$resql = $db->query($sqlCreate); +if ($resql !== false) { + print "Table $table_name created\n"; +} else { + var_dump($db->errno()); + print "Impossible : " . $sqlCreate . "\n"; + die(); +} + +$i = 0; +$nboflines++; + +$fields = implode(',', $fieldArray); +//var_dump($fieldArray);die(); +$maxLength = 0; +for ($i = 1; $i <= $record_numbers; $i++) { + if ($startlinenb && $i < $startlinenb) + continue; + if ($endlinenb && $i > $endlinenb) + continue; + $row = dbase_get_record_with_names($fhandle, $i); + if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1')) + continue; + $sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,"; + array_shift($row); // remove delete column + foreach ($row as $value) { + $sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', "; + } + replaceable_echo(implode("\t", $row)); + $sqlInsert = rtrim($sqlInsert, ', '); + $sqlInsert .= ")"; + $resql = $db->query($sqlInsert); + if ($resql === false) { + print "Impossible : " . $sqlInsert . "\n"; + var_dump($row, $db->errno()); + die(); + } + // $fields = (object) $row; + // var_dump($fields); + continue; +} +die(); + + + + + +// commit or rollback +print "Nb of lines qualified: " . $nboflines . "\n"; +print "Nb of errors: " . $error . "\n"; +if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) { + print "Rollback any changes.\n"; + $db->rollback(); +} else { + print "Commit all changes.\n"; + $db->commit(); +} + +$db->close(); +fclose($fhandle); +fclose($fhandleerr); + +exit($error); + + +/** + * replaceable_echo + * + * @param string $message Message + * @param int $force_clear_lines Force clear messages + * @return void + */ +function replaceable_echo($message, $force_clear_lines = null) +{ + static $last_lines = 0; + + if (!is_null($force_clear_lines)) { + $last_lines = $force_clear_lines; + } + + $toss = array(); + $status = 0; + $term_width = exec('tput cols', $toss, $status); + if ($status) { + $term_width = 64; // Arbitrary fall-back term width. + } + + $line_count = 0; + foreach (explode("\n", $message) as $line) { + $line_count += count(str_split($line, $term_width)); + } + + // Erasure MAGIC: Clear as many lines as the last output had. + for ($i = 0; $i < $last_lines; $i++) { + // Return to the beginning of the line + echo "\r"; + // Erase to the end of the line + echo "\033[K"; + // Move cursor Up a line + echo "\033[1A"; + // Return to the beginning of the line + echo "\r"; + // Erase to the end of the line + echo "\033[K"; + // Return to the beginning of the line + echo "\r"; + // Can be consolodated into + // echo "\r\033[K\033[1A\r\033[K\r"; + } + + $last_lines = $line_count; + + echo $message . "\n"; +} diff --git a/dev/initdata/dbf/importdb-products.php b/dev/initdata/dbf/importdb-products.php new file mode 100644 index 00000000000..845064f0688 --- /dev/null +++ b/dev/initdata/dbf/importdb-products.php @@ -0,0 +1,241 @@ +#!/usr/bin/env php + + * Copyright (C) 2016 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE + */ + +/** + * \file dev/initdata/import-product.php + * \brief Script example to insert products from a csv file. + * To purge data, you can have a look at purge-data.php + */ +// Test si mode batch +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path = dirname(__FILE__) . '/'; +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit; +} + +// Recupere root dolibarr +$path = preg_replace('/importdb-products.php/i', '', $_SERVER["PHP_SELF"]); +require $path . "../../htdocs/master.inc.php"; +require $path . "includes/dbase.class.php"; +include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +//$delimiter = ','; +//$enclosure = '"'; +//$linelength = 10000; +//$escape = '/'; +// Global variables +$version = DOL_VERSION; +$confirmed = 1; +$error = 0; + +$tvas = [ + '1' => "20.00", + '2' => "5.50", + '3' => "0.00", + '4' => "20.60", + '5' => "19.60", +]; +$tvasD = [ + '1' => "20", + '2' => "5.5", + '3' => "0", + '4' => "20", + '5' => "20", +]; + +/* + * Main + */ + +@set_time_limit(0); +print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; +dol_syslog($script_file . " launched with arg " . implode(',', $argv)); + +$table = $argv[1]; + +if (empty($argv[1])) { + print "Error: Which table ?\n"; + print "\n"; + exit(-1); +} + +$ret = $user->fetch('', 'admin'); +if (!$ret > 0) { + print 'A user with login "admin" and all permissions must be created to use this script.' . "\n"; + exit; +} + +$sql = "SELECT * FROM `$table` WHERE 1"; +$resql = $db->query($sql); +if ($resql) +while ($fields = $db->fetch_array($resql)) { + $errorrecord = 0; + if ($fields === false) + continue; + $nboflines++; + + $produit = new Product($db); + $produit->type = 0; + $produit->status = 1; + $produit->ref = trim($fields['REF']); + if ($produit->ref == '') + continue; + print "Process line nb " . $j . ", ref " . $produit->ref; + $produit->label = trim($fields['LIBELLE']); + if ($produit->label == '') + $produit->label = $produit->ref; + if (empty($produit->label)) + continue; + //$produit->description = trim($fields[4] . "\n" . ($fields[5] ? $fields[5] . ' x ' . $fields[6] . ' x ' . $fields[7] : '')); + // $produit->volume = price2num($fields[8]); + // $produit->volume_unit = 0; + $produit->weight = price2num($fields['MASSE']); + $produit->weight_units = 0; // -3 = g + //$produit->customcode = $fields[10]; + $produit->barcode = str_pad($fields['CODE'], 12, "0", STR_PAD_LEFT); + $produit->barcode_type = '2'; + $produit->import_key = $fields['CODE']; + + $produit->status = 1; + $produit->status_buy = 1; + + $produit->finished = 1; + + // $produit->multiprices[0] = price2num($fields['TARIF0']); + // $produit->multiprices[1] = price2num($fields['TARIF1']); + // $produit->multiprices[2] = price2num($fields['TARIF2']); + // $produit->multiprices[3] = price2num($fields['TARIF3']); + // $produit->multiprices[4] = price2num($fields['TARIF4']); + // $produit->multiprices[5] = price2num($fields['TARIF5']); + // $produit->multiprices[6] = price2num($fields['TARIF6']); + // $produit->multiprices[7] = price2num($fields['TARIF7']); + // $produit->multiprices[8] = price2num($fields['TARIF8']); + // $produit->multiprices[9] = price2num($fields['TARIF9']); + // $produit->price_min = null; + // $produit->price_min_ttc = null; + // $produit->price = price2num($fields[11]); + // $produit->price_ttc = price2num($fields[12]); + // $produit->price_base_type = 'TTC'; + // $produit->tva_tx = price2num($fields[13]); + $produit->tva_tx = (int) ($tvas[$fields['CODTVA']]); + $produit->tva_npr = 0; + // $produit->cost_price = price2num($fields[16]); + //compta + + $produit->accountancy_code_buy = trim($fields['COMACH']); + $produit->accountancy_code_sell = trim($fields['COMVEN']); + // $produit->accountancy_code_sell_intra=trim($fields['COMVEN']); + // $produit->accountancy_code_sell_export=trim($fields['COMVEN']); + // Extrafields + // $produit->array_options['options_ecotaxdeee'] = price2num($fields[17]); + + $produit->seuil_stock_alerte = $fields['STALERTE']; + $ret = $produit->create($user, 0); + if ($ret < 0) { + print " - Error in create result code = " . $ret . " - " . $produit->errorsToString(); + $errorrecord++; + } else { + print " - Creation OK with ref " . $produit->ref . " - id = " . $ret; + } + + dol_syslog("Add prices"); + + // If we use price level, insert price for each level + if (!$errorrecord && 1) { + //$ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array()); + $ret1 = false; + for ($i = 0; $i < 10; $i++) { + if ($fields['TARIF' . ($i)] == 0) + continue; + $ret1 = $ret1 || $produit->updatePrice(price2num($fields['TARIF' . ($i)]), 'HT', $user, $produit->tva_tx, $produit->price_min, $i + 1, $produit->tva_npr, 0, 0, array()) < 0; + } + if ($ret1) { + print " - Error in updatePrice result " . $produit->errorsToString(); + $errorrecord++; + } else { + print " - updatePrice OK"; + } + } + + + // dol_syslog("Add multilangs"); + // Add alternative languages + // if (!$errorrecord && 1) { + // $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private); + // $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private); + // + // $ret = $produit->setMultiLangs($user); + // if ($ret < 0) { + // print " - Error in setMultiLangs result code = " . $ret . " - " . $produit->errorsToString(); + // $errorrecord++; + // } else { + // print " - setMultiLangs OK"; + // } + // } + + + dol_syslog("Add stocks"); + // stocks + if (!$errorrecord && $fields['STOCK'] != 0) { + $rets = $produit->correct_stock($user, 1, $fields['STOCK'], 0, 'Stock importé'); + if ($rets < 0) { + print " - Error in correct_stock result " . $produit->errorsToString(); + $errorrecord++; + } else { + print " - correct_stock OK"; + } + } + + //update date créa + if (!$errorrecord) { + $date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2); + $retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id"); + if ($retd < 1) { + print " - Error in update date créa result " . $produit->errorsToString(); + $errorrecord++; + } else { + print " - update date créa OK"; + } + } + print "\n"; + + if ($errorrecord) { + print( 'Error on record nb ' . $i . " - " . $produit->errorsToString() . "\n"); + var_dump($db); + die(); + $error++; // $errorrecord will be reset + } + $j++; +} else + die("error : $sql"); + + + + +// commit or rollback +print "Nb of lines qualified: " . $nboflines . "\n"; +print "Nb of errors: " . $error . "\n"; +$db->close(); + +exit($error); diff --git a/dev/initdata/dbf/importdb-thirdparties.php b/dev/initdata/dbf/importdb-thirdparties.php new file mode 100644 index 00000000000..8f0eb0635f0 --- /dev/null +++ b/dev/initdata/dbf/importdb-thirdparties.php @@ -0,0 +1,355 @@ +#!/usr/bin/env php + + * Copyright (C) 2016 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE + */ + +/** + * \file dev/initdata/import-product.php + * \brief Script example to insert products from a csv file. + * To purge data, you can have a look at purge-data.php + */ +// Test si mode batch +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path = dirname(__FILE__) . '/'; +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit; +} + +// Recupere root dolibarr +$path = preg_replace('/importdb-thirdparties.php/i', '', $_SERVER["PHP_SELF"]); +require $path . "../../htdocs/master.inc.php"; +require $path . "includes/dbase.class.php"; +include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +//$delimiter = ','; +//$enclosure = '"'; +//$linelength = 10000; +//$escape = '/'; +// Global variables +$version = DOL_VERSION; +$confirmed = 1; +$error = 0; + +$civilPrivate = array("MLLE", + "MM", + "MM/MADAME", + "MME", + "MME.", + "MME²", + "MMONSIEUR", + "MMR", + "MOBNSIEUR", + "MOMSIEUR", + "MON SIEUR", + "MONDIAL", + "MONIEUR", + "MONJSIEUR", + "MONNSIEUR", + "MONRIEUR", + "MONS", + "MONSIEÕR", + "MONSIER", + "MONSIERU", + "MONSIEU", + "monsieue", + "MONSIEUR", + "Monsieur     \"", + "MONSIEUR    \"", + "MONSIEUR   E", + "MONSIEUR  DENIS", + "MONSIEUR ET MME", + "MONSIEUR!", + "MONSIEUR.", + "MONSIEUR.MADAME", + "MONSIEUR3", + "MONSIEURN", + "MONSIEURT", + "MONSIEUR£", + "MONSIEYR", + "Monsigur", + "MONSIIEUR", + "MONSIUER", + "MONSIZEUR", + "MOPNSIEUR", + "MOSIEUR", + "MR", + "Mr  Mme", + "Mr - MME", + "MR BLANC", + "MR ET MME", + "mr mm", + "MR OU MME", + "Mr.", + "MR/MME", + "MRME", + "MRR", + "Mrs", + "Mademoiselle", + "MADAOME", + "madamme", + "MADAME", + "M0NSIEUR", + "M.et Madame", + "M. ET MR", + "M.", + "M%", + "M MME", + "M ET MME", + "M", + "M CROCE", + "M DIEVART", +); + +/* + * Main + */ + +@set_time_limit(0); +print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; +dol_syslog($script_file . " launched with arg " . implode(',', $argv)); + +$table = $argv[1]; + +if (empty($argv[1])) { + print "Error: Quelle table ?\n"; + print "\n"; + exit(-1); +} + +$ret = $user->fetch('', 'admin'); +if (!$ret > 0) { + print 'A user with login "admin" and all permissions must be created to use this script.' . "\n"; + exit; +} + +$sql = "SELECT * FROM `$table` WHERE 1 "; //ORDER BY REMISE DESC,`LCIVIL` DESC"; +$resql = $db->query($sql); +//$db->begin(); +if ($resql) +while ($fields = $db->fetch_array($resql)) { + $i++; + $errorrecord = 0; + + if ($startlinenb && $i < $startlinenb) + continue; + if ($endlinenb && $i > $endlinenb) + continue; + + $nboflines++; + + $object = new Societe($db); + $object->import_key = $fields['CODE']; + $object->state = 1; + $object->client = 3; + $object->fournisseur = 0; + + $object->name = $fields['FCIVIL'] . ' ' . $fields['FNOM']; + //$object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : ''; + + $date = $fields['DATCREA'] ? $fields['DATCREA'] : ($fields['DATMOD'] ? $fields['DATMOD'] : '20200101'); + $object->code_client = 'CU' . substr($date, 2, 2) . substr($date, 4, 2) . '-' . str_pad(substr($fields['CODE'], 0, 5), 5, "0", STR_PAD_LEFT); + + + $object->address = trim($fields['FADR1']); + if ($fields['FADR2']) + $object->address .= "\n" . trim($fields['FADR2']); + if ($fields['FADR3']) + $object->address .= "\n" . trim($fields['FADR3']); + + $object->zip = trim($fields['FPOSTE']); + $object->town = trim($fields['FVILLE']); + if ($fields['FPAYS']) + $object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid'); + else + $object->country_id = 1; + $object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']); + $object->phone = substr($object->phone, 0, 20); + $object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']); + $object->fax = substr($object->fax, 0, 20); + $object->email = trim($fields['FMAIL']); + // $object->idprof2 = trim($fields[29]); + $object->tva_intra = str_replace(['.', ' '], '', $fields['TVAINTRA']); + $object->tva_intra = substr($object->tva_intra, 0, 20); + $object->default_lang = 'fr_FR'; + + $object->cond_reglement_id = dol_getIdFromCode($db, 'PT_ORDER', 'c_payment_term', 'code', 'rowid', 1); + $object->multicurrency_code = 'EUR'; + + if ($fields['REMISE'] != '0.00') { + $object->remise_percent = abs($fields['REMISE']); + } + + // $object->code_client = $fields[9]; + // $object->code_fournisseur = $fields[10]; + + + if ($fields['FCIVIL']) { + $labeltype = in_array($fields['FCIVIL'], $civilPrivate) ? 'TE_PRIVATE' : 'TE_SMALL'; + $object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'code'); + } + + // Set price level + $object->price_level = $fields['TARIF'] + 1; + // if ($labeltype == 'Revendeur') + // $object->price_level = 2; + + print "Process line nb " . $i . ", code " . $fields['CODE'] . ", name " . $object->name; + + + // Extrafields + $object->array_options['options_banque'] = $fields['BANQUE']; + $object->array_options['options_banque2'] = $fields['BANQUE2']; + $object->array_options['options_banquevalid'] = $fields['VALID']; + + if (!$errorrecord) { + $ret = $object->create($user); + if ($ret < 0) { + print " - Error in create result code = " . $ret . " - " . $object->errorsToString(); + $errorrecord++; + var_dump($object->code_client, $db); + die(); + } else { + print " - Creation OK with name " . $object->name . " - id = " . $ret; + } + } + + if (!$errorrecord) { + dol_syslog("Set price level"); + $object->set_price_level($object->price_level, $user); + } + if (!$errorrecord && @$object->remise_percent) { + dol_syslog("Set remise client"); + $object->set_remise_client($object->remise_percent, 'Importé', $user); + } + + dol_syslog("Add contact"); + // Insert an invoice contact if there is an invoice email != standard email + if (!$errorrecord && ($fields['LCIVIL'] || $fields['LNOM'])) { + $madame = array("MADAME", + "MADEMOISELLE", + "MELLE", + "MLLE", + "MM", + "Mme", + "MNE", + ); + $monsieur = array("M", + "M ET MME", + "M MME", + "M.", + "M. MME", + "M. OU Mme", + "M.ou Madame", + "MONSEUR", + "MONSIER", + "MONSIEU", + "MONSIEUR", + "monsieur:mme", + "MONSIEUR¨", + "MONSIEZUR", + "MONSIUER", + "MONSKIEUR", + "MR", + ); + $ret1 = $ret2 = 0; + + $contact = new Contact($db); + if (in_array($fields['LCIVIL'], $madame)) { + // une dame + $contact->civility_id = 'MME'; + $contact->lastname = $fields['LNOM']; + } elseif (in_array($fields['LCIVIL'], $monsieur)) { + // un monsieur + $contact->civility_id = 'MR'; + $contact->lastname = $fields['LNOM']; + } elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) { + // un monsieur + $contact->civility_id = 'DR'; + $contact->lastname = $fields['LNOM']; + } else { + // un a rattraper + $contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM']; + } + $contact->address = trim($fields['LADR1']); + if ($fields['LADR2']) + $contact->address .= "\n" . trim($fields['LADR2']); + if ($fields['LADR3']) + $contact->address .= "\n" . trim($fields['LADR3']); + + $contact->zip = trim($fields['LPOSTE']); + $contact->town = trim($fields['LVILLE']); + if ($fields['FPAYS']) + $contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid'); + else + $contact->country_id = 1; + $contact->email = $fields['LMAIL']; + $contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']); + $contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']); + $contact->socid = $object->id; + + $ret1 = $contact->create($user); + if ($ret1 > 0) { + //$ret2=$contact->add_contact($object->id, 'BILLING'); + } + if ($ret1 < 0 || $ret2 < 0) { + print " - Error in create contact result code = " . $ret1 . " " . $ret2 . " - " . $contact->errorsToString(); + $errorrecord++; + } else { + print " - create contact OK"; + } + } + + + //update date créa + if (!$errorrecord) { + $datec = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2); + $retd = $db->query("UPDATE `llx_societe` SET `datec` = '$datec 00:00:00' WHERE `rowid` = $object->id"); + if ($retd < 1) { + print " - Error in update date créa result " . $object->errorsToString(); + $errorrecord++; + } else { + print " - update date créa OK"; + } + } + print "\n"; + + if ($errorrecord) { + print( 'Error on record nb ' . $i . " - " . $object->errorsToString() . "\n"); + var_dump($db, $object, $contact); + // $db->rollback(); + die(); + $error++; // $errorrecord will be reset + } + $j++; +} else + die("error : $sql"); + +$db->commit(); + + + +// commit or rollback +print "Nb of lines qualified: " . $nboflines . "\n"; +print "Nb of errors: " . $error . "\n"; +$db->close(); + +exit($error); diff --git a/dev/initdata/dbf/includes/dbase.class.php b/dev/initdata/dbf/includes/dbase.class.php new file mode 100644 index 00000000000..0c2f6820a96 --- /dev/null +++ b/dev/initdata/dbf/includes/dbase.class.php @@ -0,0 +1,402 @@ +fd = $fd; + // Byte 4-7 (32-bit number): Number of records in the database file. Currently 0 + fseek($this->fd, 4, SEEK_SET); + $this->recordCount = self::getInt32($fd); + // Byte 8-9 (16-bit number): Number of bytes in the header. + fseek($this->fd, 8, SEEK_SET); + $this->headerLength = self::getInt16($fd); + // Number of fields is (headerLength - 33) / 32) + $this->fieldCount = ($this->headerLength - 33) / 32; + // Byte 10-11 (16-bit number): Number of bytes in record. + fseek($this->fd, 10, SEEK_SET); + $this->recordLength = self::getInt16($fd); + // Byte 32 - n (32 bytes each): Field descriptor array + fseek($fd, 32, SEEK_SET); + for ($i = 0; $i < $this->fieldCount; $i++) { + $data = fread($this->fd, 32); + $field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data)); + $this->fields[] = $field; + } + } + + //bool dbase_close ( resource $dbase_identifier ) + public function close() + { + fclose($this->fd); + } + + //array dbase_get_header_info ( resource $dbase_identifier ) + public function get_header_info() + { + return $this->fields; + } + + //int dbase_numfields ( resource $dbase_identifier ) + public function numfields() + { + return $this->fieldCount; + } + + //int dbase_numrecords ( resource $dbase_identifier ) + public function numrecords() + { + return $this->recordCount; + } + + //bool dbase_add_record ( resource $dbase_identifier , array $record ) + public function add_record($record) + { + if (count($record) != $this->fieldCount) + return false; + // Seek to end of file, minus the end of file marker + fseek($this->fd, 0, SEEK_END); + // Put the deleted flag + self::putChar8($this->fd, 0x20); + // Put the record + if (!$this->putRecord($record)) + return false; + // Update the record count + fseek($this->fd, 4); + self::putInt32($this->fd, ++$this->recordCount); + return true; + } + + //bool dbase_replace_record ( resource $dbase_identifier , array $record , int $record_number ) + public function replace_record($record, $record_number) + { + if (count($record) != $this->fieldCount) + return false; + if ($record_number < 1 || $record_number > $this->recordCount) + return false; + // Skip to the record location, plus the 1 byte for the deleted flag + fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)) + 1); + return $this->putRecord($record); + } + + //bool dbase_delete_record ( resource $dbase_identifier , int $record_number ) + public function delete_record($record_number) + { + if ($record_number < 1 || $record_number > $this->recordCount) + return false; + fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1))); + self::putChar8($this->fd, 0x2A); + return true; + } + + //array dbase_get_record ( resource $dbase_identifier , int $record_number ) + public function get_record($record_number) + { + if ($record_number < 1 || $record_number > $this->recordCount) + return false; + fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1))); + $record = array( + 'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0 + ); + foreach ($this->fields as $i => &$field) { + $value = trim(fread($this->fd, $field['length'])); + if ($field['type'] == 'L') { + $value = strtolower($value); + if ($value == 't' || $value == 'y') + $value = true; + elseif ($value == 'f' || $value == 'n') + $value = false; + else + $value = null; + } + $record[$i] = $value; + } + return $record; + } + + //array dbase_get_record_with_names ( resource $dbase_identifier , int $record_number ) + public function get_record_with_names($record_number) + { + if ($record_number < 1 || $record_number > $this->recordCount) + return false; + $record = $this->get_record($record_number); + foreach ($this->fields as $i => &$field) { + $record[$field['name']] = $record[$i]; + unset($record[$i]); + } + return $record; + } + + //bool dbase_pack ( resource $dbase_identifier ) + public function pack() + { + $in_offset = $out_offset = $this->headerLength; + $new_count = 0; + $rec_count = $this->recordCount; + while ($rec_count > 0) { + fseek($this->fd, $in_offset, SEEK_SET); + $record = fread($this->fd, $this->recordLength); + $deleted = substr($record, 0, 1); + if ($deleted != '*') { + fseek($this->fd, $out_offset, SEEK_SET); + fwrite($this->fd, $record); + $out_offset += $this->recordLength; + $new_count++; + } + $in_offset += $this->recordLength; + $rec_count--; + } + ftruncate($this->fd, $out_offset); + // Update the record count + fseek($this->fd, 4); + self::putInt32($this->fd, $new_count); + } + + /* + * A few utilitiy functions + */ + + private static function length($field) + { + switch ($field[1]) { + case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format) + return 8; + case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro) + return 18; + case 'M': // Memo (ignored): All ASCII characters (stored internally as 10 digits representing a .dbt block number, right justified, padded with whitespaces) + case 'N': // Number: -.0123456789 (right justified, padded with whitespaces) + case 'F': // Float: -.0123456789 (right justified, padded with whitespaces) + case 'C': // String: All ASCII characters (padded with whitespaces up to the field's length) + return $field[2]; + case 'L': // Boolean: YyNnTtFf? (? when not initialized) + return 1; + } + return 0; + } + + /* + * Functions for reading and writing bytes + */ + + private static function getChar8($fd) + { + return ord(fread($fd, 1)); + } + + private static function putChar8($fd, $value) + { + return fwrite($fd, chr($value)); + } + + private static function getInt16($fd, $n = 1) + { + $data = fread($fd, 2 * $n); + $i = unpack("S$n", $data); + if ($n == 1) + return (int) $i[1]; + else + return array_merge($i); + } + + private static function putInt16($fd, $value) + { + return fwrite($fd, pack('S', $value)); + } + + private static function getInt32($fd, $n = 1) + { + $data = fread($fd, 4 * $n); + $i = unpack("L$n", $data); + if ($n == 1) + return (int) $i[1]; + else + return array_merge($i); + } + + private static function putInt32($fd, $value) + { + return fwrite($fd, pack('L', $value)); + } + + private static function putString($fd, $value, $length = 254) + { + $ret = fwrite($fd, pack('A' . $length, $value)); + } + + private function putRecord($record) + { + foreach ($this->fields as $i => &$field) { + $value = $record[$i]; + // Number types are right aligned with spaces + if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) { + $value = str_repeat(' ', $field['length'] - strlen($value)) . $value; + } + self::putString($this->fd, $value, $field['length']); + } + return true; + } +} + +if (!function_exists('dbase_open')) { + + function dbase_open($filename, $mode) + { + return DBase::open($filename, $mode); + } + + function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE) + { + return DBase::create($filename, $fields, $type); + } + + function dbase_close($dbase_identifier) + { + return $dbase_identifier->close(); + } + + function dbase_get_header_info($dbase_identifier) + { + return $dbase_identifier->get_header_info(); + } + + function dbase_numfields($dbase_identifier) + { + $dbase_identifier->numfields(); + } + + function dbase_numrecords($dbase_identifier) + { + return $dbase_identifier->numrecords(); + } + + function dbase_add_record($dbase_identifier, $record) + { + return $dbase_identifier->add_record($record); + } + + function dbase_delete_record($dbase_identifier, $record_number) + { + return $dbase_identifier->delete_record($record_number); + } + + function dbase_replace_record($dbase_identifier, $record, $record_number) + { + return $dbase_identifier->replace_record($record, $record_number); + } + + function dbase_get_record($dbase_identifier, $record_number) + { + return $dbase_identifier->get_record($record_number); + } + + function dbase_get_record_with_names($dbase_identifier, $record_number) + { + return $dbase_identifier->get_record_with_names($record_number); + } + + function dbase_pack($dbase_identifier) + { + return $dbase_identifier->pack(); + } +} diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 0c754b1c874..220144f2a7d 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -26,7 +26,7 @@ // Test si mode batch $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index b66d3a3abc9..129313c70fd 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -27,7 +27,7 @@ // Test si mode batch $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index 83951c57df7..49fd9860467 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -27,7 +27,7 @@ // Test si mode batch $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index ad8cf6025bb..d0b2cd4aa56 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -27,7 +27,7 @@ // Test si mode batch $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index 9f740b5705d..91c7c969b75 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -27,7 +27,7 @@ // Test si mode batch $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/import-products.php b/dev/initdata/import-products.php index e55f13c7c82..4288c5bf3b1 100755 --- a/dev/initdata/import-products.php +++ b/dev/initdata/import-products.php @@ -30,7 +30,7 @@ $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php index 558745e8d06..ef1dfcc99ab 100755 --- a/dev/initdata/import-thirdparties.php +++ b/dev/initdata/import-thirdparties.php @@ -30,7 +30,7 @@ $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/initdata/import-users.php b/dev/initdata/import-users.php index 64af2f9eb64..60a672adf12 100755 --- a/dev/initdata/import-users.php +++ b/dev/initdata/import-users.php @@ -30,7 +30,7 @@ $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; if (substr($sapi_type, 0, 3) == 'cgi') { - 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"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit; } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 015733ed95f..460f815755e 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -6,6 +6,7 @@ build/html build/aps dev/namespacemig + dev/initdata/dbf/includes documents htdocs/core/class/lessc.class.php htdocs/custom diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f36b98b15b1..46b7a532a35 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -704,9 +704,9 @@ class AccountancyExport print $end_line; foreach ($objectLines as $line) { - $date_creation = dol_print_date($line->date_creation, '%d%m%Y'); - $date_doc = dol_print_date($line->doc_date, '%d%m%Y'); - $date_valid = dol_print_date($line->date_validated, '%d%m%Y'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_doc = dol_print_date($line->doc_date, '%Y%m%d'); + $date_valid = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal.$separator; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1b68d910f0d..9352a89de78 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1747,7 +1747,7 @@ else { print ''.$langs->trans("Categories").''; print ''; - print $form->showCategories($object->id, 'member', 1); + print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); print ''; } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 30ecafcf3e4..03dee569b84 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -531,7 +531,7 @@ if ($rowid > 0) { print ''.$langs->trans("Categories").''; print ''; - print $form->showCategories($object->id, 'member', 1); + print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); print ''; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index e92060d9e11..047dcdbea4c 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -65,7 +65,7 @@ $subscription = GETPOST("subscription", "int"); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); $vote = GETPOST("vote", "int"); -$comment = GETPOST("comment", 'alphanohtml'); +$comment = GETPOST("comment", 'none'); $mail_valid = GETPOST("mail_valid", 'none'); // Security check @@ -363,7 +363,9 @@ if ($action == 'create') print ''; print ''.$langs->trans("Description").''; - print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor->Create(); print ''.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -806,10 +808,12 @@ if ($rowid > 0) print ''; print ''.$langs->trans("Description").''; - print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor->Create(); + print ""; print ''.$langs->trans("WelcomeEMail").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print ""; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f8b9556cf89..4a0d2f8e6bc 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -415,17 +415,17 @@ print ''.$langs->trans( // Name print ''; -print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; +print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; // Address print ''; -print ''."\n"; +print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; // Country print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 0364b829b2c..21d54908cf1 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -180,11 +180,11 @@ if ($action == 'install') $modulename = preg_replace('/module_/', '', $original_file); $modulename = preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename); // Search dir $modulename - $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule - //var_dump($modulenamedir); + $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule + if (!dol_is_dir($modulenamedir)) { - $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule + $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule //var_dump($modulenamedir); if (!dol_is_dir($modulenamedir)) { @@ -207,6 +207,7 @@ if ($action == 'install') $modulenamearrays = explode("\n", $metafile); } $modulenamearrays[$modulename] = $modulename; + //var_dump($modulenamearrays);exit; foreach ($modulenamearrays as $modulenameval) { if (strpos($modulenameval, '#') === 0) continue; // Discard comments @@ -216,15 +217,14 @@ if ($action == 'install') // Now we install the module if (!$error) { - //var_dump($dirins); @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file dol_syslog("We copy now directory ".$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval." into target dir ".$dirins.'/'.$modulenameval); - $result = dolCopyDir($conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval, '0444', 1); + $result = dolCopyDir($modulenamedir, $dirins.'/'.$modulenameval, '0444', 1); if ($result <= 0) { dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING); $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyDir", $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval), null, 'errors'); + setEventMessages($langs->trans("ErrorFailToCopyDir", $modulenamedir, $dirins.'/'.$modulenameval), null, 'errors'); $error++; } } diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index bcc3aba20d4..09da33c071e 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("admin"); +$langs->load("install"); +$langs->load("errors"); if (! $user->admin) accessforbidden(); @@ -66,21 +68,123 @@ if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) print '
'; } - print ''; print ''; print "\n"; +$ErrorPicturePath = "../../theme/eldy/img/error.png"; +$WarningPicturePath = "../../theme/eldy/img/warning.png"; +$OkayPicturePath = "../../theme/eldy/img/tick.png"; -// Get PHP version -$phpversion=version_php(); -print '\n"; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Version")."".$phpversion."
'.$langs->trans("Version").''; +$arrayphpminversionerror = array(5,5,0); +$arrayphpminversionwarning = array(5,5,0); +if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) +{ + print 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror)); +} +elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) +{ + print 'Warning '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning)); +} +else +{ + print 'Ok '.versiontostring(versionphparray()); +} + +print '
GET and POST support'; + +if (! isset($_GET["testget"]) && ! isset($_POST["testpost"]) && ! isset($_GET["mainmenu"])) +{ + print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); + print ' ('.$langs->trans("Recheck").')'; +} +else +{ + print 'Ok '.$langs->trans("PHPSupportPOSTGETOk"); +} + +print '
Sessions support'; + +if (! function_exists("session_id")) +{ + print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions"); +} +else +{ + print 'Ok '.$langs->trans("PHPSupportSessions"); +} + +print '
GD support'; + +if (! function_exists("imagecreate")) +{ + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportGD"); +} +else +{ + print 'Ok '.$langs->trans("PHPSupportGD"); +} + +print '
Curl support'; + +if (! function_exists("curl_init")) +{ + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportCurl"); +} +else +{ + print 'Ok '.$langs->trans("PHPSupportCurl"); +} + +print '
UTF-8 support'; + +if (! function_exists("utf8_encode")) +{ + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportUTF8"); +} +else +{ + print 'Ok '.$langs->trans("PHPSupportUTF8"); +} + +print '
Intl support'; + +if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') +{ + if (! function_exists("locale_get_primary_language") || ! function_exists("locale_get_region")) + { + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportIntl"); + } + else + { + print 'Ok '.$langs->trans("PHPSupportIntl"); + } +} + +print '
Zip support'; + +if (!class_exists('ZipArchive')) +{ + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupport", "Zip"); +} +else +{ + print 'Ok '.$langs->trans("PHPSupport", "Zip"); +} + +print '
'; + print '
'; - - // Get php_info array $phparray=phpinfo_array(); foreach($phparray as $key => $value) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 26906735d68..1500dd0dc4d 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -81,9 +81,9 @@ $type=$db->type; $help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; llxHeader('', '', $help_url); +print ''."\n"; } - + /** + * Output HTML string to total value + * + * @return string HTML string to total value + */ + public function total() + { + $value = 0; + foreach($this->data as $valarray) // Loop on each x + { + $value += $valarray[1]; + } + return $value; + } /** * Output HTML string to show graph diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fbd00c99281..2c2064a0619 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3008,7 +3008,6 @@ class Form * @param int $productid Id of product * @param string $htmlname Name of HTML field * @param int $selected_supplier Pre-selected supplier if more than 1 result - * * @return string */ public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') @@ -5911,6 +5910,7 @@ class Form //var_dump($objecttmp->filter); $prefixforautocompletemode = $objecttmp->element; if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company'; + if ($prefixforautocompletemode == 'product') $prefixforautocompletemode='produit'; $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG); @@ -7843,4 +7843,171 @@ class Form return $out; } + + /** + * Output a combo list with invoices qualified for a third party + * + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id invoice preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. + * @param string $showproject 'all' = Show project info, ''=Hide project info + * @param User $usertofilter User object to use for filtering + * @return int Nbr of project if OK, <0 if KO + */ + public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) + { + global $user,$conf,$langs; + + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + if (is_null($usertofilter)) + { + $usertofilter = $user; + } + + $out=''; + + $hideunselectables = false; + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + + if (empty($projectsListId)) + { + if (empty($usertofilter->rights->projet->all->lire)) + { + $projectstatic=new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1); + } + } + + // Search all projects + $sql = 'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref, + p.title, p.fk_soc, p.fk_statut, p.public,'; + $sql.= ' s.nom as name'; + $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,'; + $sql.= ' '.MAIN_DB_PREFIX.'facture as f'; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; + $sql.= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement + //if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")"; + //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; + //if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; + $sql.= " GROUP BY f.ref ORDER BY p.ref, f.ref ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + // Use select2 selector + if (! empty($conf->use_javascript_ajax)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $out.=$comboenhancement; + $morecss='minwidth200imp maxwidth500'; + } + + if (empty($option_only)) { + $out.= ''; + } + + print $out; + + $this->db->free($resql); + return $num; + } + else + { + dol_print_error($this->db); + return -1; + } + } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0ce761d12b8..fb9e292ba83 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -29,17 +29,17 @@ */ class Translate { - public $dir; // Directories that contains /langs subdirectory + public $dir; // Directories that contains /langs subdirectory - public $defaultlang; // Current language for current user - public $charset_output='UTF-8'; // Codage used by "trans" method outputs + public $defaultlang; // Current language for current user + public $charset_output = 'UTF-8'; // Codage used by "trans" method outputs - public $tab_translate=array(); // Array of all translations key=>value - private $_tab_loaded=array(); // Array to store result after loading each language file + public $tab_translate = array(); // Array of all translations key=>value + private $_tab_loaded = array(); // Array to store result after loading each language file - public $cache_labels=array(); // Cache for labels return by getLabelFromKey method - public $cache_currencies=array(); // Cache to store currency symbols - private $cache_currencies_all_loaded=false; + public $cache_labels = array(); // Cache for labels return by getLabelFromKey method + public $cache_currencies = array(); // Cache to store currency symbols + private $cache_currencies_all_loaded = false; /** @@ -50,9 +50,9 @@ class Translate */ public function __construct($dir, $conf) { - if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced - if ($dir) $this->dir=array($dir); - else $this->dir=$conf->file->dol_document_root; + if (!empty($conf->file->character_set_client)) $this->charset_output = $conf->file->character_set_client; // If charset output is forced + if ($dir) $this->dir = array($dir); + else $this->dir = $conf->file->dol_document_root; } @@ -69,59 +69,59 @@ class Translate //dol_syslog(get_class($this)."::setDefaultLang srclang=".$srclang,LOG_DEBUG); // If a module ask to force a priority on langs directories (to use its own lang files) - if (! empty($conf->global->MAIN_FORCELANGDIR)) + if (!empty($conf->global->MAIN_FORCELANGDIR)) { - $more=array(); - $i=0; - foreach($conf->file->dol_document_root as $dir) + $more = array(); + $i = 0; + foreach ($conf->file->dol_document_root as $dir) { - $newdir=$dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' - if (! in_array($newdir, $this->dir)) + $newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' + if (!in_array($newdir, $this->dir)) { - $more['module_'.$i]=$newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. + $more['module_'.$i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. } } - $this->dir=array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir) + $this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir) } - $this->origlang=$srclang; + $this->origlang = $srclang; if (empty($srclang) || $srclang == 'auto') { // $_SERVER['HTTP_ACCEPT_LANGUAGE'] can be 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6' but can contains also malicious content - $langpref=empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])?'':$_SERVER['HTTP_ACCEPT_LANGUAGE']; - $langpref=preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part - $langpref=str_replace("-", "_", $langpref); - $langlist=preg_split("/[;,]/", $langpref); - $codetouse=preg_replace('/[^_a-zA-Z]/', '', $langlist[0]); + $langpref = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? '' : $_SERVER['HTTP_ACCEPT_LANGUAGE']; + $langpref = preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part + $langpref = str_replace("-", "_", $langpref); + $langlist = preg_split("/[;,]/", $langpref); + $codetouse = preg_replace('/[^_a-zA-Z]/', '', $langlist[0]); } - else $codetouse=$srclang; + else $codetouse = $srclang; // We redefine $srclang - $langpart=explode("_", $codetouse); + $langpart = explode("_", $codetouse); //print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'
'; - if (! empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY + if (!empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY { // Array force long code from first part, even if long code is defined - $longforshort=array('ar'=>'ar_SA'); - $longforshortexcep=array('ar_EG'); - if (isset($longforshort[strtolower($langpart[0])]) && ! in_array($codetouse, $longforshortexcep)) $srclang=$longforshort[strtolower($langpart[0])]; - elseif (! is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser - $srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]); - $longforlong=array('no_nb'=>'nb_NO'); - if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)]; + $longforshort = array('ar'=>'ar_SA'); + $longforshortexcep = array('ar_EG'); + if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep)) $srclang = $longforshort[strtolower($langpart[0])]; + elseif (!is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser + $srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]); + $longforlong = array('no_nb'=>'nb_NO'); + if (isset($longforlong[strtolower($srclang)])) $srclang = $longforlong[strtolower($srclang)]; } - else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]); + else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); } else { // If it's for a codetouse that is a short code xx // Array to convert short lang code into long code. - $longforshort=array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO'); - if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])]; - elseif (! empty($langpart[0])) $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]); - else $srclang='en_US'; + $longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO'); + if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])]; + elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); + else $srclang = 'en_US'; } - $this->defaultlang=$srclang; + $this->defaultlang = $srclang; //print 'this->defaultlang='.$this->defaultlang; } @@ -148,7 +148,7 @@ class Translate */ public function loadLangs($domains) { - foreach($domains as $domain) + foreach ($domains as $domain) { $this->load($domain); } @@ -176,7 +176,7 @@ class Translate */ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) { - global $conf,$db; + global $conf, $db; //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); @@ -186,18 +186,18 @@ class Translate dol_print_error('', get_class($this)."::Load ErrorWrongParameters"); return -1; } - if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys + if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys // Load $this->tab_translate[] from database - if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database. + if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database. $newdomain = $domain; $modulename = ''; // Search if a module directory name is provided into lang file name - $regs=array(); + $regs = array(); if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs)) { $newdomain = $regs[1]; @@ -205,19 +205,19 @@ class Translate } // Check cache - if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain + if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain { //dol_syslog("Translate::Load already loaded for newdomain=".$newdomain); return 0; } - $fileread=0; - $langofdir=(empty($forcelangdir)?$this->defaultlang:$forcelangdir); + $fileread = 0; + $langofdir = (empty($forcelangdir) ? $this->defaultlang : $forcelangdir); // Redefine alt - $langarray=explode('_', $langofdir); - if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt=1; - if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt=2; + $langarray = explode('_', $langofdir); + if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt = 1; + if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt = 2; if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { @@ -225,13 +225,13 @@ class Translate return -1; } - foreach($this->dir as $searchdir) + foreach ($this->dir as $searchdir) { // Directory of translation files - $file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang"; - $file_lang_osencoded=dol_osencode($file_lang); + $file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang"; + $file_lang_osencoded = dol_osencode($file_lang); - $filelangexists=is_file($file_lang_osencoded); + $filelangexists = is_file($file_lang_osencoded); //dol_syslog(get_class($this).'::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' file_lang='.$file_lang." => filelangexists=".$filelangexists); //print 'Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' this->_tab_loaded[newdomain]='.$this->_tab_loaded[$newdomain].' file_lang='.$file_lang." => filelangexists=".$filelangexists."\n"; @@ -239,19 +239,19 @@ class Translate if ($filelangexists) { // TODO Move cache read out of loop on dirs or at least filelangexists - $found=false; + $found = false; // Enable caching of lang file in memory (not by default) - $usecachekey=''; + $usecachekey = ''; // Using a memcached server - if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER)) + if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { - $usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars + $usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars } // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $usecachekey=$newdomain; + $usecachekey = $newdomain; } if ($usecachekey) @@ -259,23 +259,23 @@ class Translate //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); //global $aaa; $aaa+=1; //print $aaa." ".$usecachekey."\n"; - require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php'; - $tmparray=dol_getcache($usecachekey); + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $tmparray = dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) { - $this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added. + $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added. //print $newdomain."\n"; //var_dump($this->tab_translate); - if ($alt == 2) $fileread=1; - $found=true; // Found in dolibarr PHP cache + if ($alt == 2) $fileread = 1; + $found = true; // Found in dolibarr PHP cache } } - if (! $found) + if (!$found) { if ($fp = @fopen($file_lang, "rt")) { - if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache + if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache /** * Read each lines until a '=' (with any combination of spaces around it) @@ -316,21 +316,21 @@ class Translate } } fclose($fp); - $fileread=1; + $fileread = 1; // TODO Move cache write out of loop on dirs // To save lang content for usecachekey into cache if ($usecachekey && count($tabtranslatedomain)) { - $ressetcache=dol_setcache($usecachekey, $tabtranslatedomain); + $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain); if ($ressetcache < 0) { - $error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; + $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; dol_syslog($error, LOG_ERR); } } - if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop. + if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop. } } } @@ -341,10 +341,10 @@ class Translate { // This function MUST NOT contains call to syslog //dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG); - $langofdir=strtolower($langarray[0]).'_'.strtoupper($langarray[0]); - if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR' - if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA' - $this->load($domain, $alt+1, $stopafterdirection, $langofdir); + $langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]); + if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR' + if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA' + $this->load($domain, $alt + 1, $stopafterdirection, $langofdir); } // Now we complete with reference file (en_US) @@ -352,38 +352,38 @@ class Translate { // This function MUST NOT contains call to syslog //dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG); - $langofdir='en_US'; - $this->load($domain, $alt+1, $stopafterdirection, $langofdir); + $langofdir = 'en_US'; + $this->load($domain, $alt + 1, $stopafterdirection, $langofdir); } // We are in the pass of the reference file. No more files to scan to complete. if ($alt == 2) { - if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as found so loaded + if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as found so loaded - if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Set this file as not found + if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Set this file as not found } // This part is deprecated and replaced with table llx_overwrite_trans // Kept for backward compatibility. if (empty($loadfromfileonly)) { - $overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 + $overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang; + if (!empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 { // Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX - $tmparray=explode(',', $conf->global->$overwritekey); - foreach($tmparray as $tmp) + $tmparray = explode(',', $conf->global->$overwritekey); + foreach ($tmparray as $tmp) { - $tmparray2=explode(':', $tmp); - if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1]; + $tmparray2 = explode(':', $tmp); + if (!empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]] = $tmparray2[1]; } } } // Check to be sure that SeparatorDecimal differs from SeparatorThousand - if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"]) - && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]=''; + if (!empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"]) + && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"] = ''; return 1; } @@ -404,26 +404,26 @@ class Translate { global $conf; - $domain='database'; + $domain = 'database'; // Check parameters - if (empty($db)) return 0; // Database handler can't be used + if (empty($db)) return 0; // Database handler can't be used //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); $newdomain = $domain; // Check cache - if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database' + if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database' { //dol_syslog("Translate::Load already loaded for newdomain=".$newdomain); return 0; } - $this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database' + $this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database' - $fileread=0; - $langofdir=$this->defaultlang; + $fileread = 0; + $langofdir = $this->defaultlang; if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { @@ -432,19 +432,19 @@ class Translate } // TODO Move cache read out of loop on dirs or at least filelangexists - $found=false; + $found = false; // Enable caching of lang file in memory (not by default) - $usecachekey=''; + $usecachekey = ''; // Using a memcached server - if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER)) + if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { - $usecachekey=$newdomain.'_'.$langofdir; // Should not contains special chars + $usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars } // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $usecachekey=$newdomain; + $usecachekey = $newdomain; } if ($usecachekey) @@ -452,40 +452,40 @@ class Translate //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); //global $aaa; $aaa+=1; //print $aaa." ".$usecachekey."\n"; - require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php'; - $tmparray=dol_getcache($usecachekey); + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $tmparray = dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) { - $this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added. + $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added. //print $newdomain."\n"; //var_dump($this->tab_translate); - $fileread=1; - $found=true; // Found in dolibarr PHP cache + $fileread = 1; + $found = true; // Found in dolibarr PHP cache } } - if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) + if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql ="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL"; - $sql.=" AND entity IN (0, ".getEntity('overwrite_trans').")"; - $sql.=$db->order("lang", "DESC"); - $resql=$db->query($sql); + $sql = "SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL"; + $sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")"; + $sql .= $db->order("lang", "DESC"); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { - if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache + if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache $i = 0; while ($i < $num) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); - $key=$obj->transkey; - $value=$obj->transvalue; + $key = $obj->transkey; + $value = $obj->transvalue; //print "Domain=$domain, found a string for $tab[0] with value $tab[1]
"; if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) @@ -493,22 +493,22 @@ class Translate // Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s' $this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value); - if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache + if ($usecachekey) $tabtranslatedomain[$key] = $value; // To save lang content in cache } $i++; } - $fileread=1; + $fileread = 1; // TODO Move cache write out of loop on dirs // To save lang content for usecachekey into cache if ($usecachekey && count($tabtranslatedomain)) { - $ressetcache=dol_setcache($usecachekey, $tabtranslatedomain); + $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain); if ($ressetcache < 0) { - $error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; + $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; dol_syslog($error, LOG_ERR); } } @@ -520,9 +520,9 @@ class Translate } } - if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as loaded + if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded - if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Marque ce cas comme non trouve (no lines found for language) + if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language) return 1; } @@ -544,28 +544,28 @@ class Translate { global $conf, $db; - if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. + if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. - $newstr=$key; + $newstr = $key; if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg)) { - $newstr=$this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label'); + $newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label'); } elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg)) { - $newstr=$this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label'); + $newstr = $this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label'); } elseif (preg_match('/^SendingMethod([0-9A-Z]+)$/i', $key, $reg)) { - $newstr=$this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle'); + $newstr = $this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle'); } elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i', $key, $reg)) { - $newstr=$this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1); + $newstr = $this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1); } elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i', $key, $reg)) { - $newstr=$this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label'); + $newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label'); } elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg)) { @@ -601,37 +601,37 @@ class Translate { global $conf; - if (! empty($this->tab_translate[$key])) // Translation is available + if (!empty($this->tab_translate[$key])) // Translation is available { - $str=$this->tab_translate[$key]; + $str = $this->tab_translate[$key]; // Make some string replacement after translation - $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 + $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang; + if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 { - $tmparray=explode(';', $conf->global->$replacekey); - foreach($tmparray as $tmp) + $tmparray = explode(';', $conf->global->$replacekey); + foreach ($tmparray as $tmp) { - $tmparray2=explode(':', $tmp); - $str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); + $tmparray2 = explode(':', $tmp); + $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); } } if (strpos($key, 'Format') !== 0) { - $str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings. + $str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings. } - if ($maxsize) $str=dol_trunc($str, $maxsize); + if ($maxsize) $str = dol_trunc($str, $maxsize); // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities - $str=str_replace(array('<','>','"',), array('__lt__','__gt__','__quot__'), $str); + $str = str_replace(array('<', '>', '"',), array('__lt__', '__gt__', '__quot__'), $str); // Crypt string into HTML - $str=htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content + $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content // Restore HTML tags - $str=str_replace(array('__lt__','__gt__','__quot__'), array('<','>','"',), $str); + $str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"',), $str); return $str; } @@ -682,26 +682,26 @@ class Translate { global $conf; - if (! empty($this->tab_translate[$key])) // Translation is available + if (!empty($this->tab_translate[$key])) // Translation is available { - $str=$this->tab_translate[$key]; + $str = $this->tab_translate[$key]; // Make some string replacement after translation - $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 + $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang; + if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 { - $tmparray=explode(';', $conf->global->$replacekey); - foreach($tmparray as $tmp) + $tmparray = explode(';', $conf->global->$replacekey); + foreach ($tmparray as $tmp) { - $tmparray2=explode(':', $tmp); - $str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); + $tmparray2 = explode(':', $tmp); + $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); } } - if (! preg_match('/^Format/', $key)) + if (!preg_match('/^Format/', $key)) { //print $str; - $str=sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings. + $str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings. } return $str; @@ -751,8 +751,8 @@ class Translate */ public function convToOutputCharset($str, $pagecodefrom = 'UTF-8') { - if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str); - if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str)); + if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str = utf8_encode($str); + if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str = utf8_decode(str_replace('€', chr(128), $str)); return $str; } @@ -772,21 +772,21 @@ class Translate global $conf; // We scan directory langs to detect available languages - $handle=opendir($langdir."/langs"); - $langs_available=array(); + $handle = opendir($langdir."/langs"); + $langs_available = array(); while ($dir = trim(readdir($handle))) { if (preg_match('/^[a-z]+_[A-Z]+/i', $dir)) { $this->load("languages"); - if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue; + if (!empty($conf->global->MAIN_LANGUAGES_ALLOWED) && !in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED))) continue; if ($usecode == 2) { $langs_available[$dir] = $dir; } - if ($usecode == 1 || ! empty($conf->global->MAIN_SHOW_LANGUAGE_CODE)) + if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE)) { $langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength); } @@ -812,7 +812,7 @@ class Translate { // phpcs:enable // Test si fichier dans repertoire de la langue - foreach($this->dir as $searchdir) + foreach ($this->dir as $searchdir) { if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) return true; @@ -844,22 +844,22 @@ class Translate { global $conf; - $newnumber=$number; + $newnumber = $number; - $dirsubstitutions=array_merge(array(), $conf->modules_parts['substitutions']); - foreach($dirsubstitutions as $reldir) + $dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']); + foreach ($dirsubstitutions as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); // Check if directory exists - if (! is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded + if (!is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded - $fonc='numberwords'; + $fonc = 'numberwords'; if (file_exists($newdir.'/functions_'.$fonc.'.lib.php')) { include_once $newdir.'/functions_'.$fonc.'.lib.php'; - $newnumber=numberwords_getLabelFromNumber($this, $number, $isamount); + $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); break; } } @@ -891,36 +891,36 @@ class Translate //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit; // Check if a translation is available (this can call getTradFromKey) - $tmp=$this->transnoentitiesnoconv($key); + $tmp = $this->transnoentitiesnoconv($key); if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString') { - return $tmp; // Found in language array + return $tmp; // Found in language array } // Check in cache if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or '' { - return $this->cache_labels[$tablename][$key]; // Found in cache + return $this->cache_labels[$tablename][$key]; // Found in cache } $sql = "SELECT ".$fieldlabel." as label"; - $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; - $sql.= " WHERE ".$fieldkey." = '".$db->escape($keyforselect?$keyforselect:$key)."'"; - if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')'; + $sql .= " FROM ".MAIN_DB_PREFIX.$tablename; + $sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'"; + if ($filteronentity) $sql .= " AND entity IN (".getEntity($tablename).')'; dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $this->cache_labels[$tablename][$key]=$obj->label; - else $this->cache_labels[$tablename][$key]=$key; + if ($obj) $this->cache_labels[$tablename][$key] = $obj->label; + else $this->cache_labels[$tablename][$key] = $key; $db->free($resql); return $this->cache_labels[$tablename][$key]; } else { - $this->error=$db->lasterror(); + $this->error = $db->lasterror(); return -1; } } @@ -937,7 +937,7 @@ class Translate */ public function getCurrencyAmount($currency_code, $amount) { - $symbol=$this->getCurrencySymbol($currency_code); + $symbol = $this->getCurrencySymbol($currency_code); if (in_array($currency_code, array('USD'))) return $symbol.$amount; else return $amount.$symbol; @@ -953,22 +953,22 @@ class Translate */ public function getCurrencySymbol($currency_code, $forceloadall = 0) { - $currency_sign = ''; // By default return iso code + $currency_sign = ''; // By default return iso code if (function_exists("mb_convert_encoding")) { - $this->loadCacheCurrencies($forceloadall?'':$currency_code); + $this->loadCacheCurrencies($forceloadall ? '' : $currency_code); - if (isset($this->cache_currencies[$currency_code]) && ! empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) + if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) { - foreach($this->cache_currencies[$currency_code]['unicode'] as $unicode) + foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode) { $currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES'); } } } - return ($currency_sign?$currency_sign:$currency_code); + return ($currency_sign ? $currency_sign : $currency_code); } /** @@ -981,13 +981,13 @@ class Translate { global $db; - if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all - if (! empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency + if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all + if (!empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency $sql = "SELECT code_iso, label, unicode"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; - $sql.= " WHERE active = 1"; - if (! empty($currency_code)) $sql.=" AND code_iso = '".$db->escape($currency_code)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies"; + $sql .= " WHERE active = 1"; + if (!empty($currency_code)) $sql .= " AND code_iso = '".$db->escape($currency_code)."'"; //$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG); @@ -995,8 +995,8 @@ class Translate if ($resql) { $this->load("dict"); - $label=array(); - if (! empty($currency_code)) foreach($this->cache_currencies as $key => $val) $label[$key]=$val['label']; // Label in already loaded cache + $label = array(); + if (!empty($currency_code)) foreach ($this->cache_currencies as $key => $val) $label[$key] = $val['label']; // Label in already loaded cache $num = $db->num_rows($resql); $i = 0; @@ -1005,12 +1005,12 @@ class Translate $obj = $db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$this->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); + $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true); $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; $i++; } - if (empty($currency_code)) $this->cache_currencies_all_loaded=true; + if (empty($currency_code)) $this->cache_currencies_all_loaded = true; //print count($label).' '.count($this->cache_currencies); // Resort cache @@ -1037,7 +1037,7 @@ class Translate // phpcs:enable $substitutionarray = array(); - foreach($this->tab_translate as $code => $label) { + foreach ($this->tab_translate as $code => $label) { $substitutionarray['lang_'.$code] = $label; $substitutionarray['__('.$code.')__'] = $label; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 36d471408ee..2ac64565e9c 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -233,7 +233,7 @@ class Utils $outputdir = $conf->admin->dir_output.'/backup'; $result = dol_mkdir($outputdir); - + $errormsg = ''; // MYSQL if ($type == 'mysql' || $type == 'mysqli') @@ -296,7 +296,6 @@ class Utils $paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"'; } - $errormsg = ''; $handle = ''; // Start call method to execute dump @@ -383,6 +382,8 @@ class Utils { // Get 2048 first chars of error message. $errormsg = fgets($handle, 2048); + //$ok=0;$errormsg=''; To force error + // Close file if ($compression == 'none') fclose($handle); if ($compression == 'gz') gzclose($handle); @@ -492,7 +493,7 @@ class Utils } // Clean old files - if ($keeplastnfiles > 0) + if (! $errormsg && $keeplastnfiles > 0) { $tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC); $i = 0; @@ -504,7 +505,7 @@ class Utils } } - return 0; + return ($errormsg ? -1 : 0); } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 587b8ab8434..9b0fd948c9e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2082,9 +2082,10 @@ function dol_uncompress($inputfile, $outputdir) * @param string $outputfile Target file name (output directory must exists and be writable) * @param string $mode 'zip' * @param string $excludefiles A regex pattern. For example: '/\.log$|\/temp\//' + * @param string $rootdirinzip Add a root dir level in zip file * @return int <0 if KO, >0 if OK */ -function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '') +function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '', $rootdirinzip = '') { $foundhandler=0; @@ -2145,7 +2146,8 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = { // Get real and relative path for current file $filePath = $file->getRealPath(); - $relativePath = substr($filePath, strlen($inputdir) + 1); + $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1); + if (empty($excludefiles) || ! preg_match($excludefiles, $filePath)) { // Add current file to archive diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 75a7efe53d2..6c5a049597e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1639,13 +1639,14 @@ function dol_bc($var, $moreclass = '') } /** - * Return a formated address (part address/zip/town/state) according to country rules + * Return a formated address (part address/zip/town/state) according to country rules. + * See https://en.wikipedia.org/wiki/Address * * @param Object $object A company or contact object - * @param int $withcountry 1=Add country into address string - * @param string $sep Separator to use to build string - * @param Translate $outputlangs Object lang that contains language for text translation. - * @param int $mode 0=Standard output, 1=Remove address + * @param int $withcountry 1=Add country into address string + * @param string $sep Separator to use to build string + * @param Translate $outputlangs Object lang that contains language for text translation. + * @param int $mode 0=Standard output, 1=Remove address * @return string Formated string * @see dol_print_address() */ @@ -1656,6 +1657,8 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS + // See format of addresses on https://en.wikipedia.org/wiki/Address + // Address if (empty($mode)) { $ret .= $object->address; @@ -1692,7 +1695,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs { $ret .= ($ret ? $sep : '').$object->zip; $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); - $ret .= ($object->state_id ? (' ('.($object->state_id).')') : ''); + $ret .= ($object->state_code ? (' '.($object->state_code)) : ''); } else // Other: title firstname name \n address lines \n zip town \n country { @@ -6036,6 +6039,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : ''); + $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : ''); $birthday = dol_print_date($object->birth, 'day'); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index daf0ed5b234..861017b2844 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -222,7 +222,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $export_permission; public $export_fields_array; - public $export_TypeFields_array; + public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid' public $export_entities_array; public $export_special_array; // special or computed field public $export_dependencies_array; diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php deleted file mode 100644 index 43cb4d6e9cd..00000000000 --- a/htdocs/core/modules/export/export_excel.modules.php +++ /dev/null @@ -1,526 +0,0 @@ - - * Copyright (C) 2012 Marcos García - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/export/export_excel.modules.php - * \ingroup export - * \brief File of class to generate export file with Excel format - */ - -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - -/** - * Class to build export files with Excel format - */ -class ExportExcel extends ModeleExports -{ - /** - * @var string ID - */ - public $id; - - /** - * @var string Export Excel label - */ - public $label; - - public $extension; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - public $label_lib; - - public $version_lib; - - public $workbook; // Handle file - - public $worksheet; // Handle sheet - - public $row; - - public $col; - - public $file; // To save filename - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $conf, $langs; - $this->db = $db; - - $this->id='excel'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Excel 95 (old library)'; // Label of driver - $this->desc = $langs->trans('Excel95FormatDesc'); - $this->extension='xls'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto - $this->version='1.30'; // Driver version - - $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) - - if (empty($this->disabled)) - { - // If driver use an external library, put its name here - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; - $this->label_lib='PhpWriteExcel'; - $this->version_lib='unknown'; - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; // No way to get info from library - } - } - - $this->row=0; - } - - /** - * getDriverId - * - * @return string - */ - public function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Return driver label - */ - public function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string - */ - public function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string - */ - public function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string - */ - public function getDriverVersion() - { - return $this->version; - } - - /** - * getLibLabel - * - * @return string - */ - public function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string - */ - public function getLibVersion() - { - return $this->version_lib; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Open output file - * - * @param string $file File name to generate - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >=0 if OK - */ - public function open_file($file, $outputlangs) - { - // phpcs:enable - global $user,$conf,$langs; - - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO - } - - dol_syslog(get_class($this)."::open_file file=".$file); - $this->file=$file; - - $ret=1; - - $outputlangs->load("exports"); - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) { - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; - $this->workbook = new writeexcel_workbookbig($file); - $this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory - $this->workbook->set_sheetname($outputlangs->trans("Sheet")); - $this->worksheet = &$this->workbook->addworksheet(); - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - - if ($this->id == 'excel2007') - { - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive - { - $langs->load("errors"); - $this->error=$langs->trans('ErrorPHPNeedModule', 'zip'); - return -1; - } - } - - if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) { - $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; - $cacheSettings = array ( - 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR - ); - PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); - } - - $this->workbook = new PHPExcel(); - $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - '.DOL_APPLICATION_TITLE.' '.DOL_VERSION); - //$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION); - $this->workbook->getProperties()->setTitle(basename($file)); - $this->workbook->getProperties()->setSubject(basename($file)); - $this->workbook->getProperties()->setDescription(DOL_APPLICATION_TITLE.' '.DOL_VERSION); - - $this->workbook->setActiveSheetIndex(0); - $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet")); - $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16); - } - return $ret; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write header - * - * @param Translate $outputlangs Object lang to translate values - * @return int <0 if KO, >0 if OK - */ - public function write_header($outputlangs) - { - // phpcs:enable - //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO - - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output title line into file - * - * @param array $array_export_fields_label Array with list of label of fields - * @param array $array_selected_sorted Array with list of field to export - * @param Translate $outputlangs Object lang to translate values - * @param array $array_types Array with types of fields - * @return int <0 if KO, >0 if OK - */ - public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - // Create a format for the column headings - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO - - $formatheader =$this->workbook->addformat(); - $formatheader->set_bold(); - $formatheader->set_color('blue'); - //$formatheader->set_size(12); - //$formatheader->set_font("Courier New"); - //$formatheader->set_align('center'); - } - else - { - $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true); - $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); - } - - $this->col=0; - foreach($array_selected_sorted as $code => $value) - { - $alias=$array_export_fields_label[$code]; - //print "dd".$alias; - if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.'); - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader); - } - else - { - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias)); - if (! empty($array_types[$code]) && in_array($array_types[$code], array('Date','Numeric','TextAuto'))) // Set autowidth for some types - { - $this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true); - } - } - $this->col++; - } - $this->row++; - return 0; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output record line into file - * - * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select - * @param Translate $outputlangs Object lang to translate values - * @param array $array_types Array with types of fields - * @return int <0 if KO, >0 if OK - */ - public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - // Create a format for the column headings - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO - } - - // Define first row - $this->col=0; - - $reg=array(); - - foreach($array_selected_sorted as $code => $value) - { - if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code); - else $alias=substr($code, strpos($code, ' as ') + 4); - if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.'); - $newvalue=$objp->$alias; - - $newvalue=$this->excel_clean($newvalue); - $typefield=isset($array_types[$code])?$array_types[$code]:''; - - if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7)) - { - $array = unserialize($typefield); - $array = $array['options']; - $newvalue = $array[$newvalue]; - } - - // Traduction newvalue - if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) - { - $newvalue=$outputlangs->transnoentities($reg[1]); - } - else - { - $newvalue=$outputlangs->convToOutputCharset($newvalue); - } - - if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue)) - { - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $formatdate=$this->workbook->addformat(); - $formatdate->set_num_format('yyyy-mm-dd'); - //$formatdate->set_num_format(0x0f); - $arrayvalue=preg_split('/[.,]/', xl_parse_date($newvalue)); - //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'
'; - $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later - $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate)); - } - else - { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd'); - } - } - elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue)) - { - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $formatdatehour=$this->workbook->addformat(); - $formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss'); - //$formatdatehour->set_num_format(0x0f); - $arrayvalue=preg_split('/[.,]/', xl_parse_date($newvalue)); - //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'
'; - $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later - $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour); - } - else - { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); - } - } - else - { - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->worksheet->write($this->row, $this->col, $newvalue); - } - else - { - if ($typefield == 'Text' || $typefield == 'TextAuto') - { - //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); - $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); - } - else - { - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue); - } - } - } - $this->col++; - } - $this->row++; - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write footer - * - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >0 if OK - */ - public function write_footer($outputlangs) - { - // phpcs:enable - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Close Excel file - * - * @return int <0 if KO, >0 if OK - */ - public function close_file() - { - // phpcs:enable - global $conf; - - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->workbook->close(); - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php'; - $objWriter = new PHPExcel_Writer_Excel5($this->workbook); - $objWriter->save($this->file); - $this->workbook->disconnectWorksheets(); - unset($this->workbook); - } - return 1; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Clean a cell to respect rules of Excel file cells - * - * @param string $newvalue String to clean - * @return string Value cleaned - */ - public function excel_clean($newvalue) - { - // phpcs:enable - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue); - - return $newvalue; - } - - - /** - * Convert a column to letter (1->A, 0->B, 27->AA, ...) - * - * @param int $c Column position - * @return string Letter - */ - public function column2Letter($c) - { - - $c = intval($c); - $letter = ''; - if ($c <= 0) { - return ''; - } - - while ($c != 0) { - $p = ($c - 1) % 26; - $c = intval(($c - $p) / 26); - $letter = chr(65 + $p) . $letter; - } - - return $letter; - } -} diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php deleted file mode 100644 index ac9eb3ddfe6..00000000000 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ /dev/null @@ -1,135 +0,0 @@ - - * Copyright (C) 2012 Marcos García - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/export/export_excel2007.modules.php - * \ingroup export - * \brief File of class to generate export file with Excel format - */ - -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_excel.modules.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - -/** - * Class to build export files with Excel format - */ -class ExportExcel2007 extends ExportExcel -{ - /** - * @var string ID - */ - public $id; - - /** - * @var string label - */ - public $label; - - public $extension; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - public $label_lib; - - public $version_lib; - - public $workbook; // Handle fichier - - public $worksheet; // Handle onglet - - public $row; - - public $col; - - public $file; // To save filename - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $conf, $langs; - $this->db = $db; - - $this->id='excel2007'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Excel 2007 (old library)'; // Label of driver - $this->desc = $langs->trans('Excel2007FormatDesc'); - $this->extension='xlsx'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto - $this->version='1.30'; // Driver version - - $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) - - if (empty($this->disabled)) - { - // If driver use an external library, put its name here - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; - require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; - $this->label_lib='PhpWriteExcel'; - $this->version_lib='unknown'; - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; // No way to get info from library - } - } - - $this->row=0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Close Excel file - * - * @return int <0 if KO, >0 if OK - */ - public function close_file() - { - // phpcs:enable - global $conf; - - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->workbook->close(); - } - else - { - require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php'; - $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); - $objWriter->save($this->file); - $this->workbook->disconnectWorksheets(); - unset($this->workbook); - } - return 1; - } -} diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index b013ff1be91..df1870de0d9 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -30,7 +30,7 @@ * \ingroup agenda * \brief File of class to describe and enable/disable module Agenda */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** * Class to describe and enable/disable module Agenda @@ -59,7 +59,7 @@ class modAgenda extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='action'; + $this->picto = 'action'; // Data directories to create when module is enabled $this->dirs = array("/agenda/temp"); @@ -68,12 +68,12 @@ class modAgenda extends DolibarrModules $this->config_page_url = array("agenda_other.php"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("companies"); - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Module parts $this->module_parts = array(); @@ -86,14 +86,14 @@ class modAgenda extends DolibarrModules // ); $this->const = array(); //$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current'); - $sqlreadactions="SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang"; + $sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang"; $resql = $this->db->query($sqlreadactions); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). - if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default. + if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default. //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default. $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current'); } @@ -109,11 +109,11 @@ class modAgenda extends DolibarrModules // Boxes //------ - $this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home')); + $this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home')); // Cronjobs //------------ - $datestart=dol_now(); + $datestart = dol_now(); $this->cronjobs = array( 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart), ); @@ -122,7 +122,7 @@ class modAgenda extends DolibarrModules //------------ $this->rights = array(); $this->rights_class = 'agenda'; - $r=0; + $r = 0; // $this->rights[$r][0] Id permission (unique tous modules confondus) // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) @@ -187,8 +187,8 @@ class modAgenda extends DolibarrModules $this->rights[$r][4] = 'export'; // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; + $this->menu = array(); // List of menus to add + $r = 0; // Add here entries to declare new menus // Example to declare the Top Menu entry: @@ -204,7 +204,7 @@ class modAgenda extends DolibarrModules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - $this->menu[$r]=array( + $this->menu[$r] = array( 'fk_menu'=>0, 'type'=>'top', 'titre'=>'TMenuAgenda', @@ -219,214 +219,255 @@ class modAgenda extends DolibarrModules ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=0', - 'type'=>'left', - 'titre'=>'Actions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda', - 'langs'=>'agenda', - 'position'=>100, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=0', + 'type'=>'left', + 'titre'=>'Actions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda', + 'langs'=>'agenda', + 'position'=>100, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2, + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=1', - 'type'=>'left', - 'titre'=>'NewAction', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create', - 'langs'=>'commercial', - 'position'=>101, - 'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=1', + 'type'=>'left', + 'titre'=>'NewAction', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create', + 'langs'=>'commercial', + 'position'=>101, + 'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; // Calendar - $this->menu[$r]=array('fk_menu'=>'r=1', - 'type'=>'left', - 'titre'=>'Calendar', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda', - 'langs'=>'agenda', - 'position'=>140, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=1', + 'type'=>'left', + 'titre'=>'Calendar', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda', + 'langs'=>'agenda', + 'position'=>140, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=3', - 'type'=>'left', - 'titre'=>'MenuToDoMyActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', - 'langs'=>'agenda', - 'position'=>141, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=3', + 'type'=>'left', + 'titre'=>'MenuToDoMyActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', + 'langs'=>'agenda', + 'position'=>141, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=3', - 'type'=>'left', - 'titre'=>'MenuDoneMyActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', - 'langs'=>'agenda', - 'position'=>142, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=3', + 'type'=>'left', + 'titre'=>'MenuDoneMyActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', + 'langs'=>'agenda', + 'position'=>142, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=3', - 'type'=>'left', - 'titre'=>'MenuToDoActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', - 'langs'=>'agenda', - 'position'=>143, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=3', + 'type'=>'left', + 'titre'=>'MenuToDoActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', + 'langs'=>'agenda', + 'position'=>143, + 'perms'=>'$user->rights->agenda->allactions->read', + 'enabled'=>'$user->rights->agenda->allactions->read', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=3', - 'type'=>'left', - 'titre'=>'MenuDoneActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', - 'langs'=>'agenda', - 'position'=>144, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=3', + 'type'=>'left', + 'titre'=>'MenuDoneActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', + 'langs'=>'agenda', + 'position'=>144, + 'perms'=>'$user->rights->agenda->allactions->read', + 'enabled'=>'$user->rights->agenda->allactions->read', + 'target'=>'', + 'user'=>2 + ); // List $r++; - $this->menu[$r]=array('fk_menu'=>'r=1', - 'type'=>'left', - 'titre'=>'List', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda', - 'langs'=>'agenda', - 'position'=>110, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=1', + 'type'=>'left', + 'titre'=>'List', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda', + 'langs'=>'agenda', + 'position'=>110, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=8', - 'type'=>'left', - 'titre'=>'MenuToDoMyActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', - 'langs'=>'agenda', - 'position'=>111, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=8', + 'type'=>'left', + 'titre'=>'MenuToDoMyActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', + 'langs'=>'agenda', + 'position'=>111, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=8', - 'type'=>'left', - 'titre'=>'MenuDoneMyActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', - 'langs'=>'agenda', - 'position'=>112, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=8', + 'type'=>'left', + 'titre'=>'MenuDoneMyActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', + 'langs'=>'agenda', + 'position'=>112, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=8', - 'type'=>'left', - 'titre'=>'MenuToDoActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', - 'langs'=>'agenda', - 'position'=>113, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=8', + 'type'=>'left', + 'titre'=>'MenuToDoActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', + 'langs'=>'agenda', + 'position'=>113, + 'perms'=>'$user->rights->agenda->allactions->read', + 'enabled'=>'$user->rights->agenda->allactions->read', + 'target'=>'', + 'user'=>2 + ); $r++; - $this->menu[$r]=array('fk_menu'=>'r=8', - 'type'=>'left', - 'titre'=>'MenuDoneActions', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', - 'langs'=>'agenda', - 'position'=>114, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=8', + 'type'=>'left', + 'titre'=>'MenuDoneActions', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', + 'langs'=>'agenda', + 'position'=>114, + 'perms'=>'$user->rights->agenda->allactions->read', + 'enabled'=>'$user->rights->agenda->allactions->read', + 'target'=>'', + 'user'=>2 + ); $r++; // Reports - $this->menu[$r]=array('fk_menu'=>'r=1', - 'type'=>'left', - 'titre'=>'Reportings', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda', - 'langs'=>'agenda', - 'position'=>160, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); + $this->menu[$r]=array( + 'fk_menu'=>'r=1', + 'type'=>'left', + 'titre'=>'Reportings', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda', + 'langs'=>'agenda', + 'position'=>160, + 'perms'=>'$user->rights->agenda->allactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2 + ); + $r++; + // Categories + $this->menu[$r]=array( + 'fk_menu' => 'r=1', + 'type' => 'left', + 'titre' => 'Categories', + 'mainmenu' => 'agenda', + 'url'=>'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10', + 'langs' => 'agenda', + 'position' => 170, + 'perms' => '$user->rights->agenda->allactions->read', + 'enabled' => '$conf->categorie->enabled&&$conf->categorie->enabled', + 'target' => '', + 'user' => 2 + ); $r++; // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ExportDataset_event1"; - $this->export_permission[$r]=array(array("agenda","export")); - $this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin", - 'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ExportDataset_event1"; + $this->export_permission[$r] = array(array("agenda", "export")); + $this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin", + 'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration", 'cac.libelle'=>"ActionType", - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town', - 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6', - 's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra', + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', + 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', + 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'p.ref' => 'ProjectRef', ); - $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", - 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", + $this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date", + 'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', - 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', - 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text', + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', + 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', + 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'p.ref' => 'Text', ); - $this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action", - 'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action", + $this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action", + 'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action", 'cac.libelle'=>"action", - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company', - 'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company', - 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company', + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', + 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', + 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company', 'p.ref' => 'project', ); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id'; - if (! empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; - if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = ac.fk_project"; - $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')'; - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; - if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_order[$r] =' ORDER BY ac.datep'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id'; + if (!empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; + if (!empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; + $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project"; + $this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')'; + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)'; + if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id); + $this->export_sql_order[$r] = ' ORDER BY ac.datep'; } } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index d157e35a555..b53a9630598 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -185,7 +185,7 @@ class modCategorie extends DolibarrModules $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -350,7 +350,7 @@ class modCategorie extends DolibarrModules ); // We define here only fields that use another picto // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 96d3d3f45a5..93cd08c7001 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -65,8 +65,8 @@ class modExpedition extends DolibarrModules "/expedition/sending/temp", "/expedition/receipt", "/expedition/receipt/temp", - "/doctemplates/shipment", - "/doctemplates/delivery" + "/doctemplates/shipments", + "/doctemplates/deliveries" ); // Config pages @@ -98,7 +98,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipment"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipments"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -119,7 +119,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/deliveries"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -127,7 +127,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "1"; - $this->const[$r][3] = "Enable shipments"; + $this->const[$r][3] = "Enable delivery receipts"; $this->const[$r][4] = 0; $r++; @@ -326,8 +326,8 @@ class modExpedition extends DolibarrModules $this->remove($options); //ODT template - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/shipment'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipments/template_shipment.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/shipments'; $dest = $dirodt.'/template_shipment.odt'; if (file_exists($src) && !file_exists($dest)) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 7712c5ed4e5..9b527fe7678 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -320,7 +320,7 @@ class modFournisseur extends DolibarrModules ); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Add extra fields object - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -357,7 +357,7 @@ class modFournisseur extends DolibarrModules } // End add extra fields // Add extra fields line - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -440,7 +440,7 @@ class modFournisseur extends DolibarrModules 'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Add extra fields object - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -527,7 +527,7 @@ class modFournisseur extends DolibarrModules ); $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Add extra fields object - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -565,7 +565,7 @@ class modFournisseur extends DolibarrModules } // End add extra fields object // Add extra fields line - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'"; + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c859c6f4519..2cc525bd8aa 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -449,7 +449,7 @@ class modSociete extends DolibarrModules 's.multicurrency_code' => 'MulticurrencyCurrency' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -597,7 +597,7 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity = ".$conf->entity; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on an old database (during a migration for example) { diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index c24c3787a9c..e2d071ac730 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -93,7 +93,7 @@ class modSupplierProposal extends DolibarrModules $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposal"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposals"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; @@ -215,8 +215,8 @@ class modSupplierProposal extends DolibarrModules $this->remove($options); //ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal'; + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposals/template_supplier_proposal.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposals'; $dest=$dirodt.'/template_supplier_proposal.odt'; if (file_exists($src) && ! file_exists($dest)) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index b21ec913220..6e5924945c9 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -233,7 +233,7 @@ class modUser extends DolibarrModules 'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId" ); $this->export_TypeFields_array[$r]=array( - 'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.employee'=>'Boolean','u.job'=>'Text', + 'u.rowid'=>'Numeric', 'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.employee'=>'Boolean','u.job'=>'Text', 'u.accountancy_code'=>'Text', 'u.address'=>"Text",'u.zip'=>"Text",'u.town'=>"Text", 'u.office_phone'=>'Text','u.user_mobile'=>'Text','u.office_fax'=>'Text', diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index a5e8530d4bb..32926e098e3 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefo require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 7c400c0fbb7..a8f19b542e5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -59,6 +59,10 @@ $search_state = trim(GETPOST("search_state")); $search_country = GETPOST("search_country", 'int'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_billed = GETPOST("search_billed", 'int'); +$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int')); +$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int')); +$search_datereceipt_start = dol_mktime(0, 0, 0, GETPOST('search_datereceipt_startmonth', 'int'), GETPOST('search_datereceipt_startday', 'int'), GETPOST('search_datereceipt_startyear', 'int')); +$search_datereceipt_end = dol_mktime(23, 59, 59, GETPOST('search_datereceipt_endmonth', 'int'), GETPOST('search_datereceipt_endday', 'int'), GETPOST('search_datereceipt_endyear', 'int')); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); @@ -156,6 +160,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_country = ''; $search_type_thirdparty = ''; $search_billed = ''; + $search_datedelivery_start = ''; + $search_datedelivery_end = ''; + $search_datereceipt_start = ''; + $search_datereceipt_end = ''; $viewstatut = ''; $toselect = ''; $search_array_options = array(); @@ -234,6 +242,10 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdp if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp); if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv); if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_datedelivery_start) $sql .= " AND e.date_delivery >= '" . $db->idate($search_datedelivery_start) . "'"; +if ($search_datedelivery_end) $sql .= " AND e.date_delivery <= '" . $db->idate($search_datedelivery_end) . "'"; +if ($search_datereceipt_start) $sql .= " AND l.date_delivery >= '" . $db->idate($search_datereceipt_start) . "'"; +if ($search_datereceipt_end) $sql .= " AND l.date_delivery <= '" . $db->idate($search_datereceipt_end) . "'"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields @@ -280,6 +292,10 @@ if ($resql) if ($search_company) $param .= "&search_company=".urlencode($search_company); if ($search_town) $param .= '&search_town='.urlencode($search_town); if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); + if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); + if ($search_datereceipt_start) $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start); + if ($search_datereceipt_end) $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end); if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -391,7 +407,16 @@ if ($resql) // Date delivery planned if (!empty($arrayfields['e.date_delivery']['checked'])) { - print ' '; + print ''; + print '
'; + print $langs->trans('From') . ' '; + print $form->selectDate($search_delivery_start?$search_delivery_start:-1, 'search_delivery_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to') . ' '; + print $form->selectDate($search_delivery_end?$search_delivery_end:-1, 'search_delivery_end', 0, 0, 1); + print '
'; + print ''; } if (!empty($arrayfields['l.ref']['checked'])) { @@ -403,7 +428,16 @@ if ($resql) if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received - print ' '; + print ''; + print '
'; + print $langs->trans('From') . ' '; + print $form->selectDate($search_receipt_start?$search_receipt_start:-1, 'search_receipt_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to') . ' '; + print $form->selectDate($search_receipt_end?$search_receipt_end:-1, 'search_receipt_end', 0, 0, 1); + print '
'; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 0274e493170..06813b03ae5 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -52,10 +52,10 @@ class Export public $array_export_help=array(); // array with tooltip help for fields // To store export modules - public $hexa; - public $hexafiltervalue; + public $hexa; // List of fields in the export profile + public $hexafiltervalue; // List of search criteria in the export profile public $datatoexport; - public $model_name; + public $model_name; // Name of export profile public $sqlusedforexport; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9056d1217ca..23031d09d90 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by page $langs->loadLangs(array( @@ -312,7 +313,7 @@ if ($object->id > 0) $langs->load("categories"); print ''.$langs->trans("SuppliersCategoriesShort").''; print ''; - print $form->showCategories($object->id, 'supplier', 1); + print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); print ""; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d153f8756c7..b8745aa0d2b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -700,9 +700,10 @@ class CommandeFournisseur extends CommonOrder * @param string $option On what the link points * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $addlinktonotes Add link to show notes * @return string Chain with URL */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) { global $langs, $conf; @@ -751,6 +752,22 @@ class CommandeFournisseur extends CommonOrder if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; + if ($addlinktonotes) + { + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); + if ($txttoshow) + { + $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result .= ''; + } + } + return $result; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 807804ed5fe..1f00720a12d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2248,9 +2248,10 @@ class FactureFournisseur extends CommonInvoice * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $addlinktonotes Add link to show notes * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) { global $langs, $conf; @@ -2318,6 +2319,22 @@ class FactureFournisseur extends CommonInvoice if ($withpicto != 2) $result.= ($max?dol_trunc($ref, $max):$ref); $result .= $linkend; + if ($addlinktonotes) + { + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); + if ($txttoshow) + { + $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result .= ''; + } + } + return $result; } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index b64fde8bdad..71881d34103 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -486,6 +486,7 @@ $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; $sql .= ' cf.date_creation as date_creation, cf.tms as date_update,'; +$sql .= ' cf.note_public, cf.note_private,'; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // Add fields from extrafields @@ -936,6 +937,8 @@ if ($resql) $objectstatic->total_tva = $obj->total_tva; $objectstatic->total_ttc = $obj->total_ttc; $objectstatic->date_delivery = $db->jdate($obj->date_delivery); + $objectstatic->note_public = $obj->note_public; + $objectstatic->note_private = $obj->note_private; $objectstatic->statut = $obj->fk_statut; print ''; @@ -946,7 +949,7 @@ if ($resql) print ''; // Picto + Ref - print $objectstatic->getNomUrl(1); + print $objectstatic->getNomUrl(1, '', 0, -1, 1); // Other picto tool $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4141c8a7955..9b865cae3e6 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -269,6 +269,7 @@ if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; $sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; $sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; +$sql .= " f.note_public, f.note_private,"; $sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; @@ -371,6 +372,7 @@ if (!$search_all) $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql .= " f.localtax1, f.localtax2,"; + $sql .= " f.note_public, f.note_private,"; $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; $sql .= " typent.code,"; $sql .= " state.code_departement, state.nom,"; @@ -827,7 +829,8 @@ if ($resql) $facturestatic->ref_supplier = $obj->ref_supplier; $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; - + $facturestatic->note_public = $obj->note_public; + $facturestatic->note_private = $obj->note_private; $thirdparty->id = $obj->socid; $thirdparty->name = $obj->name; @@ -861,13 +864,8 @@ if ($resql) print ''; // Picto + Ref print ''; - // Warning - //print ''; - // Other picto tool - print ''; print ''; print ''; - print ''; // Fields title label // -------------------------------------------------------------------- @@ -199,7 +199,9 @@ if ($resql) print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "l.datestart", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "l.dateend", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "l.paid", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre(''); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + print "\n"; // Loop on record @@ -210,7 +212,7 @@ if ($resql) { $obj = $db->fetch_object($resql); if (empty($obj)) break; // Should not happen - + $loan_static->id = $obj->rowid; $loan_static->ref = $obj->rowid; $loan_static->label = $obj->label; @@ -252,12 +254,12 @@ if ($resql) $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print '
'; - print $facturestatic->getNomUrl(1); - print ''; - //print ''; + print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index ea6a2c55454..ae914b2f712 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -138,7 +138,7 @@ if ($object->id > 0) print '
'; print '
'; - print ''; + print '
'; // Type print ''; print ''; } + // Nb of days print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 9d197c752dc..6fb01d5329c 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -127,7 +127,7 @@ if (!function_exists("imagecreate")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; - // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { @@ -140,7 +140,7 @@ if (!function_exists("curl_init")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; - // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { @@ -163,7 +163,7 @@ if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; - // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { @@ -178,7 +178,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; - // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { @@ -186,6 +186,16 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc } } +if (!class_exists('ZipArchive')) +{ + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
\n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} +else +{ + print 'Ok '.$langs->trans("PHPSupport", "ZIP")."
\n"; +} // Check memory $memrequiredorig = '64M'; diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index be485ddb6b1..bbb7af35bb7 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -45,25 +45,16 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 6,'97601',3,'Mayotte'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 11,'75056',1,'Île-de-France'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 21,'51108',0,'Champagne-Ardenne'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 22,'80021',0,'Picardie'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 23,'76540',0,'Haute-Normandie'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 24,'45234',2,'Centre'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 25,'14118',0,'Basse-Normandie'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 26,'21231',0,'Bourgogne'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 31,'59350',2,'Nord-Pas-de-Calais'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 41,'57463',0,'Lorraine'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 42,'67482',1,'Alsace'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 43,'25056',0,'Franche-Comté'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 24,'45234',2,'Centre-Val de Loire'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 27,'21231',0,'Bourgogne-Franche-Comté'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 28,'76540',0,'Normandie'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 32,'59350',4,'Hauts-de-France'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 44,'67482',2,'Grand Est'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 52,'44109',4,'Pays de la Loire'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 53,'35238',0,'Bretagne'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 54,'86194',2,'Poitou-Charentes'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 72,'33063',1,'Aquitaine'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 73,'31555',0,'Midi-Pyrénées'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 74,'87085',2,'Limousin'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 82,'69123',2,'Rhône-Alpes'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 83,'63113',1,'Auvergne'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 91,'34172',2,'Languedoc-Roussillon'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 75,'33063',0,'Nouvelle-Aquitaine'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 76,'31355',1,'Occitanie'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 84,'69123',1,'Auvergne-Rhône-Alpes'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 93,'13055',0,'Provence-Alpes-Côte d''Azur'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 94,'2A004',0,'Corse'); diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 7e9417b487b..46d9b4d712e 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -42,97 +42,97 @@ insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,no insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 4,'974','97411',3,'REUNION','Réunion'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 6,'976','97601',3,'MAYOTTE','Mayotte'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'01','01053',5,'AIN','Ain'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (22,'02','02408',5,'AISNE','Aisne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (83,'03','03190',5,'ALLIER','Allier'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'01','01053',5,'AIN','Ain'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'02','02408',5,'AISNE','Aisne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'03','03190',5,'ALLIER','Allier'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'04','04070',4,'ALPES-DE-HAUTE-PROVENCE','Alpes-de-Haute-Provence'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'05','05061',4,'HAUTES-ALPES','Hautes-Alpes'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'06','06088',4,'ALPES-MARITIMES','Alpes-Maritimes'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'07','07186',5,'ARDECHE','Ardèche'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (21,'08','08105',4,'ARDENNES','Ardennes'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'09','09122',5,'ARIEGE','Ariège'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (21,'10','10387',5,'AUBE','Aube'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (91,'11','11069',5,'AUDE','Aude'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'12','12202',5,'AVEYRON','Aveyron'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'07','07186',5,'ARDECHE','Ardèche'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'08','08105',4,'ARDENNES','Ardennes'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'09','09122',5,'ARIEGE','Ariège'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'10','10387',5,'AUBE','Aube'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'11','11069',5,'AUDE','Aude'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'12','12202',5,'AVEYRON','Aveyron'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'13','13055',4,'BOUCHES-DU-RHONE','Bouches-du-Rhône'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (25,'14','14118',2,'CALVADOS','Calvados'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (83,'15','15014',2,'CANTAL','Cantal'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (54,'16','16015',3,'CHARENTE','Charente'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (54,'17','17300',3,'CHARENTE-MARITIME','Charente-Maritime'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (28,'14','14118',2,'CALVADOS','Calvados'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'15','15014',2,'CANTAL','Cantal'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'16','16015',3,'CHARENTE','Charente'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'17','17300',3,'CHARENTE-MARITIME','Charente-Maritime'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'18','18033',2,'CHER','Cher'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (74,'19','19272',3,'CORREZE','Corrèze'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'19','19272',3,'CORREZE','Corrèze'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (94,'2A','2A004',3,'CORSE-DU-SUD','Corse-du-Sud'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (94,'2B','2B033',3,'HAUTE-CORSE','Haute-Corse'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (26,'21','21231',3,'COTE-D OR','Côte-d Or'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'21','21231',3,'COTE-D OR','Côte-d Or'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (53,'22','22278',4,'COTES-D ARMOR','Côtes-d Armor'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (74,'23','23096',3,'CREUSE','Creuse'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (72,'24','24322',3,'DORDOGNE','Dordogne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (43,'25','25056',2,'DOUBS','Doubs'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'26','26362',3,'DROME','Drôme'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (23,'27','27229',5,'EURE','Eure'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'23','23096',3,'CREUSE','Creuse'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'24','24322',3,'DORDOGNE','Dordogne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'25','25056',2,'DOUBS','Doubs'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'26','26362',3,'DROME','Drôme'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (28,'27','27229',5,'EURE','Eure'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'28','28085',1,'EURE-ET-LOIR','Eure-et-Loir'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (53,'29','29232',2,'FINISTERE','Finistère'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (91,'30','30189',2,'GARD','Gard'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'31','31555',3,'HAUTE-GARONNE','Haute-Garonne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'32','32013',2,'GERS','Gers'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (72,'33','33063',3,'GIRONDE','Gironde'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (91,'34','34172',5,'HERAULT','Hérault'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'30','30189',2,'GARD','Gard'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'31','31555',3,'HAUTE-GARONNE','Haute-Garonne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'32','32013',2,'GERS','Gers'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'33','33063',3,'GIRONDE','Gironde'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'34','34172',5,'HERAULT','Hérault'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (53,'35','35238',1,'ILLE-ET-VILAINE','Ille-et-Vilaine'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'36','36044',5,'INDRE','Indre'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'37','37261',1,'INDRE-ET-LOIRE','Indre-et-Loire'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'38','38185',5,'ISERE','Isère'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (43,'39','39300',2,'JURA','Jura'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (72,'40','40192',4,'LANDES','Landes'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'38','38185',5,'ISERE','Isère'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'39','39300',2,'JURA','Jura'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'40','40192',4,'LANDES','Landes'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'41','41018',0,'LOIR-ET-CHER','Loir-et-Cher'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'42','42218',3,'LOIRE','Loire'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (83,'43','43157',3,'HAUTE-LOIRE','Haute-Loire'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'42','42218',3,'LOIRE','Loire'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'43','43157',3,'HAUTE-LOIRE','Haute-Loire'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (52,'44','44109',3,'LOIRE-ATLANTIQUE','Loire-Atlantique'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (24,'45','45234',2,'LOIRET','Loiret'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'46','46042',2,'LOT','Lot'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (72,'47','47001',0,'LOT-ET-GARONNE','Lot-et-Garonne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (91,'48','48095',3,'LOZERE','Lozère'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'46','46042',2,'LOT','Lot'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'47','47001',0,'LOT-ET-GARONNE','Lot-et-Garonne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'48','48095',3,'LOZERE','Lozère'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (52,'49','49007',0,'MAINE-ET-LOIRE','Maine-et-Loire'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (25,'50','50502',3,'MANCHE','Manche'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (21,'51','51108',3,'MARNE','Marne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (21,'52','52121',3,'HAUTE-MARNE','Haute-Marne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (28,'50','50502',3,'MANCHE','Manche'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'51','51108',3,'MARNE','Marne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'52','52121',3,'HAUTE-MARNE','Haute-Marne'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (52,'53','53130',3,'MAYENNE','Mayenne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (41,'54','54395',0,'MEURTHE-ET-MOSELLE','Meurthe-et-Moselle'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (41,'55','55029',3,'MEUSE','Meuse'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'54','54395',0,'MEURTHE-ET-MOSELLE','Meurthe-et-Moselle'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'55','55029',3,'MEUSE','Meuse'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (53,'56','56260',2,'MORBIHAN','Morbihan'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (41,'57','57463',3,'MOSELLE','Moselle'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (26,'58','58194',3,'NIEVRE','Nièvre'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (31,'59','59350',2,'NORD','Nord'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (22,'60','60057',5,'OISE','Oise'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (25,'61','61001',5,'ORNE','Orne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (31,'62','62041',2,'PAS-DE-CALAIS','Pas-de-Calais'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (83,'63','63113',2,'PUY-DE-DOME','Puy-de-Dôme'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (72,'64','64445',4,'PYRENEES-ATLANTIQUES','Pyrénées-Atlantiques'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'65','65440',4,'HAUTES-PYRENEES','Hautes-Pyrénées'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (91,'66','66136',4,'PYRENEES-ORIENTALES','Pyrénées-Orientales'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (42,'67','67482',2,'BAS-RHIN','Bas-Rhin'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (42,'68','68066',2,'HAUT-RHIN','Haut-Rhin'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'69','69123',2,'RHONE','Rhône'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (43,'70','70550',3,'HAUTE-SAONE','Haute-Saône'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (26,'71','71270',0,'SAONE-ET-LOIRE','Saône-et-Loire'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'57','57463',3,'MOSELLE','Moselle'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'58','58194',3,'NIEVRE','Nièvre'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'59','59350',2,'NORD','Nord'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'60','60057',5,'OISE','Oise'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (28,'61','61001',5,'ORNE','Orne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'62','62041',2,'PAS-DE-CALAIS','Pas-de-Calais'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'63','63113',2,'PUY-DE-DOME','Puy-de-Dôme'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'64','64445',4,'PYRENEES-ATLANTIQUES','Pyrénées-Atlantiques'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'65','65440',4,'HAUTES-PYRENEES','Hautes-Pyrénées'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'66','66136',4,'PYRENEES-ORIENTALES','Pyrénées-Orientales'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'67','67482',2,'BAS-RHIN','Bas-Rhin'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'68','68066',2,'HAUT-RHIN','Haut-Rhin'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'69','69123',2,'RHONE','Rhône'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'70','70550',3,'HAUTE-SAONE','Haute-Saône'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'71','71270',0,'SAONE-ET-LOIRE','Saône-et-Loire'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (52,'72','72181',3,'SARTHE','Sarthe'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'73','73065',3,'SAVOIE','Savoie'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (82,'74','74010',3,'HAUTE-SAVOIE','Haute-Savoie'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'73','73065',3,'SAVOIE','Savoie'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'74','74010',3,'HAUTE-SAVOIE','Haute-Savoie'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'75','75056',0,'PARIS','Paris'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (23,'76','76540',3,'SEINE-MARITIME','Seine-Maritime'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (28,'76','76540',3,'SEINE-MARITIME','Seine-Maritime'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'77','77288',0,'SEINE-ET-MARNE','Seine-et-Marne'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'78','78646',4,'YVELINES','Yvelines'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (54,'79','79191',4,'DEUX-SEVRES','Deux-Sèvres'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (22,'80','80021',3,'SOMME','Somme'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'81','81004',2,'TARN','Tarn'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (73,'82','82121',0,'TARN-ET-GARONNE','Tarn-et-Garonne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'79','79191',4,'DEUX-SEVRES','Deux-Sèvres'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'80','80021',3,'SOMME','Somme'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'81','81004',2,'TARN','Tarn'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (76,'82','82121',0,'TARN-ET-GARONNE','Tarn-et-Garonne'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'83','83137',2,'VAR','Var'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (93,'84','84007',0,'VAUCLUSE','Vaucluse'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (52,'85','85191',3,'VENDEE','Vendée'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (54,'86','86194',3,'VIENNE','Vienne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (74,'87','87085',3,'HAUTE-VIENNE','Haute-Vienne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (41,'88','88160',4,'VOSGES','Vosges'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (26,'89','89024',5,'YONNE','Yonne'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (43,'90','90010',0,'TERRITOIRE DE BELFORT','Territoire de Belfort'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'86','86194',3,'VIENNE','Vienne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (75,'87','87085',3,'HAUTE-VIENNE','Haute-Vienne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (44,'88','88160',4,'VOSGES','Vosges'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'89','89024',5,'YONNE','Yonne'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (27,'90','90010',0,'TERRITOIRE DE BELFORT','Territoire de Belfort'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'91','91228',5,'ESSONNE','Essonne'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'92','92050',4,'HAUTS-DE-SEINE','Hauts-de-Seine'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'93','93008',3,'SEINE-SAINT-DENIS','Seine-Saint-Denis'); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 18972bc6b8f..9db7c2f382d 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -75,7 +75,7 @@ UPDATE llx_holiday SET ref = rowid WHERE ref IS NULL; -- VPGSQL8.2 ALTER TABLE llx_holiday ALTER COLUMN ref SET NOT NULL; ALTER TABLE llx_c_email_senderprofile MODIFY COLUMN active tinyint DEFAULT 1 NOT NULL; - + insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('HELP', '15', 'Request for functionnal help', 1, 0, NULL); @@ -532,22 +532,22 @@ ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL; CREATE TABLE llx_mrp_production( - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - fk_mo integer NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_mo integer NOT NULL, position integer NOT NULL DEFAULT 0, - fk_product integer NOT NULL, + fk_product integer NOT NULL, fk_warehouse integer, qty real NOT NULL DEFAULT 1, qty_frozen smallint DEFAULT 0, - disable_stock_change smallint DEFAULT 0, + disable_stock_change smallint DEFAULT 0, batch varchar(30), role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' fk_stock_movement integer, -- id of stock movement when movements are validated - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, import_key varchar(14) ) ENGINE=innodb; ALTER TABLE llx_mrp_production MODIFY COLUMN qty real NOT NULL DEFAULT 1; @@ -564,3 +564,16 @@ ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo); ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_ref(ref, entity); ALTER TABLE llx_website ADD COLUMN use_manifest integer; + +ALTER TABLE llx_facture_rec MODIFY COLUMN fk_cond_reglement integer NOT NULL DEFAULT 1; + +create table llx_commande_fournisseur_dispatch_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, -- object id + import_key varchar(14) -- import key +)ENGINE=innodb; + +ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande_fournisseur_dispatch_extrafields (fk_object); + diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 17996508e26..2d9518a69f2 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -30,18 +30,70 @@ -- Missing in v11 +create table llx_commande_fournisseur_dispatch_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, -- object id + import_key varchar(14) -- import key +)ENGINE=innodb; + +ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande_fournisseur_dispatch_extrafields (fk_object); + -- For v12 -ALTER TABLE llx_societe_rib ADD COLUMN stripe_account varchar(128); +-- Migration to the new regions (France) +UPDATE llx_c_regions set nom = 'Centre-Val de Loire' WHERE fk_pays = 1 AND code_region = 24; +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 27, '21231', 0, 'Bourgogne-Franche-Comté'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 28, '76540', 0, 'Normandie'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 32, '59350', 4, 'Hauts-de-France'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 44, '67482', 2, 'Grand Est'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 75, '33063', 0, 'Nouvelle-Aquitaine'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 76, '31355', 1, 'Occitanie'); +insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (1, 84, '69123', 1, 'Auvergne-Rhône-Alpes'); +UPDATE llx_c_departements set fk_region = 27 WHERE fk_region = 26 OR fk_region = 43; +UPDATE llx_c_departements set fk_region = 28 WHERE fk_region = 25 OR fk_region = 23; +UPDATE llx_c_departements set fk_region = 32 WHERE fk_region = 22 OR fk_region = 31; +UPDATE llx_c_departements set fk_region = 44 WHERE fk_region = 21 OR fk_region = 41 OR fk_region = 42; +UPDATE llx_c_departements set fk_region = 75 WHERE fk_region = 54 OR fk_region = 74 OR fk_region = 72; +UPDATE llx_c_departements set fk_region = 76 WHERE fk_region = 73 OR fk_region = 91; +UPDATE llx_c_departements set fk_region = 84 WHERE fk_region = 82 OR fk_region = 83; + +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 21; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 22; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 23; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 25; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 26; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 31; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 41; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 42; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 43; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 54; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 72; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 73; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 74; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 82; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 83; +DELETE FROM llx_c_regions WHERE fk_pays = 1 AND code_region = 91; + +ALTER TABLE llx_bookmark DROP INDEX uk_bookmark_url; +ALTER TABLE llx_bookmark DROP INDEX uk_bookmark_title; + +ALTER TABLE llx_bookmark MODIFY COLUMN url TEXT; + +ALTER TABLE llx_bookmark ADD UNIQUE uk_bookmark_title (fk_user, entity, title); + + +ALTER TABLE llx_societe_rib ADD COLUMN stripe_account varchar(128); create table llx_object_lang ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_object integer DEFAULT 0 NOT NULL, - type_object varchar(32) NOT NULL, -- 'thirdparty', 'contact', '...' + type_object varchar(32) NOT NULL, property varchar(32) NOT NULL, lang varchar(5) DEFAULT 0 NOT NULL, value text, @@ -51,9 +103,23 @@ create table llx_object_lang ALTER TABLE llx_object_lang ADD UNIQUE INDEX uk_object_lang (fk_object, type_object, property, lang); + +CREATE TABLE llx_categorie_actioncomm +( + fk_categorie integer NOT NULL, + fk_actioncomm integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; + +ALTER TABLE llx_categorie_actioncomm ADD PRIMARY KEY pk_categorie_actioncomm (fk_categorie, fk_actioncomm); +ALTER TABLE llx_categorie_actioncomm ADD INDEX idx_categorie_actioncomm_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_actioncomm ADD INDEX idx_categorie_actioncomm_fk_actioncomm (fk_actioncomm); + +ALTER TABLE llx_categorie_actioncomm ADD CONSTRAINT fk_categorie_actioncomm_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_actioncomm ADD CONSTRAINT fk_categorie_actioncomm_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm (id); + + ALTER TABLE llx_accounting_account ADD COLUMN labelshort varchar(255) DEFAULT NULL after label; ALTER TABLE llx_subscription ADD COLUMN fk_user_creat integer DEFAULT NULL; ALTER TABLE llx_subscription ADD COLUMN fk_user_valid integer DEFAULT NULL; - - diff --git a/htdocs/install/mysql/tables/llx_bookmark.key.sql b/htdocs/install/mysql/tables/llx_bookmark.key.sql index f933939ceb7..2c0cac1922e 100644 --- a/htdocs/install/mysql/tables/llx_bookmark.key.sql +++ b/htdocs/install/mysql/tables/llx_bookmark.key.sql @@ -17,5 +17,4 @@ -- =================================================================== -ALTER TABLE llx_bookmark ADD UNIQUE uk_bookmark_url (fk_user, url); -ALTER TABLE llx_bookmark ADD UNIQUE uk_bookmark_title (fk_user, title); +ALTER TABLE llx_bookmark ADD UNIQUE uk_bookmark_title (fk_user, entity, title); diff --git a/htdocs/install/mysql/tables/llx_bookmark.sql b/htdocs/install/mysql/tables/llx_bookmark.sql index 1c11525528c..6a76ed38343 100644 --- a/htdocs/install/mysql/tables/llx_bookmark.sql +++ b/htdocs/install/mysql/tables/llx_bookmark.sql @@ -21,7 +21,7 @@ create table llx_bookmark rowid integer AUTO_INCREMENT PRIMARY KEY, fk_user integer NOT NULL, dateb datetime, - url varchar(255) NOT NULL, + url TEXT, target varchar(16), title varchar(64), favicon varchar(24), diff --git a/htdocs/install/mysql/tables/llx_categorie_actioncomm.key.sql b/htdocs/install/mysql/tables/llx_categorie_actioncomm.key.sql new file mode 100644 index 00000000000..30357eb87bc --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_actioncomm.key.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2016 Charlie Benke +-- Copyright (C) 2016-2019 Frédéric France +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_actioncomm ADD PRIMARY KEY pk_categorie_actioncomm (fk_categorie, fk_actioncomm); +ALTER TABLE llx_categorie_actioncomm ADD INDEX idx_categorie_actioncomm_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_actioncomm ADD INDEX idx_categorie_actioncomm_fk_actioncomm (fk_actioncomm); + +ALTER TABLE llx_categorie_actioncomm ADD CONSTRAINT fk_categorie_actioncomm_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_actioncomm ADD CONSTRAINT fk_categorie_actioncomm_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm (id); diff --git a/htdocs/install/mysql/tables/llx_categorie_actioncomm.sql b/htdocs/install/mysql/tables/llx_categorie_actioncomm.sql new file mode 100644 index 00000000000..52aa2a2c95d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_actioncomm.sql @@ -0,0 +1,26 @@ +-- ============================================================================ +-- Copyright (C) 2016 Charlie Benke +-- Copyright (C) 2016-2019 Frédéric France +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- Table to link actioncomm tag/categories with actioncomms +-- =========================================================================== + +CREATE TABLE llx_categorie_actioncomm +( + fk_categorie integer NOT NULL, + fk_actioncomm integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index d60537a36d0..d0e4486262a 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -48,7 +48,7 @@ create table llx_facture_rec fk_projet integer, -- projet auquel est associe la facture - fk_cond_reglement integer DEFAULT 0, -- condition de reglement + fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement) date_lim_reglement date, -- date limite de reglement fk_account integer, -- bank account id diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index b6f64d8fbb8..7207bbacc38 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -90,4 +90,5 @@ ShowCategory=Show tag/category ByDefaultInList=By default in list ChooseCategory=Choose category StocksCategoriesArea=Warehouses Categories Area +ActionCommCategoriesArea=Events Categories Area UseOrOperatorForCategories=Use or operator for categories diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 78f474ff96a..c569a48c84a 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -247,6 +247,12 @@ ProfId3US=- ProfId4US=- ProfId5US=- ProfId6US=- +ProfId1RO=Prof Id 1 (CUI) +ProfId2RO=Prof Id 2 (Nr. Înmatriculare) +ProfId3RO=Prof Id 3 (CAEN) +ProfId4RO=- +ProfId5RO=Prof Id 5 (EUID) +ProfId6RO=- ProfId1RU=Prof Id 1 (OGRN) ProfId2RU=Prof Id 2 (INN) ProfId3RU=Prof Id 3 (KPP) diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 69b6a698e1a..82de49f9c5f 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -39,8 +39,10 @@ TypeOfLeaveId=Type of leave ID TypeOfLeaveCode=Type of leave code TypeOfLeaveLabel=Type of leave label NbUseDaysCP=Number of days of vacation consumed +NbUseDaysCPHelp=The calculation takes into account the non working days and the holidays defined in the dictionary. NbUseDaysCPShort=Days consumed NbUseDaysCPShortInMonth=Days consumed in month +DayIsANonWorkingDay=%s is a non working day DateStartInMonth=Start date in month DateEndInMonth=End date in month EditCP=Edit diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 708b3bac479..1b173656a47 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -16,6 +16,7 @@ PHPSupportCurl=This PHP supports Curl. PHPSupportCalendar=This PHP supports calendars extensions. PHPSupportUTF8=This PHP supports UTF8 functions. PHPSupportIntl=This PHP supports Intl functions. +PHPSupport=This PHP supports %s functions. PHPMemoryOK=Your PHP max session memory is set to %s. This should be enough. PHPMemoryTooLow=Your PHP max session memory is set to %s bytes. This is too low. Change your php.ini to set memory_limit parameter to at least %s bytes. Recheck=Click here for a more detailed test @@ -25,6 +26,7 @@ ErrorPHPDoesNotSupportCurl=Your PHP installation does not support Curl. ErrorPHPDoesNotSupportCalendar=Your PHP installation does not support php calendar extensions. ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr cannot work correctly. Resolve this before installing Dolibarr. ErrorPHPDoesNotSupportIntl=Your PHP installation does not support Intl functions. +ErrorPHPDoesNotSupport=Your PHP installation does not support %s functions. ErrorDirDoesNotExists=Directory %s does not exist. ErrorGoBackAndCorrectParameters=Go back and check/correct the parameters. ErrorWrongValueForParameter=You may have typed a wrong value for parameter '%s'. diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 67002f622f9..ca3fd3e68b8 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -135,3 +135,5 @@ CSSClass=CSS Class NotEditable=Not editable ForeignKey=Foreign key TypeOfFieldsHelp=Type of fields:
varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]] ('1' means we add a + button after the combo to create the record, 'filter' can be 'status=1 AND fk_user = __USER_ID AND entity IN (__SHARED_ENTITIES__)' for example) +AsciiToHtmlConverter=Ascii to HTML converter +AsciiToPdfConverter=Ascii to PDF converter \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 6d062056d4d..0f9c1d8f1b3 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -249,9 +249,13 @@ TimeSpentForInvoice=Time spent OneLinePerUser=One line per user ServiceToUseOnLines=Service to use on lines InvoiceGeneratedFromTimeSpent=Invoice %s has been generated from time spent on project -ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). +ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). Note: To generate invoice, go on tab 'Time spent' of the project and select lines to include. ProjectFollowOpportunity=Follow opportunity ProjectFollowTasks=Follow tasks UsageOpportunity=Usage: Opportunity UsageTasks=Usage: Tasks UsageBillTimeShort=Usage: Bill time +InvoiceToUse=Draft invoice to use +NewInvoice=New invoice +OneLinePerTask=One line per task +OneLinePerPeriod=One line per period \ No newline at end of file diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index ca28b16261c..9e7b8f2565a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -716,9 +716,9 @@ if ($id > 0) print '
'; print '\n"; print "\n"; - print '\n"; - print '\n"; - print '\n"; + print '\n"; + print '\n"; + print '\n"; print ""; $total_capital += $objp->amount_capital; $i++; @@ -728,14 +728,14 @@ if ($id > 0) if ($object->paid == 0) { - print ''; - print ''; + print ''; + print ''; $staytopay = $object->capital - $totalpaid; print ''; - print ''; } print "
'.$langs->trans('Type').''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index f6484a313aa..26a210f40e0 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1278,9 +1278,17 @@ else print '
'.$langs->trans('NbUseDaysCP').''; + $htmlhelp = $langs->trans('NbUseDaysCPHelp'); + $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); + $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); + if ($includesaturday) $htmlhelp.='
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); + if ($includesunday) $htmlhelp.='
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); + print '
'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'
'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("RemainderToPay").' :'; - print price($staytopay, 0, $langs, 0, 0, -1, $conf->currency); + print ''; + print price($staytopay, 0, $langs, 0, -1, -1, $conf->currency); print '
"; diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 3b1ccfd2724..f925b645b98 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -28,14 +28,14 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; // Load translation files required by the page -$langs->loadLangs(array("loan","compta","banks","bills")); +$langs->loadLangs(array("loan", "compta", "banks", "bills")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'loan', '', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -124,14 +124,14 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit else { if ($limit) $sql .= $db->plimit($limit + 1, $offset); - + $resql = $db->query($sql); if (!$resql) { dol_print_error($db); exit; } - + $num = $db->num_rows($resql); } @@ -144,18 +144,18 @@ if ($resql) { $i = 0; - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_amount) $param.="&search_amount=".urlencode($search_amount); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); + if ($search_label) $param .= "&search_label=".urlencode($search_label); + if ($search_amount) $param .= "&search_amount=".urlencode($search_amount); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->loan->write) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create'); } print '
'."\n"; @@ -185,10 +185,10 @@ if ($resql) print '
 '; - print ''; - print ''; + print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; print '
'."\n"; print ''."\n"; - + print ''."\n"; - + $db->free($resql); } else diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ad329a9efbc..c9def11e910 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2571,6 +2571,10 @@ if (!function_exists("llxFooter")) print "\n".''."\n"; print "\n\n"; $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); + // Try to guess the distrib used + $distrib = 'standard'; + if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; + if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; ?>