diff --git a/.travis.yml b/.travis.yml index 1cd0a40bf82..1002216b7cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,15 @@ # We use dist: trusty to have php 5.4+ available os: linux dist: trusty -sudo: required +#sudo: required language: php # Start on every boot services: - memcached +- mysql +- postgresql addons: mariadb: '10.0' @@ -29,60 +31,25 @@ addons: # We need pgloader for import mysql database into pgsql - pgloader -php: -- '5.5' -- '5.6' -- '7.0' -- '7.1' -- '7.2' -- '7.3' -- '7.4' -- nightly - env: global: # Set to true for very verbose output - DEBUG=false - jobs: - # MariaDB overrides MySQL installation so it's not possible to test both yet - #- DB=mysql - - DB=mariadb - - DB=postgresql - # TODO - #- DB=sqlite - # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP - #- WS=apache - # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test - #- WS=nginx jobs: fast_finish: true allow_failures: - php: nightly - # We exclude some combinations not usefull to save Travis CPU - exclude: - - php: '5.6' - env: DB=mariadb - - php: '7.0' - env: DB=mariadb - - php: '7.1' - env: DB=mariadb - - php: '7.2' - env: DB=mariadb - - php: '7.3' - env: DB=mariadb - - php: '5.6' - env: DB=postgresql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - - php: '7.2' - env: DB=postgresql - - php: '7.3' - env: DB=postgresql - - php: nightly - env: DB=postgresql + include: + - if: type = push + php: '5.5' + env: DB=postgresql + - if: type = pull_request OR type = push + php: '7.4' + env: DB=mysql + - if: type = push AND branch = develop + php: nightly + env: DB=mysql notifications: email: @@ -115,11 +82,13 @@ install: echo "Updating Composer" rm $TRAVIS_BUILD_DIR/composer.json rm $TRAVIS_BUILD_DIR/composer.lock + composer -V composer self-update # To have composer making parallel downloads composer global require hirak/prestissimo composer -n init composer -n config vendor-dir htdocs/includes + composer -n config -g vendor-dir htdocs/includes echo - | @@ -148,6 +117,9 @@ install: - | echo "Adding path of binaries tools installed by composer to the PATH" export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" + echo $PATH + ls $TRAVIS_BUILD_DIR/vendor + ls $TRAVIS_BUILD_DIR/htdocs/includes/bin echo @@ -174,15 +146,16 @@ before_script: - | echo "Versions information" + echo # Check PHP echo "PHP version" php -i | head - - # Check PHP CodeSniffer installation + # Check PHP CodeSniffer version echo "PHPCS version" which phpcs phpcs --version | head - phpcs -i | head - - # Check PHPUnit installation + # Check PHPUnit version echo "PHPUnit version" which phpunit phpunit --version | head - @@ -263,10 +236,7 @@ before_script: - 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 - # configure apache virtual hosts for precise - #- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default - #- sudo cat /etc/apache2/sites-available/default - # configure apache virtual hosts for trusty + # configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf - sudo cat /etc/apache2/sites-available/000-default.conf @@ -291,17 +261,18 @@ script: # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --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/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame . + parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --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/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame . set +e echo - | - echo "Checking coding style (excluding Pull Requests builds)" + echo "Checking coding style (excluding Pull Requests builds to not overload travis, excluding also some jobs to avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then + phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; + fi set +e echo @@ -430,7 +401,7 @@ script: after_script: - | - echo "After script - Output lines of dolibarr.log" + echo "After script - Output last lines of dolibarr.log" ls $TRAVIS_BUILD_DIR/documents #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log @@ -456,7 +427,7 @@ after_failure: # Dolibarr log file echo "Debugging informations for file dolibarr.log (latest 50 lines)" tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log - # MariaDB log file + # Database log file echo "Debugging informations for file mysql error.log" sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 48c6bf342a9..169fa27b5bd 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -8,6 +8,7 @@ ALL: Check "@CHANGE" + PrestaShopWebservice: --------------------- Replace @@ -27,6 +28,19 @@ With +DEBUGBAR: +--------- + +Move + this.options = { + bodyMarginBottom: true, + bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')), + }; +few line lower in the + initialize: function() { + + + ESCPOS: ------- Replace diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index e7ec48944e1..7b23ae37d00 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -365,6 +365,7 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date.$separator; print $line->code_journal.$separator; print length_accountg($line->numero_compte).$separator; @@ -373,7 +374,7 @@ class AccountancyExport print price($line->debit).$separator; print price($line->credit).$separator; print 'E'.$separator; - print length_accountg($line->subledger_account).$separator; + print length_accounta($line->subledger_account).$separator; print $end_line; } } @@ -708,8 +709,8 @@ class AccountancyExport foreach ($objectLines as $line) { $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'); + $date_document = dol_print_date($line->doc_date, '%Y%m%d'); + $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal.$separator; @@ -721,25 +722,25 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_creation.$separator; + print $date_document . $separator; // FEC:CompteNum print $line->numero_compte.$separator; // FEC:CompteLib - print $line->label_compte.$separator; + print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum print $line->subledger_account.$separator; // FEC:CompAuxLib - print $line->subledger_label.$separator; + print dol_string_unaccent($line->subledger_label) . $separator; // FEC:PieceRef print $line->doc_ref.$separator; // FEC:PieceDate - print $date_doc.$separator; + print dol_string_unaccent($date_creation) . $separator; // FEC:EcritureLib print $line->label_operation.$separator; @@ -757,7 +758,7 @@ class AccountancyExport print $line->date_lettering.$separator; // FEC:ValidDate - print $date_valid.$separator; + print $date_validation . $separator; // FEC:Montantdevise print $line->multicurrency_amount.$separator; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 699bbf1eebc..415acfbbde0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -863,7 +863,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print " " . $sep; print '"' . $reflabel . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; @@ -893,7 +893,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"' . $key . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; if ($tabtype[$key] == 'payment_supplier') { print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; } elseif($tabtype[$key] == 'payment') { @@ -903,7 +903,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } elseif($tabtype[$key] == 'payment_salary') { print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; } else { - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; } print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . $reflabel . '"' . $sep; @@ -926,7 +926,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; + print '"' . length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print "" . $sep; print '"' . $reflabel . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; @@ -1130,7 +1130,7 @@ if (empty($action) || $action == 'view') { if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"]; - $accounttoshow = length_accounta($account_ledger); + $accounttoshow = length_accountg($account_ledger); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { if ($tabtype[$key] == 'unknown') diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 21bcc17bd42..7c86003fd25 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -286,7 +286,7 @@ if (empty($reshook)) $object->firstname = trim(GETPOST("firstname", 'alphanohtml')); $object->lastname = trim(GETPOST("lastname", 'alphanohtml')); $object->gender = trim(GETPOST("gender", 'alphanohtml')); - $object->login = trim(GETPOST("login", 'alpha')); + $object->login = trim(GETPOST("login", 'alphanohtml')); $object->pass = trim(GETPOST("pass", 'alpha')); $object->societe = trim(GETPOST("societe", 'alphanohtml')); // deprecated @@ -459,7 +459,7 @@ if (empty($reshook)) // $facebook=GETPOST("member_facebook", 'alpha'); // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $login = GETPOST("member_login", 'alpha'); + $login = GETPOST("member_login", 'alphanohtml'); $pass = GETPOST("password", 'alpha'); $photo = GETPOST("photo", 'alpha'); //$comment=GETPOST("comment",'none'); @@ -941,7 +941,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'" autofocus="autofocus">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'" autofocus="autofocus">'; } // Password @@ -1181,7 +1181,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; } // Password diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 10eca32ac13..762a7d666c7 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -183,9 +183,9 @@ foreach ($data as $val) $oldyear--; print ''; print ''; - print ''; + //print ''; print $oldyear; - print ''; + //print ''; print ''; print '0'; print '0'; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index f2fa67eba57..67596fc9193 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -41,12 +41,31 @@ $action = GETPOST('action', 'alpha'); /* * Action */ + +$reg = array(); + if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code=$reg[1]; + + // If constant is for a unique choice, delete other choices + if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); + } + if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); + } + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else @@ -114,7 +133,7 @@ print ''; if (! empty($conf->facture->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_BILL'); + print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); @@ -134,7 +153,7 @@ print ''; if (! empty($conf->commande->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER'); + print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); @@ -156,7 +175,7 @@ print ''; if (! empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); @@ -176,7 +195,7 @@ print ''; if (! empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); @@ -189,18 +208,12 @@ else print "\n\n"; $found++; -/*if (! $found) -{ - - print ''; - print ''.$langs->trans("NoModuleToManageStockDecrease").''; - print "\n"; -}*/ - print ''; + print '
'; + // Title rule for stock increase print ''; print ''; @@ -216,7 +229,7 @@ print ''; + print ''; print '
'; if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); @@ -237,7 +250,7 @@ print ''; if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); @@ -257,7 +270,7 @@ if (!empty($conf->reception->enabled)) print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION'); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); @@ -272,7 +285,7 @@ if (!empty($conf->reception->enabled)) print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE'); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); @@ -288,7 +301,7 @@ else if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 6bbaeb7c6c8..e168f5fbdc0 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -302,7 +302,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
'; print '
'.$langs->trans('ExportStructure').''; - print ''; + print ''; print ''; print '
'; print '
'; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 56602502715..e71088da27a 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2020 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 @@ -42,6 +43,8 @@ $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); $type = 'user'; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 46431cdb510..89450c57366 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -32,7 +32,7 @@ class DolibarrApi /** * @var DoliDb $db Database object */ - protected static $db; + protected $db; /** * @var Restler $r Restler object diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 77d6718ed17..75ab4cd8414 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -781,8 +781,8 @@ class Categorie extends CommonObject $objs = array(); - $tmpclass = $this->MAP_OBJ_CLASS[$type]; - $obj = new $tmpclass($this->db); + $classnameforobj = $this->MAP_OBJ_CLASS[$type]; + $obj = new $classnameforobj($this->db); $sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type]; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c"; @@ -810,8 +810,11 @@ class Categorie extends CommonObject } else { - $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); - $obj->fetch($rec['fk_'.$this->MAP_CAT_FK[$type]]); + $classnameforobj = $this->MAP_OBJ_CLASS[$type]; + + $obj = new $classnameforobj($this->db); + $obj->fetch($rec['fk_' . $this->MAP_CAT_FK[$type]]); + $objs[] = $obj; } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0962fcd63b6..938775d726d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2019 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2010-2017 Philippe Grand * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -2992,9 +2992,9 @@ class Propal extends CommonObject if (!$error) { - $main = MAIN_DB_PREFIX . 'propaldet'; - $ef = $main . "_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = " . $this->id . ")"; + $main = MAIN_DB_PREFIX . 'propaldet'; + $ef = $main . "_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = " . $this->id . ")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; if ($this->db->query($sqlef) && $this->db->query($sql)) { @@ -3011,6 +3011,9 @@ class Propal extends CommonObject if (!$error) { + // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive + $this->deleteEcmFiles(); + // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e356a4d5936..cc104261010 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -3461,6 +3461,9 @@ class Commande extends CommonOrder if (! $error) { + // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive + $this->deleteEcmFiles(); + // Remove directory with files $comref = dol_sanitizeFileName($this->ref); if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 6573207a117..cc2a5bd5283 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -51,8 +51,12 @@ $sens = GETPOST("sens", "int"); $amount = price2num(GETPOST("amount", "alpha")); $paymenttype = GETPOST("paymenttype", "int"); $accountancy_code = GETPOST("accountancy_code", "alpha"); -$subledger_account = GETPOST("subledger_account", "alpha"); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); +if (!empty($conf->accounting->enabled) && !empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : ''; +} else { + $subledger_account = GETPOST("subledger_account", "alpha"); +} // Security check $socid = GETPOST("socid", "int"); @@ -115,7 +119,7 @@ if (empty($reshook)) $object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account = GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; + $object->subledger_account = $subledger_account; $object->sens = GETPOST('sens'); $object->fk_project = GETPOST('fk_project', 'int'); @@ -219,9 +223,11 @@ if (empty($reshook)) } if ($action == 'setsubledger_account') { + $db->begin(); + $result = $object->fetch($id); - $object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""); + $object->subledger_account = $subledger_account; $res = $object->update($user); if ($res > 0) { @@ -386,7 +392,7 @@ if ($action == 'create') // Subledger account if (!empty($conf->accounting->enabled)) { - print '
'.$langs->trans("SubledgerAccount").'
'.$langs->trans("SubledgerAccount").'aaaa'; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 95d84954490..3198b34a34d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -58,7 +58,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="v.datep,v.rowid"; -if (! $sortorder) $sortorder="DESC"; +if (! $sortorder) $sortorder="DESC,DESC"; $filtre=GETPOST("filtre", 'alpha'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fd6dd0baad0..31c42e5ba9e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -439,15 +439,36 @@ if (empty($reshook)) $object->fetch($id); $object->cond_reglement_code = 0; // To clean property $object->cond_reglement_id = 0; // To clean property - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - $old_date_lim_reglement = $object->date_lim_reglement; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); + $error = 0; + + $db->begin(); + + if (! $error) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if (! $error) { + $old_date_lim_reglement = $object->date_lim_reglement; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } } elseif ($action == 'setpaymentterm' && $usercancreate) @@ -976,6 +997,7 @@ if (empty($reshook)) elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + $selectedLines = GETPOST('toselect', 'array'); $db->begin(); @@ -1565,8 +1587,11 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + // Don't add lines with qty 0 when coming from a shipment including all order lines if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) @@ -3626,8 +3651,6 @@ if ($action == 'create') print ''; print ''; - print "\n"; - // Show origin lines if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '
'; @@ -3637,12 +3660,12 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; } - print '
'; + print "\n"; } elseif ($id > 0 || !empty($ref)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d3c9ae19721..b41d2eaa9b9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Cédric Salvador @@ -416,7 +416,7 @@ class Facture extends CommonInvoice $this->brouillon = 1; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -2185,6 +2185,9 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { + // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive + $this->deleteEcmFiles(); + // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); if ($conf->facture->dir_output && !empty($this->ref)) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index e800c569c91..0f6b5ba4670 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -53,6 +53,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inv $socid = GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); + // Security check $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $lineid = GETPOST('lineid', 'int'); @@ -151,6 +153,11 @@ if ($socid > 0) { } +if ($socid > 0) { + $tmpthirdparty = new Societe($db); + $res = $tmpthirdparty->fetch($socid); + if ($res > 0) $search_societe = $tmpthirdparty->name; +} /* * Actions diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 936fbebcf6e..9b9e8e08ce5 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -180,6 +180,7 @@ print '
'; $limit=5; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql.= " WHERE entity IN (" . getEntity('prelevement') . ")"; $sql.= " ORDER BY datec DESC"; $sql.= $db->plimit($limit); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 5bb50d825fc..bb4ddc7c5d0 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -56,6 +56,8 @@ $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +$categorie = new Categorie($db); + // product/service $selected_type = GETPOST('search_type', 'int'); if ($selected_type =='') $selected_type = -1; @@ -233,10 +235,6 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } - elseif ($selected_cat) // Into a specific category - { - $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; - } $sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; $sql.= " AND l.product_type in (0,1)"; @@ -257,10 +255,22 @@ if ($modecompta == 'CREANCES-DETTES') $sql.=" AND cp.fk_product is null"; } elseif ($selected_cat) { // Into a specific category - $sql.= " AND (c.rowid = ".$selected_cat; - if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; - $sql.= ")"; - $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; + if ($subcat) { + $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); + + $listofcatsql = ""; + foreach ($TListOfCats as $key => $cat) + { + if ($key !== 0) $listofcatsql .= ","; + $listofcatsql .= $cat['rowid']; + } + } + + $sql.= " AND (p.rowid IN "; + $sql .= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE "; + if ($subcat) $sql .= "cp.fk_categorie IN (". $listofcatsql.")"; + else $sql.="cp.fk_categorie = ".$selected_cat; + $sql.= "))"; } if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; $sql.= " AND f.entity IN (".getEntity('invoice').")"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index f0f65071207..d555c50372a 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1254,6 +1254,11 @@ else } } + // Select mail models is same action as presend + if (GETPOST('modelselected', 'alpha')) { + $action = 'presend'; + } + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d51399d21a9..e06733615ce 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -410,8 +410,8 @@ else $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; @@ -421,14 +421,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); -$result = $db->query($sql); -if (!$result) +$resql = $db->query($sql); +if (! $resql) { dol_print_error($db); exit; } -$num = $db->num_rows($result); +$num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -784,7 +784,7 @@ $i = 0; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true); $contactstatic->lastname = $obj->lastname; @@ -984,7 +984,7 @@ while ($i < min($num, $limit)) $i++; } -$db->free($result); +$db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 9581d625f80..dbdba874dda 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2018 Ferran Marcet * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 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 @@ -1264,7 +1264,7 @@ if ($action == 'create') // Other attributes if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'create', $parameters); } print "
\n"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9d90520e1d7..8390fda0c28 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -820,7 +820,8 @@ class Contrat extends CommonObject $sql .= " d.fk_user_author,"; $sql .= " d.fk_user_ouverture,"; $sql .= " d.fk_user_cloture,"; - $sql .= " d.fk_unit"; + $sql .= " d.fk_unit,"; + $sql .= " d.product_type"; $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql .= " WHERE d.fk_contrat = ".$this->id; $sql .= " ORDER by d.rowid ASC"; @@ -860,6 +861,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; + $line->type = $objp->type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -872,7 +874,8 @@ class Contrat extends CommonObject $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Product Ref - $line->product_desc = $objp->product_desc; // Product Description + $line->product_type = $objp->product_type; // Product Type + $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label $line->description = $objp->description; @@ -1234,8 +1237,8 @@ class Contrat extends CommonObject } } - if (!$error) - { + // Delete lines + if (!$error) { // Delete contratdet extrafields $main = MAIN_DB_PREFIX . 'contratdet'; $ef = $main . "_extrafields"; @@ -1265,9 +1268,21 @@ class Contrat extends CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + + // Delete contract if (!$error) { - // Delete contrat $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; $sql .= " WHERE rowid=".$this->id; @@ -2674,6 +2689,7 @@ class ContratLigne extends CommonObjectLine */ public $description; + public $product_type; // 0 for product, 1 for service public $product_ref; public $product_label; diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 346b17e3288..77245c22494 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -75,7 +75,7 @@ if ($time >= $_SESSION['auto_check_events_not_before']) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']); + dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); $sql = 'SELECT id'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar'; diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 2df1f0d331e..4f7eb6890b4 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -89,7 +89,8 @@ class box_birthdays extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); + $sql.= " AND u.statut = 1"; + $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql.= " ORDER BY u.birth ASC"; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 10b9c52acb0..b3b62035783 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -105,7 +105,7 @@ class box_commandes extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('commande').")"; if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index caea252c571..7141728c23d 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -94,7 +94,7 @@ class box_contacts extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; $sql .= " ORDER BY sp.tms DESC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 19e70f7b0b4..384618c9afc 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -91,7 +91,7 @@ class box_propales extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity = ".$conf->entity; + $sql .= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index dbb26408b6f..00daf2f05ac 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -91,7 +91,7 @@ class box_services_contracts extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as product_type, p.entity"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -121,6 +121,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->label=$objp->label; $contractlinestatic->description=$objp->description; $contractlinestatic->type=$objp->type; + $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->product_id=$objp->product_id; $contractlinestatic->product_ref=$objp->product_ref; @@ -164,21 +165,21 @@ class box_services_contracts extends ModeleBoxes $productstatic->type=$objp->ptype; $productstatic->ref=$objp->product_ref; $productstatic->entity=$objp->pentity; - $productstatic->label=$objp->plabel; + $productstatic->label=$objp->product_label; $text = $productstatic->getNomUrl(1, '', 20); - if ($objp->plabel) + if ($objp->product_label) { $text .= ' - '; //$productstatic->ref=$objp->label; //$text .= $productstatic->getNomUrl(0,'',16); - $text .= $objp->plabel; + $text .= $objp->product_label; } $description = $objp->description; // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; + //$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc } diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 26f45bc08db..4603450b482 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -104,7 +104,7 @@ class box_shipments extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql .= " WHERE e.entity = ".$conf->entity; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sc.fk_user = ".$user->id; else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 881e17f73ec..26bcd859f39 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -95,7 +95,7 @@ class box_supplier_orders extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 416dc7f2f2a..b1f53d2de20 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -95,7 +95,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; $sql.= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 94983ef6bff..1daf8ea6222 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2019 Frederic France +/* Copyright (C) 2012-2018 Charlene BENKE + * Copyright (C) 2015-2020 Frederic 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 @@ -184,7 +184,7 @@ class box_task extends ModeleBoxes $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; $taskstatic->fk_statut = $objp->fk_statut; - $taskstatic->date_end = $objp->datee; + $taskstatic->date_end = $this->db->jdate($objp->datee); $taskstatic->planned_workload = $objp->planned_workload; $taskstatic->duration_effective = $objp->duration_effective; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 454673fe55b..76a9fc09a38 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -486,6 +486,9 @@ class CMailFile { //$this->message->attach(Swift_Attachment::fromPath($filename_list[$i],$mimetype_list[$i])); $attachment = Swift_Attachment::fromPath($filename_list[$i], $mimetype_list[$i]); + if (!empty($mimefilename_list[$i])) { + $attachment->setFilename($mimefilename_list[$i]); + } $this->message->attach($attachment); } } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 4a8e097fd6d..9f5dac2a0c3 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -513,7 +513,7 @@ abstract class CommonDocGenerator // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { - $extrafieldkey = $object->element; + $extrafieldkey = $object->table_element; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e104b82642d..1ff633f46ce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2019 Philippe Grand * Copyright (C) 2012-2015 Marcos García @@ -6848,6 +6848,9 @@ abstract class CommonObject var parent = $(this).find("option[parent]:first").attr("parent"); var infos = parent.split(":"); var parent_list = infos[0]; + showOptions(child_list, parent_list); + + /* Activate the handler to call showOptions on each future change */ $("select[name=\""+parent_list+"\"]").change(function() { showOptions(child_list, parent_list); }); @@ -7543,18 +7546,17 @@ abstract class CommonObject $now = dol_now(); $fieldvalues = $this->setSaveQuery(); - if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); - $values = array(); + $values = array(); // Array to store string forged for SQL syntax foreach ($fieldvalues as $k => $v) { $keys[$k] = $k; $value = $this->fields[$k]; - $values[$k] = $this->quote($v, $value); + $values[$k] = $this->quote($v, $value); // May return string 'NULL' if $value is null } // Clean and check mandatory @@ -7564,8 +7566,7 @@ abstract class CommonObject if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; - //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); - if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($this->fields[$key]['default'])) + if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && (!isset($values[$key]) || $values[$key] === 'NULL') && is_null($this->fields[$key]['default'])) { $error++; $this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); @@ -7946,6 +7947,18 @@ abstract class CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + if (!$error && !empty($this->isextrafieldmanaged)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; @@ -8252,4 +8265,49 @@ abstract class CommonObject $this->db->commit(); return 1; } + + /** + * Delete related files of object in database + * + * @return bool + */ + public function deleteEcmFiles() + { + global $conf; + + $this->db->begin(); + + switch ($this->element){ + case 'propal': + $element = 'propale'; + break; + case 'product': + $element = 'produit'; + break; + case 'order_supplier': + $element ='fournisseur/commande'; + break; + case 'invoice_supplier': + $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); + break; + case 'shipping': + $element = 'expedition/sending'; + break; + default: + $element = $this->element; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql.= " AND filepath = '".$element."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return false; + } + + $this->db->commit(); + return true; + } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f938426d4ba..57e2bf4284a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1273,7 +1273,7 @@ class ExtraFields dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; + $out .= ''; $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { @@ -1327,7 +1327,7 @@ class ExtraFields } else { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); - $out .= ''; + $out .= ''; foreach ($data as $data_key => $data_value) { $out .= '